/* Sakuna v3 — self-hosted fonts */
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =========================================================
   SAKUNA — PH Disaster Tracker
   SAME DNA as tokita.online: identical tokens, light-default
   with dark toggle, Source Serif 4 + JetBrains Mono, 2px corners,
   pure-mono chrome. Color is reserved for severity DATA only.
   ========================================================= */

:root {
  --bg: #fafaf8;
  --bg-1: #f2f2ef;
  --bg-2: #ebebe7;
  --bg-3: #e2e2dd;
  --line: #d8d8d3;
  --line-2: #c4c4be;
  --text: #0a0a0a;
  --text-2: #2a2a2a;
  --muted: #6a6a6a;
  --dim: #a8a8a4;
  --teal: #15a88f;
  --sev-low:  #5b7a90;
  --sev-mod:  #b07d12;
  --sev-high: #c5571c;
  --sev-crit: #c8102e;
  --sev-low-bg:  #eef1f3;
  --sev-mod-bg:  #f5eedd;
  --sev-high-bg: #f6e7da;
  --sev-crit-bg: #f7e2e4;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --radius: 2px;
  --panel-w: 440px;
  --header-h: 60px;
  --t: 180ms cubic-bezier(.2,.7,.2,1);
  --maxw: 1280px;
  --read: 680px;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-1: #0f0f0f;
  --bg-2: #141414;
  --bg-3: #1a1a1a;
  --line: #222222;
  --line-2: #2e2e2e;
  --text: #ededed;
  --text-2: #b8b8b8;
  --muted: #7a7a7a;
  --dim: #4a4a4a;
  --teal: #1fd1b2;
  --sev-low:  #6b9ab5;
  --sev-mod:  #e8b53a;
  --sev-high: #ec7a2c;
  --sev-crit: #ff5a64;
  --sev-low-bg:  #14202a;
  --sev-mod-bg:  #261f0e;
  --sev-high-bg: #261707;
  --sev-crit-bg: #2a0f12;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t), color var(--t);
}
::selection { background: var(--text); color: var(--bg); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px;
}
.eyebrow::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--text);
  display: inline-block;
}

/* ===================== APP SHELL ===================== */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

.topbar {
  height: var(--header-h);
  flex: 0 0 var(--header-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px;
  background: color-mix(in oklab, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}
.logo { display: flex; align-items: baseline; gap: 11px; }
.logo .mark {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .24em;
  color: var(--teal);
}
.logo .tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
a.logo { text-decoration: none; }
a.logo:hover .mark { opacity: .85; }

.topbar-links { display: flex; gap: 4px; margin-left: 16px; font-family: var(--mono); font-size: 12px; }
.topbar-links a {
  padding: 8px 12px; color: var(--text-2);
  border: 1px solid transparent; border-radius: var(--radius);
  text-decoration: none; transition: all var(--t);
}
.topbar-links a:hover { color: var(--text); border-color: var(--line); }
.topbar-links a.active { color: var(--text); border-color: var(--line); background: var(--bg-2); }

.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 18px;
  font-family: var(--mono);
  font-size: 11px;
}
.live {
  display: inline-flex; align-items: center; gap: 8px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text);
}
.live .blip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal);
  animation: blip 2s ease-out infinite;
}
@keyframes blip {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--teal) 50%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.updated { color: var(--muted); letter-spacing: .04em; }
.topbar-link {
  color: var(--muted);
  text-decoration: none;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 10px;
  font-family: var(--mono);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.topbar-link:hover { color: var(--text); }
button.topbar-link { border: 1px solid var(--line); padding: 6px 12px; border-radius: var(--radius); }
button.topbar-link:hover { border-color: var(--text); color: var(--text); }
.topbar-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  padding: 6px 12px; border-radius: var(--radius); cursor: pointer;
  transition: all var(--t);
}
.topbar-btn:hover { border-color: var(--text); color: var(--text); }
.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  width: 34px; height: 34px;
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--bg-2); }
.rain-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .12em;
  padding: 7px 12px;
  cursor: pointer;
  transition: all var(--t);
}
.rain-btn:hover { color: var(--text); border-color: var(--line-2); }
.rain-btn.on { background: #2a7fff; border-color: #2a7fff; color: #fff; }
.topbar-sep { width: 1px; height: 22px; background: var(--line); }

/* ===================== BODY: MAP + PANEL ===================== */
.body { flex: 1; display: flex; min-height: 0; }
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--bg-2); }

