:root {
  color-scheme: light;
  --paper: #f3f3f1;
  --ink: #151718;
  --muted: #6d7173;
  --line: rgba(21, 23, 24, 0.15);
  --red: #bb3f3f;
  --panel: rgba(243, 243, 241, 0.86);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

button, a { color: inherit; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  height: 68px;
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 243, 241, 0.82);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  font: 700 11px/1.1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.16em;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--ink);
  border-radius: 50%;
  top: 4px;
  left: 4px;
}

.top-metrics {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font: 600 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.14em;
}

.stage {
  position: fixed;
  inset: 68px 0 0 0;
  z-index: 1;
  overflow: hidden;
  background: var(--paper);
}

#scene-canvas { width: 100%; height: 100%; display: block; touch-action: pan-y; }

.stage-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image:
    linear-gradient(to right, rgba(21, 23, 24, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(21, 23, 24, 0.07) 1px, transparent 1px);
  background-size: 74px 74px;
  mask-image: linear-gradient(to right, black, transparent 70%);
}

.stage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 61% 48%, transparent 0 42%, rgba(243,243,241,.04) 70%, rgba(243,243,241,.18) 100%);
}

.stage-label {
  position: absolute;
  left: max(30px, 3vw);
  bottom: 31px;
  width: min(420px, 40vw);
  transition: opacity 220ms ease, transform 220ms ease;
}

.stage-label .eyebrow,
.step-kind {
  display: block;
  margin: 0 0 12px;
  color: var(--muted);
  font: 700 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.18em;
}

.stage-label h2 { margin: 0 0 8px; font-size: clamp(20px, 2.2vw, 34px); letter-spacing: -0.045em; }
.stage-label p { margin: 0; color: var(--muted); font-size: 12px; }

.legend {
  position: absolute;
  right: 32px;
  bottom: 31px;
  display: flex;
  gap: 16px;
  min-height: 18px;
  color: var(--muted);
  font: 600 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.legend-line { width: 18px; border-top: 1px solid currentColor; }

.view-controls {
  position: absolute;
  right: 30px;
  top: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font: 600 9px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .1em;
}

.view-controls button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(243,243,241,.7);
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

.view-controls button:hover { border-color: var(--ink); }

.loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--paper);
  transition: opacity 400ms ease, visibility 400ms ease;
}

.loading.done { opacity: 0; visibility: hidden; }
.loading span { width: 26px; height: 26px; border: 1px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin 800ms linear infinite; }
.loading p { margin: 0; color: var(--muted); font: 600 10px/1 ui-monospace, monospace; letter-spacing: .12em; }
@keyframes spin { to { transform: rotate(360deg); } }

.story { position: relative; z-index: 5; width: 100%; pointer-events: none; }

.story-step {
  min-height: 115vh;
  display: flex;
  align-items: center;
  padding: 90px 0 90px max(30px, 6vw);
}

.step-card {
  width: min(410px, 36vw);
  padding: 26px 28px 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
  opacity: .14;
  transform: translateY(28px);
  transition: opacity 380ms ease, transform 380ms ease;
}

.story-step.active .step-card { opacity: 1; transform: translateY(0); }
.step-index { display: block; margin-bottom: 42px; color: var(--muted); font: 500 11px/1 ui-monospace, monospace; }
.step-card h1 { margin: 0 0 22px; font-size: clamp(30px, 3.4vw, 54px); line-height: .99; letter-spacing: -.065em; }
.step-card > p:last-child { max-width: 34em; margin: 0; color: #555a5c; font-size: 13px; line-height: 1.8; }
.final-card { border-color: rgba(21,23,24,.35); }

.story-step--table .step-card {
  width: min(480px, 40vw);
}

.story-step--table .step-card h1 {
  font-size: clamp(30px, 2.65vw, 44px);
  line-height: 1.06;
  letter-spacing: -.05em;
  word-break: keep-all;
}

.progress {
  position: fixed;
  z-index: 25;
  top: 50%;
  right: 22px;
  transform: translateY(-50%);
  display: flex;
  gap: 16px;
  pointer-events: auto;
}

.progress-line {
  position: relative;
  width: 1px;
  background: repeating-linear-gradient(to bottom, rgba(21,23,24,.22) 0 5px, rgba(21,23,24,.06) 5px 9px);
}

.progress-line > span {
  position: absolute;
  inset: 0 0 auto;
  height: 0;
  background: var(--ink);
  transition: height 220ms ease;
}

.progress-camera {
  position: absolute;
  z-index: 2;
  left: -5px;
  top: 0;
  width: 11px;
  height: 8px;
  border: 1px solid var(--ink);
  background: var(--paper);
  transform: translateY(-50%);
  transition: top 220ms ease;
}

.progress-camera::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 1px;
  width: 0;
  height: 0;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  border-left: 5px solid var(--ink);
}

.progress-camera::after {
  content: "";
  position: absolute;
  left: 17px;
  top: 3px;
  width: 9px;
  border-top: 1px solid rgba(21,23,24,.22);
}

.progress nav { display: flex; flex-direction: column; gap: 6px; }
.progress-chapter {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 100px;
  margin: 4px 0 2px;
  color: var(--ink);
  white-space: nowrap;
}
.progress-chapter:first-child { margin-top: 0; }
.progress-chapter span { font: 700 8px/1 ui-monospace, monospace; letter-spacing: .09em; }
.progress-chapter b { font: 600 10px/1 "Noto Sans SC", "Microsoft YaHei", sans-serif; }
.progress a { min-width: 100px; display: flex; gap: 8px; text-decoration: none; opacity: .32; transition: opacity 180ms ease; white-space: nowrap; }
.progress a.active { opacity: 1; }
.progress a span, .progress a b { font: 600 9px/1 ui-monospace, monospace; }
.progress a b { font-weight: 500; }

