/* Kalamidad -- self-hosted fonts */

@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;
}

/* =========================================================
   KALAMIDAD -- PH Disaster Tracker
   Zedlav "Console" / Royal palette. Every class name and every
   CSS custom property name matches the JS, so no JS edits are
   required. Only values, type, and geometry moved.

   Palette:  --bg #F5F4F0 chalk ground / #0B0B0E black leather
             --teal (retained alias) = Varsity Royal #1E5FC9
   Type:     Roboto (UI + headings) + JetBrains Mono (meta)
   Geometry: hard edges, --radius 0
   Color is reserved for severity DATA only. Chrome is
   royal / chalk / black and carries no severity hue.
   ========================================================= */

:root {
  /* ---- Zedlav Royal tokens (LIGHT default) ---- */
  --bg: #F5F4F0;
  --bg-1: #FFFFFF;
  --bg-2: #E9E7E1;
  --bg-3: #DFDCD4;
  --line: rgba(11,11,14,.13);
  --line-2: rgba(11,11,14,.22);
  --text: #0B0B0E;
  --text-2: #1A1A20;
  --muted: #6C6C78;
  --dim: #9A9AA4;

  /* the one accent. --teal is kept as an alias so no JS changes. */
  --royal: #1E5FC9;
  --royal-lt: #1746A0;
  --chalk: #0B0B0E;
  --teal: var(--royal);

  /* severity -- DATA ONLY, never chrome. tuned to read on chalk. */
  --sev-low:  #6C6C78;
  --sev-mod:  #1E5FC9;
  --sev-high: #B4790C;
  --sev-crit: #C8102E;
  --sev-low-bg:  rgba(108,108,120,.10);
  --sev-mod-bg:  rgba(30,95,201,.10);
  --sev-high-bg: rgba(180,121,12,.12);
  --sev-crit-bg: rgba(200,16,46,.10);

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sans: var(--serif);

  --radius: 0px;
  --panel-w: 440px;
  --header-h: 60px;
  --t: 180ms cubic-bezier(.2,.7,.2,1);
}

[data-theme="dark"] {
  --bg: #0B0B0E;
  --bg-1: #121216;
  --bg-2: #0E0E12;
  --bg-3: #17171C;
  --line: rgba(255,255,255,.09);
  --line-2: rgba(255,255,255,.18);
  --text: #FFFFFF;
  --text-2: #E4E4E8;
  --muted: #71717C;
  --dim: #4A4A55;

  --royal: #1E5FC9;
  --royal-lt: #6A9CF0;
  --chalk: #F6F4EF;
  --teal: var(--royal-lt);

  --sev-low:  #71717C;
  --sev-mod:  #6A9CF0;
  --sev-high: #E0A02A;
  --sev-crit: #FF5A64;
  --sev-low-bg:  rgba(113,113,124,.16);
  --sev-mod-bg:  rgba(106,156,240,.14);
  --sev-high-bg: rgba(224,160,42,.14);
  --sev-crit-bg: rgba(255,90,100,.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  transition: background var(--t), color var(--t);
}
::selection { background: var(--royal); color: #fff; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--royal-lt); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  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; }

.topbar {
  height: var(--header-h);
  flex: 0 0 var(--header-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px;
  background: var(--bg);
  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: 700;
  font-size: 15px;
  letter-spacing: .2em;
  color: var(--royal);
}
.logo .tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
a.logo:hover .mark { opacity: .85; }

.topbar-links { display: flex; gap: 4px; margin-left: 10px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em; }
.topbar-links a {
  padding: 8px 12px; color: var(--text-2);
  border: 1px solid transparent;
  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: 16px; 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: 7px; height: 7px; border-radius: 50%;
  background: var(--chalk);
  animation: blip 2.4s ease-out infinite;
}
@keyframes blip {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--chalk) 50%, transparent); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.updated { color: var(--muted); letter-spacing: .04em; }
.topbar-link { color: var(--muted); letter-spacing: .1em; text-transform: uppercase; font-size: 10px; }
.topbar-link:hover { color: var(--text); }
.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--t);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--bg-2); }
.topbar-sep { width: 1px; height: 22px; background: var(--line); }
.topbar-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 8px 13px;
  cursor: pointer;
  transition: all var(--t);
}
.topbar-btn:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
a.topbar-btn { display: inline-flex; align-items: center; }