.leaflet-container { background: var(--bg-2); font-family: var(--mono); }
.leaflet-control-zoom { border: 1px solid var(--line) !important; border-radius: var(--radius) !important; overflow: hidden; box-shadow: none !important; }
.leaflet-control-zoom a {
  background: var(--bg) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--line) !important;
  width: 30px !important; height: 30px !important; line-height: 30px !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-2) !important; color: var(--text) !important; }
.recenter-btn {
  position: absolute; top: 96px; left: 12px; z-index: 1000;
  width: 30px; height: 30px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.recenter-btn svg { width: 16px; height: 16px; }
.recenter-btn:hover { background: var(--bg-2); color: var(--text); }
.leaflet-control-attribution {
  background: color-mix(in oklab, var(--bg) 82%, transparent) !important;
  color: var(--dim) !important;
  font-family: var(--mono) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

/* ===================== FILTER CHIPS ===================== */
.filters {
  position: absolute;
  top: 16px; left: 16px;
  z-index: 20;
  display: flex; gap: 8px; flex-wrap: wrap;
  max-width: calc(100% - 92px);
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px 8px 10px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip .ic { width: 15px; height: 15px; display: inline-flex; color: var(--muted); }
.chip .ic svg { width: 100%; height: 100%; }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.on .ic { color: var(--bg); }
.chip .ct { font-size: 10px; color: var(--muted); }
.chip.on .ct { color: var(--bg); opacity: .7; }

/* ===================== CRITICAL ALERT BANNER ===================== */
.alert-banner {
  position: absolute;
  bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 25;
  display: none;
  align-items: center; gap: 14px;
  padding: 11px 18px;
  background: var(--sev-crit-bg);
  border: 1px solid var(--sev-crit);
  border-radius: var(--radius);
  box-shadow: 0 16px 50px -16px color-mix(in oklab, var(--sev-crit) 50%, transparent);
  cursor: pointer;
  max-width: 56%;
}
.alert-banner.show { display: flex; }
.alert-banner .pulse-ic { width: 18px; height: 18px; color: var(--sev-crit); flex: 0 0 18px; animation: pulse-fade 1.2s ease-in-out infinite; }
@keyframes pulse-fade { 50% { opacity: .35; } }
.alert-banner .txt { font-family: var(--serif); font-size: 14px; color: var(--text); }
.alert-banner .txt strong { font-family: var(--mono); font-size: 10px; color: var(--sev-crit); letter-spacing: .12em; text-transform: uppercase; margin-right: 10px; }
.alert-banner .go { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }

/* ===================== SIDE PANEL ===================== */
.panel {
  flex: 0 0 var(--panel-w);
  width: var(--panel-w);
  background: var(--bg);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; }
.panel-count {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--bg);
  background: var(--text);
  border-radius: var(--radius);
  padding: 3px 10px;
}
.sources { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.sources .chip { padding: 6px 11px 6px 8px; font-size: 11px; }
.sources .chip .ct { font-size: 9px; }

.sortbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.sortbar .seg { margin-left: auto; display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sortbar .seg button {
  background: transparent; border: 0;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  padding: 7px 12px; cursor: pointer;
  border-right: 1px solid var(--line);
  transition: all var(--t);
}
.sortbar .seg button:last-child { border-right: 0; }
.sortbar .seg button.on { background: var(--text); color: var(--bg); }
.sortbar .seg button:hover:not(.on):not(:disabled) { color: var(--text); background: var(--bg-2); }
.sortbar .seg button:disabled { color: var(--dim); cursor: not-allowed; }

.events { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; contain: paint; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.events::-webkit-scrollbar { width: 8px; }
.events::-webkit-scrollbar-thumb { background: var(--line-2); }
.events::-webkit-scrollbar-track { background: transparent; }

.event {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--sev-low);
  cursor: pointer;
  transition: background var(--t);
}
.event:hover { background: var(--bg-1); }
.event.sev-low { border-left-color: var(--sev-low); }
.event.sev-moderate { border-left-color: var(--sev-mod); }
.event.sev-high { border-left-color: var(--sev-high); }
.event.sev-critical { border-left-color: var(--sev-crit); }

.event .ico {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid currentColor;
}
.event .ico svg { width: 19px; height: 19px; }
.event.sev-low .ico { color: var(--sev-low); background: var(--sev-low-bg); }
.event.sev-moderate .ico { color: var(--sev-mod); background: var(--sev-mod-bg); }
.event.sev-high .ico { color: var(--sev-high); background: var(--sev-high-bg); }
.event.sev-critical .ico { color: var(--sev-crit); background: var(--sev-crit-bg); animation: pulse-fade 1.4s ease-in-out infinite; }

.event .ev-body { min-width: 0; }
.event .kicker {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono);
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.event .kicker .type { color: var(--text-2); }
.event .kicker .dot { color: var(--dim); }
.event .title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -.005em;
  color: var(--text);
  margin: 0 0 8px;
  text-wrap: balance;
}
.event .when { font-family: var(--mono); font-size: 10.5px; color: var(--muted); letter-spacing: .03em; }

.event .right { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 10px; text-align: right; }
.sev-badge {
  font-family: var(--mono);
  font-size: 9px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
}
.sev-badge.sev-low { color: var(--sev-low); background: var(--sev-low-bg); }
.sev-badge.sev-moderate { color: var(--sev-mod); background: var(--sev-mod-bg); }
.sev-badge.sev-high { color: var(--sev-high); background: var(--sev-high-bg); }
.sev-badge.sev-critical { color: var(--bg); background: var(--sev-crit); border-color: var(--sev-crit); }
.event .metric { font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--text); letter-spacing: .01em; }
.event .metric .u { font-size: 9px; color: var(--muted); font-weight: 400; }
.event .dist { font-family: var(--mono); font-size: 10px; color: var(--text-2); letter-spacing: .04em; }

/* ===================== DETAIL VIEW ===================== */
.detail { display: none; flex-direction: column; height: 100%; }
.panel.detail-open .events,
.panel.detail-open .sortbar,
.panel.detail-open .panel-head,
.panel.detail-open .calm,
.panel.detail-open .loading-state,
.panel.detail-open .error-state { display: none; }
.panel.detail-open .detail { display: flex; }

.detail-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.back-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text); font-family: var(--mono);
  font-size: 11px; letter-spacing: .04em;
  padding: 8px 13px; cursor: pointer;
  transition: all var(--t);
}
.back-btn:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.detail-src { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.detail-scroll { flex: 1; overflow-y: auto; padding: 26px 22px 30px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.detail-scroll::-webkit-scrollbar { width: 8px; }
.detail-scroll::-webkit-scrollbar-thumb { background: var(--line-2); }

.detail-kicker { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.detail-kicker .type-ic { width: 22px; height: 22px; display: inline-flex; }
.detail-kicker .type-label { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.detail-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: -.015em;
  color: var(--text);
  margin: 0 0 12px;
  text-wrap: balance;
}
.detail-time { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .03em; padding-bottom: 20px; border-bottom: 1px solid var(--line); }

.explainer {
  margin: 22px 0;
  padding: 18px 20px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-left: 2px solid currentColor;
  border-radius: var(--radius);
}
.explainer.sev-low { color: var(--sev-low); }
.explainer.sev-moderate { color: var(--sev-mod); }
.explainer.sev-high { color: var(--sev-high); }
.explainer.sev-critical { color: var(--sev-crit); }
.explainer .lbl { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 9px; }
.explainer .txt { font-family: var(--serif); font-size: 16px; line-height: 1.55; color: var(--text); }

.detail-section { margin-top: 26px; }
.detail-section h3 { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; font-weight: 400; }
.kv { display: flex; flex-direction: column; }
.kv .row { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 13px; }
.kv .row:first-child { border-top: 0; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); }
.kv .v .radius-note { font-size: 9px; color: var(--dim); letter-spacing: .08em; text-transform: uppercase; margin-left: 6px; }

/* affected areas list */
.affected h3 { display: flex; align-items: baseline; gap: 8px; }
.affected-list { display: flex; flex-direction: column; }
.affected-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px;
}
.affected-row:first-child { border-top: 0; }
.af-name { color: var(--text); }
.af-dist { color: var(--muted); font-size: 10px; letter-spacing: .04em; white-space: nowrap; }
.affected-none { font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 8px 0; }

.detail-actions { display: flex; gap: 10px; margin-top: 28px; }
.btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  padding: 13px 14px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--line-2); background: var(--bg-1); color: var(--text);
  text-decoration: none; transition: all var(--t);
}
.btn:hover { background: var(--bg-2); border-color: var(--muted); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.primary:hover { background: transparent; color: var(--text); }

.nearby { margin-top: 30px; }
.nearby-item { display: grid; grid-template-columns: 24px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.nearby-item:hover .ni-title { text-decoration: underline; text-underline-offset: 3px; }
.nearby-item .ni-ic { width: 22px; height: 22px; display: inline-flex; }
.nearby-item .ni-title { font-family: var(--serif); font-size: 14px; color: var(--text); line-height: 1.2; }
.nearby-item .ni-meta { font-family: var(--mono); font-size: 10px; color: var(--muted); text-align: right; white-space: nowrap; }

/* ===================== MAP MARKERS ===================== */
.mk {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid currentColor;
  background: var(--bg);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.mk svg { width: 16px; height: 16px; }
.mk.sev-low { color: var(--sev-low); }
.mk.sev-moderate { color: var(--sev-mod); }
.mk.sev-high { color: var(--sev-high); }
.mk.sev-critical {
  color: var(--sev-crit);
  animation: mk-pulse 1.5s ease-out infinite;
}
.mk.filter-pop {
  animation: filter-pop .6s ease-out;
}
@keyframes filter-pop {
  0%   { box-shadow: 0 2px 8px rgba(0,0,0,.25), 0 0 0 0 color-mix(in oklab, currentColor 70%, transparent); }
  40%  { box-shadow: 0 2px 8px rgba(0,0,0,.25), 0 0 0 10px color-mix(in oklab, currentColor 35%, transparent); }
  100% { box-shadow: 0 2px 8px rgba(0,0,0,.25), 0 0 0 0 transparent; }
}
@keyframes mk-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--sev-crit) 55%, transparent); }
  70% { box-shadow: 0 0 0 16px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* marker clusters — severity-aware */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: none !important; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: none !important; }
