:root {
  /* Theme W1: Deep Black & Phosphor Green */
  --bg: #060807;
  --bg-elevated: #0d120f;
  --bg-card: rgba(255, 255, 255, 0.02);
  --bg-card-highlight: rgba(216, 255, 100, 0.06);
  --border-card-highlight: rgba(216, 255, 100, 0.28);
  --text: #f5f7f5;
  --text-muted: #6f7d74;
  --rule: rgba(255, 255, 255, 0.08);
  --rule-subtle: rgba(255, 255, 255, 0.04);
  --accent: #d8ff64;
  --accent-soft: rgba(216, 255, 100, 0.12);
  --gain-number: #d8ff64;
  --highlight-row-text: #d8ff64;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="w2"],
body.theme-w2 {
  /* Theme W2: Warm Charcoal & Monochromatic Off-White */
  --bg: #161514;
  --bg-elevated: #22201f;
  --bg-card: rgba(255, 255, 255, 0.035);
  --bg-card-highlight: rgba(255, 255, 255, 0.08);
  --border-card-highlight: rgba(255, 255, 255, 0.32);
  --text: #f4f4f2;
  --text-muted: #8e8d8a;
  --rule: rgba(255, 255, 255, 0.11);
  --rule-subtle: rgba(255, 255, 255, 0.06);
  --accent: #f4f4f2;
  --accent-soft: rgba(255, 255, 255, 0.1);
  --gain-number: #ffffff;
  --highlight-row-text: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: auto;
}

body {
  background: var(--bg);
  color: var(--text);
  min-width: 320px;
  overflow-x: hidden;
  line-height: 1.5;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

a {
  color: inherit;
  text-decoration: none;
}

/* ------------------------------------------------------------------ *
 * Minimalist Header & Theme Switcher
 * ------------------------------------------------------------------ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 24px clamp(24px, 5vw, 64px);
  background: linear-gradient(180deg, rgba(6, 8, 7, 0.94) 0%, rgba(6, 8, 7, 0) 100%);
  pointer-events: none;
}

[data-theme="w2"] .site-header {
  background: linear-gradient(180deg, rgba(22, 21, 20, 0.95) 0%, rgba(22, 21, 20, 0) 100%);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1360px;
  margin: 0 auto;
}

.brand {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text);
  pointer-events: auto;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  pointer-events: auto;
}

/* Theme Switchers */
.theme-switchers {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.theme-btn {
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
}

.theme-btn:hover {
  color: var(--text);
}

.theme-btn.is-active {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
}

.theme-divider {
  color: var(--rule);
  font-size: 10px;
}

.report-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.repo-link {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  transition: color 0.2s var(--ease);
}

.repo-link:hover {
  color: var(--text);
}

/* ------------------------------------------------------------------ *
 * Story Section (Pinned Editorial Split with Continuous Thread Line)
 * ------------------------------------------------------------------ */
.story-section {
  position: relative;
  height: 380vh; /* Controlled scroll length for 3 stages */
  background: var(--bg);
}

.story-viewport {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  overflow: hidden;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 64px);
}

/* Left Editorial Column */
.editorial-col {
  width: 46%;
  height: 100%;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 10;
  padding-right: 32px;
}

.editorial-sticky {
  position: relative;
  width: 100%;
  max-width: 520px;
}

.story-sentence {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  display: none;
  pointer-events: none;
}

.story-sentence:not(.is-active) {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.story-sentence.is-active {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(-50%);
}

.sentence-kicker {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 24px;
}

.sentence-title {
  font-size: clamp(42px, 4.4vw, 72px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.05em;
  color: var(--text);
}

.sentence-title .accent-sub {
  color: var(--text-muted);
  font-weight: 400;
  display: block;
  margin-top: 4px;
}

/* Right 3D Visual Column */
.visual-col {
  width: 54%;
  height: 100%;
  position: relative;
}

#stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.scroll-cue {
  position: absolute;
  bottom: 32px;
  right: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  opacity: 0.6;
  transition: opacity 0.3s;
}

/* ------------------------------------------------------------------ *
 * Results Section (2x Larger Typography & Real Contrast)
 * ------------------------------------------------------------------ */
.results-section {
  position: relative;
  z-index: 20;
  background: var(--bg);
  border-top: 1px solid var(--rule);
  padding: 160px clamp(24px, 5vw, 64px) 140px;
}

.results-inner {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.results-header {
  margin-bottom: 64px;
}

.results-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-bottom: 20px;
  display: block;
  font-weight: 600;
}

.results-headline {
  font-size: clamp(38px, 4.6vw, 64px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.08;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: break-word;
}

.results-headline .gain-number {
  color: var(--gain-number);
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: 32px;
  display: block;
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  font-family: var(--font-mono);
  text-align: left;
}

.results-table th {
  padding: 16px 20px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.results-table td {
  padding: 24px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  color: var(--text);
  white-space: nowrap;
  vertical-align: middle;
  transition: background 0.2s, border-color 0.2s;
}

.results-table td:first-child {
  border-left: 1px solid var(--rule);
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

.results-table td:last-child {
  border-right: 1px solid var(--rule);
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* 2x Larger Pass Rate Numbers */
.rate-large {
  font-size: clamp(26px, 2.6vw, 38px);
  font-weight: 700;
  letter-spacing: -0.02em;
  display: block;
}

.rate-medium {
  font-size: clamp(20px, 2.0vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  display: block;
}

.col-name {
  font-size: clamp(16px, 1.5vw, 20px);
  font-weight: 500;
}

.col-passes {
  font-size: clamp(15px, 1.4vw, 19px);
  color: var(--text-muted);
}

.col-inv {
  font-size: clamp(13.5px, 1.3vw, 16px);
  color: var(--text-muted);
}

/* High-Contrast Highlight Row (CD-AVC Cage) */
.results-table tr.highlight-row td {
  background: var(--bg-card-highlight);
  border-color: var(--border-card-highlight);
  color: var(--highlight-row-text);
}

.results-table tr.highlight-row .col-name {
  color: var(--highlight-row-text);
  font-weight: 600;
}

.results-table tr.highlight-row .col-passes {
  color: var(--highlight-row-text);
  opacity: 0.95;
}

.results-table tr.highlight-row .col-inv {
  color: var(--highlight-row-text);
  opacity: 0.9;
}

.results-footnote {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 16px;
  max-width: 840px;
}

/* Secondary Table (Plan-90 Pilot Benchmark - Honest Secondary Label) */
.secondary-table-wrap {
  margin-top: 80px;
  padding: 40px clamp(16px, 3vw, 36px);
  background: var(--bg-card);
  border: 1px dashed var(--rule);
  border-radius: 12px;
  width: 100%;
  max-width: 100%;
}

.secondary-header {
  margin-bottom: 24px;
}

.secondary-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.secondary-scroll-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.secondary-table td {
  padding: 18px 20px;
}

/* Support direct snapshotting of results section */
body.view-results-snapshot .story-section {
  display: none !important;
}

body.view-results-snapshot .results-section {
  padding-top: 100px;
}

/* ------------------------------------------------------------------ *
 * Minimalist Footer
 * ------------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 40px clamp(24px, 5vw, 64px);
  background: var(--bg);
}

.footer-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.footer-inner a:hover {
  color: var(--text);
}

/* ------------------------------------------------------------------ *
 * Mobile Responsiveness (390px Viewports)
 * ------------------------------------------------------------------ */
@media (max-width: 860px) {
  .site-header {
    padding: 16px 20px;
  }

  .header-right .repo-link {
    display: none; /* Keep header clean on mobile; GitHub link is in footer */
  }

  .report-badge {
    font-size: 10.5px;
    letter-spacing: 0.06em;
  }

  .story-viewport {
    flex-direction: column;
    padding: 0 20px;
  }

  .editorial-col {
    width: 100%;
    height: 42vh;
    padding-top: 70px;
    padding-right: 0;
    align-items: flex-end;
  }

  .editorial-sticky {
    max-width: 100%;
  }

  .story-sentence {
    top: auto;
    bottom: 16px;
    transform: none;
  }

  .story-sentence.is-active {
    transform: none;
  }

  .sentence-kicker {
    margin-bottom: 8px;
    font-size: 10px;
  }

  .sentence-title {
    font-size: clamp(26px, 7vw, 36px);
    line-height: 1.08;
  }

  .visual-col {
    width: 100%;
    height: 58vh;
  }

  .scroll-cue {
    bottom: 16px;
    right: 8px;
  }

  .results-section {
    padding: 70px 20px 50px;
  }

  .results-headline {
    font-size: clamp(24px, 6.2vw, 32px);
    line-height: 1.12;
  }

  .results-table {
    border-spacing: 0 8px;
  }

  .results-table th {
    padding: 10px 12px;
    font-size: 10px;
  }

  .results-table td {
    padding: 16px 12px;
    font-size: 11.5px;
  }

  .rate-large {
    font-size: 24px;
  }

  .rate-medium {
    font-size: 20px;
  }

  .col-name {
    font-size: 13.5px;
  }

  .col-passes {
    font-size: 13px;
  }

  .col-inv {
    font-size: 11.5px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* ------------------------------------------------------------------ *
 * Strict 390px Mobile Preview Mode
 * ------------------------------------------------------------------ */
body.is-mobile-preview {
  width: 390px !important;
  max-width: 390px !important;
  margin: 0 !important;
  overflow-x: hidden !important;
}

body.is-mobile-preview .site-header {
  width: 390px !important;
  max-width: 390px !important;
  left: 0 !important;
  right: auto !important;
  padding: 16px 20px !important;
}

body.is-mobile-preview .header-right .repo-link {
  display: none !important;
}

body.is-mobile-preview .header-inner {
  width: 350px !important;
  max-width: 350px !important;
}

body.is-mobile-preview .story-viewport {
  width: 390px !important;
  max-width: 390px !important;
  flex-direction: column !important;
  padding: 0 20px !important;
}

body.is-mobile-preview .editorial-col {
  width: 350px !important;
  max-width: 350px !important;
  height: 42vh !important;
  padding-top: 70px !important;
  padding-right: 0 !important;
  align-items: flex-end !important;
}

body.is-mobile-preview .visual-col {
  width: 350px !important;
  max-width: 350px !important;
  height: 58vh !important;
}

body.is-mobile-preview .results-section {
  width: 390px !important;
  max-width: 390px !important;
  padding: 70px 20px 50px !important;
}

body.is-mobile-preview .results-inner {
  width: 350px !important;
  max-width: 350px !important;
}

body.is-mobile-preview .table-wrap {
  width: 350px !important;
  max-width: 350px !important;
  overflow-x: auto !important;
}

body.is-mobile-preview .secondary-table-wrap {
  width: 350px !important;
  max-width: 350px !important;
  overflow-x: auto !important;
}

body.is-mobile-preview .site-footer {
  width: 390px !important;
  max-width: 390px !important;
  padding: 40px 20px !important;
}
