/* AutoMates: the shared stylesheet every page of the stack layers on.
 *
 * Palette (five colours, everything else derived from them):
 *   black #000000 · Prussian blue #14213d · orange #fca311 ·
 *   alabaster grey #e5e5e5 · white #ffffff
 *
 * Roles. Prussian blue is the voice: text, the navigation rail, a chosen tab
 * or answer. Orange is the pointer: the one action to take next, the mark on
 * whatever is current, progress, focus. Alabaster and white are the surfaces.
 * Orange on white is 2:1, far below what small text needs, so text in the
 * orange family uses --accent, a darkened orange that clears 4.5:1 on every
 * light surface here; pure orange is kept for fills and marks, where the
 * Prussian text on it reads at 7.9:1. Corners are square throughout, badges
 * excepted, and the semantic three (ok, warn, bad) stay outside the palette
 * because Yes and No must never be confused with the brand.
 */

:root {
  color-scheme: light;

  --black: #000000;
  --prussian: #14213d;
  --orange: #fca311;
  --alabaster: #e5e5e5;
  --white: #ffffff;

  --bg: #f3f3f3;              /* alabaster, cut with white */
  --panel: #ffffff;
  --panel-2: #f9f9f9;
  --ink: #14213d;
  --ink-2: #535c6f;           /* prussian 70 / alabaster 30, 6.7:1 on white */
  --ink-3: #747c8b;           /* captions and counts */
  --line: #e5e5e5;            /* alabaster, as drawn */
  --line-2: #f0f0f0;

  --accent: #9a5a00;          /* orange as text: links, kickers, counts (5.5:1) */
  --accent-2: #fca311;        /* orange as a mark: bars, fills, focus, progress */
  --accent-soft: #fff1db;     /* orange as a surface: the selected row or tab */
  --prussian-soft: #ecedf1;   /* prussian as a surface */
  --primary: #fca311;         /* the action to take next */
  --on-primary: #14213d;
  --pressed: #14213d;         /* a chosen tab, segment or answer */
  --on-pressed: #ffffff;

  --ok: #1a7a4a;
  --ok-soft: #e3f2e9;
  --warn: #8a6116;
  --warn-soft: #faf3dc;
  --bad: #b42318;
  --bad-soft: #fbe9e7;

  --rail-bg: #14213d;
  --rail-ink: #e5e5e5;
  --rail-ink-2: rgba(229, 229, 229, .68);
  --rail-line: rgba(255, 255, 255, .10);
  --rail-hover: rgba(255, 255, 255, .06);
  --rail-on: rgba(255, 255, 255, .10);

  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .08);
  --radius: 0;
  --radius-sm: 2px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --serif: Charter, "Iowan Old Style", "Source Serif 4", Georgia, "Times New Roman", serif;

  --hl-yellow: rgba(255, 214, 51, .42);
  --hl-green: rgba(64, 200, 128, .38);
  --hl-blue: rgba(74, 158, 255, .34);
  --hl-pink: rgba(255, 122, 190, .34);
  --hl-orange: rgba(255, 150, 60, .38);
  --hl-yellow-solid: #ffd633;
  --hl-green-solid: #40c880;
  --hl-blue-solid: #4a9eff;
  --hl-pink-solid: #ff7abe;
  --hl-orange-solid: #ff963c;
}

/* Dark: the palette turned over. Black beneath, Prussian panels, alabaster
   text, and orange free to carry text as well, at 9:1 on the panels. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #060a12;
    --panel: #0c1425;
    --panel-2: #14213d;
    --ink: #e5e5e5;
    --ink-2: #a6aab3;
    --ink-3: #7c8391;
    --line: #29354e;
    --line-2: #1d2841;
    --accent: #fca311;
    --accent-2: #fca311;
    --accent-soft: #3a3020;
    --prussian-soft: #1b2843;
    --primary: #fca311;
    --on-primary: #14213d;
    --pressed: #e5e5e5;
    --on-pressed: #14213d;
    --ok: #5ccb8f;
    --ok-soft: #12301f;
    --warn: #e8b84f;
    --warn-soft: #302810;
    --bad: #ff7b6b;
    --bad-soft: #3a1612;
    --rail-bg: #0c1425;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in srgb, var(--orange) 38%, transparent); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--accent-2); text-underline-offset: 2px; }

button, select, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  color: var(--ink);
  transition: background .12s, border-color .12s;
}
button:hover:not(:disabled) { background: var(--panel-2); border-color: var(--ink-3); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 650;
}
button.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 86%, var(--black));
  border-color: color-mix(in srgb, var(--primary) 86%, var(--black));
}
button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button.ghost:hover:not(:disabled) { background: var(--line-2); }
button.danger { color: var(--bad); }

/* A labelled on/off switch. The sliding knob and the On/Off word both carry
   the state, so it does not rest on colour alone. */