.cluster {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  border: 2px solid currentColor;
  background: var(--bg);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.cluster.sev-low { color: var(--sev-low); }
.cluster.sev-moderate { color: var(--sev-mod); }
.cluster.sev-high { color: var(--sev-high); }
.cluster.sev-critical { color: var(--sev-crit); animation: mk-pulse 1.5s ease-out infinite; }

.leaflet-popup-content-wrapper {
  background: var(--bg) !important; color: var(--text) !important;
  border: 1px solid var(--line-2) !important; border-radius: var(--radius) !important;
  box-shadow: 0 12px 40px -12px rgba(0,0,0,.4) !important;
}
.leaflet-popup-tip { background: var(--bg) !important; border: 1px solid var(--line-2) !important; }
.leaflet-popup-content { margin: 13px 15px !important; font-family: var(--mono) !important; }
.popup-type { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.popup-title { font-family: var(--serif); font-size: 15px; margin: 5px 0; color: var(--text); }

/* ===================== CALM STATE ===================== */
.calm { display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 28px; height: 100%; }
.calm.show { display: flex; }
.calm .ring { width: 64px; height: 64px; border-radius: 50%; border: 1.5px solid var(--text); display: flex; align-items: center; justify-content: center; color: var(--text); margin-bottom: 22px; }
.calm .ring svg { width: 28px; height: 28px; }
.calm h3 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0 0 10px; color: var(--text); }
.calm p { font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.7; max-width: 34ch; margin: 0; }

/* ===================== LOADING + ERROR STATES ===================== */
.loading-state, .error-state {
  display: none;
  padding: 48px 28px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.loading-state { display: block; }
.error-state h3 { font-family: var(--serif); font-weight: 400; font-size: 20px; color: var(--text); margin: 0 0 10px; }
.error-state p { margin: 0; }

/* ===================== GEO SEARCH / PROXIMITY ===================== */
.geobar { margin-bottom: 18px; }
.geo-search { position: relative; display: flex; align-items: center; gap: 8px; }
.geo-search .gs-ic { width: 15px; height: 15px; color: var(--muted); flex: 0 0 15px; position: absolute; left: 12px; pointer-events: none; }
.geo-search .gs-ic svg { width: 100%; height: 100%; }
.geo-search input {
  flex: 1; width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 11px 40px 11px 34px;
  outline: none;
  transition: border-color var(--t), background var(--t);
}
.geo-search input:focus { border-color: var(--text); background: var(--bg); }
.geo-search input::placeholder { color: var(--muted); }
.gps-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px;
  background: transparent; border: 0;
  color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  transition: color var(--t), background var(--t);
}
.gps-btn svg { width: 15px; height: 15px; }
.gps-btn:hover { color: var(--text); background: var(--bg-2); }
.gps-btn.active { color: var(--text); }

.gs-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  z-index: 30;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px -16px rgba(0,0,0,.35);
  max-height: 260px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.gs-results.show { display: block; }
.gs-results::-webkit-scrollbar { width: 8px; }
.gs-results::-webkit-scrollbar-thumb { background: var(--line-2); }
.gs-result {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t);
}
.gs-result:last-child { border-bottom: 0; }
.gs-result:hover, .gs-result.active { background: var(--bg-2); }
.gs-result .gr-name { font-family: var(--serif); font-size: 14px; color: var(--text); }
.gs-result .gr-region { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: .04em; }
.gs-empty { padding: 14px; font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: center; }

