/*
 * Ledger (decision 0020 §5): a registry, not a dashboard. Hairline rules,
 * square corners, black on white with one accent, state drawn as a shape with
 * a word. No shadows, no gradients, no rounded cards, no coloured left edge.
 *
 * Three rendering rules are kept by this file and must survive any edit:
 *   - machine output that is not in the graph is dashed (`.machine`);
 *   - a research note is a full-bordered yellow block (`.note-block`, `.note-form`);
 *   - a status is a square and its word, a role is a tag: never colour alone.
 *
 * Nothing here is fetched from another origin. The fonts are files in
 * node_modules, served under /vendor/fonts by src/web/server.ts.
 *
 * Order: fonts, tokens, base, shell, Ledger components, then each screen's
 * own part in the order the slices built them, forms, tables, the widths.
 *
 * Every class drawn here is emitted by some screen, and every class a screen
 * emits is drawn here (decision 0020 slice 7); tests/guardrails.test.ts reads
 * both. A hook a script or a test needs is a data- attribute, not a class.
 */

/* --- fonts ---------------------------------------------------------------- */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/vendor/fonts/plex-sans/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/vendor/fonts/plex-sans/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/vendor/fonts/plex-sans/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/vendor/fonts/plex-mono/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/vendor/fonts/plex-mono/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/vendor/fonts/source-serif/source-serif-4-latin-400-normal.woff2") format("woff2");
}

/* --- tokens --------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --ground: #ffffff;
  --ink: #111418;
  --muted: #555c66;
  --hairline: #d5d8dc;
  --rule: var(--ink);
  --accent: #1a3e9c;
  --accent-ink: #ffffff;
  --note-ground: #fff3c4;
  --note-border: #6b5200;
  --note-ink: #5a4500;
  /* Added in slice 1; decision 0020's table has neither. `--wash` is the one
     fill (a hovered row, a transparent picture's backing). `--danger` is for an
     error and a failed check, always beside its words. */
  --wash: #f3f4f6;
  --danger: #a3211a;

  /* A source's own words are set in the serif (decision 0020 §5). */
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  --control: 40px;
  --gutter: 32px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #101215;
    --ink: #e8e6e1;
    --muted: #a0a7b0;
    --hairline: #2e343b;
    --accent: #9db4ff;
    --accent-ink: #101215;
    --note-ground: #2b2410;
    --note-border: #8a7326;
    --note-ink: #d9c27a;
    --wash: #191c21;
    --danger: #ff9a94;
  }
}

/* --- base ----------------------------------------------------------------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
strong { font-weight: 600; }
code, kbd, samp { font-family: var(--mono); font-size: 0.92em; }
hr { border: none; border-top: 1px solid var(--hairline); margin: 1rem 0; }

/* A source's own words. */
blockquote, q, .quoted { font-family: var(--serif); font-size: 1.06em; }
blockquote { margin: 0.6rem 0; }

/* The page title. */
h1.page-title {
  font-size: 1.75rem;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
  overflow-wrap: anywhere;
}
/* A section: a mono label over a 2px rule. */
.section-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 1.75rem 0 0.75rem;
  padding: 0 0 7px;
  border-bottom: 2px solid var(--rule);
  line-height: 1.15;
  overflow-wrap: anywhere;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 0;
}
.section-label a, .section-label .plain { text-transform: none; letter-spacing: 0; }

details > summary { cursor: pointer; color: var(--accent); font-weight: 500; }
details[open] > summary { margin-bottom: 0.5rem; }
/* A page's finds in the site's furniture, below the article's (decision 0023 §8). */
.furniture-group { margin-top: 1rem; padding-top: 0.5rem; border-top: 1px solid var(--hairline); }

/* --- shell ---------------------------------------------------------------- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 28px;
  padding: 0 var(--gutter);
  border-bottom: 2px solid var(--rule);
  background: var(--ground);
}
.brand {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--ink);
  text-decoration: none;
  padding: 16px 0;
  white-space: nowrap;
}
.desks { display: flex; flex-wrap: wrap; gap: 0 2px; flex: 1 1 auto; }
.desks a {
  padding: 16px 12px 13px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  font-weight: 500;
  white-space: nowrap;
}
.desks a:hover { border-bottom-color: var(--hairline); }
.desks a[aria-current] { border-bottom-color: var(--ink); font-weight: 600; }
.search { flex: 0 1 300px; padding: 6px 0; }
/* Who is signed in, and Sign out (decision 0029 slice 1). */
.who { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 0.86rem; white-space: nowrap; }
.who button { min-height: 34px; padding: 0 12px; }

