:root {
  color-scheme: light;
  --paper: #f3f0e7;
  --paper-raised: #fbf9f3;
  --ink: #17252a;
  --muted: #536165;
  --line: #c7c6bd;
  --line-soft: #dddbd1;
  --accent: #a6402b;
  --accent-strong: #7d2c1d;
  --accent-pale: #ead7ca;
  --cool: #ced6d2;
  --mount: #e3e4df;
  --bar: rgba(243, 240, 231, .94);
  --shadow: 0 16px 44px rgba(29, 38, 38, .12);
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bar-height: 4rem;
  --reading-column: 60rem;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #10191b;
  --paper-raised: #172326;
  --ink: #eee7d9;
  --muted: #b5beb7;
  --line: #52605e;
  --line-soft: #344240;
  --accent: #ee9275;
  --accent-strong: #ffb29a;
  --accent-pale: #482e28;
  --cool: #354744;
  --mount: #25312f;
  --bar: rgba(16, 25, 27, .94);
  --shadow: 0 18px 48px rgba(0, 0, 0, .36);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #10191b;
    --paper-raised: #172326;
    --ink: #eee7d9;
    --muted: #b5beb7;
    --line: #52605e;
    --line-soft: #344240;
    --accent: #ee9275;
    --accent-strong: #ffb29a;
    --accent-pale: #482e28;
    --cool: #354744;
    --mount: #25312f;
    --bar: rgba(16, 25, 27, .94);
    --shadow: 0 18px 48px rgba(0, 0, 0, .36);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bar-height) + 1.5rem); }
body { min-width: 20rem; margin: 0; background: var(--paper); color: var(--ink); line-height: 1.68; }
img { display: block; max-width: 100%; }
a { color: var(--accent-strong); text-decoration-thickness: .08em; text-underline-offset: .18em; }
a:hover { color: var(--accent); }
button { color: inherit; font: inherit; }
::selection { color: #fffaf1; background: #7d2c1d; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[id] { scroll-margin-top: calc(var(--bar-height) + 1.5rem); }

.skip-link {
  position: fixed; z-index: 1000; top: .5rem; left: .5rem; padding: .7rem 1rem;
  transform: translateY(-160%); border-radius: .35rem; background: var(--ink); color: var(--paper-raised);
}
.skip-link:focus { transform: translateY(0); }

.site-bar {
  position: sticky; z-index: 50; top: 0; display: flex; min-height: var(--bar-height); align-items: center;
  justify-content: space-between; gap: 1rem; padding: .55rem max(1.15rem, calc((100vw - 72rem)/2));
  border-bottom: 1px solid var(--line-soft); background: var(--bar); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); font-family: var(--serif); font-size: 1rem; font-weight: 700; text-decoration: none; }
.brand-mark { display: grid; width: 2rem; height: 2rem; place-items: center; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); font-size: 1.05rem; }
.site-controls { display: flex; align-items: center; gap: .38rem; }
.control-label { margin-right: .35rem; color: var(--muted); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; }
.language-link { display: grid; min-width: 2.35rem; min-height: 2.35rem; place-items: center; border-radius: 2rem; color: var(--muted); font-size: .76rem; font-weight: 750; text-decoration: none; }
.language-link[aria-current="page"] { background: var(--accent-pale); color: var(--accent-strong); }
.theme-button { display: grid; width: 2.55rem; height: 2.55rem; margin-left: .25rem; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; font-size: 1.15rem; }
.theme-button:hover { border-color: var(--accent); color: var(--accent-strong); }
.progress-line { position: fixed; z-index: 55; top: var(--bar-height); left: 0; width: 100%; height: 2px; pointer-events: none; }
.progress-line span { display: block; width: 100%; height: 100%; transform: scaleX(0); transform-origin: left; background: var(--accent); }

