/* Warren UI. An investigations desk: paper and ink, a dark masthead, serif names, small-caps
   labels, and one signal colour (vermilion) for "nobody has written about this".
   Tokens adapted from OSINT Desk. No inline styles anywhere: the strict CSP has no
   'unsafe-inline'. Light and dark: html[data-theme=system|light|dark]. */

:root {                               /* light: paper */
  --bg: #f4f2ec; --surface: #fffefb; --surface-2: #eeebe3; --surface-3: #e5e1d6;
  --border: #dbd6c9; --border-strong: #8f8878;
  --text: #1c1c1a; --text-muted: #57544a; --text-faint: #6f6b60;
  --accent: #1d4f91; --accent-text: #ffffff; --accent-soft: #e3eaf4; --focus: #1d4f91;
  --ok: #1f6f3c; --ok-bg: #e5f1e7; --warn: #8a5800; --warn-bg: #faf0d7;
  --bad: #a8261c; --bad-bg: #f8e4e0; --grey: #5c5a52; --grey-bg: #ebe8e0; --info-bg: #e3eaf4;
  /* the signal colour and the documentation ramp (one hue, strongest = undocumented) */
  --hole: #b3361a; --hole-bg: #f8e5dc; --hole-text: #9e2f16;
  --doc-none: #b8391a; --doc-thin: #dc7a3e; --doc-some: #e9b48c; --doc-well: #b2ada3;
  --doc-none-text: #9e2f16; --doc-thin-text: #8f4a14; --doc-some-text: #6e5644; --doc-well-text: #5f5c55;
  --mk-ring: rgba(28, 28, 26, 0.55); --spend: #1d4f91;
  /* cues (identity; shown as a swatch plus words, never colour alone) */
  --cue-hush: #6d3fb0; --cue-firsthand: #23744a; --cue-question: #2468b3; --cue-unanswered: #9a5b00;
  --cue-removed: #a8261c; --cue-specific: #0e6f7b;
  --cue-slip: #a3155a; --cue-slip-text: #ffffff; --cue-slip-bg: #f9e1ec;  /* "let slip": the strongest cue, filled */
  --mark: #ffe680; --mark-text: #1c1c1a;
  --masthead: #17181a; --masthead-text: #efebe2; --masthead-muted: #b7b1a4; --masthead-line: #2c2d31; --masthead-input: #24262a;
  --edge: #8f8878;
  --shadow: 0 1px 2px rgba(40, 32, 16, 0.06), 0 3px 10px rgba(40, 32, 16, 0.06);
  --shadow-lg: 0 10px 40px rgba(20, 16, 8, 0.24);
  --hover: #ebe7dd;
  --radius: 6px; --gap-1: 4px; --gap-2: 8px; --gap-3: 12px; --gap-4: 16px; --gap-5: 24px; --gap-6: 32px;
  --font: "Ubuntu Sans", "Ubuntu", "Noto Sans", system-ui, sans-serif;
  --serif: "Noto Serif", "Source Serif Pro", "Iowan Old Style", "Palatino Linotype", "P052", Georgia, serif;
  --serif-display: "Noto Serif Display", "Noto Serif", "Iowan Old Style", "P052", Georgia, serif;
  --mono: "Ubuntu Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", ui-monospace, monospace;
  --text-size: 15px; --line: 1.55; --reading: 74ch; --target: 32px; --chip: 24px;
  --topbar-h: 60px;
  color-scheme: light;
}

:root[data-theme="dark"] {            /* dark: the night desk */
  --bg: #121315; --surface: #1a1b1e; --surface-2: #212327; --surface-3: #292c31;
  --border: #33363c; --border-strong: #6f737b;
  --text: #ece8df; --text-muted: #aaa69c; --text-faint: #8e8a81;
  --accent: #8fb5ec; --accent-text: #0d1420; --accent-soft: #1b2a40; --focus: #8fb5ec;
  --ok: #74cf93; --ok-bg: #14301f; --warn: #eec26a; --warn-bg: #33290f;
  --bad: #ff8d80; --bad-bg: #3b1714; --grey: #a3a097; --grey-bg: #25272b; --info-bg: #1b2a40;
  --hole: #ff8452; --hole-bg: #3a1e13; --hole-text: #ff9a70;
  --doc-none: #ff7a45; --doc-thin: #cf7a48; --doc-some: #8c6553; --doc-well: #5d5b57;
  --doc-none-text: #ff9a70; --doc-thin-text: #e7a27a; --doc-some-text: #c9a996; --doc-well-text: #aaa69c;
  --mk-ring: rgba(10, 10, 12, 0.85); --spend: #8fb5ec;
  --cue-hush: #b998f0; --cue-firsthand: #74cf93; --cue-question: #8fb5ec; --cue-unanswered: #eec26a;
  --cue-removed: #ff8d80; --cue-specific: #6fd0dc;
  --cue-slip: #ff8ac4; --cue-slip-text: #2a0716; --cue-slip-bg: #3d1428;
  --mark: #5c4b0e; --mark-text: #fff4c8;
  --masthead: #0b0c0d; --masthead-text: #ece8df; --masthead-muted: #9d998f; --masthead-line: #26282c; --masthead-input: #1a1b1e;
  --edge: #7a7e86;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 3px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
  --hover: #262a30;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #121315; --surface: #1a1b1e; --surface-2: #212327; --surface-3: #292c31;
    --border: #33363c; --border-strong: #6f737b;
    --text: #ece8df; --text-muted: #aaa69c; --text-faint: #8e8a81;
    --accent: #8fb5ec; --accent-text: #0d1420; --accent-soft: #1b2a40; --focus: #8fb5ec;
    --ok: #74cf93; --ok-bg: #14301f; --warn: #eec26a; --warn-bg: #33290f;
    --bad: #ff8d80; --bad-bg: #3b1714; --grey: #a3a097; --grey-bg: #25272b; --info-bg: #1b2a40;
    --hole: #ff8452; --hole-bg: #3a1e13; --hole-text: #ff9a70;
    --doc-none: #ff7a45; --doc-thin: #cf7a48; --doc-some: #8c6553; --doc-well: #5d5b57;
    --doc-none-text: #ff9a70; --doc-thin-text: #e7a27a; --doc-some-text: #c9a996; --doc-well-text: #aaa69c;
    --mk-ring: rgba(10, 10, 12, 0.85); --spend: #8fb5ec;
    --cue-hush: #b998f0; --cue-firsthand: #74cf93; --cue-question: #8fb5ec; --cue-unanswered: #eec26a;
    --cue-removed: #ff8d80; --cue-specific: #6fd0dc;
    --cue-slip: #ff8ac4; --cue-slip-text: #2a0716; --cue-slip-bg: #3d1428;
    --mark: #5c4b0e; --mark-text: #fff4c8;
    --masthead: #0b0c0d; --masthead-text: #ece8df; --masthead-muted: #9d998f; --masthead-line: #26282c; --masthead-input: #1a1b1e;
    --edge: #7a7e86;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 3px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
    --hover: #262a30;
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------------------------------------
   Base */

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--text-size); -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
  font-family: var(--font); font-size: 1rem; line-height: var(--line);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--gap-3); font-weight: 650; }
h1 { font-family: var(--serif-display); font-size: 2.1rem; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 var(--gap-2); }
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }
kbd {
  display: inline-block; padding: 0 5px; min-width: 1.6em; text-align: center;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
  background: var(--surface); color: var(--text-muted); font-size: 0.8rem; line-height: 1.5;
}
pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
mark { background: var(--mark); color: var(--mark-text); border-radius: 2px; padding: 0 1px; }
hr { border: 0; border-top: 1px solid var(--border); }
ul, ol { margin: 0 0 var(--gap-2); padding-left: 1.4em; }
blockquote { margin: 0; }
figure { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
[tabindex="-1"]:focus { outline: none; }
h1:focus-visible, h2:focus-visible, h3:focus-visible, h4:focus-visible { outline: none; }
.comment[tabindex="-1"]:focus { outline: 2px solid var(--focus); outline-offset: 3px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); box-shadow: var(--shadow); }
.skip-link:focus { left: 8px; }

