:root {
  --bg:        #0e1419;
  --panel:     #161d26;
  --panel-2:   #1c2530;
  --border:    #25313f;
  --text:      #e6edf3;
  --muted:     #8b98a8;
  --accent:    #38bdf8;   /* radar cyan */
  --accent-dim:#0b3a4a;

  --overlay-bg: rgba(22, 29, 38, 0.92);  /* floating map panels */
  --attr-bg:    rgba(14, 20, 25, 0.78);
  --map-bg:     #0a0f14;

  /* Severity colors carry meaning, matched to NWS conventions. */
  --sev-extreme: #ef4444;  /* tornado / extreme */
  --sev-severe:  #f97316;  /* severe thunderstorm */
  --sev-moderate:#eab308;  /* watches / moderate */
  --sev-minor:   #3b82f6;  /* advisories / minor */

  --radius: 10px;
  --gap: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

[data-theme="light"] {
  --bg:        #eef2f7;
  --panel:     #ffffff;
  --panel-2:   #f5f8fc;
  --border:    #d6dee8;
  --text:      #0f1722;
  --muted:     #5a6675;
  --accent:    #0284c7;
  --accent-dim:#bae6fd;

  --overlay-bg: rgba(255, 255, 255, 0.94);
  --attr-bg:    rgba(255, 255, 255, 0.85);
  --map-bg:     #dde5ee;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px var(--gap);
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand h1 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { margin: 1px 0 0; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }

.actions { display: flex; align-items: center; gap: 8px; }

/* Signature element: a slow radar sweep mark. */
.sweep {
  width: 34px; height: 34px; border-radius: 50%;
  background:
    radial-gradient(circle, var(--accent-dim) 0 1px, transparent 2px),
    conic-gradient(from 0deg, transparent 0 300deg, var(--accent) 360deg);
  border: 1px solid var(--border);
  position: relative;
  animation: sweep 4s linear infinite;
}
.sweep::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.25);
}
@keyframes sweep { to { transform: rotate(360deg); } }

.search { display: flex; align-items: center; gap: 8px; }
.search input[type="text"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 0.85rem;
  width: 240px;
  font-family: var(--font);
}
.search input::placeholder { color: var(--muted); }
.search button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 13px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.search button:hover { border-color: var(--accent); }
#searchBtn { background: var(--accent); color: #04222e; border-color: var(--accent); font-weight: 600; }
#searchBtn:hover { filter: brightness(1.08); }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }

.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--map-bg); }

/* Leaflet theme tweaks */
.leaflet-container { background: var(--map-bg); font-family: var(--font); }
.leaflet-control-attribution {
  background: var(--attr-bg) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-bar a { background: var(--panel); color: var(--text); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--panel-2); }