main { min-height: 60vh; }
article { width: min(100% - 2.5rem, var(--reading-column)); margin: 0 auto; }
.story-section { display: grid; grid-template-columns: minmax(13rem, .75fr) minmax(0, 1.45fr); gap: clamp(2rem, 5vw, 4.5rem); padding: clamp(4.5rem, 9vw, 8rem) 0; border-top: 1px solid var(--line); }
.story-section:first-child { padding-top: clamp(3.2rem, 7vw, 6.2rem); border-top: 0; }
.opening-copy { grid-column: 1 / -1; max-width: 58rem; padding-bottom: .6rem; }
.eyebrow, .section-index { margin: 0 0 .8rem; color: var(--accent-strong); font-size: .72rem; font-weight: 800; letter-spacing: .12em; line-height: 1.3; text-transform: uppercase; }
h1, h2, h3, p, ol, figure { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; text-wrap: pretty; }
h1 { max-width: 17ch; margin: 0 0 1.15rem; font-size: clamp(2.65rem, 6.4vw, 5.8rem); letter-spacing: -.045em; line-height: .99; }
.deck { max-width: 57ch; margin: 0; color: var(--muted); font-family: var(--serif); font-size: clamp(1.18rem, 2.1vw, 1.55rem); line-height: 1.5; }
.section-heading { align-self: start; }
.section-heading h2 { max-width: 13ch; margin: 0; font-size: clamp(1.8rem, 3vw, 2.65rem); letter-spacing: -.025em; line-height: 1.08; }
.heading-permalink { display: inline-grid; width: 2rem; height: 2rem; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font: 600 .85rem var(--sans); text-decoration: none; vertical-align: .3em; }
.heading-permalink:hover { border-color: var(--accent); color: var(--accent-strong); }
.section-content { min-width: 0; }
.section-content > p, .sources-section > p { max-width: 69ch; margin: 0 0 1.15rem; font-size: 1.02rem; }
.section-content > p:first-of-type { margin-top: .2rem; }
.citation { display: inline-flex; gap: .22rem; margin-left: .25rem; font-size: .7rem; font-weight: 750; white-space: nowrap; }
.source-mark { color: var(--accent-strong); text-decoration: none; }
.source-mark:hover { text-decoration: underline; }

.evidence-figure { margin: 0 0 1.6rem; }
.record-labels { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .35rem .75rem; margin: 0 0 .6rem; color: var(--muted); font-size: .73rem; line-height: 1.4; }
.record-kind { color: var(--ink); font-weight: 760; }
.record-date { padding-left: .75rem; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.evidence-mount { overflow: hidden; padding: .62rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--mount); box-shadow: var(--shadow); }
.evidence-mount img { width: 100%; height: auto; border-radius: .22rem; object-fit: contain; }
.evidence-figure figcaption { padding-top: .8rem; color: var(--muted); font-size: .83rem; line-height: 1.55; }
.caption-text { display: block; margin-bottom: .42rem; color: var(--ink); font-family: var(--serif); font-size: 1rem; }
.image-credit { margin: 0; }
.credit-label { color: var(--ink); font-weight: 740; }
.image-credit a { white-space: normal; }
.record-filename { display: none; }

