/* Rolldesk. World: the printed electoral roll and the violet indelible ink of polling day.
   Light ground for a desk in daylight, with every neutral tinted from the ink; the ink owns the rail and every action. */

:root {
  --ink: oklch(0.27 0.09 302);
  --ink-2: oklch(0.34 0.11 302);
  --ink-3: oklch(0.42 0.13 302);
  --ink-fg: oklch(0.96 0.015 302);
  --ink-muted: oklch(0.8 0.05 302);
  --accent: oklch(0.46 0.17 302);
  --accent-hover: oklch(0.4 0.17 302);
  --accent-weak: oklch(0.945 0.03 302);
  --accent-line: oklch(0.85 0.07 302);
  --paper: oklch(0.972 0.008 302);
  --surface: oklch(0.995 0.003 302);
  --panel: oklch(0.946 0.013 302);
  --line: oklch(0.885 0.016 302);
  --line-strong: oklch(0.78 0.022 302);
  --text: oklch(0.25 0.025 300);
  --text-2: oklch(0.43 0.025 300);
  --text-3: oklch(0.52 0.022 300);
  --stamp: oklch(0.53 0.2 27);
  --stamp-weak: oklch(0.955 0.028 27);
  --stamp-line: oklch(0.82 0.09 27);
  --amber: oklch(0.56 0.13 70);
  --amber-weak: oklch(0.955 0.045 85);
  --amber-line: oklch(0.83 0.1 80);
  --ok: oklch(0.5 0.11 160);
  --ok-weak: oklch(0.95 0.035 160);
  --radius: 6px;
  --shadow: 0 1px 2px oklch(0.25 0.03 300 / 0.06), 0 6px 20px -8px oklch(0.25 0.06 300 / 0.18);
  --font: "Anek", ui-sans-serif, system-ui, "Segoe UI", "Noto Sans", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scrollbar-color: var(--line-strong) transparent; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font: 400 1rem/1.5 var(--font); font-stretch: 100%; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: oklch(0.82 0.1 302); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, h4, p, dl, dd, ul, ol, figure { margin: 0; }
h1, h2, h3 { font-stretch: 112%; text-wrap: balance; letter-spacing: -0.012em; }
h1 { font-size: 2.25rem; line-height: 1.1; font-weight: 640; }
h2 { font-size: 1.5rem; line-height: 1.2; font-weight: 620; }
h3 { font-size: 1.125rem; line-height: 1.3; font-weight: 620; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
code, .mono { font-family: var(--mono); font-size: 0.875em; font-variant-ligatures: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
.shell.chat-open { grid-template-columns: 236px minmax(0, 1fr) clamp(380px, 34vw, 500px); }
main { padding: 44px clamp(20px, 4vw, 60px) 120px; min-width: 0; }
main:focus { outline: none; }
.page { max-width: 1120px; margin: 0 auto; display: grid; gap: 40px; }
.page > header { display: grid; gap: 12px; }
.lede { font-size: 1.1875rem; line-height: 1.5; color: var(--text-2); max-width: 68ch; }
.prose { max-width: 70ch; color: var(--text-2); }
.prose strong, .lede strong { color: var(--text); font-weight: 600; }
.section { display: grid; gap: 18px; }
.section > .section-head { display: grid; gap: 6px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.875rem; color: var(--text-3); }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs span[aria-hidden] { color: var(--line-strong); }
.muted { color: var(--text-3); }
.small { font-size: 0.875rem; }
.code-tag { font: 500 0.75rem/1 var(--mono); color: var(--text-3); background: var(--panel); border-radius: 3px; padding: 3px 5px; white-space: nowrap; }

/* Single-column grids must not grow to fit a wide child (tables, charts); let the child scroll instead. */
.page, .section, .case-detail, .bench-main, .msg-bot, .md, .working-body, .step-body, .chat-intro, .split, .scan, .chart-card { grid-template-columns: minmax(0, 1fr); }

/* ------------------------------------------------------------ rail */
.rail {
  position: sticky; top: 0; height: 100dvh; background: var(--ink); color: var(--ink-fg);
  display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 16px; overflow-y: auto;
  scrollbar-color: var(--ink-3) transparent;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--ink-fg); text-decoration: none; font: 660 1.375rem/1 var(--font); font-stretch: 118%; letter-spacing: -0.02em; }
.brand:hover { color: #fff; }
.brand-mark { width: 9px; height: 26px; border-radius: 5px 5px 3px 3px; background: linear-gradient(oklch(0.7 0.17 302), oklch(0.52 0.2 302)); transform: rotate(8deg); }
.ask-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: var(--radius);
  background: var(--ink-fg); color: var(--ink); font-weight: 600; cursor: pointer; text-align: left;
  transition: background 0.16s var(--ease), transform 0.16s var(--ease);
}
.ask-btn:hover { background: #fff; }
.ask-btn:active { transform: translateY(1px); }
.ask-btn[aria-pressed="true"] { background: oklch(0.86 0.08 302); }
.ask-btn kbd { margin-left: auto; font: 500 0.6875rem/1 var(--mono); color: var(--ink-3); border: 1px solid oklch(0.8 0.06 302); border-radius: 4px; padding: 3px 5px; }
.nav { display: grid; gap: 2px; }
.nav-label { padding: 14px 10px 6px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius);
  color: var(--ink-fg); text-decoration: none; font-weight: 500; opacity: 0.86;
  transition: background 0.15s var(--ease), opacity 0.15s var(--ease);
}
.nav a:hover { background: var(--ink-2); opacity: 1; }
.nav a[aria-current="page"] { background: var(--ink-3); opacity: 1; font-weight: 600; }
.nav svg, .ask-btn svg { width: 18px; height: 18px; flex: none; }
.rail-foot { margin-top: auto; display: grid; gap: 8px; padding: 12px 10px 0; border-top: 1px solid var(--ink-2); font-size: 0.8125rem; color: var(--ink-muted); }
.rail-foot button { background: none; border: 0; padding: 0; color: var(--ink-fg); text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; font-size: inherit; }
.rail-foot .who { color: var(--ink-fg); font-weight: 600; font-size: 0.9375rem; }

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 560; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.btn:hover { background: var(--panel); border-color: var(--text-3); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.quiet { border-color: transparent; background: none; color: var(--accent); padding-inline: 8px; }
.btn.quiet:hover { background: var(--accent-weak); }
.btn.sm { padding: 5px 10px; font-size: 0.875rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 15px; height: 15px; border-radius: 50%; border: 2px solid oklch(1 0 0 / 0.5); border-top-color: #fff; animation: spin 0.7s linear infinite; }
.btn:not(.primary).busy::after { border-color: var(--line-strong); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(1turn); } }

.field { display: grid; gap: 5px; font-size: 0.875rem; color: var(--text-2); font-weight: 560; }
.input, select.input, textarea.input {
  padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--text); font-weight: 400; font-size: 1rem; min-width: 0; caret-color: var(--accent);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
select.input { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23554a6b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: end; padding: 14px 16px; background: var(--panel); border-radius: var(--radius); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9375rem; color: var(--text); font-weight: 500; padding: 8px 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 12px; font-size: 0.875rem; font-weight: 560; color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button:hover { background: var(--panel); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--accent-line); background: var(--surface); color: var(--ink-3); border-radius: 999px; padding: 6px 13px; font-size: 0.9375rem; cursor: pointer; text-align: left; transition: background 0.15s var(--ease), border-color 0.15s var(--ease); }
.chip:hover { background: var(--accent-weak); border-color: var(--accent); }

/* ------------------------------------------------------------ notes, tags, states */
.note { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--amber-weak); border: 1px solid var(--amber-line); color: oklch(0.34 0.07 70); font-size: 0.9375rem; }
.note svg { width: 18px; height: 18px; margin-top: 2px; color: var(--amber); }
.note.info { background: var(--accent-weak); border-color: var(--accent-line); color: var(--ink-2); }
.note.info svg { color: var(--accent); }
.note.bad { background: var(--stamp-weak); border-color: var(--stamp-line); color: oklch(0.36 0.12 27); }
.note.bad svg { color: var(--stamp); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 4px; font-size: 0.8125rem; font-weight: 560; background: var(--panel); color: var(--text-2); white-space: nowrap; }
.tag.flag { background: var(--stamp-weak); color: oklch(0.42 0.16 27); }
.tag.warn { background: var(--amber-weak); color: oklch(0.4 0.1 70); }
.tag.ok { background: var(--ok-weak); color: oklch(0.36 0.09 160); }
.tag.ink { background: var(--accent-weak); color: var(--ink-3); }
.empty { padding: 36px 24px; text-align: center; color: var(--text-2); background: var(--panel); border-radius: var(--radius); display: grid; gap: 8px; justify-items: center; }
.empty strong { color: var(--text); font-size: 1.0625rem; }
.skel { border-radius: var(--radius); background: linear-gradient(90deg, var(--panel) 25%, oklch(0.975 0.008 302) 45%, var(--panel) 65%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; min-height: 18px; }
.skel.block { height: 180px; }
.skel.row { height: 44px; margin-bottom: 8px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* "How this was worked out": the query behind any view */
.working { border-top: 1px solid var(--line); padding-top: 10px; font-size: 0.875rem; }
.working > summary { cursor: pointer; color: var(--text-2); font-weight: 560; list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; }
.working > summary::-webkit-details-marker { display: none; }
.working > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform 0.18s var(--ease); margin-right: 3px; }
.working[open] > summary::before { transform: rotate(45deg); }
.working > summary:hover { color: var(--accent); }
.working-body { display: grid; gap: 10px; padding: 10px 0 2px; }
.sqlcode { margin: 0; padding: 12px 14px; background: var(--ink); color: oklch(0.93 0.03 302); border-radius: var(--radius); font: 400 0.8125rem/1.55 var(--mono); overflow-x: auto; white-space: pre; tab-size: 2; }

/* ------------------------------------------------------------ numbers */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 2px solid var(--text); }
.figure { padding: 14px 18px 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 2px; align-content: start; }
.figure b { font-size: 1.75rem; line-height: 1.1; font-weight: 640; font-stretch: 108%; letter-spacing: -0.02em; }
.figure span { font-size: 0.9375rem; color: var(--text-2); }
.figure small { font-size: 0.8125rem; color: var(--text-3); }

/* ------------------------------------------------------------ tables */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: 70vh; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9375rem; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--panel); text-align: left; font-weight: 600; font-size: 0.8125rem; font-stretch: 92%; letter-spacing: 0.01em; color: var(--text-2); padding: 9px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.tbl th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.tbl th button:hover { color: var(--accent); }
.tbl th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tbl th[aria-sort="ascending"] button::after { content: "↑"; }
.tbl th[aria-sort="descending"] button::after { content: "↓"; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl td.mono { font-family: var(--mono); font-size: 0.8125rem; white-space: nowrap; }
.tbl tbody tr.link { cursor: pointer; }
.tbl tbody tr.link:hover td { background: var(--accent-weak); }
.tbl tbody tr.link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl-foot { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding-top: 8px; font-size: 0.875rem; color: var(--text-3); }
.bar { display: inline-block; height: 8px; border-radius: 2px; background: var(--accent); vertical-align: middle; min-width: 2px; }
.bar-track { display: inline-block; width: 84px; height: 8px; border-radius: 2px; background: var(--panel); vertical-align: middle; margin-right: 8px; overflow: hidden; line-height: 0; }

/* ------------------------------------------------------------ the roll box (signature) */
.rollgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; align-items: start; }
.rollbox { position: relative; background: #fff; border: 1.5px solid var(--text); display: grid; grid-template-rows: auto 1fr auto; font-size: 0.9375rem; min-width: 0; }
.rb-head { display: flex; align-items: stretch; border-bottom: 1.5px solid var(--text); min-height: 30px; }
.rb-serial { display: grid; place-items: center; min-width: 46px; padding: 0 8px; border-right: 1.5px solid var(--text); font-weight: 600; }
.rb-epic { margin-left: auto; padding: 5px 10px; font: 600 0.875rem/1.4 var(--mono); letter-spacing: 0.01em; text-decoration: none; color: var(--text); }
a.rb-epic:hover { color: var(--accent); text-decoration: underline; }
.rb-body { padding: 8px 10px 9px; display: grid; gap: 2px; align-content: start; }
.rb-line { display: grid; grid-template-columns: 76px 1fr; gap: 6px; align-items: baseline; }
.rb-line dt { font-size: 0.8125rem; color: var(--text-3); }
.rb-line dd { font-weight: 560; overflow-wrap: anywhere; }
.rb-line.name dd { font-size: 1.0625rem; font-weight: 640; }
.rb-foot { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; justify-content: space-between; padding: 5px 6px 5px 10px; background: var(--panel); border-top: 1px solid var(--line-strong); font-size: 0.8125rem; color: var(--text-2); }
.rb-foot a { color: var(--text-2); }
.rb-stamp { position: absolute; right: 8px; top: 40px; transform: rotate(-9deg); border: 2px solid var(--stamp); color: var(--stamp); padding: 2px 8px 1px; font: 700 0.75rem/1.25 var(--font); font-stretch: 118%; letter-spacing: 0.1em; text-transform: uppercase; text-align: center; border-radius: 3px; background: oklch(1 0 0 / 0.82); pointer-events: none; }
.rb-stamp small { display: block; font-size: 0.625rem; letter-spacing: 0.06em; font-weight: 600; }
.rollbox.gone .rb-body { color: var(--text-2); }
.rollbox.unclean .rb-head { background: repeating-linear-gradient(-45deg, transparent 0 6px, var(--amber-weak) 6px 12px); }
.rb-scan { grid-column: 1 / -1; border-top: 1px solid var(--line-strong); background: var(--panel); padding: 8px; }
.rb-scan img, .scan img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line-strong); background: #fff; }
.scan { display: grid; gap: 6px; }
.scan figcaption { font-size: 0.8125rem; color: var(--text-2); }
.scan .skel { height: 150px; }
.rollbox.mini .rb-line { grid-template-columns: 1fr; }
.rollbox.mini .rb-line dt { display: none; }

/* annotated anatomy on the start page */
.anatomy { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 28px 36px; align-items: start; }
.anatomy ol { list-style: none; padding: 0; display: grid; gap: 12px; counter-reset: a; }
.anatomy li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; counter-increment: a; }
.anatomy li::before { content: counter(a); width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.8125rem; font-weight: 600; display: grid; place-items: center; margin-top: 1px; }
.anatomy li b { font-weight: 620; }
.anatomy li span { color: var(--text-2); display: block; }
.pin { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font: 600 0.6875rem/1 var(--font); margin-right: 6px; vertical-align: 1px; flex: none; }

