/* Hallmark · v2.0.0 · redesign: full · scope: app · shape: app screen · theme: brand (Capgemini blue #0070AD, Plus Jakarta Sans), two schemes: Aurora light and Midnight dark (light-dark tokens, device default, user switch) · genre: modern-minimal (inferred)
 * waivers (owner decision, 3 Nov 2026, docs/UI-STANDARDS.md §5): expressive motion instead of state-only: a fresh start screen cascades in (320ms rises, 30ms apart); the glow blooms once (500ms) and then holds; the verdict badge overshoots; every one-off animation ends within 500ms (owner decision, 7 Nov 2026). Reduced motion stills all of it, delays included.
 * critique: the old start screen was a centred greeting over six identical cards; it is now a roster you scan like a team sheet, and a Team run reads as one rail of hand-offs.
 * signature: the Team relay rail: each specialist hands to the next on one line, the Reviewer's verdict in the Team header.
 * keeps: every id, class hook, handler and test selector; Capgemini blue and Plus Jakarta Sans; the agent colours. */

/* ---------- Tokens ---------- */
:root {
  /* Two themes from one set of tokens: light-dark(<Aurora, light>, <Midnight, dark>). The device's setting picks one;
     the theme switch pins it with data-theme on <html>. */
  color-scheme: light dark;

  /* Neutrals, mixed in OKLCH toward the brand blue's hue so the greys belong to it */
  --color-paper: light-dark(oklch(98.6% 0.005 240), oklch(16.5% 0.014 255));
  --color-paper-2: light-dark(oklch(96.6% 0.009 240), oklch(19% 0.016 255));
  --color-paper-3: light-dark(oklch(93.6% 0.011 237), oklch(25% 0.02 255));
  --color-sheet: light-dark(oklch(100% 0 0), oklch(21% 0.018 255));
  --color-ink: light-dark(oklch(24% 0.03 252), oklch(95.5% 0.006 250));
  --color-ink-2: light-dark(oklch(35% 0.025 252), oklch(83% 0.012 250));
  --color-muted: light-dark(oklch(46% 0.02 252), oklch(70% 0.016 250));
  --color-rule: light-dark(oklch(90% 0.01 240), oklch(28% 0.018 255));
  --color-rule-strong: light-dark(oklch(81% 0.016 240), oklch(36% 0.022 255));
  /* Border of an input: the only boundary a field has, so it must reach 3:1 against the sheet and the sidebar */
  --color-control-line: light-dark(oklch(62% 0.02 245), oklch(55% 0.02 250));

  /* Brand: Capgemini blue is the one accent: the primary action, the current selection, state and focus */
  --color-accent: #0070ad;
  --color-accent-strong: light-dark(#005a8c, oklch(76% 0.12 237));
  --color-accent-soft: light-dark(oklch(95.4% 0.022 236), oklch(28% 0.06 240));
  --color-accent-line: light-dark(oklch(83% 0.055 236), oklch(48% 0.1 240));
  --color-accent-ink: oklch(100% 0 0);
  /* Hover fill for the primary button: darker in both themes so white text keeps at least 4.5:1 */
  --color-accent-hover: light-dark(#005a8c, #005f96);
  --color-focus: light-dark(#0070ad, oklch(76% 0.12 237));

  /* Status, each with a tint and a line; text pairs are 4.5:1 or better on their tint */
  --color-error: light-dark(#b3261e, oklch(74% 0.15 25));
  --color-error-strong: light-dark(#8f1e18, oklch(82% 0.12 25));
  --color-error-soft: light-dark(#fdf0ef, oklch(27% 0.06 25));
  --color-error-line: light-dark(oklch(85% 0.06 25), oklch(45% 0.11 25));
  --color-success: light-dark(#166534, oklch(78% 0.13 150));
  --color-success-soft: light-dark(#e8f5e9, oklch(27% 0.05 150));
  --color-success-line: light-dark(oklch(84% 0.06 150), oklch(45% 0.09 150));
  --color-warning: light-dark(#8a5300, oklch(82% 0.12 75));
  --color-warning-soft: light-dark(#fff4e0, oklch(29% 0.05 75));
  --color-warning-line: light-dark(oklch(86% 0.07 75), oklch(48% 0.09 75));

  /* Code blocks and overlays */
  --color-code-bg: light-dark(oklch(24% 0.03 252), oklch(12.5% 0.012 255));
  --color-code-fg: light-dark(oklch(93% 0.01 240), oklch(92% 0.01 250));
  --color-code-chip: light-dark(oklch(33% 0.03 252), oklch(25% 0.02 255));
  --color-code-chip-hover: light-dark(oklch(39% 0.03 252), oklch(31% 0.02 255));
  --color-scrim: light-dark(oklch(24% 0.03 252 / 0.45), oklch(8% 0.01 255 / 0.6));
  --color-shadow: light-dark(oklch(30% 0.05 250 / 0.14), oklch(0% 0 0 / 0.55));

  /* Glass layers (top bar, message box, sheets), rows and the start-screen glow */
  --color-glass: light-dark(oklch(100% 0 0 / 0.68), oklch(21% 0.018 255 / 0.72));
  --color-glass-line: light-dark(oklch(30% 0.04 245 / 0.11), oklch(100% 0 0 / 0.09));
  --color-row: light-dark(oklch(100% 0 0 / 0.72), oklch(19.5% 0.016 255));
  --color-row-hover: light-dark(oklch(100% 0 0), oklch(22.5% 0.018 255));
  --color-bubble: light-dark(oklch(95% 0.018 240), oklch(24% 0.022 255));
  --color-tile-glow: light-dark(oklch(55% 0.12 240 / 0.4), oklch(55% 0.12 240 / 0.6));
  --color-glow-1: light-dark(oklch(78% 0.1 238 / 0.55), oklch(55% 0.13 240 / 0.3));
  --color-glow-2: light-dark(oklch(85% 0.08 205 / 0.55), oklch(60% 0.09 215 / 0.15));
  --color-glow-3: light-dark(oklch(92% 0.05 160 / 0.4), oklch(55% 0.08 190 / 0.08));
  --color-sheen: light-dark(oklch(100% 0 0 / 0.9), oklch(100% 0 0 / 0.06));
  --color-sheen-strong: oklch(100% 0 0 / 0.18);
  --mask-solid: #000;
  --dur-bloom: 500ms;
  --dur-rise: 320ms;
  --shadow-raised: 0 1px 2px var(--color-shadow);
  --shadow-menu: 0 12px 32px var(--color-shadow);
  --shadow-dialog: 0 28px 80px var(--color-shadow);
  --shadow-float: 0 20px 48px -18px var(--color-shadow), inset 0 1px 0 var(--color-sheen);
  --shadow-lift: 0 10px 24px -14px var(--color-shadow);
  --glass-blur: 18px;

  /* Type: one family, a fixed 1.2 scale for an app screen */
  --font-body: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: var(--font-body);
  --font-mono: "Cascadia Code", Consolas, ui-monospace, "SFMono-Regular", Menlo, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.2rem;
  --text-xl: 1.44rem;
  --text-2xl: 1.728rem;
  --leading-ui: 1.4;
  --leading-prose: 1.65;
  --tracking-display: -0.01em;

  /* Space on a 4px grid */
  --space-3xs: 2px;
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  /* Shape: one radius per nesting level */
  --radius-inner: 6px;
  --radius-control: 10px;
  --radius-panel: 16px;
  --radius-pill: 999px;
  --rule-hair: 1px;

  /* Motion: fast and quiet; the reduced-motion rule in the base layer stills all of it */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-micro: 120ms;
  --dur-short: 220ms;
  --dur-stamp: 500ms; /* the verdict stamp; app.js reads it so both agree */
  --dur-leave: 240ms; /* the sign-in card leaving; login.js reads it */
  --dur-shake: 380ms; /* the wrong-password shake; login.js reads it */
  --dur-theme: 500ms; /* the theme reveal; app.js reads it, and the icon morph and pulse end inside it */
  --dur-morph: 380ms; /* the sun and moon morph; with its 120ms delay it ends inside --dur-theme */
  --ease-spring: cubic-bezier(0.5, 1.5, 0.6, 1);

  /* Layout */
  --sidebar-w: 264px;
  --outputs-w: 360px;
  --thread-w: 56rem;
  --measure: 46rem;
  --measure-prose: 56ch;
  --target: 36px;
  --target-sm: 32px; /* the smallest target with a mouse (UI-STANDARDS: at least 32 px) */
  --avatar: 28px;
  --hit: 44px;

  --z-raised: 10;
  --z-dropdown: 100;
  --z-drawer: 300;
  --z-modal: 400;
}
@media (pointer: coarse) {
  :root { --target: 44px; }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---------- Base ---------- */
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { scrollbar-color: var(--color-rule-strong) transparent; }
body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading-ui);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--color-accent);
}
::selection { background: color-mix(in oklab, var(--color-accent) 22%, transparent); color: var(--color-ink); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
a { color: var(--color-accent-strong); text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-synthesis: none;
  letter-spacing: var(--tracking-display);
  line-height: 1.25;
  overflow-wrap: break-word;
  min-width: 0;
  text-wrap: balance;
}
p { margin: 0; text-wrap: pretty; }
svg { display: block; }
img { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
button:disabled, input:disabled, select:disabled { opacity: 0.55; cursor: not-allowed; }
.num, td.num { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Shell ---------- */
body:not(.auth-page) { display: flex; height: 100dvh; overflow-y: clip; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; display: flex; min-height: 0; }
.thread-col { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link {
  position: absolute; left: -999px; top: var(--space-xs); z-index: var(--z-modal);
  background: var(--color-sheet); padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-control);
}
.skip-link:focus { left: var(--space-xs); }
.muted { color: var(--color-muted); }
.small { font-size: var(--text-sm); }
.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; white-space: nowrap; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: var(--target); padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-control);
  background: var(--color-sheet); color: var(--color-ink);
  font-size: var(--text-sm); font-weight: 600; line-height: 1.2; cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.btn:hover { background: var(--color-paper-2); }
.btn:active { background: var(--color-paper-3); }
.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-ink); }
.btn-primary:hover, .btn-primary:active { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-danger { background: var(--color-sheet); border-color: var(--color-error-line); color: var(--color-error); }
.btn-danger:hover, .btn-danger:active { background: var(--color-error-soft); border-color: var(--color-error); color: var(--color-error-strong); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--color-paper-3); }
.btn-block { width: 100%; }
a.btn { text-decoration: none; }
.btn-sm { min-height: var(--target-sm); padding: 0 var(--space-xs); font-size: var(--text-xs); }

.icon-btn {
  display: inline-grid; place-items: center; width: var(--target); height: var(--target);
  border: 0; border-radius: var(--radius-control); background: transparent; color: var(--color-muted); cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.icon-btn:hover { background: var(--color-paper-3); color: var(--color-ink); }
.only-mobile, .icon-btn.only-mobile, .only-phone, .icon-btn.only-phone { display: none; }

.link-btn {
  display: flex; align-items: center; gap: var(--space-xs); width: 100%; min-height: var(--target);
  padding: 0 var(--space-xs); border: 0; border-radius: var(--radius-control);
  background: none; color: var(--color-ink-2); font-size: var(--text-sm); text-align: left; cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.link-btn:hover { background: var(--color-paper-3); color: var(--color-ink); }
.link-btn .icon { color: var(--color-muted); }

.count {
  display: inline-block; min-width: 20px; padding: 0 var(--space-2xs); border-radius: var(--radius-pill);
  background: var(--color-accent-soft); color: var(--color-accent-strong);
  font-size: var(--text-xs); text-align: center; font-variant-numeric: tabular-nums;
}

select, .control select {
  min-height: var(--target); padding: 0 var(--space-xs);
  border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-control);
  background: var(--color-sheet); color: var(--color-ink); cursor: pointer;
}
select:focus-visible, input:focus-visible, textarea:focus-visible { outline-offset: 0; }
/* The browser default grey is 3.9:1 on Midnight; the muted token holds 4.5:1 in both themes */
input::placeholder, textarea::placeholder { color: var(--color-muted); opacity: 1; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-sm);
  padding: var(--space-md) var(--space-sm); background: var(--color-paper-2); border-right: var(--rule-hair) solid var(--color-rule);
}
.brand { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-2xs) var(--space-xs) var(--space-xs); }
.brand img { display: block; flex: none; }
.brand-name { font-size: var(--text-md); font-weight: 700; line-height: 1.3; }
.brand-sub { font-size: var(--text-xs); color: var(--color-muted); }
.search input {
  width: 100%; min-height: var(--target); padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-control-line); border-radius: var(--radius-control); background: var(--color-sheet);
}
.conversation-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-3xs); padding-inline: var(--space-2xs); margin-inline: calc(-1 * var(--space-2xs)); }
.conv-group { padding: var(--space-sm) var(--space-xs) var(--space-2xs); font-size: var(--text-xs); font-weight: 600; color: var(--color-muted); }
.conv-item { display: flex; align-items: center; border-radius: var(--radius-control); }
.conv-item .conv-open {
  flex: 1; min-width: 0; min-height: var(--target); padding: 0 var(--space-xs);
  border: 0; border-radius: var(--radius-control); background: none; text-align: left; cursor: pointer;
  font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover { background: var(--color-paper-3); }
.conv-item.active { background: var(--color-sheet); box-shadow: inset 0 0 0 var(--rule-hair) var(--color-rule); }
.conv-item.active .conv-open { font-weight: 600; }
.conv-actions { display: flex; opacity: 0; transition: opacity var(--dur-micro) var(--ease-out); }
.conv-item:hover .conv-actions, .conv-item.active .conv-actions, .conv-item:focus-within .conv-actions { opacity: 1; }
@media (pointer: coarse) { .conv-actions { opacity: 1; } }
.conv-actions .icon-btn { width: var(--target-sm); height: var(--target-sm); }
.conv-actions .icon { width: 16px; height: 16px; }
.sidebar-footer { display: flex; flex-direction: column; gap: var(--space-3xs); padding-top: var(--space-xs); border-top: var(--rule-hair) solid var(--color-rule); }
.user-chip { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-xs) var(--space-xs) 0; }
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .who strong { display: block; font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { font-size: var(--text-xs); color: var(--color-muted); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--space-sm); min-height: 56px; padding: var(--space-xs) var(--space-lg);
  background: var(--color-paper); border-bottom: var(--rule-hair) solid var(--color-rule);
}
.conversation-title { flex: 1; min-width: 0; font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-badge {
  padding: var(--space-3xs) var(--space-xs); border-radius: var(--radius-pill); border: var(--rule-hair) solid;
  font-size: var(--text-xs); font-weight: 600; white-space: nowrap;
}
.mode-badge.demo { background: var(--color-warning-soft); color: var(--color-warning); border-color: var(--color-warning-line); }
.mode-badge.live { background: var(--color-success-soft); color: var(--color-success); border-color: var(--color-success-line); }
.topbar-controls { display: flex; align-items: center; gap: var(--space-xs); }
.control { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); color: var(--color-muted); white-space: nowrap; }
.switch {
  min-height: var(--target); padding: 0 var(--space-xs); border-radius: var(--radius-control);
  color: var(--color-ink-2); cursor: pointer;
}
@media (hover: hover) { .switch:hover { background: var(--color-paper-3); } }
.team-toggle input, .plan-step input { accent-color: var(--color-accent); width: 16px; height: 16px; margin: 0; flex-shrink: 0; }
/* On/off settings (Docs, Community, Learning mode) read as a pill switch. The real checkbox stays and is drawn as the
   track; the knob is a background circle that slides, so labels, keyboard, screen readers and tests behave as before.
   Shape from Uiverse Galaxy (see docs/THIRD-PARTY.md); colours are the Hub's own tokens. In Midnight the on track is the
   lighter accent with a dark knob, so the track keeps 3:1 against the dark sheets. */
.switch input {
  --switch-w: 2.25rem; --switch-h: 1.25rem; --switch-gap: var(--space-3xs); --switch-knob: var(--color-sheet);
  appearance: none; -webkit-appearance: none;
  flex-shrink: 0; width: var(--switch-w); height: var(--switch-h); margin: 0;
  border: 0; border-radius: var(--radius-pill);
  background: radial-gradient(circle closest-side, var(--switch-knob) calc(100% - 1px), transparent 100%) no-repeat var(--color-muted);
  background-size: calc(var(--switch-h) - 2 * var(--switch-gap)) calc(var(--switch-h) - 2 * var(--switch-gap));
  background-position: var(--switch-gap) center;
  transition: background-color var(--dur-short) var(--ease-out), background-position var(--dur-short) var(--ease-out);
}
@media (hover: hover) { .switch:hover input:not(:checked):not(:disabled) { background-color: var(--color-ink-2); } }
.switch input:checked { --switch-knob: light-dark(var(--color-accent-ink), var(--color-sheet)); background-color: light-dark(var(--color-accent), var(--color-accent-strong)); background-position: calc(100% - var(--switch-gap)) center; }
.switch input:dir(rtl) { background-position: calc(100% - var(--switch-gap)) center; }
.switch input:checked:dir(rtl) { background-position: var(--switch-gap) center; }
.switch input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }
.switch input.no-slide { transition: none; }
@media (prefers-reduced-motion: reduce) { .switch input { transition: none; } }
@media (forced-colors: active) { .switch input { appearance: auto; -webkit-appearance: auto; width: 16px; height: 16px; background: none; } }
.switch .short { display: none; }
.team-toggle .short, .disclaimer .short, .keep-label .short, #toggle-theme .label { display: none; }
.switch.is-disabled { cursor: not-allowed; }
.switch.is-disabled input, .switch.is-disabled > span:not(.src-off) { opacity: 0.55; }
.src-off { font-size: var(--text-xs); color: var(--color-muted); }

/* ---------- Thread ---------- */
.thread { flex: 1; min-height: 0; overflow-y: auto; overflow-x: clip; padding: var(--space-lg) var(--space-lg) var(--space-sm); container-type: inline-size; }
.thread > * { max-width: var(--thread-w); margin-inline: auto; }

/* Start: a roster to scan, then examples as rows */
.empty { padding-top: var(--space-xl); }
.start-head { max-width: var(--measure); margin-bottom: var(--space-lg); }
.start-head h2 { font-size: var(--text-2xl); }
.start-head p { margin-top: var(--space-xs); color: var(--color-ink-2); }
.roster { display: grid; border-top: var(--rule-hair) solid var(--color-rule); }
.roster-row {
  display: grid; grid-template-columns: 48px minmax(0, 16.5rem) minmax(0, 1fr) 6.5rem; gap: var(--space-md); align-items: center;
  min-height: 60px; padding: var(--space-sm) var(--space-xs); text-align: left; cursor: pointer;
  border: 0; border-bottom: var(--rule-hair) solid var(--color-rule); background: transparent;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.roster-row:hover { background: var(--color-paper-2); }
.roster-row[aria-pressed="true"] { background: var(--color-accent-soft); }
.roster-row .avatar { width: 48px; height: 48px; }
.roster-row .who { display: flex; flex-direction: column; min-width: 0; }
.roster-row .name { font-weight: 700; }
.roster-row[aria-pressed="true"] .name { color: var(--color-accent-strong); }
.roster-row .role { font-size: var(--text-sm); color: var(--color-muted); }
.roster-row .good { font-size: var(--text-sm); color: var(--color-ink-2); }
.roster-row .pick { display: inline-flex; align-items: center; justify-content: flex-end; gap: var(--space-2xs); font-size: var(--text-sm); font-weight: 600; color: var(--color-accent-strong); }
.roster-row .pick .icon { width: 16px; height: 16px; }

.examples { display: grid; margin: var(--space-xl) 0 var(--space-lg); }
.examples h3 { margin-bottom: var(--space-xs); font-size: var(--text-sm); color: var(--color-ink-2); }
.example {
  display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: var(--space-md); align-items: baseline;
  min-height: var(--hit); padding: var(--space-xs); text-align: left; cursor: pointer;
  border: 0; border-top: var(--rule-hair) solid var(--color-rule); background: transparent; font-size: var(--text-sm);
  transition: background-color var(--dur-micro) var(--ease-out);
}
.examples.guided .example { grid-template-columns: 13rem minmax(0, 1fr); }
.example:last-child { border-bottom: var(--rule-hair) solid var(--color-rule); }
.example:hover { background: var(--color-paper-2); }
.example .who { display: inline-flex; align-items: center; gap: var(--space-xs); font-weight: 600; color: var(--color-ink-2); }
.example .who .icon { width: 16px; height: 16px; color: var(--color-muted); }
.example .text { color: var(--color-ink); }
.example.showcase .who, .example.showcase .who .icon { color: var(--color-accent-strong); }

@container (max-width: 44rem) {
  .roster-row { grid-template-columns: 48px minmax(0, 1fr) auto; row-gap: var(--space-2xs); }
  .roster-row .good { grid-column: 2 / -1; grid-row: 2; }
  .roster-row .pick { grid-column: 3; grid-row: 1; }
}
@container (max-width: 34rem) {
  /* Wide tables become one labelled card per row */
  .md .table-wrap { overflow: visible; }
  .md table, .md tbody, .md tr { display: block; width: 100%; }
  .md thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .md tr { margin-bottom: var(--space-sm); padding: var(--space-xs) var(--space-sm); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-control); background: var(--color-row); }
  .md td, .md td:first-child { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: var(--space-xs); min-width: 0; padding: var(--space-2xs) 0; border: 0; white-space: normal; }
  .md td::before { content: attr(data-label); color: var(--color-muted); font-size: var(--text-xs); font-weight: 600; }
  .md td:not([data-label]) { grid-template-columns: minmax(0, 1fr); }
  .md td:not([data-label])::before { content: none; }
  .example { grid-template-columns: minmax(0, 1fr); gap: var(--space-3xs); padding-block: var(--space-sm); }
}

/* ---------- Avatars ---------- */
.avatar { display: inline-block; width: var(--avatar); height: var(--avatar); flex-shrink: 0; }
.avatar svg { width: 100%; height: 100%; }
.avatar.lg { width: 36px; height: 36px; }

/* ---------- Messages ---------- */
.msg { margin-bottom: var(--space-xl); }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 85%; padding: var(--space-sm) var(--space-md);
  background: var(--color-paper-3); border-radius: var(--radius-panel);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: var(--leading-prose);
}
.user-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-xs); max-width: 85%; min-width: 0; }
.user-wrap > .file-chips { align-self: stretch; min-width: 0; }
.user-wrap .bubble { max-width: 100%; }
.msg-agent { display: flex; gap: var(--space-sm); }
.msg-agent .body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-xs); min-height: 28px; margin-bottom: var(--space-2xs); }
.msg-head .name { font-weight: 700; }
.msg-head .role { font-size: var(--text-sm); color: var(--color-muted); }
.msg-head .verdict { align-self: center; }
.routed {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs);
  margin: var(--space-2xs) 0 var(--space-sm); padding: var(--space-xs) var(--space-sm);
  border: var(--rule-hair) solid var(--color-accent-line); border-radius: var(--radius-control);
  background: var(--color-accent-soft); font-size: var(--text-sm); color: var(--color-ink-2); max-width: var(--measure-prose);
}
.routed select { min-height: var(--target-sm); font-size: var(--text-sm); }
.msg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3xs); margin-top: var(--space-sm); margin-inline-start: calc(-1 * (var(--space-xs) + var(--rule-hair))); }
.msg-actions button {
  display: inline-flex; align-items: center; gap: var(--space-2xs); min-height: var(--target); padding: 0 var(--space-xs);
  border: var(--rule-hair) solid transparent; border-radius: var(--radius-control);
  background: none; color: var(--color-muted); font-size: var(--text-sm); font-weight: 500; cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.msg-actions button .icon { width: 16px; height: 16px; }
@media (pointer: fine) { .msg-actions [data-act=copy] { min-width: 5.5rem; } }
.msg-actions button:hover { background: var(--color-paper-3); color: var(--color-ink); }
.msg-actions button.active { background: var(--color-accent-soft); color: var(--color-accent-strong); }
.msg-actions button:active:not(:disabled), .md pre .copy-code:active { transform: translateY(1px); background: var(--color-rule); }
.md pre .copy-code:active { background: var(--color-code-chip-hover); }
.meta { margin-top: var(--space-2xs); font-size: var(--text-xs); color: var(--color-muted); }
.meta summary { display: inline-flex; align-items: center; gap: var(--space-2xs); min-height: 32px; cursor: pointer; }
.meta summary:hover { color: var(--color-ink); background: var(--color-paper-3); border-radius: var(--radius-inner); }
.meta dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-3xs) var(--space-sm); margin: var(--space-xs) 0 0; }
.meta dt { font-weight: 700; }
.meta dd { margin: 0; font-variant-numeric: tabular-nums; }
.md.typing > :last-child:not(pre):not(.table-wrap)::after, .typing:not(.md)::after {
  content: ""; display: inline-block; width: 8px; height: 1em; margin-left: var(--space-3xs);
  vertical-align: text-bottom; border-radius: 2px; background: var(--color-accent); animation: caret 1.1s ease-in-out infinite;
}
@keyframes caret { 0%, 100% { opacity: 1; } 50% { opacity: 0.15; } }