.proximity { display: none; margin-top: 12px; padding: 14px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); }
.proximity.show { display: block; }
.prox-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.prox-where {
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
  color: var(--text); display: inline-flex; align-items: center; gap: 7px;
}
.prox-where::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text); }
.prox-clear { background: transparent; border: 0; color: var(--muted); font-family: var(--mono); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
.prox-clear:hover { color: var(--sev-crit); }
.prox-row { display: flex; align-items: baseline; justify-content: space-between; font-family: var(--mono); margin-bottom: 9px; }
.prox-k { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.prox-v { font-size: 13px; color: var(--text); }
input[type="range"]#radius {
  -webkit-appearance: none; appearance: none;
  accent-color: var(--text);
  width: 100%; height: 2px; background: var(--line-2); border-radius: 2px; outline: none; margin: 2px 0 12px;
}
input[type="range"]#radius::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%; background: var(--text); cursor: pointer; border: 2px solid var(--bg-1);
}
input[type="range"]#radius::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--text); cursor: pointer; border: 2px solid var(--bg-1); }
.prox-readout { font-family: var(--mono); font-size: 11px; color: var(--text-2); letter-spacing: .02em; padding-top: 11px; border-top: 1px solid var(--line); }
.prox-readout strong { color: var(--text); }

.me-marker { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 3px solid var(--bg); box-shadow: 0 0 0 0 color-mix(in oklab, var(--text) 40%, transparent); animation: blip 2s ease-out infinite; }
.event.outside { opacity: .42; }


