/* economy-sim viewer — design language from Del's claude-design comp:
   warm off-white, warm-black ink, hairline rules, Space Grotesk display,
   IBM Plex Mono labels, blue #2745d4 + red #d43d2a accents.
   Entity colors (validated): commodity=blue, credit=red, fiat=aqua. */

@font-face {
  font-family: 'Space Grotesk';
  src: url('fonts/space-grotesk-latin-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('fonts/space-grotesk-latin-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/ibm-plex-mono-latin-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/ibm-plex-mono-latin-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f2f2ee;
  --surface-1: #f6f6f1;
  --ink: #16160f;
  --ink-2: #55554a;
  --muted: #6b6b60;
  --grid: #dcdcd2;
  --baseline: #c9c9bd;
  --border: #c9c9bd;
  --rule: #16160f;
  --accent: #2745d4;
  --accent-2: #d43d2a;
  --era-barter: #dcdcd2;
  --era-commodity: #2745d4;
  --era-credit: #d43d2a;
  --era-fiat: #1baf7a;
  --seq-lo: #cdd7f6;
  --seq-hi: #16296b;
  --alarm-lo: #f6ddd6;
  --alarm-hi: #8c2416;
  --good: #0a7d3c;
  --warning: #b57e12;
  --critical: #d43d2a;
  --delta-good: #0a7d3c;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #141410;
    --surface-1: #1b1b16;
    --ink: #f2f2ee;
    --ink-2: #b3b3a4;
    --muted: #85857a;
    --grid: #2c2c24;
    --baseline: #3a3a30;
    --border: #3a3a30;
    --rule: #f2f2ee;
    --accent: #5f7df2;
    --accent-2: #e0644f;
    --era-barter: #33332a;
    --era-commodity: #5f7df2;
    --era-credit: #e0644f;
    --era-fiat: #199e70;
    --seq-lo: #22304f;
    --seq-hi: #9db4f5;
    --alarm-lo: #3d1d15;
    --alarm-hi: #f09066;
    --good: #2eb46a;
    --warning: #d7a129;
    --critical: #e0644f;
    --delta-good: #2eb46a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #141410;
  --surface-1: #1b1b16;
  --ink: #f2f2ee;
  --ink-2: #b3b3a4;
  --muted: #85857a;
  --grid: #2c2c24;
  --baseline: #3a3a30;
  --border: #3a3a30;
  --rule: #f2f2ee;
  --accent: #5f7df2;
  --accent-2: #e0644f;
  --era-barter: #33332a;
  --era-commodity: #5f7df2;
  --era-credit: #e0644f;
  --era-fiat: #199e70;
  --seq-lo: #22304f;
  --seq-hi: #9db4f5;
  --alarm-lo: #3d1d15;
  --alarm-hi: #f09066;
  --good: #2eb46a;
  --warning: #d7a129;
  --critical: #e0644f;
  --delta-good: #2eb46a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

.mono, .run-label, .chip, .btn, .event-year, .g-seed, .s-label,
.era-legend, .chart-legend, .map-caption, .card-sub, .event-count {
  font-family: var(--font-mono);
}

/* ---------- header ---------- */
.site-header { background: var(--page); position: sticky; top: 0; z-index: 20; }
.header-row {
  display: flex; align-items: center; gap: 22px; height: 64px; flex-wrap: wrap;
  border-bottom: 2px solid var(--rule);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark { display: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand-tag { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
@media (max-width: 900px) { .brand-tag { display: none; } }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  appearance: none; background: none; border: 0; color: var(--ink-2);
  font: inherit; font-size: 14.5px; padding: 7px 11px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.header-controls { display: flex; align-items: center; gap: 8px; }
.run-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.run-select {
  font-family: var(--font-mono); font-size: 12.5px; color: #fff;
  background: var(--accent); border: 0; border-radius: 6px; padding: 7px 10px;
  max-width: 240px; cursor: pointer;
}
.theme-select {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink);
  background: none; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px;
}

/* ---------- cards & layout ---------- */
.view { padding: 26px 0 48px; }
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 18px 20px;
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.card-sub { color: var(--muted); font-size: 11.5px; margin: 3px 0 0; }

.explore-grid { display: grid; grid-template-columns: minmax(360px, 500px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 980px) { .explore-grid { grid-template-columns: 1fr; } }
.explore-right { min-width: 0; }

/* ---------- map ---------- */
.map-holder { position: relative; }
#mapCanvas { width: 100%; height: auto; border-radius: 2px; display: block; border: 1px solid var(--border); }
.map-tooltip, .chart-tooltip {
  position: absolute; z-index: 30; pointer-events: none;
  background: var(--ink); color: var(--page);
  border-radius: 4px; padding: 8px 11px; font-size: 12px; line-height: 1.5;
  max-width: 250px; font-family: var(--font-mono);
}
.chart-tooltip { position: fixed; }
.tt-value { font-weight: 600; }
.tt-label { opacity: 0.75; }
.tt-row { display: flex; align-items: center; gap: 7px; }
.tt-key { width: 12px; height: 0; border-top: 3px solid; border-radius: 2px; flex: none; }
.map-caption { color: var(--muted); font-size: 11.5px; margin: 9px 0 0; }

.chips { display: flex; gap: 6px; }
.chip {
  appearance: none; font-size: 11px; cursor: pointer; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-2); background: none;
  border: 1px solid var(--border); border-radius: 3px; padding: 5px 10px;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--page); font-weight: 500; }

/* ---------- timeline ---------- */
.timeline-actions { display: flex; gap: 8px; }
.btn {
  appearance: none; font-size: 11.5px; cursor: pointer; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink); background: none;
  border: 1px solid var(--ink); border-radius: 3px; padding: 6px 12px;
}
.btn:hover { background: var(--ink); color: var(--page); }
.year-readout { color: var(--ink-2); font-weight: 400; margin-left: 10px; font-family: var(--font-mono); font-size: 13px; }
.era-band { display: flex; height: 22px; border-radius: 2px; overflow: hidden; margin: 6px 0 0; border: 1px solid var(--border); }
.era-seg { position: relative; height: 100%; }
.era-seg span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.07em;
  text-transform: uppercase; color: #fff; white-space: nowrap; overflow: hidden;
}
.era-seg.barter span { color: var(--ink-2); }
.scrubber { width: 100%; margin: 10px 0 2px; accent-color: var(--accent); }
.marker-row { position: relative; height: 10px; }
.marker {
  position: absolute; top: 2px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted); transform: translateX(-3px);
}
.marker.bad { background: var(--critical); }
.era-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 9px; font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
.era-legend .lg { display: flex; align-items: center; gap: 6px; }
.lg-swatch { width: 10px; height: 10px; border-radius: 2px; }
.year-events { margin-top: 12px; font-size: 13px; color: var(--ink-2); min-height: 20px; }
.year-events .ev { padding: 3px 0; border-bottom: 1px dashed var(--grid); }
.year-events .ev:last-child { border-bottom: 0; }
.year-events .ev-bad { color: var(--critical); }

