:root {
  --paper: #f7f4ec;
  --panel: #fffdf8;
  --ink: #211d16;
  --muted: #6d675b;
  --faint: #8a8378;
  --rule: #e4dfd2;
  --accent: #0f766e;
  --accent-warm: #b45309;
  --win: #147a3d;
  --lose: #a83232;
  --max-width: 960px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1, h2, h3, h4 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 .5rem;
}

a { color: var(--accent); }

button, input { font: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.1rem 1.25rem .4rem;
}

.brand-mark {
  font-family: Georgia, serif;
  font-size: 1.05rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.status { display: flex; gap: .4rem; flex-wrap: wrap; }

.chip {
  font-size: .72rem;
  border: 1px solid var(--rule);
  background: var(--panel);
  border-radius: 999px;
  padding: .18rem .6rem;
  color: var(--muted);
  white-space: nowrap;
}

.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem .9rem;
}

.hero h1 {
  font-size: clamp(1.95rem, 5vw, 3.5rem);
  max-width: 42rem;
  margin-bottom: .85rem;
}

.kicker {
  font-size: .74rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent-warm);
  margin: 0 0 .6rem;
}

.sub, .section-intro { color: var(--muted); max-width: 47rem; }
.sub { margin: 0 0 .7rem; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: 1.1rem;
}

.hero-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: .38rem .95rem;
  color: var(--ink);
  text-decoration: none;
  font-size: .88rem;
  background: rgba(255, 253, 248, .55);
}

.hero-actions a:first-child { background: var(--ink); color: var(--paper); }
.hero-actions a:hover { border-color: var(--accent); color: var(--accent); }
.hero-actions a:first-child:hover { background: var(--accent); color: #fff; }

.honest-line { font-size: .86rem; color: var(--faint); font-style: italic; }

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  display: grid;
  gap: 1.4rem;
}

.audit-summary {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0 1.15rem;
}

.audit-summary h2 { font-size: 1.35rem; margin-bottom: .7rem; }
.audit-metrics { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; margin: .75rem 0 .8rem; }
.audit-metrics div { display: grid; gap: .05rem; }
.audit-metrics strong { font: 600 1.7rem/1 Georgia, serif; }
.audit-metrics span { color: var(--faint); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.audit-verdict { max-width: 48rem; margin: 0; color: var(--muted); }
.audit-verdict strong { color: var(--ink); }

.panel { border-top: 1px solid var(--ink); padding: 1.5rem 0 1.3rem; min-width: 0; }
.panel h2 { font-size: 1.45rem; }
.panel h3 { font-size: 1.1rem; margin-top: 1.6rem; }
.panel h3:first-of-type { margin-top: 1rem; }
.panel h4 { font-size: 1rem; margin-top: 1.2rem; }
.tiny { font-size: .78rem; color: var(--faint); }
.fine-print { font-size: .78rem; color: var(--faint); border-top: 1px dashed var(--rule); padding-top: .7rem; margin-top: 1rem; }

#proofChart, #atlasChart { overflow-x: auto; padding-bottom: .2rem; }

.stacked-area {
  display: block;
  width: 100%;
  min-width: 720px;
  max-width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  margin: .8rem 0 .4rem;
}

.stacked-area [data-era]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -4px;
}

.era-tick { font: 11px system-ui; fill: var(--faint); }
.chart-legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .76rem; color: var(--muted); margin: .4rem 0 .6rem; }
.legend-item i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: baseline; }

.axis-tabs, .horizon-tabs { display: flex; flex-wrap: wrap; gap: .45rem; margin: .9rem 0 .5rem; }
.axis-tab {
  font-size: .85rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 999px;
  padding: .32rem .9rem;
  cursor: pointer;
  color: var(--muted);
}
.axis-tab:hover { border-color: var(--muted); }
.axis-tab.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.axis-blurb { color: var(--muted); font-size: .88rem; max-width: 46rem; margin: .2rem 0 .4rem; }
.era-controls { margin: .6rem 0 1rem; }
.control-label { display: block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: .3rem; }
#eraRange { width: 100%; accent-color: var(--accent); }
.era-scale { display: flex; justify-content: space-between; gap: 1rem; font-size: .76rem; color: var(--faint); margin-top: .25rem; }
.era-scale strong { color: var(--ink); font-size: .86rem; }

