/* Loci app shell: "settled water", in CSG colour and type (see the approved mock's DIRECTION.md).
 * Brand values come from tokens.css; this file maps them to roles. Its few literal colours are tints of brand
 * colours, plus the lifted shades the dark theme needs. Chart colours live in charts/charts.css. */

@font-face { font-family: Inter; src: url("/fonts/InterVariable.ttf") format("truetype"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("/fonts/BarlowCondensed-Medium.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  --side-w: 276px;
  --col: 704px;
  --fig: 880px;
  --ease: cubic-bezier(.22, .72, .18, 1);
  --ease-out: var(--ease-standard);

  /* surfaces */
  --paper: var(--bg);            /* off-white */
  --sheet: var(--surface);       /* white */
  --side: var(--surface);
  --side-active: #EEEEF4;
  --sunk: #EDEDF3;
  /* ink */
  --ink: var(--fg);              /* midnight */
  --ink-2: var(--muted);
  --ink-3: #66667E;              /* a step darker than tokens --meta so small text clears AA on off-white */
  --ink-4: #9C9CB1;
  --rule: #E2E2EA;
  --rule-2: #CDCDDA;
  /* roles: cobalt is Loci and the clear water, navy the settled layer, ochre what to notice, coral limits only */
  --loci: var(--accent);
  --loci-fill: var(--accent);
  --loci-hover: var(--accent-hover);
  --loci-ink: var(--accent-active);
  --loci-soft: #E8F0FF;
  --hist: var(--fg-2);
  --hist-fill: var(--fg-2);
  --mem: var(--ochre);
  --mem-ink: #8A5800;
  --limit: var(--coral);
  --limit-ink: #C21F1F;
  --limit-soft: #FDECEC;
  --focus: var(--accent);
  --shadow-1: 0 1px 2px rgba(0, 0, 51, .06);
  --shadow-2: var(--elev-raised);
  --shadow-3: 0 2px 8px rgba(0, 0, 51, .08), 0 28px 64px -18px rgba(0, 0, 51, .3);
  --scrim: rgba(0, 0, 51, .32);
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: var(--bg);            /* midnight */
  --sheet: var(--surface-warm);  /* deep navy */
  --side: #03033B;
  --side-active: var(--surface); /* navy */
  --sunk: #07063F;
  --ink-3: var(--meta);
  --ink-4: #7C7CA0;
  --rule: rgba(255, 255, 255, .12);
  --rule-2: rgba(255, 255, 255, .22);
  --loci: #4D8DFF;               /* cobalt, lifted to read on navy */
  --loci-fill: #337CFF;
  --loci-hover: #4D8DFF;
  --loci-ink: #A9C6FF;
  --loci-soft: rgba(0, 92, 255, .22);
  --hist: #B9B3F6;               /* navy, lifted to lavender so history shows on midnight */
  --hist-fill: #9B93EE;
  --mem: #F7B53B;
  --mem-ink: #FFCB66;
  --limit: #FF5C5C;
  --limit-ink: #FF9494;
  --limit-soft: rgba(242, 48, 48, .17);
  --focus: #4D8DFF;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-3: 0 2px 8px rgba(0, 0, 0, .4), 0 30px 80px -20px rgba(0, 0, 0, .75);
  --scrim: rgba(0, 0, 20, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.6 var(--font-body);
  font-optical-sizing: auto;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
::selection { background: color-mix(in srgb, var(--loci) 24%, transparent); }
svg { display: block; }
em { font-style: normal; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.noscript { padding: 24px; font-size: 15px; }

/* small uppercase labels: Barlow Condensed, the industrial voice */
.side-h, .voice-l, .ex-h, .wk-kv dt, .h {
  font-family: var(--font-display); font-weight: 500; text-transform: uppercase; letter-spacing: .07em;
}

/* ───────────── shell ───────────── */

.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.app.vv { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); }

.side {
  background: var(--side); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; padding: 18px 14px 14px; min-height: 0; min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand .mark { width: 26px; height: 26px; color: var(--ink); }
.brand-name { font-family: var(--font-display); font-size: 31px; font-weight: 500; letter-spacing: .01em; line-height: 1; }
.scrim { display: none; }
.mark .mk-water, .mark .mk-floc { fill: var(--loci); }

.new-q {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; margin-bottom: 18px;
  border-radius: var(--radius-md); background: var(--sheet); border: 1px solid var(--rule-2);
  box-shadow: var(--shadow-1); font-weight: 550; font-size: 14px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
}
.new-q:hover { border-color: var(--loci); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.new-q svg { width: 16px; height: 16px; color: var(--loci); }

.side-scroll {
  flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px 22px; min-height: 0;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 30px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 30px), transparent);
}
.side-h { font-size: 13px; color: var(--ink-3); padding: 0 10px 6px; }
.chats { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.chats-empty { padding: 8px 10px; font-size: 13px; color: var(--ink-3); line-height: 1.5; }
.chat-row { position: relative; }
.chat-link {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px;
  border-radius: var(--radius-md); position: relative; transition: background-color .18s var(--ease);
}
.chat-row:hover .chat-link { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.chat-row.active .chat-link { background: var(--side-active); }
.chat-row.active .chat-link::before { content: ''; position: absolute; left: -6px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--loci); }
.tl-t { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-m { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.tl-m i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: none; }
.tl-m i.rep { background: var(--hist-fill); }
.tl-m i.lab { background: var(--loci-fill); }
.chat-row.busy .tl-m::after { content: ''; width: 7px; height: 7px; margin-left: auto; border-radius: 50%; background: var(--loci); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.chat-acts { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: none; gap: 0; }
.chat-row:hover .chat-acts, .chat-row:focus-within .chat-acts { display: flex; }
.chat-row:hover .tl-t, .chat-row:focus-within .tl-t { padding-right: 56px; }
@media (hover: none) {
  .chat-acts { display: flex; }
  .tl-t { padding-right: 56px; }
}

.rename-box { padding: 2px 0; }
.rename { width: 100%; padding: 8px 10px; font-size: 13.5px; border: 1px solid var(--loci); border-radius: var(--radius-md); background: var(--sheet); color: var(--ink); outline: 0; box-shadow: var(--focus-ring); }
.confirm { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--rule-2); border-radius: var(--radius-md); background: var(--sheet); }
.cf-t { font-size: 13px; font-weight: 550; }
.cf-b { display: flex; gap: 8px; }
.mini { font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: var(--radius-sm); border: 1px solid var(--rule-2); background: var(--paper); }
.mini:hover { border-color: var(--ink-3); }
.mini.danger { color: var(--limit-ink); border-color: color-mix(in srgb, var(--limit) 50%, transparent); }
.mini.danger:hover { background: var(--limit-soft); }

.side-foot { border-top: 1px solid var(--rule); margin: 12px -14px 0; padding: 14px 22px 2px; display: grid; gap: 12px; font-size: 11.5px; color: var(--ink-3); line-height: 1.35; }
.foot-brand { display: flex; align-items: center; gap: 12px; }
.csg-logo { width: 40px; height: auto; flex: none; }
.sf-t > span { display: block; }
.sf-s { font-variant-numeric: tabular-nums; }
[data-theme="dark"] .csg-logo.on-light, :root:not([data-theme="dark"]) .csg-logo.on-dark { display: none; }
.who-m { display: none; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--rule); }

.who-n { font-size: 13px; color: var(--ink-2); max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linkish { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550; color: var(--ink-2); padding: 6px 10px; border-radius: var(--radius-md); white-space: nowrap; transition: background-color .18s, color .18s; }
.linkish:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.linkish svg { width: 15px; height: 15px; }

.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 58px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 18px 0 28px;
  position: relative; z-index: 6; border-bottom: 1px solid var(--rule);
}
.tb-title { flex: 1; min-width: 0; display: flex; align-items: center; }
.tb-title .t { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { margin-left: auto; flex: none; display: flex; align-items: center; gap: 8px; }
.who { display: flex; align-items: center; gap: 4px; margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--rule); }

.voice { display: flex; align-items: center; gap: 3px; padding: 3px 3px 3px 12px; border: 1px solid var(--rule-2); border-radius: var(--radius-md); background: var(--sheet); }
.voice-l { font-size: 12.5px; color: var(--ink-3); margin-right: 5px; white-space: nowrap; }
.voice button { font-size: 12.5px; font-weight: 550; padding: 5px 12px; border-radius: 6px; color: var(--ink-2); white-space: nowrap; transition: background-color .2s, color .2s; }
.voice button:hover { color: var(--ink); }
.voice button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.icon-btn { width: 36px; height: 36px; flex: none; border-radius: var(--radius-md); display: grid; place-items: center; color: var(--ink-2); transition: background-color .18s, color .18s; }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.menu-btn, .icon-btn.side-close { display: none; }
.ghost-btn { width: 28px; height: 28px; flex: none; border-radius: 6px; display: grid; place-items: center; color: var(--ink-3); transition: background-color .18s, color .18s; }
.ghost-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.ghost-btn svg { width: 15px; height: 15px; }

.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; scrollbar-gutter: stable; overscroll-behavior: contain; outline: 0; }
.scroller::-webkit-scrollbar, .side-scroll::-webkit-scrollbar { width: 10px; }
.scroller::-webkit-scrollbar-thumb, .side-scroll::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink) 16%, transparent); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.view { min-height: 100%; }
.quiet-load { color: var(--ink-3); font-size: 13.5px; padding: 28px 0; margin: 0; }

/* ───────────── the thread ───────────── */

.thread { width: min(var(--col), 100% - 56px); margin: 0 auto; padding: 10px 0 36px; }
.turn { padding-top: 6px; }
.turn + .turn { margin-top: 26px; border-top: 1px solid var(--rule); padding-top: 20px; }
.turn + .turn.pending { margin-top: 0; border-top: 0; padding-top: 6px; }   /* the answer that is still arriving belongs to the question above */
.q { display: flex; flex-direction: column; align-items: flex-end; margin: 14px 0 18px; }
.q-who { font-size: 11.5px; color: var(--ink-3); margin: 0 6px 6px; }
.bubble {
  max-width: 86%; background: var(--sheet); border: 1px solid var(--rule); box-shadow: var(--shadow-1);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg); padding: 11px 16px;
  font-size: 15px; line-height: 1.52; white-space: pre-wrap; overflow-wrap: anywhere;
}

.ans { position: relative; }
.ah { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; min-height: 28px; }
.ah .mark { width: 22px; height: 22px; color: var(--ink); flex: none; }
.ah .n { font-family: var(--font-display); font-weight: 500; font-size: 18px; letter-spacing: .02em; line-height: 1; }
.ah .tm { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.copy-btn { margin-left: auto; opacity: 0; transition: opacity .18s, background-color .18s, color .18s; }
.ans:hover .copy-btn, .ans:focus-within .copy-btn, .copy-btn:focus-visible { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }
.ans-body { padding-left: 31px; min-width: 0; }
.blocks > * + *, .blocks > .md:first-child { margin-top: 0; }

/* the answer text */
.md { min-width: 0; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md strong { font-weight: 600; }
.md code { font-family: var(--font-mono); font-size: .88em; background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 4px; padding: 1px 5px; }
.lead { font-family: var(--font-display); font-weight: 500; font-size: 31px; line-height: 1.14; letter-spacing: .004em; margin: 6px 0 18px; text-wrap: pretty; color: var(--ink); }
.p { margin: 0 0 14px; text-wrap: pretty; }
.h {
  font-size: 15.5px; color: var(--hist); margin: 28px 0 10px; display: flex; align-items: center; gap: 14px; font-weight: 500;
}
.h::after { content: ''; flex: 1; height: 1px; background: var(--rule); }
.md-ul, .md-ol { margin: 4px 0 16px; padding: 0; }
.md-ul { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.md-ul li { position: relative; padding-left: 20px; }
.md-ul li::before { content: ''; position: absolute; left: 4px; top: .66em; width: 6px; height: 6px; border-radius: 50%; background: var(--loci); }
.md-ol { padding-left: 30px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.md-ol li { padding-left: 6px; }
.md-ol li::marker { font-family: var(--font-display); font-weight: 500; font-size: 1.35em; color: var(--loci); }
.md-quote { margin: 4px 0 16px; padding: 2px 0 2px 14px; border-left: 3px solid var(--rule-2); color: var(--ink-2); }
.md-hr { border: 0; border-top: 1px solid var(--rule); margin: 22px 0; }
.md-code { margin: 6px 0 16px; padding: 12px 14px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius-md); overflow-x: auto; white-space: pre; }
.md-code code { background: none; padding: 0; font-size: inherit; }

.tbl-wrap { margin: 8px 0 18px; overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--sheet); -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--ink-3); padding: 8px 14px; border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--ink) 3%, transparent); white-space: nowrap; vertical-align: bottom; }
.tbl td { padding: 8px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; min-width: 90px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num, .tbl .a-right { text-align: right; }
.tbl .a-center { text-align: center; }

/* streaming: words wait hidden, then come into focus. Inline, so lines break as they will in the end. */
.md.live .w { display: none; }
.md.live .w.on, .md.live .w.done { display: inline; }
.md.live .w.on { animation: settle .52s var(--ease-out) both; }
.md.live .hid { display: none; }
@keyframes settle { from { opacity: 0; filter: blur(4px); } to { opacity: 1; filter: blur(0); } }

/* while tools run: one quiet line */
.live-step { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; color: var(--ink-3); font-size: 13.5px; max-height: 40px; overflow: hidden; transition: opacity .25s, max-height .3s var(--ease), margin .3s var(--ease); }
.live-step .spin { width: 13px; height: 13px; flex: none; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--loci) 22%, transparent); border-top-color: var(--loci); animation: spin .8s linear infinite; }
.live-step.is-done .spin { animation: none; border-color: var(--loci); }
.live-step .tx { background: linear-gradient(90deg, var(--ink-3) 0%, var(--ink) 50%, var(--ink-3) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.8s linear infinite; }
.live-step.is-done .tx { animation: none; background: none; color: var(--ink-3); }
.live-step.out { opacity: 0; max-height: 0; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* charts: the library draws its own card; the slot only sets its width */
.chart-slot { --figw: min(var(--fig), 100vw - var(--side-w) - 72px); width: var(--figw); margin: 16px 0 22px calc((100% - var(--figw)) / 2); min-height: 0; }
.chart-note { margin: 0; padding: 10px 14px; font-size: 13px; color: var(--ink-3); border: 1px dashed var(--rule-2); border-radius: var(--radius-md); }

.ans-tail { min-width: 0; }
.status-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; font-size: 12.5px; color: var(--ink-3); }
.sn-i svg { width: 13px; height: 13px; }
.status-note.stopped .sn-i, .status-note.interrupted .sn-i { color: var(--ink-4); }
.status-note.error { color: var(--limit-ink); }
.status-note .retry { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; color: var(--ink); border: 1px solid var(--rule-2); border-radius: var(--radius-sm); background: var(--sheet); }
.status-note .retry:hover { border-color: var(--loci); }
.status-note .retry svg { width: 13px; height: 13px; }

/* My working */
.working { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); min-width: 0; }
.working > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 6px; margin-left: -6px; border-radius: 6px; transition: background-color .18s, color .18s; user-select: none; }
.working > summary::-webkit-details-marker { display: none; }
.working > summary:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink-2); }
.working > summary svg { width: 13px; height: 13px; transition: transform .22s var(--ease); }
.working[open] > summary svg { transform: rotate(90deg); }
.wk-n::before { content: "·"; margin-right: 7px; }
.wk-steps { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.wk-step { position: relative; padding-left: 20px; line-height: 1.5; min-width: 0; overflow-wrap: anywhere; }
.wk-step::before { content: ''; position: absolute; left: 6px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-4); }
.wk-fail { color: var(--limit-ink); }
.wk-detail { margin: 7px 0 4px; padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--sheet); }
.wk-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.wk-kv { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.wk-kv dt { font-size: 12px; color: var(--ink-3); }
.wk-kv dd { margin: 0; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.wk-code { position: relative; min-width: 0; }
.wk-code pre { margin: 0; padding: 10px 40px 10px 12px; max-height: 240px; overflow: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-md); font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: var(--ink-2); white-space: pre; tab-size: 2; }
.wk-code code { font: inherit; }
.wk-copy { position: absolute; top: 6px; right: 6px; background: var(--sheet); }

/* ───────────── composer ───────────── */

.dock { position: relative; flex: none; padding: 8px 24px 16px; }
.dock::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 30px; pointer-events: none; background: linear-gradient(to top, var(--paper), color-mix(in srgb, var(--paper) 0%, transparent)); }
.is-empty .dock { display: none; }
.jump {
  position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%); z-index: 4;
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px 7px 11px; font-size: 12.5px; font-weight: 600;
  background: var(--sheet); border: 1px solid var(--rule-2); border-radius: 999px; box-shadow: var(--shadow-2);
  transition: border-color .18s, transform .18s var(--ease);
}
.jump:hover { border-color: var(--loci); }
.jump svg { width: 14px; height: 14px; color: var(--loci); }

