/* Zearch: one token set, one stylesheet. "Ethereal Glass": near-black OLED dark and a cool silver-white light theme.
   Monochrome identity, one cool accent, functional status colours (see BRAND.md).
   Light is the base; dark follows the system, or the Settings toggle (data-theme on <html>). */
@font-face { font-family: "Geist"; src: url("./assets/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("./assets/fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  /* canvas and surfaces */
  --bg: #eef0f6;
  --rail: #ffffffb8;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eceef5;
  --sunken: #f1f3f8;
  --field: #f6f7fb;
  --pop: #ffffffeb;
  /* hairlines */
  --line: #0f172a14;
  --line-2: #0f172a24;
  --line-3: #7c8496;
  /* text (AA on every surface above) */
  --ink: #0c0e14;
  --ink-2: #2b303b;
  --muted: #565c6b;
  --subtle: #626878;
  --on-ink: #ffffff;
  /* one cool accent for focus, indicators, glows and citations */
  --accent: #3a4fe0;
  --accent-ink: #2c3fc4;
  --accent-soft: #3a4fe01a;
  --focus: #3a4fe0;
  --hover: #0f172a0d;
  --backdrop: #0b0f1a59;
  /* double bezel: outer shell tint + hairline ring around an inner core */
  --shell: #0f172a08;
  --ring: #0f172a1a;
  --hi: inset 0 1px 0 #ffffffe6;
  --bezel: 0 0 #0000;
  --card-sheen: linear-gradient(180deg, #ffffff 0%, #ffffff00 38%);
  --amb: 0 1px 2px #0f172a0a, 0 10px 28px -18px #1e2a5033;
  --amb-lg: 0 32px 80px -24px #1e2a5047, 0 8px 24px -8px #1e2a5019;
  --shimmer: #ffffffb3;
  --island: #ffffff24;
  --mesh-1: #6d7cff26; --mesh-2: #38bdf822; --mesh-3: #a78bfa1f;
  --hero-a: #ffffffcc; --hero-b: #e9edfb;
  --glow: #5b6cf033;
  /* composer glass, neumorphic light and shade, and the Zearch gradient */
  --glass: #ffffffcc; --core: #fbfcfe; --neu-hi: #ffffff; --neu-lo: #1e2a5026; --neu-in: #ffffff;
  --g1: #5b6cf0; --g2: #22b3e6; --g3: #9b7bf2;
  --mark-bg: #0c0e14;
  --mark-ink: #ffffff;
  --noise: .022;
  /* functional status: text on its tinted background, and a solid fill for dots and bars */
  --bad: #a3271c;
  --ok: #14693a; --ok-bg: #e2f3e9; --ok-fill: #1f9d5b;
  --warn: #874700; --warn-bg: #fdefd6; --warn-fill: #c47f00;
  --err: #a3271c; --err-bg: #fce8e6; --err-fill: #d64537;
  --run: #1d43b8; --run-bg: #e5ecff; --run-fill: #2f5fd0;
  --idle: #454b59; --idle-bg: #eceef2; --idle-fill: #7c8494;
  --on-danger: #ffffff;
  /* categorical, for source tiers */
  --c1: #2450c8; --c2: #c2691a; --c3: #6b7280;
  /* type */
  --f-ui: "Geist", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --t-xs: 12px;
  --t-sm: 13px;
  --t-md: 15px;
  --t-lg: 17px;
  --t-xl: clamp(26px, 3.2vw, 32px);
  --t-display: clamp(34px, 5.4vw, 60px);
  /* radius: inner cores are concentric with the 6px bezel around them */
  --r-1: 8px;
  --r-2: 12px;
  --r-3: 16px;
  --r-4: 22px;
  --r-5: 28px;
  --r-pill: 999px;
  /* 4/8 spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  /* layout */
  --rail-width: 256px;
  --topbar-h: 60px;
  --answer-width: 768px;
  --home-width: 940px;
  --prose-width: 68ch;
  --hit: 38px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --t-in: 620ms;
  --t-hover: 220ms;
}
/* Dark palette. It appears twice on purpose: once for the system setting, once for the manual choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;
    --bg: #060608; --rail: #0d0e12b3; --surface: #0f1014; --surface-2: #15161c; --surface-3: #1d1f27; --sunken: #0a0a0d; --field: #0a0b0f; --pop: #101116d9;
    --line: #ffffff14; --line-2: #ffffff24; --line-3: #6b7082;
    --ink: #f1f2f6; --ink-2: #c9ccd6; --muted: #9a9eae; --subtle: #8b8fa0; --on-ink: #0a0a0d;
    --accent: #8fa2ff; --accent-ink: #b4c1ff; --accent-soft: #8fa2ff24; --focus: #9db0ff;
    --hover: #ffffff0f; --backdrop: #000000a6;
    --shell: #ffffff08; --ring: #ffffff17; --hi: inset 0 1px 1px #ffffff1f;
    --amb: 0 1px 0 #ffffff05, 0 16px 32px -22px #000000cc; --card-sheen: linear-gradient(180deg, #ffffff0a 0%, #ffffff00 42%); --amb-lg: 0 40px 90px -24px #000000e6, 0 0 0 1px #ffffff0a;
    --shimmer: #ffffff14; --island: #0a0a0d1a;
    --mesh-1: #5865f238; --mesh-2: #2f7cff26; --mesh-3: #8b5cf624;
    --hero-a: #ffffff0a; --hero-b: #ffffff03; --glow: #6a7cff3d;
    --glass: #15161ccc; --core: #121319; --neu-hi: #ffffff0a; --neu-lo: #000000b3; --neu-in: #ffffff14;
    --g1: #7181ff; --g2: #38c2f0; --g3: #a78bfa;
    --mark-bg: #ececf1; --mark-ink: #0a0a0d; --noise: .028;
    --bad: #e38d84;
    --ok: #7bdca3; --ok-bg: #12291b; --ok-fill: #3fbf7f;
    --warn: #f3c274; --warn-bg: #2e230d; --warn-fill: #e0a13a;
    --err: #f5a39c; --err-bg: #331a19; --err-fill: #e5695d;
    --run: #a5bdff; --run-bg: #18254a; --run-fill: #7ea2ff;
    --idle: #babfcb; --idle-bg: #23252d; --idle-fill: #8a91a1;
    --on-danger: #1b1b1b;
    --c1: #7ea2ff; --c2: #f0a24d; --c3: #9aa3b2;
  }
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #060608; --rail: #0d0e12b3; --surface: #0f1014; --surface-2: #15161c; --surface-3: #1d1f27; --sunken: #0a0a0d; --field: #0a0b0f; --pop: #101116d9;
  --line: #ffffff14; --line-2: #ffffff24; --line-3: #6b7082;
  --ink: #f1f2f6; --ink-2: #c9ccd6; --muted: #9a9eae; --subtle: #8b8fa0; --on-ink: #0a0a0d;
  --accent: #8fa2ff; --accent-ink: #b4c1ff; --accent-soft: #8fa2ff24; --focus: #9db0ff;
  --hover: #ffffff0f; --backdrop: #000000a6;
  --shell: #ffffff08; --ring: #ffffff17; --hi: inset 0 1px 1px #ffffff1f;
  --amb: 0 1px 0 #ffffff05, 0 16px 32px -22px #000000cc; --card-sheen: linear-gradient(180deg, #ffffff0a 0%, #ffffff00 42%); --amb-lg: 0 40px 90px -24px #000000e6, 0 0 0 1px #ffffff0a;
  --shimmer: #ffffff14; --island: #0a0a0d1a;
  --mesh-1: #5865f238; --mesh-2: #2f7cff26; --mesh-3: #8b5cf624;
  --hero-a: #ffffff0a; --hero-b: #ffffff03; --glow: #6a7cff3d;
    --glass: #15161ccc; --core: #121319; --neu-hi: #ffffff0a; --neu-lo: #000000b3; --neu-in: #ffffff14;
    --g1: #7181ff; --g2: #38c2f0; --g3: #a78bfa;
  --mark-bg: #ececf1; --mark-ink: #0a0a0d; --noise: .028;
  --bad: #e38d84;
  --ok: #7bdca3; --ok-bg: #12291b; --ok-fill: #3fbf7f;
  --warn: #f3c274; --warn-bg: #2e230d; --warn-fill: #e0a13a;
  --err: #f5a39c; --err-bg: #331a19; --err-fill: #e5695d;
  --run: #a5bdff; --run-bg: #18254a; --run-fill: #7ea2ff;
  --idle: #babfcb; --idle-bg: #23252d; --idle-fill: #8a91a1; --on-danger: #1b1b1b;
  --c1: #7ea2ff; --c2: #f0a24d; --c3: #9aa3b2;
}
@media (prefers-contrast: more) {
  :root { --line: var(--line-3); --line-2: var(--subtle); --ring: var(--line-3); --muted: var(--ink-2); --subtle: var(--ink-2); }
}

/* ---------- base ---------- */
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
html, body { width: 100%; height: 100%; min-height: 100%; margin: 0; }
body { position: relative; overflow: hidden; background: var(--bg); color: var(--ink); font: var(--t-md)/1.55 var(--f-ui); font-feature-settings: "ss01" 0, "tnum" 0; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
/* subtle radial mesh behind everything, and an optional grain: both fixed and inert */
body::before { content: ""; position: fixed; z-index: 0; inset: 0; pointer-events: none;
  background: radial-gradient(60% 55% at 12% -8%, var(--mesh-1), transparent 62%), radial-gradient(48% 42% at 96% 2%, var(--mesh-2), transparent 62%), radial-gradient(56% 40% at 55% 112%, var(--mesh-3), transparent 64%); }
body::after { content: ""; position: fixed; z-index: 200; inset: 0; pointer-events: none; opacity: var(--noise);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled, select:disabled, input:disabled { cursor: not-allowed; opacity: .5; }
button[aria-busy=true] { cursor: progress; opacity: .7; }
svg { display: block; }
a { color: inherit; }
code, pre, kbd { font-family: var(--f-mono); }
kbd { padding: 0 6px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 11px; line-height: 18px; box-shadow: 0 1px 0 var(--line); }
summary { cursor: pointer; user-select: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden], .hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sprite * { vector-effect: non-scaling-stroke; }
.sprite .fill { fill: currentColor; stroke: none; }
/* ultra-light line icons: 1.5px exact stroke at any size */
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5px; stroke-linecap: round; stroke-linejoin: round; shape-rendering: geometricPrecision; }
.skip-link { position: fixed; z-index: 300; top: var(--s-2); left: var(--s-2); padding: var(--s-2) var(--s-4); border-radius: var(--r-pill); background: var(--ink); color: var(--on-ink); font-size: var(--t-sm); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.noscript { position: relative; z-index: 1; margin: 0; padding: var(--s-3) var(--s-4); background: var(--surface-3); color: var(--ink); text-align: center; font-size: var(--t-sm); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: var(--r-pill); background: var(--line-2) padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-3) padding-box; }
::selection { background: var(--accent-soft); }

/* ---------- eyebrow tag ---------- */
.eyebrow { display: inline-flex; align-items: center; gap: 8px; min-height: 24px; padding: 3px 12px 3px 10px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 560; letter-spacing: .16em; text-transform: uppercase; line-height: 1.3; }
.eyebrow .ico { width: 14px; height: 14px; }
.eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- shared controls ---------- */
.icon-btn { position: relative; display: inline-grid; width: var(--hit); height: var(--hit); place-items: center; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--muted); transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease), transform var(--t-hover) var(--ease); }
.icon-btn:hover { background: var(--hover); border-color: var(--line); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg, .toast-close svg, .chip svg { width: 18px; height: 18px; }
/* buttons: full pills. A trailing icon lives in its own circular island. */
.ghost-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: var(--hit); padding: var(--s-2) 16px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2); font-size: var(--t-sm); font-weight: 500; white-space: nowrap; box-shadow: var(--hi); transition: background var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease), color var(--t-hover) var(--ease), transform var(--t-hover) var(--ease); }
.ghost-btn .ico { width: 16px; height: 16px; }
.ghost-btn:hover:not(:disabled) { border-color: var(--line-3); background: var(--surface-2); color: var(--ink); }
.ghost-btn:active:not(:disabled) { transform: scale(.98); }
.solid-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 40px; padding: 4px 6px 4px 20px; border: 0; border-radius: var(--r-pill); background: var(--ink); color: var(--on-ink); font-size: var(--t-sm); font-weight: 560; letter-spacing: -.005em; white-space: nowrap; box-shadow: 0 1px 0 #ffffff26 inset, 0 8px 20px -10px #0c0e1480; transition: background var(--t-hover) var(--ease), transform var(--t-hover) var(--ease), box-shadow var(--t-hover) var(--ease); }
.solid-btn:not(:has(.btn-island)) { padding: 4px 20px; }
.solid-btn:hover:not(:disabled) { background: var(--ink-2); }
.solid-btn:active:not(:disabled) { transform: scale(.98); }
.btn-island { display: grid; width: 32px; height: 32px; flex: none; place-items: center; border-radius: 50%; background: var(--island); transition: transform var(--t-hover) var(--ease); }
.btn-island .ico { width: 16px; height: 16px; }
.solid-btn:hover:not(:disabled) .btn-island, .decide:hover:not(:disabled) .decide-island { transform: translate(1px, -1px) scale(1.05); }
/* disabled primary: an outlined ghost of the button, not a grey slab */
.solid-btn:disabled { border: 1px dashed var(--line-3); background: transparent; color: var(--subtle); box-shadow: none; opacity: 1; }
.solid-btn:disabled .btn-island { background: var(--surface-3); color: var(--subtle); }
.link-btn { padding: var(--s-1) var(--s-2); border: 0; border-radius: var(--r-1); background: none; color: var(--muted); font-size: var(--t-xs); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-3); transition: color var(--t-hover) var(--ease); }
a.link-btn { display: inline-block; }
.link-btn:hover:not(:disabled) { color: var(--ink); text-decoration-color: currentColor; }
.muted, .hint { margin: 0; color: var(--muted); font-size: var(--t-xs); line-height: 1.6; }
.chip { display: inline-flex; align-items: center; gap: var(--s-1); align-self: flex-start; margin: 0; padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3); border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); font-size: var(--t-xs); }
.chip button { display: grid; width: 24px; height: 24px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.chip button:hover { background: var(--hover); color: var(--ink); }
.chip svg { width: 14px; height: 14px; }
input:not([type=checkbox]):not([type=file]):not([type=radio]), textarea, select { font-size: var(--t-sm); }
/* double-bezel cards: the element is the inner core, a spread shadow draws the shell and an outline draws its hairline ring */
/* Cards are one clean surface: a hairline edge, a soft top highlight and a low, diffuse shadow. No outer ring. */
.card, .starter, .timeline, .library-list, .card-list > li:not(.empty-state), .collection-dashboard, .market-card, .evidence-card { background-image: var(--card-sheen); }
.starter:focus-visible { outline: 2px solid var(--focus); outline-offset: 8px; }
.card { padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--r-4); background: var(--surface); box-shadow: var(--hi), var(--bezel), var(--amb); }
.card-title, .section-head h2 { margin: 0; font-size: var(--t-md); font-weight: 560; letter-spacing: -.015em; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin: 0 0 var(--s-4); }
.stat-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 12px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2); font: 500 var(--t-xs) var(--f-mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat-chip .ico { width: 14px; height: 14px; color: var(--muted); }
/* status tones drive the dot, the pill and the chart fills; the label always says the same thing in words */
[data-tone=ok] { --fill: var(--ok-fill); --pbg: var(--ok-bg); --pfg: var(--ok); }
[data-tone=warn] { --fill: var(--warn-fill); --pbg: var(--warn-bg); --pfg: var(--warn); }
[data-tone=bad] { --fill: var(--err-fill); --pbg: var(--err-bg); --pfg: var(--err); }
[data-tone=run] { --fill: var(--run-fill); --pbg: var(--run-bg); --pfg: var(--run); }
[data-tone=idle] { --fill: var(--idle-fill); --pbg: var(--idle-bg); --pfg: var(--idle); }
[data-tone=c1] { --fill: var(--c1); } [data-tone=c2] { --fill: var(--c2); } [data-tone=c3] { --fill: var(--c3); }
.dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--fill, var(--idle-fill)); }
.pill { display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 2px 11px; border: 1px solid color-mix(in srgb, var(--pfg, var(--idle)) 18%, transparent); border-radius: var(--r-pill); background: var(--pbg, var(--idle-bg)); color: var(--pfg, var(--idle)); font-size: var(--t-xs); font-weight: 540; white-space: nowrap; }
.pill .dot { background: currentColor; width: 6px; height: 6px; }
.pill-run { --pbg: var(--run-bg); --pfg: var(--run); }
.pill-run .dot, .pill[data-tone=run] .dot { animation: pulse 1.8s var(--ease) infinite; }
.segmented { display: inline-flex; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface-2); box-shadow: inset 0 1px 2px #0000000d; }
.segmented button, .segmented label { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 4px 18px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--muted); font-size: var(--t-sm); font-weight: 520; cursor: pointer; transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease), box-shadow var(--t-hover) var(--ease); }
.segmented button:hover, .segmented label:hover { color: var(--ink); }
.segmented button[aria-selected=true], .segmented button[aria-pressed=true], .segmented label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--hi), 0 0 0 1px var(--line-2), 0 4px 10px -4px #0c0e1440; }
.segmented label { position: relative; }
.segmented label input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
/* menu: bezeled floating layer (topbar options) */
.menu-wrap { position: relative; }
.menu { position: absolute; z-index: 40; top: calc(100% + 8px); right: 0; min-width: 240px; padding: 6px; border: 1px solid var(--ring); border-radius: calc(var(--r-4) + 6px); background: var(--shell); background-color: color-mix(in srgb, var(--surface) 55%, transparent); backdrop-filter: blur(22px) saturate(150%); box-shadow: var(--amb-lg); text-align: left; transform-origin: 100% 0; animation: spring .42s var(--ease) both; }
.menu-core { display: grid; gap: 2px; padding: 6px; border-radius: var(--r-4); background: var(--pop); box-shadow: var(--hi); }
.menu button, .menu a { display: flex; align-items: center; gap: var(--s-3); min-height: 42px; padding: var(--s-2) var(--s-3); border: 0; border-radius: var(--r-2); background: transparent; color: var(--ink-2); font-size: var(--t-sm); text-align: left; text-decoration: none; transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.menu button:hover, .menu a:hover, .menu button:focus-visible, .menu a:focus-visible { background: var(--hover); color: var(--ink); }
.menu .ico { color: var(--muted); }
.menu-note { margin: 0; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line); color: var(--muted); font: var(--t-xs) var(--f-mono); }
.menu-note:empty { display: none; }

