:root {
  --bg: #07080c;
  --panel: rgba(12, 13, 19, 0.72);
  --panel-solid: #0e0f16;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3efe9;
  --muted: #9a958e;
  --dim: #5f5b56;
  --track: rgba(255, 255, 255, 0.07);
  --ember: #ff7a1f;
  --ember-hot: #ffd27a;
  --ember-deep: #ff3d1f;
  --lightning: #ffc23d;
  --human: #ff5a36;
  --unknown: #a99bff;
  --ok: #7fe0a8;
  --radius: 14px;
  --font: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font-family: var(--mono); font-size: 10px; padding: 1px 5px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--muted); }

#map { position: fixed; inset: 0; }
.vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(0,0,0,0.55) 100%); }
.maplibregl-ctrl-attrib { background: rgba(0,0,0,0.5) !important; color: var(--dim); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-bottom-right { bottom: 92px; }

/* ---------- Intro ---------- */
#intro { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 120%, #2a0d04 0%, #0b0606 45%, #050507 100%); transition: opacity 1.2s ease, visibility 1.2s; }
#intro.gone { opacity: 0; visibility: hidden; }
#embers { position: absolute; inset: 0; width: 100%; height: 100%; }
.intro-inner { position: relative; text-align: center; padding: 24px; max-width: 760px; }
.eyebrow { font-family: var(--mono); letter-spacing: 0.3em; text-transform: uppercase; color: var(--ember); font-size: 12px; margin: 0 0 12px; }
#intro h1 { font-size: clamp(56px, 12vw, 132px); line-height: 0.9; margin: 0; font-weight: 700; letter-spacing: -0.04em;
  background: linear-gradient(180deg, #fff6e0 0%, #ffd27a 35%, #ff7a1f 70%, #ff3d1f 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 40px rgba(255, 110, 30, 0.45)); animation: breathe 4s ease-in-out infinite; }
#intro h1 span { font-weight: 400; }
@keyframes breathe { 50% { filter: drop-shadow(0 0 70px rgba(255, 110, 30, 0.7)); } }
.lede { color: #d9cfc4; font-size: clamp(16px, 2.2vw, 20px); line-height: 1.5; margin: 20px auto 32px; max-width: 560px; }
.intro-foot { color: var(--dim); font-size: 12px; font-family: var(--mono); margin-top: 20px; min-height: 1em; }

.cta { position: relative; border: 0; border-radius: 999px; padding: 15px 34px; font-weight: 600; font-size: 16px; color: #1b0a02;
  background: linear-gradient(135deg, #ffd27a, #ff7a1f 60%, #ff3d1f); box-shadow: 0 0 0 1px rgba(255,200,120,0.4), 0 10px 40px -10px rgba(255,100,30,0.8); transition: transform .2s, box-shadow .2s, opacity .3s; }
.cta:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(255,220,150,0.6), 0 16px 50px -10px rgba(255,100,30,1); }
.cta:disabled { opacity: 0.55; cursor: progress; }
.cta.small { padding: 9px 20px; font-size: 14px; }
.ghost { background: transparent; border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 16px; color: var(--text); transition: background .2s; }
.ghost:hover { background: rgba(255,255,255,0.06); }

/* ---------- Top bar ---------- */
.topbar { position: fixed; top: 16px; left: 16px; right: 16px; z-index: 10; display: flex; align-items: center; gap: 16px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 500; letter-spacing: -0.02em; padding: 8px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(14px); }
.brand b { color: var(--ember); font-weight: 700; }
.brand svg { width: 20px; height: 20px; fill: var(--ember); filter: drop-shadow(0 0 6px var(--ember)); }
.modes { display: flex; gap: 4px; padding: 4px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(14px); }
.modes button { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; padding: 8px 16px; border-radius: 999px; color: var(--muted); font-weight: 500; transition: color .2s, background .2s; }
.modes button:hover { color: var(--text); }
.modes button[aria-selected="true"] { background: linear-gradient(135deg, rgba(255,122,31,0.25), rgba(255,61,31,0.15)); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255,122,31,0.4); }
.modes kbd { border: 0; padding: 0; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--human); box-shadow: 0 0 0 0 rgba(255,90,54,0.7); animation: ping 1.6s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(255,90,54,0); } 100% { box-shadow: 0 0 0 0 rgba(255,90,54,0); } }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px); color: var(--muted); font-weight: 600; }

/* ---------- Panels ---------- */
.panel { position: fixed; z-index: 5; top: 76px; bottom: 100px; width: 272px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(1.2); overflow-y: auto; scrollbar-width: thin; transition: transform .5s cubic-bezier(.2,.8,.2,1), opacity .4s; }
.panel.left { left: 16px; }
.panel.right { right: 16px; width: 300px; }
body.story-mode .panel.left { transform: translateX(-120%); opacity: 0; }

.date-display { margin-bottom: 18px; }
.date-year { font-size: 64px; font-weight: 700; letter-spacing: -0.05em; line-height: 0.9; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff, #ffb36b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.date-day { font-family: var(--mono); color: var(--ember); font-size: 13px; margin-top: 4px; letter-spacing: 0.05em; text-transform: uppercase; }

.group { padding: 14px 0; border-top: 1px solid var(--line); }
.glabel { display: flex; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 10px; }
.glabel output { font-family: var(--mono); color: var(--text); text-transform: none; letter-spacing: 0; }
.seg-ctl { display: flex; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-ctl button { flex: 1; border: 0; background: transparent; padding: 7px 6px; border-radius: 7px; color: var(--muted); font-size: 13px; transition: all .2s; white-space: nowrap; }
.seg-ctl button.on { background: rgba(255,122,31,0.18); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255,122,31,0.35); }
select.source { width: 100%; background: rgba(255,255,255,0.04); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; font-size: 13px; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); transition: all .2s; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.on { color: var(--text); background: rgba(255,255,255,0.06); }
.chip.on i { background: var(--c); box-shadow: 0 0 8px var(--c); }
.toggle { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--ember); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; background: transparent; height: 22px; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: var(--track); border-radius: 4px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--ember-hot); box-shadow: 0 0 0 3px rgba(255,122,31,0.3), 0 0 12px var(--ember); }
input[type=range]::-moz-range-track { height: 4px; background: var(--track); border-radius: 4px; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--ember-hot); }
.range2 { position: relative; height: 22px; }
.range2 input { position: absolute; inset: 0; pointer-events: none; }
.range2 input::-webkit-slider-thumb { pointer-events: auto; }
.range2 input::-moz-range-thumb { pointer-events: auto; }
.range2 input + input::-webkit-slider-runnable-track { background: transparent; }