.composer {
  width: min(var(--col), 100%); margin: 0 auto; background: var(--sheet);
  border: 1px solid var(--rule-2); border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  padding: 12px 12px 10px 16px; display: grid; gap: 8px; transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--loci); box-shadow: var(--shadow-2), var(--focus-ring); }
.composer textarea {
  resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); width: 100%;
  font: 400 15px/1.5 var(--font-body); min-height: 26px; max-height: 142px; padding: 2px 0; overflow-y: auto;
}
.composer textarea::placeholder { color: var(--ink-4); }
.composer .row { display: flex; align-items: center; gap: 10px; }
.composer .hint { margin: 0; flex: 1; min-width: 0; font-size: 12px; line-height: 1.4; color: var(--ink-3); }
.composer .count { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.composer .send {
  flex: none; width: 34px; height: 34px; border-radius: var(--radius-md); display: grid; place-items: center;
  background: var(--loci-fill); color: var(--accent-on); transition: transform .2s var(--ease), opacity .2s, background-color .2s;
}
.composer .send:disabled { opacity: .3; }
.composer .send:not(:disabled):hover { transform: translateY(-1px); background: var(--loci-hover); }
.composer .send svg { width: 17px; height: 17px; }
.composer .send.stop { background: var(--sheet); color: var(--ink); border: 1.5px solid var(--ink); }
.composer .send.stop svg { width: 18px; height: 18px; }
.composer .send.stop:disabled { opacity: .45; }

.toast {
  position: absolute; left: 50%; bottom: 112px; z-index: 30; max-width: calc(100% - 32px); transform: translate(-50%, 10px);
  background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: var(--radius-md); font-size: 13px;
  box-shadow: var(--shadow-3); opacity: 0; pointer-events: none; transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ───────────── the empty chat ───────────── */

.empty { width: min(980px, 100% - 64px); margin: 0 auto; padding: min(6.5vh, 64px) 0 48px; }
.hero { width: min(740px, 100%); margin: 0 auto; text-align: center; }
.hero-jar { width: 64px; height: 80px; margin: 0 auto 16px; color: var(--ink); }
.hero-jar .jw0 { stop-color: var(--loci); stop-opacity: .03; }
.hero-jar .jw1 { stop-color: var(--loci); stop-opacity: .07; }
.hero-jar .jw2 { stop-color: var(--loci); stop-opacity: .16; }
.hero-jar .jar-surface { stroke: var(--loci); stroke-opacity: .5; }
.hero-jar .jar-floc { fill: var(--hist-fill); opacity: .85; }
.hero-jar .jar-sludge { fill: var(--hist-fill); opacity: .92; }
.hero-jar .jar-paddle { fill: var(--sheet); }
.hero h1 {
  font-family: var(--font-display); font-weight: 500; font-size: 58px; line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display); text-transform: uppercase; margin: 0 0 14px; text-wrap: balance;
}
.hero h1 em { color: var(--loci); }
.hero .sub { font-size: 16px; color: var(--ink-2); margin: 0 auto 24px; max-width: 520px; text-wrap: balance; }
.hero-composer .composer { text-align: left; }

.examples { width: min(740px, 100%); margin: 34px auto 0; }
.ex-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 2px 10px; font-size: 15.5px; color: var(--hist); }
.ex-h span:last-child { font-family: var(--font-body); font-size: 12px; letter-spacing: 0; text-transform: none; color: var(--ink-3); font-weight: 400; }
.ex-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ex {
  text-align: left; display: grid; grid-template-columns: 34px 1fr; gap: 1px 12px; align-items: start; align-content: start;
  padding: 13px 14px; border-radius: var(--radius-lg); background: var(--sheet); border: 1px solid var(--rule); box-shadow: var(--shadow-1);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
.ex:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--loci); }
.ex .ic { grid-row: span 2; width: 34px; height: 34px; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--loci-soft); color: var(--loci); }
.ex .ic svg { width: 18px; height: 18px; }
.ex-k { font-family: var(--font-display); font-weight: 500; text-transform: uppercase; letter-spacing: .07em; font-size: 13px; color: var(--ink-3); line-height: 1.3; }
.ex-t { grid-column: 2; font-size: 14px; font-weight: 550; line-height: 1.4; }

