:root {
  --bg: #0d1218;
  --panel: #161d26;
  --panel-2: #1f2833;
  --panel-3: #26313e;
  --text: #eaf0f6;
  --muted: #93a1b0;
  --faint: #5f6d7c;
  --accent: #ff6b35;
  --accent-soft: rgba(255, 107, 53, 0.14);
  --good: #3fd06c;
  --danger: #ff5a5f;
  --danger-soft: rgba(255, 90, 95, 0.16);
  --warn: #ffd166;
  --warn-soft: rgba(255, 209, 102, 0.12);
  --border: #2a3644;
  --border-soft: #222d39;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); }

/* ==== App shell ===================================================== */
/* Mobile-first: sticky header, map, then a naturally scrolling panel.  */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 1200; /* above Leaflet controls (1000) */
  background: linear-gradient(180deg, rgba(22, 29, 38, 0.98), rgba(22, 29, 38, 0.92));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
  padding: 12px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#topbar h1 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.1rem;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.help-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.help-link:hover { color: var(--text); border-color: var(--accent); }

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.live-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--good);
  background: rgba(63, 208, 108, 0.1);
  border: 1px solid rgba(63, 208, 108, 0.35);
  border-radius: 999px;
  padding: 4px 10px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 208, 108, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(63, 208, 108, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 208, 108, 0); }
}

#map {
  height: 46vh;
  min-height: 300px;
  flex: none;
  background: #0a0e13;
  scroll-margin-top: 64px; /* keep popups clear of the sticky topbar */
}

#panel {
  flex: 1;
  background: var(--panel);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ==== Desktop: sidebar + full-height map ============================ */
@media (min-width: 900px) {
  #app {
    display: grid;
    grid-template-columns: 400px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "topbar map"
      "panel  map";
    height: 100dvh;
  }
  #topbar { grid-area: topbar; position: static; border-right: 1px solid var(--border-soft); }
  #panel {
    grid-area: panel;
    overflow-y: auto;
    border-right: 1px solid var(--border-soft);
  }
  #map { grid-area: map; height: 100%; min-height: 0; }
}

/* ==== Stat tiles (hero numbers) ===================================== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px 18px 4px;
}

.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  animation: stat-in 0.45s cubic-bezier(0.22, 0.9, 0.35, 1) backwards;
}

/* Staggered entrance, left to right, once per page load. */
.stat:nth-child(1) { animation-delay: 0.05s; }
.stat:nth-child(2) { animation-delay: 0.13s; }
.stat:nth-child(3) { animation-delay: 0.21s; }
.stat:nth-child(4) { animation-delay: 0.29s; }

@keyframes stat-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Active-fires tile: rustic burnt-orange — layered like weathered clay.
   An ember glow from the top corner, a faint diagonal grain for texture,
   over a terracotta-to-char gradient. Number in warm cream. */
.stat-fire {
  background:
    radial-gradient(130% 95% at 12% -5%, rgba(255, 159, 28, 0.22), transparent 55%),
    repeating-linear-gradient(115deg, rgba(255, 226, 178, 0.035) 0 2px, rgba(0, 0, 0, 0) 2px 6px),
    linear-gradient(160deg, #8a4118 0%, #5f2c10 62%, #46200c 100%);
  border-color: rgba(205, 112, 46, 0.55);
}

.stat-fire .stat-value {
  color: #ffddab;
  text-shadow: 0 1px 8px rgba(232, 108, 22, 0.4);
}

.stat-fire .stat-label { color: #dfa878; }

.stat-value {
  display: block;
  font-size: 1.55rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.stat-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-top: 3px;
}

.ytd-line {
  margin: 8px 18px 0;
  font-size: 0.75rem;
  color: var(--faint);
}

/* ==== Air-quality chips ============================================= */
.aqi-section { padding: 14px 0 0; }

.section-title {
  margin: 0 18px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
}

.section-sub { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--faint); }

.aqi-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 18px 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.aqi-chip {
  flex: none;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
}

.aqi-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--aqi, var(--muted));
  box-shadow: 0 0 6px var(--aqi, transparent);
}

.aqi-city { color: var(--text); font-weight: 600; }
.aqi-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.aqi-cat { color: var(--muted); font-size: 0.72rem; }
.aqi-smoke { font-size: 0.85rem; line-height: 1; cursor: help; }