.muted { color: var(--text-muted); }
.fine { color: var(--text-muted); font-size: 0.87rem; margin-top: var(--gap-2); }
.sep { color: var(--text-faint); }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon-sm { width: 15px; height: 15px; vertical-align: -2px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------------------------------------------------------------------------------------------
   Masthead (top bar) */

.topbar {
  position: sticky; top: 0; z-index: 50; background: var(--masthead); color: var(--masthead-text);
  border-bottom: 1px solid var(--masthead-line); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.topbar-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand nav tools";
  align-items: center; gap: var(--gap-4); max-width: 1440px; margin: 0 auto; padding: 0 var(--gap-5); min-height: var(--topbar-h);
}
.wordmark { grid-area: brand; display: inline-flex; align-items: center; gap: 9px; color: var(--masthead-text); text-decoration: none; min-height: 40px; padding-right: 6px; }
.wordmark-glyph { width: 34px; height: 34px; flex: none; }
.wordmark-text { font-family: var(--serif-display); font-size: 1.45rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; line-height: 1; }
.wordmark:hover .wordmark-text { color: #ffffff; }

.nav { grid-area: nav; min-width: 0; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: nowrap; gap: 2px; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; color: var(--masthead-muted);
  text-decoration: none; font-weight: 550; font-size: 0.95rem; border-radius: 4px; position: relative; white-space: nowrap;
}
.nav-link:hover { color: var(--masthead-text); background: rgba(255, 255, 255, 0.06); }
.nav-link[aria-current="page"] { color: var(--masthead-text); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 3px; height: 2px; background: var(--hole); border-radius: 2px;
}
.topbar :focus-visible { outline-color: #9ec2f5; }

.topbar-tools { grid-area: tools; display: flex; align-items: center; gap: var(--gap-2); }
.global-search { position: relative; display: flex; align-items: center; }
.gs-icon { position: absolute; left: 9px; color: var(--masthead-muted); pointer-events: none; }
.gs-input {
  font: inherit; font-size: 0.93rem; width: 190px; min-height: 34px; padding: 4px 28px 4px 33px; border-radius: 4px;
  border: 1px solid #3a3c41; background: var(--masthead-input); color: var(--masthead-text);
}
.gs-input::placeholder { color: var(--masthead-muted); opacity: 1; }
.gs-input:focus { border-color: #9ec2f5; outline: none; box-shadow: 0 0 0 1px #9ec2f5; }
.gs-key { position: absolute; right: 7px; background: transparent; border-color: #3a3c41; color: var(--masthead-muted); }
.gs-input:focus + .gs-key { display: none; }

.fill-pill {
  display: inline-flex; align-items: center; gap: 8px; max-width: 232px; min-height: 32px; padding: 3px 12px 3px 10px;
  border-radius: 999px; border: 1px solid #3a3c41; color: var(--masthead-text); text-decoration: none; font-size: 0.86rem;
  background: rgba(255, 255, 255, 0.03);
}
.fill-pill:hover { border-color: var(--masthead-muted); }
.fill-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fill-dot { width: 8px; height: 8px; border-radius: 50%; background: #7ccf95; flex: none; }
.fill-pill[data-tone="running"] .fill-dot { background: #f0b45a; animation: pulse 1.4s ease-in-out infinite; }
.fill-pill[data-tone="never"] .fill-dot { background: var(--masthead-muted); }
.fill-pill[data-tone="error"] .fill-dot { background: #ff8d80; }
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 4px;
  border: 1px solid transparent; background: transparent; color: var(--masthead-muted); cursor: pointer;
}
.theme-btn:hover { color: var(--masthead-text); background: rgba(255, 255, 255, 0.06); }

/* Eleven menu items (the editor's; a reader sees ten), the OSINT mark, the search box, the update pill and the signed-in
   person need about 1,700 px on one row with Segoe UI (more with wider fonts), so the menu gets its own row up to 1,880 px.
   Wider than that, the one row is not held to the 1,440 px cap (the menu would slide under the search
   box), and the menu scrolls rather than hide links if a font still makes it too wide. */
@media (max-width: 1880px) {
  .topbar-row { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "brand tools" "nav nav"; row-gap: 0; padding-top: 6px; }
  .topbar-tools { justify-content: flex-end; }
  .nav { margin: 0 -6px 4px; overflow-x: auto; }
  :root { --topbar-h: 104px; }
}
@media not all and (max-width: 1880px) {
  .topbar-row { max-width: none; }
  .nav { overflow-x: auto; overflow-y: hidden; padding: 4px 6px; margin: -4px -6px; }   /* room for the focus ring */
}

.main { min-width: 0; }
.main:focus { outline: none; }
.boot-note, .noscript { padding: var(--gap-6); color: var(--text-muted); }

.conn-banner {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--topbar-h) + 10px); z-index: 60;
  display: flex; gap: var(--gap-2); align-items: center; max-width: min(640px, 92vw);
  background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn); border-radius: var(--radius);
  padding: var(--gap-2) var(--gap-4); box-shadow: var(--shadow);
}
.conn-banner .icon { color: var(--warn); }

.toasts { position: fixed; right: var(--gap-4); bottom: var(--gap-4); z-index: 70; display: flex; flex-direction: column; gap: var(--gap-2); align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: var(--gap-2); align-items: center; max-width: 440px;
  background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease-out;
}
.toast .icon { color: var(--bg); }
.toast-act { font: inherit; font-weight: 700; background: none; border: 1px solid currentColor; color: inherit; border-radius: 4px; padding: 2px 10px; min-height: 28px; cursor: pointer; margin-left: var(--gap-2); }
.toast-out { opacity: 0; transition: opacity 0.25s; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------------------------------------------------------------------------------------------
   Controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--target); padding: 5px 14px; border-radius: 4px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.94rem; font-weight: 550; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { padding: 3px 10px; font-size: 0.87rem; min-height: 28px; }
.btn.icon-only { padding: 4px; width: var(--target); }
.link-btn {
  background: none; border: none; padding: 0; margin: 0; font: inherit; color: var(--accent);
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; min-height: var(--chip); text-align: left;
}
.input, .select, .textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 4px; padding: 5px 10px; min-height: var(--target); max-width: 100%;
}
.input, .textarea { width: 100%; }
.select.small { min-height: 28px; padding: 2px 8px; font-size: 0.88rem; }
.textarea { resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); opacity: 1; }
.input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
input[type="date"].input { width: auto; height: var(--target); padding-top: 2px; padding-bottom: 2px; }
.select { height: var(--target); }
.select.small { height: 28px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--gap-3); min-width: 0; }
.field-label { font-weight: 600; font-size: 0.93rem; margin: 0; padding: 0; }
.field-help { color: var(--text-muted); font-size: 0.87rem; margin: 0; }
.field-error { color: var(--bad); font-size: 0.9rem; margin: 0; font-weight: 550; min-height: 0; }
.field-error:empty { display: none; }
.check { display: flex; gap: var(--gap-2); align-items: center; min-height: var(--target); cursor: pointer; }
.radio-group { border: 0; margin: 0 0 var(--gap-3); padding: 0; min-width: 0; display: grid; gap: var(--gap-2); }
.radio-group.cols-2 { grid-template-columns: 1fr 1fr; }
.radio-group legend { margin-bottom: var(--gap-2); }
.radio-card {
  display: flex; gap: var(--gap-3); align-items: flex-start; padding: var(--gap-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.radio-card:hover { border-color: var(--border-strong); }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin-top: 3px; }
.radio-text { display: flex; flex-direction: column; }
.radio-label { font-weight: 600; }
.radio-note { color: var(--text-muted); font-size: 0.87rem; }
.save-note { font-size: 0.87rem; color: var(--text-muted); }
.save-note.ok { color: var(--ok); font-weight: 600; }
.switch-label { display: inline-flex; align-items: center; gap: var(--gap-2); cursor: pointer; min-height: var(--target); font-weight: 550; }
.switch {
  appearance: none; -webkit-appearance: none; width: 40px !important; height: 24px !important; border-radius: 999px;
  background: var(--grey-bg); border: 1px solid var(--border-strong); position: relative; cursor: pointer; transition: background 0.15s;
}
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--grey); transition: transform 0.15s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(16px); background: var(--accent-text); }

.show-all { display: flex; flex-direction: column; gap: 0; }
.show-all-hint { font-size: 0.82rem; color: var(--text-muted); margin-left: 48px; margin-top: -4px; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; }
.seg-btn { font: inherit; font-size: 0.9rem; font-weight: 550; padding: 3px 14px; min-height: 32px; background: var(--surface); color: var(--text); border: 0; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn[aria-pressed="true"] { background: var(--text); color: var(--bg); }

/* chips and stamps: always a word, never colour alone */
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--chip); padding: 1px 9px;
  border-radius: 999px; font-size: 0.78rem; font-weight: 650; letter-spacing: 0.02em; line-height: 1.3;
  border: 1px solid currentColor; white-space: nowrap; vertical-align: middle;
}
.tone-ok { color: var(--ok); background: var(--ok-bg); }
.tone-warn { color: var(--warn); background: var(--warn-bg); }
.tone-bad { color: var(--bad); background: var(--bad-bg); }
.tone-grey { color: var(--grey); background: var(--grey-bg); }
.tone-info { color: var(--accent); background: var(--info-bg); }
.tone-muted { color: var(--text-muted); background: transparent; }
.tone-hole { color: var(--hole-text); background: var(--hole-bg); }
.spin-chip .icon { animation: spin 1s linear infinite; }

.doc-stamp {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; line-height: 1; padding: 4px 8px 4px 7px; min-height: var(--chip);
  border: 1.5px solid currentColor; border-radius: 3px; white-space: nowrap; vertical-align: middle;
}
.doc-stamp.doc-none { color: var(--doc-none-text); background: var(--hole-bg); }
.doc-stamp.doc-thin { color: var(--doc-thin-text); }
.doc-stamp.doc-some { color: var(--doc-some-text); }
.doc-stamp.doc-well { color: var(--doc-well-text); }
.doc-stamp.doc-unchecked { color: var(--text-muted); border-style: dashed; }
.doc-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px var(--mk-ring); }
.doc-dot.doc-none, .doc-none > .doc-dot { background: var(--doc-none); }
.doc-dot.doc-thin, .doc-thin > .doc-dot { background: var(--doc-thin); }
.doc-dot.doc-some, .doc-some > .doc-dot { background: var(--doc-some); }
.doc-dot.doc-well, .doc-well > .doc-dot { background: var(--doc-well); }
.doc-dot.doc-unchecked, .doc-unchecked > .doc-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--text-muted); }
.doc-stamp .doc-dot { width: 8px; height: 8px; box-shadow: none; }
.doc-label { color: var(--text-muted); font-size: 0.9rem; }
.doc-line { display: inline-flex; gap: var(--gap-2); align-items: center; flex-wrap: wrap; }

