:root {
  color-scheme: dark;
  --bg: #050a09;
  --surface: #08120f;
  --surface-2: #0d1a17;
  --surface-3: #12231f;
  --text: #eef9f6;
  --muted: #8fa9a2;
  --line: rgba(183, 237, 224, 0.15);
  --accent: #65e7c0;
  --accent-soft: rgba(101, 231, 192, 0.12);
  --amber: #ffb768;
  --amber-soft: rgba(255, 183, 104, 0.12);
  --shadow: rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.6; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(101, 231, 192, 0.45); outline-offset: 3px; }

.skip-link { position: absolute; top: -60px; left: 16px; z-index: 50; background: var(--accent); color: #032019; padding: 10px 14px; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 12px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 12px max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(5, 10, 9, 0.88);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; min-width: max-content; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); font-size: 14px; box-shadow: 0 0 24px rgba(101, 231, 192, 0.17); }
.brand strong { display: block; font-size: 15px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.brand small { display: block; margin-top: -2px; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }
.site-header nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.site-header nav a { padding: 9px 11px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.site-header nav a:hover { color: var(--text); background: var(--surface-2); }
.header-download { padding: 10px 14px; border-radius: 9px; background: var(--accent); color: #032019; text-decoration: none; font-size: 14px; font-weight: 700; white-space: nowrap; }

main { overflow: hidden; }
.story-shell { width: min(1240px, calc(100% - 32px)); min-height: calc(100svh - 104px); margin: 32px auto 0; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; background: var(--surface); box-shadow: 0 30px 90px var(--shadow); }
.story-topline { min-height: 54px; display: flex; align-items: center; gap: 18px; padding: 10px 20px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; letter-spacing: 0.07em; text-transform: uppercase; }
.story-progress { width: 130px; height: 2px; margin-left: auto; background: var(--line); overflow: hidden; }
.story-progress i { display: block; height: 100%; width: 16.667%; background: var(--accent); transition: width 450ms ease; }

.story-layout { display: grid; grid-template-columns: minmax(330px, 0.8fr) minmax(520px, 1.2fr); min-height: 610px; }
.narrative { min-width: 0; padding: clamp(30px, 4vw, 58px); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.chapter-label, .section-kicker { margin: 0 0 16px; color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; }
.narrative h1 { max-width: 520px; margin: 0; font-size: clamp(2.5rem, 5vw, 4.7rem); font-weight: 650; letter-spacing: -0.055em; line-height: 0.97; text-wrap: balance; }
.chapter-copy { max-width: 520px; margin: 24px 0 0; color: var(--muted); font-size: 17px; line-height: 1.7; }
.question { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.question > p:first-child { margin: 0 0 10px; color: var(--muted); font-size: 14px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.09em; }
.answer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer { min-height: 68px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); color: var(--text); text-align: left; cursor: pointer; }
.answer:hover { border-color: rgba(101, 231, 192, 0.55); }
.answer[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.answer strong, .answer span { display: block; }
.answer strong { font-size: 15px; }
.answer span { color: var(--muted); font-size: 13px; }
.answer-note { min-height: 24px; margin: 10px 0 0; color: var(--amber); font-size: 14px; }
.story-actions { margin-top: auto; padding-top: 28px; display: flex; align-items: center; gap: 9px; }
.story-actions button { min-height: 44px; padding: 10px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 700; }
.back-button { border: 1px solid var(--line); background: transparent; color: var(--muted); }
.back-button:disabled { opacity: 0.35; cursor: not-allowed; }
.next-button { border: 1px solid transparent; background: var(--accent); color: #032019; }

.evidence { min-width: 0; display: grid; grid-template-rows: auto minmax(390px, 1fr) auto auto; background: var(--surface-2); }
.evidence-head { min-height: 54px; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.evidence-head .signal { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.evidence-head strong { font-size: 14px; }
.evidence-head > span:last-child { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.evidence-stage { position: relative; min-height: 390px; overflow: hidden; background: radial-gradient(circle at 50% 48%, rgba(101, 231, 192, 0.12), transparent 28%), linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px), var(--bg); background-size: auto, 44px 44px, 44px 44px, auto; }
#main-canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; background: var(--bg); }
.loading[hidden] { display: none; }
.evidence-foot { min-height: 58px; padding: 11px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; background: rgba(8, 18, 15, 0.86); }
.evidence-foot p { margin: 0; color: var(--muted); font-size: 14px; }
.evidence-foot strong { color: var(--text); }
.evidence-foot span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.timeline { min-height: 58px; padding: 10px 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; }
.timeline button { min-width: 68px; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-3); color: var(--text); cursor: pointer; font-size: 14px; }
.timeline input { width: 100%; accent-color: var(--accent); }
.timeline span { min-width: 54px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.trace-grid { position: absolute; inset: 24px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); gap: 10px; }
.trace-grid[hidden] { display: none; }
.trace-panel { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: rgba(8, 18, 15, 0.88); }
.trace-panel canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.trace-panel span { position: absolute; left: 8px; top: 6px; z-index: 2; padding: 3px 6px; border-radius: 5px; background: rgba(5, 10, 9, 0.78); color: var(--muted); font-size: 12px; }
.trace-panel:last-child { grid-column: 2 / 3; }

.class-matrix { position: absolute; inset: 28px; display: grid; grid-template-columns: minmax(86px, 0.65fr) repeat(4, 1fr); grid-template-rows: 38px repeat(4, 1fr); gap: 7px; }
.class-matrix[hidden] { display: none; }
.matrix-label { display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; line-height: 1.2; }
.matrix-cell { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: rgba(143, 169, 162, 0.42); background: rgba(8, 18, 15, 0.68); font-size: 13px; }
.matrix-cell.active { border-color: rgba(101, 231, 192, 0.48); color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.matrix-cell.selected { box-shadow: inset 0 0 0 2px var(--accent), 0 0 24px rgba(101, 231, 192, 0.17); }

.chapter-nav { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--line); }
.chapter-nav button { min-width: 0; min-height: 75px; padding: 12px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--muted); text-align: left; cursor: pointer; }
.chapter-nav button:last-child { border-right: 0; }
.chapter-nav button:hover { background: var(--surface-2); }
.chapter-nav button[aria-current="step"] { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 2px var(--accent); }
.chapter-nav span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.chapter-nav strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.purpose-section, .atlas-section, .population-section, .archive-section { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: clamp(80px, 10vw, 148px) 0; }
.purpose-section { max-width: 920px; text-align: center; }
.purpose-section h2, .section-heading h2, .archive-copy h2 { margin: 0; font-size: clamp(2.1rem, 5vw, 4.5rem); line-height: 1.02; letter-spacing: -0.045em; font-weight: 650; text-wrap: balance; }
.purpose-section > p:last-of-type { max-width: 740px; margin: 24px auto 0; color: var(--muted); font-size: 18px; }
.purpose-pairs { margin-top: 46px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.purpose-pairs article { padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.purpose-pairs span, .purpose-pairs strong, .purpose-pairs i { display: block; }
.purpose-pairs span { color: var(--accent); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; }
.purpose-pairs strong { margin-top: 9px; font-size: 18px; }
.purpose-pairs i { margin: 5px 0 -3px; color: var(--muted); font-size: 14px; }

.section-heading { display: grid; grid-template-columns: 1fr minmax(280px, 0.62fr); gap: 50px; align-items: end; margin-bottom: 38px; }
.section-heading > p { margin: 0; color: var(--muted); font-size: 17px; }
.atlas-section { border-top: 1px solid var(--line); }
.atlas-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 0.42fr); gap: 14px; }
.atlas-grid, .atlas-detail { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.atlas-grid { min-height: 480px; padding: 20px; display: grid; grid-template-columns: minmax(110px, 0.62fr) repeat(4, 1fr); grid-template-rows: 52px repeat(4, 1fr); gap: 8px; }
.atlas-grid .axis-label { display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.25; }
.atlas-grid button { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: rgba(143, 169, 162, 0.38); cursor: default; }
.atlas-grid button.active { border-color: rgba(101, 231, 192, 0.36); color: var(--accent); background: var(--accent-soft); cursor: pointer; font-weight: 700; }
.atlas-grid button.active:hover, .atlas-grid button.active[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 24px rgba(101, 231, 192, 0.13); }
.atlas-detail { padding: 24px; }
.atlas-detail > span { color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.atlas-detail h3 { margin: 10px 0 8px; font-size: 27px; line-height: 1.12; }
.atlas-detail > p { margin: 0; color: var(--muted); font-size: 15px; }
.atlas-toggle { display: flex; gap: 7px; margin: 20px 0 12px; }
.atlas-toggle button { min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; }
.atlas-toggle button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.atlas-previews { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.atlas-previews figure { margin: 0; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.atlas-previews figure:last-child { grid-column: 1 / -1; }
.atlas-previews canvas { display: block; width: 100%; aspect-ratio: 1.35; image-rendering: pixelated; }
.atlas-previews figcaption { padding: 6px 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.population-section { border-top: 1px solid var(--line); }
.population-board { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: radial-gradient(circle at 50% 40%, rgba(101, 231, 192, 0.08), transparent 34%), var(--surface); }
#population-canvas { display: block; width: 100%; height: 510px; }
.population-legend { display: flex; gap: 24px; padding: 14px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.population-legend span { display: inline-flex; align-items: center; gap: 8px; }
.population-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(101, 231, 192, 0.35); }
.population-legend .boundary i { background: var(--amber); box-shadow: 0 0 12px rgba(255, 183, 104, 0.38); }

.archive-section { border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr); gap: 74px; }
.archive-copy > p:not(.section-kicker):not(.checksum) { margin: 24px 0; color: var(--muted); font-size: 17px; }
.primary-download { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 440px; padding: 15px 17px; border: 0; border-radius: 10px; background: var(--accent); color: #032019; text-decoration: none; font-weight: 750; text-align: left; cursor: pointer; }
.primary-download[aria-disabled="true"] { opacity: 0.58; cursor: wait; }
.primary-download span { font-size: 13px; font-weight: 650; white-space: nowrap; }
.checksum { max-width: 440px; margin: 12px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.checksum code { color: var(--muted); }
.checksum a { color: var(--muted); text-underline-offset: 3px; }
.checksum a:hover { color: var(--text); }
.archive-data { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.archive-stats { margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.archive-stats div { padding: 17px 13px; border-right: 1px solid var(--line); }
.archive-stats div:last-child { border-right: 0; }
.archive-stats dt { color: var(--muted); font-size: 12px; }
.archive-stats dd { margin: 4px 0 0; font-size: 24px; font-weight: 700; }
.download-blocks { display: grid; grid-template-columns: 1fr 1fr; }
.download-blocks a { min-width: 0; padding: 15px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; background: var(--surface); }
.download-blocks a:nth-child(2n) { border-right: 0; }
.download-blocks a:last-child { grid-column: 1 / -1; border-right: 0; }
.download-blocks a:hover { background: var(--accent-soft); }
.download-blocks strong, .download-blocks span { display: block; }
.download-blocks strong { font-size: 14px; }
.download-blocks span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.download-blocks i { font-style: normal; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
td:first-child { color: var(--accent); font-weight: 700; }
td:last-child, th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.load-example { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: start; padding: 15px; }
.load-example span { color: var(--accent); font-size: 12px; font-weight: 700; }
.load-example code { color: var(--muted); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }

.site-footer { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 44px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.site-footer p { max-width: 570px; margin: 0; color: var(--muted); font-size: 13px; text-align: right; }

@media (max-width: 980px) {
  .site-header nav { display: none; }
  .story-layout { grid-template-columns: 1fr; }
  .narrative { min-height: 560px; border-right: 0; border-bottom: 1px solid var(--line); }
  .evidence { min-height: 640px; }
  .section-heading { grid-template-columns: 1fr; gap: 20px; }
  .atlas-wrap, .archive-section { grid-template-columns: 1fr; }
  .archive-section { gap: 38px; }
}

@media (max-width: 700px) {
  .site-header { padding: 10px 16px; }
  .header-download { padding: 10px 12px; }
  .story-shell { width: calc(100% - 20px); margin-top: 12px; border-radius: 14px; }
  .story-topline > span:first-child { display: none; }
  .story-progress { margin-left: 0; flex: 1; }
  .narrative { min-height: 590px; padding: 30px 20px 22px; }
  .narrative h1 { font-size: clamp(2.6rem, 13vw, 4rem); }
  .chapter-copy { font-size: 16px; }
  .evidence { min-height: 580px; grid-template-rows: auto minmax(330px, 1fr) auto auto; }
  .evidence-head { flex-wrap: wrap; }
  .evidence-head > span:last-child { width: 100%; margin-left: 0; }
  .evidence-stage { min-height: 330px; }
  .evidence-foot { align-items: flex-start; flex-direction: column; }
  .trace-grid { inset: 12px; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 1fr); }
  .trace-panel:last-child { grid-column: auto; }
  .class-matrix { inset: 14px 10px; grid-template-columns: 74px repeat(4, 1fr); gap: 4px; }
  .matrix-label, .matrix-cell { font-size: 10px; }
  .chapter-nav button { min-height: 58px; padding: 10px 6px; text-align: center; }
  .chapter-nav strong { display: none; }
  .purpose-section, .atlas-section, .population-section, .archive-section { width: calc(100% - 28px); padding: 86px 0; }
  .purpose-pairs { grid-template-columns: 1fr; }
  .atlas-grid { min-height: 430px; padding: 10px; grid-template-columns: 88px repeat(4, 1fr); gap: 5px; }
  .atlas-grid .axis-label, .atlas-grid button { font-size: 11px; }
  #population-canvas { height: 420px; }
  .archive-stats { grid-template-columns: repeat(2, 1fr); }
  .archive-stats div:nth-child(2) { border-right: 0; }
  .archive-stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .site-footer p { text-align: left; }
}

@media (max-width: 440px) {
  .brand small { display: none; }
  .header-download { font-size: 13px; }
  .answer-row { grid-template-columns: 1fr; }
  .narrative { min-height: 650px; }
  .atlas-detail { padding: 18px; }
  .atlas-previews { grid-template-columns: 1fr; }
  .atlas-previews figure:last-child { grid-column: auto; }
  .population-legend { align-items: flex-start; flex-direction: column; gap: 8px; }
  .primary-download { align-items: flex-start; flex-direction: column; }
  .download-blocks { grid-template-columns: 1fr; }
  .download-blocks a, .download-blocks a:nth-child(2n), .download-blocks a:last-child { grid-column: auto; border-right: 0; }
  .load-example { grid-template-columns: 1fr; }
}

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