/* ============================================================
   Triton Weather Radar — dark glass UI
   ============================================================ */

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

:root {
  --bg-0: #050505;
  --bg-1: #0d0d0d;
  --bg-2: #181818;

  --glass-bg: rgba(22, 22, 22, 0.6);
  --glass-bg-strong: rgba(18, 18, 18, 0.86);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-border-strong: rgba(255, 255, 255, 0.14);

  --text: #ececec;
  --text-dim: #9a9a9a;
  --text-muted: #5e5e5e;

  --accent: #ffb300;
  --accent-2: #ff8a00;
  --accent-glow: rgba(255, 179, 0, 0.4);
  --accent-grad: linear-gradient(135deg, #ffd54f 0%, #ff8a00 100%);

  --sev-extreme: #ff1744;
  --sev-severe: #ff6d00;
  --sev-moderate: #ffd600;
  --sev-minor: #00b0ff;
  --sev-unknown: #8e94a8;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.55);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display",
               system-ui, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-0);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }

/* Native dropdown items — Chromium honors these on Windows */
select option,
select optgroup {
  background-color: #161616;
  color: #ececec;
}
select option:checked,
select option:hover {
  background-color: #2a2a2a;
}

/* ============================================================
   GLASS UTILITY
   ============================================================ */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-md);
}

/* ============================================================
   MAP
   ============================================================ */
#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, #1a1a1a 0%, transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 110%, #0a0a0a 0%, transparent 60%),
    var(--bg-0);
}

.leaflet-container {
  background: transparent;
  font-family: inherit;
  outline: none;
}

.leaflet-control-attribution {
  background: rgba(18, 18, 18, 0.65) !important;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text-muted) !important;
  font-size: 10px !important;
  border-radius: 6px 0 0 0 !important;
  padding: 2px 6px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

.leaflet-control-zoom {
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius) !important;
  overflow: hidden;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  margin: 0 !important;
}
.leaflet-control-zoom a {
  background: var(--glass-bg) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--glass-border) !important;
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  font-size: 18px !important;
  font-weight: 300 !important;
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover {
  background: rgba(255, 179, 0, 0.15) !important;
  color: var(--accent) !important;
}
.leaflet-top.leaflet-left { display: none; } /* hide default zoom — we'll move it */
.leaflet-bottom.leaflet-right { z-index: 700; }

/* Make sure radar tiles render crisply on top of base map */
.leaflet-tile-pane { z-index: 100; }
.leaflet-overlay-pane { z-index: 400; }

/* Alert polygon glow + severity-tiered pulse (Extreme = fast, Severe = slow) */
.alert-polygon {
  filter: drop-shadow(0 0 4px currentColor);
  transform-box: fill-box;
  transform-origin: center;
}
.alert-polygon.severity-extreme {
  animation: alert-pulse-fast 1.1s ease-in-out infinite;
}
.alert-polygon.severity-severe {
  animation: alert-pulse-slow 2.4s ease-in-out infinite;
}
@keyframes alert-pulse-fast {
  0%, 100% { fill-opacity: 0.16; stroke-opacity: 1;   stroke-width: 2; }
  50%      { fill-opacity: 0.48; stroke-opacity: 0.55; stroke-width: 3.5; }
}
@keyframes alert-pulse-slow {
  0%, 100% { fill-opacity: 0.16; stroke-opacity: 0.95; }
  50%      { fill-opacity: 0.32; stroke-opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .alert-polygon { animation: none !important; }
}

/* ============================================================
   TOP BAR
   ============================================================ */
.top-bar {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 14px;
  border-radius: var(--radius);
  z-index: 1000;
  height: 54px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}
.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow), 0 0 4px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.78); }
}
.brand-name {
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 12px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.state-select {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 7px 28px 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%239ba3b8' d='M5 6L0 0h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  min-width: 0;
}
.state-select:focus { outline: none; border-color: var(--accent); }

.alert-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(255, 23, 68, 0.22), rgba(255, 109, 0, 0.22));
  border: 1px solid rgba(255, 109, 0, 0.4);
  min-width: 64px;
  height: 40px;
  transition: transform 0.15s, opacity 0.2s;
  flex-shrink: 0;
}
.alert-count:active { transform: scale(0.95); }
.alert-count.zero {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--glass-border);
}
.alert-count-num {
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
}
.alert-count-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  line-height: 1.2;
  margin-top: 2px;
}

