:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --accent: #5b4bdb;
  --accent-text: #ffffff;
  --user: #e7e4ff;
  --border: #d8d8de;
  --danger: #c0392b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131316;
    --surface: #1e1e23;
    --text: #ececf1;
    --muted: #9a9aa3;
    --accent: #8a7dff;
    --accent-text: #101014;
    --user: #2b2857;
    --border: #33333b;
    --danger: #ff7b6b;
  }
}

* { box-sizing: border-box; }
/* Author rules like `display: grid` would otherwise override the hidden attribute. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, "Segoe UI", sans-serif; }
button { font: inherit; cursor: pointer; border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; background: var(--surface); color: var(--text); }
button[type="submit"], #send { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
#send.stop { background: var(--danger); border-color: var(--danger); color: #fff; }
h1, h2 { margin: 0; }
h2 { font-size: 0.85rem; color: var(--muted); margin-top: 14px; text-transform: uppercase; letter-spacing: 0.04em; }

#banner { position: fixed; top: 0; left: 0; right: 0; padding: 8px 16px; text-align: center; background: var(--danger); color: #fff; z-index: 10; }

.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; display: grid; gap: 12px; }
.login-card input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.error { color: var(--danger); min-height: 1.4em; margin: 0; }

.chat { height: 100%; height: 100dvh; display: flex; flex-direction: column; max-width: 820px; margin: 0 auto; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; }
.panel { margin: 0 16px 8px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; max-height: 50vh; overflow-y: auto; }
.panel pre { white-space: pre-wrap; margin: 4px 0; font: 0.85rem/1.4 ui-monospace, Consolas, monospace; color: var(--muted); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.choice.selected { border-color: var(--accent); font-weight: 600; }
.actions { display: flex; gap: 8px; margin-top: 14px; }

.messages { flex: 1; overflow-y: auto; padding: 8px 16px; display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); text-align: center; margin-top: 30vh; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--user); border-color: transparent; white-space: pre-wrap; }
.bubble.assistant p, .bubble.assistant ul { margin: 0 0 8px; white-space: pre-wrap; }
.bubble.assistant > :last-child { margin-bottom: 0; }
.bubble.assistant pre { margin: 0 0 8px; padding: 10px; overflow-x: auto; background: var(--bg); border-radius: 10px; }
.bubble code { font: 0.9em ui-monospace, Consolas, monospace; }
.thinking { color: var(--muted); }
.note { align-self: center; color: var(--muted); font-size: 0.9rem; }

.composer { display: flex; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; font: inherit; resize: none; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); max-height: 200px; }