/* The sign-in page: one column, the shell's header and nothing else. */
main.signin { max-width: 34rem; }
.signin .field input { width: 100%; }
.signin .qr svg { display: block; width: 220px; height: 220px; margin: 6px 0; }
.signin .label { display: block; margin-bottom: 4px; }

/* The screens under the current desk. */
.sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 20px;
  padding: 9px var(--gutter);
  border-bottom: 1px solid var(--hairline);
  font-size: 0.82rem;
}
.sub a { color: var(--muted); text-decoration: none; padding: 2px 0; }
.sub a:hover { color: var(--ink); text-decoration: underline; }
.sub a[aria-current] { color: var(--ink); font-weight: 600; }

.alarm { padding: 0 var(--gutter); }
.alarm .message { margin: 12px 0 0; }

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px var(--gutter) 48px;
}
/* A section a route scrolls to (#/source/<id>/history) lands with room above it. */
main [id] { scroll-margin-top: 1rem; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 6px 24px;
  flex-wrap: wrap;
  padding: 12px var(--gutter);
  border-top: 1px solid var(--hairline);
  font-size: 0.8rem;
  color: var(--muted);
}
.foot .audit { font-family: var(--mono); font-size: 0.75rem; }
.foot .audit.broken { color: var(--danger); font-weight: 500; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Ledger components (components.js) ------------------------------------ */

.label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.mono { font-family: var(--mono); font-size: 0.86em; }
.lede { color: var(--muted); margin: 0 0 1.4rem; max-width: 70ch; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; margin-bottom: 18px; }
.page-head > .titles { flex: 1 1 420px; min-width: 0; }
.page-head h1.page-title { margin: 4px 0 0; }
.page-head > .actions { display: flex; flex-wrap: wrap; gap: 8px; }

.section { margin-bottom: 28px; }

/* The state strip: four cells, each a label, a value and one line. */
.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  border: 1px solid var(--ink);
  border-right: none;
  border-bottom: none;
  margin-bottom: 22px;
}
.strip > .cell { padding: 12px 16px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.strip .value { font-weight: 600; font-size: 1.07rem; display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.strip .detail { color: var(--muted); font-size: 0.93rem; }

.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; border-bottom: 1px solid var(--ink); margin-bottom: 22px; }
.tabs a {
  padding: 9px 14px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: none;
  font-weight: 500;
}
.tabs a:hover { border-color: var(--hairline); }
.tabs a[aria-current] { border-color: var(--ink); background: var(--ink); color: var(--ground); }

/* State by shape and word: hollow is suggested, half is under review, filled is confirmed. */
.mark { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.mark.suggested::before, .mark.under_review::before, .mark.confirmed::before {
  content: "";
  flex: none;
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--ink);
}
.mark.under_review::before { border-left-width: 5.5px; }
.mark.confirmed::before { background: var(--ink); }

/* A tag: a citation's role, a kind. PRIMARY is inverted, SECONDARY outlined. */
.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
  padding: 1px 6px;
  border: 1px solid var(--ink);
  color: var(--ink);
  white-space: nowrap;
  vertical-align: baseline;
}
.tag.role-primary { background: var(--ink); color: var(--ground); }
.tag.role-secondary { background: transparent; }
.tag.role-unassessed { border-color: var(--muted); color: var(--muted); }

/* Machine output that is not in the graph: dashed, and it says so. */
.machine {
  border: 1px dashed var(--ink);
  padding: 11px 13px;
  background: transparent;
}
.machine + .machine { margin-top: 10px; }

/* A research note: a full-bordered yellow block, always labelled. */
.note-block {
  background: var(--note-ground);
  border: 1px solid var(--note-border);
  padding: 11px 13px;
}
.note-block .label { color: var(--note-ink); }

/* A Tip (components.js): the word drawn as it was (a tag, or text with a
   dotted underline), and a press shows its meaning under it. */