/* ---------- shell and rail ---------- */
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); height: var(--app-h, 100dvh); transition: grid-template-columns 480ms var(--ease); }
/* the rail element fills its column; the floating glass panel is its ::before */
.rail { position: relative; z-index: 30; display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; min-height: 0; padding: 26px 22px 24px 26px; overflow: hidden; }
.rail::before { content: ""; position: absolute; z-index: -1; inset: 10px 8px 10px 10px; border: 1px solid var(--ring); border-radius: var(--r-5); background: var(--rail); backdrop-filter: blur(24px) saturate(150%); box-shadow: var(--hi), var(--amb); }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 0 0 var(--s-1) var(--s-1); min-height: 44px; }
.brand { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; flex: 0 0 28px; color: var(--ink); shape-rendering: geometricPrecision; overflow: visible; }
.brand-word { font-size: 21px; font-weight: 500; letter-spacing: -.045em; line-height: 1; }
.icon-btn.rail-close, .icon-btn.menu-btn { display: none; }
.rail-search { display: flex; align-items: center; gap: 0; width: 100%; min-height: 44px; padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--field); color: var(--muted); text-align: left; font-size: var(--t-sm); box-shadow: inset 0 1px 2px #0000000f; transition: border-color var(--t-hover) var(--ease), color var(--t-hover) var(--ease), background var(--t-hover) var(--ease); }
.rail-search:hover { border-color: var(--line-3); color: var(--ink); }
.rail-search kbd { margin-left: auto; font-size: 11px; }
.rail-nav { display: flex; flex: 1; flex-direction: column; gap: var(--s-4); min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: var(--s-1) 0; }
.nav-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.rail-title { margin: 0; padding: var(--s-1) var(--s-3); color: var(--subtle); font-size: 11px; font-weight: 560; letter-spacing: .16em; text-transform: uppercase; }
.nav-item { position: relative; display: flex; align-items: center; width: 100%; min-width: 0; min-height: 42px; padding: var(--s-2) 14px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); text-align: left; text-decoration: none; font-size: var(--t-sm); font-weight: 500; transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item .ico { color: var(--muted); transition: color var(--t-hover) var(--ease); }
.nav-item:hover .ico { color: var(--ink); }
/* labels fade and collapse smoothly with the rail */
.nav-item .rail-label, .rail-search .rail-label:not(kbd), .brand .rail-label { min-width: 0; max-width: 220px; margin-left: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: max-width 480ms var(--ease), margin 480ms var(--ease), opacity 320ms var(--ease); }
.rail-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: opacity 320ms var(--ease); }
.rail-search { min-width: 0; }
.rail-search kbd { flex: none; }
.nav-item[aria-current=page] { background: var(--surface); color: var(--ink); font-weight: 560; box-shadow: var(--hi), 0 0 0 1px var(--line-2), 0 8px 18px -10px #0c0e1459; }
.nav-item[aria-current=page] .ico { color: var(--ink); }
/* animated active indicator */
.nav-item::before { content: ""; position: absolute; left: -10px; top: 50%; width: 3px; height: 18px; margin-top: -9px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent); transform: scaleY(0); opacity: 0; transition: transform 420ms var(--ease), opacity 260ms var(--ease); }
.nav-item[aria-current=page]::before { transform: scaleY(1); opacity: 1; }
.history { min-width: 0; overflow: hidden; margin: 2px 0 var(--s-1) 26px; padding: 0 0 0 var(--s-2); border-left: 1px solid var(--line-2); list-style: none; }
.history li button { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; min-height: 32px; padding: var(--s-1) var(--s-2); border: 0; border-radius: var(--r-1); background: transparent; color: var(--muted); text-align: left; font-size: var(--t-xs); transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.history li button:hover { background: var(--hover); color: var(--ink); }
.history li button[aria-current=page] { color: var(--ink); font-weight: 560; }
.h-q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-foot { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 2px; padding-top: var(--s-3); border-top: 1px solid var(--line); }
.account-card { min-width: 0; display: flex; align-items: center; gap: var(--s-3); width: 100%; margin-top: var(--s-2); padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--field); text-align: left; box-shadow: inset 0 1px 2px #0000000f; transition: border-color var(--t-hover) var(--ease); }
.account-card:hover { border-color: var(--line-3); }
.avatar { display: grid; width: 34px; height: 34px; flex: none; place-items: center; border-radius: 50%; background: var(--ink); color: var(--on-ink); font-size: var(--t-sm); font-weight: 600; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-2); }
.account-text { display: grid; min-width: 0; max-width: 200px; line-height: 1.3; overflow: hidden; transition: max-width 480ms var(--ease), opacity 320ms var(--ease); }
.account-text strong { overflow: hidden; font-size: var(--t-sm); font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.account-text small { overflow: hidden; color: var(--muted); font-size: var(--t-xs); text-overflow: ellipsis; white-space: nowrap; }
.scrim { display: none; }
.edge-swipe { display: none; }
.rail-resizer { position: absolute; z-index: 5; top: 0; right: 0; bottom: 0; width: 12px; cursor: col-resize; touch-action: none; }
.rail-resizer::after { content: ""; position: absolute; top: 50%; right: 3px; width: 3px; height: 44px; margin-top: -22px; border-radius: 3px; background: transparent; transition: background var(--t-hover) var(--ease), height var(--t-hover) var(--ease), margin var(--t-hover) var(--ease); }
.rail-resizer:hover::after, .rail-resizer.is-dragging::after { height: 72px; margin-top: -36px; background: var(--line-3); }
.rail-resizer:focus-visible { outline: none; }
.rail-resizer:focus-visible::after { height: 72px; margin-top: -36px; background: var(--focus); }
.shell.is-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; transition: none; }
.shell.is-resizing * { pointer-events: none; transition: none !important; }
.shell.is-resizing .rail-resizer { pointer-events: auto; }
.rail-collapsed .rail-resizer { display: none; }
@media (min-width: 681px) {
  .rail-collapsed { --rail-width: 88px; }
  .rail-collapsed .rail { padding-inline: 20px 18px; }
  .rail-collapsed .rail-head { flex-direction: column; justify-content: center; gap: var(--s-2); padding: 0; }
  .rail-collapsed .rail-nav .rail-label, .rail-collapsed .rail-search .rail-label:not(kbd), .rail-collapsed .brand .rail-label, .rail-collapsed .rail-foot .nav-item .rail-label { max-width: 0; margin-left: 0; opacity: 0; }
  .rail-collapsed .rail-title { opacity: 0; height: 0; padding: 0; }
  .rail-collapsed .rail-search kbd { display: none; }
  .rail-collapsed .account-text { max-width: 0; opacity: 0; }
  .rail-collapsed .account-card { gap: 0; padding: 4px; justify-content: center; }
  .rail-collapsed .nav-item, .rail-collapsed .rail-search { justify-content: center; padding-inline: 0; }
  .rail-collapsed .history { display: none; }
  .rail-collapsed .nav-group + .nav-group { padding-top: var(--s-3); border-top: 1px solid var(--line); }
  .rail-collapsed .rail-toggle svg { transform: scaleX(-1); }
  .rail-collapsed .nav-item::before { left: -8px; }
}