/* Sources */
.sources { margin-top: var(--space-sm); font-size: var(--text-sm); }
.sources ol { margin: var(--space-2xs) 0 0; padding-left: var(--space-lg); }
.sources li { margin: var(--space-3xs) 0; }
.src-tag {
  display: inline-block; margin-inline-end: var(--space-2xs); padding: 0 var(--space-xs);
  border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-inner);
  background: var(--color-sheet); color: var(--color-muted); font-size: var(--text-xs); line-height: 18px; white-space: nowrap;
}
.src-tag.src-docs { border-color: var(--color-accent-line); background: var(--color-accent-soft); color: var(--color-accent-strong); }
.src-tag.src-community { border-color: var(--color-warning-line); background: var(--color-warning-soft); color: var(--color-warning); }
.src-date { color: var(--color-muted); font-size: var(--text-xs); }

/* Notices */
.error-box, .notice-box, .success-box {
  padding: var(--space-sm) var(--space-md); border: var(--rule-hair) solid; border-radius: var(--radius-control); font-size: var(--text-sm);
}
.error-box { border-color: var(--color-error-line); background: var(--color-error-soft); color: var(--color-error); }
.notice-box { border-color: var(--color-warning-line); background: var(--color-warning-soft); color: var(--color-warning); }
.success-box { border-color: var(--color-success-line); background: var(--color-success-soft); color: var(--color-success); }