.cue-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--gap-2) 0 0; }
.cue-badge {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--chip); padding: 1px 9px 1px 7px; border-radius: 3px;
  font-size: 0.8rem; font-weight: 600; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); cursor: help;
}
.cue-swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.cue-hush .cue-swatch { background: var(--cue-hush); }
.cue-firsthand .cue-swatch { background: var(--cue-firsthand); }
.cue-question .cue-swatch { background: var(--cue-question); }
.cue-unanswered .cue-swatch { background: var(--cue-unanswered); }
.cue-removed .cue-swatch { background: var(--cue-removed); }
.cue-specific .cue-swatch { background: var(--cue-specific); }
.cue-slip .cue-swatch { background: var(--cue-slip); }
/* "Let slip" is the strongest cue: a filled badge, a solid underline in text */
.cue-badge.cue-slip { background: var(--cue-slip); border-color: var(--cue-slip); color: var(--cue-slip-text); font-weight: 700; }
.cue-badge.cue-slip .cue-swatch { background: var(--cue-slip-text); border-radius: 50%; }

.inline-msg {
  display: flex; gap: var(--gap-2); align-items: center; flex-wrap: wrap; padding: var(--gap-2) var(--gap-3);
  border-radius: var(--radius); border: 1px solid currentColor; margin: 0 0 var(--gap-3);
}
.inline-msg > span { color: var(--text); flex: 1 1 260px; }
.inline-msg .btn { margin-left: auto; }
.loading { display: flex; gap: var(--gap-2); align-items: center; color: var(--text-muted); padding: var(--gap-3) 0; margin: 0; }
.loading .icon { animation: spin 1s linear infinite; }

.empty { text-align: center; padding: var(--gap-6) var(--gap-4); color: var(--text-muted); max-width: 600px; margin: var(--gap-4) auto; }
.empty-icon { width: 34px; height: 34px; color: var(--border-strong); margin-bottom: var(--gap-2); }
.empty-title { color: var(--text); font-weight: 650; }
.empty-text { color: var(--text); font-size: 1.02rem; }
.empty-actions { display: flex; gap: var(--gap-2); justify-content: center; flex-wrap: wrap; margin-top: var(--gap-3); }

.progress { position: relative; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin: 6px 0; }
.progress-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }
.progress.indeterminate .progress-fill { width: 30%; animation: indet 1.6s ease-in-out infinite; }
@keyframes indet { 0% { left: -30%; } 100% { left: 100%; } }

.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-family: var(--mono); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 650; background: var(--surface-2); }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* dialogs */
.dialog {
  border: 1px solid var(--border); border-radius: 8px; padding: 0; background: var(--surface); color: var(--text);
  width: min(540px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-lg);
}
.dialog-wide { width: min(700px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(12, 12, 10, 0.5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-3); padding: var(--gap-4) var(--gap-5) var(--gap-2); }
.dialog-title { margin: 0; font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.dialog-desc { padding: 0 var(--gap-5); color: var(--text-muted); }
.dialog-body { padding: var(--gap-2) var(--gap-5) var(--gap-3); overflow: auto; max-height: calc(100vh - 240px); }
.dialog-actions { display: flex; gap: var(--gap-2); justify-content: flex-end; flex-wrap: wrap; padding: var(--gap-3) var(--gap-5) var(--gap-4); border-top: 1px solid var(--border); }
.confirm-text { font-size: 1.02rem; }
.merge-results { display: grid; gap: var(--gap-2); margin-top: var(--gap-2); }

/* ---------------------------------------------------------------------------------------------
   Screens: common */

.screen { padding: var(--gap-5) var(--gap-6) 64px; max-width: 1320px; margin: 0 auto; }
.screen-head { margin-bottom: var(--gap-4); }
.screen-head.compact { margin-bottom: var(--gap-3); }
.screen-head h1 { margin-bottom: 4px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--gap-4); flex-wrap: wrap; }
.head-actions { display: flex; gap: var(--gap-2); align-items: center; flex-wrap: wrap; }
.eyebrow { font-family: var(--mono); font-size: 0.74rem; font-weight: 650; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 6px; }
.lede { color: var(--text-muted); font-size: 1.04rem; max-width: 70ch; margin: 0; }
.lede-more { display: flex; gap: var(--gap-2); align-items: baseline; margin-top: 6px; font-size: 0.96rem; }
.lede-more .icon { color: var(--cue-slip); flex: none; position: relative; top: 2px; }
.h1-sub { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 0.62em; color: var(--text-muted); letter-spacing: 0; }
.result-count { color: var(--text-muted); font-size: 0.9rem; margin: var(--gap-2) 0; }
.reading { max-width: var(--reading); }
.more-slot { margin: var(--gap-4) 0; display: flex; justify-content: center; }
.more-slot:empty { display: none; }
.row-actions { display: flex; gap: var(--gap-2); align-items: center; flex-wrap: wrap; margin: var(--gap-3) 0 0; }

.sec-head { display: flex; align-items: center; gap: var(--gap-3); margin: 0 0 var(--gap-3); min-height: 28px; }
.sec-title { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text); margin: 0; white-space: nowrap; }
.sec-count { color: var(--text-muted); font-weight: 500; letter-spacing: 0.04em; }
.sec-rule { flex: 1; height: 1px; background: var(--border); min-width: 16px; }
.sec-extra { display: flex; gap: var(--gap-2); align-items: center; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: var(--gap-4) var(--gap-5); margin-bottom: var(--gap-4); }
.panel-h { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; margin: 0 0 var(--gap-2); }
.panel-sub { font-size: 0.88rem; font-weight: 650; margin: var(--gap-3) 0 var(--gap-1); }

.filter-bar { display: flex; align-items: flex-end; gap: var(--gap-4); flex-wrap: wrap; margin: var(--gap-3) 0 var(--gap-2); }
.filter-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.filter-field.grow { flex: 1 1 260px; max-width: 420px; }
.filter-field.end { margin-left: auto; }
.filter-label { font-family: var(--mono); font-size: 0.72rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }

.unverified-note { display: flex; gap: var(--gap-2); align-items: flex-start; color: var(--text-muted); font-size: 0.9rem; margin: 0 0 var(--gap-4); max-width: 90ch; }
.unverified-note .icon { margin-top: 3px; color: var(--text-faint); }

.counts { color: var(--text-muted); font-size: 0.9rem; margin: var(--gap-2) 0 0; }
.count-link { color: var(--accent); font-weight: 600; }
.big-counts { font-size: 0.98rem; }

/* marked text */
.marked { overflow-wrap: anywhere; }
.mk { padding: 0 1px; border-radius: 2px; }
.mk-hit { background: var(--mark); color: var(--mark-text); }
.mk-entity { background: transparent; color: inherit; box-shadow: inset 0 -2px 0 var(--accent); padding: 0; border-radius: 0; }
.mk-entity .mk-link { color: inherit; text-decoration: none; }
.mk-entity:hover { background: var(--accent-soft); }
.mk-entity .mk-link:focus-visible { outline-offset: 1px; }
.mk-cue { position: relative; color: inherit; background: transparent; border-bottom: 2px dotted currentColor; padding: 0; border-radius: 0; }
.mk-cue.cue-hush { background: color-mix(in srgb, var(--cue-hush) 14%, transparent); border-bottom-color: var(--cue-hush); }
.mk-cue.cue-firsthand { background: color-mix(in srgb, var(--cue-firsthand) 14%, transparent); border-bottom-color: var(--cue-firsthand); }
.mk-cue.cue-question { background: color-mix(in srgb, var(--cue-question) 14%, transparent); border-bottom-color: var(--cue-question); }
.mk-cue.cue-unanswered { background: color-mix(in srgb, var(--cue-unanswered) 14%, transparent); border-bottom-color: var(--cue-unanswered); }
.mk-cue.cue-removed { background: color-mix(in srgb, var(--cue-removed) 14%, transparent); border-bottom-color: var(--cue-removed); }
.mk-cue.cue-specific { background: color-mix(in srgb, var(--cue-specific) 14%, transparent); border-bottom-color: var(--cue-specific); }
.mk-cue.cue-slip { background: var(--cue-slip-bg); border-bottom: 2px solid var(--cue-slip); font-weight: 650; }
.mk-entity.mk-hit, .mk-cue.mk-hit { background: var(--mark); color: var(--mark-text); }
.mk-cue[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 20; white-space: nowrap;
  background: var(--text); color: var(--bg); font: 600 0.78rem/1.3 var(--font); padding: 4px 8px; border-radius: 4px; box-shadow: var(--shadow);
  pointer-events: none;
}

/* ---------------------------------------------------------------------------------------------
   Holes */

.welcome {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--gap-4); align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--hole); border-radius: 8px;
  padding: var(--gap-5); margin-bottom: var(--gap-5); box-shadow: var(--shadow);
}
.welcome-mark { width: 52px; height: 52px; border-radius: 50%; background: var(--hole-bg); color: var(--hole); display: grid; place-items: center; }
.welcome-mark .icon { width: 28px; height: 28px; }
.welcome-h { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; margin-bottom: var(--gap-2); }
.welcome-progress { max-width: 560px; margin: var(--gap-3) 0; }
.welcome-msg { color: var(--text-muted); font-size: 0.92rem; }
.welcome-actions { display: flex; gap: var(--gap-2); flex-wrap: wrap; margin-top: var(--gap-3); }

.updating-note { display: flex; align-items: center; gap: var(--gap-2); flex-wrap: wrap; margin: 0 0 var(--gap-3); padding: 6px var(--gap-3); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 4px; background: var(--surface); font-size: 0.9rem; color: var(--text-muted); }
.updating-note .icon { color: var(--accent); animation: spin 1s linear infinite; }
.updating-note span { color: var(--text); }
/* The rule under the tabs is an inset shadow, not a border the tabs overlap with a negative margin: that
   made the bar 1 px taller than its box, and overflow-x: auto then showed a vertical scrollbar. The
   selected tab's underline paints over the rule. */