/* ---------- stage: topbar, tabs, feed, home ---------- */
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: transparent; }
.stage:focus { outline: none; }
.topbar { position: relative; z-index: 8; display: flex; flex: 0 0 var(--topbar-h); align-items: center; gap: var(--s-3); height: var(--topbar-h); padding: 0 var(--s-6) 0 var(--s-4); backdrop-filter: blur(18px); background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 70%, transparent), transparent); }
.top-brand { display: none; color: var(--ink); }
.new-research .btn-island .ico { stroke-width: 1.75px; }
.topbar-right { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }
.feed { position: relative; z-index: 6; flex: 1; min-height: 0; overflow: auto; padding: 0 var(--s-6) 0 var(--s-4); overscroll-behavior: contain; }
.empty { position: relative; display: flex; width: min(100%, var(--home-width)); min-height: 100%; flex-direction: column; align-items: stretch; gap: var(--s-6); margin: 0 auto; padding: var(--s-2) 0 var(--s-7); text-align: center; }
/* staggered fade-up with a blur-to-sharp settle; the animation restarts every time the panel is shown */
@keyframes enter { from { opacity: 0; transform: translateY(18px) scale(.985); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
/* fill-mode backwards (never forwards): a finished animation must not leave a containing block behind for the fixed mode popover */
.empty > *, .view-inner > *, .overview-content > *, .stat-grid > * { animation: enter var(--t-in) var(--ease) backwards; }
.empty > :nth-child(2), .view-inner > :nth-child(2), .stat-grid > :nth-child(2) { animation-delay: 70ms; }
.empty > :nth-child(3), .view-inner > :nth-child(3), .stat-grid > :nth-child(3) { animation-delay: 140ms; }
.empty > :nth-child(4), .view-inner > :nth-child(4), .stat-grid > :nth-child(4) { animation-delay: 210ms; }
.empty > :nth-child(5), .view-inner > :nth-child(5), .stat-grid > :nth-child(5) { animation-delay: 280ms; }
.stat-grid > :nth-child(6) { animation-delay: 350ms; }
/* home: the headline and one message box, nothing else */
.empty { justify-content: center; gap: clamp(20px, 4vh, 36px); height: 100%; min-height: 0; padding: 0 0 8vh; }
/* home never scrolls: the feed only scrolls once there is a thread */
.stage:not([data-thread]) .feed { overflow: hidden; }
.welcome-copy { display: grid; justify-items: center; padding: 0 var(--s-3); }
.empty h1 { max-width: 18ch; margin: 0 auto; color: var(--ink); font-size: clamp(26px, min(4.2vw, 6.2vh), 46px); line-height: 1.06; font-weight: 500; letter-spacing: -.04em; font-kerning: normal; text-wrap: balance; }
.composer-slot { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 760px; margin: 0 auto; }
.composer-slot::before { content: ""; position: absolute; z-index: -1; inset: -30% -10% -20%; pointer-events: none; background: radial-gradient(45% 55% at 50% 50%, var(--glow), transparent 70%); opacity: .7; }
.research-notice { margin: 12px 0 0; color: var(--muted); font-size: var(--t-xs); }
.research-notice:empty, .research-status:empty { display: none; }

/* ---------- composer: liquid-glass shell, neumorphic core, a corner tab for voice and send ---------- */
@property --angle { syntax: "<angle>"; initial-value: 0deg; inherits: true; }
@keyframes zearch-spin { to { --angle: 360deg; } }
.composer {
  position: relative; isolation: isolate; display: flex; flex-direction: column; width: 100%; padding: 6px;
  border-radius: 30px; box-shadow: var(--hi), 0 0 0 1px var(--ring), 0 34px 70px -34px var(--neu-lo); text-align: left; animation: zearch-spin 9s linear infinite; }
/* the glass lives on a pseudo-element: a backdrop-filter on the form itself would trap the fixed mode menu inside it */
.composer::after { content: ""; position: absolute; z-index: -1; inset: 0; border-radius: inherit; background: var(--glass); backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%); pointer-events: none; }
/* the glow: a slow conic sweep in the Zearch accents, masked to a ring and softly blurred (not a haze) */
.composer-glow { position: absolute; z-index: -1; inset: -3px; border-radius: 33px; filter: blur(12px); opacity: .5; pointer-events: none; transition: opacity 400ms var(--ease); }
.composer-glow::before, .composer::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 3px; pointer-events: none;
  background: conic-gradient(from var(--angle), var(--g1), var(--g2) 22%, transparent 38%, transparent 58%, var(--g3) 78%, var(--g1));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
.composer::before { z-index: 1; padding: 1px; opacity: .55; transition: opacity 400ms var(--ease); }
.composer:focus-within .composer-glow { opacity: .85; }
.composer:focus-within::before { opacity: .9; }
.composer:has(#decide[data-busy=true]) { animation-duration: 2.6s; }
.composer:has(#decide[data-busy=true]) .composer-glow { opacity: .9; }
.composer-card { position: relative; z-index: 3; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 12px 12px 10px 16px; border-radius: 24px;
  background: var(--core); box-shadow: inset 0 1px 0 var(--neu-in), inset 0 0 0 1px var(--line), -5px -5px 14px var(--neu-hi), 7px 9px 20px var(--neu-lo); }
.composer-card[data-drop] { box-shadow: inset 0 0 0 2px var(--g2), 0 0 24px -4px var(--g2); }
.composer-context { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 2px; }
.ctx-chip { display: inline-flex; max-width: 100%; align-items: center; gap: 6px; min-height: 32px; padding: 2px 4px 2px 10px; border-radius: var(--r-pill); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line), inset 1px 1px 3px var(--neu-lo); color: var(--ink-2); font-size: var(--t-xs); }
.ctx-chip > .ico { width: 14px; height: 14px; color: var(--muted); }
.ctx-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-file-name { color: var(--ink); font-weight: 560; }
.ctx-file-meta { color: var(--muted); font-family: var(--f-mono); }
.ctx-file[data-state=error] { box-shadow: inset 0 0 0 1px var(--err-fill); }
.ctx-file[data-state=error] .ctx-file-meta { color: var(--err); }
.ctx-file[data-state=uploading] > .ico { animation: pulse 1.2s ease-in-out infinite; }
.ctx-x { display: grid; width: 26px; height: 26px; flex: none; place-items: center; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.ctx-x:hover { background: var(--hover); color: var(--ink); }
.ctx-x .ico { width: 13px; height: 13px; }
.target-field { display: flex; flex: 1 1 100%; align-items: center; gap: 8px; min-width: 0; padding: 0 12px; border-radius: var(--r-pill); background: var(--field); box-shadow: inset 0 0 0 1px var(--line-2), inset 2px 2px 5px var(--neu-lo); transition: box-shadow var(--t-hover) var(--ease); }
.target-field > .ico { width: 16px; height: 16px; flex: none; color: var(--muted); }
.target-field[data-state=ok] > .ico { color: var(--ok); }
.target-field[data-state=bad] { box-shadow: inset 0 0 0 1px var(--err-fill); }
.target-field:focus-within { box-shadow: inset 0 0 0 1px var(--g2), 0 0 0 3px var(--accent-soft); }
.composer .target-url { flex: 1; min-width: 0; height: 38px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: var(--t-sm) var(--f-mono); }
.url-hint { flex: none; max-width: 45%; overflow: hidden; color: var(--err); font-size: var(--t-xs); text-overflow: ellipsis; white-space: nowrap; }
.url-hint:empty { display: none; }
.composer textarea { display: block; width: 100%; min-height: 56px; max-height: 40vh; resize: none; padding: 6px 2px 4px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: var(--t-lg); line-height: 1.5; letter-spacing: -.01em; caret-color: var(--g1); }
.composer textarea::placeholder { color: var(--subtle); }
.slash-menu { position: absolute; z-index: 40; top: calc(100% + 12px); left: 0; width: min(280px, 100%); margin: 0; padding: 6px; border-radius: 18px; background: var(--pop); backdrop-filter: blur(16px); box-shadow: var(--hi), 0 0 0 1px var(--ring), var(--amb-lg); list-style: none; animation: spring .3s var(--ease) both; }
.slash-opt { display: grid; grid-template-columns: 18px auto 1fr; align-items: center; gap: 10px; min-height: 38px; padding: 4px 12px; border-radius: 12px; color: var(--ink-2); font-size: var(--t-sm); cursor: pointer; }
.slash-opt[aria-selected=true], .slash-opt:hover { background: var(--hover); color: var(--ink); }
.slash-opt .ico { width: 16px; height: 16px; color: var(--muted); }
.slash-name { font: var(--t-xs) var(--f-mono); }
.slash-desc { color: var(--muted); font-size: var(--t-xs); text-align: right; }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-left: -4px; }
.composer-tools, .composer-end { display: flex; min-width: 0; align-items: center; gap: 8px; }
/* raised neumorphic controls; they sink in when pressed */
.tool-btn, .mode-btn, .tab-btn { border: 0; background: var(--core); color: var(--ink-2); box-shadow: -2px -2px 5px var(--neu-hi), 3px 3px 7px var(--neu-lo), inset 0 0 0 1px var(--line); transition: box-shadow var(--t-hover) var(--ease), color var(--t-hover) var(--ease), transform var(--t-hover) var(--ease); }
.tool-btn:hover:not(:disabled), .mode-btn:hover:not(:disabled), .tab-btn:hover:not(:disabled) { color: var(--ink); }
.tool-btn:active:not(:disabled), .mode-btn:active:not(:disabled), .tab-btn:active:not(:disabled), .mode-btn[aria-expanded=true] { box-shadow: inset 2px 2px 5px var(--neu-lo), inset -2px -2px 5px var(--neu-hi), inset 0 0 0 1px var(--line); }
.tool-btn { display: inline-grid; width: 36px; height: 36px; flex: none; place-items: center; padding: 0; border-radius: 50%; cursor: pointer; }
.tool-btn .ico { width: 18px; height: 18px; }
#attach-btn .ico { stroke-width: 1.9px; }
.notes-toggle[data-on=true] { color: var(--accent-ink); box-shadow: inset 2px 2px 5px var(--neu-lo), inset 0 0 0 1px var(--g1); }
.notes-toggle:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.mode-wrap { position: relative; min-width: 0; }
.mode-btn { display: inline-flex; max-width: 100%; align-items: center; gap: 7px; height: 36px; padding: 0 10px 0 12px; border-radius: var(--r-pill); font-size: var(--t-sm); font-weight: 540; }
.mode-btn > .ico { width: 16px; height: 16px; flex: none; }
.mode-btn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-btn-chev { width: 13px !important; height: 13px !important; color: var(--muted); transition: transform 320ms var(--ease); }
.mode-btn[aria-expanded=true] .mode-btn-chev { transform: rotate(180deg); }
.char-count { color: var(--muted); font: var(--t-xs) var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.char-count:empty { display: none; }
.char-count.warn { color: var(--warn); font-weight: 560; }
/* voice: a raised mic; while listening a gradient ring follows the input level */
.tab-btn { position: relative; display: inline-grid; width: 40px; height: 40px; flex: none; place-items: center; padding: 0; border-radius: 50%; cursor: pointer; }
.tab-btn .ico { width: 18px; height: 18px; }
.voice-ring { position: absolute; inset: -3px; border-radius: 50%; padding: 2px; opacity: 0; pointer-events: none; background: conic-gradient(from var(--angle), var(--g1), var(--g2), var(--g3), var(--g1));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  transform: scale(calc(1 + var(--level, 0) * .35)); transition: opacity 200ms var(--ease), transform 90ms linear; }
.voice-btn[data-state] { color: var(--accent-ink); }
.voice-btn[data-state] .voice-ring { opacity: 1; }
.voice-btn[data-state=working] .voice-ring { opacity: .6; animation: pulse 1s ease-in-out infinite; }
/* send: an ink circle at rest; on hover a Zearch gradient fades in with a soft glow */
.decide { position: relative; isolation: isolate; display: inline-grid; width: 40px; height: 40px; flex: none; place-items: center; padding: 0; overflow: hidden; border: 0; border-radius: 50%; background: var(--ink); color: var(--on-ink);
  box-shadow: inset 0 1px 0 #ffffff33, 0 8px 18px -8px #0c0e1499; transition: transform var(--t-hover) var(--ease), box-shadow 320ms var(--ease), color var(--t-hover) var(--ease); }
.decide::before { content: ""; position: absolute; z-index: -1; inset: 0; border-radius: inherit; background: linear-gradient(135deg, var(--g1), var(--g2) 55%, var(--g3)); opacity: 0; transition: opacity 320ms var(--ease); }
.decide:hover:not(:disabled), .decide:focus-visible:not(:disabled) { color: #fff; transform: translateY(-1px); box-shadow: inset 0 1px 0 #ffffff55, 0 10px 26px -6px color-mix(in srgb, var(--g1) 70%, transparent), 0 0 0 1px #ffffff22; }
.decide:hover:not(:disabled)::before, .decide:focus-visible:not(:disabled)::before { opacity: 1; }
.decide:hover:not(:disabled) .ico { transform: translateY(-1px); }
.decide:active:not(:disabled) { transform: scale(.94); }
.decide .ico { width: 18px; height: 18px; stroke-width: 1.9px; transition: transform var(--t-hover) var(--ease); }
.decide:disabled { background: var(--core); color: var(--subtle); box-shadow: inset 2px 2px 5px var(--neu-lo), inset -2px -2px 5px var(--neu-hi), inset 0 0 0 1px var(--line); opacity: 1; }
.decide[data-busy=true] { color: #fff; }
.decide[data-busy=true]::before { opacity: 1; }
.decide[data-busy=true] .ico { display: none; }
.decide[data-busy=true]::after { content: ""; width: 11px; height: 11px; border-radius: 3px; background: currentColor; }
/* dock: the same box, tighter, over the thread. Also used on phones while the keyboard is open. */
.dock { position: relative; z-index: 6; flex: 0 0 auto; padding: 12px var(--s-6) max(12px, env(safe-area-inset-bottom)) var(--s-4); background: linear-gradient(180deg, transparent, var(--bg) 26%); }
.dock-inner { width: min(100%, var(--answer-width)); margin: 0 auto; }
.dock-inner:empty { display: none; }
.stage:not([data-thread]) .dock { display: none; }
.composer.compact { padding: 5px; border-radius: 26px; }
.composer.compact .composer-glow { opacity: .32; border-radius: 29px; }
.composer.compact .composer-card { padding: 8px 8px 8px 14px; border-radius: 21px; }
.composer.compact textarea { min-height: 40px; padding: 6px 2px 2px; font-size: var(--t-md); }
.composer.compact .slash-menu { top: auto; bottom: calc(100% + 10px); }
/* mode menu: a small glass list, one icon and one name per mode */
.mode-panel { position: fixed; z-index: 60; top: 0; left: 0; width: 232px; padding: 0; border-radius: 20px; background: var(--pop); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--hi), 0 0 0 1px var(--ring), var(--amb-lg); transform-origin: var(--ox, 24px) var(--oy, 0); animation: spring .36s var(--ease) both; }
.mode-panel[data-side=above] { --oy: 100%; }
.mode-panel-core { position: relative; max-height: calc(var(--mh, 440px) - 2px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: auto; padding: 6px; }
.mode-panel-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sheet-grip { display: none; }
#mode-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; outline: 0; }
.mode-opt { display: grid; grid-template-columns: 18px minmax(0, 1fr) 16px; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: 13px; color: var(--ink-2); cursor: pointer; animation: fade-row .26s var(--ease) both; transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.mode-opt:nth-child(2) { animation-delay: 20ms; } .mode-opt:nth-child(3) { animation-delay: 40ms; } .mode-opt:nth-child(4) { animation-delay: 60ms; } .mode-opt:nth-child(5) { animation-delay: 80ms; } .mode-opt:nth-child(6) { animation-delay: 100ms; }
.mode-opt:hover, .mode-opt.is-active { background: var(--hover); color: var(--ink); }
#mode-list:focus-visible { outline: none; }
#mode-list:focus-visible .mode-opt.is-active { outline: 2px solid var(--focus); outline-offset: -2px; }
.mode-opt .mode-opt-ico { width: 17px; height: 17px; color: var(--muted); }
.mode-opt-name { min-width: 0; overflow: hidden; color: inherit; font-size: var(--t-sm); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.mode-opt-check { width: 15px !important; height: 15px !important; color: var(--accent-ink); opacity: 0; }
.mode-opt[aria-selected=true] { color: var(--ink); }
.mode-opt[aria-selected=true] .mode-opt-ico { color: var(--accent-ink); }
.mode-opt[aria-selected=true] .mode-opt-check { opacity: 1; }
/* voice mode: a calm full-screen stage with an orb that breathes with the voice */
.voice-overlay { position: fixed; z-index: 95; inset: 0; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: fade .35s var(--ease) backwards; }
.voice-stage { display: grid; justify-items: center; gap: 18px; width: min(100%, 520px); text-align: center; }
.voice-title { margin: 0; color: var(--subtle); font-size: 11px; font-weight: 560; letter-spacing: .16em; text-transform: uppercase; }
.voice-orb { position: relative; width: 200px; height: 200px; margin: 12px 0; transform: scale(calc(.94 + var(--level, 0) * .22)); transition: transform 90ms linear; animation: zearch-spin 7s linear infinite; }
.voice-orb span { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from var(--angle), var(--g1), var(--g2), var(--g3), var(--g1)); filter: blur(18px); opacity: .55; }
.voice-orb span:nth-child(2) { inset: 18px; filter: blur(8px); opacity: .8; transform: rotate(120deg); }
.voice-orb span:nth-child(3) { inset: 34px; filter: none; opacity: 1; background: radial-gradient(circle at 35% 30%, #ffffffcc, transparent 45%), conic-gradient(from calc(var(--angle) * -1), var(--g2), var(--g1), var(--g3), var(--g2)); box-shadow: inset 0 0 30px #0006; }
.voice-overlay[data-state=thinking] .voice-orb { animation-duration: 2.4s; }
.voice-overlay[data-state=speaking] .voice-orb span:nth-child(3) { animation: pulse 1.6s ease-in-out infinite; }
.voice-overlay[data-state=idle] .voice-orb, .voice-overlay[data-state=error] .voice-orb { animation-play-state: paused; filter: saturate(.5); }
.voice-state { margin: 0; color: var(--ink); font-size: var(--t-lg); font-weight: 520; letter-spacing: -.01em; }
.voice-transcript { min-height: 3em; max-width: 46ch; margin: 0; color: var(--muted); font-size: var(--t-md); line-height: 1.5; }
.voice-actions { display: flex; gap: 16px; margin-top: 8px; }
.voice-action { display: grid; width: 56px; height: 56px; place-items: center; border: 0; border-radius: 50%; background: var(--core); color: var(--ink); box-shadow: -3px -3px 8px var(--neu-hi), 4px 4px 12px var(--neu-lo), inset 0 0 0 1px var(--line); }
.voice-action .ico { width: 22px; height: 22px; }
.voice-action:active { box-shadow: inset 3px 3px 8px var(--neu-lo), inset -3px -3px 8px var(--neu-hi); }
.voice-end { color: var(--err); }
.listen-btn[aria-pressed=true] { color: var(--accent-ink); }
.rate-group { display: inline-flex; gap: 2px; }
.turn-actions .rate-btn { width: 36px; padding: 0; justify-content: center; }
.rate-btn svg { width: 16px; height: 16px; transition: transform var(--t-hover) var(--ease); }
.rate-btn[aria-pressed=true] { color: var(--accent-ink); background: var(--accent-soft); }
.rate-btn[aria-pressed=true] svg { transform: scale(1.08); fill: color-mix(in srgb, currentColor 18%, transparent); }

/* shared: icon tile and switch (Settings and Help) */
.tile-ico { display: grid; width: 40px; height: 40px; flex: none; place-items: center; border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: var(--hi); }
.tile-ico .ico { width: 18px; height: 18px; }
.switch { appearance: none; -webkit-appearance: none; position: relative; width: 42px; height: 24px; flex: none; margin: 0; border-radius: var(--r-pill); background: var(--line-3); cursor: pointer; transition: background var(--t-hover) var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0005; transition: transform 320ms var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:disabled { cursor: not-allowed; opacity: .55; }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- pages: shared header, cards, forms ---------- */
.view { position: relative; z-index: 1; flex: 1; min-height: 0; overflow: auto; padding: var(--s-4) var(--s-6) var(--s-8) var(--s-4); overscroll-behavior: contain; }
.view:focus { outline: none; }
.view-inner { width: min(100%, 980px); margin: 0 auto; padding: 0 6px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5); margin: var(--s-5) 0 var(--s-5); }
/* The page tag sits beside the title; the subtitle runs underneath both. */
/* Title, then its tag on the same line; the description sits under both, never beside them. */
.page-titles { display: grid; flex: 1; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "title tag" "sub sub"; align-items: center; justify-items: start; gap: 8px 12px; min-width: 0; }
.page-titles > h1 { grid-area: title; }
.page-titles > .eyebrow { grid-area: tag; min-height: 22px; padding: 2px 10px 2px 8px; gap: 6px; font-size: 10.5px; letter-spacing: .12em; background: transparent; }
.page-titles > .eyebrow .ico { width: 12px; height: 12px; }
.page-titles > .page-sub { grid-area: sub; }
.page-head h1 { margin: 0; font-size: clamp(32px, 4.2vw, 44px); font-weight: 500; letter-spacing: -.04em; line-height: 1.04; }
.page-sub { max-width: 72ch; margin: 0; color: var(--muted); font-size: var(--t-sm); line-height: 1.55; text-wrap: pretty; }
.page-actions { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding-bottom: 4px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin: 0 0 var(--s-5); padding-bottom: var(--s-4); border-bottom: 1px solid var(--line); }
.count-badge { min-width: 28px; padding: 2px 10px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); font: 560 var(--t-xs) var(--f-mono); text-align: center; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-6); align-items: start; }
.callout { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 var(--s-6); padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--r-3); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); color: var(--ink-2); font-size: var(--t-sm); line-height: 1.55; box-shadow: var(--hi); }
.callout .ico { margin-top: 1px; color: var(--accent-ink); }
.callout span { min-width: 0; }
.field { display: grid; gap: 8px; margin: 0 0 var(--s-5); }
.field > label, .field-label { color: var(--ink-2); font-size: var(--t-xs); font-weight: 560; letter-spacing: .01em; }
.field-help { display: flex; justify-content: space-between; gap: var(--s-2); margin: 0; color: var(--muted); font: var(--t-xs) var(--f-mono); font-variant-numeric: tabular-nums; }
.field-help.warn { color: var(--warn); }
.field-help.bad, .field-error { color: var(--err); }
.view-inner input:not([type=checkbox]):not([type=file]):not([type=radio]):not([type=search]), .view-inner textarea, .sheet-body select, .sheet-body input:not([type=checkbox]):not([type=file]):not([type=radio]), .sheet-body textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--field); color: var(--ink); font-size: var(--t-sm); box-shadow: inset 0 1px 2px #0000000d; transition: border-color var(--t-hover) var(--ease), box-shadow var(--t-hover) var(--ease), background var(--t-hover) var(--ease); }
.view-inner input:hover:not(:focus):not(:disabled), .view-inner textarea:hover:not(:focus), .sheet-body input:hover:not(:focus):not([type=radio]), .sheet-body textarea:hover:not(:focus) { border-color: var(--line-3); }
.view-inner input:focus-visible, .view-inner textarea:focus-visible, .sheet-body input:focus-visible, .sheet-body textarea:focus-visible { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.view-inner textarea, .sheet-body textarea { resize: vertical; line-height: 1.55; }
.view-inner input::placeholder, .view-inner textarea::placeholder, .sheet-body input::placeholder { color: var(--subtle); }
.view-inner [aria-invalid=true] { border-color: var(--err-fill) !important; }
.form-card { margin: 0 0 var(--s-6); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-1); }
.dropzone { position: relative; display: grid; justify-items: center; gap: 6px; padding: var(--s-6) var(--s-4); border: 1px dashed var(--line-3); border-radius: var(--r-3); background: radial-gradient(70% 90% at 50% 0%, var(--accent-soft), transparent 70%), var(--field); color: var(--ink-2); text-align: center; font-size: var(--t-sm); cursor: pointer; transition: border-color var(--t-hover) var(--ease), background var(--t-hover) var(--ease), transform var(--t-hover) var(--ease); }
.dz-ico { display: grid; width: 44px; height: 44px; place-items: center; margin-bottom: 4px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: var(--hi), 0 6px 14px -8px #0c0e1440; transition: transform 320ms var(--ease); }
.dropzone strong { color: var(--ink); font-weight: 560; }
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); background: radial-gradient(70% 100% at 50% 0%, var(--accent-soft), transparent 75%), var(--surface-2); }
.dropzone:hover .dz-ico, .dropzone.is-drag .dz-ico { transform: translateY(-2px); }
.dropzone:has(.dz-input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.dz-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.dz-sub { color: var(--muted); font: var(--t-xs) var(--f-mono); }
.file-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface-2); color: var(--ink); font-size: var(--t-sm); }
.file-row .ico { width: 18px; height: 18px; color: var(--muted); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font: var(--t-xs) var(--f-mono); }
.check-row { display: inline-flex; align-items: center; gap: 10px; min-height: 32px; color: var(--ink-2); font-size: var(--t-xs); font-weight: 520; cursor: pointer; }
.check-row input, .lib-check { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.ghost-btn.danger { color: var(--err); }
.ghost-btn.danger:hover:not(:disabled) { border-color: var(--err-fill); color: var(--err); background: var(--err-bg); }
.solid-btn.danger { background: var(--err-fill); color: var(--on-danger); box-shadow: none; }
.solid-btn.danger:hover:not(:disabled) { background: var(--err); color: var(--on-danger); }
.confirm-wrap { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.confirm-msg { color: var(--ink-2); font-size: var(--t-xs); }

/* lists */
.workspace-list { margin: 0; padding: 0; list-style: none; }
.workspace-list li:not(.empty-state):not(.skeleton) { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.workspace-list li.skeleton { height: 56px; margin: var(--s-2) 0; padding: 0; border: 0; }
.workspace-list .workspace-title { flex: 1; max-width: 100%; padding: 0; border: 0; background: none; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
button.workspace-title:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-3); }
.item-list { margin-top: var(--s-5); }
.item-list li:not(.empty-state):not(.skeleton) { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; padding: 12px 0; }
.item-list li:not(.empty-state):last-child { border-bottom: 0; }
.item-ico { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface-2); color: var(--ink); box-shadow: var(--hi); }
.item-ico .ico { width: 18px; height: 18px; }
.item-main { display: grid; min-width: 0; gap: 1px; }
.item-title { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--muted); font: var(--t-xs) var(--f-mono); }
/* empty state: one centred vertical stack. Icon, title, text, button; the button never wraps. */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; width: 100%; margin: 0; padding: var(--s-7) var(--s-5); border: 1px solid var(--line); border-radius: var(--r-4); background: radial-gradient(50% 70% at 50% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 75%), var(--surface); box-shadow: var(--hi), var(--amb); text-align: center; list-style: none; }
/* Inside a card the empty state is quiet: no second box, just the message in the free space. */
.card .empty-state, .two-col .empty-state { flex: 1; padding: var(--s-6) var(--s-4); border: 0; background: none; box-shadow: none; }
.card .empty-state .empty-ico, .two-col .empty-state .empty-ico { width: 40px; height: 40px; }
.empty-state h3 + p { margin-top: -2px; }
.empty-ico { display: grid; width: 48px; height: 48px; flex: none; place-items: center; margin-bottom: 4px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: var(--hi), 0 10px 20px -12px #0c0e1459; }
.empty-ico .ico { width: 20px; height: 20px; }
.empty-state h3 { margin: 4px 0 0; font-size: var(--t-md); font-weight: 560; letter-spacing: -.02em; line-height: 1.3; text-wrap: balance; }
.empty-state p { max-width: 42ch; margin: 0; color: var(--muted); font-size: var(--t-sm); line-height: 1.6; text-wrap: pretty; }
.empty-state .solid-btn, .empty-state .ghost-btn { flex: none; width: auto; margin-top: var(--s-3); white-space: nowrap; }
.card-list li.empty-state, .library-list li.empty-state { border-radius: var(--r-4); }
.empty-card { display: grid; justify-items: center; gap: 10px; padding: var(--s-7) var(--s-5); text-align: center; }
.empty-card h2 { margin: 0; font-size: var(--t-xl); font-weight: 500; letter-spacing: -.03em; }
.empty-card .hint { max-width: 46ch; font-size: var(--t-sm); }
.empty-card .solid-btn, .empty-card .ghost-btn { margin-top: var(--s-3); }

/* library */
.lib-toolbar { display: grid; gap: var(--s-4); margin: 0 0 var(--s-6); padding: var(--s-4) var(--s-5); }
.search-field { position: relative; display: flex; align-items: center; }
.search-field > .ico { position: absolute; left: 16px; color: var(--muted); pointer-events: none; }
.search-field input[type=search] { width: 100%; min-height: 48px; padding: 10px 44px 10px 46px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--field); color: var(--ink); font-size: var(--t-sm); box-shadow: inset 0 1px 2px #0000000d; transition: border-color var(--t-hover) var(--ease), box-shadow var(--t-hover) var(--ease); }
.search-field input[type=search]:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-field input[type=search]::placeholder { color: var(--subtle); }
.search-clear { position: absolute; right: 6px; width: 36px; height: 36px; }
.filter-row { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-meta-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.library-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-4); background: var(--surface); box-shadow: var(--hi), var(--bezel), var(--amb); }
.workspace-list.library-list li:not(.empty-state):not(.skeleton) { padding: 0 var(--s-5); }
.workspace-list.library-list li:not(.empty-state):not(.skeleton):last-child { border-bottom: 0; }
.library-list li.empty-state { margin: 0; border: 0; border-radius: 0; background: transparent; }
.library-item { display: grid !important; grid-template-columns: auto minmax(0, 1fr) auto auto auto; grid-template-areas: "chk title pill date act"; align-items: center; gap: var(--s-4); min-height: 60px; transition: background var(--t-hover) var(--ease); }
.library-item:hover, .library-item:focus-within { background: var(--surface-2); }
.library-item.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.library-item .lib-hit { grid-area: chk; }
.library-item .workspace-title { grid-area: title; display: block; min-height: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.library-item .pill { grid-area: pill; }
.library-item .lib-date { grid-area: date; }
.library-item .lib-actions { grid-area: act; justify-self: end; }
.lib-date, .lib-meta { color: var(--muted); font: var(--t-xs) var(--f-mono); white-space: nowrap; }
.mode-tag, .tag { display: inline-flex; align-items: center; min-height: 20px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: var(--r-pill); color: var(--muted); font: 500 11px var(--f-mono); white-space: nowrap; }
.bulkbar { position: sticky; z-index: 3; top: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); margin: 0 0 var(--s-5); padding: 8px 8px 8px var(--s-5); border-radius: var(--r-pill); background: var(--ink); color: var(--on-ink); box-shadow: var(--amb-lg); font-size: var(--t-sm); }
.bulkbar .confirm-msg { color: var(--on-ink); }
.bulkbar .ghost-btn { background: transparent; border-color: color-mix(in srgb, var(--on-ink) 30%, transparent); color: var(--on-ink); box-shadow: none; }
.bulkbar .ghost-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--on-ink) 14%, transparent); color: var(--on-ink); }
.bulkbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