.tip { display: inline-block; max-width: 100%; vertical-align: baseline; }
button.tip-toggle { min-height: 0; font-weight: inherit; cursor: help; }
button.tip-toggle:not(.tag):not(.help-toggle) {
  border: 0; padding: 0; background: none; color: inherit;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
button.tip-toggle:not(.tag):not(.help-toggle):hover { background: none; color: var(--ink); }
.tip-text {
  display: block;
  margin: 4px 0 0;
  max-width: 60ch;
  color: var(--muted);
  font: 0.9rem/1.4 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  white-space: pre-line;
}

.key {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.5;
  border: 1px solid var(--ink);
  padding: 0 5px;
  margin-right: 4px;
}

/* The one message pattern (decision 0020 §4): shown where the person acted. */
.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--ink);
  padding: 10px 13px;
  margin: 10px 0;
}
.message > .body { flex: 1; min-width: 0; }
.message.error { border: 2px solid var(--danger); }
.message > .label { padding-top: 3px; }
.message.error .label { color: var(--danger); }
.message > button { flex: none; }

/* An index: what is under a desk, one hairline row each: name, what it is, a figure. */
.index { list-style: none; margin: 0; padding: 0; }
.index > li {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr auto;
  gap: 2px 24px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
}
.index .name { font-weight: 500; }
.index .about { color: var(--muted); }
.index .about .there { color: var(--ink); }
.index .count { font-family: var(--mono); font-size: 0.86rem; text-align: right; white-space: nowrap; }
.index strong { font-family: var(--mono); font-size: 1rem; font-weight: 500; }

/* A main column and, on a wide screen, a rail. The rail drops under at medium width. */
.cols { display: flex; flex-wrap: wrap; gap: 28px 40px; align-items: flex-start; }
.cols > .main { flex: 999 1 620px; min-width: 0; }
.cols > .rail { flex: 1 1 300px; min-width: 0; }

/* --- the record page (record.js, slice 2) --------------------------------- */

.under-title { margin: -10px 0 16px; }
.small { font-size: 0.8rem; }

/* The header's menu for the rare and destructive actions: a button that opens a list. */
.menu { position: relative; }
.menu > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--control);
  padding: 0 16px;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-weight: 500;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; margin-left: 8px; border: 4px solid transparent; border-top-color: currentColor; transform: translateY(2px); }
.menu[open] > summary { background: var(--ink); color: var(--ground); margin-bottom: 0; }
.menu-list {
  position: absolute;
  right: 0;
  z-index: 10;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  border: 1px solid var(--ink);
  border-top: none;
}
.menu-list > button, .menu-list > a {
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 0 14px;
  min-height: var(--control);
  display: flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 400;
}
.menu-list > :last-child { border-bottom: none; }
.menu-list > button:hover, .menu-list > a:hover { background: var(--wash); color: var(--ink); }
.danger-text { color: var(--danger); }
.menu-list > .danger-text { color: var(--danger); }
button.danger { border: 2px solid var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger); color: var(--ground); }

/* "Why this rule": the reasoning one press away, in place. */
.why { margin-top: 4px; }
.why > summary { font-weight: 400; font-size: 0.9rem; }
.why[open] > summary { margin-bottom: 4px; }

