:root {
  --bg: #0b0f16;
  --panel: #121a26;
  --panel2: #182335;
  --border: #22304a;
  --text: #e8eef7;
  --muted: #8ea2bf;
  --accent: #ffd23f;
  --warn: #ff5a4e;
  --advisory: #ff9f43;
  --watch: #ffd23f;
  --ok: #3ddc84;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 15, 22, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.bolt { font-size: 26px; }
h1 { font-size: 17px; letter-spacing: 2px; font-weight: 800; }
h1 .az { color: var(--accent); }
.sub { font-size: 12px; color: var(--muted); }

.livedot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted);
}
.livedot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.livedot.err { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px 30px; }

section { margin-bottom: 22px; }

h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 8px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
}

.card.muted { color: var(--muted); }

.banner { border-color: var(--accent); background: #1c1f14; }
.hidden { display: none !important; }

.haboob {
  border-color: #e07b39;
  border-width: 2px;
  background: #241407;
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.haboob .big { font-weight: 800; font-size: 16px; letter-spacing: 0.5px; }

/* Map */
#mapShell {
  position: relative;
}
#map {
  height: 440px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b0f16;
  z-index: 0;
  position: relative;
}
.map-fs-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 500;
  padding: 7px 11px;
  font-size: 12px;
  background: rgba(18, 26, 38, 0.92);
  border-color: var(--border);
}
#mapShell.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 0;
}
#mapShell.fullscreen #map {
  flex: 1;
  height: auto !important;
  min-height: 0;
  border-radius: 0;
  border: none;
}
#mapShell.fullscreen .playback {
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  flex: none;
}
#mapShell.fullscreen .map-fs-btn {
  top: 12px;
  right: 12px;
}
body.map-fs-open { overflow: hidden; }
.leaflet-container { background: #0b0f16; font: inherit; }
/* Keep radar visible while scrubbing: stacked layers crossfade, no blank flash */
.radar-fade { transition: opacity 0.32s ease; }
.radar-fade.radar-instant { transition: none !important; }
/* Transparent placeholder while a radar tile loads — avoids black rectangles */
.leaflet-tile-container img.leaflet-tile { background: transparent; }
/* Layers / filter under zoom + scroll-zoom on the left (avoids nav overlap on mobile) */
.leaflet-top.leaflet-left .leaflet-control-layers {
  margin-top: 6px;
}
/* All left-rail control buttons the same 30px square — Leaflet's layers
   ("filters") toggle defaults to 36px (44px on touch), which made it look
   bigger than zoom / scroll / location. */
.leaflet-control-layers-toggle,
.leaflet-touch .leaflet-control-layers-toggle,
.leaflet-retina .leaflet-control-layers-toggle {
  width: 30px;
  height: 30px;
  background-size: 20px 20px;
}
.leaflet-control-scrollzoom a,
.leaflet-control-mylocation a {
  width: 30px;
  height: 30px;
  line-height: 30px;
  display: block;
  text-align: center;
  font-size: 15px;
  text-decoration: none;
  color: #333;
  background: #fff;
}
.leaflet-control-scrollzoom a.off { opacity: 0.45; }
.leaflet-control-scrollzoom a.on { opacity: 1; box-shadow: inset 0 0 0 2px #2a6fd6; }
.leaflet-control-mylocation a.active { box-shadow: inset 0 0 0 2px #2a6fd6; }
.myloc-dot {
  background: transparent;
  border: none;
}
.myloc-dot span {
  display: block;
  width: 14px;
  height: 14px;
  margin: 3px;
  border-radius: 50%;
  background: #2a6fd6;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(42, 111, 214, 0.35);
}
.arc-selected {
  filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 8px currentColor);
}
.critrow {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  margin: 6px 0;
  cursor: pointer;
}
.critrow input { margin-top: 2px; }
.storm-list-item .storm-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.storm-list-item .storm-num { font-weight: 800; color: var(--accent); }
.storm-list-item .storm-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}
.storm-list-item .storm-meta { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.storm-list-item .storm-actions { margin-top: 8px; }
.storm-list-item a.maplink {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.storm-list-item a.maplink:hover { text-decoration: underline; }
.storm-timeline {
  list-style: none;
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.storm-timeline li {
  font-size: 12px;
  color: #c9d6e8;
  line-height: 1.4;
  padding-left: 12px;
  position: relative;
}
.storm-timeline li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.storm-timeline .tl-time {
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
}
.storm-sort { margin-bottom: 10px; }
.popup-morelink {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}
.citylabel {
  background: transparent;
  border: none;
  box-shadow: none;
  color: #cfd9e8;
  font-size: 10px;
  font-weight: 600;
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
}
/* no tooltip tip-arrows between a dot/wind-arrow and its label */
.citylabel::before, .windlabel::before { display: none; }
.leaflet-popup-content .dim { color: #a8b8cc; font-weight: 400; font-size: 12px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #0e1520;
  color: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}
.leaflet-popup-content {
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
}
.popup-eli5 {
  margin-top: 10px;
  padding: 10px 11px;
  background: #162033;
  border: 1px solid #2a3d5c;
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.55;
  font-weight: 500;
}
.popup-eli5 .popup-eli5-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #9eb4d0;
  margin-bottom: 4px;
  font-weight: 700;
}
.trackmark {
  background: transparent;
  border: none;
  font-size: 18px;
  text-shadow: 0 1px 4px #000;
}
.cellmark { font-size: 20px; }

/* Radar playback bar */
.playback {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 12px;
}
.playbtn { padding: 6px 12px; font-size: 14px; line-height: 1; }
.playspeeds { display: flex; gap: 3px; flex: none; }
.speedbtn {
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}
.speedbtn.active { background: var(--panel2); color: var(--text); border-color: var(--accent); }
.playback input[type='range'] { flex: 1; accent-color: var(--accent); min-width: 0; }
.playtime {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
  min-width: 64px;
  text-align: right;
}
.playtime.live { color: var(--ok); }
.leaflet-control-mylocation a.locating {
  opacity: 0.55;
  animation: myloc-pulse 0.9s ease-in-out infinite;
}
@keyframes myloc-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
.trackarrow, .windarrow {
  background: transparent !important;
  border: none !important;
  font-size: 15px;
  text-shadow: 0 1px 3px #000;
  /* Do NOT set position here — Leaflet markers must stay position:absolute */
  overflow: visible !important;
}
.leaflet-marker-icon.windarrow,
.leaflet-div-icon.windarrow,
.leaflet-marker-icon.trackarrow {
  position: absolute !important; /* defend against any relative rules */
  overflow: visible !important;
  background: transparent !important;
  border: none !important;
}
.wind-icon-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 3px;
  width: max-content;
  height: 100%;
  overflow: visible;
  pointer-events: auto;
}
.wind-arrow-stack {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: visible;
}
.wind-orient {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transform-origin: center center;
  overflow: visible;
}
.wind-mover {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Drift along local +X (parent .wind-orient is already rotated downwind) */
  animation: wind-drift var(--wdur, 2s) linear infinite;
  will-change: transform;
  overflow: visible;
}
.wind-glyph {
  display: inline-block;
  transform-origin: center center;
  filter: drop-shadow(0 0 1px #000) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.85));
}
.wind-glyph-approx {
  /* Full color + dark outline so arrows read on green/yellow radar */
  -webkit-text-stroke: 1.25px #0b0f16;
  paint-order: stroke fill;
  filter: drop-shadow(0 0 1px #000) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.95));
}
/* One-way downwind drift — no opacity keyframes (those hid every arrow) */
@keyframes wind-drift {
  0% {
    transform: translateX(calc(var(--wamp, 8px) * -0.15));
  }
  100% {
    transform: translateX(var(--wamp, 8px));
  }
}
.wind-mph {
  flex: 0 0 auto;
  white-space: nowrap;
  line-height: 1;
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
  pointer-events: none; /* clicks hit the marker/arrow, not orphaned labels */
}
.wind-mph-obs {
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.wind-mph-approx {
  color: #ffffff;
  opacity: 1;
  font-size: 9px;
  font-weight: 700;
  -webkit-text-stroke: 0.6px #0b0f16;
  paint-order: stroke fill;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}
/* Hide approx mph when zoomed out (class toggled on #map) */
.wind-labels-hidden .wind-mph-approx {
  display: none !important;
}
/* Legacy tooltip classes (storm tracks etc. still use windlabel for city-adjacent) */
.windlabel {
  background: transparent;
  border: none;
  box-shadow: none;
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
}

/* Section collapse toggles */
.section-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  padding: 6px 8px;
  margin: 0 0 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.section-toggle-btn:hover { background: var(--panel2); color: var(--text); }
.section-toggle-btn .carrot { font-size: 11px; width: 14px; text-align: center; }
.section-collapsed-btn {
  background: #1e3a5f !important;
  border-color: #3d9be9 !important;
  color: #d6e8ff !important;
  box-shadow: 0 0 0 1px rgba(61, 155, 233, 0.35);
}
.section-collapsed-btn:hover {
  background: #254a75 !important;
  color: #fff !important;
}
.section-body { min-height: 0; }

/* Storm reasoning Technical / ELI5 */
.reason-block {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel2);
}
.reason-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 7px 10px;
  cursor: pointer;
  text-align: left;
}
.reason-toggle .carrot { font-size: 10px; width: 12px; }
.reason-updated {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--muted);
  white-space: nowrap;
}
.popup-eli5 .popup-updated {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: #8ea2bf;
}
.reason-body {
  padding: 0 10px 9px;
  font-size: 12px;
  line-height: 1.5;
  color: #c9d6e8;
}
.reason-block.collapsed .reason-body { display: none; }
.reason-collapsed-btn {
  background: #1e3a5f !important;
  color: #d6e8ff !important;
}
.signal-actions { display: inline-flex; gap: 4px; flex: none; }

/* Metro Sentinel */
.sentinel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.level-pill {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 5px 12px;
  border-radius: 999px;
  color: #10151d;
}
.level-pill.lvl0 { background: var(--ok); }
.level-pill.lvl1 { background: var(--watch); }
.level-pill.lvl2 { background: var(--advisory); }
.level-pill.lvl3 { background: var(--warn); color: #fff; }
.sentinel-summary { font-size: 14px; line-height: 1.5; }
.signals { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.signals li {
  font-size: 13px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
.signals li.signalrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.signalrow .mapbtn { flex: none; font-size: 14px; }

/* Engine section */
.engine ol { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.engine li { font-size: 13px; line-height: 1.55; color: #c9d6e8; }
.engine .sub { margin-top: 12px; line-height: 1.5; }
.engine code {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}
.flow { font-size: 13px; line-height: 1.7; color: #c9d6e8; }
.credit { margin-top: 12px; }
.credit a, .flow a { color: var(--accent); }

/* Impact list */
.impact-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.impact-city { font-weight: 700; font-size: 15px; }
.impact-eta { font-weight: 700; color: var(--accent); white-space: nowrap; }
.impact-eta.now { color: var(--warn); }
.impact-what { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Alerts */
.alerts { display: flex; flex-direction: column; gap: 10px; }

.alert {
  border-left: 4px solid var(--advisory);
  cursor: pointer;
}
.alert.severe { border-left-color: var(--warn); }
.alert.watch { border-left-color: var(--watch); }
.alert.dust { border-left-color: #e07b39; }
.alert.custom { border-left-color: #7cc4ff; }
.headright { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.hidebtn, .mapbtn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
}
.hidebtn:hover, .mapbtn:hover { color: var(--text); }
.hiddenbar { cursor: pointer; padding: 6px 2px; text-decoration: underline; }
.citylabel.hitlabel { color: var(--accent); font-weight: 800; font-size: 11px; }

.alert .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.alert .event { font-weight: 700; font-size: 15px; flex: 1; }
.source-pill {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--border);
}
.source-pill.nws { color: #8ea2bf; background: rgba(142, 162, 191, 0.12); }
.source-pill.engine { color: #7cc4ff; background: rgba(124, 196, 255, 0.12); border-color: #7cc4ff; }
.alert .until { font-size: 12px; color: var(--muted); white-space: nowrap; }
.alert .area { font-size: 13px; color: var(--muted); margin-top: 2px; }
.alert .track { font-size: 13px; color: var(--accent); margin-top: 4px; font-weight: 600; }
.alert .details { display: none; margin-top: 8px; font-size: 13px; white-space: pre-wrap; color: #c9d6e8; }
.alert.open .details { display: block; }

/* Notifications */
.notifrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pushstate { font-weight: 600; }
.btncol { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #14202e; border-color: var(--accent); }
.btn:active { transform: scale(0.97); }

/* Notification scope picker */
#notifScope { margin-top: 10px; }
.scopetabs { margin-top: 8px; }
.countychips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.countychips .tab { padding: 5px 10px; font-size: 12px; }
.ziprow { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.ziprow input {
  flex: 1;
  min-width: 120px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
}
#scopeStatus { margin-top: 8px; }

.keyrow { margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.keyrow input {
  flex: 1;
  min-width: 160px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}
.keyrow .sub { flex-basis: 100%; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--panel2); color: var(--text); border-color: var(--accent); }

.viewer {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #000;
  display: block;
  min-height: 180px;
}

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* Links */
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.link { text-decoration: none; color: var(--text); font-weight: 600; }
.link span { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.link:active { background: var(--panel2); }

footer { margin-top: 26px; display: flex; flex-direction: column; gap: 4px; }
.enginestatus { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.enginestatus .livedot { width: 8px; height: 8px; flex: none; }

/* Section nav: wrapping button rows (no horizontal scrollbar) */
html { scroll-behavior: smooth; }
section, #map-section { scroll-margin-top: 72px; }
#siteNav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 14px 4px;
}
#siteNav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  min-height: 38px;
}
#siteNav a:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--panel2);
}
#siteNav a:active { color: var(--text); border-color: var(--accent); }
#siteNav.side {
  position: fixed; right: 8px; top: 92px; z-index: 40;
  flex-direction: column; flex-wrap: nowrap; gap: 2px; padding: 8px 5px; max-width: none;
  background: rgba(18, 26, 38, 0.94); border: 1px solid var(--border);
  border-radius: 14px; backdrop-filter: blur(8px); margin: 0;
}
#siteNav.side a {
  background: none; border: none; padding: 4px 6px; font-size: 17px; min-height: 0;
  justify-content: center;
}
#siteNav.side .nl { display: none; }
#siteNav.side a:hover { background: var(--panel2); border-radius: 8px; }
