/* WorldFork — design system: deep-ink + mint */
:root {
  --bg: oklch(0.985 0.003 240);
  --bg-2: oklch(0.965 0.005 240);
  --bg-3: oklch(0.93 0.008 240);
  --fg: oklch(0.22 0.03 250);
  --fg-2: oklch(0.45 0.025 250);
  --fg-3: oklch(0.62 0.018 245);
  --rule: oklch(0.88 0.01 240);
  --rule-2: oklch(0.93 0.008 240);
  --accent: oklch(0.72 0.16 175);
  --accent-soft: oklch(0.94 0.05 175);
  --accent-deep: oklch(0.48 0.13 180);
  --good: oklch(0.72 0.16 175);
  --warn: oklch(0.78 0.15 90);
  --bad: oklch(0.62 0.18 20);
  --grid: oklch(0.92 0.01 240);
  --inverse-fg: oklch(0.985 0.003 240);
  --inverse-bg: oklch(0.22 0.03 250);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --font-serif: "Newsreader", Georgia, serif;

  --radius: 4px;
  --radius-lg: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { min-height: 100vh; }

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---------- typography utilities ---------- */
.mono { font-family: var(--font-mono); font-feature-settings: "ss02"; }
.serif { font-family: var(--font-serif); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-3);
  font-weight: 500;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.brand-mark {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.brand-mark em { font-style: italic; color: var(--accent); font-weight: 400; }
.brand-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.topnav { display: flex; gap: 28px; }
.topnav a {
  font-size: 13px;
  color: var(--fg-2);
  text-decoration: none;
  letter-spacing: 0.01em;
  position: relative;
  padding-bottom: 2px;
}
.topnav a.active { color: var(--fg); }
.topnav a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -19px;
  height: 1px;
  background: var(--fg);
}
.topnav a:hover { color: var(--fg); }

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
}
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  display: inline-block;
}
.dot.idle { background: var(--fg-3); }
.dot.run { background: var(--accent); animation: blink 1.4s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: var(--radius);
  text-decoration: none;
  transition: transform 120ms ease, opacity 120ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--rule);
}
.btn.ghost:hover { border-color: var(--fg); }
.btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn.lg {
  padding: 14px 24px;
  font-size: 14px;
}

/* ---------- cards ---------- */
.card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--bg);
  padding: 24px;
}
.card.tight { padding: 16px; }

/* ---------- HOME ---------- */
.home {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 32px 96px;
}
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 64px;
  align-items: end;
  margin-bottom: 64px;
}
.hero h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(48px, 6vw, 84px);
  line-height: 0.98;
  letter-spacing: -0.025em;
  margin: 24px 0 28px;
  color: var(--fg);
}
.hero h1 em {
  font-style: italic;
  color: var(--accent);
}
.hero p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg-2);
  max-width: 52ch;
  margin: 0;
}

.hero-aside {
  border-left: 1px solid var(--rule);
  padding-left: 32px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--fg-2);
}
.hero-aside dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.hero-aside dt { color: var(--fg-3); font-family: var(--font-mono); font-size: 11px; padding-top: 3px; }
.hero-aside dd { margin: 0; color: var(--fg); }

.scenario-pane {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 64px;
  background: var(--bg);
}
.scenario-left {
  padding: 32px;
  border-right: 1px solid var(--rule);
}
.scenario-left h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 12px 0 16px;
}
.scenario-left p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg-2);
  margin: 0 0 24px;
}
.scenario-right {
  background: var(--bg-2);
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.config-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 20px;
  font-size: 13px;
}
.config-list dt {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.config-list dd {
  margin: 0;
  font-family: var(--font-mono);
  color: var(--fg);
}
.config-list dd .pill {
  display: inline-block;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  font-size: 11px;
  margin-right: 4px;
}

.start-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--rule);
}
.start-row .hint {
  font-size: 12px;
  color: var(--fg-3);
  font-family: var(--font-mono);
}