/* Firefighting aircraft markers (replica icons) */
.ac-icon { background: none; border: none; }
.ac-wrap { position: relative; }
/* Flying: offset cast shadow gives the same above-the-map feel as the S-64 */
.ac3d { filter: drop-shadow(2.5px 4px 3px rgba(0, 0, 0, 0.45)); overflow: visible; }
.ac3d.ac-flat { filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.5)); }
.ac-rotor { animation: rotor-spin 0.55s linear infinite; }
.ac-rotor2 { animation-delay: -0.27s; }
.ac-prop { animation: rotor-spin 0.26s linear infinite; }
@keyframes rotor-spin { to { transform: rotate(360deg); } }

/* Aircraft lights: soft nav dots + blinking anti-collision beacon */
.s64-nav {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  pointer-events: none;
}
.s64-nav-l { left: 26%; top: 47%; background: #ff5252; box-shadow: 0 0 4px 1px rgba(255, 82, 82, 0.55); }
.s64-nav-r { right: 26%; top: 47%; background: #54e08a; box-shadow: 0 0 4px 1px rgba(84, 224, 138, 0.55); }
.s64-beacon {
  position: absolute;
  left: calc(50% - 1.5px);
  top: 55%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 5px 2px rgba(255, 59, 48, 0.6);
  animation: beacon-blink 1.1s ease-in-out infinite;
  pointer-events: none;
}
svg .ac-beacon { animation: beacon-blink 1.1s ease-in-out infinite; }
@keyframes beacon-blink {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 1; }
}

/* ==== Drop-in-progress animations ==================================== */
/* Fixed-wing: released material streams tailward as a flowing curtain.
   The wrapper rotates with the heading, so "tail" is simply down in
   local coordinates. Segments spawn at the belly, drift back, widen,
   and fade — the staggered loop reads as continuous pouring. */
.ac-dropline {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.ac-dropline i {
  position: absolute;
  left: -6px;
  top: 0;
  width: 12px;
  height: 14px;
  border-radius: 45%;
  opacity: 0;
  animation: drop-flow 1.15s linear infinite;
}
.ac-dropline i:nth-child(2) { animation-delay: 0.28s; }
.ac-dropline i:nth-child(3) { animation-delay: 0.56s; }
.ac-dropline i:nth-child(4) { animation-delay: 0.84s; }
.drop-phos i {
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 110, 80, 0.95), rgba(226, 60, 44, 0.75) 55%, rgba(226, 60, 44, 0) 78%);
}
.drop-water i {
  background: radial-gradient(ellipse at 50% 30%, rgba(214, 238, 255, 0.95), rgba(110, 180, 245, 0.7) 55%, rgba(110, 180, 245, 0) 78%);
}
@keyframes drop-flow {
  0%   { transform: translateY(0) scale(0.45, 0.6); opacity: 0; }
  12%  { opacity: 0.95; }
  70%  { opacity: 0.55; }
  100% { transform: translateY(26px) scale(1.5, 1.15); opacity: 0; }
}