@media (max-width: 900px) {
  .topbar { padding: 0 18px; }
  .top-metrics span:first-child, .progress { display: none; }
  .story-step { align-items: flex-end; padding: 70px 18px 100px; }
  .step-card { width: min(520px, 92vw); padding: 20px; }
  .story-step--table .step-card { width: min(520px, 92vw); }
  .step-index { margin-bottom: 18px; }
  .step-card h1 { font-size: 34px; }
  .story-step--table .step-card h1 { font-size: 32px; }
  .stage-label { display: none; }
  .legend { right: 18px; bottom: 18px; }
  .view-controls { right: 18px; top: 16px; }
}

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

.current-evidence-panel { position: absolute; z-index: 12; top: 7%; right: max(140px,10vw); width: min(500px,38vw); max-height: 79%; overflow: auto; overscroll-behavior: contain; padding: 24px; background: rgba(243,243,241,.96); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(21,23,24,.08); pointer-events: auto; scrollbar-width: thin; }
.current-evidence-panel[hidden] { display: none; }
.current-eyebrow { color: var(--muted); font: 600 9px/1.6 monospace !important; letter-spacing: .13em; }
.current-evidence-panel h3 { margin: 14px 0 20px; font-size: clamp(22px,2vw,32px); letter-spacing: -.05em; line-height: 1.15; }
.current-evidence-panel p { font-size: 12px; line-height: 1.8; }
.current-note { color: var(--muted); font-size: 10px !important; }
.current-stat-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; margin: 30px 0; }
.current-stat-grid span { border-top: 1px solid var(--line); padding: 12px 0; color: var(--muted); font-size: 11px; }
.current-stat-grid b { display: block; margin-top: 12px; color: var(--ink); font: 500 32px/1 monospace; }
.angular-chart { display: block; width: 100%; }
.route-map { display: block; width: 100%; background: linear-gradient(90deg,rgba(21,23,24,.04) 1px,transparent 1px),linear-gradient(rgba(21,23,24,.04) 1px,transparent 1px); background-size: 28px 28px; }
.route-map text { font: 9px monospace; }
.current-jump { color: #247f78; font: 600 10px/1.5 monospace; text-decoration: none; white-space: nowrap; }
.angular-chart text { font: 9px monospace; }
.angular-point { cursor: pointer; }
.angular-point:hover circle,.angular-point.chosen circle { fill: #bb3f3f; }
.angular-point:focus-visible { outline: 2px solid #bb3f3f; }
.current-photo { margin: 16px 0 0; }
.current-photo img { width: 100%; height: auto; display: block; }
.current-photo figcaption { margin: 8px 0; color: var(--muted); font: 9px/1.7 monospace; }
.route-comparison { width: 100%; border-collapse: collapse; font: 11px/1.7 monospace; }
.route-comparison td,.route-comparison th { border-bottom: 1px solid var(--line); padding: 10px 4px; text-align: right; }
.route-comparison th:first-child,.route-comparison td:first-child { text-align: left; font-family: "Microsoft YaHei",sans-serif; }
.evidence-switch { display: flex; gap: 16px; margin: 18px 0; font-size: 11px; }
.evidence-switch input,.current-evidence-panel input[type="range"] { accent-color: #247f78; }
.current-play { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 10px; margin: 20px 0 14px; }
.current-play button { border: 1px solid var(--line); padding: 8px 12px; background: transparent; font-size: 11px; cursor: pointer; }
.current-play span { font: 9px/1.6 monospace; color: var(--muted); }
.current-evidence-panel input[type="range"] { width: 100%; margin: 12px 0; }
.arrival-list { display: grid; gap: 4px; margin-top: 14px; }
.arrival-list button { display: flex; align-items: center; gap: 12px; text-align: left; padding: 9px 6px; border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; color: #8a8d8e; }
.arrival-list button.visited { color: #247f78; }
.arrival-list button > b { font: 500 21px monospace; }
.arrival-list button > span { font: 10px monospace; flex: 1; }
.arrival-list button small { display: block; margin-top: 5px; font: 9px monospace; }
.arrival-list button em { font: 9px monospace; }
.current-evidence-panel video { display: block; width: 100%; background: #222; }
.current-thumb-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-top: 14px; }
.current-thumb-grid button { border: 1px solid transparent; background: transparent; padding: 0; text-align: left; cursor: pointer; }
.current-thumb-grid button.chosen { border-color: #247f78; }
.current-thumb-grid img { display: block; width: 100%; }
.current-thumb-grid span { display: block; font: 8px/1.7 monospace; margin-top: 4px; }
.progress { max-height: calc(100vh - 115px); }
.progress nav { overflow-y: auto; scrollbar-width: thin; padding-right: 5px; }
@media(max-width:900px) {
  .current-evidence-panel { top: 58px; right: 18px; width: calc(100% - 36px); max-height: 49%; padding: 18px; }
  .current-evidence-panel h3 { font-size: 24px; }
  .story-step[data-step="21"],.story-step[data-step="22"],.story-step[data-step="23"],.story-step[data-step="24"],.story-step[data-step="25"],.story-step[data-step="26"] { padding-bottom: 28px; }
  .angular-chart { max-height: 220px; }
}