/* ===================== 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 theming */
.leaflet-container { background: var(--bg-2); font-family: var(--mono); }
/* the basemap is desaturated so the only color on the map is severity */
.leaflet-tile-pane { filter: grayscale(1); }
.leaflet-control-zoom { border: 1px solid var(--line) !important; border-radius: 0 !important; overflow: hidden; box-shadow: none !important; }
.leaflet-control-zoom a {
  background: var(--bg-1) !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; }
.leaflet-control-attribution {
  background: color-mix(in oklab, var(--bg) 84%, transparent) !important;
  color: var(--muted) !important;
  font-family: var(--mono) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

/* ===================== FILTER CHIPS ===================== */
.filters {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 20;
  display: flex; gap: 7px; flex-wrap: wrap;
  max-width: calc(100% - 100px);
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip .ic { width: 14px; height: 14px; display: inline-flex; flex: 0 0 14px; }
.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: 9.5px; opacity: .62; }
.chip.on .ct { color: var(--bg); opacity: .62; }

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

/* ===================== 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: 16px 20px 14px; border-bottom: 1px solid var(--line); }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.panel-count {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--bg);
  background: var(--text);
  padding: 3px 10px;
}
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.src {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  padding: 4px 9px;
  border: 1px solid var(--line);
  color: var(--text-2);
  background: var(--bg-1);
  display: inline-flex; align-items: center; gap: 6px;
}
.src .tick { color: var(--chalk); font-weight: 700; }
.src.down { color: var(--muted); }
.src.down .tick { color: var(--sev-high); }

/* sort */
.sortbar {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.sortbar .seg { margin-left: auto; display: flex; border: 1px solid var(--line); }
.sortbar .seg button {
  background: transparent; border: 0;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .1em; 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; }

/* event list */
.events { flex: 1; overflow-y: auto; 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: 36px 1fr auto;
  gap: 14px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--sev-low);
  cursor: pointer;
  transition: background var(--t);
}
.event:hover { background: var(--bg-2); }
.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;
  flex: 0 0 36px;
}
.event .ico svg { width: 18px; height: 18px; }
.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: .13em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
.event .kicker .type { color: var(--text-2); }
.event .kicker .dot { color: var(--dim); }
.event .title {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: -.01em;
  color: var(--text);
  margin: 0 0 7px;
  text-wrap: pretty;
}
.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: 9px; text-align: right; }
.sev-badge {
  font-family: var(--mono);
  font-size: 9px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.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: 15px; font-weight: 600; 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 { display: none; }
.panel.detail-open .detail { display: flex; }

.detail-top { display: flex; align-items: center; justify-content: space-between; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.back-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--line);
  color: var(--text); font-family: var(--mono);
  font-size: 11px; letter-spacing: .06em;
  padding: 9px 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: .14em; text-transform: uppercase; color: var(--muted); }

.detail-scroll { flex: 1; overflow-y: auto; padding: 24px 20px 32px; 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: 15px; }
.detail-kicker .type-ic { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid currentColor; }
.detail-kicker .type-ic svg { width: 18px; height: 18px; }
.detail-kicker .type-label { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); }
.detail-title {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.14;
  letter-spacing: -.025em;
  color: var(--text);
  margin: 0 0 12px;
  text-wrap: pretty;
}
.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 0;
  padding: 17px 19px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-left: 2px solid currentColor;
}
.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: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 9px; }
.explainer .txt { font-family: var(--sans); font-size: 15px; line-height: 1.6; color: var(--text-2); text-wrap: pretty; }

.detail-section { margin-top: 26px; }
.detail-section h3 { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 400; }
.kv { display: flex; flex-direction: column; }
.kv .row { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); }
.kv .v .pill { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; padding: 2px 8px; border: 1px solid currentColor; }
.pill.green { background: var(--bg-2); color: var(--chalk); }
.pill.orange { background: var(--sev-high-bg); color: var(--sev-high); }
.pill.red { background: var(--sev-crit-bg); color: var(--sev-crit); }

.detail-actions { display: flex; gap: 9px; margin-top: 26px; }
.btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  min-height: 46px; padding: 0 14px; cursor: pointer;
  border: 1px solid var(--line-2); background: transparent; color: var(--text);
  transition: all var(--t);
}
.btn:hover { background: var(--bg-2); }
.btn.primary { background: var(--royal); border-color: var(--royal); color: #fff; }
.btn.primary:hover { background: transparent; color: var(--royal); }

.nearby { margin-top: 30px; }
.nearby-item { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; transition: background var(--t); }
.nearby-item:hover { background: var(--bg-2); }
.nearby-item .ni-ic { width: 22px; height: 22px; display: inline-flex; }
.nearby-item .ni-ic svg { width: 16px; height: 16px; }
.nearby-item .ni-title { font-family: var(--sans); font-size: 13.5px; color: var(--text); line-height: 1.25; }
.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 10px rgba(0,0,0,.35);
  position: relative;
}
.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; }
@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; }
}

