:root {
  --paper: #f7f3ea;
  --paper-raised: #fffdf8;
  --ink: #1d2420;
  --muted: #64675f;
  --accent: #27513a;
  --accent-soft: #dfe8df;
  --rule: #cbc4b6;
  --rule-strong: #79776e;
  --note: #eee7d9;
  --warning: #875e25;
}

body.dark {
  --paper: #171a18;
  --paper-raised: #1e221f;
  --ink: #eee9de;
  --muted: #b9b4a9;
  --accent: #9bc6a9;
  --accent-soft: #283a2f;
  --rule: #434740;
  --rule-strong: #8c9188;
  --note: #28271f;
  --warning: #ddb675;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

.container { width: min(1180px, 100%); margin: 0 auto; padding-inline: 28px; }

/* Masthead */
.app-header { padding: 38px 0 30px; border-bottom: 1px solid var(--rule); }
.app-header .container { position: relative; }
.brand-line { display: flex; align-items: baseline; gap: 14px; margin-bottom: 20px; }
.brand-kicker { color: var(--accent); font-size: 14px; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
.brand-note { color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: 14px; font-style: italic; }
.app-header .title {
  max-width: 940px;
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 5vw, 62px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 0.98;
  text-wrap: balance;
}
.app-header .subtitle { display: block; margin: 18px 0 0; color: var(--muted); font-size: 15px; }
.header-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 8px; font-size: 14px; }
.header-links a { color: var(--ink); }
.theme-toggle {
  position: absolute;
  top: 0;
  right: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 4px;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); }