/* monitors and batches */
.workspace-list.card-list li:not(.empty-state):not(.skeleton) { display: block; margin: 0 0 var(--s-6); padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--r-4); background: var(--surface); box-shadow: var(--hi), var(--bezel), var(--amb); }
.card-list li.empty-state { margin: 0 0 var(--s-6); }
.job-head { display: flex; align-items: flex-start; gap: 14px; }
.job-head .item-ico { width: 44px; height: 44px; }
.job-head .item-ico .ico { width: 20px; height: 20px; }
.job-titles { flex: 1; min-width: 0; }
.job-kind { margin: 0 0 4px; color: var(--subtle); font-size: 11px; font-weight: 560; letter-spacing: .16em; text-transform: uppercase; }
.job-title { margin: 0; font-size: var(--t-lg); font-weight: 560; letter-spacing: -.02em; overflow-wrap: anywhere; }
.job-sub { margin: 2px 0 0; color: var(--muted); font-size: var(--t-xs); overflow-wrap: anywhere; }
.job-summary { margin: var(--s-4) 0 0; color: var(--ink-2); font-size: var(--t-sm); line-height: 1.6; }
.job-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); margin: var(--s-4) 0 0; padding: var(--s-4) 0 0; border-top: 1px solid var(--line); }
.job-meta div { display: grid; gap: 2px; }
.job-meta dt { color: var(--muted); font-size: var(--t-xs); }
.job-meta dd { margin: 0; color: var(--ink); font: var(--t-sm) var(--f-mono); font-variant-numeric: tabular-nums; }
.job-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-4); }
.progress { height: 6px; margin: var(--s-4) 0 0; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-3); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--fill, var(--idle-fill)); transition: width 600ms var(--ease); }
.batch-rows { margin: var(--s-4) 0 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-2); overflow: hidden; }
.workspace-list.card-list .batch-rows li:not(.empty-state) { display: flex; margin: 0; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; box-shadow: none; }
.workspace-list.card-list .batch-rows li:last-child { border-bottom: 0; }
.batch-rows .batch-url { flex: 1; min-width: 160px; overflow-wrap: anywhere; font: var(--t-xs) var(--f-mono); }
.mode-select-wrap { position: relative; display: inline-flex; }
.depth-select { appearance: none; -webkit-appearance: none; min-height: var(--hit); padding: 0 36px 0 16px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2); font-size: var(--t-sm); font-weight: 500; cursor: pointer; box-shadow: var(--hi); }
.depth-select:hover { border-color: var(--line-3); }
.mode-select-wrap .ico { position: absolute; top: 50%; right: 12px; width: 16px; height: 16px; margin-top: -8px; color: var(--muted); pointer-events: none; }