/* Files */
.file-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-xs); }
#attach-note { padding: var(--space-xs) var(--space-2xs); }
.attach-list { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-bottom: var(--space-xs); max-height: 9.5rem; overflow-y: auto; }
.file-chip {
  display: inline-flex; align-items: center; gap: var(--space-xs); max-width: 100%; min-height: 32px;
  padding: var(--space-2xs) var(--space-2xs) var(--space-2xs) var(--space-xs);
  border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-control); background: var(--color-sheet); font-size: var(--text-sm);
  min-width: 0;
}
.file-chips .file-chip { padding-right: var(--space-sm); }
.file-chip .icon { width: 16px; height: 16px; flex: none; color: var(--color-accent); }
.file-chip .icon-btn .icon { color: inherit; }
.file-chip .fname { max-width: 220px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .finfo { padding-right: var(--space-3xs); color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .icon-btn { width: var(--target-sm); height: var(--target-sm); flex: none; }
.file-chip.reading .finfo, .file-chip.lost .finfo { font-style: italic; }
.file-chip.error { flex-wrap: wrap; border-color: var(--color-error-line); background: var(--color-error-soft); }
.file-chip.error .fname { flex: 0 1 auto; min-width: 8ch; }
.file-chip.error .finfo { flex: 1 1 100%; color: var(--color-error); white-space: normal; }
.file-chip.lost { border-style: dashed; }
.file-notice { margin-top: var(--space-2xs); }

/* Download menu */
.dl { position: relative; display: inline-flex; }
.dl > button .icon:last-child { width: 14px; height: 14px; }
.dl-menu {
  position: absolute; bottom: calc(100% + var(--space-2xs)); left: 0; z-index: var(--z-dropdown); min-width: 210px;
  display: flex; flex-direction: column; padding: var(--space-2xs);
  background: var(--color-sheet); border-radius: var(--radius-control); box-shadow: var(--shadow-menu);
}
.msg-actions .dl-menu button { justify-content: flex-start; width: 100%; color: var(--color-ink); }
.msg-actions .dl-menu button:hover, .msg-actions .dl-menu button:focus-visible { background: var(--color-paper-3); }

/* ---------- Answer text ---------- */
.md { overflow-wrap: break-word; line-height: var(--leading-prose); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md > p, .md > ul, .md > ol, .md > blockquote, .md > h1, .md > h2, .md > h3, .md > h4 { max-width: var(--measure-prose); }
.md h1, .md h2, .md h3, .md h4 { margin: var(--space-lg) 0 var(--space-xs); line-height: 1.3; }
.md h1 { font-size: var(--text-xl); }
.md h2 { font-size: var(--text-lg); }
.md h3, .md h4 { font-size: var(--text-md); }
.md p { margin: var(--space-xs) 0; }
.md ul, .md ol { margin: var(--space-xs) 0; padding-left: var(--space-lg); }
.md li { margin: var(--space-3xs) 0; }
.md blockquote {
  margin: var(--space-sm) 0; padding: var(--space-xs) var(--space-md);
  border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-control); background: var(--color-paper-2);
}
.md code { padding: 0 var(--space-2xs); line-height: 1.4; border-radius: var(--radius-inner); background: var(--color-paper-3); font-family: var(--font-mono); font-size: 0.875em; }
.md pre {
  position: relative; overflow-x: auto; padding: var(--space-xl) var(--space-md) var(--space-md);
  border-radius: var(--radius-control); background: var(--color-code-bg); color: var(--color-code-fg); line-height: 1.5;
}
.md pre code { padding: 0; background: none; color: inherit; }
.md pre .copy-code {
  position: absolute; top: var(--space-xs); right: var(--space-xs); display: inline-flex; align-items: center; gap: var(--space-2xs);
  min-height: 32px; padding: 0 var(--space-xs); border: 0; border-radius: var(--radius-inner);
  background: var(--color-code-chip); color: var(--color-code-fg); font-size: var(--text-xs); cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.md pre .copy-code:hover { background: var(--color-code-chip-hover); }
.md .table-wrap { overflow-x: auto; margin: var(--space-md) 0; }
.md table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: 1.5; }
.md th, .md td { padding: var(--space-xs) var(--space-sm) var(--space-xs) 0; text-align: left; vertical-align: top; overflow-wrap: normal; word-break: normal; min-width: 7em; }
.md th { border-bottom: var(--rule-hair) solid var(--color-rule-strong); color: var(--color-ink-2); font-weight: 600; white-space: nowrap; }
.md td { border-bottom: var(--rule-hair) solid var(--color-rule); }
.md td:first-child, .md th:first-child { min-width: 5.5em; white-space: nowrap; }
.md hr { margin: var(--space-lg) 0; border: 0; border-top: var(--rule-hair) solid var(--color-rule); }
.md a { color: var(--color-accent-strong); }
.md .link-host { font-size: var(--text-xs); color: var(--color-muted); }

/* ---------- Team relay ---------- */
.team-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md); border-radius: var(--radius-panel); background: var(--color-paper-2);
}
.team-head h2 { font-size: var(--text-md); }
.team-head .status { margin-left: auto; font-size: var(--text-sm); color: var(--color-muted); }
.relay { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs); font-size: var(--text-sm); color: var(--color-ink-2); }
.relay .arrow { color: var(--color-muted); }
.team-head { position: relative; }
.relay [data-relay] { border-radius: 6px; transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out); }
.relay [data-relay].is-active { background: var(--color-accent-soft); color: var(--color-accent-strong); box-shadow: 0 0 0 3px var(--color-accent-soft); }
/* The handoff: a short glowing line runs from one agent to the next (script positions it) */
.relay-pulse {
  position: absolute; left: 0; top: 0; width: 32px; height: 2px; border-radius: 2px; opacity: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent); box-shadow: 0 0 8px 1px var(--color-accent);
}
.team-body { margin-top: var(--space-md); }
.plan { padding: var(--space-xs) 0 var(--space-md); }
.plan > p { margin-bottom: var(--space-sm); max-width: var(--measure); color: var(--color-ink-2); font-size: var(--text-sm); }
.plan-steps { margin: 0; padding: 0; list-style: none; border-top: var(--rule-hair) solid var(--color-rule); }
.plan-step { border-bottom: var(--rule-hair) solid var(--color-rule); }
.plan-step label { display: flex; align-items: center; gap: var(--space-sm); min-height: 52px; padding: var(--space-xs) 0; cursor: pointer; }
.plan-step.off .avatar { opacity: 0.55; }
.plan-step.off .task, .plan-step.off .task strong, .plan-step.off .task strong .role { color: var(--color-muted); }
.plan-step.off .task strong { text-decoration: line-through; }
.plan-step .num { width: 20px; text-align: center; font-size: var(--text-sm); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.plan-step .task { flex: 1; font-size: var(--text-sm); color: var(--color-ink-2); }
.plan-step .task strong { display: block; color: var(--color-ink); }
.plan-step .task strong .role, .step-title strong .role { margin-left: var(--space-xs); font-weight: 400; color: var(--color-muted); }
.plan-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); margin-top: var(--space-md); }
.plan-actions select { max-width: 14rem; }