.leaflet-popup-content-wrapper {
  background: var(--bg-1) !important; color: var(--text) !important;
  border: 1px solid var(--line-2) !important; border-radius: 0 !important;
  box-shadow: 0 18px 44px -20px rgba(0,0,0,.7) !important;
}
.leaflet-popup-tip { background: var(--bg-1) !important; border: 1px solid var(--line-2) !important; }
.leaflet-popup-content { margin: 12px 14px !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(--sans); font-size: 14px; margin: 5px 0; color: var(--text); }
.popup-link { color: var(--text); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; border-bottom: 1px solid var(--line-2); }

/* ===================== CALM STATE ===================== */
.calm { display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 60px 30px; height: 100%; }
.calm.show { display: flex; }
.calm .ring { width: 62px; height: 62px; border: 1px solid var(--text); display: flex; align-items: center; justify-content: center; color: var(--text); margin-bottom: 22px; }
.calm .ring svg { width: 26px; height: 26px; }
.calm h3 { font-family: var(--sans); font-weight: 700; font-size: 22px; letter-spacing: -.02em; margin: 0 0 10px; color: var(--text); }
.calm p { font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.75; max-width: 34ch; margin: 0; }

/* ===================== GEO SEARCH / PROXIMITY ===================== */
.geobar { margin-bottom: 0; }
.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);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 12px 40px 12px 34px;
  outline: none;
  transition: border-color var(--t), background var(--t);
}
.geo-search input:focus { border-color: var(--royal); }
.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;
  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(--royal); }

.gs-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  z-index: 30;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  box-shadow: 0 18px 50px -20px rgba(0,0,0,.45);
  max-height: 230px; 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; gap: 9px;
  padding: 10px 13px;
  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(--mono); font-size: 12.5px; color: var(--text); }
.gs-result .gr-region { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: .06em; }
.gs-empty { padding: 14px; font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: center; }

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

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

/* ===================== PANEL FOOTER (new) ===================== */
.panel-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 12px 20px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .1em;
  color: var(--muted);
  line-height: 1.8;
  text-transform: uppercase;
}

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

@media (max-width: 860px) {
  .body { display: block; position: relative; height: calc(100vh - var(--header-h)); overflow: hidden; }
  .map-wrap { position: absolute; inset: 0; flex: none; }

  .filters {
    top: 14px; left: 0; right: 0;
    max-width: none;
    padding: 0 14px 4px;
    gap: 8px;
    overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  }
  .filters::-webkit-scrollbar { display: none; }
  .chip { padding: 11px 14px; font-size: 12.5px; flex: 0 0 auto; min-height: 44px; }
  .chip .ic { width: 16px; height: 16px; flex: 0 0 16px; }

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

  .sheet-grab {
    display: block;
    flex: 0 0 auto;
    padding: 0 18px 12px;
    touch-action: none;
    cursor: grab;
    border-bottom: 1px solid var(--line);
  }
  .panel.snap-full .sheet-grab { cursor: default; }
  .sheet-handle { display: block; width: 40px; height: 3px; background: var(--line-2); 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: 12.5px; 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;
    font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
    padding: 0 14px; min-height: 44px; cursor: pointer; white-space: nowrap;
  }
  .peek-pill svg { width: 14px; height: 14px; }

  .panel-head { padding: 16px 18px 14px; }
  .sources { margin-top: 14px; }

  .event { grid-template-columns: 44px 1fr auto; gap: 14px; padding: 18px; min-height: 76px; }
  .event .ico { width: 42px; height: 42px; flex: 0 0 42px; }
  .event .ico svg { width: 21px; height: 21px; }
  .event .title { font-size: 17px; }
  .event .kicker { font-size: 10px; }
  .event .when { font-size: 11px; }
  .event .metric { font-size: 16px; }
  .sev-badge { font-size: 9.5px; padding: 4px 9px; }

  .detail-top { padding: 14px 18px; }
  .back-btn { padding: 0 15px; min-height: 44px; font-size: 12px; }
  .detail-scroll { padding: 22px 18px 28px; }
  .detail-title { font-size: 25px; }
  .explainer { padding: 16px 18px; }
  .explainer .txt { font-size: 15px; }
  .kv .row { grid-template-columns: 130px 1fr; font-size: 12.5px; padding: 12px 0; }
  .detail-actions { position: sticky; bottom: 0; background: var(--bg); padding: 14px 0 4px; margin-top: 24px; }
  .btn { min-height: 48px; font-size: 12px; }

  .mk::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; }

  .topbar { gap: 10px; padding: 0 14px; }
  .logo .tag { display: none; }
  .topbar-link { display: none; }
  .updated { display: none; }
  .topbar-sep { display: none; }
  .topbar-btn { padding: 8px 11px; }
  .topbar-links { margin-left: 8px; gap: 2px; }
  .topbar-links a { padding: 9px 10px; font-size: 11px; }
  .live { display: none; }

  .alert-banner { max-width: calc(100% - 28px); bottom: 144px; }
  .gs-results { max-height: 44vh; }
  .panel-foot { display: none; }
}