/* overview: an asymmetric bento */
.overview-summary { margin: 0 0 var(--s-6); color: var(--ink-2); font: var(--t-sm) var(--f-mono); }
.stat-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-6); margin: 0 0 var(--s-6); }
.stat-grid > * { min-width: 0; }
/* row 1: four KPIs · row 2: runs per day beside the source mix · row 3: what Zearch noticed beside the log */
.stat-verified, .stat-speed, .stat-cost, .stat-runs, .stat-grid .sk-card { grid-column: span 3; }
.stat-daily, .stat-grid .sk-daily { grid-column: 1 / 9; }
.stat-mix, .stat-grid .sk-mix { grid-column: 9 / 13; }
.stat-insights, .stat-grid .sk-insights { grid-column: 1 / 6; }
.stat-activity, .stat-grid .sk-activity { grid-column: 6 / 13; }
.stat-runs .chip-list { margin-top: 0; }
.stat { display: flex; flex-direction: column; min-width: 0; padding: var(--s-5) var(--s-5) var(--s-4); }
.stat > p { margin: 0; }
.stat-title { margin: 0; color: var(--muted); font-size: 11px; font-weight: 560; letter-spacing: .16em; text-transform: uppercase; }
.stat-value { margin-top: var(--s-3) !important; color: var(--ink); font-size: 44px; font-weight: 450; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-verified .stat-value { font-size: clamp(48px, 5vw, 64px); letter-spacing: -.06em; background: linear-gradient(180deg, var(--ink), color-mix(in srgb, var(--ink) 55%, transparent)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-sub { min-height: 1.5em; margin-top: var(--s-2) !important; color: var(--muted); font-size: var(--t-xs); }
.stat-visual { margin: var(--s-4) 0; }
.stat-verified .stat-visual { margin-top: auto; }
.stat-speed .stat-visual { display: flex; flex: 1; flex-direction: column; justify-content: flex-end; }
.stat-speed .spark { flex: 1; min-height: 72px; }
.stat-foot { margin-top: auto !important; padding-top: var(--s-3); border-top: 1px solid var(--line); color: var(--subtle); font-size: var(--t-xs); line-height: 1.45; }
.stat-daily .section-head h2, .stat-insights .section-head h2, .activity .section-head h2 { color: var(--muted); font-size: 11px; font-weight: 560; letter-spacing: .16em; text-transform: uppercase; }
.stack { display: flex; gap: 3px; height: 12px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-3); }
.stack .seg { flex: 1 1 0; min-width: 6px; border-radius: 3px; background: var(--fill); }
.legend { display: flex; flex-wrap: wrap; gap: 4px var(--s-4); margin: var(--s-3) 0 0; padding: 0; list-style: none; color: var(--muted); font-size: var(--t-xs); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--ink); font: 560 var(--t-xs) var(--f-mono); }
.swatch { width: 9px; height: 9px; border-radius: 3px; background: var(--fill); }
.spark { width: 100%; height: 72px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.75px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-cap { margin: 4px 0 0 !important; color: var(--subtle); font-size: 11px; }
.bars { display: flex; align-items: stretch; gap: 4px; height: 168px; padding-top: var(--s-2); border-bottom: 1px solid var(--line-2); }
.bar { display: flex; flex: 1; align-items: flex-end; min-width: 0; }
.bar-fill { width: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 35%, transparent)); }
.bar-axis { display: flex; justify-content: space-between; gap: var(--s-2); margin-top: var(--s-2); color: var(--muted); font: var(--t-xs) var(--f-mono); }
.chip-list { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-4) 0 0; padding: 0; list-style: none; }
.insight-list { margin: 0 0 var(--s-3); padding: 0; list-style: none; }
.insight-list li { padding: var(--s-3) 0; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: var(--t-sm); line-height: 1.55; }
.insight-list li:first-child { padding-top: 0; }
.activity { padding: var(--s-5) var(--s-5) var(--s-3); }
.table-wrap { margin: 0 calc(var(--s-5) * -1); overflow-x: auto; }
table.log { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
table.log th { padding: 0 var(--s-3) var(--s-2); border-bottom: 1px solid var(--line-2); color: var(--muted); font-size: 11px; font-weight: 560; letter-spacing: .12em; text-transform: uppercase; text-align: left; white-space: nowrap; }
table.log th:first-child, table.log td:first-child { padding-left: var(--s-5); }
table.log th:last-child, table.log td:last-child { padding-right: var(--s-5); }
.th-sort { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 var(--s-2); margin-left: calc(var(--s-2) * -1); border: 0; border-radius: var(--r-pill); background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.th-sort:hover { color: var(--ink); background: var(--hover); }
.th-sort .ico { width: 14px; height: 14px; opacity: .55; }
th[aria-sort=ascending] .th-sort, th[aria-sort=descending] .th-sort { color: var(--ink); }
th[aria-sort=ascending] .th-sort .ico, th[aria-sort=descending] .th-sort .ico { opacity: 1; }
table.log td { padding: var(--s-3); border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
table.log tbody tr { transition: background var(--t-hover) var(--ease); }
table.log tbody tr:last-child td { border-bottom: 0; }
table.log tbody tr:hover { background: var(--surface-2); }
table.log td.q { width: 40%; max-width: 0; }
.row-link { display: block; max-width: 100%; min-height: 32px; overflow: hidden; padding: 0; border: 0; background: none; color: var(--ink); text-align: left; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-sm); }
.row-link:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-3); }
table.log time { white-space: nowrap; font: var(--t-xs) var(--f-mono); }
.num { font-family: var(--f-mono); font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
.stat-grid .skeleton { min-height: 200px; }
.sk-wide { height: 280px; }

/* skeletons: the shimmer only moves a transform */
.skeleton { position: relative; overflow: hidden; border-radius: var(--r-3); background: var(--surface-2); border: 1px solid var(--line); }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, var(--shimmer) 50%, transparent 80%); transform: translateX(-100%); animation: sweep 1.8s var(--ease) infinite; }

/* ---------- command palette: one clean panel ---------- */
dialog.palette { width: min(620px, calc(100vw - 24px)); margin: 12vh auto auto; padding: 0; overflow: hidden; border: 1px solid var(--ring); border-radius: 22px; background: var(--pop); color: var(--ink); box-shadow: var(--hi), var(--amb-lg); }
dialog.palette[open] { animation: palette-in .32s var(--ease) backwards; transform-origin: 50% 0; }
@keyframes palette-in { from { opacity: 0; transform: translateY(-8px) scale(.985); } to { opacity: 1; transform: none; } }
dialog.palette::backdrop, .sheet::backdrop { background: var(--backdrop); backdrop-filter: blur(6px); animation: fade .4s var(--ease) both; }
.palette-box { display: flex; flex-direction: column; max-height: min(70vh, 560px); }
.palette-input { display: flex; flex: none; align-items: center; gap: 12px; padding: 0 14px 0 20px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-input > .ico { width: 18px; height: 18px; }
.palette-input input { flex: 1; min-width: 0; height: 58px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; letter-spacing: -.005em; }
.palette-input input::placeholder { color: var(--subtle); }
.palette-esc { flex: none; padding: 3px 8px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface-2); color: var(--muted); font: 500 11px var(--f-mono); }
#palette-list { flex: 1; min-height: 0; margin: 0; padding: 6px 8px 10px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; list-style: none; }
.palette-item { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 10px; border-radius: 12px; color: var(--ink-2); font-size: var(--t-sm); cursor: pointer; transition: background 120ms var(--ease), color 120ms var(--ease); }
.palette-item[aria-selected=true] { background: color-mix(in srgb, var(--accent) 10%, var(--hover)); color: var(--ink); }
.palette-item[aria-selected=true]::after { content: "↵"; flex: none; color: var(--muted); font: 500 12px var(--f-mono); }
.p-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .p-group { flex: none; max-width: 40%; overflow: hidden; color: var(--subtle); font-size: var(--t-xs); text-overflow: ellipsis; white-space: nowrap; }
.palette-head { margin: 0; padding: 14px 10px 6px; color: var(--subtle); font-size: 11px; font-weight: 560; letter-spacing: .08em; text-transform: uppercase; }
.palette-head:first-child { padding-top: 8px; }
.palette-item .p-ico { display: grid; width: 30px; height: 30px; flex: none; place-items: center; border-radius: 9px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); }
.palette-item[aria-selected=true] .p-ico { background: var(--surface); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.palette-item .p-ico .ico { width: 15px; height: 15px; color: inherit; }
.palette-none { padding: var(--s-7) var(--s-5); color: var(--muted); text-align: center; font-size: var(--t-sm); }
.palette-foot { display: flex; flex: none; align-items: center; gap: var(--s-4); margin: 0; padding: 10px 20px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface-2) 50%, transparent); color: var(--subtle); font-size: 11px; }
.palette-foot kbd { min-width: 20px; padding: 1px 6px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--muted); font: 500 10.5px var(--f-mono); text-align: center; }

/* ---------- conversation ---------- */
.thread { width: min(100%, var(--answer-width)); margin: 0 auto; padding: var(--s-5) 0; }
.turn { margin: 0 0 var(--s-7); animation: enter .7s var(--ease) backwards; }
.user-message { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2); margin: 0 0 var(--s-6); }
.user-label, .assistant-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--t-xs); font-weight: 560; }
.assistant-head { margin: 0 0 var(--s-4); color: var(--ink); font-size: var(--t-sm); }
.assistant-head .mark { display: grid; width: 28px; height: 28px; place-items: center; color: var(--ink); }
.assistant-head .mark .ico { width: 28px; height: 28px; stroke-width: 2px; }
.user-bubble { max-width: min(82%, 600px); padding: 12px 18px; border: 1px solid var(--line-2); border-radius: var(--r-4) var(--r-4) 8px var(--r-4); background: var(--surface); color: var(--ink); box-shadow: var(--hi), var(--amb); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.user-message > .source-meta { max-width: min(82%, 600px); margin: 0 var(--s-1) 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-mono); }
.assistant-message { min-width: 0; }
.user-label { max-width: min(82%, 600px); margin-right: var(--s-2); font-weight: 500; }
.user-label .ico { width: 13px; height: 13px; }
.user-target { min-width: 0; overflow: hidden; padding-left: 8px; border-left: 1px solid var(--line-2); font-family: var(--f-mono); text-overflow: ellipsis; white-space: nowrap; }
.assistant-head { flex-wrap: wrap; }
/* live progress: Search → Read → Select → Write → Verify, shown only while a run works */
.run-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 0 var(--s-2); padding: 0; list-style: none; }
.run-step { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--r-pill); color: var(--subtle); font-size: 11.5px; font-weight: 500; }
.run-step::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); }
.run-step[data-state=done] { color: var(--muted); }
.run-step[data-state=done]::before { background: var(--ok-fill); }
.run-step[data-state=active] { background: var(--accent-soft); color: var(--accent-ink); }
.run-step[data-state=active]::before { background: var(--accent); animation: pulse 1.2s var(--ease) infinite; }
.source-strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--s-4); }
.source-pill { display: inline-flex; max-width: 220px; flex: none; align-items: center; gap: 6px; min-height: 32px; padding: 2px 12px 2px 3px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--hi); color: var(--ink-2); font-size: var(--t-xs); transition: border-color var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.source-pill:hover { border-color: var(--accent); color: var(--ink); }
.source-pill-n { display: grid; min-width: 24px; height: 24px; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font: 600 11px/1 var(--f-mono); }
.source-pill-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-more { padding-left: 12px; color: var(--muted); }
.research-status { display: flex; align-items: center; gap: 10px; margin: 0 0 var(--s-3); color: var(--muted); font-size: var(--t-xs); }
.research-status[data-busy=true]::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: pulse 1.4s var(--ease) infinite; }
/* streaming shimmer: a thin bar sweeps by transform only */
.research-status[data-busy=true] { position: relative; overflow: hidden; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); box-shadow: var(--hi); }
.research-status[data-busy=true]::after { content: ""; position: absolute; left: 0; bottom: 0; width: 100%; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); transform: translateX(-100%); animation: sweep 1.6s var(--ease) infinite; }
.research-status[data-tone=error] { align-items: flex-start; padding: var(--s-3) var(--s-4); border: 1px solid color-mix(in srgb, var(--err-fill) 35%, transparent); border-radius: var(--r-3); background: var(--err-bg); color: var(--err); font-size: var(--t-sm); }
.research-status[data-tone=error]::before { content: "!"; display: inline-grid; flex: none; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: var(--err-fill); color: var(--on-danger); font: 700 12px/1 var(--f-ui); animation: none; box-shadow: none; }
.research-status[data-tone=notice] { padding: var(--s-3) var(--s-4); border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--surface); font-size: var(--t-sm); }
.research-prose { font-size: 16px; line-height: 1.75; overflow-wrap: anywhere; }
.research-prose > p, .research-prose > ul, .research-prose > ol, .research-prose > h2, .research-prose > h3, .research-prose > h4, .research-prose > blockquote, .answer-details > p, .answer-details > ul, .answer-details > ol, .answer-details > h2, .answer-details > h3, .answer-details > h4, .answer-details > blockquote { max-width: var(--prose-width); }
.research-prose p { margin: 0 0 1em; white-space: pre-wrap; }
.research-prose h2, .research-prose h3, .research-prose h4 { margin: 1.5em 0 .5em; font-size: var(--t-lg); line-height: 1.35; letter-spacing: -.02em; }
.research-prose li { margin: .4em 0; }
.research-prose li > ul, .research-prose li > ol { margin: .2em 0 .4em; }
.research-prose hr { max-width: var(--prose-width); margin: 1.6em 0; border: 0; border-top: 1px solid var(--line-2); }
.text-link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 3px; transition: text-decoration-color var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.text-link:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.research-prose blockquote { margin: 1em 0; padding: 0 var(--s-4); border-left: 2px solid var(--accent); color: var(--ink-2); white-space: pre-wrap; }
.research-prose code { font-size: .86em; }
.research-prose :not(pre) > code { padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.citation { text-decoration-color: var(--line-3); text-underline-offset: 3px; }
/* citation chips: the number only; the full "[n]" stays in the text for copy and the label for assistive tech */
.citation-button { position: relative; display: inline-block; min-width: 20px; height: 20px; margin: 0 2px; padding: 0 6px; vertical-align: middle; border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-ink); font-size: 0; line-height: 18px; text-align: center; text-decoration: none; cursor: pointer; transition: background var(--t-hover) var(--ease), transform var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.citation-button::after { content: attr(data-citation-id); font: 600 11px/18px var(--f-mono); }
.citation-button::before { content: ""; position: absolute; inset: -12px -8px; }
.citation-button:hover { background: var(--accent); color: var(--surface); transform: translateY(-1px); }
.research-prose .citation { margin-inline: 2px; font-size: var(--t-xs); }
.research-prose .citation-button { font-size: 0; }
.answer-details, .research-trace { margin: var(--s-4) 0; }
.research-prose .answer-details { border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); box-shadow: var(--hi); }
.answer-details > summary { display: grid; gap: 1px; padding: 12px 16px; }
.answer-details > :not(summary) { margin-inline: 16px; }
.answer-details > :last-child { margin-bottom: 16px; }
.details-title { color: var(--ink); font-weight: 560; }
.details-hint { color: var(--muted); font-size: var(--t-xs); }
.answer-details summary, .research-trace summary { color: var(--ink-2); font-size: var(--t-sm); }
.answer-table { max-width: 100%; overflow: auto; margin: var(--s-4) 0; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); }
.answer-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.answer-table th, .answer-table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.answer-table tr:last-child td { border-bottom: 0; }
.answer-table th { color: var(--ink-2); font-weight: 600; background: var(--surface-2); }
.answer-code { margin: var(--s-4) 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--sunken); }
.answer-code-language { display: block; padding: var(--s-2) var(--s-4) 0; color: var(--muted); font: var(--t-xs)/1.4 var(--f-mono); }
.answer-code pre { overflow: auto; margin: 0; padding: var(--s-3) var(--s-4) var(--s-4); }
.chart-toggle { margin: 0 0 var(--s-3); padding: 6px 14px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font-size: var(--t-xs); }
.chart-toggle:hover { background: var(--hover); }
.chart-toggle[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.answer-chart { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-3); }
.chart-row { display: grid; grid-template-columns: minmax(80px, 1fr) minmax(90px, 3fr) auto; gap: var(--s-3); align-items: center; color: var(--ink-2); font-size: var(--t-xs); }
.chart-row > span { overflow-wrap: anywhere; }
.chart-track { height: 12px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-3); }
.chart-fill { height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 50%, transparent), var(--accent)); }