/* hierarchy ladder */
.ladder { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.ladder > div { padding: 16px 18px; display: grid; gap: 3px; align-content: start; position: relative; }
.ladder > div + div { border-left: 1px solid var(--line); }
.ladder > div + div::before { content: ""; position: absolute; left: -7px; top: 26px; width: 12px; height: 12px; background: var(--surface); border-top: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); transform: rotate(45deg); }
.ladder b { font-size: 1.5rem; font-weight: 640; line-height: 1.15; font-stretch: 108%; }
.ladder strong { font-weight: 620; }
.ladder span { font-size: 0.875rem; color: var(--text-2); }

/* ------------------------------------------------------------ checks list */
.checks { display: grid; border-top: 2px solid var(--text); }
.check-row { display: grid; grid-template-columns: minmax(0, 1fr) 170px 28px; gap: 6px 24px; align-items: center; padding: 16px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; transition: background 0.15s var(--ease); }
.check-row:hover { background: var(--accent-weak); color: inherit; }
.check-row h3 { color: var(--text); }
.check-row:hover h3 { color: var(--accent-hover); }
.check-row p { color: var(--text-2); font-size: 0.9375rem; max-width: 68ch; }
.check-row .count { text-align: right; display: grid; gap: 1px; }
.check-row .count b { font-size: 1.5rem; font-weight: 640; line-height: 1.1; color: var(--stamp); font-stretch: 108%; }
.check-row .count span { font-size: 0.8125rem; color: var(--text-3); }
.check-row > svg { width: 18px; height: 18px; color: var(--text-3); }
.check-row .where { font-size: 0.8125rem; color: var(--text-3); margin-top: 4px; }