/* ============================================================
   RIGHT RAIL (locate / layers)
   ============================================================ */
.rail {
  position: fixed;
  right: calc(12px + var(--safe-right));
  top: calc(82px + var(--safe-top));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 900;
}

.rail-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
  transition: transform 0.15s, color 0.2s, background 0.2s;
}
.rail-btn:hover, .rail-btn:active { color: var(--accent); transform: scale(0.96); }
.rail-btn.active { color: var(--accent); border-color: rgba(255, 179, 0, 0.4); }
.rail-btn svg { width: 20px; height: 20px; fill: currentColor; }
.rail-btn.hidden { display: none; }

/* ============================================================
   SEARCH PANEL + PIN
   ============================================================ */
.search-panel {
  position: fixed;
  right: calc(64px + var(--safe-right));
  top: calc(82px + var(--safe-top));
  width: 280px;
  padding: 10px;
  border-radius: var(--radius);
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.search-panel.open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
  pointer-events: none;
}
#search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 9px 32px 9px 32px;
  border-radius: 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
#search-input::placeholder { color: var(--text-muted); }
#search-input:focus { border-color: var(--accent); }

.search-clear {
  position: absolute;
  right: 6px;
  width: 22px;
  height: 22px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.search-clear:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.search-clear.hidden { display: none; }

.search-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
}
.search-results:empty { display: none; }
.search-result {
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid transparent;
}
.search-result:hover {
  background: rgba(255, 179, 0, 0.08);
  border-color: rgba(255, 179, 0, 0.3);
  color: var(--text);
}
.search-result-name {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 1px;
}
.search-result-context {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-empty {
  padding: 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

/* User location dot (blue, slow pulse) — drops when "Locate me" succeeds.
   Built so the dot stays visible even if a CSS regression hits the pulse. */
.user-location-dot {
  background: transparent;
  border: none;
  pointer-events: none;
}
.user-location-dot .ulp-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(33, 150, 243, 0.55);
  animation: user-loc-pulse 2.4s ease-out infinite;
  z-index: 1;
  transform-origin: center;
}
@keyframes user-loc-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  80%  { transform: scale(4.5); opacity: 0; }
  100% { transform: scale(4.5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .user-location-dot .ulp-pulse { animation: none; opacity: 0; }
}

/* Custom pin marker (Leaflet divIcon) */
.triton-pin {
  width: 32px !important;
  height: 40px !important;
  background: transparent;
  border: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}
.triton-pin svg {
  width: 32px;
  height: 40px;
  overflow: visible;
}
.pin-shape {
  fill: var(--accent);
  stroke: #1a1a1a;
  stroke-width: 1.5;
}
.pin-dot {
  fill: #1a1a1a;
}
.triton-pin::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 4px;
  background: radial-gradient(ellipse at center, rgba(255, 179, 0, 0.5) 0%, transparent 70%);
  animation: pin-pulse 1.6s ease-in-out infinite;
}
@keyframes pin-pulse {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.4; transform: translateX(-50%) scale(0.6); }
}

.pin-popup-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 4px;
}
.pin-popup-context {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  line-height: 1.4;
}
.pin-popup-coords {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.pin-remove {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(255, 23, 68, 0.15);
  border: 1px solid rgba(255, 23, 68, 0.4);
  color: #ff5577;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: background 0.15s;
}
.pin-remove:hover { background: rgba(255, 23, 68, 0.28); }

/* ============================================================
   LAYERS PANEL
   ============================================================ */
.layers-panel {
  position: fixed;
  right: calc(64px + var(--safe-right));
  top: calc(82px + var(--safe-top));
  width: 260px;
  padding: 12px 14px;
  border-radius: var(--radius);
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.layers-panel.open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.layers-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--glass-border);
}