button.switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px 4px 10px;
  white-space: nowrap;
  color: var(--ink-2);
}
button.switch-btn.on { color: var(--ink); border-color: var(--accent-2); }
button.switch-btn .track {
  position: relative;
  flex: none;
  width: 26px;
  height: 15px;
  border-radius: 999px;
  background: var(--line);
  transition: background .14s;
}
button.switch-btn.on .track { background: var(--accent-2); }
button.switch-btn .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  transition: transform .14s;
}
button.switch-btn.on .knob { transform: translateX(11px); background: var(--prussian); }
button.switch-btn .state {
  min-width: 24px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-3);
}
button.switch-btn.on .state { color: var(--accent); }

input[type=text], input[type=number], input[type=search], input[type=password],
input[type=date], textarea, select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: 3px solid color-mix(in srgb, var(--orange) 35%, transparent);
  outline-offset: 0;
  border-color: var(--accent-2);
}
textarea { resize: vertical; }
label.field { display: block; margin-bottom: 10px; }
label.field > span {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 4px;
  font-weight: 550;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  height: 50px;
  flex: none;
}
.topbar h1 {
  font-size: 15px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .sub { color: var(--ink-3); font-size: 12px; }
/* On a phone the bar wraps rather than squeezing its buttons into columns. */
@media (max-width: 720px) {
  .topbar { height: auto; min-height: 50px; flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
}
.spacer { flex: 1; }
.brand {
  font-weight: 750;
  letter-spacing: -.2px;
  font-size: 14px;
  white-space: nowrap;
}
.brand .tag {
  font-size: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: 1px;
}

/* File-kind labels. Four kinds told apart by fill as much as by colour:
   the manuscript solid, supplements grey, code orange-tinted, data outlined. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--line-2);
  color: var(--ink-2);
  white-space: nowrap;
  font-weight: 600;
}
.pill.main { background: var(--pressed); color: var(--on-pressed); }
.pill.supplement { background: var(--line); color: var(--ink); }
.pill.code { background: var(--accent-soft); color: var(--accent); }
.pill.data { background: var(--panel); color: var(--ink); border-color: var(--ink-3); }

/* ---------------------------------------------------------------- layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.panes {
  flex: 1;
  display: grid;
  /* Widths are variables so the two splitters can drag them. The 6px tracks
     between the panes are the splitters themselves. */
  grid-template-columns:
    var(--pane-left, 260px) 6px minmax(0, 1fr) 6px var(--pane-right, 420px);
  min-height: 0;
}
.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  overflow: hidden;
}
.pane.left { border-right: 1px solid var(--line); }
.pane.right { border-left: 1px solid var(--line); }
.pane.center { background: var(--bg); }
.pane-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  flex: none;
  min-height: 40px;
  background: var(--panel);
}
.pane-head h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-3);
  margin: 0;
  font-weight: 700;
}
.pane-body { flex: 1; overflow: auto; }

.tabs { display: flex; gap: 2px; }
.tabs button {
  border: none;
  background: transparent;
  border-radius: var(--radius);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}
.tabs button.on {
  background: var(--accent-soft);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent-2);
}

/* ------------------------------------------------------------ file tree */
.tree { padding: 6px; }
.tree-group { margin-bottom: 4px; }
.tree-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.3;
}
.tree-item:hover { background: var(--line-2); }
.tree-item.on {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent-2);
}
.tree-item .name { flex: 1; word-break: break-word; }
.tree-item .meta { font-size: 10px; color: var(--ink-3); white-space: nowrap; }
.tree-item.child { margin-left: 14px; font-size: 12px; }
.tree-item.unviewable { opacity: .55; }
.tree-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--line-2);
  color: var(--ink-2);
  flex: none;
}
.tree-toggle {
  border: none;
  background: none;
  padding: 0 2px;
  color: var(--ink-3);
  font-size: 10px;
  width: 14px;
  flex: none;
  cursor: pointer;
}

/* --------------------------------------------------------------- viewer */
.viewer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: none;
  flex-wrap: wrap;
}
.viewer-bar .fname {
  font-weight: 600;
  font-size: 13px;
  max-width: 40ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-scroll {
  flex: 1;
  overflow: auto;
  padding: 16px;
  scroll-behavior: smooth;
}
.viewer-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--ink-3);
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