.lens-tabs { display: flex; gap: 0; box-shadow: inset 0 -1px 0 var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.lens-tab {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-weight: 600; font-size: 0.95rem; color: var(--text-muted);
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 14px 7px; min-height: 42px; cursor: pointer; white-space: nowrap;
}
.lens-tab:hover { color: var(--text); }
.lens-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--hole); }
.tab-count { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; line-height: 1.5; }
.lens-tab[aria-selected="true"] .tab-count { color: var(--text); }
.lens-line { margin: var(--gap-3) 0 var(--gap-2); font-family: var(--serif); font-style: italic; font-size: 1.02rem; color: var(--text); }
.switch-slot { margin-left: auto; }

.hole-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--gap-3); }
.hole-list > li { min-width: 0; }
.hole-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--gap-4); position: relative;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--doc-well); border-radius: 6px;
  padding: var(--gap-4) var(--gap-5) var(--gap-4) var(--gap-4); box-shadow: var(--shadow);
}
.hole-card.ranked { grid-template-columns: 2.4rem minmax(0, 1fr) auto; padding-left: var(--gap-3); }
.hole-card.doc-none { border-left-color: var(--doc-none); }
.hole-card.doc-thin { border-left-color: var(--doc-thin); }
.hole-card.doc-some { border-left-color: var(--doc-some); }
.hole-card.doc-unchecked { border-left-color: var(--border-strong); border-left-style: dashed; }
.hole-card:hover { border-color: var(--border-strong); }
.hole-card.doc-none:hover { border-left-color: var(--doc-none); }
.hole-card.doc-thin:hover { border-left-color: var(--doc-thin); }
.hole-card.doc-some:hover { border-left-color: var(--doc-some); }
.hc-rank { font-family: var(--mono); font-size: 0.9rem; color: var(--text-faint); padding-top: 3px; text-align: right; font-variant-numeric: tabular-nums; }
.hc-main { min-width: 0; }
.hc-eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 2px; }
.kind { font-family: var(--mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.hc-lenses { display: inline-flex; flex-wrap: wrap; gap: 0; font-size: 0.8rem; color: var(--text-muted); }
.lens-word + .lens-word::before { content: "\00B7"; margin: 0 6px; color: var(--text-faint); }
.hc-lenses::before { content: "\2014"; margin-right: 8px; color: var(--text-faint); }
.lens-tag { display: inline-flex; align-items: center; min-height: var(--chip); font-size: 0.78rem; color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 9px; text-decoration: none; }
a.lens-tag:hover { border-color: var(--border-strong); color: var(--text); }
.hc-name { font-family: var(--serif); font-size: 1.32rem; font-weight: 600; margin: 0 0 6px; line-height: 1.25; }
.hc-link { color: var(--text); text-decoration: none; }
.hc-link:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.hc-link::before { content: ""; position: absolute; inset: 0; z-index: 0; }
.hole-card a:not(.hc-link), .hole-card button, .hole-card .spark-fig { position: relative; z-index: 1; }
.hc-doc { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 var(--gap-2); }
.reasons { margin: 0; padding-left: 1.1em; color: var(--text); }
.reasons li { margin: 2px 0; }
.reasons li::marker { color: var(--text-faint); }
.reasons.big li { margin: 6px 0; font-size: 1.02rem; }
.hc-snippet { margin: var(--gap-3) 0 0; padding: 4px 0 4px var(--gap-3); border-left: 2px solid var(--border); font-family: var(--serif); font-size: 0.95rem; color: var(--text); }
.hc-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--gap-2); min-width: 128px; }
.hole-card.compact { padding: var(--gap-3) var(--gap-4); }
.hole-card.compact .hc-name { font-size: 1.15rem; }

.spark-fig { line-height: 0; }
.spark { display: block; overflow: visible; }
.spark-base { stroke: var(--border-strong); stroke-width: 1; }
.spark-bar { fill: var(--text-faint); }
.spark-bar.now { fill: var(--hole); }
.spark-hit { fill: transparent; }
.spark-col:hover .spark-bar { fill: var(--text); }
.spark-col:hover .spark-bar.now { fill: var(--hole); }
.spark-yr { font: 600 9px var(--mono); fill: var(--text-muted); }

.interest.chip { font-size: 0.74rem; }
.status-ctl { display: flex; flex-direction: column; gap: 3px; }

/* ---------------------------------------------------------------------------------------------
   Leads (quote cards) */

.lens-tab.tab-slip .cue-swatch { background: var(--cue-slip); width: 10px; height: 10px; border-radius: 50%; }
.lead-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--gap-3); max-width: 1040px; }
.lead-list > li { min-width: 0; }
.lead-card {
  display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); gap: var(--gap-3); position: relative;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 6px;
  padding: var(--gap-4) var(--gap-5) var(--gap-4) var(--gap-3); box-shadow: var(--shadow);
}
.lead-card.lead-slip { border-left-color: var(--cue-slip); }
.lead-card.lead-hush { border-left-color: var(--cue-hush); }
.lead-card.lead-firsthand { border-left-color: var(--cue-firsthand); }
.lead-card:hover { border-color: var(--border-strong); }
.lead-card.lead-slip:hover { border-left-color: var(--cue-slip); }
.lead-card.lead-hush:hover { border-left-color: var(--cue-hush); }
.lead-card.lead-firsthand:hover { border-left-color: var(--cue-firsthand); }
.lc-main { min-width: 0; }
.lc-where { margin-bottom: 2px; }
.lc-thread { font-style: normal; font-weight: 600; color: var(--text); }
.lc-note { display: flex; gap: 6px; align-items: center; font-size: 0.84rem; color: var(--text-muted); margin: 0 0 4px; }
.lc-quote { margin: var(--gap-2) 0 0; padding: 2px 0 2px var(--gap-4); border-left: 3px solid var(--border); }
.lc-title { font-family: var(--serif); font-size: 1.08rem; font-weight: 600; margin: 0 0 4px; }
.lc-text { font-family: var(--serif); font-size: 1.04rem; line-height: 1.62; margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.lc-why { margin: var(--gap-3) 0 0; }
.lc-why-h, .lc-ents .chips-label { font-family: var(--mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 2px; }
.lc-why .reasons { font-size: 0.94rem; }
.lc-ents { display: flex; align-items: baseline; gap: 6px var(--gap-3); margin: var(--gap-3) 0 0; }
.lc-ents .chips-label { flex: none; white-space: nowrap; }
.lc-ent-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px var(--gap-3); flex: 1 1 0; min-width: 0; }
.lc-ent { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }   /* a long name drops its stamp below it on a narrow screen */
.lc-ent .entity-chip { max-width: 100%; }
.lc-ent .doc-stamp { font-size: 0.62rem; padding: 3px 6px; min-height: 20px; }
.lc-actions { margin-top: var(--gap-3); padding-top: var(--gap-2); border-top: 1px solid var(--border); }
.lc-actions .lc-copy { margin-left: auto; }
.cite-text { font-family: var(--mono); font-size: 0.86rem; }
/* round 4: a personal plea's caution, the whole passage, and leads marked "Not useful" */
.lc-caution { display: flex; gap: 6px; align-items: flex-start; font-size: 0.88rem; font-weight: 600; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 4px 8px; margin: 2px 0 6px; }
.lc-caution .icon { flex: none; margin-top: 3px; }
.lc-caution > span { color: var(--text); min-width: 0; }
.lc-whole-line { margin: 4px 0 0 var(--gap-4); }
.lead-card.is-dismissed { border-left-style: dashed; background: var(--surface-2); }
.lead-card.is-dismissed .lc-quote { opacity: 0.85; }
.lead-gone { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--gap-3); padding: var(--gap-2) var(--gap-4); border: 1px dashed var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text-muted); font-size: 0.9rem; }
.lead-gone > span { flex: 1 1 220px; min-width: 0; }
.lead-dismissed-ctl .switch-label .tab-count { margin-left: 2px; }
.lead-dismissed-ctl .switch:disabled { opacity: 0.5; cursor: not-allowed; }
.lead-dismissed-ctl .switch:disabled + span { color: var(--text-muted); }
.hc-side .unverified, .hole-chips .unverified { white-space: nowrap; }

/* ---------------------------------------------------------------------------------------------
   Hole page */

.trail { display: flex; align-items: center; flex-wrap: wrap; gap: 4px var(--gap-3); margin: 0 0 var(--gap-3); font-size: 0.9rem; }
.trail-label { font-family: var(--mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.crumbs { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0; margin: 0; }
.crumbs li { display: inline-flex; align-items: center; }
.crumbs li + li::before { content: "\203A"; color: var(--text-faint); margin: 0 7px; font-size: 1.1em; }
.crumbs a { display: inline-flex; align-items: center; min-height: var(--chip); }
.crumbs [aria-current="page"] { font-weight: 650; }
.trail-all { margin-left: auto; font-size: 0.85rem; }

.hole-head { border-bottom: 2px solid var(--text); padding-bottom: var(--gap-4); margin-bottom: var(--gap-3); }
.hole-title-row { display: flex; align-items: baseline; gap: var(--gap-3); flex-wrap: wrap; }
.hole-name { font-size: 2.4rem; margin: 0 0 4px; }
.hole-chips { display: flex; align-items: center; gap: var(--gap-2); }
.score { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); cursor: help; border-bottom: 1px dotted var(--text-faint); }
.aliases { color: var(--text); font-size: 0.95rem; margin: 0 0 var(--gap-2); }
.hole-doc { display: flex; align-items: center; gap: var(--gap-3); flex-wrap: wrap; margin: var(--gap-2) 0 0; }
.hole-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--gap-3) var(--gap-4); flex-wrap: wrap; margin-top: var(--gap-4); }
.status-ctl .select { min-width: 190px; }
.action-btns { display: flex; gap: var(--gap-2); flex-wrap: wrap; }

