:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c232d;
  --border: #262e3a;
  --text: #f0f3f6;
  --text-2: #a8b3c1;
  --text-3: #7d8896;
  --accent: #3987e5;
  --calm: #0ca30c;
  --tense: #8fb81c;
  --elevated: #fab219;
  --high: #ec835a;
  --extreme: #d03b3b;
  --up: #ec835a;
  --down: #3fb950;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header / footer */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; font-size: 17px; }
.brand-mark { width: 26px; height: 26px; color: var(--elevated); }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--text-2); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 24px 0 40px; color: var(--text-2); font-size: 13px; }
.crumbs { margin: 20px 0 0; font-size: 13px; color: var(--text-3); }
.crumbs a { color: var(--text-2); text-decoration: none; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; margin-top: 24px; align-items: start; }
.main-col { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-title { font-size: 17px; margin: 0; }
.panel-sub { margin: 2px 0 12px; color: var(--text-3); font-size: 13px; }
.section-h { font-size: 18px; margin: 0 0 12px; }
.section-sub { margin: -8px 0 12px; font-size: 13px; }
.small-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 0 0 8px; font-weight: 600; }

/* Hero */
.hero { padding: 24px; }
.hero-head h1 { margin: 0; font-size: 26px; }
.hero-head p { margin: 4px 0 0; }
.hero-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px; align-items: center; margin-top: 16px; }
.hero-gauge { text-align: center; }
.hero-delta { margin-top: 4px; font-size: 14px; }

/* Gauge */
.gauge { width: 100%; display: block; }
.gauge-lg { max-width: 360px; margin: 0 auto; }
.band-calm { stroke: var(--calm); } .band-tense { stroke: var(--tense); } .band-elevated { stroke: var(--elevated); }
.band-high { stroke: var(--high); } .band-extreme { stroke: var(--extreme); }
.gauge-marker { fill: var(--text); stroke: var(--surface); stroke-width: 3; }
.gauge-value { fill: var(--text); font-size: 44px; font-weight: 700; text-anchor: middle; font-variant-numeric: tabular-nums; }
.gauge-value-sm { font-size: 40px; }
.gauge-label { fill: var(--text-2); font-size: 15px; font-weight: 600; text-anchor: middle; }

/* History list */
.history { margin: 0; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.history-row dt { color: var(--text-2); }
.history-row dd { margin: 0; display: flex; align-items: center; gap: 10px; }
.history-yearly { margin-top: 12px; }
.history-yearly .history-row dt { font-size: 14px; }

/* Pills, deltas, tags */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill-calm { color: var(--calm); border-color: color-mix(in srgb, var(--calm) 45%, transparent); background: color-mix(in srgb, var(--calm) 12%, transparent); }
.pill-tense { color: var(--tense); border-color: color-mix(in srgb, var(--tense) 45%, transparent); background: color-mix(in srgb, var(--tense) 12%, transparent); }
.pill-elevated { color: var(--elevated); border-color: color-mix(in srgb, var(--elevated) 45%, transparent); background: color-mix(in srgb, var(--elevated) 12%, transparent); }
.pill-high { color: var(--high); border-color: color-mix(in srgb, var(--high) 45%, transparent); background: color-mix(in srgb, var(--high) 12%, transparent); }
.pill-extreme { color: #f07171; border-color: color-mix(in srgb, var(--extreme) 55%, transparent); background: color-mix(in srgb, var(--extreme) 16%, transparent); }
.delta { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); } .delta.flat { color: var(--text-3); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px; text-decoration: none; }
.tag-link:hover { color: var(--text); border-color: var(--text-3); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.card { padding: 16px 16px 14px; text-decoration: none; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--text-3); transform: translateY(-1px); }
.card h3 { margin: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; }

/* Hotspots */
.hotspots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.hotspot { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name val" "meter meter"; gap: 8px 12px; padding: 12px 14px; text-decoration: none; align-items: center; }
.hotspot:hover { border-color: var(--text-3); }
.hotspot-name { grid-area: name; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hotspot-val { grid-area: val; display: flex; align-items: center; gap: 8px; }
.meter { grid-area: meter; width: 100%; height: 6px; display: block; }
.meter-track { fill: var(--surface-2); }
.fill-calm { fill: var(--calm); } .fill-tense { fill: var(--tense); } .fill-elevated { fill: var(--elevated); }
.fill-high { fill: var(--high); } .fill-extreme { fill: var(--extreme); }

/* Chart */
.chart-panel { padding: 20px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.select select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button { background: none; border: 0; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--border); color: var(--text); }
.chart { position: relative; height: 280px; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.chart .axis text { fill: var(--text-3); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#chart-fill); }
.chart .crosshair { stroke: var(--text-3); stroke-dasharray: 3 3; }
.chart .hover-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.tooltip strong { font-size: 14px; }

/* World map */
.map-panel { padding: 20px; }
.world { width: 100%; height: auto; display: block; margin-top: 8px; }
.world .region path { stroke: var(--surface); stroke-width: .6; transition: opacity .15s; }
.world a:hover .region path, .world a:focus .region path { opacity: .8; }
.world .nodata { fill: var(--surface-2); }
.map-label rect { fill: var(--bg); stroke: var(--border); opacity: .9; }
.map-label text { fill: var(--text); font-size: 14px; font-weight: 700; text-anchor: middle; font-variant-numeric: tabular-nums; pointer-events: none; }
.map-label { pointer-events: none; }
.legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.fill-calm { background: var(--calm); } .swatch.fill-tense { background: var(--tense); } .swatch.fill-elevated { background: var(--elevated); }
.swatch.fill-high { background: var(--high); } .swatch.fill-extreme { background: var(--extreme); }
.region-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 20px; }
.region-list a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); text-decoration: none; }
.region-list a:hover .region-name { text-decoration: underline; }
.region-val { display: flex; align-items: center; gap: 8px; }

/* Sources */
.sources-panel { padding: 18px; position: sticky; top: 16px; }
.sources { list-style: none; margin: 0; padding: 0; }
.source { padding: 12px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.source-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.logo { width: 20px; height: 20px; border-radius: 5px; background: #fff; object-fit: contain; }
.logo-fallback { display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--text); background: var(--border); }
.outlet { color: var(--text-2); font-weight: 600; }
.source-title { font-weight: 500; text-decoration: none; line-height: 1.4; }
.source-title:hover { text-decoration: underline; }

/* Prose */
.prose { padding: 28px; margin-top: 24px; max-width: 820px; }
.prose h1 { margin-top: 0; }
.prose h2 { font-size: 18px; margin-top: 28px; }
.prose p, .prose li, .prose dd { color: var(--text-2); }
.defs dt { font-weight: 600; margin-top: 12px; }
.defs dd { margin: 2px 0 0; }
.scale-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sources-panel { position: static; }
}
@media (max-width: 640px) {
  .hero { padding: 18px; }
  .hero-body { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .header-inner { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .nav a { padding: 6px 8px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 12px 10px; }
  .chart { height: 220px; }
}