.page-wrap { margin: 0 auto 18px; width: max-content; }
.page-no {
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 4px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.page {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 0;
  overflow: hidden;
}
/* The page picture is purely visual. Left interactive, a drag on it starts
   the browser's native image drag, which swallows the pointer stream and
   fights the word selection. */
.page img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.page .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9c0c9;
  font-size: 12px;
}
.hl-layer, .sel-layer, .marquee-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hl-layer { z-index: 1; }
.sel-layer { z-index: 2; }
.marquee-layer { z-index: 3; }
/* Selection snaps to words by geometry, so the whole page is a text target. */
.page { cursor: text; user-select: none; }
.page.boxmode { cursor: crosshair; }

.sel-layer .selr {
  position: absolute;
  background: rgba(20, 33, 61, .22);
  border-radius: 2px;
}

.hl {
  position: absolute;
  border-radius: 2px;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) { .hl { mix-blend-mode: screen; opacity: .8; } }
.hl.yellow { background: var(--hl-yellow); }
.hl.green { background: var(--hl-green); }
.hl.blue { background: var(--hl-blue); }
.hl.pink { background: var(--hl-pink); }
.hl.orange { background: var(--hl-orange); }
.hl.flash { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.hl.unlinked { box-shadow: inset 0 -2px 0 var(--bad); }

.marquee {
  position: absolute;
  border: 1.5px dashed var(--accent-2);
  background: rgba(252, 163, 17, .1);
}

/* ------------------------------------------------------------ code view */
.code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 1100px;
  margin: 0 auto;
}
.code-line { display: flex; }
.code-line:hover { background: var(--line-2); }
.code-line .ln {
  flex: none;
  width: 52px;
  text-align: right;
  padding: 0 10px 0 6px;
  color: var(--ink-3);
  user-select: none;
  border-right: 1px solid var(--line-2);
  font-size: 11px;
}
.code-line .lc {
  flex: 1;
  padding: 0 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.code-line.hit { background: rgba(255, 214, 51, .18); }
mark.hl-text {
  padding: 1px 0;
  border-radius: 2px;
  background: var(--hl-yellow);
  color: inherit;
}
mark.hl-text.green { background: var(--hl-green); }
mark.hl-text.blue { background: var(--hl-blue); }
mark.hl-text.pink { background: var(--hl-pink); }
mark.hl-text.orange { background: var(--hl-orange); }
mark.hl-text.flash { outline: 2px solid var(--accent-2); }

/* ----------------------------------------------------------- table view */
.sheet-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.grid-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: calc(100vh - 190px);
}
table.grid { border-collapse: collapse; font-size: 12px; font-family: var(--mono); }
table.grid th, table.grid td {
  border: 1px solid var(--line-2);
  padding: 3px 8px;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}
table.grid th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  z-index: 2;
  font-weight: 650;
  color: var(--ink-2);
}
table.grid td.rownum, table.grid th.rownum {
  position: sticky;
  left: 0;
  background: var(--panel-2);
  color: var(--ink-3);
  text-align: right;
  z-index: 1;
}
table.grid td.sel { background: var(--accent-soft); outline: 1px solid var(--accent-2); }
table.grid td.cell-hl { background: var(--hl-yellow); }
table.grid td.cell-hl.green { background: var(--hl-green); }
table.grid td.cell-hl.blue { background: var(--hl-blue); }
table.grid td.cell-hl.pink { background: var(--hl-pink); }
table.grid td.cell-hl.orange { background: var(--hl-orange); }