/* A form opened in place: a ruled box with its title and a way to close it. */
.panel { border: 1px solid var(--ink); padding: 12px 16px 16px; margin: 0 0 22px; }
.panel.inset { margin: 10px 0 0; border-color: var(--hairline); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.panel-head > strong { font-size: 1.05rem; }
.form > * + * { margin-top: 12px; }
.form .first, .panel .first { margin-top: 0; }
.fields { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-start; }
.fields > .field { flex: 1 1 200px; min-width: 0; }
.fields > .field.grow { flex: 3 1 280px; }
.field > label { display: block; margin-bottom: 4px; }
.field > input + select, .field > input + input { margin-top: 6px; }
.field.wide { flex-basis: 100%; }
.field .row { margin-top: 6px; }
.grow { flex: 2 1 260px; width: auto; }
input.narrow { width: 7rem; }
label.check { display: flex; gap: 8px; align-items: baseline; font-weight: 400; }

/* A consequence stated above the button that causes it. */
.consequence { border: 1px solid var(--ink); padding: 10px 13px; margin: 0; }
.consequence.strong { border-width: 2px; }
.consequence > p { margin: 6px 0 0; }
.consequence ul { margin: 6px 0 0; padding-left: 1.2rem; }
/* A served caveat, in the system's words. */
.caveat { border-top: 1px solid var(--hairline); padding-top: 6px; margin: 6px 0 0; color: var(--muted); font-size: 0.93rem; }
.caveat > .label { margin-right: 6px; }
.hint { border: 1px solid var(--hairline); padding: 6px 10px; margin-top: 6px; }
.hint.strong { border-color: var(--ink); }
.hints { margin-top: 6px; }

/* Tags beyond a role: a plain kind, a strong flag, a failed check. */
.tag.plain { border-color: var(--hairline); color: var(--muted); }
.tag.strong { border-width: 2px; padding: 0 5px; font-weight: 500; }
.tag.danger { border-color: var(--danger); color: var(--danger); }

/* Rows: one hairline per thing. */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.rows > li > p { margin: 6px 0 0; }
.rows > li > * + * { margin-top: 6px; }
/* The site item a document page linked to (decision 0023 §8): marked in place, not by colour alone. */
.rows > li.current { outline: 2px solid var(--ink); outline-offset: 4px; }

/* A property list: name, value. */
table.kv td { padding: 8px 12px 8px 0; }
table.kv td.k { width: 170px; color: var(--muted); white-space: nowrap; }
table.kv tbody tr:hover { background: transparent; }

/* The evidence list: one ruled entry per cited source, its controls under it. */
.ev-list { list-style: none; margin: 0; padding: 0; }
.ev-item { padding: 14px 0; border-bottom: 1px solid var(--hairline); }
.ev-item > * + * { margin-top: 4px; }
.ev-head { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline; }
.ev-actions { margin-top: 10px; }
.ev-actions button { min-height: 34px; padding: 0 12px; font-weight: 400; }
.files a { font-size: 0.9rem; }
.section-actions { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.section-label > span:first-child { white-space: nowrap; }
.section-actions button, .section-label button { min-height: 32px; padding: 0 12px; font-family: var(--sans); font-size: 0.9rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.sub-label { margin-top: 1.4rem; }

/* The rail's sections are tighter than the main column's. */
.rail .section { margin-bottom: 22px; }
.rail .machine, .rail .note-block { margin-top: 10px; }
.rail .note-block p, .note-block > p { margin: 4px 0; }
.note-form > .label { color: var(--note-ink); }
.note-form { background: var(--note-ground); border: 1px solid var(--note-border); padding: 11px 13px; }
.resolved { margin-top: 14px; }
.preflight > * + * { margin-top: 8px; }
.defects { margin: 0; padding-left: 1.2rem; }

/* --- the document page (source.js, slice 3) ------------------------------- */

/* The Read tab. The document's own text is its words, so the serif; an OCR
   reading sits inside a MachineBlock, page by page, in the interface's sans:
   it is a machine's guess, not the document's words. */
.reading-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 70vh;
  overflow: auto;
  margin: 8px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  font: 1rem/1.6 var(--serif);
}
.reading-text.ocr { font-family: var(--sans); border: none; padding: 4px 0 0; max-height: 50vh; }
.reading .machine + .machine { margin-top: 12px; }
/* A vendor's copy's words beside our screenshot of the post (decision 0022 slice 4). */
.compare-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.compare-pair .reading-text { margin: 0; }
.compare-shot { display: block; max-width: 100%; height: auto; border: 1px solid var(--hairline); }
@media (max-width: 700px) {
  .compare-pair { grid-template-columns: 1fr; }
}
.image-viewer { margin: 0; }
.image-viewer > * + * { margin-top: 8px; }

/* What it yields: a heading the machine read from the layout, over its leads. */
.ref-heading { margin: 18px 0 6px; font-weight: 600; }
.indent { margin-left: 14px; }
.break { overflow-wrap: anywhere; }
.filters { margin: 10px 0; }
.filters button { min-height: 34px; padding: 0 12px; }
.reason-box { margin-top: 10px; }
.machine > * + *, .decided-item > * + * { margin-top: 8px; }
.decided-item { border: 1px solid var(--hairline); padding: 11px 13px; }
.decided-item + .decided-item { margin-top: 10px; }
.occurrence { margin: 6px 0; }
.occurrence .quoted { color: var(--ink); }
.tag-button {
  min-height: 28px;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
}
.sighting-pictures { align-items: flex-start; gap: 16px; }

/* --- the Decide desk (decision 0020 slice 4) --------------------------------
   Wide: the list beside the item, which stays in view as the list scrolls.
   Narrow: the list above the item (§5). A group is a mono label over a rule,
   its rows hairlines; the row being decided is marked by a 2px ink edge on all
   sides and aria-current, never by colour alone. */
.keys-line .key { margin: 0 2px 0 0; }
.decide-hub { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); gap: 28px 36px; align-items: start; }
.decide-item { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; min-width: 0; }
.decide-list { min-width: 0; }
.decide-group { margin-top: 18px; }
.decide-group-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-bottom: 2px solid var(--rule); padding-bottom: 4px;
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.decide-group-title { font: inherit; letter-spacing: inherit; text-transform: inherit; border: 0; padding: 0; min-height: 32px; background: none; color: var(--ink); text-align: left; }
button.decide-group-title:hover { background: none; color: var(--accent); }
.decide-group-tools { margin: 8px 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.decide-rows { list-style: none; margin: 0; padding: 0; }
.decide-rows > li { border-bottom: 1px solid var(--hairline); }
.decide-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  min-height: 0; padding: 8px 10px; border: 2px solid transparent; background: none;
  color: var(--ink); font-weight: 400; text-align: left;
}
.decide-row:hover { background: var(--wash); color: var(--ink); }
.decide-row[aria-current="true"] { border-color: var(--ink); }
.decide-row-title { overflow-wrap: anywhere; }
.decide-more { margin-top: 8px; min-height: 34px; padding: 0 12px; font-weight: 400; }
.decide-head.row { justify-content: flex-start; flex-wrap: nowrap; gap: 10px; }
.decide-holds { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.decide-found > * + * { margin-top: 8px; }
.decide-found .tag { white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
.decide-form { margin-top: 10px; }
.decide-form > * + * { margin-top: 10px; }
.decision-item { border: 1px solid var(--ink); padding: 11px 13px; }
.decision-item > * + * { margin-top: 8px; }
.decision-item + .decision-item, .machine + .decision-item, .decision-item + .machine { margin-top: 10px; }
button.armed { outline: 2px solid var(--ink); outline-offset: 2px; }
.decide-head .help-toggle { flex: none; min-height: 24px; min-width: 24px; padding: 0 6px; font-weight: 600; }
.decide-head > .muted.mono { margin-left: auto; }
.decide-head > .muted.mono + .help-toggle { margin-left: 8px; }
.decide-help { border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); padding: 6px 0; }
.decide-help > p { margin: 4px 0; }
.decide-help .consequence { border: 0; padding: 0; }
.decide-name strong { font-size: 1.15rem; }
.decide-question { font-weight: 600; margin: 0; }
.decide-buttons { gap: 8px; }
.decide-reason { border-top: 1px solid var(--hairline); padding-top: 8px; }
.decide-reason > * + * { margin-top: 8px; }
.quick-reasons { gap: 6px; }
[data-count].short { color: var(--danger); }
fieldset.role-choice.compact { border: 0; padding: 0; margin: 0; display: flex; gap: 4px 16px; align-items: baseline; flex-wrap: wrap; }
fieldset.role-choice.compact legend { float: left; margin-right: 8px; padding: 0; font-weight: 400; color: var(--muted); }
fieldset.role-choice.compact label.role-option { margin: 0; }
fieldset.role-choice.compact .help-toggle { min-height: 22px; min-width: 22px; padding: 0 5px; font-weight: 600; }
.signals { margin: 4px 0 0; padding-left: 1.1rem; }
.signals > li + li { margin-top: 3px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair-side { border-top: 1px solid var(--hairline); padding-top: 6px; min-width: 0; }
fieldset.choice { border: 1px solid var(--hairline); padding: 8px 12px; margin: 0; }
fieldset.choice .check { display: block; margin-top: 4px; }

/* Different, and the check before creating (decision 0021 §6, §7): the
   likely records one hairline row each, "This one" at the row's right. */
.likely-row { gap: 4px 10px; align-items: baseline; }
.likely-row + .likely-row { border-top: 1px solid var(--hairline); padding-top: 4px; margin-top: 4px; }
.likely-row .push { margin-left: auto; min-height: 30px; padding: 0 10px; font-weight: 400; }
.link-button {
  border: 0; background: none; padding: 0; min-height: 0;
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px; font-weight: 400;
}
.link-button:hover { background: none; color: var(--accent); text-decoration-thickness: 2px; }
.create-check { border-top: 1px solid var(--hairline); padding-top: 8px; }
.create-check > * + * { margin-top: 8px; }
.likely-head .help-toggle { min-height: 24px; min-width: 24px; padding: 0 6px; font-weight: 600; }

/* The rail's next steps: done or not yet, in a word, and the step's button. */
.steps .step-head { gap: 8px; }
.steps button, .steps .button-link { min-height: 34px; padding: 0 12px; font-weight: 400; }
.button-link.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button-link.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--ground); }

/* --- forms and buttons ---------------------------------------------------- */

button, .button-link {
  font: inherit;
  font-weight: 500;
  min-height: var(--control);
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ground);
  color: var(--ink);
  cursor: pointer;
}
button:hover, .button-link:hover { background: var(--ink); color: var(--ground); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--ground); }
button:disabled { opacity: 0.5; cursor: not-allowed; background: var(--ground); color: var(--ink); border-style: dotted; }
button.primary:disabled { background: var(--ground); color: var(--ink); border-color: var(--ink); }
/* A link that sits among buttons and should read as one. */
.button-link { display: inline-flex; align-items: center; text-decoration: none; }