/* Reading layout */
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 56px; align-items: start; }
.content, .report, .card { min-width: 0; }
.sidebar { position: sticky; top: 28px; max-height: calc(100vh - 56px); overflow: auto; padding: 34px 0; }
.sidebar-title {
  margin: 0 0 14px;
  padding-top: 12px;
  border-top: 2px solid var(--ink);
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sidebar nav { display: grid; }
.sidebar nav a {
  display: block;
  padding: 8px 0 8px 13px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.25;
  text-decoration: none;
}
.sidebar nav a:hover { color: var(--ink); }
.sidebar nav a.active { border-left-color: var(--accent); color: var(--accent); }

.topbar { display: none; position: sticky; top: 0; z-index: 5; padding: 10px 0; border-bottom: 1px solid var(--rule); background: var(--paper); }
.mobile-toc {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  background: var(--paper-raised);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

/* Report */
.report { padding: 0 0 36px; }
.card { padding: 38px 0 42px; border-bottom: 1px solid var(--rule); }
.report-provenance { padding-top: 34px; }
.report-status { color: var(--muted); }
.publication-notice { margin-top: 28px; padding: 18px 0 18px 20px; border-left: 3px solid var(--warning); color: var(--muted); }
.publication-notice h2 { margin: 0 0 4px; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 21px; font-weight: 500; }
.publication-notice p { margin: 0; font-size: 15px; }
.publication-notice time { color: var(--ink); }
.publication-notice details { margin-top: 8px; font-size: 14px; }
.publication-notice summary { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.publication-notice details p { margin-top: 8px; }
.report-citation { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; padding: 0.15em 0.1em; }
.source-number { color: var(--muted); font-variant-numeric: tabular-nums; }

/* A navigation map of existing findings, not a quantitative risk assessment. */
.review-map { margin-top: 30px; padding-top: 24px; border-top: 2px solid var(--accent); }
.review-map h2 { margin-bottom: 8px; font-size: 25px; }
.review-map > p { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.review-map-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.review-map-group h3 { margin: 0 0 12px; font-size: 18px; line-height: 1.25; }
.review-map-count { display: block; margin-top: 5px; color: var(--muted); font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.review-map-group ul { margin: 0; list-style: none; }
.review-map-group li { margin: 0; border-top: 1px solid var(--rule); }
.review-map-group a { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 12px 0; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.review-priority { color: var(--muted); font-size: 13px; text-decoration: none; }
.review-priority::before { content: "↳ "; }
.report h3[id^="finding-"], .archive-report h3[id^="finding-"] { scroll-margin-top: 90px; }
.report h3[id^="finding-"]:target, .archive-report h3[id^="finding-"]:target { outline: 2px solid var(--accent); outline-offset: 6px; }

.report-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 30px; margin: 24px 0 0; }
.report-meta-item { min-width: 0; }
.report-meta dt { margin-bottom: 3px; color: var(--muted); font-size: 13px; font-weight: 750; letter-spacing: 0.055em; text-transform: uppercase; }
.report-meta dd { margin: 0; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
.report-meta-evidence { grid-column: auto; }
.provenance-explanation { max-width: 76ch; margin: 22px 0 0; color: var(--muted); font-size: 14px; }

.card h2, .card h3, .card h4 { color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
.card h2 { margin: 0 0 24px; font-size: 30px; letter-spacing: -0.02em; line-height: 1.1; scroll-margin-top: 78px; }
.card h3 { margin: 26px 0 8px; font-size: 21px; line-height: 1.25; }
.card h4 { margin: 22px 0 6px; font-size: 18px; line-height: 1.3; }
.card > p { max-width: 78ch; margin: 0 0 18px; }
.card > ul, .card > ol { max-width: 78ch; margin-top: 0; }
ul, ol { margin: 10px 0 18px 23px; padding: 0; }
li + li { margin-top: 8px; }

/* Tables use rules where they carry meaning, not boxes around every surface. */
.table-wrap { overflow-x: auto; margin: 26px 0 12px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule-strong); }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 15px; }
th { padding: 12px 16px 11px 0; border-bottom: 1px solid var(--rule-strong); color: var(--ink); font-weight: 700; text-align: left; vertical-align: bottom; }
td { padding: 13px 16px 14px 0; line-height: 1.5; vertical-align: top; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr + tr td { border-top: 1px solid var(--rule); }
.table-wrap th:first-child, .table-wrap td:first-child { width: 24%; min-width: 160px; font-weight: 650; }

/* Supporting content */
blockquote { margin: 20px 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--muted); }
hr { margin: 28px 0; border: 0; border-top: 1px solid var(--rule); }
code { padding: 2px 5px; background: var(--note); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
pre { overflow-x: auto; margin: 22px 0; padding: 18px; background: var(--note); font-size: 14px; line-height: 1.55; }
pre code { padding: 0; background: transparent; font-size: inherit; }

.evidence-note, .evidence-inline { color: var(--muted); font-size: 14px; line-height: 1.5; }
.evidence-note { margin: 12px 0 18px; padding-left: 14px; border-left: 2px solid var(--warning); }
.evidence-inline { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--warning); }
.evidence-label { margin-right: 8px; color: var(--warning); font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; }
.digest-handoff, .manifest-link { font-weight: 650; white-space: nowrap; }
.digest-handoff::after, .manifest-link::after { content: " ↗"; }

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, select:focus-visible { outline: 3px solid var(--warning); outline-offset: 3px; }

/* Footer and secondary pages */
.app-footer { padding: 28px 0 34px; color: var(--muted); font-size: 14px; }
.app-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.archive-shell, .publication-history-shell { padding: 36px 0 48px; }
.archive-context { padding-top: 26px; }
.archive-note { max-width: 82ch; margin: 22px 0; padding-left: 18px; border-left: 3px solid var(--warning); color: var(--muted); }
.archive-note strong, .archive-note time { color: var(--ink); }
.archive-list, .publication-history-list { margin: 28px 0 0; padding: 0; border-top: 2px solid var(--ink); }
.archive-list li, .publication-history-entry { list-style: none; border-bottom: 1px solid var(--rule); }
.archive-list a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; padding: 16px 0; color: var(--ink); text-decoration: none; }
.archive-list a:hover span { color: var(--accent); text-decoration: underline; }
.archive-list time { color: var(--muted); }
.archive-report { padding: 0 28px 36px; }
.publication-history-shell > p { max-width: 82ch; color: var(--muted); }
.publication-history-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 17px 0; }
.publication-history-entry div { display: grid; gap: 2px; }
.publication-history-entry strong { color: var(--ink); font-weight: 650; }
.publication-history-entry time { color: var(--muted); font-size: 14px; }
.publication-history-entry > a { font-size: 14px; text-align: right; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { display: block; }
  .report-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .review-map-groups { grid-template-columns: 1fr; gap: 20px; }
  .review-map-group a { flex-direction: row; justify-content: space-between; gap: 16px; }
  .review-priority { flex-shrink: 0; }
  .container { padding-inline: 18px; }
  .app-header { padding: 26px 0 22px; }
  .brand-line { display: grid; gap: 2px; margin-bottom: 14px; }
  .app-header .title { max-width: 330px; font-size: 39px; line-height: 0.98; }
  .app-header .subtitle { margin-top: 14px; }
  .theme-toggle { top: 1px; right: 18px; }
  .report-meta { grid-template-columns: 1fr; gap: 16px; }
  .card { padding: 32px 0 36px; }
  .card h2 { font-size: 27px; }
  .table-wrap { margin-inline: -18px; padding-inline: 18px; }
  table { min-width: 680px; }
  .archive-list a { grid-template-columns: 1fr; gap: 4px; }
  .publication-history-entry { grid-template-columns: 1fr; gap: 7px; }
  .publication-history-entry > a { text-align: left; }
  .app-footer .container { display: grid; }
}

/* Print: report only */
@media print {
  .review-map-group { break-inside: avoid; }
  .review-map { break-inside: avoid; --ink: #000; --muted: #444; --accent: #000; --rule: #aaa; }
  :root { --paper: #fff; --ink: #000; --muted: #444; --rule: #aaa; --rule-strong: #555; --accent: #000; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .app-header, .topbar, .sidebar, .app-footer, .theme-toggle { display: none !important; }
  .layout { display: block; }
  .report { padding: 0; }
  .card { break-inside: avoid; padding: 18pt 0; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; }
  a { color: #000; }
}