.layers-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.layers-row.inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.layers-row label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}
.layers-row select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 6px 28px 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%239ba3b8' d='M5 6L0 0h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.layers-row select:focus { outline: none; border-color: var(--accent); }

.layers-value {
  position: absolute;
  right: 14px;
  font-size: 11px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.layers-row { position: relative; }

/* Switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  border: 1px solid var(--glass-border);
  transition: background 0.2s;
}
.switch-track::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch-track {
  background: linear-gradient(135deg, rgba(255, 179, 0, 0.35), rgba(255, 138, 0, 0.35));
  border-color: rgba(255, 179, 0, 0.5);
}
.switch input:checked + .switch-track::before {
  transform: translateX(16px);
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ============================================================
   RANGE INPUTS
   ============================================================ */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--fill, 0%), rgba(255,255,255,0.1) var(--fill, 0%), rgba(255,255,255,0.1) 100%);
  border-radius: 2px;
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff 0%, #ffe5b3 100%);
  border: 2px solid var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  cursor: pointer;
  margin-top: 0;
}
input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  cursor: pointer;
}

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
  position: fixed;
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  bottom: calc(76px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  border-radius: var(--radius);
  z-index: 999;
  height: 56px;
}

.timeline-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-grad);
  color: white;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(255, 179, 0, 0.35);
  transition: transform 0.12s;
}
.timeline-btn:active { transform: scale(0.92); }
.timeline-btn svg { width: 18px; height: 18px; fill: currentColor; }
.icon-pause { display: none; }
.timeline.playing .icon-play { display: none; }
.timeline.playing .icon-pause { display: block; }

.timeline-meta {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 60px;
}
.timeline-time {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent-glow);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.timeline-time.future {
  color: var(--sev-moderate);
  text-shadow: 0 0 8px rgba(255, 214, 0, 0.4);
}
.timeline-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-top: 1px;
}

#frame-scrub { flex: 1; min-width: 40px; }

.timeline-speed {
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 2px;
  flex-shrink: 0;
}
.speed-btn {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  border-radius: 6px;
  transition: all 0.15s;
  font-variant-numeric: tabular-nums;
}
.speed-btn.active {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 0 8px rgba(255, 179, 0, 0.3);
}

/* ============================================================
   ALERT SHEET (mobile bottom sheet)
   ============================================================ */
.alert-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  height: 64px;
  transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  padding-bottom: var(--safe-bottom);
}
.alert-sheet.expanded {
  height: 78vh;
}

.sheet-handle {
  flex-shrink: 0;
  padding: 6px 16px 4px;
  cursor: pointer;
  user-select: none;
}
.sheet-handle-bar {
  width: 38px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
  margin: 0 auto 6px;
  opacity: 0.5;
}
.sheet-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  padding: 0 2px;
}
.sheet-close {
  width: 30px;
  height: 30px;
  font-size: 24px;
  line-height: 1;
  color: var(--text-dim);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.sheet-close:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.alert-sheet.expanded .sheet-close { display: flex; }

.sheet-filters {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 10px 14px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  opacity: 0;
  transition: opacity 0.2s 0.1s;
  pointer-events: none;
}
.sheet-filters::-webkit-scrollbar { display: none; }
.alert-sheet.expanded .sheet-filters { opacity: 1; pointer-events: auto; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.18s;
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active {
  background: linear-gradient(135deg, rgba(255, 179, 0, 0.2), rgba(255, 138, 0, 0.2));
  border-color: rgba(255, 179, 0, 0.5);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(255, 179, 0, 0.18);
}
.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 4px currentColor;
}

.sheet-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s 0.15s;
}
.alert-sheet.expanded .sheet-list { opacity: 1; }

.sheet-list::-webkit-scrollbar { width: 4px; }
.sheet-list::-webkit-scrollbar-thumb { background: var(--glass-border-strong); border-radius: 2px; }

