:root {
  color-scheme: light dark;
  --bg: light-dark(#f7f7f8, #17181b);
  --surface: light-dark(#fff, #212226);
  --quiet: light-dark(#f0edf8, #252332);
  --bubble: light-dark(#ebe8f4, #2c293b);
  --ink: light-dark(#242232, #eeedf4);
  --muted: light-dark(#5e5a70, #b9b5c7);
  --border: light-dark(#d9d5e1, #3c3948);
  --accent: light-dark(#533b8e, #cbbaff);
  --on-accent: light-dark(#fff, #21143e);
  --error: light-dark(#8c2542, #fbb1c2);
  --shadow: light-dark(#29244912, #0004);
  --column: 48rem;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p { margin: 0; }
button, textarea, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .56; }
button:focus-visible, select:focus-visible, summary:focus-visible, input:focus-visible, main:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
svg { width: 1.125rem; height: 1.125rem; flex: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.workspace { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; }
.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner { max-width: 72rem; min-height: 4.25rem; margin-inline: auto; padding: .65rem clamp(.75rem, 3.5vw, 2rem); display: flex; align-items: center; justify-content: space-between; gap: .625rem; }
.brand, .actions { display: flex; align-items: center; gap: .625rem; }
.brand h1 { font-size: 1rem; line-height: 1.3; white-space: nowrap; }
.brand p { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.mark { width: 2.25rem; height: 2.25rem; display: inline-grid; flex: none; place-items: center; border-radius: .8rem; background: var(--quiet); color: var(--accent); }
.mark svg { width: 1.375rem; height: 1.375rem; }
.button { min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .4rem .8rem; border-radius: .7rem; border: 1px solid var(--border); background: var(--surface); font-size: .875rem; font-weight: 650; white-space: nowrap; }
.button:not(:disabled):hover { background: var(--quiet); }
.primary, .primary:not(:disabled):hover { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.primary:not(:disabled):hover { filter: brightness(.92); }
.theme-picker { min-width: 0; display: flex; align-items: center; position: relative; color: var(--muted); }
.theme-picker svg { position: absolute; inset-inline-start: .5rem; pointer-events: none; }
.theme-picker select { min-height: 2.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: .7rem; padding: .35rem .4rem .35rem 1.85rem; font-size: .8125rem; cursor: pointer; }
#viewport { min-height: 0; overflow: auto; scrollbar-gutter: stable both-edges; overscroll-behavior: contain; overflow-anchor: none; }
.welcome, .messages { width: min(var(--column), 100%); margin-inline: auto; padding-inline: clamp(.8rem, 3vw, 1.5rem); }
.welcome { padding-block: clamp(2rem, 12vh, 8rem) 1.25rem; }
.eyebrow { display: block; margin-bottom: .55rem; font-size: .73rem; font-weight: 720; letter-spacing: .14em; color: var(--accent); }
.welcome h2 { font-size: clamp(1.9rem, 5vw, 3.3rem); font-weight: 680; line-height: 1.13; letter-spacing: -.045em; }
.welcome p { max-width: 37ch; margin-top: .75rem; color: var(--muted); }
.messages { display: grid; gap: 1.5rem; padding-block: 1.4rem 1.6rem; }
.turn { min-width: 0; }
.turn h2 { color: var(--muted); margin: 0 0 .4rem; font-size: .79rem; font-weight: 680; }
.turn.user { justify-self: end; max-width: min(90%, 39rem); padding: .7rem .95rem; border: 1px solid var(--border); border-radius: 1rem 1rem .35rem 1rem; background: var(--bubble); }
.turn.assistant { width: 100%; }
.message-text, .reasoning-text { white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.answer { line-height: 1.72; }
.reasoning { margin-bottom: .85rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--quiet); color: var(--ink); }
.reasoning summary { padding: .6rem .8rem; border-radius: .75rem; cursor: pointer; color: var(--accent); font-weight: 680; font-size: .875rem; }
.reasoning-text { margin: 0 .85rem .8rem; padding-inline-start: .75rem; border-inline-start: 2px solid var(--border); font-size: .9375rem; line-height: 1.66; }
.reasoning:not([open]) .reasoning-text { display: none; }
.pending, .notice { color: var(--muted); font-size: .875rem; }
.notice:not(:empty) { margin-top: .7rem; }
.notice[data-error="true"], .composer [data-error="true"], .login-card #status { color: var(--error); }
.dock { position: relative; padding: .7rem .8rem max(.45rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg); }
.composer { max-width: var(--column); margin: auto; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); box-shadow: 0 3px 16px var(--shadow); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { display: block; field-sizing: content; width: 100%; min-height: 3.1rem; max-height: min(11rem, 34dvh); padding: .75rem .9rem .35rem; resize: none; border: 0; border-radius: 1rem; outline: none; background: transparent; }
textarea::placeholder { color: var(--muted); opacity: 1; }
.composer-bar { min-height: 3rem; padding: .225rem .45rem .4rem .8rem; display: flex; justify-content: flex-end; align-items: center; gap: .5rem; }
.composer-bar #status { margin-right: auto; min-width: 0; font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.privacy { margin-top: .35rem; text-align: center; color: var(--muted); font-size: .75rem; }
.jump { position: absolute; bottom: calc(100% + .45rem); right: max(.9rem, calc((100% - var(--column)) / 2)); z-index: 1; box-shadow: 0 2px 12px var(--shadow); }
.login-page { min-height: 100dvh; padding: 1.5rem; display: grid; place-items: center; }
.login-card { width: min(100%, 26rem); padding: clamp(1rem, 5vw, 2.25rem); background: var(--surface); border: 1px solid var(--border); border-radius: 1.25rem; box-shadow: 0 6px 32px var(--shadow); }
.login-card .mark { margin-bottom: .85rem; }
.login-card h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.035em; }
.login-card p { color: var(--muted); }
.login-card form { margin-top: 1.25rem; display: grid; gap: .45rem; }
.login-card label { color: var(--muted); font-size: .875rem; }
.login-card input { width: 100%; min-height: 2.75rem; margin-bottom: .35rem; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--bg); }
.login-card #status { font-size: .875rem; }
.login-card #status:empty { display: none; }
@media (width <= 530px) {
  .brand, .actions { gap: .4rem; }
  .brand .mark { width: 1.875rem; height: 1.875rem; }
  .theme-picker svg { display: none; }
  .theme-picker select { padding-inline: .25rem; }
  .topbar .button { padding-inline: .5rem; }
  .topbar .button svg { display: none; }
  #viewport { scrollbar-gutter: auto; }
  .dock { padding-top: .4rem; }
  .privacy { font-size: .6875rem; }
}
@media (height <= 460px) {
  .topbar-inner { min-height: 3.3rem; padding-block: .25rem; }
  .welcome { padding-top: 1rem; }
  .composer textarea { min-height: 2.4rem; }
}
