:root {
  --bg: #0d0f0e;
  --surface: #161a18;
  --surface-2: #1d2320;
  --border: #2a322e;
  --text: #e8ece9;
  --muted: #9aa49e;
  --green: #1db954;
  --green-soft: #6fdc97;
  --red: #e85d6a;
  --radius: 14px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.65;
  font-size: 16.5px;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* ---------- hero ---------- */
.hero {
  padding: 88px 0 64px;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(29, 185, 84, 0.16), transparent),
    var(--bg);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(34px, 5.6vw, 56px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 22px;
}

.accent { color: var(--green); }

.lede { max-width: 720px; color: var(--muted); font-size: 18.5px; margin-bottom: 38px; }
.lede em, .lede strong { color: var(--text); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 38px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px;
  font-weight: 600;
  color: var(--green-soft);
  display: block;
}

.stat .label { font-size: 13px; color: var(--muted); }

.hero-links { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-block;
  background: var(--green);
  color: #06210f;
  font-weight: 600;
  font-size: 15px;
  padding: 11px 22px;
  border-radius: 999px;
  text-decoration: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }

/* ---------- table of contents ---------- */
.toc {
  margin-top: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
}

.toc-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 14px;
}

.toc ol {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 32px;
}

.toc a {
  display: block;
  padding: 7px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.toc a:hover { background: var(--surface-2); color: var(--green-soft); }

.toc .num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--green);
  margin-right: 10px;
}

/* fixed scroll-spy rail, wide screens only (built by app.js) */
.toc-rail {
  position: fixed;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  gap: 4px;
  max-width: 150px;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 10;
}

.toc-rail.visible { opacity: 1; }

.toc-rail a {
  display: block;
  padding: 5px 10px;
  border-left: 2px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.toc-rail a:hover { color: var(--text); }

.toc-rail a.active {
  color: var(--green-soft);
  border-left-color: var(--green);
}

.toc-rail .num { display: none; }

@media (min-width: 1440px) {
  .toc-rail { display: flex; }
}

/* ---------- sections ---------- */
section { padding: 64px 0 8px; scroll-margin-top: 18px; }

h2 {
  font-size: clamp(24px, 3.4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

h2 .num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62em;
  font-weight: 400;
  color: var(--green);
  vertical-align: 0.18em;
  margin-right: 10px;
}

section > p { max-width: 780px; color: var(--muted); margin-bottom: 28px; }
section > p strong, section > p em { color: var(--text); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 22px;
}

.card h3 { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.card h3 .sub { font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 8px; }

.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.chart-row .card { margin-bottom: 22px; }

.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 380px; }
.chart-box.short { height: 200px; }

.caption { font-size: 13.5px; color: var(--muted); margin-top: 14px; }
.caption strong, .caption em { color: var(--text); }

/* ---------- glossary ---------- */
.glossary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 26px;
  margin-bottom: 12px;
}

.glossary .term {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
}

.glossary dt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--green-soft);
  display: inline;
  margin-right: 6px;
}

.glossary dt::after { content: ' — '; color: var(--muted); font-weight: 400; }
.glossary dd { display: inline; color: var(--muted); }

/* ---------- metric legend ---------- */
.metric-legend {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  font-size: 13px;
}

.metric-legend dt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--green-soft);
  display: inline;
  margin-right: 6px;
}

.metric-legend dt::after { content: ' — '; color: var(--muted); font-weight: 400; }
.metric-legend dd { display: inline; color: var(--muted); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }

th, td { padding: 10px 14px; text-align: center; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }

thead th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

tbody tr { border-bottom: 1px solid rgba(42, 50, 46, 0.5); }
tbody tr:last-child { border-bottom: none; }
tbody td { font-family: 'JetBrains Mono', monospace; font-size: 13.5px; }
tbody td:first-child { font-family: 'Inter', sans-serif; font-size: 14.5px; }

tr.winner { background: rgba(29, 185, 84, 0.08); }
tr.winner td:first-child { color: var(--green-soft); font-weight: 600; }
td.best { color: var(--green-soft); font-weight: 600; }

