:root {
  --bg: #0b0d10;
  --card: #141820;
  --border: #2a3140;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #7baaf7;
  --doom: #f28b82;
  --utopia: #81c995;
  --friction: #fdd663;
  --severe: #c58af9;
  --spine: #7baaf7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
h1 { margin: 0; font-size: 1.5rem; }
.subtitle { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.95rem; }
.header-actions { display: flex; gap: 0.75rem; }
.header-actions a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.load-row { margin-top: 1rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 0.85rem; }
code { color: var(--accent); font-size: 0.85em; }

main { padding: 1.25rem 1.5rem 2rem; max-width: 1200px; margin: 0 auto; }
footer {
  padding: 1rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.hero-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) {
  .hero-grid, .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.15rem;
}
.card-wide { margin-bottom: 1rem; }
.card h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.section-hint { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.85rem; }

.outcome-layout {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.region-bars { flex: 1; min-width: 200px; }

.bar-row { margin: 0.4rem 0; }
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}
.bar-track {
  height: 10px;
  background: #1e2430;
  border-radius: 5px;
  overflow: hidden;
  margin-top: 5px;
}
.bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease;
}
.bar-fill.doom { background: var(--doom); }
.bar-fill.utopia { background: var(--utopia); }
.bar-fill.friction { background: var(--friction); }
.bar-fill.severe { background: var(--severe); }
.bar-fill.spine { background: var(--spine); }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
td, th { text-align: left; padding: 0.3rem 0; vertical-align: top; }
th { color: var(--muted); font-weight: 500; width: 42%; }

/* Spine course timeline */
.spine-timeline {
  position: relative;
  padding: 2rem 0 0.5rem;
  min-height: 120px;
}
.spine-axis {
  position: absolute;
  left: 0; right: 0;
  top: 3.2rem;
  height: 4px;
  background: #1e2430;
  border-radius: 2px;
}
.spine-node {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  text-align: center;
  min-width: 72px;
}
.spine-dot {
  width: 14px; height: 14px;
  background: var(--spine);
  border-radius: 50%;
  margin: 2.35rem auto 0.35rem;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 2px var(--spine);
}
.spine-label { font-size: 0.75rem; font-weight: 600; color: var(--text); }
.spine-date { font-size: 0.7rem; color: var(--muted); }
.spine-pct { font-size: 0.68rem; color: var(--accent); }

/* Terminal flow */
.flow-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0;
  font-size: 0.8rem;
}
.flow-spine { color: var(--muted); min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-arrow { color: var(--muted); }
.flow-term { color: var(--text); max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-pct { min-width: 3rem; text-align: right; color: var(--accent); }

/* Sample runs */
.sample-runs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}
.run-card {
  background: #0f1218;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}
.run-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.run-region {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
}
.run-region.doom { background: rgba(242,139,130,0.15); color: var(--doom); }
.run-region.utopia { background: rgba(129,201,149,0.15); color: var(--utopia); }
.run-region.friction { background: rgba(253,214,99,0.12); color: var(--friction); }
.run-region.severe { background: rgba(197,138,249,0.15); color: var(--severe); }
.run-terminal { font-size: 0.78rem; color: var(--muted); }
.run-course {
  list-style: none;
  margin: 0; padding: 0;
  font-size: 0.78rem;
}
.run-course li {
  padding: 0.2rem 0;
  border-left: 2px solid var(--border);
  padding-left: 0.5rem;
  margin-left: 0.25rem;
}
.run-course li.spine { border-color: var(--spine); }
.run-course li.event { border-color: #5c8df6; }
.run-course .when { color: var(--muted); margin-right: 0.35rem; }

/* Branching timeline */
.bt-svg { display: block; margin: 0.5rem 0 1rem; }
.bt-col-year { fill: var(--text); font-size: 13px; font-weight: 600; }
.bt-col-label { fill: var(--muted); font-size: 11px; }
.bt-node-label { fill: var(--text); font-size: 11px; font-weight: 500; }
.bt-node-pct { fill: var(--accent); font-size: 10px; }
.bt-footer {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  margin-top: 0.5rem;
}
@media (max-width: 700px) {
  .bt-footer { grid-template-columns: 1fr; }
}
.bt-footer h3 {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.bt-top-paths ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}
.bt-top-paths li { margin: 0.35rem 0; }
.bt-path-region {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-right: 0.35rem;
}
.bt-path-region.doom { background: rgba(242,139,130,0.15); color: var(--doom); }
.bt-path-region.utopia { background: rgba(129,201,149,0.15); color: var(--utopia); }
.bt-path-region.friction { background: rgba(253,214,99,0.12); color: var(--friction); }
.bt-path-region.severe { background: rgba(197,138,249,0.15); color: var(--severe); }
.bt-bucket {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin: 0.3rem 0;
  color: var(--muted);
}
.bt-bucket span:last-child { color: var(--accent); }

.bt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.bt-legend-title {
  font-weight: 600;
  color: var(--text);
  margin-right: 0.25rem;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}
.swatch-spine { background: #7baaf7; }
.swatch-gov { background: #e76f51; }
.swatch-c10 { background: #c58af9; }
.swatch-friction { background: var(--friction); }
.swatch-doom { background: var(--doom); }
.swatch-utopia { background: var(--utopia); }
.swatch-severe { background: var(--severe); }

/* Event impact table */
.impact-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.impact-table th, .impact-table td { padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
.impact-table th { color: var(--muted); font-weight: 500; }
.impact-table .pos { color: var(--doom); }
.impact-table .neg { color: var(--utopia); }
.impact-table .muted-cell { color: var(--muted); }