/* Each step hangs off one rail; the avatar sits on it */
.step { margin-left: calc(var(--avatar) / 2 - 1px + var(--space-md) + var(--rule-hair)); border-left: 2px solid var(--color-rule); }
.step > summary {
  display: flex; align-items: center; gap: var(--space-sm); min-height: 52px; margin-left: calc(var(--avatar) / -2 - 1px); padding: var(--space-xs) var(--space-xs) var(--space-xs) 0;
  list-style: none; cursor: pointer; border-radius: var(--radius-control);
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary .avatar { box-shadow: 0 0 0 4px var(--color-paper); }
.step > summary::after {
  content: ""; flex-shrink: 0; width: 8px; height: 8px; margin-left: var(--space-xs);
  border-right: 2px solid var(--color-muted); border-bottom: 2px solid var(--color-muted);
  transform: rotate(45deg); transition: transform var(--dur-short) var(--ease-out);
}
.step:not([open]) > summary::after { transform: rotate(-45deg); }
.step > summary:hover { background: var(--color-paper-2); }
.step .step-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.step .step-title .task { font-size: var(--text-sm); color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step .step-state { font-size: var(--text-xs); color: var(--color-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.step .step-body { padding: var(--space-2xs) 0 var(--space-lg) var(--space-lg); }
.final { margin-top: var(--space-lg); padding-top: var(--space-md); border-top: 2px solid var(--color-rule-strong); }
.final h3 { margin-bottom: var(--space-xs); font-size: var(--text-lg); }
.verdict {
  display: inline-flex; align-items: center; gap: var(--space-2xs); padding: var(--space-3xs) var(--space-sm);
  border: var(--rule-hair) solid; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 700;
}
.verdict.approve { border-color: var(--color-success-line); background: var(--color-success-soft); color: var(--color-success); }
.verdict.comments { border-color: var(--color-accent-line); background: var(--color-accent-soft); color: var(--color-accent-strong); }
.verdict.changes { border-color: var(--color-warning-line); background: var(--color-warning-soft); color: var(--color-warning); }
.verdict.escalate { border-color: var(--color-error-line); background: var(--color-error-soft); color: var(--color-error); }

/* ---------- Composer ---------- */
.composer { padding: var(--space-xs) var(--space-lg) var(--space-sm); }
.composer-box {
  position: relative; max-width: var(--thread-w); margin: 0 auto; padding: var(--space-sm) var(--space-sm) var(--space-xs);
  border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-panel);
  background: var(--color-sheet); box-shadow: var(--shadow-raised);
}
.composer-box:focus-within { outline: 2px solid var(--color-focus); outline-offset: -1px; } /* drawn over the border, so no gap shows between the box and its ring */
.composer-box.dropping { border-color: var(--color-accent); background: var(--color-accent-soft); }
.composer textarea {
  display: block; width: 100%; min-height: 28px; max-height: 220px; padding: var(--space-2xs) var(--space-2xs);
  border: 0; resize: none; background: transparent; line-height: 1.5;
}
.composer textarea:focus-visible { outline: none; }
.composer-bar { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: var(--space-xs); margin-top: var(--space-xs); }
.composer-left, .composer-right { display: flex; align-items: center; gap: var(--space-xs); }
.composer-left { flex: 1 1 0; flex-wrap: wrap; min-width: 0; }
.btn-attach { flex: none; color: var(--color-ink-2); }
#send, #stop { flex: none; min-width: 5.5rem; }
.agent-select { flex: 0 1 15rem; min-width: 0; }
.agent-select select { width: 100%; padding: 0 var(--space-sm); background: var(--color-paper); font-size: var(--text-sm); font-weight: 600; }
.team-toggle {
  display: flex; align-items: center; gap: var(--space-xs); min-height: var(--target); padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-control);
  background: var(--color-paper); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; cursor: pointer;
}
@media (hover: hover) { .team-toggle:hover { background: var(--color-paper-3); } }
.team-toggle:has(input:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); color: var(--color-accent-strong); }
.hint { font-size: var(--text-xs); white-space: nowrap; }
.composer-bar:has(#stop:not([hidden])) .hint { visibility: hidden; }
.disclaimer { max-width: var(--thread-w); margin: var(--space-xs) auto 0; padding-inline: var(--space-2xs); font-size: var(--text-xs); text-wrap: balance; }
.mention-menu {
  position: absolute; bottom: calc(100% + var(--space-xs)); left: var(--space-sm); z-index: var(--z-dropdown); min-width: 260px;
  padding: var(--space-2xs); background: var(--color-sheet); border-radius: var(--radius-control); box-shadow: var(--shadow-menu);
}
.mention-item { display: flex; align-items: center; gap: var(--space-sm); min-height: var(--target); padding: var(--space-2xs) var(--space-xs); border-radius: var(--radius-inner); cursor: pointer; }
.mention-item > div:not(.avatar) { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-item[aria-selected="true"], .mention-item:hover { background: var(--color-accent-soft); }
.mention-item .avatar { width: 24px; height: 24px; }

/* ---------- Privacy notice: long enough to scroll inside the dialog; actions wrap on narrow screens ---------- */
#notice-modal .notice-body { max-height: min(60vh, 34rem); overflow-y: auto; padding: var(--space-2xs) var(--space-xs); margin-inline: calc(-1 * var(--space-xs)); }
#notice-modal .notice-body:focus-visible { outline-offset: 0; }
#notice-modal .notice-body h3 { margin: var(--space-sm) 0 var(--space-2xs); }
#notice-modal .notice-body p, #notice-modal .notice-body li { font-size: var(--text-sm); }
.notice-actions { flex-wrap: wrap; }

/* ---------- Deep links: the note shown when a link can't be used ---------- */
.link-note {
  display: flex; align-items: center; gap: var(--space-xs); margin: var(--space-xs) var(--space-lg) 0; padding: var(--space-2xs) var(--space-2xs) var(--space-2xs) var(--space-sm);
  border: var(--rule-hair) solid var(--color-warning-line); border-radius: var(--radius-control);
  background: var(--color-warning-soft); color: var(--color-warning); font-size: var(--text-sm); overflow-wrap: anywhere;
}
.link-note[hidden] { display: none; }
.link-note > span { flex: 1; }
.link-note-url { flex: 2; min-width: 0; min-height: var(--target); padding: 0 var(--space-xs); border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-inner); background: var(--color-sheet); color: var(--color-ink); font-family: var(--font-mono); font-size: var(--text-xs); }
.link-note-url[hidden] { display: none; }
.guided-links { margin: 0 0 var(--space-sm); padding: 0; list-style: none; }
.guided-links li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); min-height: var(--target); border-bottom: var(--rule-hair) solid var(--color-rule); font-size: var(--text-sm); }