/* ---------- fixes grid ---------- */
.fix-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-bottom: 22px; }
.card.fix { margin-bottom: 0; border-top: 3px solid var(--green); }
.card.fix h4 { font-size: 15.5px; margin-bottom: 8px; }
.card.fix p { font-size: 14px; color: var(--muted); }
.card.fix p em { color: var(--text); }

/* ---------- recipe ---------- */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 8px;
}

.recipe-grid div {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 16px;
  font-size: 14px;
  color: var(--muted);
}

.recipe-grid strong { color: var(--text); }
.recipe-grid .emoji { display: block; font-size: 22px; margin-bottom: 8px; }

/* ---------- decision tree ---------- */
.tree-scroll { overflow-x: auto; padding: 8px 0 4px; }

ul.tree, .tree ul {
  display: flex;
  justify-content: center;
  list-style: none;
  margin: 0;
  padding: 18px 0 0;
  position: relative;
}

ul.tree { padding-top: 0; min-width: 880px; }

.tree li {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 18px 5px 0;
  flex: 1;
}

ul.tree > li { padding-top: 0; }

/* connectors */
.tree li::before, .tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  width: 50%;
  height: 18px;
  border-top: 1px solid var(--border);
}
.tree li::after {
  right: auto;
  left: 50%;
  border-left: 1px solid var(--border);
  border-radius: 8px 0 0 0;
}
.tree li::before { border-right: 1px solid var(--border); border-radius: 0 8px 0 0; }
.tree li:first-child::before, .tree li:last-child::after { border-top: none; border-radius: 0; }
ul.tree > li::before, ul.tree > li::after { display: none; }
.tree li > ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 18px;
  border-left: 1px solid var(--border);
}

.t-edge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  white-space: nowrap;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  margin-bottom: 8px;
}

.t-node {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  white-space: nowrap;
}

.t-leaf {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px 9px;
  min-width: 92px;
}

.t-val { font-family: 'JetBrains Mono', monospace; font-size: 21px; font-weight: 600; color: var(--text); }
.t-leaf.up .t-val { color: var(--green-soft); }
.t-leaf.down .t-val { color: var(--red); }
.t-delta, .t-share { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

.on-best > .t-node, .on-best > .t-leaf {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(29, 185, 84, 0.35), 0 0 18px rgba(29, 185, 84, 0.12);
}
.on-best > .t-edge { color: var(--green-soft); border-color: var(--green); }

/* plain-words explainer */
.plain-intro { font-size: 14.5px; color: var(--muted); margin-bottom: 16px; max-width: 720px; }
.plain-intro strong, .plain-steps strong { color: var(--text); }

.plain-steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 10px;
  margin-bottom: 6px;
}

.plain-steps li {
  counter-increment: step;
  position: relative;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 16px 12px 48px;
  font-size: 14px;
  color: var(--muted);
}

.plain-steps li::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(29, 185, 84, 0.15);
  color: var(--green-soft);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- trends ---------- */
.trend-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-bottom: 22px; }
.trend-grid .card { margin-bottom: 0; padding: 18px 20px; }
.trend-grid h3 { font-size: 14.5px; margin-bottom: 4px; }
.trend-grid .trend-def { font-size: 12px; color: var(--muted); line-height: 1.45; margin-bottom: 10px; min-height: 52px; }
.trend-grid .chart-box { height: 170px; }

/* ---------- conclusions ---------- */
.conclusion { border-left: 3px solid var(--green); }
.conclusion h3 { color: var(--green-soft); }
.conclusion p { color: var(--muted); font-size: 15.5px; }

/* ---------- footer ---------- */
footer {
  margin-top: 72px;
  padding: 36px 0 48px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--muted);
}

footer a { color: var(--green-soft); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .chart-row, .fix-grid, .recipe-grid { grid-template-columns: 1fr; }
  .trend-grid { grid-template-columns: 1fr 1fr; }
  .chart-box.tall { height: 420px; }
}

@media (max-width: 540px) {
  .trend-grid { grid-template-columns: 1fr; }
  .glossary { grid-template-columns: 1fr; }
  .toc ol { grid-template-columns: 1fr; }
  .trend-grid .trend-def { min-height: 0; }
  .hero { padding: 56px 0 44px; }
  section { padding: 48px 0 8px; }
}