input[type="search"], input[type="text"], input[type="number"], input[type="url"],
input[type="date"], input[type="file"], textarea, select {
  width: 100%;
  min-height: var(--control);
  padding: 8px 10px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ground);
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 5rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); width: 1rem; height: 1rem; vertical-align: -2px; }
label { font-weight: 500; }

/* --- tables --------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 0.96rem; }
th, td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--hairline); vertical-align: top; }
th {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 8px;
  padding-bottom: 6px;
  white-space: nowrap;
}
tbody tr:hover { background: var(--wash); }
/* A wide table scrolls inside its own box. */
.scroll { overflow-x: auto; }

/* --- layout helpers ------------------------------------------------------ */

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 0.6rem; }

.hash { font-family: var(--mono); font-size: 0.75rem; word-break: break-all; color: var(--muted); }

/* The network view (look-up.js). */
#cy { height: 460px; border: 1px solid var(--ink); background: var(--ground); }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.2rem; margin: 0; font-size: 0.96rem; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; word-break: break-word; }

fieldset { border: 1px solid var(--hairline); padding: 0.5rem 0.8rem 0.6rem; margin: 0; }
fieldset.role-choice { flex-basis: 100% !important; }
fieldset legend { font-size: 0.86rem; color: var(--muted); padding: 0 0.3rem; }
label.role-option { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.93rem; margin: 0.25rem 0; color: var(--ink) !important; font-weight: 400; }
label.role-option input { flex: none; }