/* ---------- charts ---------- */
.chart-card svg { display: block; width: 100%; height: auto; }
.chart-card svg text { font-family: var(--font-mono); }
.chart-legend { display: flex; gap: 16px; font-size: 11px; color: var(--ink-2); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.chart-legend .lg { display: flex; align-items: center; gap: 6px; }
.lg-line { width: 14px; height: 0; border-top: 3px solid; border-radius: 2px; }

/* ---------- today (editorial) ---------- */
.today-eyebrow {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 500;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent);
  margin: 34px 0 14px;
}
.today-headline {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(38px, 6vw, 64px); line-height: 1.04; letter-spacing: -0.025em;
  margin: 0 0 24px; max-width: 950px;
}
.today-chiprow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 34px; }
.tchip {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.07em; text-transform: uppercase;
  border: 1px solid var(--ink); border-radius: 3px; padding: 6px 11px; color: var(--ink);
}
.tchip.alert { border-color: var(--accent-2); color: var(--accent-2); }
.tchip.alert::before { content: '● '; }
.tchip.live { border-color: var(--accent); color: var(--accent); }
.tchip.live::before { content: '● '; }

.epoch-head {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  letter-spacing: -0.01em; margin: 6px 0 14px;
}
.epoch-note {
  border-left: 3px solid var(--accent); padding: 4px 0 4px 22px;
  max-width: 720px; margin-bottom: 40px;
}
.epoch-title {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 8px;
}
.epoch-note p { color: var(--ink-2); font-size: 15.5px; line-height: 1.65; margin: 0 0 12px; }
.today-chipnote { color: var(--muted); font-size: 13.5px; }
.stat-band {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--baseline); border-bottom: 1px solid var(--baseline);
  margin-bottom: 40px;
}
@media (max-width: 800px) { .stat-band { grid-template-columns: repeat(2, 1fr); } }
.sb-cell { padding: 20px 22px 22px; border-left: 1px solid var(--baseline); }
.sb-cell:first-child { border-left: 0; padding-left: 0; }
.sb-label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted);
}
.sb-value { font-family: var(--font-display); font-weight: 700; font-size: 42px; letter-spacing: -0.02em; line-height: 1.1; margin-top: 8px; }
.sb-value small { font-family: var(--font-mono); font-size: 13px; font-weight: 400; color: var(--ink-2); letter-spacing: 0; margin-left: 6px; }
.sb-value.blue { color: var(--accent); }
.sb-value.red { color: var(--accent-2); }
.sb-delta { font-family: var(--font-mono); font-size: 11.5px; margin-top: 4px; color: var(--muted); }
.sb-delta.up { color: var(--delta-good); }
.sb-delta.down { color: var(--critical); }
.today-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: start; margin-bottom: 30px; }
@media (max-width: 900px) { .today-cols { grid-template-columns: 1fr; gap: 30px; } }
.today-col h3 {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  letter-spacing: -0.01em; margin: 0 0 14px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.today-col h3 .range { font-family: var(--font-mono); font-size: 11px; font-weight: 400; color: var(--muted); letter-spacing: 0.05em; }
.today-chart svg { display: block; width: 100%; height: auto; }
.today-chart svg text { font-family: var(--font-mono); }
.today-chart-caption { color: var(--ink-2); font-size: 13.5px; margin-top: 14px; max-width: 460px; }
.chron-list { border-top: 1px solid var(--baseline); }
.chron-item { display: flex; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--grid); }
.chron-year {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  color: var(--accent); flex: none; width: 52px; padding-top: 2px;
}
.chron-text { color: var(--ink-2); font-size: 14.5px; }
.chron-text.bad { color: var(--accent-2); }
.today-cta { margin: 4px 0 20px; font-size: 13.5px; }
.today-cta a { color: var(--accent); }
.today-worldmap h3 { margin-top: 26px; }
#todayMapCanvas { width: 100%; max-width: 560px; height: auto; border-radius: 2px; display: block; border: 1px solid var(--border); }