/* ===================== FOOTER ===================== */
.footer {
  padding: 12px 24px;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 20px;
}
.footer a { color: var(--teal); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* ===================== MOBILE ===================== */
.sheet-grab { display: none; }
.sheet-handle { display: none; }

@media (max-width: 860px) {
  /* full-height map; sheet floats over it */
  .body { display: block; position: relative; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); overflow: hidden; }
  .map-wrap { position: absolute; inset: 0; flex: none; isolation: isolate; }

  /* map-overlay filters hidden on mobile; panel has its own set */
  .map-wrap .filters { display: none; }
  .chip { padding: 10px 14px 10px 11px; font-size: 12.5px; flex: 0 0 auto; }
  .chip .ic { width: 16px; height: 16px; }

  /* the panel becomes a draggable bottom sheet */
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0;
    width: 100%; height: 88vh;
    border-left: 0;
    border-top: 1px solid var(--line-2);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -18px 50px -22px rgba(0,0,0,.4);
    z-index: 35;
    overflow: hidden;
    transform: translateY(calc(88vh - 132px));
    transition: transform .34s cubic-bezier(.32,.72,0,1);
  }
  .panel.dragging { transition: none; will-change: transform; }

  /* grabber: handle + peek summary */
  .sheet-grab {
    display: block;
    flex: 0 0 auto;
    padding: 0 18px 12px;
    touch-action: none;
    cursor: grab;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    border-radius: 18px 18px 0 0;
  }
  .panel.snap-full .sheet-grab { cursor: default; }
  .sheet-handle { display: block; width: 40px; height: 4px; background: var(--line-2); border-radius: 2px; margin: 10px auto 12px; }
  .sheet-peek { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
  .peek-summary {
    font-family: var(--mono); font-size: 13px; letter-spacing: .02em; color: var(--text);
    display: flex; align-items: center; gap: 8px;
  }
  .peek-summary .crit { color: var(--sev-crit); font-weight: 600; }
  .peek-summary .sep { color: var(--dim); }
  .peek-pill {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--text); color: var(--bg);
    border: 0; border-radius: var(--radius);
    font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
    padding: 10px 14px; cursor: pointer; white-space: nowrap;
  }
  .peek-pill svg { width: 14px; height: 14px; }

  /* head no longer carries the handle; tighten */
  .panel-head { padding: 16px 18px 14px; background: var(--bg); }
  .sources { margin-top: 14px; }

  /* bigger, breathing event cards + real touch targets */
  .event { grid-template-columns: 44px 1fr auto; gap: 14px; padding: 18px; min-height: 76px; }
  .event .ico { width: 42px; height: 42px; }
  .event .ico svg { width: 22px; height: 22px; }
  .event .title { font-size: 18px; margin-bottom: 7px; }
  .event .kicker { font-size: 10px; }
  .event .when { font-size: 11px; }
  .event .metric { font-size: 17px; }
  .sev-badge { font-size: 9.5px; padding: 4px 9px; }

  /* detail view spacing */
  .detail-top { padding: 14px 18px; }
  .back-btn { padding: 10px 15px; font-size: 12px; }
  .detail-scroll { padding: 22px 18px 28px; }
  .detail-title { font-size: 26px; }
  .explainer { padding: 16px 18px; }
  .explainer .txt { font-size: 15.5px; }
  .kv .row { grid-template-columns: 130px 1fr; font-size: 13px; padding: 12px 0; }
  .detail-actions { position: sticky; bottom: 0; background: var(--bg); padding: 14px 0 4px; margin-top: 24px; }
  .btn { padding: 15px 14px; font-size: 12px; }

  /* bigger marker touch targets (visual stays centered) */
  .mk::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; }

  /* topbar: fixed to device top so keyboard/autofill bar can't push it off */
  .topbar {
    gap: 10px; padding: 0 14px;
    position: fixed; top: 0; left: 0; right: 0;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    background: var(--bg);
  }
  .body { margin-top: var(--header-h); }
  .logo .tag { display: none; }
  .topbar-link { display: none; }
  .updated { display: none; }
  .topbar-btn { padding: 8px 11px; }
  .topbar-links { margin-left: 8px; gap: 2px; }
  .topbar-links a { padding: 7px 9px; font-size: 11px; }
  .live { display: none; }

  /* alert banner sits above the peek sheet */
  .alert-banner { max-width: calc(100% - 28px); bottom: 144px; }

  /* search results: cap height so keyboard doesn't bury them */
  .gs-results { max-height: 44vh; }

  .footer { flex-direction: column; gap: 4px; }
}

@media (max-width: 420px) {
  .kv .row { grid-template-columns: 124px 1fr; }
  .detail-actions { flex-direction: column; }
}

/* ===================== REDUCED MOTION ===================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