/* ---------- actions, follow-ups, export menu ---------- */
.turn-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-3); padding-bottom: var(--s-3); border-bottom: 1px solid var(--line); }
.assistant-message > .turn-actions { margin-top: var(--s-5); padding: var(--s-4) 0 0; border-top: 1px solid var(--line); border-bottom: 0; }
.turn-actions .spacer { flex: 1; }
/* action row: icon pills */
.turn-actions .ghost-btn { min-height: 36px; padding: 4px 14px 4px 12px; gap: 8px; font-size: var(--t-xs); }
.btn-label { min-width: 0; }
.followups { display: flex; flex-wrap: wrap; gap: 8px; margin: var(--s-5) 0 0; }
.followups-title { width: 100%; margin: 0; color: var(--subtle); font-size: 11px; font-weight: 560; letter-spacing: .16em; text-transform: uppercase; }
.followup-chip { position: relative; min-height: 40px; padding: 8px 18px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(0); box-shadow: var(--hi); color: var(--ink-2); font-size: var(--t-sm); text-align: left; animation: tile-in .55s var(--ease) both; transition: border-color var(--t-hover) var(--ease), color var(--t-hover) var(--ease), transform var(--t-hover) var(--ease), background var(--t-hover) var(--ease); }
.followup-chip:nth-of-type(2) { animation-delay: 60ms; } .followup-chip:nth-of-type(3) { animation-delay: 120ms; } .followup-chip:nth-of-type(4) { animation-delay: 180ms; }
.followup-chip:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); transform: translateY(-1px); }
.followup-chip:active:not(:disabled) { transform: scale(.98); }
.export-menu { position: relative; z-index: 3; }
.export-menu summary { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 36px; padding: var(--s-2) 14px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2); font-size: var(--t-xs); font-weight: 500; list-style: none; box-shadow: var(--hi); transition: border-color var(--t-hover) var(--ease), background var(--t-hover) var(--ease); }
.export-menu summary::-webkit-details-marker { display: none; }
.export-menu summary .ico { width: 16px; height: 16px; }
.export-menu summary::after { content: ""; width: 6px; height: 6px; margin-top: -3px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.export-menu summary:hover, .export-menu[open] summary { border-color: var(--line-3); background: var(--surface-2); color: var(--ink); }
.export-options { position: absolute; left: 0; bottom: calc(100% + var(--s-2)); display: grid; gap: 2px; min-width: 200px; padding: 6px; border: 1px solid var(--ring); border-radius: var(--r-4); background: var(--pop); backdrop-filter: blur(22px); box-shadow: var(--hi), var(--amb-lg); animation: spring .4s var(--ease) both; transform-origin: 0 100%; }
.export-options .ghost-btn { justify-content: flex-start; width: 100%; border: 0; background: transparent; box-shadow: none; }
.export-options .ghost-btn:hover:not(:disabled) { background: var(--hover); }

/* ---------- evidence ---------- */
.research-evidence { margin: var(--s-5) 0 0; color: var(--ink-2); font-size: var(--t-sm); }
.research-evidence > summary, .research-trace > summary { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 var(--s-4); border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--hi); color: var(--ink-2); font-size: var(--t-sm); font-weight: 520; list-style: none; transition: border-color var(--t-hover) var(--ease), background var(--t-hover) var(--ease); }
.research-evidence > summary::-webkit-details-marker, .research-trace > summary::-webkit-details-marker, .answer-details > summary::-webkit-details-marker { display: none; }
.research-evidence > summary::after, .research-trace > summary::after { content: ""; width: 7px; height: 7px; margin: -3px 2px 0 auto; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform 320ms var(--ease); }
.research-evidence[open] > summary::after, .research-trace[open] > summary::after { margin-top: 3px; transform: rotate(225deg); }
.src-count { display: inline-grid; min-width: 24px; height: 24px; padding: 0 7px; place-items: center; border-radius: var(--r-pill); background: var(--ink); color: var(--on-ink); font: 600 11px var(--f-mono); }
.research-evidence > summary:hover, .research-trace > summary:hover { color: var(--ink); border-color: var(--line-3); }
.research-evidence ol { display: grid; gap: var(--s-5); margin: var(--s-4) 6px var(--s-3); padding: 0; list-style: none; }
.evidence-card { margin: 0; padding: var(--s-4) var(--s-5); border: 1px solid var(--line); border-radius: var(--r-4); background: var(--surface); box-shadow: var(--hi), var(--bezel), var(--amb); scroll-margin: var(--s-6); animation: tile-in .5s var(--ease) both; }
.evidence-card:focus { outline: none; }
.evidence-card.is-target { animation: target 1.8s var(--ease); }
.evidence-head { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.evidence-num { display: inline-grid; flex: none; min-width: 24px; height: 24px; padding: 0 6px; place-items: center; border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-ink); font: 600 11px var(--f-mono); }
.evidence-head > a, .evidence-private { color: var(--ink); font-size: var(--t-sm); font-weight: 560; overflow-wrap: anywhere; }
.evidence-domain { display: block; margin: 2px 0 0 36px; color: var(--muted); font: var(--t-xs) var(--f-mono); }
.evidence-excerpt { display: -webkit-box; overflow: hidden; margin: var(--s-3) 0 0; color: var(--ink-2); font-size: var(--t-xs); line-height: 1.7; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.evidence-excerpt.expanded { display: block; }
.evidence-card > .link-btn { margin-top: var(--s-1); padding-left: 0; }
.source-meta { display: block; margin-top: var(--s-1); color: var(--muted); font-size: var(--t-xs); }
.source-capture { margin-top: var(--s-2); }
.source-capture summary { width: max-content; padding: var(--s-1) 0; color: var(--ink-2); font-size: var(--t-xs); }
.source-snapshot { max-height: 380px; overflow: auto; margin: var(--s-2) 0 0; padding: var(--s-3); border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--sunken); color: var(--ink-2); font-size: var(--t-xs); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.source-snapshot mark { background: var(--accent-soft); color: var(--ink); box-shadow: 0 0 0 2px var(--accent-soft); border-radius: 3px; }
.trace-list { margin: var(--s-2) 0 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); overflow: hidden; }
.trace-list li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: var(--t-xs); overflow-wrap: anywhere; }
.trace-list li:last-child { border-bottom: 0; }
.trace-list li::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--ok-fill); }
.cite-pop { position: fixed; z-index: 90; display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border: 1px solid var(--ring); border-radius: var(--r-3); background: var(--pop); backdrop-filter: blur(20px); box-shadow: var(--hi), var(--amb-lg); color: var(--ink); font-size: var(--t-xs); pointer-events: none; }
.cite-pop strong { font-size: var(--t-sm); font-weight: 560; }
.cite-pop small { color: var(--muted); font: var(--t-xs) var(--f-mono); }
.cite-pop p { margin: var(--s-1) 0 0; color: var(--ink-2); line-height: 1.5; }

/* ---------- market ---------- */
.market-card { margin: 0 0 var(--s-5); padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--r-4); background: var(--surface); box-shadow: var(--hi), var(--bezel), var(--amb); }
.market-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-1) var(--s-4); color: var(--ink-2); font-size: var(--t-sm); font-weight: 560; }
.market-card-head span:last-child { color: var(--muted); font-size: var(--t-xs); font-weight: 450; }
.market-price { margin: var(--s-3) 0 2px; color: var(--ink); font-size: clamp(38px, 5.4vw, 56px); font-weight: 480; letter-spacing: -.06em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.market-time, .market-no-chart { margin: 0; color: var(--muted); font-size: var(--t-xs); }
.market-change { display: inline-flex; margin: 2px 0 6px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--hover); color: var(--ink); font-size: var(--t-sm); font-weight: 560; font-variant-numeric: tabular-nums; }
.market-change[data-direction=up] { background: color-mix(in srgb, #2fbf71 16%, transparent); color: color-mix(in srgb, #2fbf71 70%, var(--ink)); }
.market-change[data-direction=down] { background: color-mix(in srgb, #e5484d 14%, transparent); color: color-mix(in srgb, #e5484d 70%, var(--ink)); }
.market-range { margin: 0 0 4px; color: var(--ink-2); font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
.market-figure { margin: 0 0 var(--s-5); padding: var(--s-4); border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--surface); }
.market-figure figcaption { color: var(--ink); font-size: var(--t-sm); font-weight: 550; }
.market-figure svg { width: 100%; height: auto; margin: var(--s-2) 0; border-bottom: 1px solid var(--line); }
.market-figure svg polyline { stroke: var(--accent); }
.market-figure small { color: var(--muted); font-size: var(--t-xs); line-height: 1.5; }
.market-card .market-figure { margin: var(--s-5) 0 0; padding: var(--s-4) 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.market-card .market-figure svg { max-height: 195px; }
.market-card .market-figure small { display: block; }
.market-no-chart { margin-top: var(--s-5); padding: var(--s-4) 0 2px; border-top: 1px solid var(--line); }
.market-disclaimer { margin: var(--s-4) 0 0; color: var(--muted); font-size: var(--t-xs); line-height: 1.55; }
.market-disclaimer a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.market-card:not(.is-history) + p { color: var(--muted); font-size: var(--t-xs); line-height: 1.6; }

/* ---------- collections ---------- */
.collection-dashboard { overflow: hidden; margin: 2px 6px var(--s-5); border: 1px solid var(--line); border-radius: var(--r-4); background: var(--surface); box-shadow: var(--hi), var(--bezel), var(--amb); }
.collection-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-3); }
.collection-eyebrow { color: var(--muted); font: 11px/1.4 var(--f-mono); letter-spacing: .16em; }
.collection-title h2 { margin: var(--s-1) 0 0; font-size: 26px; font-weight: 500; letter-spacing: -.04em; line-height: 1.2; }
.collection-target { max-width: 50%; margin: 0 0 var(--s-1); color: var(--muted); text-align: right; font: var(--t-xs) var(--f-mono); overflow-wrap: anywhere; }
.collection-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); margin: var(--s-2) var(--s-5) var(--s-4); }
.collection-metric { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-2); box-shadow: var(--hi); text-align: left; transition: background var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease), transform var(--t-hover) var(--ease); }
.collection-metric:hover { border-color: var(--line-3); background: var(--surface-3); transform: translateY(-1px); }
.collection-metric strong { color: var(--ink); font: 450 24px/1.2 var(--f-ui); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.collection-metric span { color: var(--muted); font-size: var(--t-xs); }
.collection-tabs { display: flex; gap: var(--s-1); overflow-x: auto; padding: 0 var(--s-5); border-bottom: 1px solid var(--line); }
.collection-tab { flex: none; min-height: 44px; padding: var(--s-2) var(--s-3); border: 0; border-bottom: 2px solid transparent; border-radius: var(--r-2) var(--r-2) 0 0; background: none; color: var(--muted); font-size: var(--t-xs); font-weight: 520; transition: color var(--t-hover) var(--ease), background var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease); }
.collection-tab:hover { background: var(--hover); color: var(--ink); }
.collection-tab[aria-selected=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.collection-panel { min-width: 0; padding: var(--s-5); }
.collection-panel .research-prose { font-size: var(--t-md); line-height: 1.7; }
.collection-panel .research-prose > :last-child { margin-bottom: 0; }
.collection-section-title { margin: 0 0 var(--s-4); font-size: 14px; font-weight: 560; letter-spacing: -.01em; }
.collection-empty, .collection-data-note { margin: 0 0 var(--s-4); color: var(--muted); font-size: var(--t-sm); line-height: 1.6; }
.collection-page { margin: var(--s-2) 0; padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-2); }
.collection-page-top { display: flex; align-items: flex-start; gap: var(--s-3); min-width: 0; }
.collection-index { color: var(--muted); font: var(--t-xs) var(--f-mono); }
.collection-page-top a { color: var(--ink); font-size: 14px; text-decoration: none; overflow-wrap: anywhere; }
.collection-page-top a:hover, .collection-media-card a:hover { text-decoration: underline; }
.collection-page p { margin: var(--s-2) 0 var(--s-1) 28px; color: var(--ink-2); font-size: var(--t-xs); line-height: 1.55; }
.collection-url, .collection-page-meta { display: block; margin: var(--s-1) 0 0 28px; color: var(--muted); font: var(--t-xs) var(--f-mono); overflow-wrap: anywhere; }
.collection-page-capture { margin: var(--s-3) 0 0 28px; }
.collection-page-capture summary { color: var(--ink-2); font-size: var(--t-xs); }
.collection-page-capture pre { max-height: 280px; margin: var(--s-2) 0 0; padding: var(--s-3); overflow: auto; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--sunken); color: var(--ink-2); font-size: var(--t-xs); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.collection-filters { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-4); }
.filter-btn { min-height: 34px; padding: 4px 14px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: transparent; color: var(--muted); font-size: var(--t-xs); font-weight: 500; transition: border-color var(--t-hover) var(--ease), background var(--t-hover) var(--ease), color var(--t-hover) var(--ease), transform var(--t-hover) var(--ease); }
.filter-btn:hover:not(:disabled) { border-color: var(--line-3); background: var(--hover); color: var(--ink); }
.filter-btn:active:not(:disabled) { transform: scale(.97); }
.filter-btn[aria-pressed=true] { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }
.collection-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s-3); }
.collection-media-card { min-width: 0; padding: var(--s-2); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-2); }
.collection-media-frame { display: grid; height: 118px; place-items: center; overflow: hidden; border-radius: var(--r-2); background: var(--sunken); color: var(--muted); font-size: var(--t-xs); }
.collection-media-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.collection-kind { display: block; margin: var(--s-2) 0 var(--s-1); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.collection-media-card a { display: block; overflow: hidden; color: var(--ink-2); font-size: var(--t-xs); text-overflow: ellipsis; white-space: nowrap; }
.collection-contact { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--s-2); align-items: center; padding: var(--s-3) 0; border-top: 1px solid var(--line); }
.collection-contact strong { font-size: var(--t-sm); font-weight: 500; overflow-wrap: anywhere; }
.collection-contact small { grid-column: 1; color: var(--muted); font-size: var(--t-xs); overflow-wrap: anywhere; }
.collection-contact button { grid-column: 2; grid-row: 1 / 3; }
.collection-fields { display: grid; grid-template-columns: 120px minmax(0, 1fr); margin: 0 0 var(--s-4); border-top: 1px solid var(--line); font-size: var(--t-xs); }
.collection-fields dt, .collection-fields dd { margin: 0; padding: var(--s-3) 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.collection-fields dt { color: var(--muted); }
.collection-fields dd { color: var(--ink-2); font-family: var(--f-mono); }
.collection-decision { display: grid; gap: 3px; margin: var(--s-4) 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-2); }
.collection-decision strong { font-size: var(--t-sm); font-weight: 560; }
.collection-decision small { color: var(--muted); font-size: var(--t-xs); }
.collection-visual { padding-top: var(--s-4); border-top: 1px solid var(--line); }
.collection-visual > img { display: block; width: 100%; max-height: 360px; object-fit: contain; object-position: top center; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--sunken); }
.collection-download { display: inline-block; margin: var(--s-2) 0 var(--s-4); color: var(--ink-2); font-size: var(--t-xs); }
.collection-palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-2); margin: var(--s-2) 0 var(--s-4); }
.collection-color { display: flex; align-items: center; gap: var(--s-2); min-width: 0; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-2); }
.collection-swatch { width: 24px; height: 24px; flex: none; border: 1px solid var(--line-3); border-radius: 6px; }
.collection-color small { overflow: hidden; color: var(--ink-2); font: var(--t-xs) var(--f-mono); text-overflow: ellipsis; white-space: nowrap; }