/* A passage (decision 0012 §6): the page's text, the span marked. The document's words, so the serif. */
.passage-text {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--ink);
  background: transparent;
  font: 1rem/1.6 var(--serif);
}
/* An OCR reading is a machine's guess: drawn dashed, like other machine output. */
.passage-text.ocr { border-style: dashed; }
.passage-text mark {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--ink);
  outline: 2px solid var(--accent);
}
/* Offsets whose text is no longer the recorded quote. */
.passage-text mark.stale { background: transparent; outline: 2px dashed var(--danger); }
/* A citation's passage: its parts set apart by the gap, the change line on its own row. */
.passage-line { margin: 0.3rem 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.passage-line > div { flex-basis: 100%; }

/* Decision 0015 §4: an image's intake fields, and what its camera says. */
.image-intake { border-top: 1px solid var(--hairline); padding-top: 0.5rem; flex: 1 1 100%; }
.image-intake[hidden], .intake-record[hidden] { display: none; }
.intake-record { border: 1px solid var(--hairline); padding: 0.4rem 0.6rem; }
.photo-check { margin: 0.3rem 0; }
.check-parts { margin: 0.2rem 0 0; padding-left: 1.2rem; }
.check-parts li { margin: 0.1rem 0; }

/* Images (decision 0015). Every <img> here is a derived display copy, written
   without metadata: never a captured file, never an SVG as markup. A checker
   board behind it shows where a logo is transparent. */
.thumb {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 320px;
  border: 1px solid var(--hairline);
  background: repeating-conic-gradient(var(--wash) 0% 25%, var(--ground) 0% 50%) 50% / 16px 16px;
}
.thumb.small { max-height: 96px; max-width: 160px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.8rem; }
.image-tile { border: 1px solid var(--hairline); padding: 0.6rem; background: transparent; font-size: 0.93rem; }
.image-tile .thumb { margin-bottom: 0.4rem; }
.no-thumb { display: flex; align-items: center; justify-content: center; height: 96px; border: 1px solid var(--hairline); color: var(--muted); font-size: 0.86rem; }

/* Dragging a region for an exemplar. */
.crop-stage { position: relative; display: inline-block; user-select: none; touch-action: none; cursor: crosshair; max-width: 100%; }
.crop-stage img { display: block; max-width: 100%; max-height: 520px; border: 1px solid var(--hairline); }
.crop-box { position: absolute; border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); pointer-events: none; }