.alert-card {
  position: relative;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 18px;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
  overflow: hidden;
}
.alert-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--card-color, var(--sev-minor));
  box-shadow: 0 0 14px var(--card-color, rgba(0,176,255,0.4));
}
.alert-card:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  transform: translateX(2px);
  border-color: var(--glass-border-strong);
}
.alert-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.alert-card-event {
  font-weight: 700;
  font-size: 13px;
  color: var(--card-color, var(--text));
  text-shadow: 0 0 8px color-mix(in srgb, var(--card-color, transparent) 40%, transparent);
}
.alert-card-severity {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--card-color, var(--text-dim));
  flex-shrink: 0;
}
.alert-card-headline {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.alert-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.alert-card-area {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--text-dim);
}
.alert-card-no-geom {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.05);
  font-size: 9px;
  color: var(--text-muted);
  font-style: italic;
}

.sheet-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.sheet-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.4;
}

/* ============================================================
   LOADER
   ============================================================ */
.loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.loader.show { opacity: 1; }
.loader-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 179, 0, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: 13px; color: var(--text-dim); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  top: calc(80px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  padding: 10px 16px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 3000;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  max-width: 88%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { border-color: rgba(255, 23, 68, 0.5); }

/* ============================================================
   LEAFLET POPUP
   ============================================================ */
.leaflet-popup-content-wrapper {
  background: var(--glass-bg-strong) !important;
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border-strong) !important;
  border-radius: var(--radius) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 4px;
}
.leaflet-popup-content {
  margin: 12px 14px !important;
  font-family: inherit;
  line-height: 1.45;
  min-width: 220px;
  max-width: 300px;
}
.leaflet-popup-tip {
  background: var(--glass-bg-strong) !important;
  border: 1px solid var(--glass-border-strong) !important;
}
.leaflet-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 22px !important;
  padding: 8px !important;
  width: 32px !important;
  height: 32px !important;
}
.leaflet-popup-close-button:hover { color: var(--text) !important; }

.popup-event {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--popup-color, var(--text));
  text-shadow: 0 0 8px color-mix(in srgb, var(--popup-color, transparent) 30%, transparent);
}
.popup-severity {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: var(--popup-color, var(--text-dim));
  margin-bottom: 8px;
}
.popup-headline {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  line-height: 1.45;
}
.popup-meta {
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--glass-border);
  padding-top: 8px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.popup-meta strong { color: var(--text-dim); font-weight: 600; }

/* ============================================================
   DESKTOP / TABLET (≥768px)
   ============================================================ */
@media (min-width: 768px) {
  .top-bar {
    left: calc(16px + var(--safe-left));
    right: auto;
    width: 360px;
  }
  .rail {
    right: calc(16px + var(--safe-right));
    top: calc(82px + var(--safe-top));
  }
  .layers-panel {
    right: calc(68px + var(--safe-right));
  }
  .timeline {
    left: calc(16px + var(--safe-left));
    right: calc(360px + var(--safe-right));
    bottom: calc(16px + var(--safe-bottom));
  }
  .alert-sheet {
    top: calc(82px + var(--safe-top));
    right: calc(16px + var(--safe-right));
    bottom: calc(16px + var(--safe-bottom));
    left: auto;
    width: 332px;
    border-radius: var(--radius-lg);
    height: auto !important;
    border: 1px solid var(--glass-border);
    padding-bottom: 0;
  }
  .alert-sheet .sheet-handle-bar { display: none; }
  .alert-sheet .sheet-close { display: none !important; }
  .alert-sheet .sheet-handle { padding-top: 14px; cursor: default; }
  .alert-sheet .sheet-filters { opacity: 1; pointer-events: auto; }
  .alert-sheet .sheet-list { opacity: 1; }
  .leaflet-bottom.leaflet-right { display: none; } /* attribution placement on desktop */
}

/* Wider screens — keep timeline from getting absurdly long */
@media (min-width: 1400px) {
  .timeline { right: calc(360px + var(--safe-right)); max-width: none; }
}