/* ───────────── signed out ───────────── */

.landing { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--paper); }
.land-top { display: flex; align-items: center; justify-content: space-between; padding: 22px 28px; }
.land-logo .csg-logo { width: 54px; }
.land-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 24px 12vh; }
.land-mark .mark.big { width: 56px; height: 56px; color: var(--ink); margin: 0 auto 8px; }
.land-main h1 { font-family: var(--font-display); font-weight: 500; font-size: 88px; line-height: .95; letter-spacing: var(--tracking-display); margin: 0 0 14px; }
.land-sub { font-size: 16.5px; color: var(--ink-2); margin: 0 0 28px; max-width: 420px; text-wrap: balance; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 9px; padding: 12px 24px; border-radius: var(--radius-md); border: 0; cursor: pointer;
  background: var(--loci-fill); color: var(--accent-on); font-size: 15px; font-weight: 600; text-decoration: none;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--loci) 80%, transparent); transition: background-color .18s, transform .18s var(--ease);
}
.btn-primary:hover { background: var(--loci-hover); transform: translateY(-1px); }
.btn-primary svg { width: 16px; height: 16px; }

/* ───────────── laptop ───────────── */

@media (max-width: 1440px) {
  :root { --side-w: 252px; --col: 680px; --fig: 820px; }
  body, .composer textarea { font-size: 14.5px; }
  .lead { font-size: 29px; }
  .hero h1 { font-size: 52px; }
}
@media (max-height: 820px) {
  .empty { padding-top: 3vh; }
  .hero-jar { width: 50px; height: 62px; margin-bottom: 10px; }
  .hero h1 { font-size: 46px; margin-bottom: 8px; }
  .hero .sub { margin-bottom: 18px; font-size: 15px; }
  .examples { margin-top: 24px; }
  .ex { padding: 10px 12px; }
}

