:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-border: #111111;
  --text: #111111;
  --muted: #555555;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  padding: 20px;
  overflow: hidden; /* the page always fits one viewport; only the chat thread scrolls */
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100dvh - 40px);
}

.topbar,
.canvas-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
}

.topbar {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.brand {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#query {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #111111;
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 160ms ease;
}

#query::placeholder {
  color: #777777;
}

#query:focus {
  border-color: #000000;
}

.matches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.matches:empty {
  display: none;
}

.chip {
  padding: 3px 12px;
  border: 1px solid #111111;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  background: #ffffff;
}

.chip-modifier {
  border-style: dashed;
  color: #444444;
}

.chip-unknown {
  border-color: #bbbbbb;
  color: #999999;
}

.chip-click {
  cursor: pointer;
  text-decoration: none;
  color: #111111;
}

.chip-click:hover {
  background: #111111;
  color: #ffffff;
}

.topbar {
  position: relative;
}

.nav {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 14px;
}

.nav a {
  color: #555555;
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.nav a:hover {
  color: #000000;
}

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.social a {
  text-decoration: none;
}

.mini-input {
  padding: 8px 14px;
  border: 1px solid #111111;
  border-radius: 999px;
  font-size: 0.85rem;
  outline: none;
  background: #ffffff;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding: 4px 6px 10px;
}

.msg {
  align-self: flex-start;
  max-width: 320px;
}

.msg-mine {
  align-self: flex-end;
  text-align: right;
}

.msg-canvas {
  border: 1px solid #111111;
  border-radius: 8px;
  background: #ffffff;
  display: block;
}

.msg-mine .msg-canvas {
  border-style: dashed;
}

.msg-meta {
  font-size: 0.72rem;
  color: #999999;
  margin-top: 3px;
  letter-spacing: 0.03em;
}

.msg-meta a {
  color: #999999;
  text-decoration: none;
}

.msg-meta a:hover {
  color: #000000;
}

.msg-quote {
  font-size: 0.72rem;
  color: #777777;
  border-left: 2px solid #cccccc;
  padding-left: 8px;
  margin-bottom: 4px;
  font-style: italic;
}

.chip-selected {
  background: #111111;
  color: #ffffff !important;
}

#visual-canvas.drawing {
  cursor: crosshair;
}

/* while a chat is open, the canvas compacts so the thread and the
   live compose preview are both on screen */
body.chat-open #visual-canvas {
  flex: 0 0 min(30vh, 320px);
}

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #111111;
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  z-index: 10;
}

.canvas-panel {
  padding: 16px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#visual-canvas {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #111111;
  touch-action: none; /* finger-drawing must not scroll the page */
}

@media (max-width: 720px) {
  body {
    padding: 12px;
  }

  .app-shell {
    height: calc(100dvh - 24px);
  }

  .canvas-panel {
    border-radius: 12px;
  }

  .topbar,
  .canvas-panel {
    padding: 12px;
  }

  /* on phones the nav flows under the brand instead of overlapping it */
  .nav {
    position: static;
    margin-top: -6px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .msg,
  .msg-canvas {
    max-width: 100%;
  }

  .msg-canvas {
    height: auto; /* keep the drawing's aspect when width is squeezed */
  }
}