.hole-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--gap-4); align-items: start; }
.hole-main, .hole-side { min-width: 0; }
.side-panel { padding: var(--gap-4); }
.why .reasons { margin-bottom: var(--gap-2); }
.lens-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: var(--gap-2) 0 0; }

.item-list { list-style: none; padding: 0; margin: 0; }
.item-list > li + li { border-top: 1px solid var(--border); }
.item-card { padding: var(--gap-3) 0; min-width: 0; }
.results .item-card { padding: var(--gap-4) 0; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--gap-3); }
.item-meta { color: var(--text-muted); font-size: 0.86rem; margin: 0 0 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; }
.src { font-weight: 650; color: var(--text); }
.author { font-family: var(--mono); font-size: 0.82rem; }
.item-tag { font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; white-space: nowrap; }
.is-record .item-tag { color: var(--accent); border-color: currentColor; }
.is-press .item-tag { color: var(--text); border-color: var(--border-strong); }
.item-title { font-family: var(--serif); font-size: 1.08rem; font-weight: 600; margin: 2px 0 4px; }
.item-text { margin: 4px 0 0; font-family: var(--serif); font-size: 0.99rem; line-height: 1.6; white-space: pre-line; }
.is-claim .item-text { border-left: 3px solid var(--border); padding-left: var(--gap-3); }
.is-record .item-text { font-family: var(--font); font-size: 0.95rem; }
.item-actions { display: flex; gap: var(--gap-3); align-items: center; flex-wrap: wrap; margin: var(--gap-2) 0 0; }
.small-link { font-size: 0.88rem; display: inline-flex; align-items: center; gap: 4px; min-height: var(--chip); }
.ext-link .icon { width: 13px; height: 13px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px var(--gap-4); margin: var(--gap-2) 0 0; }
.fact { min-width: 0; }
.fact dt { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.fact dd { margin: 0; font-size: 0.92rem; overflow-wrap: anywhere; }
.entity-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: var(--gap-2) 0 0; }
.chips-label { font-size: 0.82rem; color: var(--text-muted); }
.entity-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--chip); padding: 1px 9px 1px 4px; border-radius: 3px;
  border: 1px solid var(--border-strong); color: var(--text); text-decoration: none; font-size: 0.86rem; font-weight: 550; background: var(--surface);
}
.entity-chip:hover { border-color: var(--accent); color: var(--accent); }
.entity-chip.high { border-left: 3px solid var(--hole); }
.holes-matching .entity-chips { margin: var(--gap-3) 0 0; }
/* "Single source" beside a name in a chip, a list row or a popup: as compact as the stamp next to it */
.entity-chip .single-source, .conn-tags .single-source, .lc-ent .single-source { font-size: 0.66rem; min-height: 20px; padding: 0 6px; }
.scope-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--gap-2); margin: var(--gap-3) 0 0; font-size: 0.92rem; overflow-wrap: anywhere; }
.communities { font-size: 0.92rem; margin: 4px 0 0; }
.post-link { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: var(--gap-3) 0 0; font-size: 0.92rem; overflow-wrap: anywhere; }
.kind-mini { font-family: var(--mono); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; background: var(--surface-2); color: var(--text-muted); padding: 1px 4px; border-radius: 2px; }

.timeline-fig { margin: 0; }
.timeline { width: 100%; height: auto; display: block; overflow: visible; }
.tl-base { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.tl-tick { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.tl-year { font: 600 11px var(--mono); fill: var(--text-muted); }
.tl-bar { fill: var(--text-faint); }
.tl-bar.peak { fill: var(--hole); }
.tl-hit { fill: transparent; }
.tl-col:hover .tl-bar { fill: var(--text); }
.tl-col:hover .tl-bar.peak { fill: var(--hole); }
.tl-peak { font: 600 11px var(--font); fill: var(--text); }
.fig-cap { font-size: 0.84rem; color: var(--text-muted); margin-top: 4px; }

.checks-list { list-style: none; padding: 0; margin: 0; }
.check-row { padding: var(--gap-3) 0; border-top: 1px solid var(--border); }
.check-head { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-2); }
.check-name { font-weight: 650; }
.check-label { margin: 4px 0 0; font-size: 0.93rem; }
.check-not_run .check-label { color: var(--text-muted); }
.check-links { margin: 4px 0 0; padding-left: 1.1em; font-size: 0.88rem; }
.check-links li { margin: 2px 0; }
.check-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-2); flex-wrap: wrap; margin: 6px 0 0; font-size: 0.84rem; }
.check-foot .btn { margin-left: auto; }
.doc-summary { display: flex; align-items: center; gap: var(--gap-2); flex-wrap: wrap; font-size: 0.9rem; }

.mini-map { height: 220px; border-radius: 6px; border: 1px solid var(--border); overflow: hidden; background: var(--surface-2); }
.map-fail { padding: var(--gap-4); }

.conn-list { list-style: none; padding: 0; margin: var(--gap-2) 0 0; }
.conn-row { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-2); padding: 7px 0; border-top: 1px solid var(--border); }
.conn-link {
  display: flex; flex-direction: column; min-width: 0; text-decoration: none; color: var(--text); font: inherit; text-align: left;
  background: none; border: 0; padding: 2px 0; cursor: pointer; min-height: var(--target);
}
.conn-name { font-weight: 650; color: var(--accent); }
.conn-link:hover .conn-name { text-decoration: underline; }
.conn-meta { font-size: 0.82rem; color: var(--text-muted); }
.conn-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.new-conn {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text); border: 1.5px dashed var(--text-muted);
  border-radius: 3px; padding: 1px 6px; white-space: nowrap;
}
.conn-tags .doc-stamp { font-size: 0.64rem; padding: 3px 6px; min-height: 20px; }

/* ---------------------------------------------------------------------------------------------
   Thread */

.thread-head { border-bottom: 2px solid var(--text); padding-bottom: var(--gap-3); margin-bottom: var(--gap-3); }
.thread-title { font-size: 2rem; }
.post { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: var(--gap-4) var(--gap-5); margin-bottom: var(--gap-4); max-width: 900px; }
.post-text { font-family: var(--serif); font-size: 1.06rem; line-height: 1.65; white-space: pre-line; }
.thread-bar { display: flex; align-items: center; gap: var(--gap-3) var(--gap-5); flex-wrap: wrap; margin-bottom: var(--gap-3); }
.thread-bar .result-count { margin: 0; }
.legend-pop { position: relative; font-size: 0.9rem; }
.legend-pop summary { cursor: pointer; color: var(--accent); min-height: var(--chip); display: inline-flex; align-items: center; }
.legend-list { list-style: none; padding: var(--gap-2) var(--gap-3); margin: 6px 0 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); display: grid; gap: 6px; }
.comments { list-style: none; padding: 0; margin: 0; max-width: 960px; }
.comment { padding: var(--gap-2) 0 var(--gap-2) var(--gap-4); border-left: 2px solid var(--border); margin-bottom: 2px; }
.comment.depth-0 { border-left-color: var(--border-strong); }
.comment.depth-1 { margin-left: 22px; }
.comment.depth-2 { margin-left: 44px; }
.comment.depth-3 { margin-left: 66px; }
.comment.depth-4 { margin-left: 88px; }
.comment.depth-5 { margin-left: 110px; }
.comment.depth-6 { margin-left: 132px; }
.comment.depth-7, .comment.depth-8 { margin-left: 154px; }
.comment.has-marks { border-left-color: var(--accent); }
.comment.focus-item { background: var(--accent-soft); border-left-color: var(--accent); border-radius: 0 6px 6px 0; }
.comment-text { font-family: var(--serif); font-size: 0.99rem; line-height: 1.6; white-space: pre-line; }
.removed-box {
  display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-style: italic; font-size: 0.92rem;
  border: 1px dashed var(--border-strong); border-radius: 4px; padding: 4px 10px; background: var(--surface-2);
}
.comment.removed.jumped .removed-box { border-color: var(--accent); }

/* ---------------------------------------------------------------------------------------------
   Search */

.search-form { display: flex; gap: var(--gap-2); max-width: 820px; }
.big-input { font-size: 1.1rem; min-height: 42px; padding: 6px 14px; }
.search-form .btn { min-height: 42px; padding: 6px 18px; }
.filter-bar.wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: var(--gap-3) var(--gap-4); gap: var(--gap-3) var(--gap-4); }
.filter-bar.wrap .select { min-width: 140px; }
.list-empty, .list-loading { list-style: none; }
.results { max-width: 940px; }

/* ---------------------------------------------------------------------------------------------
   Map */