.era-panel { border: 1px solid var(--rule); border-radius: 8px; background: #fff; padding: 1.1rem 1.2rem 1rem; }
.era-head { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.era-head h3 { margin: 0; }
.share-list { display: grid; gap: .32rem; margin: .8rem 0 .4rem; max-width: 38rem; }
.share-row { display: grid; grid-template-columns: minmax(140px, 240px) 1fr 56px; gap: .7rem; align-items: center; font-size: .86rem; }
.share-label { color: var(--muted); text-align: right; line-height: 1.2; }
.share-track { height: 9px; background: var(--paper); border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.share-track i { display: block; height: 100%; opacity: .65; }
.share-value { font-size: .78rem; color: var(--faint); }

.receipt-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .7rem; margin-top: .5rem; }
.receipt-card { border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); padding: .8rem .9rem; }
.receipt-card p { margin: .35rem 0 .55rem; font-size: .88rem; }
.receipt-meta { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.chip-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.label-chip { font-size: .7rem; border: 1px solid var(--rule); border-radius: 999px; padding: .12rem .55rem; color: var(--muted); background: #fff; }
.label-chip.split { border-color: var(--accent-warm); color: var(--accent-warm); background: #fdf6ee; }

.table-scroll { overflow-x: auto; }
.receipt-table, .eval-table { width: 100%; border-collapse: collapse; font-size: .87rem; margin: .5rem 0 1rem; }
.receipt-table th, .eval-table th { text-align: left; font-family: Georgia, serif; font-weight: 600; font-size: .82rem; color: var(--muted); border-bottom: 1px solid var(--rule); padding: .35rem .8rem .35rem 0; white-space: nowrap; }
.receipt-table td, .eval-table td { border-bottom: 1px dashed var(--rule); padding: .42rem .8rem .42rem 0; vertical-align: top; }
.eval-table td .tiny { margin-top: .1rem; }
td.good, .tiny.good { color: var(--win); }
td.bad, .tiny.bad { color: var(--lose); }
.caveats { margin: .4rem 0 0; padding-left: 1.2rem; color: var(--muted); font-size: .92rem; max-width: 47rem; }
.caveats li { margin: .45rem 0; }

.read-note { margin: .65rem 0 .7rem; max-width: 47rem; }
.read-note summary, .context-details summary { cursor: pointer; color: var(--accent); font-size: .84rem; }
.read-note[open] summary { margin-bottom: .3rem; }
.section-note { border-left: 2px solid var(--rule); color: var(--muted); font-size: .84rem; padding: .25rem 0 .25rem .75rem; max-width: 47rem; margin: 0; }

.forecast-strip { display: flex; gap: .8rem; overflow-x: auto; scroll-snap-type: x proximity; padding: .65rem .2rem 1rem; margin: .4rem 0 1rem; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.forecast-card { flex: 0 0 340px; max-width: 340px; scroll-snap-align: start; border: 1px solid var(--rule); border-radius: 8px; background: #fff; padding: .9rem 1rem; display: flex; flex-direction: column; }
.forecast-card h4 { margin: .4rem 0 .1rem; font-size: 1.05rem; }
.anchor-title { font-size: .82rem; color: var(--muted); margin: .1rem 0 .5rem; }
.card-flags { display: flex; flex-wrap: wrap; gap: .3rem; }
.card-flag { font-size: .64rem; letter-spacing: .07em; text-transform: uppercase; border-radius: 999px; padding: .16rem .55rem; white-space: nowrap; }
.card-flag.typical { background: var(--paper); color: var(--muted); border: 1px solid var(--rule); }
.card-flag.stress { background: #fdf6ee; color: var(--accent-warm); border: 1px solid var(--accent-warm); }
.card-flag.win { background: #e5f3ea; color: var(--win); }
.card-flag.lose { background: #f8e8e8; color: var(--lose); }
.context-list { margin: .3rem 0; padding-left: 1.1rem; font-size: .76rem; color: var(--muted); max-height: 180px; overflow-y: auto; }
.context-list li { margin: .18rem 0; }
.pair-legend { display: flex; gap: .8rem; font-size: .68rem; color: var(--faint); margin: .2rem 0 .35rem; align-items: center; }
.pair-legend i, .pair-legend b { display: inline-block; vertical-align: baseline; margin-right: .25rem; }
.pair-legend i { width: 10px; height: 7px; border-radius: 2px; }
.pair-legend i.predicted { background: var(--accent); }
.pair-legend i.realized { background: var(--accent-warm); }
.pair-legend b.ghost-key { width: 2px; height: 10px; background: var(--faint); }
.pair-row { display: grid; grid-template-columns: minmax(96px, 118px) 1fr 64px; gap: .5rem; align-items: center; margin: .22rem 0; }
.pair-label { font-size: .72rem; color: var(--muted); text-align: right; line-height: 1.15; }
.pair-tracks { display: grid; gap: 2px; }
.pair-track { position: relative; height: 7px; background: var(--paper); border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.pair-track i { display: block; height: 100%; }
.pair-track i.predicted { background: var(--accent); opacity: .75; }
.pair-track i.realized { background: var(--accent-warm); opacity: .75; }
.pair-track b.ghost { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--faint); }
.pair-vals { font-size: .68rem; color: var(--faint); white-space: nowrap; }
.mse-line { margin-top: .5rem; border-top: 1px dashed var(--rule); padding-top: .4rem; }

.scenario-controls { margin: 1rem 0 .3rem; }
#anchorRange { width: 100%; accent-color: var(--accent); }
.anchor-readout { font-size: .88rem; color: var(--muted); margin: .35rem 0 .1rem; }
.anchor-readout strong { color: var(--ink); font-family: Georgia, serif; font-size: 1.08rem; margin-right: .1rem; }
.question-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .7rem 0 .6rem; }
.question-chip {
  font-size: .82rem;
  border: 1px solid var(--rule);
  background: var(--panel);
  border-radius: 999px;
  padding: .32rem .8rem;
  cursor: pointer;
  color: var(--muted);
  text-align: left;
}
.question-chip:hover { border-color: var(--accent); color: var(--accent); }
#scenarioQuestion {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  padding: .6rem .75rem;
  resize: vertical;
  min-height: 58px;
  color: var(--ink);
}
.scenario-run-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .6rem 0 .9rem; }
.scenario-status { font-size: .82rem; color: var(--accent-warm); max-width: 34rem; }
.scenario-card {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  padding: .95rem 1.1rem;
  margin: .4rem 0 .9rem;
}
.scenario-card h3 { margin-top: 0; font-size: 1.12rem; }
.scenario-card p { margin: .4rem 0; color: var(--muted); font-size: .92rem; }
.scenario-receipt { border-left: 2px solid var(--accent-warm); padding: .2rem 0 .2rem .7rem; margin: .6rem 0 .2rem; max-width: 47rem; }

.workbench-start-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .8rem 0 .4rem; }
.workbench-start-row[hidden] { display: none; }
#workbenchRange { width: 100%; accent-color: var(--accent); }
.workbench-window-head { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.workbench-window-head h3 { margin-bottom: .1rem; }
.link-action { border: none; background: none; color: var(--accent); font-size: .84rem; cursor: pointer; padding: 0; text-decoration: underline; }
.link-action:hover { color: var(--accent-warm); }
.workbench-window { border: 1px solid var(--rule); border-radius: 8px; background: #fff; padding: .35rem .7rem; margin: .5rem 0 .3rem; }
.window-row { display: grid; grid-template-columns: 82px 1fr auto; gap: .6rem; align-items: baseline; padding: .28rem 0; border-bottom: 1px dashed var(--rule); font-size: .84rem; }
.window-row:last-child { border-bottom: none; }
.window-year { color: var(--faint); font-size: .76rem; white-space: nowrap; }
.window-title { color: var(--muted); line-height: 1.3; min-width: 0; }
.window-row.is-removed .window-title, .window-row.is-removed .window-year { text-decoration: line-through; opacity: .55; }
.window-row.is-invented { background: #f2faf8; border-radius: 6px; padding-left: .4rem; padding-right: .4rem; }
.window-badge { font-size: .64rem; letter-spacing: .06em; text-transform: uppercase; border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: .05rem .4rem; margin-left: .4rem; white-space: nowrap; }
.window-badge.invented { border-color: var(--accent-warm); color: var(--accent-warm); }
.window-actions { display: flex; gap: .3rem; }
.row-action { font-size: .7rem; border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: .1rem .5rem; cursor: pointer; color: var(--muted); white-space: nowrap; }
.row-action:hover { border-color: var(--accent); color: var(--accent); }
.row-action[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.invent-form { border: 1px dashed var(--rule); border-radius: 8px; background: var(--panel); padding: .8rem .9rem; display: flex; flex-wrap: wrap; gap: .7rem; align-items: end; margin: .5rem 0 .8rem; }
.invent-field { display: grid; gap: .2rem; flex: 1 1 180px; min-width: 0; }
.invent-field-year { flex: 0 1 110px; }
.invent-field input, .invent-field select { border: 1px solid var(--rule); border-radius: 6px; background: #fff; padding: .35rem .55rem; font-size: .86rem; color: var(--ink); width: 100%; }
.invent-axes { display: contents; }
.divergence-strip { display: flex; align-items: flex-end; gap: 1.1rem; border: 1px solid var(--rule); border-radius: 8px; background: #fff; padding: .8rem 1rem .6rem; margin: .4rem 0 .8rem; width: fit-content; max-width: 100%; overflow-x: auto; }
.divergence-bar { display: grid; justify-items: center; gap: .2rem; }
.divergence-track { display: flex; align-items: flex-end; height: 72px; width: 22px; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.divergence-track i { display: block; width: 100%; background: var(--accent); opacity: .75; }
.divergence-h { font-size: .74rem; color: var(--ink); font-family: Georgia, serif; }
.divergence-v { font-size: .68rem; color: var(--faint); }

.frontier-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: .8rem; margin: 1rem 0 .6rem; }
.frontier-card { border: 1px solid var(--rule); border-radius: 8px; background: #fff; padding: .9rem 1rem; }
.frontier-card h4 { margin: .4rem 0 .3rem; font-size: 1rem; }

.surprise-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .7rem; margin: .8rem 0 1.2rem; }
.surprise-card { border: 1px solid var(--rule); border-radius: 8px; background: #fff; padding: .8rem .95rem; }
.surprise-card h4 { margin: 0 0 .5rem; font-size: .98rem; }
.surprise-row { display: grid; grid-template-columns: 64px 1fr; gap: .55rem; align-items: start; margin: .42rem 0; }
.surprise-bar { height: 8px; margin-top: .32rem; background: var(--paper); border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.surprise-bar i { display: block; height: 100%; background: var(--accent); opacity: .7; }
.surprise-row.far .surprise-bar i { background: var(--accent-warm); }
.surprise-text { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.surprise-text strong { color: var(--ink); margin-right: .25rem; }
.surprise-text .tiny { display: block; }
.audit-badge { display: inline-block; font-size: .64rem; color: var(--accent-warm); border: 1px solid var(--accent-warm); border-radius: 999px; padding: .05rem .35rem; margin-left: .2rem; }
.secondary-action { font-size: .88rem; border: 1px solid var(--ink); border-radius: 999px; background: var(--panel); color: var(--ink); padding: .38rem .9rem; cursor: pointer; width: fit-content; }
.secondary-action:hover { border-color: var(--accent); color: var(--accent); }

.run-receipt { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 1rem 0 2rem; padding: .7rem 0; }
.run-receipt summary { cursor: pointer; font-weight: 700; }
.receipt-facts { display: grid; gap: .3rem; margin: .8rem 0; }
.receipt-facts p { display: grid; grid-template-columns: minmax(145px, 220px) 1fr; gap: .7rem; margin: 0; font-size: .8rem; color: var(--muted); }
.receipt-facts strong { color: var(--ink); }
.receipt-hash { overflow-wrap: anywhere; font-size: .72rem; }
.receipt-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.receipt-download { display: inline-flex; text-decoration: none; }
.method-notes { margin-top: 1rem; }

.site-footer { max-width: var(--max-width); margin: 0 auto; padding: 0 1.25rem 2.5rem; font-size: .78rem; color: var(--faint); }

@media (max-width: 640px) {
  .stacked-area { min-width: 100%; }
  .hero { padding-top: 1.35rem; }
  .hero h1 { font-size: 2rem; }
  .hero-actions a { flex: 1 1 100%; justify-content: center; }
  .panel { padding: 1.1rem 0 1rem; }
  .audit-metrics { gap: 1rem 1.5rem; }
  .share-row { grid-template-columns: minmax(110px, 150px) 1fr 48px; }
  .share-label { font-size: .78rem; }
  .era-tick { font-size: 14px; }
  .forecast-card { flex-basis: min(300px, calc(100vw - 3rem)); max-width: min(300px, calc(100vw - 3rem)); }
  .receipt-facts p { grid-template-columns: 1fr; gap: .05rem; }
  .question-chip { flex: 1 1 100%; }
  .scenario-run-row .secondary-action { width: 100%; text-align: center; }
  .window-row { grid-template-columns: 1fr; gap: .15rem; }
  .window-actions { justify-content: flex-start; }
  .invent-field, .invent-field-year { flex: 1 1 100%; }
  .invent-form .secondary-action { width: 100%; text-align: center; }
  .workbench-start-row .secondary-action { width: 100%; text-align: center; }
}
