:root {
  color-scheme: dark;
  --bg: #0B0A08;
  --panel: #12100D;
  --bone: #EDE6DA;
  --muted: #8A8175;
  --arterial: #FF4A2D;
  --amber: #FFB454;
  --positive: #7DC383;
  --negative: #E5484D;
  --line: rgba(237, 230, 218, 0.13);
  --line-soft: rgba(237, 230, 218, 0.07);
  --mono: "SFMono-Regular", "IBM Plex Mono", "JetBrains Mono", Menlo, monospace;
  --display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  font-family: var(--display);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--bone);
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(rgba(237, 230, 218, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(237, 230, 218, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--bone);
}

a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 50;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.8rem 1rem;
  transform: translateY(-150%);
  background: var(--bone);
  color: var(--bg);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
  padding: 0 clamp(22px, 4.2vw, 72px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(11, 10, 8, 0.94);
  backdrop-filter: blur(16px);
}

.wordmark, .footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  width: fit-content;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.wordmark-mark {
  position: relative;
  width: 21px;
  height: 13px;
  border-top: 1px solid var(--arterial);
}

.wordmark-mark::after {
  position: absolute;
  top: -4px;
  left: 7px;
  width: 4px;
  height: 10px;
  border-left: 1px solid var(--arterial);
  border-right: 1px solid var(--arterial);
  content: "";
}

.chapter-nav, .site-footer nav {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2.2vw, 32px);
}

.chapter-nav a, .site-footer nav a {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: color 160ms ease;
}

.chapter-nav a:hover, .site-footer nav a:hover { color: var(--bone); }

.pilot-status, .closing-status {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 0.55rem;
  color: var(--bone);
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--arterial);
  box-shadow: 0 0 12px rgba(255, 74, 45, 0.5);
}

.story-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.08fr);
  align-items: stretch;
  width: min(100%, 1680px);
  margin: 0 auto;
}

.stage-panel {
  position: sticky;
  z-index: 5;
  top: 100px;
  align-self: start;
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto auto;
  min-height: min(720px, calc(100svh - 120px));
  height: calc(100svh - 116px);
  padding: clamp(22px, 3.4vw, 56px) clamp(20px, 3.2vw, 54px) 24px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(135deg, rgba(18, 16, 13, 0.42), rgba(11, 10, 8, 0.02));
}

.stage-head, .stage-foot, .stage-cadence {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.59rem;
  letter-spacing: 0.09em;
}

.stage-head { color: var(--bone); }
.stage-phase { color: var(--arterial); }

.stage-graphic {
  position: relative;
  display: grid;
  align-items: center;
  min-height: 210px;
  margin: 22px -22px 18px;
  overflow: hidden;
}

.pulse-svg { display: block; width: 100%; height: clamp(220px, 38vh, 420px); overflow: visible; }
.stage-grid-lines { fill: none; stroke: rgba(237, 230, 218, 0.06); stroke-width: 1; }
.stage-baseline { fill: none; stroke: rgba(237, 230, 218, 0.17); stroke-width: 1; }
.cadence-marks { fill: none; stroke: rgba(255, 180, 84, 0.58); stroke-width: 1.5; }
.pulse-line { fill: none; stroke: var(--arterial); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 9px rgba(255, 74, 45, 0.22)); }
.clearance-comb { fill: none; stroke: var(--amber); stroke-width: 2; opacity: 0; }
.toxic-markers { fill: var(--amber); opacity: 0; filter: drop-shadow(0 0 8px rgba(255, 180, 84, 0.24)); }
.toxic-markers circle:nth-child(2n) { fill: var(--arterial); }
.stage-foot { padding-top: 10px; border-top: 1px solid var(--line); }
.stage-foot span:last-child { color: var(--amber); }
.stage-cadence { justify-content: flex-start; gap: 1.2rem; padding-top: 18px; font-size: 0.55rem; }
.stage-cadence b { margin-right: 0.3rem; color: var(--bone); font-weight: 500; }

.chapters { min-width: 0; }

.chapter {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 94svh;
  padding: clamp(60px, 8vh, 112px) clamp(28px, 5vw, 82px);
  border-bottom: 1px solid var(--line-soft);
  scroll-margin-top: 90px;
}