.screen.map-screen { max-width: none; padding-bottom: var(--gap-4); }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: var(--gap-4); height: calc(100vh - var(--topbar-h) - 150px); min-height: 460px; }
.big-map { height: 100%; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.map-panel { overflow-y: auto; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: var(--gap-4); }
.map-panel .show-all { margin: var(--gap-2) 0; }
.layers .check { font-size: 0.94rem; }
.spend-key { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--spend); background: color-mix(in srgb, var(--spend) 20%, transparent); flex: none; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 0.9rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.places { margin-top: var(--gap-4); border-top: 1px solid var(--border); padding-top: var(--gap-3); }
.place-list { list-style: none; padding: 0; margin: 0; }
.place-btn {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%;
  font: inherit; font-size: 0.92rem; text-align: left; background: none; border: 0; border-radius: 4px; padding: 5px 6px; min-height: var(--target); color: var(--text); cursor: pointer;
}
.place-btn:hover { background: var(--hover); }
.place-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-meta { font-size: 0.8rem; color: var(--text-muted); }
.no-basemap { background: var(--surface-2); }

.leaflet-container { font: 13px/1.45 var(--font); background: var(--surface-2); }
.leaflet-container a { color: var(--accent); }
.leaflet-pane path.place-mk { stroke: var(--mk-ring); stroke-width: 1.5; fill-opacity: 0.95; }
.leaflet-pane path.place-mk.doc-none { fill: var(--doc-none); }
.leaflet-pane path.place-mk.doc-thin { fill: var(--doc-thin); }
.leaflet-pane path.place-mk.doc-some { fill: var(--doc-some); }
.leaflet-pane path.place-mk.doc-well { fill: var(--doc-well); }
.leaflet-pane path.place-mk.doc-unchecked { fill: var(--surface); fill-opacity: 0.9; stroke: var(--text-muted); stroke-width: 2; stroke-dasharray: 3 2; }
.leaflet-pane path.spend-mk { fill: var(--spend); fill-opacity: 0.14; stroke: var(--spend); stroke-width: 1.5; stroke-opacity: 0.7; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper { border-radius: 6px; }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-muted); width: 28px; height: 28px; font-size: 20px; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 88%, transparent) !important; color: var(--text-muted); }
.leaflet-bar a { background: var(--surface); color: var(--text); border-bottom-color: var(--border); width: 32px !important; height: 32px !important; line-height: 32px !important; }
.leaflet-bar a:hover { background: var(--surface-2); color: var(--text); }
.leaflet-tooltip { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow); font-weight: 600; }
.leaflet-tooltip-top::before { border-top-color: var(--surface); }
.leaflet-control-scale-line { background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--text-muted); border-color: var(--text-muted); }
.map-note { display: flex; gap: 6px; align-items: flex-start; max-width: 420px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 5px 9px; font-size: 0.84rem; box-shadow: var(--shadow); }
.popup-kind { font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin: 0; }
.popup-title { font-family: var(--serif); font-size: 1.1rem; margin: 2px 0 6px; }
.popup-text { margin: 0 0 6px; font-size: 0.88rem; }
.popup .btn.primary { color: var(--accent-text); }

/* ---------------------------------------------------------------------------------------------
   Graph */

.graph-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--gap-4); flex-wrap: wrap; }
.graph-head h1 { font-size: 1.9rem; }
.graph-controls { display: flex; align-items: center; gap: var(--gap-4); flex-wrap: wrap; }
.graph-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--gap-4); align-items: start; }
.graph-stage { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; min-height: 440px; position: relative; overflow: hidden; }
.graph-svg { display: block; width: 100%; height: auto; user-select: none; }
.edge { stroke: var(--edge); stroke-opacity: 0.55; stroke-linecap: round; }
.edge.side { stroke-opacity: 0.16; }
.edge.new { stroke-dasharray: 6 5; stroke-opacity: 0.85; }
.graph-svg.hovering .edge { stroke-opacity: 0.08; }
.graph-svg.hovering .edge.hot { stroke: var(--text); stroke-opacity: 0.9; }
.node { cursor: pointer; }
.node-hit { fill: transparent; }
.node-dot { stroke: var(--surface); stroke-width: 2; fill: var(--doc-well); }
.node.doc-none .node-dot { fill: var(--doc-none); }
.node.doc-thin .node-dot { fill: var(--doc-thin); }
.node.doc-some .node-dot { fill: var(--doc-some); }
.node.doc-unchecked .node-dot { fill: var(--surface); stroke: var(--text-muted); stroke-dasharray: 3 2; }
.node-ring { fill: none; stroke: var(--text); stroke-width: 1.5; }
.node-label { font: 600 12px var(--font); fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.node.centre .node-label { font-size: 14px; font-weight: 700; }
.node.quiet .node-label { opacity: 0; }
.node.hot .node-label, .node:focus .node-label { opacity: 1; }
.node.hot .node-dot { stroke: var(--text); }
.node:focus { outline: none; }
.node:focus-visible .node-hit { stroke: var(--focus); stroke-width: 2; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 6px var(--gap-4); padding: var(--gap-2) var(--gap-3); border-top: 1px solid var(--border); font-size: 0.84rem; color: var(--text-muted); }
.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-line { display: inline-block; width: 24px; height: 0; border-top: 2px solid var(--edge); }
.lg-line.dashed { border-top-style: dashed; }
.side-name { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.graph-side .conn-tags { flex-direction: row; align-items: center; }

/* ---------------------------------------------------------------------------------------------
   Notebook */

.status-strip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-2); margin: 0 0 var(--gap-5); }
.status-jump {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 7px 14px; height: 42px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600;
}
a.status-jump:hover { border-color: var(--border-strong); }
.status-jump.is-zero { color: var(--text-muted); background: transparent; border-style: dashed; font-weight: 500; }
.sj-n { font-family: var(--mono); font-size: 1.15rem; font-weight: 700; }
.trail-jump { margin-left: auto; }
.nb-group { margin-bottom: var(--gap-5); }
.nb-extra { margin-top: var(--gap-3); }
.nb-notes { background: var(--surface-2); border-left: 3px solid var(--accent); padding: var(--gap-2) var(--gap-3); margin: 0; white-space: pre-line; font-size: 0.94rem; }
.nb-notes-label { display: block; font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.nb-actions { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-2); margin: var(--gap-2) 0 0; flex-wrap: wrap; }
.trail-day { font-family: var(--serif); font-size: 1rem; font-weight: 600; margin: var(--gap-3) 0 var(--gap-1); }
.trail-list { list-style: none; padding: 0; margin: 0; }
.trail-step { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: var(--gap-3); padding: 4px 0; border-bottom: 1px dotted var(--border); }
.trail-time { color: var(--text-muted); font-size: 0.86rem; font-family: var(--mono); }
.trail-arrow { color: var(--text-faint); }

/* ---------------------------------------------------------------------------------------------
   Sources */

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: var(--gap-4); }
.stat { display: flex; flex-direction: column; gap: 2px; background: var(--surface); padding: var(--gap-3) var(--gap-4); text-decoration: none; color: var(--text); }
a.stat:hover { background: var(--hover); }
a.stat .stat-n { color: var(--accent); }
.stat-n { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-l { font-size: 0.85rem; color: var(--text-muted); }
/* a source table sits in a .table-wrap (screens/sources.js): the wrap draws the border and scrolls sideways on a phone */
.src-wrap { margin: var(--gap-2) 0; }
.src-table { border: 0; border-radius: 0; margin: 0; display: table; }
.src-name { min-width: 220px; }
.src-label { display: block; font-weight: 650; }
.src-msg { display: block; font-size: 0.84rem; color: var(--text-muted); font-weight: 400; }
.src-msg.bad { color: var(--bad); }
.src-msg.warn { color: var(--warn); }
.src-row.disabled .src-label { color: var(--text-muted); }
.src-act { text-align: right; white-space: nowrap; }
.src-name .progress { max-width: 280px; }
.about { margin-top: var(--gap-3); font-size: 0.93rem; }
.about summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: var(--chip); display: inline-flex; align-items: center; }
.about p { margin: 6px 0 0; max-width: 90ch; }
.add-form { max-width: 760px; }
.prefix-input { display: flex; align-items: stretch; max-width: 360px; }
.prefix { display: inline-flex; align-items: center; padding: 0 8px; border: 1px solid var(--border-strong); border-right: 0; border-radius: 4px 0 0 4px; background: var(--surface-2); color: var(--text-muted); font-family: var(--mono); }
.prefix-input .input { border-radius: 0 4px 4px 0; }
.ref-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 0 var(--gap-5); }
.ref-row { padding: var(--gap-3) 0; border-top: 1px solid var(--border); min-width: 0; }
.ref-head { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-2); }
.ref-name { font-weight: 650; }
.ref-what { margin: 4px 0 0; font-size: 0.92rem; }
.ref-meta { display: flex; flex-wrap: wrap; gap: 2px var(--gap-3); margin: 6px 0 0; font-size: 0.82rem; color: var(--text-muted); }
.ref-meta strong { font-weight: 600; color: var(--text); }
.ref-reason { color: var(--warn); }
.import-box { margin: var(--gap-4) 0 var(--gap-2); padding: var(--gap-3) var(--gap-4); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; }
.import-box .panel-sub { margin-top: 0; }
.import-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--gap-4); margin-top: var(--gap-3); }
.file-input { font: inherit; font-size: 0.92rem; min-height: var(--target); color: var(--text); max-width: 100%; }
.file-input::file-selector-button { font: inherit; font-weight: 550; margin-right: var(--gap-3); padding: 5px 12px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; min-height: var(--target); }
.import-results { list-style: none; padding: 0; margin: var(--gap-2) 0 0; display: grid; gap: 4px; font-size: 0.92rem; }
.import-results li { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.import-results .icon { margin-top: 3px; }
.import-ok .icon { color: var(--ok); }
.import-bad { color: var(--bad); }
.import-wait .icon { animation: spin 1s linear infinite; }
.at-time { font-family: var(--mono); font-size: 0.82rem; color: var(--text); }
.via { font-style: italic; }
.settings-grid { display: flex; flex-wrap: wrap; gap: var(--gap-3) var(--gap-5); align-items: flex-end; }
.jobs .job-list { list-style: none; padding: 0; margin: 0; }
.job { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-3); padding: var(--gap-2) 0; border-top: 1px solid var(--border); }
.job-main { min-width: 0; flex: 1; }
.job-label { font-weight: 650; margin: 0; display: flex; gap: var(--gap-2); align-items: center; flex-wrap: wrap; }
.job-msg { margin: 2px 0 0; font-size: 0.9rem; color: var(--text-muted); }
.job .progress { max-width: 420px; }

/* ---------------------------------------------------------------------------------------------
   Guide */