/* Hovering rotorcraft: material spreads beneath as widening splash rings. */
.ac-splash {
  position: absolute;
  left: 50%;
  top: 55%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.ac-splash i {
  position: absolute;
  left: -11px;
  top: -7px;
  width: 22px;
  height: 14px;
  border-radius: 50%;
  opacity: 0;
  animation: splash-ring 1.6s ease-out infinite;
}
.ac-splash i:nth-child(2) { animation-delay: 0.53s; }
.ac-splash i:nth-child(3) { animation-delay: 1.06s; }
.ac-splash.drop-water i {
  border: 2px solid rgba(150, 205, 250, 0.85);
  background: radial-gradient(ellipse, rgba(214, 238, 255, 0.5), rgba(110, 180, 245, 0) 70%);
}
.ac-splash.drop-phos i {
  border: 2px solid rgba(255, 120, 90, 0.85);
  background: radial-gradient(ellipse, rgba(255, 140, 110, 0.5), rgba(226, 60, 44, 0) 70%);
}
@keyframes splash-ring {
  0%   { transform: scale(0.25); opacity: 0; }
  15%  { opacity: 0.9; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Active drop-run: gentle pulse ring */
.ac-active { animation: ac-pulse 1.6s ease-out infinite; }
@keyframes ac-pulse {
  0% { filter: drop-shadow(0 1.5px 2px rgba(0,0,0,0.65)) drop-shadow(0 0 0 rgba(255,90,95,0.7)); }
  70% { filter: drop-shadow(0 1.5px 2px rgba(0,0,0,0.65)) drop-shadow(0 0 7px rgba(255,90,95,0)); }
  100% { filter: drop-shadow(0 1.5px 2px rgba(0,0,0,0.65)) drop-shadow(0 0 0 rgba(255,90,95,0)); }
}

@media (prefers-reduced-motion: reduce) {
  .ac-rotor, .ac-prop, .ac-active, .ac-dropline i, .ac-splash i, .s64-beacon, svg .ac-beacon { animation: none; }
}

/* Fire aircraft activity */
.aclog-section { padding: 4px 0 10px; border-top: 1px solid var(--border-soft); }
.aclog-section .section-title { margin-top: 12px; }

/* Headline counters */
.ac-stats { display: flex; gap: 8px; padding: 0 18px 10px; }
.ac-pill {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
}
.ac-pill-val {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.ac-pill-lbl {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-top: 1px;
}

/* By-model bars (expandable to individual airframes) */
.ac-models { padding: 0 18px 6px; }
.ac-model, .ac-model summary {
  display: grid;
  grid-template-columns: 12px 26px 1fr 64px auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}
.ac-model.ac-model-exp { display: block; padding: 0; }
.ac-model summary {
  cursor: pointer;
  list-style: none;
  border-radius: 8px;
}
.ac-model summary::-webkit-details-marker { display: none; }
.ac-model summary:hover { background: var(--panel-2); }
.ac-arrow {
  color: var(--text);
  font-size: 0.7rem;
  line-height: 1;
  transition: transform 0.15s ease;
  text-align: center;
}
.ac-model-exp[open] .ac-arrow { transform: rotate(90deg); }
.ac-model-ico { width: 26px; height: 26px; display: inline-flex; }
.ac-model-name {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.ac-model-title {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-model-tails {
  font-size: 0.66rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.2px;
}
.ac-model-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--panel-3);
  overflow: hidden;
}
.ac-model-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #ff9f5a);
}
.ac-model-count {
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 22px;
  text-align: right;
}

/* Individual airframes under a model */
.ac-inds {
  list-style: none;
  margin: 0 0 4px;
  padding: 2px 0 4px 46px;
}
.ac-ind {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 3px 8px 3px 0;
  font-size: 0.76rem;
  border-left: 2px solid var(--border);
  padding-left: 10px;
}
.ac-ind-id { font-weight: 600; font-variant-numeric: tabular-nums; }
.ac-ind-meta { color: var(--muted); font-size: 0.7rem; text-align: right; }
.ac-ind-more { color: var(--faint); font-style: italic; }

/* Recent aircraft (collapsible) */
.ac-recent { padding: 2px 18px 0; }
.ac-recent > summary {
  cursor: pointer;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  list-style: none;
  padding: 4px 0;
}
.ac-recent > summary::-webkit-details-marker { display: none; }
.ac-recent > summary::after { content: " ▾"; color: var(--faint); }
.ac-recent[open] > summary::after { content: " ▴"; }
.aclog-list { list-style: none; margin: 0; padding: 0; }
.aclog-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
}
.aclog-item:last-child { border-bottom: none; }
.aclog-ico { flex: none; width: 26px; height: 26px; display: inline-flex; }
.aclog-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.aclog-id { font-size: 0.82rem; font-weight: 600; }
.aclog-sub { font-size: 0.72rem; color: var(--muted); }
.aclog-when { flex: none; font-size: 0.72rem; color: var(--faint); }

.aqi-chip.skeleton {
  width: 150px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ==== Controls ====================================================== */
.controls {
  display: flex;
  gap: 8px;
  padding: 12px 18px 4px;
}

.search-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
}

.search-input::placeholder { color: var(--faint); }

select, button {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
}

#refresh-btn {
  flex: none;
  width: 40px;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--accent);
  font-weight: 700;
}

#refresh-btn.spinning { animation: spin 0.9s linear infinite; }
#refresh-btn:disabled { opacity: 0.6; cursor: progress; }

