* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;
  --page-bg: #0f1117;
  --surface: #171a21;
  --surface-alt: #1d2230;
  --border: #2b3140;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --user-bg: #1f3a8a;
  --user-text: #eff6ff;
  --assistant-bg: #202635;
  --assistant-text: #f8fafc;
  --button-bg: #10a37f;
  --button-bg-hover: #0d8b6a;
}

body {
  font-family: system-ui, sans-serif;
  height: 100vh;
  background:
    radial-gradient(circle at top, rgba(16, 163, 127, 0.14), transparent 30%),
    var(--page-bg);
  color: var(--text);
  padding: 12px;
}

/* Full-height flex column: top-bar → pane → input */
.layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  gap: 8px;
}

.top-bar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 4px;
  flex-shrink: 0;
}

.top-bar h1 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.top-bar p {
  color: var(--muted);
  font-size: 13px;
}

.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
}

/* Scrollable message feed */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

/* Chat bubbles */
.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(180deg, #2563eb, var(--user-bg));
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--assistant-bg);
  color: var(--assistant-text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Blinking cursor while waiting */
.msg.thinking::after {
  content: "▌";
  animation: blink 0.8s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Markdown: code blocks and inline code */
.msg pre {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 6px 0;
}

.msg code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 13px;
}

.msg :not(pre) > code {
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 5px;
  border-radius: 4px;
}

/* Shared input bar at the bottom */
.input-row {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  flex-shrink: 0;
}

.input-row textarea {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  outline: none;
}

.input-row textarea::placeholder {
  color: #64748b;
}

.input-row textarea:focus {
  border-color: rgba(16, 163, 127, 0.9);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.16);
}

.input-row button {
  padding: 0 20px;
  border-radius: 10px;
  border: none;
  background: var(--button-bg);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  min-width: 80px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.input-row button:hover:not(:disabled) {
  background: var(--button-bg-hover);
}

.input-row button:active:not(:disabled) {
  transform: translateY(1px);
}

.input-row button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Edge-to-edge on small screens */
@media (max-width: 768px) {
  body { padding: 0; height: 100dvh; }
  .layout { border-radius: 0; gap: 0; }
  .input-row { border-radius: 0; border-left: none; border-right: none; border-bottom: none; }
  .msg { max-width: 92%; }
}

/* Tool call: the lookup the model asked for, and what came back */
.msg.tool {
  align-self: stretch;
  max-width: 100%;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
}

.msg.tool pre {
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.tool img {
  display: block;
  margin-top: 8px;
  border-radius: 8px;
  background: white;
  max-width: 320px;
}

/* In-app manual: what the tools are and what to type to reach them */
.manual {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-shrink: 0;
  font-size: 13px;
}

.manual > summary {
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  list-style: none;
}

.manual > summary::before {
  content: "▸ ";
}

.manual[open] > summary::before {
  content: "▾ ";
}

.manual > summary:hover {
  color: var(--text);
}

.manual__body {
  padding: 0 14px 12px;
  display: grid;
  gap: 8px;
}

.manual__intro {
  color: var(--muted);
  line-height: 1.5;
  max-width: 80ch;
}

/* Example | description | tool name, collapsing to one column when narrow */
.manual__row {
  display: grid;
  grid-template-columns: minmax(200px, 22rem) 1fr auto;
  gap: 4px 14px;
  align-items: baseline;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.manual__ask {
  text-align: left;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}

.manual__ask:hover {
  border-color: rgba(16, 163, 127, 0.9);
}

.manual__detail {
  color: var(--muted);
  line-height: 1.5;
}

.manual__name {
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
}

@media (max-width: 768px) {
  .manual { border-radius: 0; border-left: none; border-right: none; }
  .manual__row { grid-template-columns: 1fr; }
  .manual__name { display: none; }
}

/* Demo seat status: shown while joining, when the demo is full, or when sign-in is missing. */
.status {
  margin: 0;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.9rem;
}

/* Sign in with Google */
.signin {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
}
.signin p {
  margin: 0;
}
.signin__error {
  color: #f87171;
}
.account {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.link-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