/* ---------- branches view ---------- */
.branch-row {
  display: flex; align-items: baseline; gap: 16px;
  padding: 11px 4px; border-bottom: 1px solid var(--grid);
}
.branch-row.child { padding-left: 34px; }
.branch-key {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent);
  flex: none; width: 170px;
}
.branch-row.child .branch-key { color: var(--accent-2); }
.branch-title { font-size: 14px; color: var(--ink); }
.branch-status { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-left: auto; }
.branch-status.dead { color: var(--critical); }
.branch-open { font-size: 12.5px; color: var(--accent); flex: none; }

/* ---------- events view ---------- */
.events-filter {
  width: 100%; font-family: var(--font-mono); font-size: 13.5px; color: var(--ink);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 3px; padding: 9px 12px; margin-bottom: 12px;
}
.event-list { font-size: 13.5px; }
.event-item {
  display: flex; gap: 16px; padding: 7px 4px; border-bottom: 1px solid var(--grid);
  cursor: pointer;
}
.event-item:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.event-year { color: var(--accent); font-size: 12px; flex: none; width: 56px; padding-top: 1px; }
.event-text { color: var(--ink-2); }
.event-count { color: var(--muted); font-size: 11.5px; margin: 6px 0 12px; }

/* ---------- gallery ---------- */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.g-card { border: 1px solid var(--border); background: var(--surface-1); border-radius: 3px; padding: 15px 17px; }
.g-ending { font-family: var(--font-display); font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.g-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.g-seed { color: var(--muted); font-size: 11px; margin-top: 3px; text-transform: uppercase; letter-spacing: 0.05em; }
.g-facts { margin-top: 10px; font-size: 12.5px; color: var(--ink-2); display: grid; gap: 3px; }
.g-facts b { color: var(--ink); font-weight: 600; }
.gallery-note { color: var(--ink-2); font-size: 13.5px; margin: 4px 0 16px; max-width: 720px; }

/* ---------- about ---------- */
.about { max-width: 760px; }
.about h2 { font-family: var(--font-display); font-size: 20px; letter-spacing: -0.01em; margin: 26px 0 8px; }
.about p, .about li { color: var(--ink-2); font-size: 14.5px; }
.about code {
  font-family: var(--font-mono);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: 3px; padding: 1px 6px; font-size: 12.5px;
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--baseline); padding: 18px 0 30px;
  color: var(--muted); font-size: 11.5px; font-family: var(--font-mono);
}
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