/* ---------- dialogs: outer shell around an inner core ---------- */
.sheet { width: min(540px, calc(100vw - 24px)); max-height: min(88dvh, 800px); padding: 6px; overflow: hidden; border: 1px solid var(--ring); border-radius: calc(var(--r-4) + 8px); background: color-mix(in srgb, var(--surface) 62%, transparent); color: var(--ink); box-shadow: var(--amb-lg); overscroll-behavior: contain; }
.sheet[open] { animation: spring .5s var(--ease) backwards; }
.sheet-body { display: flex; flex-direction: column; gap: var(--s-4); max-height: calc(min(88dvh, 800px) - 14px); overflow: auto; padding: 0 var(--s-6) var(--s-6); border-radius: calc(var(--r-4) + 2px); background: var(--pop); box-shadow: var(--hi); overscroll-behavior: contain; }
.sheet-body > header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin: 0 calc(var(--s-6) * -1); padding: var(--s-5) var(--s-6) var(--s-4); border-bottom: 1px solid var(--line); background: var(--pop); backdrop-filter: blur(20px); }
.sheet-titles { display: grid; justify-items: start; gap: var(--s-3); }
.sheet-body h2 { margin: 0; font-size: 26px; font-weight: 500; letter-spacing: -.04em; line-height: 1.1; }
.sheet-body h2 em { color: var(--muted); font-style: normal; }
.sheet-body p { margin: 0; color: var(--ink-2); font-size: var(--t-sm); line-height: 1.6; }
.sheet-body p.hint { color: var(--muted); font-size: var(--t-xs); }
.sheet-body select option { background: var(--surface); }
.sheet-body footer { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-3); }
.workspace-sheet { width: min(740px, calc(100vw - 24px)); }
.workspace-sheet h3 { margin: 0 0 var(--s-1); font-size: var(--t-md); font-weight: 560; letter-spacing: -.015em; }
.sheet-body .turn-actions { margin-top: var(--s-2); padding-bottom: 0; border-bottom: 0; }
#account-email-form, #account-code-form { display: grid; gap: var(--s-2); margin: var(--s-3) 0; max-width: 400px; }
#note-form, #document-form, #batch-form { display: grid; }
.setting-card { border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-2); box-shadow: var(--hi); }
.setting-card.pad { padding: var(--s-5); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 14px 16px; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-check { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: var(--s-3); margin: 0; cursor: pointer; }
.setting-text { display: grid; gap: 2px; min-width: 0; }
.setting-text strong { color: var(--ink); font-size: var(--t-sm); font-weight: 560; }
.setting-text small { color: var(--muted); font-size: var(--t-xs); line-height: 1.45; }
.fact-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); margin: 0; padding: 0; list-style: none; }
.fact-tiles li { display: grid; align-content: start; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-2); box-shadow: var(--hi); font-size: var(--t-xs); line-height: 1.5; }
.fact-tiles li b { color: var(--ink); font-size: var(--t-sm); font-weight: 560; }
.fact-tiles li span:not(.tile-ico) { color: var(--muted); }
.fact-tiles .tile-ico { margin-bottom: 4px; }
.sheet-body .segmented label { margin: 0; color: var(--muted); font-size: var(--t-sm); }
.sheet-body .segmented label:has(input:checked) { color: var(--ink); }
.sheet-body .segmented input { width: auto; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; }

/* ---------- toasts ---------- */
.toast-region { position: fixed; z-index: 80; left: 50%; bottom: max(var(--s-6), env(safe-area-inset-bottom)); display: grid; justify-items: center; width: min(460px, calc(100vw - 32px)); transform: translateX(-50%); pointer-events: none; }
/* The page's own toasts live bottom-right, clear of the chat box; dialogs keep theirs inside. */
#toast-region { left: auto; right: max(24px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); justify-items: end; width: min(380px, calc(100vw - 32px)); transform: none; }
#toast-region .toast { animation: toast-in .42s var(--ease) both; transform-origin: 100% 100%; }
.toast.is-leaving { animation: toast-out .22s var(--ease) both !important; pointer-events: none; }
@keyframes toast-in { from { opacity: 0; transform: translateX(28px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(28px) scale(.98); } }
/* When the chat box reaches under the toast's corner, app.js lifts the region above it (--toast-lift). */
#toast-region { bottom: max(24px, var(--toast-lift, 0px), env(safe-area-inset-bottom)); }
.toast { display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 8px 8px 8px 10px; border: 1px solid var(--ring); border-radius: var(--r-pill); background: color-mix(in srgb, var(--surface-3) 88%, transparent); backdrop-filter: blur(22px) saturate(150%); color: var(--ink); box-shadow: var(--hi), var(--amb-lg); font-size: var(--t-sm); pointer-events: auto; animation: spring .5s var(--ease) both; transform-origin: 50% 100%; }
.toast-error { border-color: color-mix(in srgb, var(--err-fill) 45%, var(--ring)); }
.toast-badge { display: grid; width: 32px; height: 32px; flex: none; place-items: center; border-radius: 50%; background: var(--ok-bg); color: var(--ok); }
.toast-error .toast-badge { background: var(--err-bg); color: var(--err); }
.toast-ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75px; stroke-linecap: round; stroke-linejoin: round; }
.toast-text { flex: 1; padding: 2px 0; overflow-wrap: anywhere; }
.toast-close { display: grid; width: 32px; height: 32px; flex: none; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.toast-close:hover { background: var(--hover); color: var(--ink); }
.toast-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5px; stroke-linecap: round; }