.hero { min-height: calc(100svh - 76px); justify-content: center; }
.eyebrow, .step-index, .lane-card > span, .snapshot-label, .tail-label, .reflex-caption, .scroll-cue, .rhythm-footer {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.eyebrow { display: flex; gap: 1rem; margin: 0 0 26px; }
.eyebrow span:first-child { color: var(--arterial); }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-weight: 500; }
h1, h2 { letter-spacing: -0.055em; }
h1 { max-width: 10ch; margin-bottom: 24px; font-size: clamp(3.7rem, 7vw, 7.5rem); line-height: 0.95; }
h1 em { color: var(--arterial); font-style: normal; }
h2 { max-width: 13ch; margin-bottom: 24px; font-size: clamp(2.8rem, 5.2vw, 5.5rem); line-height: 0.99; }
h3 { margin-bottom: 13px; font-size: 1.15rem; letter-spacing: -0.03em; }

.hero-copy, .section-lede {
  max-width: 48ch;
  margin-bottom: 0;
  color: #B9B0A4;
  font-size: clamp(1rem, 1.2vw, 1.13rem);
  line-height: 1.75;
}

.hero-ctas { display: flex; align-items: center; gap: 1.4rem; margin: 32px 0 42px; }
.text-link { color: var(--bone); font-family: var(--mono); font-size: 0.72rem; text-decoration-color: var(--arterial); text-underline-offset: 6px; }
.text-link span { margin-left: 0.4rem; color: var(--arterial); }
.hero-note { color: var(--muted); font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.05em; }

.terminal-ribbon {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: rgba(18, 16, 13, 0.8);
}

.terminal-ribbon > div { display: grid; gap: 12px; min-height: 82px; padding: 16px 13px; border-right: 1px solid var(--line); }
.terminal-ribbon > div:last-child { border-right: 0; }
.terminal-ribbon span { color: var(--muted); font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.055em; line-height: 1.4; }
.terminal-ribbon strong { font-family: var(--mono); font-size: 1.1rem; font-weight: 400; letter-spacing: -0.04em; }
.scroll-cue { display: flex; align-items: center; gap: 12px; margin: 30px 0 0; font-size: 0.56rem; }
.scroll-cue-line { width: 26px; height: 1px; background: var(--arterial); }

.section-lede { max-width: 54ch; }
.steps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 46px; }
.step-card { min-height: 206px; padding: 20px 17px; border: 1px solid var(--line); background: linear-gradient(145deg, rgba(18, 16, 13, 0.9), rgba(18, 16, 13, 0.36)); }
.step-index { display: block; margin-bottom: 40px; color: var(--arterial); font-size: 0.57rem; }
.step-card p, .lane-card p { margin-bottom: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.65; }
.rhythm-footer { display: flex; justify-content: space-between; gap: 1rem; margin-top: 26px; padding-top: 15px; border-top: 1px solid var(--line); font-size: 0.56rem; }
.rhythm-footer span:last-child { color: var(--bone); }

.gate-rail { display: flex; align-items: center; margin: 42px 0 28px; }
.gate-node { display: grid; gap: 12px; min-width: 70px; color: var(--bone); font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.02em; }
.gate-node span { color: var(--amber); font-size: 0.56rem; }
.gate-node b { font-weight: 400; white-space: nowrap; }
.gate-connector { flex: 1; height: 1px; margin: 0 9px; background: linear-gradient(90deg, var(--amber), var(--line)); }
.zero-scan { display: flex; align-items: center; gap: 18px; padding: 21px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.zero-mark { color: var(--amber); font-family: var(--mono); font-size: 2.8rem; line-height: 1; }
.zero-scan p { margin: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.7; }
.zero-scan strong { color: var(--bone); font-weight: 500; }
.lane-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.lane-card { padding: 18px; border: 1px solid var(--line); background: rgba(18, 16, 13, 0.72); }
.lane-card > span { font-size: 0.54rem; }
.lane-card h3 { margin: 16px 0 9px; color: var(--bone); font-family: var(--mono); font-size: 0.93rem; letter-spacing: -0.03em; }

.expel-section { background: linear-gradient(90deg, rgba(255, 74, 45, 0.035), transparent 62%); }
.reflex-list { margin-top: 46px; border-top: 1px solid var(--line); }
.reflex-list > div { display: grid; grid-template-columns: 48px 1.1fr 1fr; align-items: center; gap: 10px; min-height: 70px; border-bottom: 1px solid var(--line); }
.reflex-index { color: var(--amber); font-family: var(--mono); font-size: 0.65rem; }
.reflex-list strong { font-size: 0.97rem; font-weight: 500; }
.reflex-list > div span:last-child { color: var(--muted); font-size: 0.72rem; }
.reflex-caption { display: flex; align-items: center; gap: 10px; margin: 26px 0 0; font-size: 0.55rem; }
.amber-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }

.book-section { justify-content: flex-start; padding-top: clamp(58px, 8vh, 96px); }
.snapshot-label { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 32px 0 14px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 0.54rem; }
.snapshot-label strong { color: var(--amber); font-weight: 400; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); background: rgba(18, 16, 13, 0.84); }
table { width: 100%; min-width: 600px; border-collapse: collapse; font-family: var(--mono); font-variant-numeric: tabular-nums; }
th, td { padding: 17px 14px; border-bottom: 1px solid var(--line); text-align: right; font-size: 0.67rem; font-weight: 400; white-space: nowrap; }
thead th { color: var(--muted); font-size: 0.55rem; letter-spacing: 0.03em; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody th { color: var(--bone); }
.positive { color: var(--positive); }
.tail-note { display: grid; grid-template-columns: 150px 1fr; gap: 12px; margin: 18px 0 0; color: var(--muted); font-size: 0.73rem; line-height: 1.7; }
.tail-label { color: var(--negative); font-size: 0.53rem; }
.tail-note strong { color: var(--negative); font-family: var(--mono); font-size: 0.68rem; font-weight: 400; }
.risk-note { display: flex; gap: 14px; margin-top: 32px; padding: 17px 18px; border: 1px solid rgba(255, 180, 84, 0.34); background: rgba(255, 180, 84, 0.045); }
.risk-icon { display: grid; flex: 0 0 22px; place-items: center; width: 22px; height: 22px; border: 1px solid var(--amber); border-radius: 50%; color: var(--amber); font-family: var(--mono); font-size: 0.7rem; }
.risk-note p { margin: 0; color: var(--muted); font-size: 0.77rem; line-height: 1.7; }
.risk-note strong { color: var(--bone); font-weight: 500; }

.closing { min-height: 88svh; border-bottom: 0; }
.closing h2 { max-width: 11ch; }
.closing-lockup { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--line); }
.closing-name { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.15em; }
.closing-cta { display: flex; align-items: center; justify-content: space-between; width: fit-content; min-width: 208px; gap: 44px; margin-top: 22px; padding: 14px 17px; border: 1px solid var(--arterial); color: var(--bone); font-family: var(--mono); font-size: 0.68rem; text-decoration: none; transition: background 160ms ease, color 160ms ease; }
.closing-cta span { color: var(--arterial); }
.closing-cta:hover { background: var(--arterial); color: var(--bg); }
.closing-cta:hover span { color: var(--bg); }
.closing-footnote { margin: 20px 0 0; color: var(--muted); font-family: var(--mono); font-size: 0.58rem; line-height: 1.6; }

.site-footer { display: flex; align-items: center; justify-content: space-between; min-height: 86px; padding: 20px clamp(22px, 4.2vw, 72px); border-top: 1px solid var(--line-soft); }
.footer-brand { gap: 11px; font-size: 0.66rem; }
.footer-brand span { color: var(--muted); font-family: var(--mono); font-size: 0.51rem; font-weight: 400; letter-spacing: 0.06em; }
.site-footer nav { gap: 20px; }
.site-footer nav a { font-size: 0.56rem; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }

@media (max-width: 900px) {
  .topbar { grid-template-columns: auto 1fr auto; padding-inline: 22px; }
  .chapter-nav { gap: 12px; }
  .chapter-nav a { font-size: 0.57rem; }
  .story-grid { grid-template-columns: minmax(250px, 0.78fr) minmax(0, 1.22fr); }
  .stage-panel { padding-inline: 20px; }
  .stage-cadence { gap: 0.8rem; font-size: 0.5rem; }
  .chapter { padding-inline: 32px; }
  .steps-grid { grid-template-columns: 1fr; }
  .step-card { min-height: auto; }
  .step-index { margin-bottom: 20px; }
}