@media (max-width: 420px) {
  .kv .row { grid-template-columns: 116px 1fr; }
  .detail-actions { flex-direction: column; }
  .peek-pill span.lbl { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =========================================================
   Ported from original -- missing in designer delivery
   16 functional class families required by kalamidad-app.js
   that were absent from the designer's Royal-palette CSS.
   Numbers below map to the migration checklist.
   ========================================================= */

/* 4. accessibility: screen-reader-only text (used by h1) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 5. map recenter button (critical: kill path without it) */
.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); }

/* 15. rain radar toggle button */
.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; }

/* 3. scrollable panel wrapper (critical for desktop scroll) */
.panel-scroll { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--line-2); }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel.detail-open .panel-scroll { display: none; }

/* 13. affected areas section (detail view) */
.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); flex: 1; min-width: 0; }
.af-pop { color: var(--muted); font-size: 10px; white-space: nowrap; margin: 0 8px; }
.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; }

/* 7-10. source health pills */
.source-health { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 4px; }
.sh-pill {
  font-family: var(--mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 10px; border: 1px solid;
}
.sh-ok { color: #2e8b57; border-color: #2e8b5744; background: #2e8b5712; }
.sh-err { color: var(--sev-crit); border-color: color-mix(in oklab, var(--sev-crit) 25%, transparent); background: var(--sev-crit-bg); }

/* 2. marker clusters -- severity-aware, reuses .mk styling */
.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-badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
  line-height: 1;
}
/* 16. .cluster-mk has no dedicated rule in the original CSS either --
   it is a compound class (see kalamidad-app.js iconCreateFunction)
   that inherits .mk (already defined above) and pairs with
   .cluster-badge for the count. No block to port. */

/* 14. marker pulse on filter-chip selection */
.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; }
}

/* 1. custom tooltip for map markers */
.sak-tooltip {
  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;
  font-family: var(--mono) !important; padding: 10px 14px !important;
}
.sak-tooltip::before { border-top-color: var(--bg) !important; }

/* 11-12. 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; }

@media (max-width: 860px) {
  /* 6. mobile sheet collapse button */
  .sheet-collapse { display: none; }

  /* 3. panel-scroll mobile drag/scroll behavior */
  .panel-scroll {
    flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
    min-height: 0; overscroll-behavior: contain; touch-action: pan-y;
  }
  .panel.snap-peek .panel-scroll { touch-action: none; }
  .panel-scroll .events { overflow-y: visible; flex: none; contain: none; min-height: 0; padding-bottom: 140px; }
  .panel.detail-open .panel-scroll { display: none; }
  .sec-more { padding: 15px 18px; font-size: 12px; }
  .sec-head { padding: 14px 18px 8px; }
}

/* Ported: type-grouped section headers (missing from both designer + initial port) */
.sec-head {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 22px 8px;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.sec-head .sec-ic { width: 15px; height: 15px; display: inline-flex; color: var(--text-2); }
.sec-head .sec-ic svg { width: 100%; height: 100%; }
.sec-head .sec-label { color: var(--text-2); }
.sec-head .sec-count {
  margin-left: auto; color: var(--bg); background: var(--text);
  border-radius: var(--radius); padding: 2px 8px; font-size: 10px;
}
.sec-more {
  display: block; width: 100%; text-align: left;
  padding: 12px 22px; background: transparent;
  border: 0; border-bottom: 1px solid var(--line);
  color: var(--teal, #2dd4bf); font-family: var(--mono);
  font-size: 11px; letter-spacing: .04em; cursor: pointer;
  transition: background var(--t);
}
.sec-more:hover { background: var(--bg-2); }