/* ------------------------------------------------------------- checklist */
.section-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-3);
  font-weight: 700;
  padding: 12px 12px 5px;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 3;
}
.item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 10px 8px;
  background: var(--panel);
  overflow: hidden;
}
/* Open: a Prussian frame. Armed (collecting highlights): the orange mark. */
.item.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--prussian-soft); }
.item.armed { border-color: var(--accent-2); box-shadow: inset 3px 0 0 var(--accent-2); }
/* Quick jump landed here: a one-second pulse so the eye finds the card. */
.item.jumped { animation: item-jumped 1.1s ease-out; }
@keyframes item-jumped {
  from { box-shadow: 0 0 0 3px var(--accent-2); }
  to { box-shadow: 0 0 0 3px transparent; }
}
.item-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  cursor: pointer;
}
.item-head:hover { background: var(--panel-2); }
.item-num {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: var(--radius);
  background: var(--line-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item.decided .item-num { background: var(--pressed); color: var(--on-pressed); }
.item-title { flex: 1; min-width: 0; }
.item-title .nm { font-weight: 620; font-size: 13px; line-height: 1.3; }
.item-title .st { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.item-badges { display: flex; gap: 4px; align-items: center; flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.reported { background: var(--ok); }
.dot.partially_reported { background: var(--warn); }
.dot.not_found { background: var(--bad); }
.dot.unclear { background: var(--warn); }
.dot.not_applicable { background: var(--ink-3); }
.dot.claimed_but_unsupported { background: var(--bad); }
.ev-count {
  font-size: 10px;
  font-weight: 700;
  background: var(--line-2);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ev-count.has { background: var(--accent-soft); color: var(--accent); }

.item-body {
  border-top: 1px solid var(--line-2);
  padding: 10px;
  background: var(--panel-2);
  font-size: 12.5px;
}
.item-q { color: var(--ink-2); line-height: 1.5; margin-bottom: 10px; }
.status-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.status-row button {
  font-size: 11px;
  padding: 3px 8px;
  font-weight: 600;
}
.status-row button.on {
  background: var(--pressed);
  color: var(--on-pressed);
  border-color: var(--pressed);
}
.arm-btn { font-size: 11px; }
.arm-btn.on { background: var(--accent-2); color: var(--on-primary); border-color: var(--accent-2); font-weight: 650; }

.ev-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ev {
  border: 1px solid var(--line);
  border-left: 3px solid var(--hl-yellow-solid);
  border-radius: var(--radius);
  padding: 6px 8px;
  background: var(--panel);
  font-size: 12px;
}
.ev.green { border-left-color: var(--hl-green-solid); }
.ev.blue { border-left-color: var(--hl-blue-solid); }
.ev.pink { border-left-color: var(--hl-pink-solid); }
.ev.orange { border-left-color: var(--hl-orange-solid); }
.ev .loc {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.ev .loc .grow { flex: 1; }
.ev q { font-style: normal; line-height: 1.45; display: block; color: var(--ink); }
.ev q::before, .ev q::after { content: '"'; color: var(--ink-3); }
.ev .note { color: var(--ink-2); font-size: 11px; margin-top: 4px; font-style: italic; }
.ev .acts { display: flex; gap: 2px; }
.ev .acts button { padding: 1px 5px; font-size: 10px; }

.guide { margin-top: 10px; }
.guide summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 0;
}
.guide .gbody {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
  padding: 6px 0 2px;
  border-top: 1px solid var(--line-2);
  margin-top: 4px;
}
.guide .gbody h4 {
  margin: 10px 0 3px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.guide .gbody pre {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 7px;
  margin: 4px 0;
  max-height: 220px;
  overflow: auto;
}
.terms { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.term {
  font-size: 10.5px;
  font-family: var(--mono);
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  cursor: pointer;
  color: var(--ink-2);
}
.term:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-2); }

/* ---------------------------------------------------------------- popup */
.popup {
  position: fixed;
  z-index: 100;
  width: 330px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  font-size: 13px;
}
.popup .quote {
  font-size: 12px;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 6px 8px;
  max-height: 84px;
  overflow: auto;
  line-height: 1.45;
  margin-bottom: 8px;
}
.swatches { display: flex; gap: 5px; margin-bottom: 8px; align-items: center; }
.swatch {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.on { border-color: var(--ink); }
.swatch.yellow { background: var(--hl-yellow-solid); }
.swatch.green { background: var(--hl-green-solid); }
.swatch.blue { background: var(--hl-blue-solid); }
.swatch.pink { background: var(--hl-pink-solid); }
.swatch.orange { background: var(--hl-orange-solid); }

.item-picker {
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.pick {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  padding: 5px 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-2);
  font-size: 12px;
  line-height: 1.3;
}
.pick:last-child { border-bottom: none; }
.pick:hover { background: var(--panel-2); }
.pick.on { background: var(--accent-soft); }
.pick input { width: auto; margin-top: 2px; accent-color: var(--prussian); }
.pick .n { font-weight: 700; color: var(--ink-3); flex: none; width: 16px; font-variant-numeric: tabular-nums; }
.popup-actions { display: flex; gap: 6px; }
.popup-actions button { flex: 1; }

/* ------------------------------------------------------------- library */
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 720px) { .grid2, .grid4 { grid-template-columns: 1fr; } }

.drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12px;
  cursor: pointer;
  background: var(--panel-2);
  transition: border-color .12s, background .12s;
}
.drop:hover, .drop.over { border-color: var(--accent-2); background: var(--accent-soft); color: var(--accent); }
.drop strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 2px; }
.drop .filelist { margin-top: 7px; text-align: left; font-size: 11px; color: var(--ink-2); }
.drop .filelist div {
  padding: 2px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
table.list td { padding: 9px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.list tr:last-child td { border-bottom: none; }
table.list .t { font-weight: 600; }
table.list .m { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

.empty { text-align: center; padding: 36px; color: var(--ink-3); }

/* -------------------------------------------------------------- compare */
table.matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.matrix th, table.matrix td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
table.matrix th { background: var(--panel-2); font-size: 11px; }
table.matrix tr.conflict td { background: var(--bad-soft); }
table.matrix tr.conflict td:first-child { border-left: 3px solid var(--bad); }
.verdict {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
}
/* A figure in a report: a rule above, the number in Prussian, the label
   letter-spaced beneath. */
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 12px;
}
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .k { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; font-weight: 650; }
.stat .h { font-size: 11px; color: var(--ink-2); margin-top: 3px; }
details.ev-detail summary { cursor: pointer; font-size: 11px; color: var(--accent); margin-top: 4px; }

/* --------------------------------------------------------------- toast */
#toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--prussian);
  color: var(--alabaster);
  padding: 8px 14px;
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
  font-size: 12.5px;
  box-shadow: var(--shadow);
  animation: rise .18s ease-out;
}
.toast.err { background: var(--bad); color: #fff; border-left-color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.progress-ring { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bar { width: 90px; height: 6px; background: var(--line-2); border-radius: 0; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent-2); transition: width .2s; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 1px 4px;
  background: var(--panel-2);
  color: var(--ink-2);
}

/* ------------------------------------------------------------------ rail
 * Global left navigation, shared by the portal pages and the workbench.
 * Fixed rather than a grid column so it survives the workbench's own
 * full-height three-pane layout without restructuring it. Prussian blue in
 * both schemes: the one dark element on a light page, and the orange mark
 * on the current section is the only colour in it.
 */
:root { --rail-w: 178px; --rail-w-min: 54px; }

body.with-rail { padding-left: var(--rail-w); }
body.with-rail.rail-collapsed { padding-left: var(--rail-w-min); }

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail-w);
  background: var(--rail-bg);
  color: var(--rail-ink);
  border-right: 1px solid var(--rail-line);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width .13s ease;
}
.rail-collapsed .rail { width: var(--rail-w-min); }

.rail .rail-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 12px;
  font-weight: 750;
  font-size: 14px;
  letter-spacing: -.2px;
  border-bottom: 1px solid var(--rail-line);
  white-space: nowrap;
  overflow: hidden;
  color: var(--rail-ink);
  text-decoration: none;
}
.rail .rail-brand:hover { text-decoration: none; color: #fff; }
.rail .rail-mark {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
}
.rail .rail-mark svg { width: 26px; height: 26px; display: block; }

.rail nav { padding: 8px 8px 0; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 570;
  color: var(--rail-ink-2);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.rail nav a:hover { background: var(--rail-hover); color: var(--rail-ink); text-decoration: none; }
.rail nav a.on {
  background: var(--rail-on);
  color: #fff;
  font-weight: 650;
  box-shadow: inset 3px 0 0 var(--orange);
}
.rail nav a svg { flex: none; width: 17px; height: 17px; stroke-width: 1.7; }
.rail nav a.on svg { color: var(--orange); }
.rail nav a .soon {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--rail-ink-2);
  background: rgba(255, 255, 255, .12);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}
.rail nav a.on .soon { color: var(--rail-ink); }
.rail nav .rail-sep {
  height: 1px;
  background: var(--rail-line);
  margin: 8px 4px;
}

.rail .rail-foot {
  border-top: 1px solid var(--rail-line);
  padding: 9px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rail .rail-who {
  font-size: 11.5px;
  color: var(--rail-ink-2);
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}
.rail .rail-who b {
  color: var(--rail-ink);
  font-weight: 620;
  display: block;
  font-size: 12.5px;
  text-transform: none;
}
.rail .rail-foot button {
  width: 100%;
  font-size: 12px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: transparent;
  border-color: var(--rail-line);
  color: var(--rail-ink-2);
}
.rail .rail-foot button:hover:not(:disabled) {
  background: var(--rail-hover);
  border-color: rgba(255, 255, 255, .28);
  color: #fff;
}
/* Scoped separately from the nav links, which have their own sizing. */
.rail .rail-foot button svg {
  flex: none;
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

.rail-collapsed .rail .label,
.rail-collapsed .rail .soon,
.rail-collapsed .rail .rail-who,
.rail-collapsed .rail .rail-brand span:not(.rail-mark) { display: none; }
.rail-collapsed .rail nav a { justify-content: center; padding: 9px 0; }
.rail-collapsed .rail .rail-brand { justify-content: center; padding: 12px 0; }
.rail-collapsed .rail .rail-foot button { padding: 5px 0; }
.rail-collapsed .rail .rail-foot button .btxt { display: none; }

.rail-toggle {
  position: absolute;
  top: 14px;
  right: -11px;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  line-height: 1;
}
.rail-toggle:hover { color: var(--accent); border-color: var(--accent-2); background: var(--panel); }

/* The workbench is already three columns; keep the rail out of its way. */
body.with-rail .app { height: 100vh; }

@media (max-width: 900px) {
  body.with-rail { padding-left: var(--rail-w-min); }
  .rail { width: var(--rail-w-min); }
  .rail .label, .rail .soon, .rail .rail-who { display: none; }
  .rail nav a { justify-content: center; padding: 9px 0; }
  .rail-toggle { display: none; }
}

/* --------------------------------------------------------- search matches
 * Drawn below the selectable text layer, like the highlight layer, so they
 * never interfere with selecting text.
 */
.search-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.search-hit {
  position: absolute;
  border-radius: 2px;
  background: rgba(255, 190, 0, .45);
  outline: 1px solid rgba(200, 130, 0, .55);
  mix-blend-mode: multiply;
}
.search-hit.current {
  background: rgba(255, 140, 0, .6);
  outline: 2px solid #d96b00;
}
@media (prefers-color-scheme: dark) {
  .search-hit { mix-blend-mode: screen; background: rgba(255, 200, 40, .38); }
  .search-hit.current { background: rgba(255, 170, 40, .55); }
}
.code-line.current-hit { background: rgba(255, 170, 40, .3); }

/* ------------------------------------------------------ answer buttons */
/* Yes / No / N/A. Colour only once chosen, so an unanswered item reads as
   genuinely blank rather than as a default. */
.status-row button.ans { min-width: 54px; }
.status-row button.ans.on.reported { background: var(--ok); border-color: var(--ok); color: #fff; }
.status-row button.ans.on.not_found { background: var(--bad); border-color: var(--bad); color: #fff; }
.status-row button.ans.on.not_applicable {
  background: var(--ink-3);
  border-color: var(--ink-3);
  color: #fff;
}
@media (prefers-color-scheme: dark) {
  .status-row button.ans.on.reported,
  .status-row button.ans.on.not_found,
  .status-row button.ans.on.not_applicable { color: var(--prussian); }
}

/* "optional" tag beside a field label */
.opt {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
  background: var(--line-2);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  vertical-align: 1px;
}

/* --------------------------------------------------------------- splitters
 * Drag to rebalance the three panes. The width lives in a CSS variable on
 * .panes and is remembered per browser, so a reviewer sets it once.
 */
.splitter {
  position: relative;
  cursor: col-resize;
  background: var(--line);
  transition: background .12s;
  touch-action: none;
}
.splitter:hover,
.splitter.dragging { background: var(--accent-2); }
/* A wider invisible grab area than the visible 6px line, so it is easy to hit
   without making the divider itself look heavy. */
.splitter::before {
  content: '';
  position: absolute;
  inset: 0 -4px;
  z-index: 20;
}
/* The grip marks appear on hover so the divider reads as draggable. */
.splitter::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 26px;
  margin: -13px 0 0 -1px;
  border-radius: 2px;
  background: var(--panel);
  opacity: 0;
  transition: opacity .12s;
}
.splitter:hover::after,
.splitter.dragging::after { opacity: .85; }

/* While dragging, stop the pointer selecting text or changing shape over the
   panes it passes across. */
body.resizing,
body.resizing * { cursor: col-resize !important; user-select: none !important; }

@media (max-width: 900px) { .splitter { display: none; } }

/* Blind review indicator ------------------------------------------------ */
.blind-chip { display: inline-flex; align-items: center; padding: 3px 9px;
              border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 650;
              letter-spacing: 0.2px; background: var(--warn-soft); color: var(--warn);
              border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); white-space: nowrap; }