@media (max-width: 700px) {
  .topbar { min-height: 60px; grid-template-columns: 1fr auto; padding-inline: 18px; }
  .wordmark { font-size: 0.72rem; }
  .chapter-nav { display: none; }
  .pilot-status { font-size: 0.54rem; }
  .story-grid { display: block; }
  .stage-panel {
    position: sticky;
    top: 60px;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 17px 48px 15px;
    gap: 3px;
    width: 100%;
    min-height: 0;
    height: 94px;
    padding: 8px 18px 5px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(11, 10, 8, 0.97);
    backdrop-filter: blur(14px);
  }
  .stage-head, .stage-foot { font-size: 0.48rem; }
  .stage-graphic { grid-row: 2; min-height: 0; height: 48px; margin: 0 -8px; }
  .pulse-svg { height: 48px; }
  .stage-foot { grid-row: 3; padding-top: 0; border-top: 0; }
  .stage-cadence { display: none; }
  .chapter { min-height: 82svh; padding: 82px 22px 68px; scroll-margin-top: 158px; }
  .hero { min-height: calc(100svh - 154px); padding-top: 48px; }
  .eyebrow { margin-bottom: 20px; font-size: 0.58rem; }
  h1 { max-width: 9ch; margin-bottom: 20px; font-size: clamp(3.3rem, 14vw, 5rem); }
  h2 { max-width: 12ch; margin-bottom: 18px; font-size: clamp(2.8rem, 11.5vw, 4rem); }
  .hero-copy, .section-lede { font-size: 0.93rem; line-height: 1.7; }
  .hero-ctas { flex-wrap: wrap; gap: 13px 20px; margin: 26px 0 32px; }
  .terminal-ribbon { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .terminal-ribbon > div { min-height: 66px; padding: 12px; border-bottom: 1px solid var(--line); }
  .terminal-ribbon > div:nth-child(2) { border-right: 0; }
  .terminal-ribbon > div:nth-child(n+3) { border-bottom: 0; }
  .terminal-ribbon span { font-size: 0.48rem; }
  .terminal-ribbon strong { font-size: 0.98rem; }
  .scroll-cue { margin-top: 22px; }
  .steps-grid { gap: 8px; margin-top: 30px; }
  .step-card { padding: 16px; }
  .step-index { margin-bottom: 18px; }
  .step-card p, .lane-card p { font-size: 0.78rem; }
  .rhythm-footer { font-size: 0.5rem; }
  .gate-rail { align-items: stretch; flex-direction: column; gap: 0; margin: 30px 0 22px; }
  .gate-node { grid-template-columns: 28px 1fr; align-items: center; gap: 8px; min-height: 36px; font-size: 0.57rem; }
  .gate-connector { flex: 0 0 13px; width: 1px; height: 13px; margin: 0 0 0 4px; background: var(--line); }
  .zero-scan { gap: 14px; padding: 16px 0; }
  .zero-mark { font-size: 2.3rem; }
  .lane-grid { grid-template-columns: 1fr; gap: 8px; margin-top: 15px; }
  .lane-card { padding: 15px; }
  .lane-card h3 { margin: 12px 0 6px; }
  .reflex-list { margin-top: 30px; }
  .reflex-list > div { grid-template-columns: 34px 1.05fr 1fr; gap: 6px; min-height: 66px; }
  .reflex-list strong { font-size: 0.83rem; }
  .reflex-list > div span:last-child { font-size: 0.62rem; }
  .reflex-caption { font-size: 0.5rem; }
  .book-section { padding-top: 60px; }
  .snapshot-label { display: grid; grid-template-columns: 1fr; gap: 7px; margin-top: 25px; font-size: 0.5rem; }
  .table-scroll { margin-inline: -8px; }
  th, td { padding: 14px 11px; font-size: 0.61rem; }
  thead th { font-size: 0.51rem; }
  .tail-note { grid-template-columns: 1fr; gap: 6px; font-size: 0.7rem; }
  .risk-note { margin-top: 24px; padding: 14px; }
  .risk-note p { font-size: 0.72rem; }
  .closing { min-height: 78svh; }
  .closing-lockup { align-items: flex-start; flex-direction: column; gap: 14px; margin-top: 34px; }
  .closing-status { justify-self: start; }
  .site-footer { align-items: flex-start; flex-direction: column; gap: 17px; min-height: 106px; padding: 20px 22px; }
  .site-footer nav { flex-wrap: wrap; gap: 14px 20px; }
}

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