/* ---------- Outputs panel ---------- */
.outputs {
  width: var(--outputs-w); flex-shrink: 0; overflow-y: auto; padding: var(--space-md);
  background: var(--color-sheet); border-left: var(--rule-hair) solid var(--color-rule);
}
.outputs-head { display: flex; align-items: center; justify-content: space-between; }
.outputs-head h2 { font-size: var(--text-md); }
.outputs > p { margin-top: var(--space-2xs); }
.outputs-list { display: flex; flex-direction: column; margin: var(--space-md) 0 0; padding: 0; list-style: none; border-top: var(--rule-hair) solid var(--color-rule); }
.output-item { display: flex; flex-direction: column; gap: var(--space-xs); padding: var(--space-sm) 0; border-bottom: var(--rule-hair) solid var(--color-rule); }
.output-item .top { display: flex; align-items: center; gap: var(--space-xs); }
.output-item .avatar { width: var(--avatar); height: var(--avatar); }
.output-item .title { font-size: var(--text-sm); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.output-item .by { font-size: var(--text-xs); color: var(--color-muted); }
.output-item .actions { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }

/* ---------- Dialogs ---------- */
.modal {
  width: calc(100% - 32px); max-width: 520px; padding: var(--space-lg);
  border: 0; border-radius: var(--radius-panel); background: var(--color-sheet); color: var(--color-ink); box-shadow: var(--shadow-dialog);
}
.modal[open] { animation: rise-in var(--dur-short) var(--ease-out); }
.modal::backdrop { background: var(--color-scrim); }
.modal-wide { max-width: 920px; min-height: min(34rem, calc(100dvh - 38px)); }
.modal h2 { margin-bottom: var(--space-sm); font-size: var(--text-lg); }
.modal h3 { margin: var(--space-lg) 0 var(--space-xs); font-size: var(--text-md); }
.modal ul, .modal ol { padding-left: var(--space-lg); line-height: var(--leading-prose); }
.modal .guided-links { padding-left: 0; }
.modal p { line-height: var(--leading-prose); }
.modal > p { margin-bottom: var(--space-md); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
/* A long dialog keeps its title and Close in view */
.modal-head { position: sticky; top: calc(-1 * var(--space-lg)); z-index: 1; margin-top: calc(-1 * var(--space-lg)); padding: var(--space-lg) 0 var(--space-xs); background: var(--color-sheet); }
#usage-body > :first-child { margin-top: var(--space-xs); }
#usage-body > p:last-child { margin-top: var(--space-sm); }
#agents-table > p:first-of-type { margin-top: var(--space-sm); }
.modal-head h2 { margin-bottom: 0; }
.modal > .notice-box { margin-bottom: var(--space-md); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-xs); margin-top: var(--space-md); }
.data-table { width: 100%; margin-top: var(--space-xs); border-collapse: collapse; font-size: var(--text-sm); }
.data-table th, .data-table td { padding: var(--space-xs) var(--space-sm) var(--space-xs) 0; text-align: left; vertical-align: middle; }
.data-table th { border-bottom: var(--rule-hair) solid var(--color-rule-strong); color: var(--color-ink-2); font-weight: 600; white-space: nowrap; }
.data-table td { border-bottom: var(--rule-hair) solid var(--color-rule); }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.modal-wide .table-scroll { margin-top: var(--space-xs); }
.table-scroll > .data-table { margin-top: 0; }
.data-table td.small, .data-table td.nowrap, #users-table td:last-child { white-space: nowrap; }
.tag {
  display: inline-block; padding: var(--space-3xs) var(--space-xs); border-radius: var(--radius-pill);
  background: var(--color-paper-3); color: var(--color-ink-2); font-size: var(--text-xs); font-weight: 700; white-space: nowrap;
}
.tag.admin { background: var(--color-accent-soft); color: var(--color-accent-strong); }
.tag.off { background: var(--color-error-soft); color: var(--color-error); }
.tag.pending { background: var(--color-warning-soft); color: var(--color-warning); }
.row-actions { display: flex; flex-wrap: nowrap; gap: var(--space-2xs); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-xs); margin-bottom: var(--space-md); }
.field label { font-size: var(--text-sm); font-weight: 600; }
.field input, .field select {
  min-width: 0;
  min-height: var(--hit); padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-control-line); border-radius: var(--radius-control); background: var(--color-sheet);
}
.field input:focus-visible, .field select:focus-visible, .search input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -1px; }
@media (hover: hover) { .field input:hover:not(:focus-visible):not(:disabled):not([aria-invalid="true"]) { border-color: var(--color-ink-2); } }
.field input[aria-invalid="true"] { border-color: var(--color-error); }
.field .help, .pw-help { min-height: 1lh; font-size: var(--text-sm); color: var(--color-muted); }
.field-error { font-size: var(--text-sm); color: var(--color-error); }
.password-wrap { position: relative; display: flex; }
.password-wrap input { flex: 1; padding-right: var(--space-2xl); }
.password-wrap .icon-btn, .toggle-pw { position: absolute; top: 50%; right: 0; width: var(--hit); height: var(--hit); transform: translateY(-50%); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 150px auto; gap: var(--space-sm); align-items: end; }
.form-grid .field { margin-bottom: 0; }
.form-grid .btn { min-height: var(--hit); }
.secret {
  padding: var(--space-2xs) var(--space-xs); border: var(--rule-hair) dashed var(--color-rule-strong); border-radius: var(--radius-inner);
  background: var(--color-sheet); font-family: var(--font-mono); font-size: var(--text-md); user-select: all;
}