.lock-line {
  margin-top: 16px;
  font-size: 12px;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- runs list ---------- */
.runs-section h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  margin: 0 0 4px;
}
.runs-section .sub {
  color: var(--fg-3);
  font-size: 13px;
  margin-bottom: 20px;
}
.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.runs-table thead th {
  text-align: left;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--rule);
}
.runs-table tbody tr {
  border-bottom: 1px solid var(--rule-2);
  transition: background 100ms ease;
  cursor: pointer;
}
.runs-table tbody tr:hover {
  background: var(--bg-2);
}
.runs-table td {
  padding: 14px 16px;
  vertical-align: middle;
}
.runs-table .scenario { font-weight: 500; }
.runs-table .timestamp { font-family: var(--font-mono); color: var(--fg-3); font-size: 12px; }
.runs-table .ratio { font-family: var(--font-mono); }
.runs-table .arrow { color: var(--fg-3); text-align: right; }
.runs-table tbody tr:hover .arrow { color: var(--accent); }

.outcome-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.outcome-bar .track {
  width: 80px;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}
.outcome-bar .fill {
  height: 100%;
  background: var(--accent);
}
.outcome-bar .v {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
}

/* ---------- SIMULATION ---------- */
.sim-page {
  display: grid;
  grid-template-rows: auto 1fr;
  height: calc(100vh - 64px);
}
.sim-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.sim-meta-left { display: flex; align-items: center; gap: 24px; }
.phase-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  background: var(--bg-2);
  color: var(--fg-2);
}
.sim-stats {
  display: flex;
  gap: 32px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--fg-3);
}
.sim-stats strong {
  color: var(--fg);
  font-weight: 600;
  font-size: 14px;
  margin-right: 4px;
}

.sim-body {
  display: grid;
  grid-template-columns: 1fr 380px;
  overflow: hidden;
}
.tree-pane {
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, var(--grid) 1px, transparent 0) 0 0/24px 24px,
    var(--bg);
  overflow: hidden;
  border-right: 1px solid var(--rule);
}
.tree-pane svg { display: block; }
.tree-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.tree-toolbar .seg {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}
.tree-toolbar .seg button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tree-toolbar .seg button.on { background: var(--fg); color: var(--bg); }

.tree-legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
}
.tree-legend .ramp {
  width: 100px;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right,
    oklch(0.7 0.13 175),
    oklch(0.65 0.16 250),
    oklch(0.6 0.18 330));
}

/* tree elements */
.node-link {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1.2;
  transition: stroke 200ms ease, stroke-width 200ms ease;
}
.node-link.active { stroke: var(--accent); stroke-width: 1.6; }
.node-link.dim { stroke: var(--rule-2); }
.node-circle {
  fill: var(--bg);
  stroke: var(--fg-2);
  stroke-width: 1.2;
  transition: all 200ms ease;
}
.node-circle.root { fill: var(--fg); stroke: var(--fg); }
.node-circle.fork { fill: var(--bg); stroke: var(--fg); stroke-width: 1.5; }
.node-circle.running { stroke: var(--accent); stroke-dasharray: 2 2; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); transform-box: fill-box; transform-origin: center; } }
.node-leaf {
  stroke: var(--fg);
  stroke-width: 1;
  cursor: pointer;
  transition: transform 150ms ease;
  transform-origin: center;
  transform-box: fill-box;
}
.node-leaf:hover { transform: scale(1.2); }
.node-leaf.selected { stroke-width: 2; }
.node-label {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--fg-3);
  pointer-events: none;
}
.node-leaf-label {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: var(--fg);
  pointer-events: none;
}
.round-tick {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--fg-3);
}
.round-line {
  stroke: var(--rule-2);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}
.fork-marker-line {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.5;
}

.detail-pane {
  background: var(--bg);
  overflow-y: auto;
  padding: 28px;
}
.detail-pane h4 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  margin: 6px 0 4px;
  letter-spacing: -0.01em;
}
.detail-pane .sub-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  margin-bottom: 20px;
}
.detail-section { margin-bottom: 24px; }
.detail-section .label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-3);
  margin-bottom: 8px;
}
.detail-section .body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg-2);
}
.outcome-rows {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  font-size: 13px;
}
.outcome-rows .k { color: var(--fg-2); font-family: var(--font-mono); font-size: 12px; }
.outcome-rows .v { font-family: var(--font-mono); font-weight: 600; text-align: right; }
.outcome-rows .v.bool-yes { color: var(--accent-deep); }
.outcome-rows .v.bool-no { color: var(--fg-3); }

.quote {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg);
  font-family: var(--font-serif);
}