.live-source { font-size: 13px; line-height: 1.5; color: var(--muted); margin-bottom: 14px; }
.live-source .src { color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.live-source .badge { font-family: var(--mono); font-size: 10px; padding: 2px 6px; border-radius: 4px; background: rgba(255,194,61,0.15); color: var(--lightning); }
.live-source .badge.real { background: rgba(127,224,168,0.15); color: var(--ok); }
.live-source ul { list-style: none; padding: 0; margin: 8px 0 0; font-family: var(--mono); font-size: 11px; }
.live-source li::before { content: '● '; color: var(--dim); }
.live-source li.ok::before { color: var(--ok); }
.live-source li.bad::before { color: var(--human); }

/* ---------- Stats ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kv { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi.hot .kv { color: var(--ember-hot); text-shadow: 0 0 18px rgba(255,122,31,0.6); }
.kl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); line-height: 1.3; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart { position: relative; padding: 12px 0; border-top: 1px solid var(--line); }
.chart h3 { margin: 0 0 6px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); display: flex; justify-content: space-between; }
.chart h3 small { text-transform: none; letter-spacing: 0; color: var(--dim); }
.donut, .clock { width: 100%; height: auto; display: block; }
.seg { transition: stroke-dasharray .7s cubic-bezier(.2,.8,.2,1), stroke-dashoffset .7s cubic-bezier(.2,.8,.2,1); }
.clock .seg.now { filter: drop-shadow(0 0 4px #ffb36b); }
.donut-big { fill: var(--text); font-size: 20px; font-weight: 700; }
.donut-sub { fill: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: 0.1em; }
.clock-label { fill: var(--dim); font-size: 8px; font-family: var(--mono); }
.legend { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; }
.legend b { margin-left: auto; color: var(--text); font-family: var(--mono); font-weight: 400; }
.yearbars { display: flex; align-items: flex-end; gap: 2px; height: 80px; }
.ybar { flex: 1; height: 100%; position: relative; border: 0; background: transparent; padding: 0 0 13px; display: flex; align-items: flex-end; min-width: 0; }
.ybar .fill { display: block; width: 100%; height: 100%; border-radius: 2px 2px 0 0; background: linear-gradient(0deg, rgba(255,61,31,0.5), rgba(255,160,60,0.8)); transform-origin: bottom; transition: transform .8s cubic-bezier(.2,.8,.2,1), background .3s; }
.ybar:hover .fill { background: linear-gradient(0deg, #ff7a1f, #ffe0a0); }
.ybar.active .fill { background: linear-gradient(0deg, #ff7a1f, #fff3d6); box-shadow: 0 0 12px rgba(255,160,60,0.8); }
.ybar .yl { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 8px; color: var(--dim); }
.ybar:nth-child(odd) .yl { visibility: hidden; }
.yearbars.dense .ybar .yl { visibility: hidden; }
.yearbars.dense .ybar:nth-child(5n+1) .yl { visibility: visible; }
.yearbars.dense { gap: 1px; }
.largest { border-top: 1px solid var(--line); padding-top: 12px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.largest b { color: var(--text); }
.largest button { background: none; border: 0; padding: 0; color: var(--ember-hot); text-decoration: underline; text-underline-offset: 3px; }

.threats { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.threats h3 { margin: 0 0 8px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.threat { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; cursor: pointer; }
.threat:hover { color: var(--ember-hot); }
.threat span:last-child { font-family: var(--mono); color: var(--human); white-space: nowrap; }

/* ---------- Timeline ---------- */
.timeline { position: fixed; z-index: 6; left: 16px; right: 16px; bottom: 16px; height: 68px; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(16px); transition: transform .5s, opacity .4s; }
body.mode-live .timeline, body.mode-explore .timeline { transform: translateY(140%); opacity: 0; }
.play { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: linear-gradient(135deg, #ffd27a, #ff7a1f); box-shadow: 0 0 20px rgba(255,122,31,0.5); }
.play svg { width: 18px; height: 18px; fill: #1b0a02; }
.play .i-pause, .play.playing .i-play { display: none; }
.play.playing .i-pause { display: block; }
.track { position: relative; flex: 1; height: 48px; cursor: crosshair; touch-action: none; }
#tl-canvas { width: 100%; height: 100%; display: block; }
.playhead { position: absolute; top: -6px; bottom: 10px; width: 2px; left: 0; background: #fff; box-shadow: 0 0 10px #fff, 0 0 20px var(--ember); pointer-events: none; will-change: transform; }
.playhead span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 10px; white-space: nowrap; color: var(--ember-hot); background: rgba(0,0,0,0.6); padding: 1px 5px; border-radius: 4px; }
.hover-tip { position: absolute; bottom: 52px; transform: translateX(-50%); font-family: var(--mono); font-size: 11px; background: var(--panel-solid); border: 1px solid var(--line-strong); padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s; }
.track:hover .hover-tip { opacity: 1; }
.speed { flex: none; width: 190px; }

/* ---------- Year flash ---------- */
.year-flash { position: fixed; z-index: 4; left: 50%; top: 45%; transform: translate(-50%, -50%); font-size: clamp(90px, 20vw, 240px); font-weight: 700; letter-spacing: -0.06em; pointer-events: none; opacity: 0;
  color: transparent; -webkit-text-stroke: 1px rgba(255,190,120,0.5); }
.year-flash.show { animation: flash 1.8s ease-out; }
@keyframes flash { 0% { opacity: 0; transform: translate(-50%, -46%) scale(0.96); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -54%) scale(1.04); } }

/* ---------- Card ---------- */
.card { position: fixed; z-index: 20; left: 50%; top: 84px; transform: translateX(-50%); width: min(380px, calc(100vw - 32px)); padding: 18px 20px; background: rgba(14,15,22,0.92); border: 1px solid rgba(255,122,31,0.35); border-radius: var(--radius);
  box-shadow: 0 20px 60px -20px rgba(255,90,30,0.5); backdrop-filter: blur(16px); animation: rise .35s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
.card .close { position: absolute; top: 10px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; }
.card .kicker { font-family: var(--mono); font-size: 11px; color: var(--ember); letter-spacing: 0.08em; text-transform: uppercase; }
.card h2 { margin: 4px 0 12px; font-size: 26px; letter-spacing: -0.03em; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; font-size: 13px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }
.card .compare { font-size: 13px; color: #d9cfc4; line-height: 1.5; padding: 10px 12px; border-radius: 10px; background: rgba(255,122,31,0.08); border: 1px solid rgba(255,122,31,0.15); }
.card .actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Story ---------- */
.story { position: fixed; z-index: 8; left: 16px; bottom: 100px; width: min(420px, calc(100vw - 32px)); padding: 22px 24px; background: rgba(10,11,16,0.85); border: 1px solid var(--line-strong); border-radius: var(--radius); backdrop-filter: blur(18px); animation: rise2 .6s cubic-bezier(.2,.8,.2,1); }
@keyframes rise2 { from { opacity: 0; transform: translateY(20px); } }
.story-progress { display: flex; gap: 4px; margin-bottom: 14px; }
.story-progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--track); transition: background .4s; }
.story-progress i.on { background: var(--ember); box-shadow: 0 0 8px var(--ember); }
.story-kicker { margin: 0; font-family: var(--mono); font-size: 11px; color: var(--ember); letter-spacing: 0.15em; text-transform: uppercase; }
.story h2 { margin: 6px 0 10px; font-size: 28px; letter-spacing: -0.03em; line-height: 1.1; }
.story p#story-body { margin: 0 0 18px; color: #d9cfc4; line-height: 1.6; font-size: 15px; }
.story p#story-body b { color: var(--ember-hot); font-weight: 600; }
.story-nav { display: flex; justify-content: space-between; }
.story .text-swap { animation: fadein .5s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Tooltip, dialog, toast ---------- */
.deck-tooltip { font-family: var(--font) !important; background: rgba(14,15,22,0.94) !important; border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 12px !important; font-size: 13px !important; color: var(--text) !important; max-width: 260px; }
.deck-tooltip b { color: var(--ember-hot); }
.deck-tooltip small { color: var(--muted); font-family: var(--mono); }
dialog { max-width: 560px; background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 24px 28px; line-height: 1.6; font-size: 14px; }
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
dialog h2 { margin-top: 0; }
dialog code { font-family: var(--mono); font-size: 12px; color: var(--ember-hot); }
.muted { color: var(--muted); }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 100px; transform: translate(-50%, 20px); background: var(--panel-solid); border: 1px solid var(--line-strong); padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: all .3s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

[data-show] { display: none; }
body.mode-timeline [data-show~="timeline"], body.mode-explore [data-show~="explore"], body.mode-live [data-show~="live"], body.mode-spread [data-show~="spread"] { display: block; }

/* ---------- True spread replay ---------- */
body.mode-spread #stats > :not([data-show~="spread"]) { display: none; }
body.mode-spread .timeline:not(.spread-tl) { transform: translateY(140%); opacity: 0; pointer-events: none; }
.spread-tl { transform: translateY(140%); opacity: 0; pointer-events: none; }
body.mode-spread .spread-tl { transform: none; opacity: 1; pointer-events: auto; }
body.mode-spread.story-mode .spread-tl { transform: translateY(140%); opacity: 0; }
.spread-tl .speed { width: 250px; }
#spread-canvas { width: 100%; height: 100%; display: block; }
.small { font-size: 12px; line-height: 1.5; }
.search { width: 100%; background: rgba(255,255,255,0.04); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; margin-bottom: 8px; }
.search:focus { outline: none; border-color: rgba(255,122,31,0.5); box-shadow: 0 0 0 3px rgba(255,122,31,0.12); }
.spread-list { max-height: 38vh; overflow-y: auto; scrollbar-width: thin; margin: 0 -6px; padding: 0 6px; }
.spread-list code { font-family: var(--mono); font-size: 11px; color: var(--ember-hot); }
.sl-year { position: sticky; top: 0; z-index: 1; font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em; color: var(--dim); padding: 8px 0 4px; background: linear-gradient(var(--panel-solid) 70%, transparent); }
.sl-row { position: relative; display: flex; width: 100%; justify-content: space-between; gap: 8px; align-items: baseline; background: transparent; border: 0; border-radius: 8px; padding: 7px 8px 9px; text-align: left; color: var(--muted); font-size: 13px; transition: background .2s, color .2s; }
.sl-row:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.sl-row.on { background: linear-gradient(135deg, rgba(255,122,31,0.22), rgba(255,61,31,0.08)); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255,122,31,0.35); }
.sl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-ha { font-family: var(--mono); font-size: 11px; color: var(--dim); white-space: nowrap; }
.sl-row.on .sl-ha { color: var(--ember-hot); }
.sl-row i { position: absolute; left: 8px; bottom: 4px; height: 2px; width: var(--w); max-width: calc(100% - 16px); border-radius: 2px; background: linear-gradient(90deg, var(--ember-deep), var(--ember-hot)); opacity: 0.55; }

.spread-kicker { margin: 0; font-family: var(--mono); font-size: 11px; color: var(--ember); letter-spacing: 0.12em; text-transform: uppercase; }
.spread-name { margin: 4px 0 14px; font-size: 26px; letter-spacing: -0.03em; line-height: 1.05; }
.spread-today { margin: -6px 0 6px; font-size: 12px; color: var(--muted); min-height: 1.4em; font-variant-numeric: tabular-nums; }
.spread-today b { color: var(--ember-hot); font-weight: 600; }
.spread-today .peak { font-family: var(--mono); font-size: 10px; padding: 1px 6px; border-radius: 4px; margin-left: 4px; background: rgba(255,210,122,0.16); color: var(--ember-hot); text-transform: uppercase; letter-spacing: 0.08em; }
.growth { width: 100%; height: auto; display: block; overflow: visible; }
.growth .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.growth .lbl { fill: var(--dim); font-size: 8px; font-family: var(--mono); }
.growth .ghost { fill: none; stroke: rgba(255,255,255,0.12); stroke-width: 1; stroke-dasharray: 2 2; }
.growth .curve { fill: none; stroke: var(--ember-hot); stroke-width: 1.8; filter: drop-shadow(0 0 4px rgba(255,140,40,0.9)); }
.growth .bars rect { fill: rgba(255,122,31,0.65); }
.growth .bars rect.pk { fill: #fff3d6; filter: drop-shadow(0 0 3px #ffb36b); }
.growth .mg { fill: #fff3d6; filter: drop-shadow(0 0 3px #ffd27a); }
.growth .ph line { stroke: rgba(255,255,255,0.6); stroke-width: 1; }
.growth .ph-dot { fill: #fff; filter: drop-shadow(0 0 5px var(--ember)); }
.rate-legend { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; }
.rate-legend i { flex: 1; height: 6px; border-radius: 3px; box-shadow: 0 0 10px rgba(255,140,40,0.45); }
.dot-legend { display: flex; gap: 14px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.dot-legend span { display: flex; align-items: center; gap: 6px; }
.dot-legend i { width: 7px; height: 7px; border-radius: 50%; }
.dot-legend .d-hot { background: #ffdc82; box-shadow: 0 0 6px #ff8c32; }
.dot-legend .d-beam { width: 2px; height: 12px; border-radius: 1px; background: linear-gradient(0deg, #fff, rgba(255,150,60,0)); }
.spread-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; padding: 12px 0; border-top: 1px solid var(--line); font-size: 12px; }
.spread-facts dt { color: var(--muted); }
.spread-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.spread-facts dd b { color: var(--ember-hot); font-weight: 600; }
.spread-facts small { color: var(--dim); font-family: var(--mono); font-size: 10px; }
.spread-method { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 11.5px; line-height: 1.55; color: #d9cfc4; background: rgba(255,122,31,0.07); border: 1px solid rgba(255,122,31,0.15); }
.spread-method b { color: var(--ember-hot); }

.spread-title { position: fixed; z-index: 7; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; opacity: 0; width: min(900px, calc(100vw - 32px)); }
.spread-title .eyebrow { margin-bottom: 6px; }
.spread-title h2 { margin: 0; font-size: clamp(48px, 9vw, 112px); font-weight: 700; letter-spacing: -0.05em; line-height: 0.95;
  background: linear-gradient(180deg, #fff6e0 0%, #ffd27a 40%, #ff7a1f 80%, #ff3d1f 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 40px rgba(255,110,30,0.55)); }
.spread-title p:last-child { margin: 12px 0 0; font-family: var(--mono); font-size: 13px; color: #d9cfc4; letter-spacing: 0.06em; }
.spread-title.show { animation: title-card 4.2s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes title-card { 0% { opacity: 0; transform: translate(-50%, -44%) scale(0.97); letter-spacing: 0.02em; } 18%, 62% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -56%) scale(1.02); } }

.spread-callout { position: fixed; z-index: 7; left: 50%; top: 84px; transform: translate(-50%, -10px); padding: 9px 18px; border-radius: 999px; font-size: 14px; white-space: nowrap; pointer-events: none; opacity: 0;
  background: rgba(14,15,22,0.88); border: 1px solid rgba(255,190,120,0.5); box-shadow: 0 0 40px -6px rgba(255,120,40,0.75); backdrop-filter: blur(12px); }
.spread-callout b { color: var(--ember-hot); }
.spread-callout small { font-family: var(--mono); color: var(--dim); margin-left: 6px; }
.spread-callout.show { animation: callout 4.5s ease forwards; }
@keyframes callout { 0% { opacity: 0; transform: translate(-50%, -10px); } 10%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 0); } }
.spread-slow { position: fixed; z-index: 7; left: 50%; top: 128px; transform: translateX(-50%); font-family: var(--mono); font-size: 10px; letter-spacing: 0.35em; text-transform: uppercase; color: var(--ember-hot); opacity: 0; transition: opacity .5s; pointer-events: none; }
.spread-slow.on { opacity: 0.8; }
.spread-loading { position: fixed; z-index: 7; left: 50%; bottom: 104px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); background: var(--panel-solid); border: 1px solid var(--line-strong); padding: 9px 16px; border-radius: 999px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.spread-loading.show { opacity: 1; }
.spread-loading i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ember); border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card .actions { flex-wrap: wrap; }
.card .actions button { white-space: nowrap; }
.card .actions .cta.small { padding: 9px 16px; }
.card .actions .spread-btn { background: linear-gradient(135deg, #fff3d6, #ffb36b); }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .modes kbd, .brand { display: none; }
  .modes button { padding: 8px 12px; }
  .panel.right { display: none; }
  .panel.left { top: auto; bottom: 96px; width: auto; right: 16px; max-height: 38vh; }
  .date-year { font-size: 40px; }
  .speed { width: 120px; }
  .speed button:nth-child(n+3) { display: none; }
  .story { bottom: 96px; }
  .spread-tl .speed { width: 130px; }
  .spread-callout { top: 70px; font-size: 12px; }
  .spread-list { max-height: 18vh; }
  body.story-mode .panel.left { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Scene, lightning, sound ---------- */
.hint { margin: 6px 0 0; font-size: 11px; line-height: 1.45; color: var(--dim); }
.hint b { color: var(--text); font-weight: 600; }
.group .seg-ctl + .toggle { margin-top: 12px; }
.group .toggle + .glabel { margin-top: 12px; }
.cldn-head { margin-top: 16px; }
.ghost.small { padding: 5px 12px; font-size: 12px; margin-top: 8px; }
#sky-clock { font-variant-numeric: tabular-nums; }

.sky-flash { position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at 50% 40%, rgba(200, 215, 255, 0.9), rgba(140, 160, 255, 0.25) 60%, transparent 85%); mix-blend-mode: screen; }
.sky-flash.on { animation: skyflash .5s ease-out; }
@keyframes skyflash { 0% { opacity: var(--flash, .1); } 12% { opacity: calc(var(--flash, .1) * .3); } 24% { opacity: var(--flash, .1); } 100% { opacity: 0; } }

.sound-btn { flex: none; position: relative; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); display: grid; place-items: center; transition: all .2s; }
.sound-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sound-btn svg path:first-child { fill: currentColor; stroke: none; }
.sound-btn .w1, .sound-btn .w2 { opacity: .35; }
.sound-btn:hover { color: var(--text); border-color: rgba(255, 122, 31, 0.5); }
.sound-btn.on { color: var(--ember-hot); border-color: rgba(255, 122, 31, 0.6); box-shadow: 0 0 16px rgba(255, 122, 31, 0.35); }
.sound-btn.on .w1, .sound-btn.on .w2 { opacity: 1; }
.sound-btn .eq { position: absolute; bottom: -2px; right: -4px; display: none; gap: 1px; align-items: flex-end; height: 10px; }
.sound-btn.on .eq { display: flex; }
.sound-btn .eq i { width: 2px; background: var(--ember); border-radius: 1px; animation: eq 0.9s ease-in-out infinite; }
.sound-btn .eq i:nth-child(2) { animation-delay: -.3s; }
.sound-btn .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 10px; } }

/* ---------- Documentary: Emberline Presents ---------- */
.intro-ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.watch-cta { display: inline-flex; align-items: center; gap: 8px; padding: 14px 26px; font-size: 15px; border-color: rgba(255,122,31,0.45); }
.watch-cta svg, .watch-btn svg { width: 12px; height: 12px; fill: var(--ember); }
.watch-cta:disabled { opacity: 0.4; cursor: progress; }
.watch-btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 999px; background: var(--panel); border: 1px solid rgba(255,122,31,0.45); backdrop-filter: blur(14px); font-weight: 500; transition: background .2s, box-shadow .2s; }
.watch-btn:hover { background: rgba(255,122,31,0.14); box-shadow: 0 0 18px -4px var(--ember); }
body.doc-mode .watch-btn { background: linear-gradient(135deg, rgba(255,122,31,0.3), rgba(255,61,31,0.18)); }

body.doc-mode .story-nav, body.doc-mode .story-progress { display: none; }
.doc-bar { display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: 10px; margin-top: 4px; }
.doc-bar[hidden] { display: none; }
.doc-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(255,255,255,0.04); color: var(--text); padding: 0; font-size: 13px; transition: background .2s; }
.doc-btn:hover { background: rgba(255,122,31,0.18); }
.doc-btn svg { width: 14px; height: 14px; fill: currentColor; }
#doc-pause .i-play, #doc-pause.paused .i-pause { display: none; }
#doc-fire { color: var(--ember); }
#doc-fire svg { fill: currentColor; filter: drop-shadow(0 0 4px rgba(255,122,31,0.7)); }
#doc-fire.off { color: var(--dim); }
#doc-fire.off svg { filter: none; }
#doc-fire.off::after { content: ''; position: absolute; width: 18px; height: 1.5px; background: currentColor; transform: rotate(-45deg); }
#doc-fire { position: relative; }
#doc-pause.paused .i-play { display: block; }
#doc-pause.paused { border-color: var(--ember); box-shadow: 0 0 12px -2px var(--ember); }
.doc-progress { display: flex; gap: 4px; }
.doc-progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--track); transition: background .4s, box-shadow .4s; }
.doc-progress i.on { background: var(--ember); box-shadow: 0 0 8px var(--ember); }
.doc-voice { grid-column: 1 / -1; margin: 2px 0 0; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--dim); text-transform: uppercase; }
.doc-paused-note { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--ember-hot); display: none; }
body.doc-paused .doc-paused-note { display: block; }

.doc-caption { position: fixed; z-index: 9; left: 452px; right: 332px; bottom: 102px; margin: 0; text-align: center; pointer-events: none;
  font-size: clamp(16px, 1.45vw, 21px); line-height: 1.45; font-weight: 500; color: #fff8ef; opacity: 0; transition: opacity .35s;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9), 0 0 24px rgba(0,0,0,0.9); text-wrap: balance; }
.doc-caption.on { opacity: 1; }
.doc-caption.swap { animation: fadein .45s ease; }
.doc-card.in:not([hidden]) + .doc-caption { opacity: 0; } /* the card already shows its line */

.doc-card { position: fixed; inset: 0; z-index: 40; display: grid; place-content: center; justify-items: center; text-align: center; padding: 24px; opacity: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(30,10,4,0.72), rgba(5,5,7,0.94) 70%); transition: opacity .9s ease; }
.doc-card.in { opacity: 1; }
.doc-card.out { opacity: 0; pointer-events: none; }
.doc-card[hidden] { display: none; } /* display: grid would otherwise leave the invisible card over the map, eating every click */
.doc-card h1 { margin: 0; font-size: clamp(44px, 8vw, 104px); line-height: 0.95; letter-spacing: -0.04em; font-weight: 700;
  background: linear-gradient(180deg, #fff3dc 10%, var(--ember-hot) 45%, var(--ember) 75%, var(--ember-deep)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 40px rgba(255,110,30,0.45)); }
.doc-card.in h1 { animation: doc-title 2.4s cubic-bezier(.2,.8,.2,1) both; }
@keyframes doc-title { from { opacity: 0; letter-spacing: 0.04em; filter: blur(8px) drop-shadow(0 0 40px rgba(255,110,30,0)); } }
.doc-sub { margin: 18px 0 0; font-size: clamp(16px, 2vw, 22px); color: #e6dbcf; max-width: 640px; }
.doc-disclose { margin: 34px 0 0; font-family: var(--mono); font-size: 11px; line-height: 1.7; color: var(--muted); letter-spacing: 0.04em; max-width: 620px; }
.doc-sim { margin: 18px 0 0; padding: 4px 12px; border: 1px solid var(--human); border-radius: 6px; color: var(--human); font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; }
.doc-end { display: flex; gap: 12px; margin-top: 30px; }

@media (max-width: 1100px) {
  .doc-caption { left: 16px; right: 16px; bottom: auto; top: 70px; }
}
@media (max-width: 900px) {
  .watch-btn { padding: 0 12px; }
  .doc-caption { font-size: 15px; }
}

/* ---------- Sources: "Read the rings" ---------- */
.sources-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 999px; background: var(--panel); border: 1px solid rgba(255,210,122,0.35); backdrop-filter: blur(14px); color: var(--ember-hot); font-weight: 500; transition: background .2s, box-shadow .2s; }
.sources-btn:hover { background: rgba(255,210,122,0.12); box-shadow: 0 0 18px -4px var(--ember-hot); }
.sources-btn i { position: relative; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ember-hot); box-shadow: 0 0 8px rgba(255,210,122,0.6), inset 0 0 0 2px rgba(0,0,0,0.6), inset 0 0 0 3.5px rgba(255,210,122,0.7); animation: ringGlow 2.6s ease-in-out infinite; }
@keyframes ringGlow { 50% { box-shadow: 0 0 14px rgba(255,140,50,0.9), inset 0 0 0 2px rgba(0,0,0,0.6), inset 0 0 0 3.5px rgba(255,180,90,0.9); } }
dialog .sources-btn { height: auto; padding: 8px 14px; }
.intro-sources { margin-top: 14px; background: none; border: 0; color: var(--muted); font-size: 13px; letter-spacing: 0.02em; border-bottom: 1px dotted var(--dim); padding: 2px 0; transition: color .2s; }
.intro-sources:hover { color: var(--ember-hot); }

.sources { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-columns: 1fr minmax(340px, 420px); background: radial-gradient(ellipse at 38% 55%, #1d0b04 0%, #0a0606 55%, #050507 100%); opacity: 0; transition: opacity .4s ease; }
.sources.on { opacity: 1; }
.sources[hidden] { display: none; } /* display: grid above would otherwise keep the closed overlay over the map, eating every click */
body.sources-open .topbar, body.sources-open .panel, body.sources-open .timeline { visibility: hidden; }
.rings-stage { position: relative; min-height: 0; display: grid; grid-template-rows: auto 1fr; }
.rings-head { padding: 28px 36px 0; max-width: 760px; pointer-events: none; position: relative; z-index: 1; }
.rings-head .eyebrow { margin-bottom: 6px; }
.rings-head h2 { margin: 0; font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.03em; font-weight: 600; }
.rings-lede { margin: 8px 0 6px; color: var(--muted); font-size: 13.5px; line-height: 1.55; max-width: 640px; }
.rings-sum { margin: 0; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.rings-sum b { color: var(--ember-hot); font-weight: 600; }
#rings { width: 100%; height: 100%; min-height: 0; display: block; touch-action: none; }
.rings-tip { position: absolute; z-index: 2; pointer-events: none; min-width: 150px; max-width: 220px; padding: 8px 11px; font-size: 12px; line-height: 1.5; background: rgba(10,8,8,0.92); border: 1px solid var(--line-strong); border-radius: 8px; }
.rings-tip b { font-size: 14px; }
.rings-tip span { color: var(--muted); }
.rings-tip .scar { color: var(--ember); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
.rings-tip .cov { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.rings-tip .cov i, .src-list button i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px var(--c); margin-right: 5px; }
.rings-replay { position: absolute; left: 36px; bottom: 24px; }

.src-panel { position: relative; overflow-y: auto; scrollbar-width: thin; padding: 22px 22px 28px; background: rgba(12,13,19,0.78); border-left: 1px solid var(--line); backdrop-filter: blur(16px); }
.src-close { position: sticky; top: 0; float: right; z-index: 2; }
.src-group h4 { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); font-weight: 500; }
.src-group h4 small { color: var(--dim); letter-spacing: 0.08em; margin-left: 6px; }
.src-group:first-child h4 { margin-top: 4px; }
.src-group > div { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.src-list button em { display: none; }
.src-list button { display: flex; align-items: center; width: 100%; gap: 2px; text-align: left; padding: 5px 8px; margin: 0; line-height: 1.25; background: transparent; border: 1px solid transparent; border-radius: 8px; font-size: 13px; color: var(--text); transition: background .15s, border-color .15s; }
.src-list button span { flex: 1; font-size: 12px; }
.src-list button:hover { background: rgba(255,255,255,0.04); }
.src-list button[aria-pressed="true"] { background: rgba(255,255,255,0.06); border-color: color-mix(in srgb, var(--c) 55%, transparent); }
.src-list em, .src-kicker span { font-style: normal; font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.t-simulated { color: #c9b8ff !important; } .t-interpolated { color: var(--ember) !important; } .t-synthetic { color: #f2a0c8 !important; }

.src-card { margin-top: 18px; padding: 18px; border: 1px solid var(--line-strong); border-top: 2px solid var(--c); border-radius: var(--radius); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 9%, transparent), transparent 140px); font-size: 13px; line-height: 1.55; animation: cardIn .35s ease; }
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } }
.src-card h3 { margin: 2px 0 4px; font-size: 19px; letter-spacing: -0.01em; }
.src-kicker { margin: 0; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.src-owner { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.src-facts { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; margin: 12px 0; font-size: 12px; }
.src-facts dt { color: var(--dim); }
.src-facts dd { margin: 0; }
.src-facts b { color: var(--ember-hot); }
.src-card code, .src-facts code { font-family: var(--mono); font-size: 11px; color: var(--ember-hot); word-break: break-all; }
.src-card a { color: var(--ember-hot); }
.src-req { margin: 0; padding: 10px; max-height: 150px; overflow: auto; white-space: pre-wrap; word-break: break-all; font: 10.5px/1.5 var(--mono); color: #d7cfc4; background: rgba(0,0,0,0.45); border: 1px solid var(--line); border-radius: 8px; }
.src-card .glabel { margin: 12px 0 6px; }
.src-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.src-actions .ghost.small { margin-top: 8px; text-decoration: none; font-size: 12px; }
.src-ping-out { min-height: 1em; margin: 8px 0 0; font-family: var(--mono); font-size: 11px; color: var(--ok); }
.src-ping-out.bad { color: var(--human); }
.funnel { margin: 10px 0 4px; display: grid; gap: 3px; }
.funnel div { position: relative; display: flex; justify-content: space-between; padding: 3px 8px; font-size: 11.5px; border-radius: 4px; overflow: hidden; }
.funnel div i { position: absolute; left: 0; top: 0; bottom: 0; z-index: -1; background: color-mix(in srgb, var(--c) 32%, transparent); }
.funnel div.cut { color: var(--muted); padding-left: 18px; }
.funnel div.cut i { background: rgba(255,90,54,0.35); }
.funnel b { font-family: var(--mono); font-weight: 600; }
.src-foot { margin-top: 16px; font-size: 11.5px; line-height: 1.5; }

@media (max-width: 900px) {
  .sources { grid-template-columns: 1fr; grid-template-rows: minmax(420px, 64vh) auto; overflow-y: auto; }
  .rings-head { padding: 18px 16px 0; }
  .rings-lede { display: none; }
  .rings-replay { left: 16px; bottom: 8px; }
  .src-panel { overflow: visible; border-left: 0; border-top: 1px solid var(--line); padding: 16px; backdrop-filter: none; background: rgba(12,13,19,0.92); }
  .src-close { position: fixed; top: 14px; right: 14px; z-index: 3; }
  .sources-btn { padding: 0 11px; }
}
@media (max-width: 1100px) { .sources-btn { font-size: 0; gap: 0; } .sources-btn i { margin: 0; } dialog .sources-btn { font-size: 13px; gap: 8px; } }
@media (prefers-reduced-motion: reduce) { .sources-btn i { animation: none; } .src-card { animation: none; } }

/* ---------- Search (src/search-mode.js) ---------- */
body.mode-search [data-show~="search"] { display: block; }
body.mode-search .timeline { transform: translateY(140%); opacity: 0; pointer-events: none; }
body.mode-search .panel { bottom: 16px; }
body.mode-search .panel.left { width: 300px; }
body.mode-search .panel.right { width: 360px; display: flex; flex-direction: column; overflow: hidden; }
body.mode-search .date-display { display: none; }
body.mode-search #stats > :not([data-show~="search"]) { display: none; }
body.mode-search #stats > .sx-results { display: flex; flex-direction: column; min-height: 0; flex: 1; }
body.mode-search .maplibregl-ctrl-bottom-right { bottom: 16px; right: 384px; }
#sx-zone-group[hidden], .sx-applied[hidden], .sx-examples[hidden] { display: none !important; }
.sx-top { border-top: 0; padding-top: 0; }

.sx-box { display: flex; align-items: center; gap: 10px; padding: 0 12px; height: 46px; border-radius: 12px; cursor: text;
  background: linear-gradient(rgba(14,15,22,0.9), rgba(14,15,22,0.9)) padding-box, linear-gradient(135deg, rgba(255,210,122,0.55), rgba(255,61,31,0.35)) border-box;
  border: 1px solid transparent; box-shadow: 0 0 30px -12px rgba(255,122,31,0.8); transition: box-shadow .25s; }
.sx-box:focus-within { box-shadow: 0 0 0 3px rgba(255,122,31,0.16), 0 0 36px -8px rgba(255,122,31,0.9); }
.sx-box svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--ember-hot); stroke-width: 2; stroke-linecap: round; filter: drop-shadow(0 0 4px rgba(255,140,40,0.8)); }
.sx-box input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); font: inherit; font-size: 15px; }
.sx-box input::placeholder { color: var(--dim); }
.sx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sx-chips:empty { display: none; }
.sx-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; font-size: 12px; color: var(--text);
  border: 1px solid rgba(255,122,31,0.45); background: rgba(255,122,31,0.12); animation: chipIn .35s cubic-bezier(.2,.8,.2,1); }
.sx-chip i { font-style: normal; width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.sx-chip:hover i { background: rgba(255,255,255,0.12); color: var(--text); }
.sx-chip.clear { border-color: var(--line-strong); background: transparent; color: var(--muted); padding-right: 10px; }
@keyframes chipIn { from { opacity: 0; transform: scale(0.85); } }
.sx-hint { margin: 8px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.sx-hint:empty { display: none; }
.sx-hint .warn { color: var(--lightning); }
.sx-hint kbd { font-size: 9px; }
.sx-examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
.sx-ex { border: 1px dashed var(--line-strong); background: transparent; border-radius: 8px; padding: 4px 8px; font-size: 12px; color: var(--muted); font-family: var(--mono); transition: color .2s, border-color .2s, background .2s; }
.sx-ex:hover { color: var(--ember-hot); border-color: rgba(255,122,31,0.5); background: rgba(255,122,31,0.06); }

.sx-cause-chips .chip small, #sx-zones .chip small { font-family: var(--mono); font-size: 10px; color: var(--dim); }
.chip.picked { box-shadow: inset 0 0 0 1px var(--c); }
.sx-months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; height: 64px; }
.sx-mbar { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; padding: 0; border: 0; background: transparent; border-radius: 4px; }
.sx-mbar .b { width: 100%; height: calc(var(--h) * 0.72); min-height: 2px; border-radius: 3px 3px 1px 1px; background: linear-gradient(0deg, rgba(255,61,31,0.45), rgba(255,170,70,0.85)); transition: height .5s cubic-bezier(.2,.8,.2,1), opacity .2s, filter .2s; }
.sx-mbar .l { font-family: var(--mono); font-size: 9px; color: var(--dim); }
.sx-mbar:hover .b { filter: brightness(1.3); }
.sx-mbar.off .b { opacity: 0.25; }
.sx-mbar.on .b { background: linear-gradient(0deg, #ff7a1f, #fff3d6); box-shadow: 0 0 10px rgba(255,160,60,0.8); }
.sx-mbar.on .l { color: var(--ember-hot); }
.sx-frows { display: flex; flex-direction: column; gap: 2px; }
.sx-frow { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 5px 8px 7px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12.5px; text-align: left; transition: background .2s, color .2s; }
.sx-frow:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.sx-frow .k b { display: inline-block; width: 16px; color: var(--text); font-family: var(--mono); font-weight: 600; }
.sx-frow .n { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.sx-frow i { position: absolute; left: 8px; bottom: 3px; height: 2px; width: calc((100% - 16px) * var(--w) / 100); border-radius: 2px; background: linear-gradient(90deg, var(--ember-deep), var(--ember-hot)); opacity: 0.5; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.sx-frow.off { opacity: 0.55; }
.sx-frow.on { background: linear-gradient(135deg, rgba(255,122,31,0.22), rgba(255,61,31,0.08)); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255,122,31,0.35); }
.sx-frow.on i { opacity: 1; box-shadow: 0 0 8px rgba(255,140,40,0.8); }
.sx-frow.on .n { color: var(--ember-hot); }
.sx-pair { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--dim); }
.sx-pair input { flex: 1; min-width: 0; background: rgba(255,255,255,0.04); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 12.5px; font-family: var(--mono); }
.sx-pair input:focus { outline: none; border-color: rgba(255,122,31,0.5); }
.sx-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ghost.small { padding: 5px 10px; font-size: 12px; }
.sx-tools .ghost.on { background: rgba(255,122,31,0.2); border-color: rgba(255,122,31,0.6); box-shadow: 0 0 14px -4px var(--ember); }

.sx-results .kpis { margin-bottom: 8px; }
.sx-sentence { margin: 0 0 6px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.sx-sentence b { color: var(--text); font-weight: 500; }
.sx-hist { display: flex; align-items: flex-end; gap: 1px; height: 64px; padding-bottom: 12px; cursor: crosshair; touch-action: none; user-select: none; }
.sx-hist .hb { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.sx-hist .hb i { display: block; width: 100%; height: var(--h); min-height: 1px; border-radius: 1px 1px 0 0; background: linear-gradient(0deg, rgba(255,61,31,0.5), rgba(255,170,70,0.85)); transition: height .5s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.sx-hist .hb:hover i { background: linear-gradient(0deg, #ff7a1f, #ffe0a0); }
.sx-hist .hb.off i { opacity: 0.2; }
.sx-hist .hb.on i { background: linear-gradient(0deg, #ff7a1f, #fff3d6); box-shadow: 0 0 6px rgba(255,160,60,0.7); }
.sx-hist .hb em { position: absolute; top: 100%; left: 0; margin-top: 2px; font-style: normal; font-family: var(--mono); font-size: 8px; color: var(--dim); }
.sx-hist-tip { margin: 2px 0 0; min-height: 14px; font-family: var(--mono); font-size: 10px; color: var(--ember-hot); }
.sx-link { background: none; border: 0; padding: 0; color: var(--ember-hot); font-size: 12px; text-decoration: underline; text-decoration-color: rgba(255,210,122,0.35); text-underline-offset: 3px; }
.sx-link:hover { text-decoration-color: var(--ember-hot); }
.sx-link[hidden] { display: none; }
.chart h3 small .sx-link { font-size: 10px; margin-left: 6px; }
.sx-list-head { display: flex; gap: 6px; align-items: center; padding: 10px 0 6px; border-top: 1px solid var(--line); }
.sx-list-head select { flex: 1; width: auto; }
.sx-dir { width: 32px; height: 32px; flex: none; font-size: 14px; }
.sx-list { flex: 1; min-height: 120px; overflow-y: auto; scrollbar-width: thin; margin: 0 -8px; padding: 0 8px; }
.sx-row { position: relative; display: flex; width: 100%; justify-content: space-between; gap: 10px; align-items: center; background: transparent; border: 0; border-radius: 8px; padding: 7px 8px 9px; text-align: left; color: var(--muted); font-size: 13px; transition: background .2s, color .2s; }
.sx-row:hover, .sx-row:focus-visible { background: rgba(255,255,255,0.05); color: var(--text); outline: none; }
.sx-row.on { background: linear-gradient(135deg, rgba(255,122,31,0.22), rgba(255,61,31,0.08)); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255,122,31,0.35); }
.sx-name { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; min-width: 0; color: var(--text); }
.sx-name .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px var(--c); flex: none; }
.sx-name small { flex-basis: 100%; padding-left: 13px; font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.sx-name .sp { font-style: normal; font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; padding: 0 5px; border-radius: 4px; background: rgba(255,210,122,0.15); color: var(--ember-hot); }
.sx-ha { flex: none; text-align: right; font-family: var(--mono); font-size: 12px; color: var(--ember-hot); }
.sx-ha small { display: block; font-size: 9.5px; color: var(--dim); }
.sx-row b { position: absolute; left: 8px; bottom: 3px; height: 2px; width: calc((100% - 16px) * var(--w) / 100); border-radius: 2px; background: linear-gradient(90deg, var(--c), transparent); opacity: 0.55; }
.sx-more, .sx-empty { margin: 10px 8px; }
.sx-empty { color: var(--muted); font-size: 13px; line-height: 1.5; }
.sx-actions { padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.sx-use { display: flex; gap: 8px; }
.sx-use .cta.small { padding: 8px 16px; }
.sx-export { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12px; }
.sx-applied { border-top-color: rgba(255,122,31,0.35); }
.sx-applied-q { margin: 0 0 8px; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.sx-applied-btns { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 900px) {
  body.mode-search .panel.left { top: 76px; bottom: auto; left: 16px; right: 16px; width: auto; max-height: 30vh; }
  body.mode-search .panel.right { display: flex; top: auto; bottom: 16px; left: 16px; right: 16px; width: auto; height: 42vh; }
  body.mode-search .maplibregl-ctrl-bottom-right { display: none; }
  .modes { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .modes::-webkit-scrollbar { display: none; }
  .modes button { flex: none; }
}