.guide-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--gap-6); align-items: start; }
.guide-toc { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); overflow-y: auto; font-size: 0.9rem; }
.toc-h { font-family: var(--mono); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.guide-toc ul { list-style: none; padding: 0; margin: 0; }
.guide-toc li a { display: block; padding: 3px 0; text-decoration: none; color: var(--text); min-height: var(--chip); }
.guide-toc li a:hover { color: var(--accent); text-decoration: underline; }
.guide-toc .toc-l3 a { padding-left: var(--gap-3); color: var(--text-muted); }
.guide-content { font-size: 1.02rem; }
.guide-content h2 { font-family: var(--serif); font-size: 1.55rem; font-weight: 600; margin: var(--gap-6) 0 var(--gap-3); padding-top: var(--gap-2); border-top: 1px solid var(--border); }
.guide-content h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.guide-content h3 { font-size: 1.12rem; margin: var(--gap-5) 0 var(--gap-2); }
.guide-content h4 { font-size: 1rem; margin: var(--gap-4) 0 var(--gap-2); }
.guide-content p, .guide-content li { line-height: 1.65; }
.md-list li { margin: 4px 0; }
.md-quote { border-left: 3px solid var(--hole); padding: 4px 0 4px var(--gap-3); margin: var(--gap-3) 0; font-family: var(--serif); font-style: italic; }
.md-pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: var(--gap-3); margin: var(--gap-3) 0; }
.md-pre code { background: none; border: 0; padding: 0; }

/* ---------------------------------------------------------------------------------------------
   Narrower windows (down to 900 px) */

@media (max-width: 1100px) {
  .hole-grid { grid-template-columns: minmax(0, 1fr); }
  .graph-layout { grid-template-columns: minmax(0, 1fr); }
  .map-layout { grid-template-columns: minmax(0, 1fr) 280px; }
}
@media (max-width: 980px) {
  .screen { padding: var(--gap-4) var(--gap-4) 48px; }
  .topbar-row { padding: 6px var(--gap-4) 0; }
  .fill-pill { max-width: 200px; }
  .guide-layout { grid-template-columns: minmax(0, 1fr); }
  .guide-toc { position: static; max-height: none; }
  .hole-name { font-size: 2rem; }
  .radio-group.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .import-grid { grid-template-columns: minmax(0, 1fr); }
  .switch-slot { margin-left: 0; }
  .lc-actions .lc-copy { margin-left: 0; }
}
/* phone width: the Leads cards drop the rank column and every row wraps */
@media (max-width: 600px) {
  .lead-card { grid-template-columns: minmax(0, 1fr); padding: var(--gap-3); }
  .lead-card .hc-rank { display: none; }
  .lc-quote { padding-left: var(--gap-3); }
  .lc-whole-line { margin-left: var(--gap-3); }
  .lc-ents { flex-direction: column; align-items: flex-start; }
  .screen.leads .item-head { flex-wrap: wrap; }
  .screen.leads .filter-field.grow { flex-basis: 100%; max-width: none; }
  .lead-dismissed-ctl .show-all-hint { margin-left: 0; margin-top: 0; }
}

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

@media print {
  .topbar, .toasts, .conn-banner, .skip-link, .hole-actions, .more-slot, .item-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .panel, .hole-card { box-shadow: none; border-color: #999; }
}

/* ===========================================================================================
   Warren OSINT additions: sign-in page, the person in the top bar, citations and source tiers,
   editor-only controls, the Admin screen and the Patents screen. Tokens only; no new colours.
   =========================================================================================== */

[hidden] { display: none !important; }
.wordmark-sub { font-size: 0.62em; letter-spacing: 0.22em; color: var(--masthead-muted); margin-left: 4px; }

/* sign-in */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: var(--gap-5); background: var(--bg); }
.login-main { width: min(460px, 100%); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--hole); border-radius: 8px;
  padding: var(--gap-6) var(--gap-5); box-shadow: var(--shadow); }
.login-mark { margin: 0 0 var(--gap-2); }
.login-mark .wordmark-glyph { width: 56px; height: 56px; }
.login-title { font-family: var(--serif-display); font-size: 1.7rem; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 var(--gap-2); }
.login-lede { color: var(--text-muted); margin: 0 0 var(--gap-5); }
.login-form { display: grid; gap: var(--gap-2); }
.login-label { font-weight: 650; }
.login-input { font: 600 1.1rem/1.4 var(--mono); letter-spacing: 0.08em; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%; }
.login-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.login-show { display: flex; gap: var(--gap-2); align-items: center; font-size: 0.9rem; color: var(--text-muted); }
.login-btn { justify-self: start; min-width: 140px; }
.login-msg { min-height: 1.5em; margin: 0; color: var(--bad); font-weight: 600; }
.login-help, .login-fine { font-size: 0.9rem; color: var(--text-muted); margin: var(--gap-4) 0 0; }
.login-fine { font-size: 0.84rem; border-top: 1px solid var(--border); padding-top: var(--gap-3); }

/* the person in the top bar */
.person { display: flex; align-items: center; gap: var(--gap-2); margin-left: var(--gap-2); }
.person-name { color: var(--masthead-muted); font-size: 0.86rem; white-space: nowrap; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }
.person-out { background: transparent; color: var(--masthead-text); border-color: var(--masthead-line); }
.person-out:hover { background: rgba(255, 255, 255, 0.06); color: var(--masthead-text); border-color: var(--masthead-muted); }   /* not .btn:hover's page colour */

/* citations and tiers */
.cite { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--gap-2); margin: var(--gap-2) 0 0; padding-top: var(--gap-2);
  border-top: 1px dashed var(--border); font-size: 0.86rem; color: var(--text-muted); }
.cite-label { font-family: var(--mono); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.cite-text { color: var(--text); overflow-wrap: anywhere; }
.cite-copy { min-height: 24px; padding: 0 8px; }
.item-tag.tier-official { color: var(--accent); border-color: currentColor; }
.item-tag.tier-journalism { color: var(--ok); border-color: currentColor; }
.item-tag.tier-firsthand { color: var(--cue-firsthand); border-color: currentColor; }
.item-tag.tier-podcast { color: var(--cue-hush); border-color: currentColor; }
.item-tag.tier-chatter { color: var(--text-muted); }
.withheld-note { display: flex; gap: var(--gap-2); align-items: baseline; font-size: 0.88rem; color: var(--text-muted); margin: var(--gap-2) 0 0; }
.removed-text { font-style: italic; color: var(--text-muted); }
.item-card.pulled { opacity: 0.45; }
.item-card.pulled::after { content: "Pulled: readers no longer see this."; display: block; margin-top: var(--gap-2); font-weight: 650; color: var(--bad); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.danger-text { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { border-color: var(--border); }

/* the editor's review on a hole page */
.review-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--gap-2) var(--gap-4);
  margin-top: var(--gap-3); padding: var(--gap-2) var(--gap-3); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); background: var(--surface); }
.review-words { margin: 0; font-size: 0.93rem; }
.chip.review { font-weight: 650; }

/* the Sources list on a hole page */
.src-group { border-top: 1px solid var(--border); padding: var(--gap-2) 0; }
.src-group > summary { cursor: pointer; font-weight: 650; min-height: var(--target); display: flex; align-items: center; }
.src-list { margin: var(--gap-2) 0 0; padding-left: var(--gap-5); display: grid; gap: var(--gap-2); }
.src-list .cite { border-top: 0; padding-top: 0; margin: 0; }

/* Admin */
.admin-tabs { margin-top: var(--gap-4); }
.admin-body { padding-top: var(--gap-4); display: grid; gap: var(--gap-4); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--gap-3); }
.stat-tile { display: grid; gap: 2px; padding: var(--gap-3) var(--gap-4); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; text-decoration: none; color: var(--text); }
.stat-tile:hover { border-color: var(--accent); }
.stat-n { font-family: var(--serif-display); font-size: 1.8rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.86rem; color: var(--text-muted); }
.plain-list { margin: 0; padding-left: var(--gap-5); display: grid; gap: var(--gap-2); max-width: 80ch; }
.form-row { display: flex; flex-wrap: wrap; gap: var(--gap-2); align-items: center; margin-top: var(--gap-2); }
.form-row .input { flex: 1 1 260px; min-width: 0; }
.setting { padding: var(--gap-3) 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; }
.small { font-size: 0.86rem; }
.mono { font-family: var(--mono); }
/* position: relative keeps the screen-reader-only text (position: absolute) inside the scrolling box, where it cannot widen the page */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.row-off td { color: var(--text-muted); }
.row-warn td { background: var(--warn-bg); }
.role-chip { margin-left: var(--gap-2); }
.code-show { font: 700 1.4rem/1.4 var(--mono); letter-spacing: 0.1em; padding: var(--gap-3); background: var(--surface-2);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; user-select: all; overflow-wrap: anywhere; }
.flag-list { display: grid; gap: var(--gap-3); }
.flag-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-2); margin: 0 0 var(--gap-2); }
.flag-note { margin: var(--gap-2) 0; padding: var(--gap-2) var(--gap-3); border-left: 3px solid var(--border-strong); background: var(--surface-2);
  white-space: pre-wrap; overflow-wrap: anywhere; }
.review-actions { align-items: center; margin-top: var(--gap-2); }
.dialog-msg { color: var(--bad); min-height: 1.2em; margin: var(--gap-2) 0 0; }
.dialog-body textarea.input, .dialog-body .input { width: 100%; margin-bottom: var(--gap-3); }

/* Patents */
.patent-list { display: grid; gap: var(--gap-3); }
.patent-card .item-title { font-family: var(--serif); }
.signal-row { display: flex; flex-wrap: wrap; gap: var(--gap-2); margin: var(--gap-2) 0; }
.contracts { margin-top: var(--gap-3); }
.contracts ul { margin: 4px 0 0; padding-left: var(--gap-5); display: grid; gap: 4px; font-size: 0.92rem; }
.fact-head { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin: 0; }
.src-patent { font-weight: 650; }
.filters { display: flex; flex-wrap: wrap; gap: var(--gap-2); align-items: center; margin: var(--gap-3) 0; }
.filters .input { flex: 1 1 280px; min-width: 0; }