/* ---------- Sign-in page ---------- */
body.auth-page { display: grid; place-items: center; min-height: 100dvh; padding: var(--space-lg); overflow-y: auto; isolation: isolate; }
body.auth-page::before {
  content: ""; position: fixed; z-index: -1; inset: -10% -10% auto -10%; height: 70vh; pointer-events: none;
  background:
    radial-gradient(45% 70% at 30% 10%, var(--color-glow-1), transparent 70%),
    radial-gradient(40% 60% at 72% 15%, var(--color-glow-2), transparent 72%),
    radial-gradient(30% 50% at 50% 40%, var(--color-glow-3), transparent 75%);
  -webkit-mask-image: radial-gradient(closest-side, var(--mask-solid) 55%, transparent);
  mask-image: radial-gradient(closest-side, var(--mask-solid) 55%, transparent);
  animation: glow-settle var(--dur-bloom) var(--ease-out) both; /* settles once into its resting place */
}
body.auth-page.tab-hidden::before { animation-play-state: paused; }
/* Under reduced motion the glow simply shows, with no settle. */
@media (prefers-reduced-motion: reduce) { body.auth-page::before { animation: none; } }
.auth-card {
  width: 100%; max-width: 420px; padding: var(--space-xl) var(--space-lg) var(--space-lg);
  border: var(--rule-hair) solid var(--color-glass-line); border-radius: var(--radius-panel); box-shadow: var(--shadow-float);
  /* No backdrop blur here: the glow moves behind the card, and a blur would be redone on every frame */
  background: color-mix(in oklch, var(--color-sheet) 90%, transparent);
  animation: rise-in var(--dur-rise) var(--ease-out) both;
}
/* Sign-in: the card rises in, then the brand and each form row follow 40ms apart (all done by 500ms). A wrong password shakes the card
   (script); a successful sign-in lets it shrink and fade before the app opens (script). */
@keyframes glow-settle { from { transform: translate3d(4%, 3%, 0) scale(1.12); opacity: 1; } to { transform: translate3d(-4%, -2%, 0) scale(1); opacity: 0.85; } }
.auth-card .brand, .auth-card form > :not(.error-box) { animation: rise-in var(--dur-rise) var(--ease-out) both; animation-delay: min(calc(60ms + var(--n, 0) * 40ms), 180ms); }
.auth-card .brand { --n: 0; }
.auth-card form > :nth-child(1) { --n: 1; }
.auth-card form > :nth-child(2) { --n: 2; }
.auth-card form > :nth-child(4) { --n: 3; }
.auth-card form > :nth-child(5) { --n: 4; }
.auth-card form > :nth-child(6) { --n: 5; }
.auth-card form > :nth-child(7) { --n: 6; }
.auth-card form > :nth-child(8) { --n: 7; }
.auth-card form > :nth-child(9) { --n: 8; }
.auth-card form > :nth-child(10) { --n: 9; }
.auth-card .brand { margin-bottom: var(--space-lg); padding: 0; }
.auth-layout .auth-card { min-height: 31rem; }
.auth-card .brand-name { font-size: var(--text-lg); }
.auth-card h1 { margin-bottom: var(--space-2xs); font-size: var(--text-xl); }
.auth-card .lead { margin-bottom: var(--space-lg); color: var(--color-ink-2); font-size: var(--text-sm); }
.auth-card .btn { width: 100%; min-height: var(--hit); }
.auth-card .error-box { margin-bottom: var(--space-md); }
.auth-foot { margin-top: var(--space-lg); color: var(--color-muted); font-size: var(--text-xs); }

/* ---------- Glass and depth: the message box floats over the thread, the top bar and sheets are frosted ---------- */
.main { position: relative; }
.topbar {
  position: relative; z-index: var(--z-dropdown);
  background: var(--color-glass); border-bottom-color: var(--color-glass-line);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%); backdrop-filter: blur(var(--glass-blur)) saturate(150%);
}
.thread { padding-bottom: calc(var(--composer-h, 160px) + var(--space-md)); scroll-padding-bottom: calc(var(--composer-h, 160px) + var(--space-md)); }
.composer {
  position: absolute; inset: auto 0 0 0; z-index: var(--z-raised); pointer-events: none;
  padding-top: var(--space-xl); padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--color-paper) 55%);
}
.composer > * { pointer-events: auto; }
.composer-box {
  border-color: var(--color-glass-line); background: var(--color-glass); box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%); backdrop-filter: blur(var(--glass-blur)) saturate(150%);
}
.btn-primary { box-shadow: 0 6px 20px -8px var(--color-accent), inset 0 1px 0 var(--color-sheen-strong); }
.msg-user .bubble { background: var(--color-bubble); border: var(--rule-hair) solid var(--color-glass-line); }
.team-head { background: var(--color-row); border: var(--rule-hair) solid var(--color-glass-line); }

/* Start screen: a big, tight headline over a soft glow in the brand blue */
.empty { position: relative; padding-top: var(--space-2xl); isolation: isolate; }
.empty::before {
  content: ""; position: absolute; z-index: -1; inset: -64px 5% auto 5%; height: 480px; pointer-events: none;
  background:
    radial-gradient(55% 75% at 26% 4%, var(--color-glow-1), transparent 70%),
    radial-gradient(45% 65% at 76% 8%, var(--color-glow-2), transparent 72%),
    radial-gradient(35% 50% at 55% 32%, var(--color-glow-3), transparent 75%);
  -webkit-mask-image: radial-gradient(closest-side, var(--mask-solid) 55%, transparent);
  mask-image: radial-gradient(closest-side, var(--mask-solid) 55%, transparent);
}
.start-head h2 { font-size: clamp(2rem, 1.2rem + 2vw, 2.75rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; }
.start-head p { font-size: var(--text-lg); }
.start-head .welcome { color: var(--color-ink); font-weight: 600; }
.start-head .welcome + p { margin-top: var(--space-2xs); font-size: var(--text-md); color: var(--color-muted); }

/* The roster: rows that lift under the pointer; the selected one carries the accent */
.roster { gap: var(--space-2xs); border-top: 0; }
.roster-row {
  border: var(--rule-hair) solid transparent; border-radius: var(--radius-control); background: var(--color-row);
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out);
}
.roster-row:hover { background: var(--color-row-hover); border-color: var(--color-glass-line); }
.roster-row[aria-pressed="true"] { background: var(--color-accent-soft); border-color: var(--color-accent-line); }
.roster-row .avatar { border-radius: var(--radius-control); box-shadow: 0 0 0 1px var(--color-glass-line), 0 6px 18px -6px var(--color-tile-glow); }
.example { border-radius: var(--radius-control); }

/* Theme switch cross-fades the whole page */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--dur-short); animation-timing-function: var(--ease-out); }

/* Theme switch: script drives a circular reveal of the new theme, so the default cross-fade is off. */
:root[data-theme-switch]::view-transition-old(root),
:root[data-theme-switch]::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
:root[data-theme-switch]::view-transition-old(root) { z-index: 1; }
:root[data-theme-switch]::view-transition-new(root) {
  z-index: 2;
  /* The 64px soft edge must match SOFT_EDGE_PX in js/theme.js, which times the status bar change from it. */
  -webkit-mask-image: radial-gradient(circle at var(--vt-x) var(--vt-y), #000 calc(var(--vt-r) - 64px), transparent var(--vt-r));
  mask-image: radial-gradient(circle at var(--vt-x) var(--vt-y), #000 calc(var(--vt-r) - 64px), transparent var(--vt-r));
}
@property --vt-r { syntax: '<length>'; inherits: true; initial-value: 0px; }

/* Sun and moon morph: the rays turn away and a mask slides in to carve the crescent. */
#toggle-theme .sun-and-moon { overflow: visible; }
#toggle-theme .sun-and-moon .sun { transform-origin: 12px 12px; transform: scale(1.6); transition: transform var(--dur-morph) var(--ease-spring); }
#toggle-theme .sun-and-moon .sun-beams { transform-origin: 12px 12px; opacity: 0; transform: rotate(-60deg) scale(0.6); transition: transform var(--dur-short) var(--ease-spring), opacity var(--dur-short) var(--ease-out); }
#toggle-theme .sun-and-moon .moon-cut { transform: translateX(-7px); transition: transform var(--dur-morph) var(--ease-out) 80ms; }
#toggle-theme.is-dark .sun-and-moon .sun { transform: scale(1); transition-delay: 120ms; }
#toggle-theme.is-dark .sun-and-moon .sun-beams { opacity: 1; transform: rotate(0) scale(1); transition-delay: 180ms; }
#toggle-theme.is-dark .sun-and-moon .moon-cut { transform: translateX(0); transition-delay: 0ms; }
#toggle-theme.theme-pulse { animation: theme-pulse var(--dur-theme) var(--ease-out) both; }
@keyframes theme-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--color-accent) 45%, transparent); }
  100% { box-shadow: 0 0 0 14px color-mix(in oklch, var(--color-accent) 0%, transparent); }
}

/* ---------- Motion ----------
   New messages settle in; the specialist working in a Team run pulses on the rail and the rail fills as each one
   finishes; a verdict pops in once; a fresh start screen cascades in while its glow blooms once; rows and buttons lift
   under the pointer; menus, sheets, the Outputs panel and dialogs rise as they open. Transform and opacity only;
   the reduced-motion rule in the base layer stills all of it, and nothing here hides content when scripts are off.
   app.js keeps each animation's clock across re-renders. */
@keyframes settle-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes settle-badge { 0% { opacity: 0; transform: scale(1.5); } 45% { opacity: 1; transform: scale(0.92); } 70% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes verdict-sweep { from { transform: translateX(-110%); } to { transform: translateX(110%); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes drift { from { transform: translate3d(-2%, 0, 0) scale(1); } to { transform: translate3d(2%, 2%, 0) scale(1.06); } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(100%); } }
@keyframes working-ring { from { opacity: 0.6; transform: scale(1); } to { opacity: 0; transform: scale(1.55); } }
@keyframes breathe { from { opacity: 0.45; } to { opacity: 1; } }

.msg.enter { animation: settle-in var(--dur-short) var(--ease-out) both; }
/* The verdict is stamped down once: it lands from slightly above, presses in, and a band of its own colour sweeps across */
.verdict.settle { position: relative; overflow: hidden; animation: settle-badge var(--dur-stamp) var(--ease-out) both; }
.verdict.settle::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 25%, color-mix(in oklch, currentColor 32%, transparent) 50%, transparent 75%);
  animation: verdict-sweep var(--dur-stamp) var(--ease-out) both;
}