@keyframes spin { to { transform: rotate(360deg); } }

button:hover, select:hover { border-color: var(--accent); }

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

.status {
  padding: 6px 18px;
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1.2em;
}

.status.error { color: #ff8a80; }

/* ==== Alert banner ================================================== */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 18px 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--warn-soft);
  border: 1px solid rgba(255, 209, 102, 0.4);
  color: #ffe08a;
  font-size: 0.8rem;
  line-height: 1.4;
}

.alert-banner[hidden] { display: none; }
.alert-banner .alert-icon { flex: none; font-size: 0.95rem; }
.alert-banner b { color: #ffd166; }

/* ==== Incident list ================================================= */
.incident-list {
  list-style: none;
  margin: 0;
  padding: 6px 14px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.incident {
  background: linear-gradient(180deg, var(--panel-2), rgba(31, 40, 51, 0.6));
  border: 1px solid var(--border);
  border-left: 4px solid var(--sev, var(--accent));
  border-radius: 10px;
  padding: 11px 13px;
  margin: 8px 0;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.incident:hover, .incident:focus-visible {
  transform: translateX(2px);
  border-color: var(--accent);
  background: var(--panel-3);
}

.incident-name {
  font-weight: 600;
  font-size: 0.93rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.incident-name > span:first-child {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.incident-meta {
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 8px;
}

.incident-meta .sep { color: var(--faint); }

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}

.badge-acres { background: var(--accent-soft); color: var(--accent); }

.badge-new {
  background: var(--danger-soft);
  color: var(--danger);
  letter-spacing: 0.8px;
  font-size: 0.62rem;
  padding: 2px 7px;
  animation: pulse-soft 2.4s ease-out infinite;
}

@keyframes pulse-soft {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 95, 0.35); }
  70% { box-shadow: 0 0 0 6px rgba(255, 90, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 90, 95, 0); }
}

.empty-note {
  padding: 14px 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* City-limit outlines: dark casing so the dashes stay readable over
   bright satellite imagery (no visible effect on the dark base). */
.city-outline { filter: drop-shadow(0 0 1.5px rgba(6, 10, 14, 0.9)); }

/* Collapsed small-fires group row */
.incident-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(31, 40, 51, 0.45);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 9px 13px;
  margin: 8px 0;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.1s ease, background 0.1s ease, color 0.1s ease;
}

.incident-group:hover, .incident-group:focus-visible {
  border-color: var(--accent);
  background: var(--panel-3);
  color: var(--text);
}

.group-arrow {
  display: inline-block;
  color: var(--accent);
  font-size: 0.8rem;
  transition: transform 0.15s ease;
}

.incident-group.open .group-arrow { transform: rotate(90deg); }

.group-sub {
  font-weight: 400;
  color: var(--faint);
}

/* Compact cards inside the expanded group */
.incident-sm {
  padding: 8px 12px;
  margin: 6px 0 6px 14px;
  border-left-width: 3px;
}

.incident-sm .incident-name { font-size: 0.85rem; }
.incident-sm .incident-meta { margin-top: 4px; font-size: 0.72rem; }

/* Growth-trend chips */
.trend-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.trend-accel { background: var(--danger-soft); color: var(--danger); }
.trend-grow { background: var(--accent-soft); color: var(--accent); }
.trend-steady { background: rgba(147, 161, 176, 0.14); color: var(--muted); }
.trend-slow { background: rgba(63, 208, 108, 0.12); color: var(--good); }
.trend-est { background: rgba(147, 161, 176, 0.1); color: var(--faint); font-weight: 500; }
.spread-chip { background: rgba(255, 177, 94, 0.14); color: #ffb15e; }
.spread-warn { background: var(--danger-soft); color: var(--danger); }

/* Containment micro-bar */
.containment {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}

.containment-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--panel-3);
  overflow: hidden;
}

.containment-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2fae59, var(--good));
  min-width: 2px;
}

.containment-num {
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: 34px;
  text-align: right;
}

/* ==== Latest updates (InciWeb) ====================================== */
.updates-section { padding: 4px 0 8px; border-top: 1px solid var(--border-soft); }
.updates-section .section-title { margin-top: 12px; }

.updates-list {
  list-style: none;
  margin: 0;
  padding: 0 18px;
}

.update-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-soft);
}