.comment.pulled, .post.pulled { opacity: 0.45; }
.comment.pulled::after, .post.pulled::after { content: "Pulled: readers no longer see this."; display: block; font-weight: 650; color: var(--bad); }

/* narrow windows: keep the top bar's first row from overflowing */
@media (max-width: 1000px) {
  .wordmark-sub, .person-name { display: none; }
  .gs-input { width: 150px; }
  .fill-pill { max-width: 170px; }
}

/* === logo (the owner's mark, docs/brand/owner-logo-reference.jpg; drawn by scripts/build_favicon.py): a thin ring,
   a serif W, a vermilion bar across it. Ring and W take the text colour (light in the top bar, dark on a light sign-in
   page); the bar keeps the reference's vermilion in both themes. The ring is thickened a little at small sizes. === */
.wm-ring { fill: none; stroke: currentColor; stroke-width: 2.4; }
.wordmark .wm-ring { stroke-width: 3.2; }      /* about 1 px at 34 px */
.wm-w { fill: currentColor; }
.wm-bar { fill: #c4492a; }
@media (max-width: 600px) { .wordmark .wordmark-glyph { width: 30px; height: 30px; } }   /* phones: the old glyph's footprint */
/* === end logo === */

/* === quality check (Admin › Quality check; analysis/checker.py) === */
.checker-panel { min-width: 0; }          /* a wide table scrolls in its box, not the page */
.checker-panel .seg { flex-wrap: wrap; }
.checker-list { margin-top: var(--gap-3); }
.checker-card .item-card { margin: var(--gap-2) 0; }
.checker-name { display: grid; gap: var(--gap-1, 4px); }
.checker-name-link { font-weight: 650; font-size: 1.05rem; overflow-wrap: anywhere; }
.checker-quote { margin: 0; }
.checker-pair { display: grid; gap: var(--gap-2); }
.checker-and { margin: 0; font-size: 0.86rem; }
.checker-actions { margin-top: var(--gap-2); }
.checker-table th[scope="row"] { font-weight: 600; text-align: left; }
.more-row { margin: var(--gap-2) 0 0; }
/* === end quality check === */

/* === Weapons & technology (screens/patents.js, the Weapons & tech screen) === */
.weapons .wx-views { margin-top: var(--gap-3); }
.weapons .wx-lenses { margin-top: var(--gap-1); box-shadow: none; }
.weapons .wx-lenses .lens-tab { font-size: 0.92rem; }
.wx-filters .wx-field { display: inline-flex; min-width: 0; max-width: 100%; }
.wx-filters .wx-field[data-filter="q"] { flex: 1 1 280px; }
.wx-filters .wx-field[data-filter="q"] .input { flex: 1 1 auto; width: 100%; }
.wx-filters .select { max-width: 100%; }
.wx-filters .wx-date { flex: 0 1 auto; width: auto; }
.wx-check { align-items: center; gap: var(--gap-1); font-size: 0.92rem; }
.wx-note { color: var(--text-muted); font-size: 0.9rem; margin: var(--gap-2) 0 0; }
.wx-chips { display: flex; flex-wrap: wrap; gap: var(--gap-1); align-items: center; margin: var(--gap-1) 0 0; }
a.chip.wx-prog, a.chip.wx-company { text-decoration: none; }
a.chip.wx-prog:hover, a.chip.wx-company:hover { text-decoration: underline; }
.wx-label { margin: var(--gap-1) 0 var(--gap-2); }
.wx-card .item-title { overflow-wrap: anywhere; }
.weapons .item-card .chip { white-space: normal; max-width: 100%; }   /* long counts and programme names wrap on a phone */
/* the Holes and Quotes views (DECISIONS #38) */
.wx-list > .hole-card { margin: 0 0 var(--gap-3); }
.wx-list > .wx-quote { margin: 0 0 var(--gap-3); }
.wx-list > .wx-quote > .item-card { margin: 0; }
.wx-hole-extra .entity-chips, .wx-quote-extra .entity-chips { margin-top: var(--gap-2); }
.wx-hole-extra .item-actions, .wx-quote-extra .item-actions { margin-top: var(--gap-2); }
.wx-why { margin: var(--gap-2) 0 0; font-size: 0.9rem; }
.wx-lead-line { margin: var(--gap-2) 0 0; }
.wx-quote-extra .lc-why { margin-top: var(--gap-2); }
.wx-quote-extra .lc-caution { margin-top: var(--gap-2); }
.wx-filters .wx-all, .wx-filters .wx-name { align-items: center; gap: var(--gap-2); flex-wrap: wrap; }
.wx-naming { font-weight: 600; overflow-wrap: anywhere; }
.wx-best { margin: var(--gap-2) 0; padding: 4px 0 4px var(--gap-3); border-left: 2px solid var(--border); }
.wx-best-h { margin: 0 0 2px; font-family: var(--mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.wx-best .item-text { margin: 0; }
.hole-section { margin: 0 0 var(--gap-2); font-size: 0.92rem; color: var(--text-muted); overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .wx-filters .wx-field, .wx-filters .select, .wx-filters .wx-date { flex: 1 1 100%; width: 100%; }
  .wx-filters .btn { flex: 1 1 auto; }
}
/* === end Weapons & technology === */

/* === integration: phone width (the top bar's tools overlapped the wordmark below about 600 px, and an item's source
   tag could push a quote card past the screen edge) === */
@media (max-width: 600px) {
  .item-head { flex-wrap: wrap; row-gap: 4px; }
  .topbar-row { column-gap: var(--gap-2); padding-left: var(--gap-3); padding-right: var(--gap-3); }
  .wordmark { padding-right: 0; }
  .wordmark-text { display: none; }               /* the glyph stays, and the link keeps its label */
  .topbar-tools { min-width: 0; gap: 6px; }
  .global-search { flex: 1 1 auto; min-width: 0; }
  .gs-input { width: 100%; min-width: 64px; padding-right: 8px; }
  .gs-key { display: none; }
  .fill-pill { flex: 0 1 auto; min-width: 0; max-width: 104px; padding: 3px 8px; }
  .person { margin-left: 0; }
  /* a long section heading ("New weapons and technology records") wraps, and its count and rule go on the line below,
     instead of pushing the page sideways */
  .sec-head { flex-wrap: wrap; row-gap: var(--gap-1); }
  .sec-title { white-space: normal; min-width: 0; }
  /* a technology-area chip ("Radar, electronic warfare and jamming") is wider than a 320 px card: it wraps its own words */
  .chip.wx-area { max-width: 100%; white-space: normal; }
}
/* === end integration: phone width === */

/* === What's new (screens/whatsnew.js, components/watch.js, the count on the menu) === */
.nav-badge {                                       /* the masthead is dark in both themes, so one amber pill works in both */
  display: inline-block; min-width: 1.5em; margin-left: 6px; padding: 0 6px; border: 1px solid transparent; border-radius: 999px;
  background: #f0b45a; color: #17181a; font-size: 0.74rem; font-weight: 700; line-height: 1.5; text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-badge[hidden] { display: none; }
@media (forced-colors: active) { .nav-badge { border-color: CanvasText; } }

.watch-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.watch-btn[aria-busy="true"] { opacity: 0.7; cursor: progress; }
.watch-slot { margin: 0 0 var(--gap-3); }
.watch-slot:empty { display: none; }
@media (forced-colors: active) { .watch-btn[aria-pressed="true"] { border-width: 2px; } }

.whatsnew .screen-head { margin-bottom: var(--gap-3); }
.wn-windows { display: flex; flex-wrap: wrap; gap: var(--gap-2); margin: 0 0 var(--gap-5); }
.wn-window {
  display: inline-flex; align-items: center; min-height: var(--target); padding: 0 var(--gap-3); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.93rem; font-weight: 550;
}
.wn-window:hover { background: var(--hover); }
.wn-window.current { border-color: var(--hole); box-shadow: inset 0 -2px 0 var(--hole); font-weight: 700; }
@media (forced-colors: active) { .wn-window.current { border-width: 3px; } }
.wn-section { margin: 0 0 var(--gap-6); min-width: 0; }
.wn-total { color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; }
.wn-empty { color: var(--text-muted); margin: 0; }
.wn-more { margin: var(--gap-3) 0 0; }
.wn-watches { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap-3); }
.wn-watches > li { min-width: 0; }
.wn-watch { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); padding: var(--gap-3) var(--gap-4); min-width: 0; }
.wn-watch.has-news { border-left-color: var(--hole); }
.wn-watch.quiet { padding-top: var(--gap-2); padding-bottom: var(--gap-2); }
.wn-watch-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-1) var(--gap-3); }
.wn-watch-title { margin: 0; font-family: var(--serif); font-size: 1.12rem; min-width: 0; overflow-wrap: anywhere; }
.wn-watch-title a { color: inherit; }
.wn-new { margin-left: auto; font-weight: 700; color: var(--hole-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wn-none { margin-left: auto; color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; }
.wn-items { margin-top: var(--gap-2); }
.wn-actions { margin-top: var(--gap-2); }
.wn-lead .lc-caution { margin-bottom: var(--gap-1); }
.wn-lead .lc-why { margin: 0 0 var(--gap-2); }
.wn-section .item-card { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .wn-windows { gap: var(--gap-1); }
  .wn-window { flex: 1 1 calc(50% - var(--gap-1)); justify-content: center; text-align: center; }
  .wn-watch { padding: var(--gap-3); }
  .wn-new, .wn-none { margin-left: 0; }
}
/* === end What's new === */