/* ------------------------------------------------------------ coverage register */
.register { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.register table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
.register th, .register td { border: 1px solid var(--line); padding: 0; }
.register thead th { padding: 8px 6px; font-weight: 600; font-size: 0.75rem; font-stretch: 88%; color: var(--text-2); background: var(--panel); vertical-align: bottom; line-height: 1.25; min-width: 62px; }
.register tbody th { text-align: left; padding: 6px 12px; font-weight: 560; white-space: nowrap; background: var(--surface); position: sticky; left: 0; z-index: 1; }
.register tbody th a { color: var(--text); text-decoration: none; }
.register tbody th a:hover { color: var(--accent); text-decoration: underline; }
.register td a, .register td span { display: grid; place-items: center; height: 34px; min-width: 62px; font-size: 0.8125rem; text-decoration: none; }
.register td a { color: var(--ink); background: color-mix(in srgb, var(--accent) calc(8% + var(--fill) * 34%), var(--surface)); }
.register td a.full { color: #fff; background: var(--accent); font-weight: 600; }
.register td a:hover { outline: 2px solid var(--ink); outline-offset: -2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.8125rem; color: var(--text-2); align-items: center; }
.legend i { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--line); vertical-align: -2px; margin-right: 6px; }

/* ------------------------------------------------------------ ask box (start page) */
.askbox { display: grid; gap: 12px; padding: 20px; background: var(--ink); border-radius: 10px; color: var(--ink-fg); }
.askbox label { font-weight: 620; font-size: 1.125rem; font-stretch: 108%; }
.askbox form { display: flex; gap: 8px; }
.askbox input { flex: 1; padding: 12px 14px; border-radius: var(--radius); border: 1px solid transparent; background: #fff; color: var(--text); font-size: 1.0625rem; min-width: 0; caret-color: var(--accent); }
.askbox input:focus { outline: 3px solid oklch(0.72 0.14 302); outline-offset: 0; }
.askbox .btn.primary { background: oklch(0.72 0.15 302); border-color: transparent; color: var(--ink); }
.askbox .btn.primary:hover { background: oklch(0.8 0.12 302); color: var(--ink); }
.askbox .chip { background: var(--ink-2); border-color: var(--ink-3); color: var(--ink-fg); }
.askbox .chip:hover { background: var(--ink-3); border-color: var(--ink-muted); }

/* ------------------------------------------------------------ cases */
.explain { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px 32px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.explain h3 { font-size: 0.9375rem; margin-bottom: 4px; }
.explain p, .explain li { color: var(--text-2); font-size: 0.9375rem; }
.explain ul { padding-left: 18px; display: grid; gap: 4px; }
.cases { display: grid; border-top: 2px solid var(--text); }
.case { border-bottom: 1px solid var(--line); }
.case > button { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) auto 20px; gap: 6px 20px; align-items: center; width: 100%; padding: 12px 6px; }
.case > button:hover { background: var(--accent-weak); }
.case > button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.case > button > svg { width: 16px; height: 16px; color: var(--text-3); transition: transform 0.2s var(--ease); }
.case.open > button > svg { transform: rotate(90deg); }
.case.open > button { background: var(--accent-weak); }
.case-where { font-weight: 620; display: grid; gap: 1px; }
.case-where small { font-weight: 400; color: var(--text-3); font-size: 0.8125rem; }
.case-what { color: var(--text-2); font-size: 0.9375rem; }
.case-what b { color: var(--text); font-weight: 620; }
.case-detail { padding: 6px 6px 22px; display: grid; gap: 18px; }
.case-detail .say { font-size: 1.0625rem; max-width: 72ch; }
.case-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.meter { display: inline-grid; grid-template-columns: 64px auto; gap: 8px; align-items: center; font-size: 0.875rem; white-space: nowrap; }
.meter i { height: 8px; border-radius: 2px; background: var(--panel); position: relative; overflow: hidden; }
.meter i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--lvl, var(--amber)); }
.meter.hi { --lvl: var(--stamp); }
.meter.lo { --lvl: var(--text-3); }
.split { display: grid; gap: 8px; }
.split-bar { display: flex; height: 22px; border-radius: 3px; overflow: hidden; background: var(--panel); }
.split-bar i { min-width: 1px; }
.split-key { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.875rem; color: var(--text-2); }
.split-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.split-key b { color: var(--text); font-weight: 620; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.pair > svg { width: 22px; height: 22px; color: var(--text-3); }

/* ------------------------------------------------------------ charts */
.chart { width: 100%; height: 320px; min-width: 0; overflow: hidden; }
.chart.tall { height: 420px; }
.chart-card { display: grid; gap: 8px; padding: 16px 16px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.chart-card h3, .chart-card h4 { font-size: 1rem; font-weight: 620; }
.chart-card .cap { font-size: 0.8125rem; color: var(--text-3); }

/* ------------------------------------------------------------ sql workbench */
.bench { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
.bench-side { display: grid; gap: 4px; position: sticky; top: 20px; max-height: calc(100dvh - 40px); overflow: auto; padding-right: 14px; scrollbar-gutter: stable; }
.bench-side details { border-bottom: 1px solid var(--line); }
.bench-side summary { cursor: pointer; padding: 8px 2px; font-weight: 600; font-size: 0.9375rem; list-style: none; display: flex; gap: 8px; justify-content: space-between; align-items: baseline; }
.bench-side summary::-webkit-details-marker { display: none; }
.bench-side summary:hover { color: var(--accent); }
.bench-side summary small { font-weight: 400; color: var(--text-3); font-size: 0.75rem; }
.bench-side .tbl-about { font-size: 0.8125rem; color: var(--text-2); padding: 0 2px 8px; }
.col-list { list-style: none; padding: 0 0 10px; display: grid; gap: 1px; }
.col-list button { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 0; width: 100%; padding: 4px 6px; border-radius: 4px; }
.col-list button:hover { background: var(--accent-weak); }
.col-list button:focus-visible { outline: 2px solid var(--accent); }
.col-list code { font-weight: 600; font-size: 0.8125rem; }
.col-list span { font-size: 0.75rem; color: var(--text-3); line-height: 1.35; }
.ex-list { list-style: none; padding: 0 0 10px; display: grid; gap: 2px; }
.ex-list button { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; padding: 5px 6px; border-radius: 4px; font-size: 0.875rem; color: var(--text-2); }
.ex-list button:hover { background: var(--accent-weak); color: var(--ink-3); }
.ex-list button:focus-visible { outline: 2px solid var(--accent); }
.editor { border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: #fff; }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.editor textarea { width: 100%; min-height: 200px; border: 0; padding: 12px; font: 0.875rem/1.55 var(--mono); resize: vertical; display: block; }
.CodeMirror { height: auto; min-height: 190px; font: 0.875rem/1.55 var(--mono); color: var(--text); }
.CodeMirror-scroll { min-height: 190px; max-height: 50vh; }
.CodeMirror-gutters { background: var(--panel); border-right: 1px solid var(--line); }
.CodeMirror-linenumber { color: var(--text-3); }
.CodeMirror-cursor { border-left: 2px solid var(--accent); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: oklch(0.9 0.06 302); }
.cm-s-default .cm-keyword { color: oklch(0.42 0.18 302); font-weight: 600; }
.cm-s-default .cm-string { color: oklch(0.45 0.13 150); }
.cm-s-default .cm-number { color: oklch(0.5 0.15 50); }
.cm-s-default .cm-comment { color: var(--text-3); font-style: italic; }
.cm-s-default .cm-builtin, .cm-s-default .cm-atom { color: oklch(0.45 0.12 230); }
.CodeMirror-hints { font: 0.8125rem/1.5 var(--mono); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50; }
li.CodeMirror-hint-active { background: var(--accent); }
.bench-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bench-bar .spacer { flex: 1; }
.bench-main { display: grid; gap: 14px; min-width: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); }
.tabs button { border: 0; background: none; padding: 8px 14px; font-weight: 560; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.chart-cfg { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.chart-cfg .field { font-size: 0.8125rem; }
.chart-cfg .input { padding: 5px 28px 5px 9px; font-size: 0.875rem; }

/* ------------------------------------------------------------ guide */
.gloss { display: grid; border-top: 2px solid var(--text); }
.gloss > div { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 4px 28px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.gloss dt { font-weight: 620; display: grid; gap: 4px; align-content: start; justify-items: start; }
.gloss dd { color: var(--text-2); max-width: 68ch; }
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; counter-reset: f; }
.flow > div { padding: 14px 16px 14px 0; border-top: 2px solid var(--text); display: grid; gap: 4px; align-content: start; position: relative; margin-right: 14px; }
.flow > div b { font-weight: 620; }
.flow > div span { font-size: 0.875rem; color: var(--text-2); }
.flow > div:not(:last-child)::after { content: ""; position: absolute; right: -11px; top: -6px; width: 8px; height: 8px; border-top: 2px solid var(--text); border-right: 2px solid var(--text); transform: rotate(45deg); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px 32px; }
.plain-list { padding-left: 18px; display: grid; gap: 6px; color: var(--text-2); }

/* ------------------------------------------------------------ chat dock */
.chat { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line-strong); min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.chat-head h2 { font-size: 1.0625rem; margin-right: auto; }
.icon-btn { border: 0; background: none; width: 34px; height: 34px; border-radius: var(--radius); display: grid; place-items: center; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--panel); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 18px; scroll-behavior: smooth; overscroll-behavior: contain; }
.chat-intro { display: grid; gap: 14px; margin: auto 0; }
.chat-intro p { color: var(--text-2); }
.chat-intro .chips { display: grid; }
.chat-intro .chip { border-radius: var(--radius); padding: 9px 12px; }
.msg-user { align-self: flex-end; max-width: 88%; background: var(--ink); color: var(--ink-fg); padding: 9px 14px; border-radius: 14px 14px 3px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-bot { display: grid; gap: 12px; min-width: 0; }
.md { display: grid; gap: 10px; overflow-wrap: anywhere; min-width: 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 1.0625rem; font-weight: 620; margin-top: 6px; letter-spacing: 0; }
.md ul, .md ol { padding-left: 20px; display: grid; gap: 4px; }
.md table { border-collapse: collapse; font-size: 0.875rem; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.md th { background: var(--panel); font-weight: 600; white-space: nowrap; }
.md td[align="right"], .md th[align="right"] { text-align: right; }
.md pre { margin: 0; padding: 10px 12px; background: var(--ink); color: oklch(0.93 0.03 302); border-radius: var(--radius); overflow-x: auto; font-size: 0.8125rem; }
.md code { background: var(--panel); padding: 1px 4px; border-radius: 3px; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0; padding: 2px 0 2px 14px; border-left: 1px solid var(--line-strong); color: var(--text-2); }
.md .mermaid-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fff; overflow-x: auto; }
.md .mermaid-box svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.step { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); font-size: 0.875rem; min-width: 0; }
.step > summary { cursor: pointer; padding: 7px 10px; list-style: none; display: flex; gap: 8px; align-items: center; color: var(--text-2); }
.step > summary::-webkit-details-marker { display: none; }
.step > summary svg { width: 15px; height: 15px; flex: none; color: var(--accent); }
.step > summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step > summary em { margin-left: auto; font-style: normal; color: var(--text-3); font-size: 0.75rem; white-space: nowrap; }
.step.running > summary svg { animation: spin 1s linear infinite; }
.step.failed > summary svg { color: var(--stamp); }
.step-body { padding: 0 10px 10px; display: grid; gap: 8px; min-width: 0; }
.step-body .tbl-wrap { max-height: 280px; }
.step-body .tbl { font-size: 0.8125rem; }
.step-body .tbl td, .step-body .tbl th { padding: 5px 8px; }
.thinking { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 0.875rem; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.thinking span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }
.chat-form { border-top: 1px solid var(--line); padding: 12px 14px 14px; display: grid; gap: 8px; background: var(--surface); }
.chat-ctx { font-size: 0.75rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--line-strong); border-radius: 10px; padding: 6px 6px 6px 12px; background: #fff; }
.chat-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.chat-input textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; padding: 6px 0; max-height: 160px; min-height: 24px; line-height: 1.45; caret-color: var(--accent); }
.chat-input .btn { padding: 8px 10px; border-radius: 8px; }
.chat-opts { display: flex; align-items: center; gap: 10px; justify-content: space-between; font-size: 0.75rem; color: var(--text-3); }
.chat-opts .seg { flex: none; }
.chat-opts .seg button { padding: 3px 9px; font-size: 0.75rem; }
.history { position: absolute; top: 54px; right: 12px; left: 12px; z-index: 5; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 60vh; overflow: auto; padding: 6px; display: grid; gap: 2px; }
.history button { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; padding: 8px 10px; border-radius: 4px; display: grid; gap: 1px; }
.history button:hover { background: var(--accent-weak); }
.history button:focus-visible { outline: 2px solid var(--accent); }
.history small { color: var(--text-3); font-size: 0.75rem; }

/* ------------------------------------------------------------ login */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-side { background: var(--ink); color: var(--ink-fg); padding: clamp(28px, 6vw, 72px); display: grid; align-content: space-between; gap: 40px; }
.login-side h1 { font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.05; max-width: 14ch; }
.login-side p { color: var(--ink-muted); max-width: 44ch; font-size: 1.0625rem; }
.login-main { display: grid; place-items: center; padding: 32px 24px; }
.login-main form { width: min(380px, 100%); display: grid; gap: 16px; }
.login-main h2 { margin-bottom: 4px; }
.form-error { color: var(--stamp); font-size: 0.9375rem; font-weight: 560; min-height: 1.4em; }

/* ------------------------------------------------------------ responsive */
.topbar { display: none; }
@media (max-width: 1180px) {
  .shell.chat-open { grid-template-columns: 236px minmax(0, 1fr); }
  .chat { position: fixed; inset: 0 0 0 auto; width: min(480px, 100vw); z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 860px) {
  .shell, .shell.chat-open { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 8px 12px; overflow-x: auto; }
  .rail .nav { display: flex; gap: 2px; }
  .rail .nav a { padding: 8px 10px; white-space: nowrap; }
  .rail .nav a svg { display: none; }
  .nav-label, .rail-foot, .ask-btn kbd { display: none; }
  .ask-btn { width: auto; flex: none; padding: 8px 12px; }
  .brand { font-size: 1.125rem; padding: 0; }
  main { padding: 24px 16px 96px; }
  h1 { font-size: 1.75rem; }
  .lede { font-size: 1.0625rem; }
  .anatomy, .bench, .pair { grid-template-columns: minmax(0, 1fr); }
  .pair > svg { transform: rotate(90deg); justify-self: center; }
  .bench-side { position: static; max-height: none; }
  .ladder { grid-template-columns: 1fr 1fr; }
  .ladder > div:nth-child(3) { border-left: 0; }
  .ladder > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .ladder > div + div::before { display: none; }
  .flow { grid-template-columns: 1fr; }
  .flow > div:not(:last-child)::after { display: none; }
  .check-row { grid-template-columns: minmax(0, 1fr) 20px; }
  .check-row .count { grid-column: 1; text-align: left; display: flex; gap: 8px; align-items: baseline; }
  .case > button { grid-template-columns: minmax(0, 1fr) 20px; }
  .case > button > :nth-child(2), .case > button > :nth-child(3) { grid-column: 1; }
  .case > button > svg { grid-row: 1; grid-column: 2; }
  .gloss > div { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 28px 24px; gap: 16px; }
  .chat { width: 100vw; }
  .askbox form { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
