/* ===== DESIGN TOKENS ===== */
:root {
  --bg: #fbfaf7;
  --bg-elevated: #ffffff;
  --ink: #15212e;
  --ink-soft: #3a4a5c;
  --ink-muted: #6b7785;
  --rule: #e3e0d8;
  --upstream: #1f3a52;
  --midmarket: #4a7396;
  --downstream: #7aa6cc;
  --feedback: #16a085;
  --accent: #c8392c;

  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --content-max: 920px;
  --nav-h: 56px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 18px;
}

/* ===== NAV ===== */
.nav-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(251,250,247,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; padding: 0 24px;
}
.nav-paper {
  font-family: var(--font-sans);
  font-weight: 600; font-size: 14px; color: var(--ink);
}
.nav-sub {
  font-family: var(--font-sans);
  font-weight: 400; font-size: 12px; color: var(--ink-muted);
  margin-left: 12px;
}
.nav-progress {
  width: 120px; height: 3px; background: var(--rule); border-radius: 2px; overflow: hidden;
}
.nav-progress-fill {
  height: 100%; width: 0%; background: var(--accent); transition: width 0.1s;
}

/* ===== CHAPTER RAIL ===== */
.chapter-rail {
  position: fixed; left: 24px; top: 50%; transform: translateY(-50%);
  z-index: 90;
}
.chapter-rail ol { list-style: none; }
.chapter-rail li {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; cursor: pointer;
  transition: all 0.2s;
}
.chapter-rail .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rule); transition: all 0.2s;
  flex-shrink: 0;
}
.chapter-rail li.active .dot { background: var(--accent); transform: scale(1.4); }
.chapter-rail .label {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 500; color: var(--ink-muted);
  white-space: nowrap; opacity: 0; transform: translateX(-4px);
  transition: all 0.2s;
}
.chapter-rail li:hover .label,
.chapter-rail li.active .label { opacity: 1; transform: translateX(0); }

@media (max-width: 1100px) { .chapter-rail { display: none; } }

/* ===== CHAPTER ===== */
.chapter {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 7rem 24px 3rem;
}
.chapter + .chapter { border-top: 1px solid var(--rule); }

.eyebrow {
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 12px;
}
.chapter h2 {
  font-size: 2.2rem; font-weight: 700; line-height: 1.2;
  margin-bottom: 1rem;
}
.lede {
  font-size: 1.1rem; color: var(--ink-soft);
  margin-bottom: 1.5rem; max-width: 780px;
}

/* ===== PLAIN CARD ===== */
.plain-card {
  background: var(--bg);
  border-left: 4px solid #d4a853;
  padding: 1.5rem 1.8rem;
  margin: 2rem 0;
  border-radius: 0 8px 8px 0;
}
.plain-label {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #b8860b; margin-bottom: 10px;
}
.plain-card p { margin-bottom: 0.6rem; font-size: 0.97rem; line-height: 1.65; }
.plain-card p:last-child { margin-bottom: 0; }

/* ===== EQUATION BLOCK ===== */
.equation-block {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.2rem 1.8rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}
.equation-block .eq-label {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em;
}

/* ===== INTERACTIVE ===== */
.interactive-section {
  margin: 2rem 0;
}
.interactive-section .hint {
  font-family: var(--font-sans);
  font-size: 12px; color: var(--ink-muted);
  margin-bottom: 12px; font-style: italic;
}
.controls {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin-bottom: 16px;
}
.control-group {
  flex: 1; min-width: 200px;
}
.control-group label {
  display: block;
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 500; color: var(--ink-soft);
  margin-bottom: 4px;
}
.control-group input[type="range"] {
  width: 100%; accent-color: var(--accent);
}
.control-group .range-val {
  font-family: var(--font-mono);
  font-size: 13px; color: var(--accent); font-weight: 500;
}
.chart-grid {
  display: grid; gap: 16px;
}
.chart-grid.g2 { grid-template-columns: 1fr 1fr; }
.chart-grid.g1 { grid-template-columns: 1fr; }
.chart-box {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  min-height: 320px;
}
.readout-cards {
  display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px;
}
.readout-card {
  flex: 1; min-width: 140px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}