.update-item:last-child { border-bottom: none; }

.update-item a {
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.update-item a:hover { color: var(--accent); text-decoration: underline; }

.update-when {
  flex: none;
  color: var(--faint);
  font-size: 0.72rem;
}

.badge-offlist {
  background: rgba(255, 159, 28, 0.16);
  color: #ffb45e;
  border: 1px solid rgba(255, 159, 28, 0.4);
}

/* source tag on merged update feeds */
.src-tag {
  flex: none;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--faint);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
  text-transform: uppercase;
}

/* ==== My location (GPS blue dot) ======================================= */
.leaflet-control-locate a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: #444;
  background: #fff;
  cursor: pointer;
}
.leaflet-control-locate a:hover { color: #1a73e8; }
.leaflet-control-locate a.locate-active { color: #1a73e8; }
.leaflet-control-locate a.locate-busy svg { animation: locate-spin 1.1s linear infinite; }
@keyframes locate-spin { to { transform: rotate(360deg); } }

.gps-icon { background: none; border: none; }
.gps-dot {
  display: block;
  width: 14px;
  height: 14px;
  margin: 4px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-sizing: content-box;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
  animation: gps-pulse 2.2s ease-out infinite;
}
@keyframes gps-pulse {
  0%   { box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(26, 115, 232, 0.45); }
  70%  { box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5), 0 0 0 16px rgba(26, 115, 232, 0); }
  100% { box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(26, 115, 232, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .gps-dot { animation: none; }
}

/* ==== 3D Skycrane sprite icon ========================================== */
.s64-3d { position: relative; background: none; border: none; }
.s64-rot, .s64-lift, .s64-shadow { position: absolute; inset: 0; }
.s64-frame { position: absolute; inset: 0; overflow: hidden; }
.s64-strip {
  position: absolute;
  top: 0;
  left: 0;
  width: 600%;
  height: 100%;
  background-size: 100% 100%; /* 6-frame sheet exactly fills the 600% strip */
  background-repeat: no-repeat;
  animation: s64-rotor 0.18s steps(6) infinite reverse;
}
/* flying: body lifted, silhouette shadow cast on the ground below-right */
.s64-lift { transform: translateY(-8px); }
.s64-shadow {
  transform: translate(11px, 14px) scale(0.9);
  filter: brightness(0) blur(2.5px);
  opacity: 0.35;
}
@keyframes s64-rotor {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}
@media (prefers-reduced-motion: reduce) {
  .s64-strip { animation: none; }
}
.s64-lift.ac-active { filter: drop-shadow(0 0 7px rgba(255, 120, 60, 0.9)); }

/* ==== Fire flame pins ================================================== */
.fire-pin {
  background: none;
  border: none;
}
.fire-pin svg {
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
  transition: transform 0.12s ease;
}
.fire-pin:hover svg { transform: scale(1.18); }
.fire-pin-dim svg { opacity: 0.72; }
.fire-pin-retired svg { opacity: 0.8; }

/* Retired fires: collapsible season archive under the active list */
.retired-section summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 14px;
  -webkit-tap-highlight-color: transparent;
}
.retired-section summary:hover { color: var(--accent); }
.retired-note {
  margin: 2px 14px 4px;
  font-size: 0.74rem;
  color: var(--faint);
}
.retired-list { padding-top: 0; }
.incident-retired {
  border-left-color: #5d6a76;
  margin-left: 0;
  opacity: 0.92;
}
.badge-acres-retired { background: rgba(93, 106, 118, 0.25); color: #9aa7b4; }
.badge-retired {
  font-size: 0.64rem;
  letter-spacing: 0.4px;
  background: rgba(93, 106, 118, 0.22);
  color: #aab6c2;
}
.badge-retired-out { background: rgba(63, 208, 108, 0.14); color: #7fd89c; }
.badge-retired-controlled { background: rgba(84, 160, 255, 0.14); color: #8db8ef; }
.badge-retired-presumed { color: #8a97a4; font-style: italic; }
/* pulse ring only for fires discovered in the last 24 h */
.fire-pin-new::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 62%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.45);
  animation: fire-ping 1.7s ease-out infinite;
}
@keyframes fire-ping {
  0%   { box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.5); }
  75%  { box-shadow: 0 0 0 16px rgba(255, 107, 53, 0); }
  100% { box-shadow: 0 0 0 3px rgba(255, 107, 53, 0); }
}
/* POI-style fire name labels (city zoom) */
.fire-label-icon { background: none; border: none; }
.fire-label {
  display: inline-block;
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #f3e9dd;
  background: rgba(14, 17, 24, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  padding: 1px 6px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.legend-flame {
  display: inline-block;
  width: 20px;
  text-align: center;
  vertical-align: -2px;
  margin-right: 4px;
}
.leaflet-tooltip {
  background: rgba(16, 20, 28, 0.94);
  color: #e8ecf3;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  font-size: 0.74rem;
  padding: 3px 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}
.leaflet-tooltip-top:before { border-top-color: rgba(16, 20, 28, 0.94); }

/* ==== Possible new fires (satellite, unconfirmed) ===================== */
.unl-item a { display: inline-flex; align-items: center; gap: 7px; }
.unl-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff9f1c;
  box-shadow: 0 0 6px rgba(255, 159, 28, 0.8);
}
.unl-icon { background: none; border: none; }
.unl-pulse {
  display: block;
  width: 14px;
  height: 14px;
  margin: 6px;
  border-radius: 50%;
  background: rgba(255, 159, 28, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 159, 28, 0.35);
  animation: unl-pulse 1.6s ease-out infinite;
}
@keyframes unl-pulse {
  0%   { box-shadow: 0 0 0 3px rgba(255, 159, 28, 0.4); }
  70%  { box-shadow: 0 0 0 14px rgba(255, 159, 28, 0); }
  100% { box-shadow: 0 0 0 3px rgba(255, 159, 28, 0); }
}

/* ==== About + FAQ ==================================================== */
.about-section {
  padding: 4px 18px 12px;
  border-top: 1px solid var(--border-soft);
}
.about-section .section-title { margin: 12px 0 8px; padding: 0; }

.about-text {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
}
.about-text strong { color: var(--text); }

.faq {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  margin: 6px 0;
  background: var(--panel-2);
}

.faq summary {
  cursor: pointer;
  padding: 9px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  list-style: none;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 12px;
  color: var(--faint);
  transition: transform 0.15s ease;
}
.faq[open] summary::after { transform: rotate(45deg); }
.faq summary:hover { color: var(--accent); }

.faq p {
  margin: 0;
  padding: 0 12px 10px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ==== Footer ======================================================== */
.panel-footer {
  padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
}

.updated { margin: 6px 0 0; color: var(--faint); }

/* ==== Leaflet theming =============================================== */
.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; font-size: 0.85rem; line-height: 1.5; }
.leaflet-popup-content h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.leaflet-popup-content .row { color: var(--muted); }
.leaflet-popup-content .row b { color: var(--text); }

/* Latest-coverage block inside fire popups */
.news-block {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}
.news-head { font-weight: 600; color: var(--text); }
.news-row { margin: 4px 0; line-height: 1.35; }
.news-row a {
  color: var(--accent);
  text-decoration: none;
  display: block;
}
.news-row a:hover { text-decoration: underline; }
.news-meta { font-size: 0.72rem; color: var(--faint); display: block; }
.news-pending { font-style: italic; color: var(--faint); }
.news-tag {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  margin-bottom: 2px;
}
.news-tag-official { background: rgba(63, 208, 108, 0.15); color: #7fd89c; }
.leaflet-popup-content .weather-row { color: var(--text); }
.leaflet-popup-content .growth-row { color: var(--text); }
.leaflet-popup-content .spread-row { color: #ffb15e; }
.leaflet-popup-content .growth-detail { font-size: 0.78rem; }
.leaflet-popup-content .growth-warn { color: var(--danger); font-weight: 600; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

.legend {
  background: rgba(22, 29, 38, 0.92);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.75rem;
  line-height: 1.7;
}
.legend h4 {
  margin: 0 0 6px;
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* collapsible legend: compact flame button on phones, auto-tucks on map drag */
.legend-toggle,
.legend-close {
  display: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--faint);
  font-size: 1rem;
  line-height: 1;
}
.legend-close:hover { color: var(--text); }
.legend.legend-collapsed { padding: 0; }
.legend.legend-collapsed .legend-body { display: none; }
.legend.legend-collapsed .legend-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
}
@media (max-width: 760px) {
  .legend-close { display: inline-block; } /* expanded state gets an × on phones */
}

.legend .dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}

.leaflet-control-layers {
  background: rgba(22, 29, 38, 0.94);
  color: var(--text);
  border: 1px solid var(--border) !important;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.leaflet-control-layers-expanded { padding: 8px 12px 8px 10px; font-size: 0.8rem; }
.leaflet-control-layers label { margin: 3px 0; }
.leaflet-control-layers-selector { margin-right: 6px; }
.leaflet-control-layers-separator { border-top: 1px solid var(--border); }

.leaflet-bar a {
  background: var(--panel-2);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.leaflet-bar a:hover { background: var(--panel-3); }
.leaflet-bar a.leaflet-disabled {
  background: var(--panel);
  color: var(--faint);
}

.leaflet-control-attribution {
  background: rgba(13, 18, 24, 0.75) !important;
  color: var(--faint) !important;
  font-size: 0.62rem;
}
.leaflet-control-attribution a { color: var(--muted); }

/* ==== Scrollbars (WebKit) =========================================== */
#panel::-webkit-scrollbar, .aqi-chips::-webkit-scrollbar { height: 6px; width: 8px; }
#panel::-webkit-scrollbar-thumb, .aqi-chips::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}
#panel::-webkit-scrollbar-track, .aqi-chips::-webkit-scrollbar-track { background: transparent; }

/* Compact legend + controls on phones so the map stays usable */
@media (max-width: 600px) {
  .legend {
    font-size: 0.62rem;
    line-height: 1.5;
    padding: 6px 8px;
  }
  .legend h4 { margin: 0 0 3px; font-size: 0.62rem; }
  .legend .dot { width: 8px; height: 8px; margin-right: 4px; }
}

/* ==== Small phones ================================================== */
@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 1.3rem; }
  #topbar h1 { font-size: 1rem; }
}

/* ==== Touch ergonomics ============================================== */
@media (pointer: coarse) {
  select, button, .search-input { min-height: 44px; }
  .incident { padding: 13px 14px; }
}

/* ==== Reduced motion ================================================ */
@media (prefers-reduced-motion: reduce) {
  .live-dot, .badge-new, .aqi-chip.skeleton, #refresh-btn.spinning, .stat { animation: none; }
  .incident { transition: none; }
}

/* ==== Guide page ==================================================== */
.guide-body {
  display: block;
  overflow: auto;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.guide-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}
.guide-head { border-bottom: 1px solid var(--border-soft); padding-bottom: 16px; margin-bottom: 8px; }
.guide-back {
  display: inline-block;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--muted);
  margin-bottom: 14px;
}
.guide-back:hover { color: var(--accent); }
.guide-head h1 { margin: 0 0 6px; font-size: 1.5rem; }
.guide-lede { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.6; }
.guide-lede a, .guide-callout a, .guide-list a { color: var(--accent); }

.guide-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 10px 0;
  z-index: 2;
}
.guide-toc a {
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
}
.guide-toc a:hover { border-color: var(--accent); }

.guide-section { padding: 18px 0; border-top: 1px solid var(--border-soft); }
.guide-section h2 { font-size: 1.15rem; margin: 0 0 12px; }
.guide-note {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 16px;
}

.guide-item {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.guide-item h3 { margin: 0 0 6px; font-size: 1rem; }
.guide-item p { margin: 0; color: var(--text); font-size: 0.9rem; line-height: 1.65; }
.guide-item em { color: var(--muted); font-style: italic; }

.guide-tag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.guide-list { margin: 0; padding-left: 20px; }
.guide-list li { font-size: 0.9rem; line-height: 1.7; margin-bottom: 6px; }

/* compact definition rows */
.guide-defs { margin: 0; }
.guide-defs dt {
  font-weight: 700;
  font-size: 0.92rem;
  margin-top: 14px;
}
.guide-defs dt:first-child { margin-top: 0; }
.guide-defs dd {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}
.guide-defs dd strong { color: var(--text); }
.guide-defs dd a { color: var(--accent); }

.guide-callout {
  background: var(--accent-soft);
  border: 1px solid rgba(255, 107, 53, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 14px 0 0;
}
.guide-foot { padding-top: 20px; }