.empty-detail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  color: var(--fg-3);
  font-size: 13px;
  line-height: 1.6;
}
.empty-detail .ic {
  width: 28px; height: 28px;
  border: 1px dashed var(--rule);
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
}

.completion-banner {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--fg);
  color: var(--bg);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  z-index: 10;
  animation: rise 400ms ease both;
}
@keyframes rise { from { transform: translateY(20px); opacity: 0; } }
.completion-banner .text { font-size: 13px; }
.completion-banner .text strong { font-weight: 500; display: block; }
.completion-banner .text span { color: var(--fg-3); font-family: var(--font-mono); font-size: 11px; }
.completion-banner .btn {
  background: var(--bg);
  color: var(--fg);
  border-color: var(--bg);
}

/* ---------- ANALYSIS ---------- */
.analysis {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 32px 96px;
}
.analysis-head {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 48px;
  align-items: end;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 28px;
  margin-bottom: 40px;
}
.analysis-head h2 {
  font-family: var(--font-serif);
  font-size: clamp(36px, 4vw, 56px);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 14px 0 8px;
  line-height: 1.05;
}
.analysis-head h2 em { color: var(--accent); font-style: italic; }
.analysis-head p {
  color: var(--fg-2);
  font-size: 14px;
  line-height: 1.65;
  max-width: 56ch;
}
.analysis-head-meta {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.8;
}
.analysis-head-meta strong { color: var(--fg); font-weight: 500; }

.headline-prob {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 48px;
  margin-bottom: 56px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.prob-num {
  background: var(--fg);
  color: var(--bg);
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.prob-num .label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: oklch(0.7 0.02 240);
}
.prob-num .big {
  font-family: var(--font-serif);
  font-size: clamp(72px, 9vw, 132px);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin-top: 12px;
}
.prob-num .big em { color: var(--accent); font-style: italic; }
.prob-num .ci {
  font-family: var(--font-mono);
  font-size: 12px;
  color: oklch(0.75 0.02 240);
  margin-top: 8px;
}
.prob-num .meta {
  font-size: 12px;
  color: oklch(0.7 0.02 240);
  margin-top: auto;
  padding-top: 24px;
  line-height: 1.6;
}
.prob-num .meta strong { color: var(--bg); font-weight: 500; }

.dist-pane {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dist-pane .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.dist-pane .head h5 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  margin: 0;
}
.dist-pane .head .legend {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
}
.dist-svg {
  width: 100%;
  height: 200px;
  display: block;
}
.dist-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding-top: 16px;
  border-top: 1px solid var(--rule-2);
}
.dist-stats > div {
  font-size: 12px;
  color: var(--fg-3);
}
.dist-stats > div .v {
  display: block;
  font-family: var(--font-mono);
  color: var(--fg);
  font-size: 16px;
  font-weight: 500;
  margin-top: 4px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.section-sub {
  color: var(--fg-3);
  font-size: 13px;
  margin-bottom: 24px;
}

.outcome-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 56px;
}
.outcome-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--bg);
}
.outcome-card .label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
}
.outcome-card .name {
  font-family: var(--font-serif);
  font-size: 20px;
  margin: 4px 0 16px;
}
.outcome-card .desc {
  color: var(--fg-2);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.outcome-card .mini-svg {
  width: 100%;
  height: 100px;
  display: block;
}
.outcome-card .nums {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
}
.outcome-card .nums strong { color: var(--fg); font-weight: 600; font-size: 13px; display: block; margin-top: 2px; }

.bool-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 56px;
}
.bool-row {
  display: grid;
  grid-template-columns: 1fr 240px 80px;
  gap: 20px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-2);
}
.bool-row .info .name { font-family: var(--font-mono); font-size: 13px; }
.bool-row .info .desc { font-size: 12px; color: var(--fg-3); margin-top: 3px; }
.bool-row .bar { height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; position: relative; }
.bool-row .bar .fill { height: 100%; background: var(--accent); transition: width 600ms ease; }
.bool-row .pct { font-family: var(--font-mono); font-weight: 600; text-align: right; }