.readout-card .rc-label {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.readout-card .rc-value {
  font-family: var(--font-mono);
  font-size: 1.4rem; font-weight: 500; color: var(--accent);
  margin-top: 4px;
}

/* ===== CALLOUT ===== */
.callout {
  border-left: 4px solid var(--accent);
  padding: 1rem 1.4rem;
  margin: 2rem 0;
  background: rgba(200,57,44,0.04);
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: var(--ink-soft);
}

/* ===== CHAPTER FOOT LINK ===== */
.chapter-foot {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans);
  font-size: 14px; font-weight: 500; color: var(--ink-soft);
  text-decoration: none; margin-top: 1.5rem;
  transition: all 0.2s;
}
.chapter-foot:hover { color: var(--accent); }
.chapter-foot:hover .arrow { transform: translateX(4px); }
.arrow { transition: transform 0.2s; }

/* ===== COVER ===== */
.cover { padding-top: 10rem; }
.cover-inner { max-width: 760px; margin: 0 auto; }
.cover-eyebrow {
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 16px;
}
.cover-title {
  font-size: 2.8rem; font-weight: 700; line-height: 1.15;
  margin-bottom: 0.5rem;
}
.cover-title em { color: var(--accent); }
.cover-subtitle {
  font-size: 1.15rem; color: var(--ink-soft); margin-bottom: 1rem;
}
.cover-byline {
  font-family: var(--font-sans);
  font-size: 14px; color: var(--ink-soft); margin-bottom: 2.5rem; line-height: 1.6;
}
.cover-byline .muted { color: var(--ink-muted); }

.cover-abstract {
  background: var(--bg);
  border-left: 4px solid #d4a853;
  padding: 1.8rem 2rem;
  margin: 2rem 0;
  border-radius: 0 8px 8px 0;
}
.cover-abstract-label {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #b8860b; margin-bottom: 12px;
}
.cover-abstract p { margin-bottom: 0.8rem; font-size: 1.02rem; line-height: 1.7; }
.cover-abstract p:last-child { margin-bottom: 0; }

.cover-pillars {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  margin: 2.5rem 0 0;
}
.pillar {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.4rem;
}
.pillar-num {
  font-family: var(--font-serif);
  font-size: 1.6rem; font-weight: 700; color: var(--accent);
  margin-bottom: 6px;
}
.pillar-title {
  font-family: var(--font-sans);
  font-size: 14px; font-weight: 600; color: var(--ink);
  margin-bottom: 6px;
}
.pillar-text {
  font-size: 0.88rem; color: var(--ink-soft); line-height: 1.55;
}

@media (max-width: 700px) {
  .cover-pillars { grid-template-columns: 1fr; }
  .chart-grid.g2 { grid-template-columns: 1fr; }
  .cover-title { font-size: 2rem; }
}

/* ===== STRATEGY CARDS ===== */
.strategy-cards {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.strategy-card {
  flex: 1; min-width: 160px;
  background: var(--bg-elevated);
  border: 2px solid var(--rule);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.strategy-card:hover { border-color: var(--midmarket); }
.strategy-card.selected { border-color: var(--accent); background: rgba(200,57,44,0.04); }
.strategy-card .sc-title {
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.strategy-card .sc-desc {
  font-size: 11px; color: var(--ink-muted); margin-top: 4px;
}

/* ===== PROSE ELEMENTS ===== */
.prose { margin: 1rem 0; max-width: 780px; }
.prose p { margin-bottom: 0.8rem; }

/* ===== SVG DIAGRAM ===== */
.diagram-container {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}
.diagram-container svg text {
  font-family: var(--font-sans);
}