@keyframes spring { from { opacity: 0; transform: translateY(8px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes tile-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
/* Rows inside a scroller fade only: a transform would overflow the scroller and flash a scrollbar. */
@keyframes fade-row { from { opacity: 0; } to { opacity: 1; } }
@keyframes sweep { to { transform: translateX(100%); } }
@keyframes target { 0%, 40% { box-shadow: var(--hi), var(--bezel), 0 0 0 2px var(--accent), 0 0 24px var(--accent-soft); } 100% { box-shadow: var(--hi), var(--bezel), var(--amb); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.8); } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .stat-verified, .stat-speed, .stat-cost, .stat-runs, .stat-grid .sk-card { grid-column: span 6; }
  .stat-daily, .stat-mix, .stat-insights, .stat-activity, .stat-grid .skeleton:not(.sk-card) { grid-column: span 12; }
}
@media (max-width: 900px) {
  .topbar { padding-inline: var(--s-4); }
  .feed, .dock, .view { padding-inline: var(--s-4); }
  .stat-speed, .stat-cost { grid-column: span 6; }
}
@media (max-width: 680px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(316px, 88vw); padding: max(26px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); transform: translateX(-104%); transition: transform 480ms var(--ease), visibility 0s linear 480ms; visibility: hidden; }
  .rail::before { inset: 0; border-radius: 0 var(--r-5) var(--r-5) 0; background: color-mix(in srgb, var(--surface) 88%, transparent); }
  .rail-open .rail { transform: translateX(0); visibility: visible; transition: transform 480ms var(--ease), visibility 0s; }
  .rail-open .scrim { position: fixed; z-index: 20; inset: 0; display: block; background: var(--backdrop); backdrop-filter: blur(4px); animation: fade .4s var(--ease) both; }
  .icon-btn.menu-btn, .icon-btn.rail-close { display: inline-grid; }
  .icon-btn.rail-toggle { display: none; }
  .top-brand { display: inline-grid; place-items: center; width: 44px; height: 44px; }
  #allowance-chip { display: none; }
  .feed { padding: 0 max(var(--s-4), env(safe-area-inset-right)) 0 max(var(--s-4), env(safe-area-inset-left)); }
  .view { padding: var(--s-1) max(var(--s-4), env(safe-area-inset-right)) var(--s-7) max(var(--s-4), env(safe-area-inset-left)); }
  .view-inner { padding: 0 6px; }
  .empty { gap: var(--s-5); padding-bottom: max(var(--s-6), env(safe-area-inset-bottom)); }
  .thread { padding-top: var(--s-4); }
  .user-message { margin-bottom: var(--s-4); }
  .user-bubble { max-width: 92%; padding: 10px var(--s-4); font-size: 14px; }
  .user-message > .source-meta { max-width: 92%; }
  .research-prose { font-size: var(--t-md); line-height: 1.65; }
  .turn { margin-bottom: var(--s-6); }
  .market-card { padding: var(--s-4); }
  .market-card-head { display: grid; }
  .page-head { flex-direction: column; align-items: stretch; gap: var(--s-4); }
  .page-head h1 { font-size: 32px; }
  .page-actions { width: 100%; }
  .two-col { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .fact-tiles { grid-template-columns: minmax(0, 1fr); }
  .rail-resizer { display: none; }
  .history { display: none; }
  .setting-row { flex-wrap: wrap; }
  .setting-row .segmented { width: 100%; }
  .setting-row .segmented label { flex: 1; }
  .lib-toolbar { padding: var(--s-3) var(--s-4); }
  .job-head { flex-wrap: wrap; }
  .stat-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .stat-grid > *, .stat-grid .sk-card { grid-column: 1 / -1 !important; grid-row: auto !important; }
  .stat { padding: var(--s-5) var(--s-4) var(--s-4); }
  .card { padding: var(--s-4); }
  .activity { padding: var(--s-4) var(--s-4) var(--s-2); }
  .table-wrap { margin: 0; overflow: visible; }
  table.log, table.log tbody { display: block; }
  table.log thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.log tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2) var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
  table.log tbody tr:last-child { border-bottom: 0; }
  table.log td, table.log td:first-child, table.log td:last-child { display: block; padding: 0; border: 0; }
  table.log td::before { content: attr(data-label); display: block; color: var(--subtle); font-size: 11px; }
  table.log td.q { grid-column: 1 / -1; order: -1; width: auto; max-width: none; }
  table.log td.q::before { display: none; }
  .library-item { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "chk title title" ". pill date" ". act act"; gap: 0 var(--s-3); padding-block: 6px; }
  .library-item .lib-date { justify-self: end; }
  .library-item .lib-actions { justify-self: start; padding: 4px 0 6px; }
  .library-item .pill { justify-self: start; }
  .workspace-list.card-list li:not(.empty-state):not(.skeleton) { padding: var(--s-4); }
  .empty-state { padding: var(--s-6) var(--s-4); }
  .collection-head { flex-direction: column; align-items: flex-start; gap: var(--s-1); padding: var(--s-4) var(--s-4) var(--s-3); }
  .collection-target { max-width: 100%; text-align: left; }
  .collection-metrics { gap: var(--s-1); margin: var(--s-1) var(--s-4) var(--s-3); }
  .collection-metric { padding: var(--s-2) var(--s-3); }
  .collection-metric strong { font-size: 18px; }
  .collection-tabs { padding: 0 var(--s-4); }
  .collection-panel { padding: var(--s-4); }
  .collection-page { padding: var(--s-3); }
  .collection-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collection-contact { grid-template-columns: minmax(0, 1fr); }
  .collection-contact button { grid-column: 1; grid-row: auto; justify-self: start; margin-top: var(--s-2); }
  .sheet-body > header { margin-inline: calc(var(--s-5) * -1); padding-inline: var(--s-5); }
  .sheet-body h2 { font-size: 24px; }
  .p-group { display: none; }
  .rail-collapsed { --rail-width: 256px; }
}
@media (max-width: 430px) {
  .toast { border-radius: var(--r-4); }
}

/* Touch and phones: 44px targets, 16px inputs (no iOS focus zoom), tap feedback that does not depend on hover. */
button, a, summary, label, [role=button], [role=option], input, select, textarea { touch-action: manipulation; }
@media (pointer: coarse), (max-width: 680px) {
  :root { --hit: 44px; }
  input:not([type=checkbox]):not([type=file]):not([type=radio]), textarea, select, .depth-select, .composer textarea, .composer .target-url, .view-inner input, .view-inner textarea, .search-field input[type=search], .palette-input input, .sheet-body input, .sheet-body textarea { font-size: 16px !important; }
  .link-btn, .th-sort, .chip button { min-height: 44px; min-width: 44px; }
  .chip button { width: 44px; height: 44px; margin: -10px -6px -10px 0; }
  .mode-opt { min-height: 56px; }
  .filter-btn { min-height: 44px; }
  .check-row { min-height: 44px; }
  .lib-check, .check-row input { width: 22px; height: 22px; }
.lib-hit { display: grid; width: 44px; height: 44px; margin: 0 0 0 -12px; place-items: center; cursor: pointer; grid-area: chk; }
  .toast-close { width: 44px; height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .nav-item, .history li button, .segmented button, .segmented label, .rail-search { min-height: 44px; }
  .row-link, .tl-title { min-height: 44px; }
  .ghost-btn, .turn-actions .ghost-btn, .export-menu summary, .followup-chip, .solid-btn, .tile-link, .example-chip, .depth-select, .mode-more a { min-height: 44px; }
  .account-card { min-height: 52px; }
  .switch-wrap { min-height: 44px; }
  .switch { width: 48px; height: 28px; }
  .switch::after { width: 22px; height: 22px; }
  .switch:checked::after { transform: translateX(20px); }
  .palette-item { min-height: 52px; }
  .collection-tab { min-height: 48px; }
  .cite-pop { display: none; }
  /* tap feedback: pressed states instead of hover-only affordances */
  .nav-item:active, .history li button:active, .library-item:active, .tl-item:active, .palette-item:active, .mode-opt:active, .menu button:active, .filter-btn:active, .row-link:active { background: var(--hover); }
}
@media (hover: none) {
  .rail-search kbd { display: none; }
  .solid-btn:hover:not(:disabled) .btn-island { transform: none; }
}

/* ---------- phones: a first-class layout ---------- */
.mode-scrim { position: fixed; z-index: 59; inset: 0; background: var(--backdrop); backdrop-filter: blur(6px); animation: fade .35s var(--ease) backwards; }
.sheet-grip { display: none; }
.mode-panel-head { touch-action: none; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@media (max-width: 680px) {
  body { position: fixed; inset: 0; width: 100%; height: auto; }   /* no page scroll, no rubber band, no layout shift behind the drawer */
  .feed, .view { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .rail, .rail * { touch-action: pan-y; }
  .edge-swipe { position: fixed; z-index: 15; top: var(--topbar-h); bottom: 0; left: 0; display: block; width: 16px; touch-action: pan-y; }
  .rail-open .edge-swipe, .kb .edge-swipe { display: none; }
  .topbar { --topbar-h: 56px; height: var(--topbar-h); flex-basis: var(--topbar-h); gap: 2px; padding: 0 max(8px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(20px) saturate(150%); }
  .topbar-right { margin-left: 0; gap: 0; }
  /* Phones: New research is a round + that matches the header's other icon buttons. */
  .new-research { width: 40px; height: 40px; min-height: 40px; margin-left: auto; padding: 0; border-radius: 50%; }
  .new-research .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .new-research .btn-island { width: 100%; height: 100%; margin: 0; background: transparent; }
  .topbar .icon-btn { width: 40px; height: 40px; }
  #runs-pill { width: 28px; height: 28px; min-height: 0; margin-right: 4px; padding: 0; justify-content: center; }
  #runs-pill #runs-pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #runs-pill .dot { width: 9px; height: 9px; }
  .empty { padding-top: 0; }
  .feed { padding-top: var(--s-2); }
  .empty h1 { font-size: clamp(32px, 9.6vw, 40px); }
  .composer { border-radius: 28px; padding: 5px; }
  .composer-card { border-radius: 23px; }
  .dock { padding: 0 max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .stage[data-thread][data-surface=research] .dock { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  /* keyboard open: only the composer and the newest message stay on screen */
  .kb .welcome-copy, .kb .research-notice { display: none; }
  .kb .empty { gap: 0; padding-bottom: 8px; }
  .kb .dock { padding-bottom: 8px; }
  /* mode picker: a bottom sheet with a grip, big rows and a scrim */
  .mode-panel { z-index: 60; }
  .mode-panel[data-sheet] { top: auto; right: 0; bottom: 0; left: 0; width: auto; padding: 6px 6px 0; border-bottom: 0; border-radius: 32px 32px 0 0; transform-origin: 50% 100%; animation: sheet-up .55s var(--ease) backwards; }
  .mode-panel[data-sheet] .mode-panel-core { max-height: calc(var(--mh) - 6px); padding: 4px 8px max(12px, env(safe-area-inset-bottom)); border-radius: 27px 27px 0 0; }
  .mode-panel[data-sheet] .sheet-grip { display: block; width: 44px; height: 5px; margin: 6px auto 8px; border-radius: 5px; background: var(--line-3); opacity: .7; }
  .mode-panel[data-sheet] .mode-panel-head { margin: 0 -8px; padding: 0 8px 4px; }
  .mode-panel[data-sheet] .mode-panel-title { position: static; width: auto; height: auto; clip: auto; padding: 4px 12px 8px; color: var(--subtle); font-size: 11px; font-weight: 560; letter-spacing: .16em; text-transform: uppercase; }
  .mode-panel[data-sheet] .mode-opt { min-height: 52px; padding: 0 14px; font-size: var(--t-md); }
  .mode-panel[data-sheet] .mode-more { margin-top: 6px; }
  /* pages */
  .view { padding-top: var(--s-2); }
  .page-head { margin: var(--s-3) 0 var(--s-5); }
  .page-head h1 { font-size: 34px; }
  .page-sub { font-size: 14px; }
  .page-actions .solid-btn { width: 100%; justify-content: space-between; padding-left: 22px; }
  .lib-meta-row { flex-wrap: wrap; }
  .two-col { gap: var(--s-5); }
  .form-actions .solid-btn { flex: 1 1 auto; justify-content: space-between; }
  .job-actions > * { flex: 0 0 auto; }
  .workspace-list .confirm-wrap { width: 100%; justify-content: flex-start; }
  /* dialogs: bottom sheets with a sticky header and footer */
  .sheet { width: 100%; max-width: 100%; max-height: 94dvh; margin: auto 0 0; padding: 6px 6px 0; border-bottom: 0; border-radius: 34px 34px 0 0; }
  .sheet[open] { animation: sheet-up .55s var(--ease) backwards; }
  .sheet-body { max-height: calc(94dvh - 6px); padding: 0 var(--s-5) 0; border-radius: 29px 29px 0 0; }
  .sheet-body > header { padding-top: var(--s-6); }
  .sheet-body > header::before { content: ""; position: absolute; top: 9px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 5px; background: var(--line-3); opacity: .7; }
  .sheet-body:not(:has(footer)) { padding-bottom: max(var(--s-5), env(safe-area-inset-bottom)); }
  .sheet-body footer { position: sticky; bottom: 0; z-index: 2; margin: var(--s-2) calc(var(--s-5) * -1) 0; padding: 12px var(--s-5) max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--pop); }
  .sheet-body footer .solid-btn, .sheet-body footer .ghost-btn { flex: 1 1 auto; }
  dialog.palette { width: calc(100vw - 16px); margin: max(10px, env(safe-area-inset-top)) auto auto; }
  #palette-list { max-height: calc(var(--app-h, 100dvh) - 170px); }
  /* Phones: under the header, never over the chat box or the keyboard. */
  #toast-region { top: calc(64px + env(safe-area-inset-top)); bottom: auto; right: 16px; width: calc(100vw - 32px); justify-items: stretch; }
  #toast-region .toast { animation-name: toast-drop; transform-origin: 50% 0; }
  #toast-region .toast.is-leaving { animation-name: toast-lift !important; }
  @keyframes toast-drop { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }
  @keyframes toast-lift { to { opacity: 0; transform: translateY(-14px) scale(.98); } }
}
/* short landscape screens */
@media (max-height: 520px) and (pointer: coarse) {
  :root { --topbar-h: 48px; }
  .eyebrow { display: none; }
  .empty h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skeleton::after, .research-status[data-busy=true]::after { display: none; }
  .evidence-card.is-target { animation: none; outline: 2px solid var(--focus); outline-offset: 2px; }
}
:root[data-motion=reduce] *, :root[data-motion=reduce] *::before, :root[data-motion=reduce] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
:root[data-motion=reduce] .skeleton::after, :root[data-motion=reduce] .research-status[data-busy=true]::after { display: none; }
:root[data-motion=reduce] .evidence-card.is-target { animation: none; outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- phones: minimal home with the message box in thumb reach ---------- */
@media (max-width: 680px) {
  .empty { justify-content: flex-start; gap: 0; height: 100%; padding: 0 0 max(4px, env(safe-area-inset-bottom)); }
  .welcome-copy { flex: 1; align-content: center; padding: var(--s-6) var(--s-2); }
  .empty h1 { font-size: clamp(26px, 7.4vw, 32px); }
  .composer-slot { margin-top: auto; max-width: none; }
  .composer-slot::before { display: none; }
  .composer { border-radius: 26px; padding: 5px; }
  .composer-glow { border-radius: 29px; }
  .composer-card { padding: 8px 8px 8px 12px; border-radius: 21px; }
  .composer textarea { min-height: 44px; padding: 8px 2px 2px; font-size: 16px; }
  .composer-row { margin-left: -6px; }
  .tool-btn, .decide, .tab-btn { width: 42px; height: 42px; }
  .mode-btn { height: 44px; padding: 0 10px; }
  .mode-btn-name { max-width: 34vw; }
  .target-field { padding: 0 10px; }
  .composer .target-url { height: 42px; font-size: 16px; }
  .url-hint { display: none; }
  .target-field[data-state=bad] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--err-fill) 18%, transparent); }
  .ctx-x { width: 36px; height: 36px; }
  .slash-menu { top: auto; bottom: calc(100% + 10px); width: 100%; }
  .slash-opt { min-height: 48px; }
  .user-bubble { max-width: 85%; }
  .user-label { max-width: 85%; }
  .source-strip { flex-wrap: nowrap; overflow-x: auto; margin-inline: -4px; padding: 0 4px 2px; scrollbar-width: none; }
  .source-strip::-webkit-scrollbar { display: none; }
  .kb .empty { padding-bottom: 6px; }
}
@media (max-width: 380px) {
  .run-step:not([data-state=active]) { display: none; }
}

/* ---------- desktop: every page fits the screen, and long lists scroll inside their own panel ----------
   Phones and short windows keep the stacked, scrolling pages above. */
@media (min-width: 681px) and (min-height: 640px) {
  .view { display: flex; flex-direction: column; overflow: hidden; padding-top: var(--s-2); padding-bottom: var(--s-5); }
  .view-inner { display: flex; flex: 1; flex-direction: column; min-height: 0; width: min(100%, 1180px); }
  .view-inner > * { flex: none; }
  .page-head { margin: var(--s-4) 0 var(--s-5); }
  .page-head h1 { font-size: 30px; line-height: 1.1; }
  .page-sub { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  /* Scrolling panels keep room for each card's outer ring. */
  #research-list, #investigations-list, #batches-list, .two-col .item-list { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }

  /* overview: KPIs, charts and the log on one screen */
  .overview-content { display: flex; flex: 1; flex-direction: column; min-height: 0; }
  .overview-content > .empty-card { flex: none; }
  .stat-grid { flex: 1; min-height: 0; margin: 0; gap: var(--s-4); grid-template-rows: auto minmax(0, .85fr) minmax(0, 1.3fr); }
  .stat-verified, .stat-speed, .stat-cost, .stat-runs, .stat-grid .sk-card { grid-column: span 3; grid-row: 1; }
  .stat-daily, .stat-grid .sk-daily { grid-column: 1 / 9; grid-row: 2; }
  .stat-mix, .stat-grid .sk-mix { grid-column: 9 / 13; grid-row: 2; }
  .stat-insights, .stat-grid .sk-insights { grid-column: 1 / 6; grid-row: 3; }
  .stat-activity, .stat-grid .sk-activity { grid-column: 6 / 13; grid-row: 3; }
  .stat-grid .skeleton { min-height: 0; }
  .stat-grid .sk-card { height: 150px; }
  .stat-grid > .card { min-height: 0; padding: var(--s-4) var(--s-5); }
  /* KPI cards: the figure and its caption share one line */
  .stat { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 10px; overflow: hidden; }
  .stat > .stat-title, .stat > .stat-visual, .stat > .stat-foot { grid-column: 1 / -1; }
  .stat > .stat-visual { grid-row: 3; align-self: safe end; }
  .stat > .stat-foot { grid-row: 4; }
  .stat-value { margin-top: var(--s-2) !important; font-size: 34px; }
  .stat-verified .stat-value { font-size: 40px; }
  .stat-sub { align-self: end; min-height: 0; margin: 0 0 5px !important; overflow: hidden; line-height: 1.35; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .stat-visual { margin: var(--s-3) 0 var(--s-2); }
  .stat-verified .stat-visual { margin-top: var(--s-3); }
  .stat-runs .chip-list { gap: 4px; }
  .stat-runs .stat-chip { min-height: 0; padding: 1px 8px; font-size: 11px; }
  .stat-speed .stat-visual { flex: none; }
  .stat-speed .spark { flex: none; height: 30px; min-height: 0; }
  .spark-cap { display: none; }
  .stat-foot { overflow: hidden; padding-top: var(--s-2); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
  .legend { gap: 2px var(--s-3); margin-top: var(--s-2); font-size: 11px; }
  .stat-daily, .stat-insights, .stat-activity { display: flex; flex-direction: column; overflow: hidden; }
  .stat-grid .section-head { flex: none; margin-bottom: var(--s-3); }
  .stat-daily .bars { flex: 1; height: auto; min-height: 0; }
  .insight-list { flex: 1; min-height: 0; margin-bottom: var(--s-2); overflow: auto; }
  .insight-list li { padding: var(--s-2) 0; }
  .stat-insights > .hint { flex: none; font-size: 11px; }
  .stat-activity .table-wrap { flex: 1; min-height: 0; overflow: auto; margin-bottom: calc(var(--s-4) * -1); }
  .stat-activity thead th { position: sticky; z-index: 1; top: 0; background: var(--surface); }
  .stat-activity table.log td { padding-block: 6px; white-space: nowrap; }
  .stat-activity table.log th:nth-child(5), .stat-activity table.log td:nth-child(5),
  .stat-activity table.log th:nth-child(6), .stat-activity table.log td:nth-child(6) { display: none; }
  .section-meta { display: inline-flex; align-items: baseline; gap: var(--s-2); }

  /* library: toolbar in one band, the list scrolls inside its card */
  .lib-toolbar { grid-template-columns: minmax(220px, 1fr) auto; align-items: center; gap: var(--s-3) var(--s-4); margin-bottom: var(--s-4); padding: var(--s-3) var(--s-4); }
  .lib-toolbar .lib-meta-row { grid-column: 1 / -1; }
  .bulkbar { margin-bottom: var(--s-3); }
  #research-list { flex: 1 1 auto; }
  .workspace-list.library-list li:not(.empty-state):not(.skeleton) { min-height: 52px; }

  /* knowledge: two columns, each a compact form above its own scrolling list */
  .two-col { flex: 1; min-height: 0; align-items: stretch; gap: var(--s-5); }
  .two-col > .card { display: flex; flex-direction: column; min-height: 0; padding: var(--s-4) var(--s-5); }
  .two-col .card-head { flex: none; margin-bottom: var(--s-3); padding-bottom: var(--s-3); }
  .two-col form { flex: none; }
  .two-col .item-list { flex: 1; margin: var(--s-3) -8px 0; padding: 0 8px; border-top: 1px solid var(--line); }
  .two-col .item-list li:not(.empty-state):not(.skeleton) { padding: 8px 0; }
  .two-col .field { gap: 4px; margin-bottom: var(--s-3); }
  .two-col .field-help { position: absolute; right: 0; top: 0; }
  .two-col .field { position: relative; }
  .two-col textarea { min-height: 64px; max-height: 120px; }
  #note-form, #document-form { grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s-3); align-items: end; }
  #note-form > .field:not(:has(.dropzone)) { grid-column: 1 / -1; }
  #note-form > .field:has(.dropzone), #document-form > .field { margin-bottom: 0; }
  .two-col .form-actions { margin: 0; }
  .two-col .dropzone { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "ico main" "ico sub"; justify-items: start; column-gap: 12px; row-gap: 0; padding: 10px 14px; text-align: left; }
  .two-col .dz-ico { grid-area: ico; width: 34px; height: 34px; margin: 0; }
  .two-col .dz-main { grid-area: main; }
  .two-col .dz-sub { grid-area: sub; }
  .two-col .file-row { grid-column: 1 / -1; }

  /* monitors: a compact grid of cards that scrolls inside the page */
  #investigations-list > .empty-state, #batches-list > .empty-state { grid-column: 1 / -1; padding-block: var(--s-8); }
  .two-col .item-list:has(> .empty-state) { display: flex; flex-direction: column; border-top: 0; }
  #investigations-list { display: grid; flex: 1 1 auto; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); align-content: start; gap: var(--s-4); margin: -8px; padding: 8px; }
  .workspace-list.card-list > li:not(.empty-state):not(.skeleton) { margin: 0; padding: var(--s-4); }
  #investigations-list .job-summary { margin-top: var(--s-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #investigations-list .job-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px var(--s-3); margin-top: var(--s-3); padding-top: var(--s-3); }
  .job-actions { gap: 6px; margin-top: var(--s-3); }
  .job-actions .ghost-btn, .job-actions select, .job-actions .depth-select { min-height: 34px; padding: 4px 12px; font-size: var(--t-xs); }
  .job-actions .mode-select-wrap .depth-select { padding-right: 30px; }
  .job-head .item-ico { width: 36px; height: 36px; }
  .job-title { font-size: var(--t-md); }
  .card-list li.empty-state { margin: 0; }

  /* batches: the form on the left, the queue on the right */
  .batch-layout { display: grid; flex: 1; min-height: 0; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); align-items: start; gap: var(--s-5); }
  .batch-layout > .form-card { margin: 0; padding: var(--s-4) var(--s-5); }
  .batch-layout .card-head { margin-bottom: var(--s-3); padding-bottom: var(--s-3); }
  .batch-layout .field { margin-bottom: var(--s-3); }
  #batches-list { display: grid; align-content: start; gap: var(--s-4); max-height: 100%; margin: -8px; padding: 8px; }
  #batches-list .batch-rows { max-height: 168px; overflow: auto; }
}
@media (min-width: 681px) and (min-height: 640px) and (max-height: 820px) {
  /* Laptop heights: drop secondary lines before anything has to scroll. */
  .page-head { margin: var(--s-3) 0 var(--s-4); }
  .page-head h1 { font-size: 26px; }
  .stat-foot, .stat-insights > .hint { display: none; }
  .stat-grid { gap: var(--s-3); }
  .stat-grid > .card { padding: var(--s-3) var(--s-4); }
  .stat-value { font-size: 30px; }
  .stat-verified .stat-value { font-size: 34px; }
  .legend { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
}

/* Account: sign-in providers, plan and credits, team, API keys */
.provider-row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-block: var(--s-3); }
.provider-btn { flex: 1 1 180px; justify-content: center; text-decoration: none; }
.provider-or { text-align: center; margin-block: var(--s-2); }
.credit-meter { height: 6px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; margin-block: var(--s-3); box-shadow: inset 0 0 0 1px var(--line); }
.credit-meter span { display: block; height: 100%; background: var(--ink); transform-origin: 0 50%; transform: scaleX(0); transition: transform .6s var(--ease); }
.lot-list { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: grid; gap: 2px; }
.lot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.lot > :first-child { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.lot .mono, .key-reveal code { font-family: 'Geist Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.topup-row { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); }
.key-reveal { padding: var(--s-3); border: 1px solid var(--accent); border-radius: var(--r-md, 12px); background: var(--accent-soft); font-size: var(--t-sm); overflow-wrap: anywhere; }
.key-reveal code { user-select: all; }
a.solid-btn, a.ghost-btn { text-decoration: none; display: inline-flex; align-items: center; }