/* Start screen: headline, roster and examples cascade in, 30ms apart and all done by 500ms, while the glow blooms once into place */
.empty.cascade .start-head { animation: rise-in var(--dur-rise) var(--ease-out) both; }
.empty.cascade .roster-row, .empty.cascade .example { animation: rise-in var(--dur-rise) var(--ease-out) both; animation-delay: min(calc(var(--i, 0) * 30ms + 40ms), 180ms); }
.empty::before { transform: translate3d(2%, 2%, 0) scale(1.06); }
.empty.cascade::before { animation: drift var(--dur-bloom) var(--ease-out) both; }

/* What an agent is doing while no text streams: a quiet line with a sheen passing through it */
.activity {
  margin-top: var(--space-xs); width: fit-content; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--color-muted); font-size: var(--text-sm);
  background: linear-gradient(90deg, var(--color-muted) 0%, var(--color-ink) 50%, var(--color-muted) 100%) 0 0 / 200% 100%;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  animation: activity-sheen 1.6s linear infinite, fade-in var(--dur-short) var(--ease-out);
}
@keyframes activity-sheen { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (forced-colors: active) { .activity { background: none; -webkit-text-fill-color: currentColor; } }
/* A glyph for the state the server reported, set once when the state starts; the sheen above is the only loop */
.activity .act-icon { display: inline-block; vertical-align: -2px; margin-right: var(--space-2xs); line-height: 0; }
.activity .act-icon:empty { display: none; }
.activity .act-icon .icon { width: 14px; height: 14px; color: var(--color-muted); -webkit-text-fill-color: currentColor; }
.activity[data-kind="thinking"] .act-icon .icon { animation: glyph-pop 320ms var(--ease-out) both; }
.activity[data-kind="searching"] .act-icon .icon { animation: glyph-swing 420ms var(--ease-out) both; }
.activity[data-kind="reading"] .act-icon .icon { animation: glyph-rise 320ms var(--ease-out) both; }
.activity[data-kind="reference"] .act-icon .icon { animation: fade-in 320ms var(--ease-out) both; }
@keyframes glyph-pop { from { opacity: 0; transform: scale(0.4) rotate(-45deg); } }
@keyframes glyph-swing { from { opacity: 0; transform: translate(-3px, 2px) rotate(-25deg); } }
@keyframes glyph-rise { from { opacity: 0; transform: translateY(4px); } }
/* The writing mark: shown while answer text really streams, gone when it ends */
.writing { display: inline-flex; align-self: center; color: var(--color-accent); }
.writing .icon { width: 14px; height: 14px; }
.step > summary .writing { margin-right: var(--space-2xs); }

/* The Team rail fills with the accent up to the agent at work */
.step { transition: border-color var(--dur-short) var(--ease-out); }
.step.is-done, .step.is-working { border-left-color: var(--color-accent-line); }

/* Lifts under the pointer, only where a pointer can hover */
@media (hover: hover) {
  .roster-row:hover, .example:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
  .btn-primary:hover { transform: translateY(-1px); }
}
.example { transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out); }
.dl-menu, .mention-menu { animation: drop-in var(--dur-micro) var(--ease-out); }
.outputs { animation: slide-in 280ms var(--ease-out) both; }
.modal::backdrop { animation: fade-in var(--dur-short) var(--ease-out); }
@media (prefers-reduced-motion: reduce) { .modal::backdrop { animation: none; } }

/* The one doing the work: a ring that leaves the avatar on the rail, while that step streams */
.step.is-working > summary .avatar, .team.is-planning .team-head .avatar { position: relative; }
.step.is-working > summary .avatar::after, .team.is-planning .team-head .avatar::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius-control);
  box-shadow: 0 0 0 2px var(--color-accent); animation: working-ring 1.4s var(--ease-out) infinite;
}

/* Waiting for the first words: three lines in the shape of the answer */
.msg-agent .md.typing:empty::before {
  content: ""; display: block; height: 3.4em; max-width: 30rem; border-radius: var(--radius-inner);
  background: repeating-linear-gradient(to bottom, var(--color-paper-3) 0 0.7em, transparent 0.7em 1.15em);
  animation: breathe 1.1s ease-in-out infinite alternate;
}
.msg-agent .md.typing:empty::after { display: none; }

/* Pressed controls give under the pointer */
.btn, .msg-actions button, .icon-btn { transition-property: background-color, border-color, color, transform; }
.btn:active:not(:disabled), .icon-btn:active:not(.toggle-pw) { transform: translateY(1px); }

/* Copy: the icon becomes a tick that draws itself once; script puts it back after 1.2s */
@keyframes tick-draw { from { stroke-dasharray: 30; stroke-dashoffset: 30; } to { stroke-dasharray: 30; stroke-dashoffset: 0; } }
@keyframes tick-pop { from { transform: scale(0.5); } 60% { transform: scale(1.18); } to { transform: scale(1); } }
.msg-actions button.copied .icon, .copy-code.copied .icon { animation: tick-pop 300ms var(--ease-out) both; }
.msg-actions button.copied .icon path, .copy-code.copied .icon path { animation: tick-draw 320ms var(--ease-out) 60ms both; }

/* Guided task cards: lift a little under the pointer or keyboard focus; the icon nudges along */
.examples.guided > .example .who .icon { transition: transform var(--dur-short) var(--ease-out); }
.examples.guided > .example:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.examples.guided > .example:focus-visible .who .icon { transform: translateX(3px) scale(1.12); }
@media (hover: hover) {
  .examples.guided > .example:hover { transform: translateY(-2px); }
  .examples.guided > .example:hover .who .icon { transform: translateX(3px) scale(1.12); }
}

/* Send and Stop: the plane that flies off, and the Outputs copy that slides away (both made by script, for a moment) */
.send-ghost { position: fixed; z-index: var(--z-drawer); pointer-events: none; display: grid; place-items: center; color: var(--color-accent); }
.send-ghost svg { width: 100%; height: 100%; }
.outputs-ghost { position: fixed; z-index: var(--z-drawer); margin: 0; pointer-events: none; animation: none; }
.content.is-sliding { overflow-x: clip; }

/* Top bar shadow grows as the thread scrolls (scroll-driven; no script). The shadow is a layer whose opacity is
   driven, so nothing repaints while scrolling. Where unsupported the bar keeps its plain edge. */
@supports (animation-timeline: scroll()) and (timeline-scope: --thread-scroll) {
  .main { timeline-scope: --thread-scroll; }
  .thread { scroll-timeline: --thread-scroll block; }
  .topbar::after {
    content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; pointer-events: none; opacity: 0;
    background: linear-gradient(to bottom, var(--color-shadow), transparent);
    animation: topbar-shadow linear both; animation-timeline: --thread-scroll; animation-range: 0 64px;
  }
  @keyframes topbar-shadow { to { opacity: 0.5; } }
  /* Scroll-linked opacity is not motion, so it stays under reduced motion; the base layer's time limits must not
     collapse it (a scroll timeline has no duration of its own) */
  @media (prefers-reduced-motion: reduce) {
    .topbar::after { animation-duration: auto !important; animation-iteration-count: 1 !important; }
  }
}

/* ---------- Utilities (instead of inline styles, so the CSP needs no 'unsafe-inline') ---------- */
.u-pad-8 { padding: var(--space-xs); }
.u-pad-24 { padding: var(--space-lg); }
.u-minw-0 { min-width: 0; }
.u-row { display: flex; align-items: center; gap: var(--space-xs); }
.u-wrap { flex-wrap: wrap; }
.u-mt-8 { margin-top: var(--space-xs); }
.u-mt-12 { margin-top: var(--space-sm); }

/* ---------- Touch: every control reaches a 44px hit target on a coarse pointer ---------- */
@media (pointer: coarse) {
  .msg-actions button, .meta summary, .mention-item, .routed select, .md pre .copy-code { min-height: var(--hit); }
  .msg-actions button { min-width: var(--hit); justify-content: center; }
  .meta summary { min-width: var(--hit); padding-inline: var(--space-xs); }
  .conv-actions .icon-btn, .file-chip .icon-btn { width: var(--hit); height: var(--hit); }
  .conv-actions .icon { width: 18px; height: 18px; }
  .btn-sm { min-height: var(--hit); padding: 0 var(--space-sm); }
  .composer textarea { min-height: var(--hit); }
}