/* ───────────── phone and small tablet: the sidebar is a drawer ───────────── */

@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(320px, 86vw); padding-top: calc(14px + env(safe-area-inset-top));
    box-shadow: var(--shadow-3); transform: translateX(-104%); visibility: hidden;
    transition: transform .3s var(--ease-out), visibility 0s linear .3s;
  }
  .app.drawer-open .side { transform: none; visibility: visible; transition: transform .3s var(--ease-out), visibility 0s; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); }
  .app.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .icon-btn.menu-btn, .icon-btn.side-close { display: grid; }
  .side-close { margin-left: auto; }
  .brand { padding-bottom: 14px; }
  .who { display: none; }
  .who-m { display: flex; }
  .voice-l { display: none; }
  .voice { padding-left: 3px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .tb-title .t { font-size: 14px; padding-left: 4px; }
  .thread { width: min(var(--col), 100% - 40px); }
  .chart-slot { width: 100%; margin-left: 0; }
  .chat-acts { display: flex; }
  .tl-t { padding-right: 56px; }
}

@media (max-width: 600px) {
  body { font-size: 15px; }
  .thread { width: calc(100% - 28px); padding-top: 4px; }
  .ans-body { padding-left: 0; }
  .ah { margin-bottom: 8px; }
  .lead { font-size: 26px; margin-bottom: 14px; }
  .bubble { max-width: 94%; }
  .dock { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer { padding: 10px 10px 8px 14px; }
  .composer:focus-within .hint { display: none; }
  .composer .hint { font-size: 11.5px; }
  .empty { width: calc(100% - 32px); padding-top: 24px; }
  .hero-jar { width: 44px; height: 55px; margin-bottom: 8px; }
  .hero h1 { font-size: 38px; }
  .hero .sub { font-size: 15px; margin-bottom: 16px; }
  .examples { margin-top: 22px; }
  .ex-h { flex-direction: column; gap: 2px; }
  .ex-grid { grid-template-columns: minmax(0, 1fr); }
  .toast { bottom: 96px; }
  .land-main h1 { font-size: 72px; }
  .land-top { padding: 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .md.live .w.on, .live-step .spin, .live-step .tx, .chat-row.busy .tl-m::after { animation: none !important; }
  .live-step .tx { background: none; color: var(--ink-3); }
  .side, .scrim, .toast, .jump, .live-step { transition: none !important; }
}