/* Emblem sightings (decision 0015 §5): the picture with the placed region drawn on it.
   The region is a machine's placement, so it is dashed; the second line keeps it
   visible on a picture of any colour. */
.sighting-picture { position: relative; display: inline-block; max-width: 360px; }
.sighting-picture img { display: block; max-width: 100%; }
.sighting-region { position: absolute; border: 2px dashed var(--accent); outline: 1px solid rgba(255, 255, 255, 0.7); pointer-events: none; }
.sighting-exemplar { margin: 0; max-width: 160px; }
.sighting-exemplar img { display: block; max-width: 100%; border: 1px solid var(--hairline); }
.same-picture { margin: 0.2rem 0 0.6rem; }

/* The Intake desk (decision 0020 slice 5): a section's ? opens the served
   words in place; the form's task sits in plain view under its label. */
.section-label .help-toggle { min-height: 22px; min-width: 22px; padding: 0 5px; margin-left: 6px; font-weight: 600; }
.section-help { border-bottom: 1px solid var(--hairline); padding: 0 0 6px; margin-bottom: 10px; }
.section-help > p { margin: 4px 0; max-width: 75ch; }
.switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.switch button { font-weight: 400; }
.switch button[aria-pressed="true"] { background: var(--ink); color: var(--ground); font-weight: 500; }
.task { margin: 0 0 10px; }