/* ---------- Narrower screens ---------- */
@media (max-width: 84rem) {
  .topbar { flex-wrap: wrap; row-gap: var(--space-2xs); }
  /* The controls row wraps instead of pushing Export and Outputs off screen at tablet widths */
  .topbar-controls { width: 100%; flex-wrap: wrap; row-gap: var(--space-2xs); }
  .topbar-controls #export-chat { margin-left: auto; }
  .hint { display: none; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
/* Tablet widths only: a tighter controls row (phones show the Release label in the Options sheet) */
@media (min-width: 40.01rem) and (max-width: 84rem) {
  .topbar-controls .control:not(.switch) > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .topbar-controls #release { max-width: 11rem; }
}
@media (max-width: 60rem) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: var(--z-drawer); transform: translateX(-100%);
    transition: transform var(--dur-short) var(--ease-out), visibility 0s var(--dur-short);
    visibility: hidden;
  }
  /* Closed, the drawer is out of the tab order and the accessibility tree and casts no shadow onto the page */
  .sidebar.open { transform: none; visibility: visible; transition-delay: 0s; box-shadow: var(--shadow-dialog); }
  .sidebar.open ~ .main::after { content: ""; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--color-scrim); animation: fade-in var(--dur-short) var(--ease-out); }
  .only-mobile, .icon-btn.only-mobile { display: inline-grid; }
  .outputs { position: fixed; inset: 0 0 0 auto; z-index: var(--z-drawer); width: min(100%, var(--outputs-w)); box-shadow: var(--shadow-dialog); }
  .output-item .actions { display: grid; grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: var(--space-xs) var(--space-sm); }
  .thread { padding-top: var(--space-md); padding-inline: var(--space-sm); }
  .composer { padding-top: var(--space-xs); padding-inline: var(--space-sm); }
  .link-note { margin-inline: var(--space-sm); }
  .step .step-body { padding-left: var(--space-md); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 40rem) {
  /* One-row top bar; release, sources, export and outputs open as a frosted sheet under it */
  .topbar { flex-wrap: nowrap; gap: var(--space-2xs); min-height: 52px; padding: var(--space-2xs) var(--space-xs); padding-top: max(var(--space-2xs), env(safe-area-inset-top)); }
  .topbar .only-phone { display: inline-grid; }
  .conversation-title { font-size: var(--text-md); }
  .mode-badge { padding: var(--space-3xs) var(--space-2xs); }
  .topbar-controls {
    display: none; position: absolute; top: 100%; left: 0; right: 0; width: auto;
    flex-wrap: wrap; gap: var(--space-xs); padding: var(--space-sm);
    background: var(--color-sheet); border-bottom: var(--rule-hair) solid var(--color-glass-line); box-shadow: var(--shadow-menu);
  }
  .topbar.options-open .topbar-controls { display: flex; animation: sheet-in var(--dur-short) var(--ease-out); }
  .topbar-controls .control:not(.switch) { flex: 1 1 100%; }
  .topbar-controls .control select { flex: 1; }
  .topbar-controls .switch { flex: 0 0 auto; }
  .topbar-controls #export-chat, .topbar-controls #toggle-outputs { flex: 1 1 100%; margin-left: 0; }
  .topbar-controls .switch { margin-inline: 0; padding-inline: 0; }
  /* The page behind the Options sheet dims like it does behind the drawer */
  .topbar.options-open ~ .content::after { content: ""; position: fixed; inset: 52px 0 0 0; z-index: calc(var(--z-dropdown) - 1); background: var(--color-scrim); pointer-events: none; }
  .empty { padding-top: var(--space-md); }
  .start-head h2 { font-size: var(--text-xl); }
  .start-head .welcome { font-size: var(--text-md); }
  .start-head .welcome + p { font-size: var(--text-sm); }
  /* One row under the text box: attach, agent, team, send */
  .composer-bar { flex-wrap: nowrap; }
  .composer-left { flex-wrap: nowrap; gap: var(--space-2xs); }
  .agent-select { flex: 1 1 auto; }
  .btn-attach, #send, #stop { width: var(--target); min-width: 0; padding: 0; }
  .btn-attach .label, #send .label, #stop .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .team-toggle { padding: 0 var(--space-2xs); }
  .agent-select select { padding-inline: var(--space-xs); }
  .msg-user .bubble, .user-wrap { max-width: 92%; }

  /* Calm phone layout: what you need for the next step is on screen; the rest is one tap away.
     Theme and mode move into the Options sheet; long descriptions, roles, costs and reasons hide;
     well-known actions (copy, download, rate) become icons with names for screen readers. */
  .topbar-controls #toggle-theme { display: inline-flex; align-items: center; width: auto; gap: var(--space-2xs); padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-control); }
  .topbar-controls #toggle-theme .label { display: inline; font-size: var(--text-sm); }
  .topbar-controls .mode-badge { align-self: center; }

  .start-head .welcome + p { display: none; }
  .start-head { margin-bottom: var(--space-md); }
  .roster { gap: var(--space-2xs); }
  .roster-row { grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; padding-block: var(--space-xs); }
  .roster-row .avatar { width: 40px; height: 40px; }
  .roster-row .good { display: none; }
  .roster-row .pick .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .examples { margin-top: var(--space-lg); }
  .examples > .example:nth-child(n+5) { display: none; }
  /* Guided tasks work from exported files, which is desk work; the phone start stays short. */
  .examples.guided { display: none; }
  .example .text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

  .team-toggle .long, .disclaimer .long, .keep-label .long { display: none; }
  .team-toggle .short, .disclaimer .short, .keep-label .short { display: inline; }
  .disclaimer { text-align: center; }

  .msg-head .role, .routed .why, .routed .label { display: none; }
  .routed { padding: var(--space-2xs) var(--space-xs); }
  .msg-actions { gap: 0; }
  .msg-actions button:not(.keep-label) .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .step-title .role { display: none; }
  .step:not(.is-working) .step-state { display: none; }
}

/* Guided tasks: the agent name trails the hint */
.examples.guided { margin-top: 0; }
.examples.guided .text .muted { color: var(--color-muted); white-space: nowrap; }
.examples.guided .text .muted::before { content: '· '; }

/* Checkboxes inside switches show they can be clicked, like their labels. */
.switch input, .team-toggle, .team-toggle input, .plan-step input { cursor: pointer; }

/* Phones: 16px text in selects stops iOS from zooming in when they are tapped. */
@media (max-width: 40rem) {
  .agent-select select, .topbar-controls select { font-size: max(16px, var(--text-sm)); }
}

/* Touch: source links get a full-size hit area. */
@media (pointer: coarse) {
  .sources li > a { display: inline-flex; align-items: center; min-height: var(--hit); }
}

/* ---------- Sign-in hero: what the Hub is, beside the card on wide screens and above it on phones ---------- */
.auth-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); align-items: center; width: 100%; max-width: 1080px; }
@media (min-width: 60rem) { .auth-layout { grid-template-columns: minmax(0, 1fr) 420px; gap: clamp(2rem, 6vw, 5rem); } }
.auth-layout .auth-card { justify-self: center; }
.auth-hero { max-width: 34rem; }
.auth-hero > * { animation: rise-in var(--dur-rise) var(--ease-out) both; animation-delay: min(calc(40ms + var(--n, 0) * 40ms), 180ms); }
.hero-eyebrow { --n: 0; margin: 0 0 var(--space-sm); color: var(--color-accent-strong); font-size: var(--text-sm); font-weight: 700; letter-spacing: 0.02em; }
.hero-title { --n: 1; margin: 0; font-size: clamp(2rem, 1.2rem + 3.2vw, 3.25rem); font-weight: 800; line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; color: var(--color-ink); }
.hero-accent { color: var(--color-accent-strong); }
.hero-sub { --n: 2; margin: var(--space-md) 0 0; max-width: 56ch; color: var(--color-ink-2); font-size: var(--text-md); line-height: 1.6; text-wrap: pretty; }
.hero-agents { --n: 3; display: flex; flex-wrap: wrap; gap: var(--space-md); margin: var(--space-lg) 0 0; padding: 0; list-style: none; }
.hero-agents li { display: grid; justify-items: center; gap: var(--space-2xs); }
.hero-avatar { display: block; width: 52px; height: 52px; border-radius: var(--radius-control); box-shadow: var(--shadow-float); overflow: hidden; }
.hero-avatar svg { display: block; width: 100%; height: 100%; }
.hero-agent-name { color: var(--color-ink-2); font-size: var(--text-xs); font-weight: 600; }
.hero-agents li { animation: pop-in var(--dur-rise) var(--ease-out) both; animation-delay: calc(100ms + var(--i, 0) * 20ms); }
.hero-agents li:nth-child(1) { --i: 0; } .hero-agents li:nth-child(2) { --i: 1; } .hero-agents li:nth-child(3) { --i: 2; } .hero-agents li:nth-child(4) { --i: 3; } .hero-agents li:nth-child(5) { --i: 4; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.85); } }
.hero-points { --n: 4; display: grid; gap: var(--space-xs); margin: var(--space-lg) 0 0; padding: 0; list-style: none; color: var(--color-ink-2); font-size: var(--text-sm); }
.hero-points li { display: flex; align-items: center; gap: var(--space-xs); }
.hero-points svg { width: 18px; height: 18px; color: var(--color-accent-strong); flex-shrink: 0; }
/* Phones: a short hero above the card; the details stay for wide screens. */
@media (max-width: 60rem) {
  .auth-layout { justify-items: center; gap: var(--space-lg); }
  .auth-hero { text-align: center; }
  .hero-sub { margin-inline: auto; font-size: var(--text-sm); }
  .hero-agents { justify-content: center; gap: var(--space-sm); }
  .hero-avatar { width: 40px; height: 40px; }
  .hero-points { display: none; }
}
@media (max-width: 40rem) { .hero-sub, .hero-agents { display: none; } }