.evidence-stack { margin: 2.4rem 0 0; }
.evidence-stack > figcaption { margin-bottom: 1rem; font-family: var(--serif); font-size: 1.35rem; }
.stack-list { position: relative; display: grid; gap: .65rem; margin: 0; padding: 0; list-style: none; counter-reset: stack; }
.stack-list::before { position: absolute; top: 1.3rem; bottom: 1.3rem; left: 1.12rem; width: 1px; background: var(--line); content: ""; }
.stack-layer { position: relative; display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); gap: .7rem; align-items: start; padding: .9rem 1rem .95rem .3rem; border: 1px solid var(--line-soft); border-radius: .45rem; background: var(--paper-raised); }
.stack-index { z-index: 1; display: grid; width: 1.72rem; height: 1.72rem; place-items: center; border: 1px solid var(--accent); border-radius: 50%; background: var(--paper-raised); color: var(--accent-strong); font-size: .66rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stack-layer h3 { margin: .05rem 0 .15rem; font-size: 1.08rem; }
.stack-layer p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.diagram-note { margin: .75rem 0 0; color: var(--muted); font-size: .78rem; }

.chronology-panel { margin: 2rem 0 2.4rem; padding: clamp(1rem, 2.4vw, 1.5rem); border: 1px solid var(--accent); border-left-width: 4px; border-radius: .45rem; background: var(--paper-raised); }
.chronology-panel h3 { margin: 0 0 1rem; font-size: 1.45rem; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline-row { display: grid; grid-template-columns: minmax(8.5rem, .48fr) minmax(0, 1.52fr); gap: .8rem; padding: .68rem 0; border-top: 1px solid var(--line-soft); }
.timeline-date { color: var(--accent-strong); font-size: .82rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.55; }
.timeline-scope { margin: 0; font-size: .89rem; line-height: 1.5; }
.section-5 .evidence-figure { margin-top: 2rem; }

.share-row { display: flex; align-items: center; gap: .8rem; min-height: 3rem; margin: -.6rem 0 2rem; padding: .55rem 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.share-label { color: var(--muted); font-size: .8rem; }
.share-actions { display: flex; align-items: center; gap: .35rem; }
.share-icon { display: grid; width: 2.5rem; height: 2.5rem; flex: none; place-items: center; border: 1px solid var(--line-soft); border-radius: 50%; background: transparent; color: var(--ink); font-size: .9rem; font-weight: 750; text-decoration: none; cursor: pointer; }
.share-icon:hover { border-color: var(--accent); color: var(--accent-strong); }
.share-status { min-height: 1.2em; color: var(--muted); font-size: .78rem; }
.share-icon[hidden], .copy-fallback[hidden] { display: none; }
.copy-fallback { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; flex-basis: 100%; padding-top: .45rem; color: var(--muted); font-size: .78rem; }
.copy-fallback input { min-width: min(24rem, 65vw); min-height: 2.5rem; padding: .4rem .65rem; border: 1px solid var(--line); border-radius: .3rem; background: var(--paper-raised); color: var(--ink); font: .82rem var(--sans); }
.copy-fallback button { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border: 1px solid var(--line-soft); border-radius: 50%; background: transparent; cursor: pointer; }

.sources-section { padding: 4rem 0 6rem; border-top: 1px solid var(--line); }
.sources-section .section-heading { margin-bottom: 1.3rem; }
.sources-section .section-heading h2 { max-width: 20ch; }
.source-list { display: grid; gap: 0; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.source-entry { display: grid; grid-template-columns: 3rem minmax(0, 1fr); gap: .8rem; padding: .85rem 0; border-top: 1px solid var(--line-soft); scroll-margin-top: 6rem; }
.source-id { padding-top: .1rem; color: var(--accent-strong); font-size: .76rem; font-weight: 800; }
.source-title { font-family: var(--serif); font-size: .99rem; line-height: 1.35; }
.source-entry p { margin: .25rem 0 0; color: var(--muted); font-size: .77rem; line-height: 1.4; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 2rem; padding: 1.4rem max(1.25rem, calc((100vw - 72rem)/2)); border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.site-footer p { margin: 0; }
.site-footer a { color: inherit; }

.rail { display: none; }

@media (max-width: 69.999rem) {
  [id] { scroll-margin-top: calc(var(--bar-height) + 4rem); }
  .rail { position: sticky; z-index: 44; top: var(--bar-height); display: flex; max-width: 100vw; gap: .35rem; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; margin: 0; padding: .38rem .8rem; border-bottom: 1px solid var(--line); background: var(--paper-raised); }
  .rail::-webkit-scrollbar { display: none; }
  .rail::before { display: none; }
  .rail-dot { position: relative; display: inline-flex; width: auto; height: 2.15rem; flex: 0 0 auto; align-items: center; justify-content: center; gap: .42rem; padding: .3rem .62rem; border: 1px solid var(--line-soft); border-radius: 2rem; background: var(--paper); color: var(--ink); text-decoration: none; }
  .rail-dot .dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--muted); }
  .rail-dot[aria-current="true"] { border-color: var(--accent); color: var(--accent-strong); }
  .rail-dot[aria-current="true"] .dot { background: var(--accent); }
  .rail-label { position: static; max-width: none; overflow: visible; transform: none; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: inherit; font-size: .74rem; font-weight: 650; line-height: 1.2; text-overflow: clip; white-space: nowrap; opacity: 1; pointer-events: auto; }
}

.back-top { position: fixed; z-index: 45; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); display: inline-flex; min-width: 3rem; min-height: 3rem; align-items: center; justify-content: center; gap: .3rem; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 2rem; background: var(--paper-raised); box-shadow: var(--shadow); color: var(--ink); cursor: pointer; font-size: .85rem; }
.back-top:hover { border-color: var(--accent); color: var(--accent-strong); }
.back-top[hidden] { display: none; }

@media (min-width: 70rem) {
  .rail { --col: var(--reading-column); --gut: 1.1rem; position: fixed; z-index: 40; top: 50%; left: calc(50% + var(--col)/2 + var(--gut)); display: flex; max-height: calc(100vh - 8rem); flex-direction: column; transform: translateY(-50%); margin: 0; padding: .4rem 0; }
  .rail::before { position: absolute; top: 1.1rem; bottom: 1.1rem; left: .875rem; width: 1px; background: var(--line); content: ""; }
  .rail-dot { position: relative; display: flex; width: 1.75rem; height: 1.85rem; flex: 1 1 auto; align-items: center; justify-content: center; border-radius: 50%; text-decoration: none; }
  .rail-dot .dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px var(--paper); transition: transform .18s, background .18s; }
  .rail-dot:hover .dot, .rail-dot:focus-visible .dot { transform: scale(1.3); background: var(--accent); }
  .rail-dot[aria-current="true"] .dot { transform: scale(1.45); background: var(--accent); box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px color-mix(in srgb, var(--accent) 42%, transparent); }
  .rail-label { position: absolute; top: 50%; right: calc(100% + .4rem); max-width: 12rem; overflow: hidden; transform: translate(5px, -50%); padding: .2rem .55rem; border: 1px solid var(--line); border-radius: .35rem; background: var(--paper-raised); box-shadow: 0 5px 18px rgba(0,0,0,.12); color: var(--ink); font-size: .75rem; font-weight: 650; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
  .rail-dot:hover .rail-label, .rail-dot:focus-visible .rail-label { transform: translate(0, -50%); opacity: 1; }
}

@media (min-width: 90rem) {
  .rail-label { right: auto; left: calc(100% + .15rem); max-width: calc(50vw - var(--col)/2 - var(--gut) - 3rem); transform: translate(-4px, -50%); padding: .12rem .2rem; border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
  .rail-dot[aria-current="true"] .rail-label { transform: translate(0, -50%); color: var(--ink); opacity: 1; }
}

@media (max-width: 46rem) {
  :root { --bar-height: 3.65rem; }
  .back-top { display: none; }
  .site-bar { padding-inline: .8rem; }
  .brand { gap: .5rem; font-size: .87rem; }
  .brand-mark { width: 1.8rem; height: 1.8rem; }
  .control-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .site-controls { gap: .15rem; }
  .language-link { min-width: 2.15rem; min-height: 2.2rem; }
  .theme-button { width: 2.25rem; height: 2.25rem; }
  article { width: min(100% - 2rem, var(--reading-column)); }
  .story-section { grid-template-columns: minmax(0, 1fr); gap: 1.15rem; padding: 3.8rem 0; }
  .story-section:first-child { padding-top: 3rem; }
  .opening-copy { padding-bottom: .5rem; }
  .section-index { margin-bottom: .45rem; }
  .section-heading h2 { max-width: 21ch; font-size: clamp(1.75rem, 8vw, 2.25rem); }
  .section-content > p { font-size: .99rem; }
  .evidence-mount { padding: .38rem; }
  .record-labels { font-size: .69rem; }
  .timeline-row { grid-template-columns: minmax(6.8rem, .6fr) minmax(0, 1.4fr); gap: .45rem; }
  .timeline-date { font-size: .75rem; }
  .timeline-scope { font-size: .82rem; }
  .share-row { align-items: flex-start; flex-wrap: wrap; gap: .35rem .6rem; margin-top: 0; }
  .share-label { align-self: center; }
  .share-actions { flex: 1; justify-content: flex-start; }
  .share-icon { width: 2.75rem; height: 2.75rem; }
  .share-status { flex-basis: 100%; padding-left: .1rem; }
  .source-entry { grid-template-columns: 2.35rem minmax(0, 1fr); gap: .45rem; }
  .site-footer { padding: 1.2rem 1rem; }
}

@media (max-width: 22rem) {
  .brand { font-size: .78rem; }
  .brand-mark { width: 1.65rem; height: 1.65rem; }
  .language-link { min-width: 1.9rem; }
  .theme-button { width: 2rem; height: 2rem; }
  .timeline-row { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
}

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

@media (forced-colors: active) {
  .rail::before { background: CanvasText; }
  .rail-dot .dot { background: CanvasText; box-shadow: none; }
  .rail-dot[aria-current="true"] .dot { background: Highlight; }
  .evidence-mount, .chronology-panel, .stack-layer { border: 1px solid CanvasText; }
  .progress-line span { background: Highlight; }
}

@media print {
  :root { color-scheme: light; --paper: #fff; --paper-raised: #fff; --ink: #111; --muted: #333; --line: #888; --line-soft: #ccc; }
  .site-bar, .progress-line, .rail, .share-row, .back-top, .skip-link { display: none !important; }
  body { background: #fff; color: #111; }
  article { width: 100%; }
  .story-section { break-inside: avoid; padding: 2rem 0; }
  .evidence-mount { box-shadow: none; }
  a { color: #111; }
  a[href^="https://"]::after { content: " (" attr(href) ")"; overflow-wrap: anywhere; font-size: .7em; }
}