.map-controls {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 500;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 0.8rem;
}
.ctl { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ctl-slider { flex-direction: column; align-items: stretch; gap: 4px; }
.ctl-slider span { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.ctl input[type="range"] { accent-color: var(--accent); }
.ctl input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

.live-badge {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 500;
  display: flex; align-items: center; gap: 7px;
  background: var(--overlay-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* Layer picker + control buttons */
.ctl-select { flex-direction: column; align-items: stretch; gap: 4px; }.ctl-select span { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
#radarType {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 0.82rem;
  font-family: var(--font);
  cursor: pointer;
}

/* Mobile-only toggle that opens the floating layer panel. */
.controls-toggle {
  display: none;
  position: absolute;
  top: 12px; left: 12px;
  z-index: 600;
  background: var(--overlay-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.on { border-color: var(--accent); color: var(--accent); }

/* Radar loop timeline bar */
.radar-loop {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 600; display: flex; align-items: center; gap: 11px;
  background: var(--overlay-bg); border: 1px solid var(--border);
  border-radius: 22px; padding: 7px 15px; backdrop-filter: blur(6px);
  width: min(460px, calc(100% - 24px));
}
.radar-loop[hidden] { display: none; }
.loop-play {
  background: var(--accent); color: #04222e; border: none; border-radius: 50%;
  width: 30px; height: 30px; flex-shrink: 0; cursor: pointer; font-size: 0.72rem;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
#loopSlider { flex: 1; accent-color: var(--accent); }
.loop-time { font-family: var(--mono); font-size: 0.74rem; color: var(--text); white-space: nowrap; min-width: 66px; text-align: right; }

/* Storm indicator toggles */
.ctl-storm { flex-direction: column; align-items: stretch; gap: 5px; }
.ctl-storm > span { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.storm-toggles { display: flex; flex-wrap: wrap; gap: 5px; }
.stoggle {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  border-radius: 14px; padding: 3px 9px; font-size: 0.72rem; cursor: pointer;
  opacity: 0.55; transition: opacity 0.12s, border-color 0.12s;
}
.stoggle.on { opacity: 1; color: var(--text); border-color: var(--accent); }

/* Storm map markers + motion arrows */
.storm-icon span { font-size: 20px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); cursor: pointer; }
.storm-bolt span { font-size: 15px; line-height: 1; filter: drop-shadow(0 0 2px rgba(0,0,0,0.7)); cursor: pointer; }
.storm-arrow span { display: inline-block; font-size: 16px; line-height: 1; font-weight: 700; }
.leaflet-tooltip.storm-tip {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; max-width: 240px; white-space: normal; box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.leaflet-tooltip.storm-tip::before { display: none; }
.st-title { font-weight: 600; font-size: 0.82rem; margin-bottom: 3px; }
.st-row { font-size: 0.76rem; }
.st-motion { color: var(--accent); font-family: var(--mono); margin-top: 2px; }
.st-area { color: var(--muted); font-size: 0.68rem; margin-top: 4px; }

/* SPC outlook control + legend */
.ctl-spc { flex-direction: column; align-items: stretch; gap: 6px; }
.spc-head { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.spc-day {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 7px; font: inherit; font-size: 0.8rem; width: 100%;
}
.spc-day:disabled { opacity: 0.45; cursor: not-allowed; }

.spc-legend {
  position: absolute; top: 12px; right: 12px; z-index: 600;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 11px; max-width: 210px; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.spc-legend-head { font-size: 0.74rem; font-weight: 600; margin-bottom: 6px; }
.spc-legend-items { display: flex; flex-direction: column; gap: 4px; }
.spc-legend-row { display: flex; align-items: center; gap: 7px; font-size: 0.74rem; }
.spc-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.35); flex: none; }
.spc-valid { color: var(--muted); font-size: 0.66rem; margin-top: 7px; font-family: var(--mono); }
.spc-empty { color: var(--muted); font-size: 0.74rem; }
@media (max-width: 600px) {
  .spc-legend { top: 8px; right: 8px; max-width: 160px; padding: 7px 9px; }
}

/* 90-day outlook */
.wide-btn { width: 100%; padding: 9px; }
.outlook-body { display: flex; flex-direction: column; gap: 10px; }
.outlook-summary { font-size: 0.82rem; line-height: 1.45; }
.outlook-summary .warm { color: #f59e0b; font-weight: 600; }
.outlook-summary .cool { color: #38bdf8; font-weight: 600; }
.outlook-chart { width: 100%; height: auto; display: block; }
.outlook-chart .grid { stroke: var(--border); stroke-width: 1; }
.outlook-chart .axis-label { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.outlook-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.74rem; color: var(--muted); }
.outlook-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg-swatch { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.outlook-note { color: var(--muted); font-size: 0.68rem; line-height: 1.4; }
.outlook-err { color: var(--muted); font-size: 0.78rem; }

/* 90-day forecast list inside the lightbox (room for icons) */
.olx-legend { color: var(--muted); font-size: 0.78rem; line-height: 1.6; margin: 4px 0 12px; }
.olx-legend .warm { color: #f59e0b; font-weight: 700; }
.olx-legend .cool { color: #38bdf8; font-weight: 700; }
.olx-legend .neutral { color: var(--muted); font-weight: 700; }
.olx-head, .olx-row {
  display: grid; grid-template-columns: 30px 1.4fr 1.1fr 1.1fr 0.8fr; gap: 8px; align-items: center;
}
.olx-head {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  padding: 0 4px 6px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel-2);
}
.olx-list { max-height: 60vh; overflow-y: auto; }
.olx-row { padding: 7px 4px; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
.olx-row:last-child { border-bottom: none; }
.olx-icon { font-size: 13px; text-align: center; line-height: 1; letter-spacing: -1px; font-weight: 700; }
.olx-icon.warm { color: #f59e0b; }
.olx-icon.cool { color: #38bdf8; }
.olx-icon.neutral { color: var(--muted); }
.olx-icon.na { color: var(--border); }
.olx-date { color: var(--text); }
.olx-fc { font-variant-numeric: tabular-nums; }
.olx-norm { color: var(--muted); font-variant-numeric: tabular-nums; }
.olx-na { color: var(--muted); font-size: 0.78rem; }
.olx-anom { font-family: var(--mono); font-size: 0.84rem; text-align: right; }
.olx-anom.warm { color: #f59e0b; }
.olx-anom.cool { color: #38bdf8; }

/* This day in history */
.hist-intro { color: var(--muted); font-size: 0.82rem; margin: 4px 0 12px; }
.hist-controls { display: flex; gap: 8px; margin-bottom: 14px; }
.hist-controls input[type="date"] {
  flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 9px; font: inherit; color-scheme: dark;
}
[data-theme="light"] .hist-controls input[type="date"] { color-scheme: light; }
.hist-results { min-height: 40px; }
.hist-empty { color: var(--muted); font-size: 0.85rem; padding: 6px 0; }
.hist-cond { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.hist-cond-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.hist-narrative { font-size: 0.86rem; line-height: 1.5; margin: 0 0 12px; color: var(--text); }
.hist-glyph { font-size: 34px; line-height: 1; }
.hist-temps { font-size: 1.5rem; font-weight: 700; }
.hist-temps .lo { color: var(--muted); font-weight: 500; }
.hist-label { color: var(--muted); font-size: 0.82rem; }
.hist-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.hist-stat { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 5px 0; border-top: 1px solid var(--border); }
.hist-stat span { color: var(--muted); }
.hist-h3 { font-size: 0.92rem; margin: 4px 0 8px; }
.hist-warn { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.hist-warn:last-of-type { border-bottom: none; }
.hist-warn-icon { font-size: 20px; line-height: 1; }
.hist-warn-name { font-weight: 600; font-size: 0.88rem; }
.hist-warn-time { color: var(--muted); font-size: 0.76rem; font-family: var(--mono); }
.live-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 360px;
  flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.loc-head h2 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.loc-sub { margin: 3px 0 0; color: var(--muted); font-size: 0.8rem; font-family: var(--mono); }

/* ---------- Nowcast banner ---------- */
.nowcast {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 0.86rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nowcast[hidden] { display: none; }
.nowcast.clear { background: var(--panel-2); color: var(--muted); }
.nowcast.rain  { background: var(--accent-dim); color: var(--text); border-color: var(--accent); }
.nowcast.storm { background: #4a1d1d; color: #ffe2e2; border-color: var(--sev-extreme); }
.nowcast-note { font-size: 0.66rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.nowcast.storm .nowcast-note { color: #e7a3a3; }

.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h3 { margin: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.count { font-family: var(--mono); font-size: 0.85rem; font-weight: 600; }
.note { font-size: 0.7rem; color: var(--muted); font-family: var(--mono); }

.empty { color: var(--muted); font-size: 0.85rem; margin: 4px 0; }

/* ---------- Alerts ---------- */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert {
  border-left: 4px solid var(--sev-minor);
  background: var(--panel);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}
.alert:hover { background: #202b38; }
.alert.sev-extreme  { border-left-color: var(--sev-extreme); }
.alert.sev-severe   { border-left-color: var(--sev-severe); }
.alert.sev-moderate { border-left-color: var(--sev-moderate); }
.alert.sev-minor    { border-left-color: var(--sev-minor); }

.alert-title { font-weight: 600; font-size: 0.9rem; display: flex; justify-content: space-between; gap: 8px; }
.alert-tag {
  font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; white-space: nowrap; align-self: flex-start;
  color: #04222e;
}
.alert.sev-extreme  .alert-tag { background: var(--sev-extreme); }
.alert.sev-severe   .alert-tag { background: var(--sev-severe); }
.alert.sev-moderate .alert-tag { background: var(--sev-moderate); }
.alert.sev-minor    .alert-tag { background: var(--sev-minor); }

.alert-meta { color: var(--muted); font-size: 0.74rem; margin-top: 4px; font-family: var(--mono); }
.alert-body { margin-top: 8px; font-size: 0.8rem; line-height: 1.45; color: #cdd7e1; display: none; white-space: pre-wrap; }
.alert.open .alert-body { display: block; }

.all-clear {
  display: flex; align-items: center; gap: 9px;
  color: #7ee0a0; font-size: 0.88rem; font-weight: 500;
}
.all-clear::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #34d399; }

/* ---------- Forecast ---------- */
.forecast-list { display: flex; flex-direction: column; }
.fc-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
}
.fc-row:last-child { border-bottom: none; }
.fc-icon { width: 40px; height: 40px; border-radius: 7px; object-fit: cover; background: var(--panel); }
.fc-when { font-weight: 600; font-size: 0.85rem; }
.fc-desc { color: var(--muted); font-size: 0.76rem; margin-top: 1px; line-height: 1.3; }
.fc-temp { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; text-align: right; }
.fc-pop { font-size: 0.68rem; color: var(--accent); font-family: var(--mono); text-align: right; }

.extend-hint {
  font-size: 0.72rem; color: var(--muted); line-height: 1.5;
  margin: 0; padding: 0 2px;
}

/* ---------- 10-day outlook ---------- */
.extended-list { display: flex; flex-direction: column; }
.ext-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
}
.ext-row:last-child { border-bottom: none; }
.ext-emoji { font-size: 1.25rem; text-align: center; line-height: 1; }
.ext-day { font-weight: 600; font-size: 0.85rem; }
.ext-sub { color: var(--muted); font-size: 0.7rem; font-family: var(--mono); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 9px; align-items: center; }
.ext-sun { white-space: nowrap; }
.ext-pop { color: var(--accent); }
.ext-temp { font-family: var(--mono); font-size: 0.95rem; font-weight: 600; text-align: right; white-space: nowrap; }
.ext-temp .lo { color: var(--muted); }

.uv-badge {
  font-family: var(--mono); font-size: 0.62rem; font-weight: 600;
  padding: 1px 6px; border-radius: 4px; color: #04121e; white-space: nowrap;
}
.uv-low      { background: #4ade80; }
.uv-moderate { background: #facc15; }
.uv-high     { background: #fb923c; }
.uv-veryhigh { background: #f87171; }
.uv-extreme  { background: #c084fc; }

/* ---------- Voice controls ---------- */
.voice-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.mini-btn {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 5px 12px; font-size: 0.76rem; font-weight: 500; cursor: pointer;
}
.mini-btn:hover { border-color: var(--accent); }

/* ---------- Lightbox ---------- */
body.lb-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(3, 7, 12, 0.66); backdrop-filter: blur(2px); }
.lb-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lb-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--muted);
  font-size: 1.7rem; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.lb-close:hover { color: var(--text); background: var(--panel-2); }

.lb-head { display: flex; gap: 14px; align-items: center; padding-right: 28px; }
.lb-icon { width: 64px; height: 64px; border-radius: 10px; flex-shrink: 0; object-fit: cover; background: var(--panel-2); }
.lb-head h2 { margin: 0; font-size: 1.3rem; }
.lb-sub { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.lb-temp { margin: 4px 0 0; font-family: var(--mono); font-size: 0.92rem; }

.lb-precip {
  margin: 14px 0; padding: 10px 12px; border-radius: 9px;
  background: var(--accent-dim); color: var(--text); font-size: 0.86rem; font-weight: 500;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
}
.lb-precip.storm { background: #4a1d1d; }
.lb-precip.clear { background: var(--panel-2); color: var(--muted); }
.lb-note { font-size: 0.68rem; color: var(--muted); font-weight: 400; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; }
.stat-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat-value { font-size: 0.98rem; font-weight: 600; margin-top: 3px; }
.stat-extra { font-size: 0.7rem; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

.lb-section { margin-top: 16px; }
.lb-section h3 { margin: 0 0 7px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.lb-narrative { margin: 0; font-size: 0.88rem; line-height: 1.5; }

.lb-alert {
  display: flex; flex-direction: column; gap: 1px;
  border-left: 4px solid var(--sev-minor); background: var(--panel-2);
  border-radius: 7px; padding: 8px 11px; margin-bottom: 6px; font-size: 0.84rem;
}
.lb-alert span { color: var(--muted); font-size: 0.74rem; }
.lb-alert.sev-extreme  { border-left-color: var(--sev-extreme); }
.lb-alert.sev-severe   { border-left-color: var(--sev-severe); }
.lb-alert.sev-moderate { border-left-color: var(--sev-moderate); }
.lb-alert.sev-minor    { border-left-color: var(--sev-minor); }

.hr-list { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.hr-row {
  display: grid; grid-template-columns: 52px 22px 40px 42px auto auto 1fr;
  align-items: center; gap: 6px; padding: 6px 2px; font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.hr-row:last-child { border-bottom: none; }
.hr-time { font-family: var(--mono); color: var(--muted); }
.hr-emoji { text-align: center; }
.hr-temp { font-family: var(--mono); font-weight: 600; }
.hr-pop { font-family: var(--mono); color: var(--accent); font-size: 0.74rem; }
.hr-dew { color: var(--muted); font-size: 0.72rem; }
.hr-uv { color: var(--muted); font-size: 0.72rem; font-family: var(--mono); }
.hr-wind { font-family: var(--mono); color: var(--muted); font-size: 0.72rem; text-align: right; }

/* AQI badges */
.aqi-badge { font-family: var(--mono); font-size: 0.62rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; color: #04121e; }
.aqi-good  { background: #4ade80; }
.aqi-mod   { background: #facc15; }
.aqi-usg   { background: #fb923c; }
.aqi-unh   { background: #f87171; }
.aqi-vunh  { background: #c084fc; }
.aqi-haz   { background: #b45309; color: #fff; }
.aqi-na    { background: var(--border); color: var(--muted); }

.fc-row { cursor: pointer; }
.fc-row:hover { background: var(--panel-2); border-radius: 7px; }

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .hr-row { grid-template-columns: 52px 22px 40px 40px auto; }
  .hr-dew, .hr-uv { display: none; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 16px; border-radius: 8px;
  font-size: 0.82rem; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Map popups ---------- */
.leaflet-popup-content-wrapper {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
}
.leaflet-popup-tip { background: var(--panel-2); border: 1px solid var(--border); }
.popup-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 3px; }
.popup-meta { color: var(--muted); font-size: 0.74rem; font-family: var(--mono); }

/* ---------- Responsive ---------- */

/* Tablet and down: stack the map over the sidebar, let the page scroll. */
@media (max-width: 820px) {
  body { height: auto; min-height: 100vh; overflow: auto; }
  .layout { flex-direction: column; flex: none; }
  .map-wrap { height: 58vh; min-height: 340px; flex: none; }
  .sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); overflow: visible; }
}

/* Phone: compact header, collapsible controls, finger-sized targets. */
@media (max-width: 600px) {
  .topbar { padding: 10px 12px; }
  .brand-sub { display: none; }
  .brand h1 { font-size: 1rem; }

  /* Search drops to its own full-width row beneath brand + actions. */
  .search { order: 3; flex: 1 0 100%; }
  .search input[type="text"] { width: 100%; flex: 1; min-height: 44px; }
  .search button { min-height: 44px; }

  /* Icon-only action buttons. */
  .icon-btn .label { display: none; }
  .icon-btn {
    padding: 0; width: 44px; height: 44px; font-size: 1.1rem;
    display: inline-flex; align-items: center; justify-content: center;
  }

  /* Map controls collapse behind the toggle button. */
  .controls-toggle { display: block; }
  .map-controls { display: none; top: 60px; }
  .map-controls.open { display: flex; }
  #radarType { min-height: 42px; }
  .ctl input[type="checkbox"] { width: 20px; height: 20px; }
  .ctl { min-height: 28px; }

  .map-wrap { height: 56vh; min-height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  .sweep, .live-badge .dot { animation: none; }
  .toast { transition: none; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- TV-style warning crawl ---- */
.warn-crawl {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1400; height: 40px;
  display: flex; align-items: center; gap: 0; overflow: hidden;
  background: #b91c1c; color: #fff; box-shadow: 0 -2px 10px rgba(0,0,0,0.4);
  font-family: var(--mono);
}
.warn-crawl[hidden] { display: none; }
.warn-crawl.sev-extreme { background: #7f1d1d; }
.warn-crawl.sev-severe { background: #b91c1c; }
.warn-crawl.sev-moderate { background: #c2410c; }
.warn-crawl.is-test { background: #1d4ed8; }
.warn-crawl-label {
  flex: none; align-self: stretch; display: flex; align-items: center; padding: 0 12px;
  background: rgba(0,0,0,0.28); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.warn-crawl-viewport { flex: 1; overflow: hidden; white-space: nowrap; }
.warn-crawl-track {
  display: inline-block; white-space: nowrap;
  font-size: 0.86rem; will-change: transform;
  animation: crawl linear infinite;
}
.warn-crawl-close {
  flex: none; background: transparent; border: none; color: #fff; font-size: 1.3rem;
  cursor: pointer; padding: 0 12px; align-self: stretch; opacity: 0.8;
}
.warn-crawl-close:hover { opacity: 1; }
@keyframes crawl { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .warn-crawl-track { animation: none; white-space: nowrap; overflow-x: auto; }
}

/* ---- Live storm coverage (corner) ---- */
.live-launcher {
  position: fixed; left: 12px; bottom: 12px; z-index: 1450;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 13px; font: inherit; font-size: 0.8rem; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.live-launcher:hover { border-color: var(--accent); }
body.crawl-on .live-launcher, body.crawl-on .live-pip { bottom: 50px; }
.live-pip {
  position: fixed; left: 12px; bottom: 12px; z-index: 1500; width: 340px; max-width: calc(100vw - 24px);
  background: #000; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}
.live-pip[hidden] { display: none; }
.live-pip-head { display: flex; align-items: center; gap: 6px; padding: 6px; background: var(--panel-2); }
.live-tabs { display: flex; gap: 4px; flex: 1; }
.live-tab {
  background: var(--panel); color: var(--muted); border: 1px solid var(--border);
  border-radius: 13px; padding: 3px 10px; font-size: 0.74rem; cursor: pointer;
}
.live-tab.on { color: var(--text); border-color: var(--accent); }
.live-open, .live-close {
  flex: none; background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 1.05rem; text-decoration: none; padding: 2px 6px; line-height: 1;
}
.live-open:hover, .live-close:hover { color: var(--text); }
.live-pip-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.live-pip-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.live-pip-note { margin: 0; padding: 6px 8px; font-size: 0.66rem; color: var(--muted); background: var(--panel-2); line-height: 1.35; }
@media (max-width: 600px) { .live-pip { width: calc(100vw - 24px); } }

/* Hazardous Weather Outlook */
.hwo-meta { color: var(--muted); font-size: 0.8rem; margin: 2px 0 10px; }
.hwo-text {
  white-space: pre-wrap; word-wrap: break-word; font-family: var(--mono); font-size: 0.78rem;
  line-height: 1.5; color: var(--text); background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; max-height: 58vh; overflow-y: auto; margin: 0 0 10px;
}