.branch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 40px;
}
.branch-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  user-select: none;
}
.branch-table thead th:hover { color: var(--fg); }
.branch-table tbody tr { border-bottom: 1px solid var(--rule-2); }
.branch-table tbody tr:hover { background: var(--bg-2); }
.branch-table td { padding: 14px 12px; vertical-align: middle; }
.branch-table .name { font-weight: 500; }
.branch-table .name .dim { color: var(--fg-3); font-family: var(--font-mono); font-size: 11px; display: block; margin-top: 2px; }
.branch-table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 6px;
}

.takeaways {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 56px;
}
.takeaway {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--bg);
}
.takeaway .num {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.takeaway h6 {
  font-family: var(--font-sans);
  font-size: 14px;
  margin: 0 0 8px;
  font-weight: 500;
}
.takeaway p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg-2);
  margin: 0;
}

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--rule);
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
}

/* ---------- subtle grain overlay ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
}

/* ---------- scenario picker (topbar dropdown) ---------- */
.topbar-sep {
  width: 1px;
  height: 18px;
  background: var(--rule);
  display: inline-block;
}
.scenario-picker {
  position: relative;
  font-family: var(--font-sans);
}
.scenario-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px 7px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.scenario-picker-btn:hover { border-color: var(--fg-3); }
.scenario-picker-btn.open { border-color: var(--fg); background: var(--bg-2); }
.scenario-picker-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.scenario-picker-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scenario-picker-caret {
  font-size: 9px;
  color: var(--fg-3);
  transition: transform 120ms ease;
}
.scenario-picker-btn.open .scenario-picker-caret { transform: rotate(180deg); }

.scenario-picker-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 380px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px -8px oklch(0.2 0.03 250 / 0.18), 0 4px 8px -4px oklch(0.2 0.03 250 / 0.12);
  padding: 6px;
  z-index: 200;
  animation: pickerDrop 160ms ease both;
}
@keyframes pickerDrop {
  from { opacity: 0; transform: translateY(-4px); }
}
.scenario-picker-head {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 10px 12px 6px;
}
.scenario-picker-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--fg);
  transition: background 120ms ease;
}
.scenario-picker-item:hover { background: var(--bg-2); }
.scenario-picker-item.current { background: var(--accent-soft); }
.scenario-picker-item.current:hover { background: var(--accent-soft); }
.scenario-picker-item-main { min-width: 0; }
.scenario-picker-item-title {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.snapshot-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-3);
  color: var(--fg-3);
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 400;
}
.scenario-picker-item-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  margin-top: 2px;
}
.scenario-picker-item-meta {
  text-align: right;
  flex-shrink: 0;
}
.scenario-picker-item-prob {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1;
  color: var(--accent-deep);
}
.scenario-picker-item.current .scenario-picker-item-prob { color: var(--accent-deep); }
.scenario-picker-item-ts {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  margin-top: 4px;
}
.scenario-picker-foot {
  border-top: 1px solid var(--rule-2);
  margin-top: 4px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  letter-spacing: 0.04em;
}

/* ---------- scenario chips (Home active row) ---------- */
.scenario-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.scenario-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.scenario-chip {
  font: inherit;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg-2);
  cursor: pointer;
  transition: all 120ms ease;
}
.scenario-chip:hover { color: var(--fg); border-color: var(--fg-3); }
.scenario-chip.on {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ---- Graph view (BranchDetail panel) ---- */
.graph-pane {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px;
}
.graph-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.graph-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
}
.graph-stats {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
}
.graph-svg {
  width: 100%;
  height: 320px;
  display: block;
}
.graph-empty {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  text-align: center;
  padding: 60px 20px;
}
.graph-tooltip {
  position: absolute;
  bottom: 56px;
  left: 12px;
  right: 12px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  box-shadow: 0 2px 8px oklch(0 0 0 / 0.06);
}
.graph-tooltip strong {
  font-size: 12px;
  color: var(--fg);
}
.graph-tooltip.edge .edge-type {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-deep);
}
.graph-tooltip.edge .edge-pair {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg);
}
.graph-type-badge {
  display: inline-block;
  font-size: 10px;
  font-family: var(--font-mono);
  color: white;
  padding: 1px 6px;
  border-radius: 3px;
  width: fit-content;
}
.graph-summary {
  font-size: 11px;
  color: var(--fg-2);
  line-height: 1.4;
}
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
}
.graph-legend-item { display: flex; align-items: center; gap: 4px; }
.graph-legend-item .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