/* Look up, Referrals and More (decision 0020 slice 6). */
.row.tight { gap: 6px; }
.paths { list-style: none; margin: 0; padding: 0; }
.paths > li { border-bottom: 1px solid var(--hairline); padding: 10px 0; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.path-steps { flex: 1 1 320px; }
.legend-item { margin-right: 10px; white-space: nowrap; }
.list-row { border-bottom: 1px solid var(--hairline); padding: 12px 0; }
.list-row > * + * { margin-top: 8px; }
.list-head .tag { margin: 4px 6px 0 0; white-space: normal; }
.list-row .row { align-items: flex-start; }
.scan-action { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.decided-proposal, .decided-sighting { border: 1px solid var(--hairline); padding: 10px 13px; }
.decided-proposal > * + *, .decided-sighting > * + * { margin-top: 6px; }
.decided-proposal blockquote { margin: 0; }
dl.glossary { margin: 0; }
dl.glossary > div { display: grid; grid-template-columns: minmax(10rem, 16rem) 1fr; gap: 0 18px; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
dl.glossary dt { font-weight: 500; overflow-wrap: anywhere; }
dl.glossary dd { margin: 0; }
#legend { display: flex; flex-wrap: wrap; gap: 4px 10px; }
table.kv td { overflow-wrap: anywhere; }
@media (max-width: 700px) {
  dl.glossary > div { grid-template-columns: 1fr; }
  .section-label { flex-wrap: wrap; }
  .section-label > span:first-child { white-space: normal; }
  /* A key wraps between words, never inside one ("Waitin g"). */
  table.kv td.k { width: auto; white-space: normal; overflow-wrap: normal; }
  .paths > li { flex-direction: column; gap: 4px; }
}
.origin { overflow-wrap: anywhere; }
.index .about .origin { display: block; font-size: 0.86rem; }
.tag.warn { border-color: var(--danger); color: var(--danger); }
.plain-list { margin: 6px 0; padding-left: 1.1rem; }
.feed-items, .batch-files { list-style: none; margin: 0; padding: 0; }
.feed-item, .batch-file { border-bottom: 1px solid var(--hairline); padding: 9px 0; min-width: 0; }
.feed-item > * + *, .batch-file > * + * { margin-top: 4px; }
.feed-item .push { margin-left: auto; min-height: 30px; padding: 0 10px; font-weight: 400; }
.next-steps { gap: 4px 14px; }

/* --- widths ---------------------------------------------------------------
   Wide: main column and rail. Medium: the rail wraps under (the flex bases in
   `.cols`). Narrow, a phone: one column, the desks wrap, a wide table scrolls
   inside its own box, and controls are 44px. */

@media (max-width: 1100px) {
  :root { --gutter: 24px; }
}

@media (max-width: 700px) {
  :root { --gutter: 16px; --control: 44px; }
  .top { gap: 0 16px; }
  .brand { flex-basis: 100%; }
  .desks { margin: 0 -8px; }
  .search { flex: 1 1 100%; padding: 8px 0 12px; }
  .sub { gap: 0 16px; }
  main { padding: 20px var(--gutter) 40px; }
  h1.page-title { font-size: 1.45rem; }
  /* 16px stops a phone zooming the page when a field takes focus. */
  input, textarea, select { font-size: 16px; }
  main table { display: block; overflow-x: auto; max-width: 100%; }
  .index > li { grid-template-columns: 1fr auto; }
  .index .name { grid-column: 1; grid-row: 1; }
  .index .count { grid-column: 2; grid-row: 1; }
  .index .about { grid-column: 1 / -1; grid-row: 2; }
  /* A long figure ("2 imported, 1 skipped, 1 failed") or a path wraps rather than widening the page. */
  .index > li > * { min-width: 0; }
  .index .count { white-space: normal; }
  .index .about { overflow-wrap: anywhere; }
  dl.props { grid-template-columns: 1fr; gap: 0 0; }
  dl.props dd { margin-bottom: 0.5rem; }
  .strip > .cell { padding: 10px 12px; }
  #cy { height: 360px; }
  .decide-hub { grid-template-columns: 1fr; }
  .decide-item { position: static; max-height: none; overflow: visible; }
  .pair { grid-template-columns: 1fr; }

  /* Every control is a 44px target (0020 slice 7). The buttons drawn smaller
     on a wide screen take the full control height; the wordmark, the desk and
     sub-desk links, the tabs and a disclosure line are padded to it. */
  .brand { display: flex; align-items: center; min-height: var(--control); padding: 4px 0 0; }
  .desks a { padding: 13px 8px 10px; }
  .sub a { padding: 14px 0; }
  .tabs a { padding: 13px 14px; }
  details > summary { padding: 12px 0; }
  .ev-actions button, .section-actions button, .section-label button, .filters button, .tag-button,
  .decide-group-title, .decide-more, .likely-row .push, .feed-item .push,
  .steps button, .steps .button-link { min-height: var(--control); }
  /* A ? stays small beside its label; its target reaches 44px round it. */
  .help-toggle, .tip-toggle { position: relative; }
  .help-toggle::after { content: ""; position: absolute; inset: -11px; }
  .tip-toggle::after { content: ""; position: absolute; inset: -13px 0; }
  .tip-toggle.help-toggle::after { inset: -11px; }
}

@media print {
  .top, .sub, .foot { display: none; }
  main { max-width: none; padding: 0; }
}

/* Named together (decision 0018 §5): a lead, so each pair is dashed machine output. */
.together-documents, .together-groups, .together-rows { list-style: none; margin: 0; padding: 0; }
.together-group + .together-group { margin-top: 14px; }
.together-held { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 6px; }
.together-rows > li + li { margin-top: 8px; }
.together-group > button { margin-top: 8px; }
.together-documents > li + li { margin-top: 22px; }
.together-doc { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.together-names { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.together-passage { margin-top: 8px; font: 1rem/1.6 var(--serif); }
.together-passage mark { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); outline: 1px solid var(--accent); }
.together-passage mark[data-mark="designated"] { outline-style: dashed; }
.together-passage[data-placed="false"] .passage-quote { color: var(--muted); }
.together-row button { margin-top: 8px; }
