/* HurricaneMap — Catppuccin Mocha + glassmorphism */
:root {
  --base:   #11111b;
  --mantle: #181825;
  --crust:  #1e1e2e;
  --surface0: #313244;
  --surface1: #45475a;
  --text:    #cdd6f4;
  --subtext: #a6adc8;
  --overlay: #6c7086;
  --blue:    #89b4fa;
  --lavender:#b4befe;
  --sapphire:#74c7ec;

  --cat-ts:  #74c7ec;  /* sapphire */
  --cat-1:   #a6e3a1;  /* green */
  --cat-2:   #f9e2af;  /* yellow */
  --cat-3:   #fab387;  /* peach */
  --cat-4:   #f38ba8;  /* pink */
  --cat-5:   #cba6f7;  /* mauve */

  /* Semantic status colors */
  --success: #a6e3a1;  /* green */
  --warning: #f9e2af;  /* yellow */
  --error:   #f38ba8;  /* pink/red */
  --info:    #89b4fa;  /* blue */

  --glass-bg:   rgba(30, 30, 46, 0.72);
  --glass-edge: rgba(205, 214, 244, 0.10);
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.45);

  /* Elevation shadows (semantic depth) */
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-xl:  0 12px 48px rgba(0, 0, 0, 0.45);

  /* Spacing scale */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;

  /* Component sizing */
  --button-height: 40px;
  --button-height-lg: 44px;
  --input-height: 40px;
  --touch-target-min: 44px;

  /* Focus ring */
  --focus-ring: 3px solid rgba(180, 190, 254, 0.6);
}

/* Light theme — Catppuccin Latte */
html.light-theme {
  --base:   #eff1f5;
  --mantle: #e6e9f0;
  --crust:  #dce0e8;
  --surface0: #ccd0dd;
  --surface1: #bcc0cc;
  --text:    #4c4f69;
  --subtext: #6c6f85;
  --overlay: #7c8296;
  --blue:    #1e66f5;
  --lavender:#7c3aed;
  --sapphire:#04a5e5;

  --cat-ts:  #04a5e5;  /* sapphire */
  --cat-1:   #40a02b;  /* green */
  --cat-2:   #e49320;  /* yellow */
  --cat-3:   #fe640b;  /* peach */
  --cat-4:   #d20f39;  /* pink */
  --cat-5:   #8839ef;  /* mauve */

  --success: #40a02b;  /* green */
  --warning: #e49320;  /* yellow */
  --error:   #d20f39;  /* pink/red */
  --info:    #1e66f5;  /* blue */

  --glass-bg:   rgba(239, 241, 245, 0.85);
  --glass-edge: rgba(76, 79, 105, 0.12);
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.12);

  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.15);
  --shadow-xl:  0 12px 48px rgba(0, 0, 0, 0.2);
}

/* High-contrast mode — WCAG AAA 7:1 minimum contrast ratios */
html.high-contrast {
  --base:   #000000;
  --mantle: #0a0a0a;
  --crust:  #1a1a1a;
  --surface0: #2d2d2d;
  --surface1: #404040;
  --text:    #ffffff;  /* 21:1 contrast on black */
  --subtext: #e0e0e0;  /* 19:1 contrast */
  --overlay: #404040;
  --blue:    #0047b2;  /* darkened for 7:1+ on white text */
  --lavender:#4a0080;
  --sapphire:#00539b;

  --cat-ts:  #00539b;  /* darker sapphire */
  --cat-1:   #004d00;  /* darker green */
  --cat-2:   #994c00;  /* darker yellow */
  --cat-3:   #993300;  /* darker peach */
  --cat-4:   #800020;  /* darker pink */
  --cat-5:   #330099;  /* darker mauve */

  --success: #00b300;  /* bright green */
  --warning: #ccaa00;  /* bright yellow */
  --error:   #ff0000;  /* bright red */
  --info:    #0047b2;  /* bright blue */

  --glass-bg:   rgba(0, 0, 0, 0.95);
  --glass-edge: rgba(255, 255, 255, 0.20);
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.8);

  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-xl:  0 12px 48px rgba(0, 0, 0, 0.8);

  font-size: 18px; /* +2px larger base font */
  font-weight: 500; /* bolder text overall */
}

/* High-contrast light mode — WCAG AAA on light backgrounds */
html.light-theme.high-contrast {
  --base:   #ffffff;
  --mantle: #f5f5f5;
  --crust:  #e8e8e8;
  --surface0: #d0d0d0;
  --surface1: #b8b8b8;
  --text:    #000000;  /* 21:1 contrast on white */
  --subtext: #1a1a1a;  /* 19:1 contrast */
  --overlay: #666666;
  --blue:    #0047b2;  /* same darker blue */
  --lavender:#4a0080;
  --sapphire:#00539b;

  --cat-ts:  #00539b;
  --cat-1:   #004d00;
  --cat-2:   #994c00;
  --cat-3:   #993300;
  --cat-4:   #800020;
  --cat-5:   #330099;

  --success: #004d00;
  --warning: #994c00;
  --error:   #800020;
  --info:    #0047b2;

  --glass-bg:   rgba(255, 255, 255, 0.98);
  --glass-edge: rgba(0, 0, 0, 0.20);
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.15);

  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.15);
  --shadow-xl:  0 12px 48px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #070b12;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
               "Helvetica Neue", Arial, sans-serif;
  background: var(--base);
  color: var(--text);
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background: var(--base);
}

/* Glass surface base */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* Header — user-tuned offset to clear the left-edge map controls */
.app-header,
header.app-header.glass {
  position: absolute;
  top: 16px;
  left: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.title-block h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
  background: linear-gradient(95deg, var(--lavender), var(--sapphire));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.01em;
}
.title-block .subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--subtext);
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--glass-edge);
  color: var(--subtext);
  width: var(--button-height);
  height: var(--button-height);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, color 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  will-change: transform, color, box-shadow;
  flex-shrink: 0;
}
.icon-btn:hover {
  transform: translateY(-1px);
  color: var(--text);
  background: rgba(180, 190, 254, 0.08);
  border-color: rgba(180, 190, 254, 0.25);
}
.icon-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 var(--focus-ring);
  border-color: rgba(180, 190, 254, 0.5);
}
.icon-btn:active {
  transform: translateY(0);
}

/* Filters — moved to the LEFT side beneath the header so the right side
   is dedicated to the mode-panels (storm/state/stats/compare) without
   horizontal overlap. */
.filters {
  position: absolute;
  top: 100px;
  left: 12px;
  z-index: 1500;
  width: 280px;
  max-height: calc(100vh - 240px);  /* 100px top + 140px timeline = 240px reserved */
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.filter-row > label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtext);
}
.year-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}
.year-inputs input {
  flex: 1;
}
.year-clear-btn {
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

/* Highlight active year filter */
.filter-row--year.active-filter {
  background: rgba(137, 180, 250, 0.08);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(137, 180, 250, 0.3);
  margin: -6px -6px 0;
}
.filter-row--year.active-filter > label {
  color: var(--blue);
}
input[type="number"], input[type="search"], select {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  height: var(--input-height);
  transition: all 120ms ease;
  font-family: inherit;
}
input[type="number"]:focus,
input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: var(--lavender);
  background: var(--crust);
  box-shadow: inset 0 0 0 2px rgba(180, 190, 254, 0.3), 0 0 0 3px rgba(180, 190, 254, 0.15);
}
input[type="number"]:disabled,
input[type="search"]:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface0);
}
input[type="number"]::placeholder,
input[type="search"]::placeholder {
  color: var(--subtext);
  opacity: 0.7;
}

.cat-toggles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.cat-btn {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  color: var(--subtext);
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cat-btn.on.cat-ts { background: var(--cat-ts); color: var(--base); border-color: var(--cat-ts); }
.cat-btn.on.cat-1  { background: var(--cat-1);  color: var(--base); border-color: var(--cat-1); }
.cat-btn.on.cat-2  { background: var(--cat-2);  color: var(--base); border-color: var(--cat-2); }
.cat-btn.on.cat-3  { background: var(--cat-3);  color: var(--base); border-color: var(--cat-3); }
.cat-btn.on.cat-4  { background: var(--cat-4);  color: var(--base); border-color: var(--cat-4); }
.cat-btn.on.cat-5  { background: var(--cat-5);  color: var(--base); border-color: var(--cat-5); }
.cat-btn:hover { 
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.cat-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 var(--focus-ring), var(--shadow-sm);
}
.cat-btn:not(.on) { opacity: 0.6; }
.cat-btn:not(.on):hover { opacity: 1; background: rgba(255, 255, 255, 0.06); }

label > input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: middle;
}
.text-btn {
  background: transparent;
  border: 1px solid var(--surface0);
  color: var(--subtext);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.text-btn:hover { 
  color: var(--text);
  border-color: var(--lavender);
  background: rgba(180, 190, 254, 0.05);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.text-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 var(--focus-ring), var(--shadow-sm);
  border-color: var(--lavender);
}
.text-btn:active {
  transform: translateY(0);
}
.visible-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--subtext);
  align-self: center;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  background: var(--crust);
  border: 1px solid var(--surface0);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  animation: search-fade-in 120ms ease;
}
@keyframes search-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-results li {
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--surface0);
  transition: background-color 100ms ease;
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover { 
  background: var(--surface0);
  padding-left: 12px;
}

/* Legend — bottom-left, aligned with the filters/header column */
.legend {
  position: absolute;
  bottom: 30px;
  left: 12px;
  z-index: 1000;
  padding: 12px 16px;
  font-size: 12px;
}
.legend .legend-heading {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtext);
}
.legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.dot.cat-ts { background: var(--cat-ts); }
.dot.cat-1  { background: var(--cat-1); }
.dot.cat-2  { background: var(--cat-2); }
.dot.cat-3  { background: var(--cat-3); }
.dot.cat-4  { background: var(--cat-4); }
.dot.cat-5  { background: var(--cat-5); }

/* All right-side mode-panels share the same slot (mutually exclusive — only
   one open at a time, managed by panels.js). Storm panel is the primary;
   state / stats / compare swap into the same position when opened. */
.storm-panel,
.stats-panel,
.compare-panel,
.state-panel,
.on-this-date-panel {
  position: absolute;
  top: 110px;
  right: 16px;
  bottom: 160px;     /* leave room for timeline (140px) + padding (20px) */
  z-index: 1000;
  width: 420px;
  max-width: calc(100vw - 32px);
  overflow-y: auto;
  padding: 18px 22px 22px;
  font-size: 13px;
  line-height: 1.55;
}

/* User-tuned storm-panel sizing — natural height, capped to the viewport so
   the playback controls and bottom edge stay visible. The premium-pass block
   below replaces the hard-coded height with a flexible cap. */
section.storm-panel.glass {
  top: 8px;
  bottom: 8px;
  max-height: calc(100vh - 16px);
}

.close-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--subtext);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 120ms ease;
}
.close-btn:hover { 
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--glass-edge);
  transform: scale(1.05);
}
.close-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.15);
}

.storm-panel h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.storm-panel .meta-row {
  font-size: 12px;
  color: var(--subtext);
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.cat-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--base);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cat-pill.cat-ts { background: var(--cat-ts); }
.cat-pill.cat-1  { background: var(--cat-1); }
.cat-pill.cat-2  { background: var(--cat-2); }
.cat-pill.cat-3  { background: var(--cat-3); }
.cat-pill.cat-4  { background: var(--cat-4); }
.cat-pill.cat-5  { background: var(--cat-5); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0 14px;
}
.stat-grid .stat {
  background: var(--mantle);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--surface0);
  transition: all 120ms ease;
  cursor: default;
}
.stat-grid .stat:hover {
  border-color: rgba(180, 190, 254, 0.25);
  background: rgba(180, 190, 254, 0.03);
}
.stat .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtext);
}
.stat .value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

/* Panel section heading shared style */
.panel-section-h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtext);
  margin: 16px 0 8px;
  font-weight: 600;
}

/* Intensity chart */
.chart-host { margin-bottom: 8px; }
.intensity-chart {
  position: relative;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 10px;
  padding: 8px 8px 6px;
  transition: all 120ms ease;
  will-change: border-color, box-shadow;
}
.intensity-chart:hover {
  border-color: rgba(180, 190, 254, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 10px;
  color: var(--subtext);
  margin-bottom: 4px;
  padding: 0 4px;
}
.cl-item { display: inline-flex; align-items: center; gap: 5px; }
.cl-swatch {
  display: inline-block;
  width: 16px;
  height: 2px;
  border-radius: 1px;
}
.cl-swatch.wind { background: rgba(205, 214, 244, 0.85); }
.cl-swatch.pres { background: linear-gradient(to right, var(--sapphire) 0%, var(--sapphire) 50%, transparent 50%, transparent 100%); background-size: 6px 2px; height: 2px; }
.cl-landfall { color: rgba(243,139,168,0.9); }

.intensity-svg {
  width: 100%;
  height: auto;
  display: block;
}
.intensity-svg .ax-tick {
  font-size: 9px;
  fill: var(--subtext);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.chart-dot { transition: r 80ms ease; }
.chart-dot:hover { r: 4; }

.chart-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--crust);
  color: var(--text);
  border: 1px solid var(--surface0);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  min-width: 130px;
}
.tt-time { color: var(--lavender); font-size: 10px; margin-bottom: 4px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.tt-row { display: flex; justify-content: space-between; gap: 12px; line-height: 1.5; }
.tt-row span { color: var(--subtext); }

.landfall-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.landfall-list li {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 7px 10px;
  background: var(--mantle);
  border-radius: 8px;
  border: 1px solid var(--surface0);
  transition: all 120ms ease;
  cursor: default;
}
.landfall-list li:hover {
  background: var(--surface0);
  border-color: rgba(180, 190, 254, 0.25);
}
.landfall-list .where {
  color: var(--text);
  font-weight: 600;
}
.landfall-list .when {
  color: var(--subtext);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
}
.inferred-tag {
  display: inline-block;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 4px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface1);
  color: var(--subtext);
}

.similar-storms-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.similar-storm-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  padding: 8px 10px;
  background: var(--mantle);
  border-radius: 8px;
  border: 1px solid var(--surface0);
  transition: all 120ms ease;
  cursor: pointer;
}
.similar-storm-row:hover {
  background: var(--surface0);
  border-color: var(--lavender);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.similar-storm-name {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.similar-storm-cat {
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  min-width: 45px;
}
.similar-storm-landfalls {
  color: var(--subtext);
  font-size: 11px;
  text-align: right;
  min-width: 65px;
}
.similar-storm-score {
  color: var(--lavender);
  font-weight: 600;
  font-size: 11px;
  text-align: right;
  min-width: 40px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.action-btn {
  text-decoration: none;
  text-align: center;
  background: var(--mantle);
  color: var(--text);
  border: 1px solid var(--surface0);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  transition: all 120ms ease;
  cursor: pointer;
}
.action-btn:hover {
  background: var(--surface0);
  border-color: var(--lavender);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.action-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.15);
}
.action-btn.primary { 
  background: var(--lavender); 
  color: var(--base); 
  border-color: var(--lavender);
  box-shadow: 0 4px 12px rgba(180, 190, 254, 0.25);
}
.action-btn.primary:hover { 
  background: var(--blue); 
  border-color: var(--blue);
  box-shadow: 0 6px 16px rgba(137, 180, 250, 0.35);
}

/* Panel action buttons row (Play + Pin side-by-side) */
.panel-actions-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
  align-items: stretch;
}
.panel-actions-row .play-anim-btn { margin-top: 0; }
.pin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
  white-space: nowrap;
}
.pin-btn:hover { 
  background: var(--surface0); 
  border-color: var(--lavender);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.pin-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.15);
}
.pin-btn.pinned {
  background: var(--lavender);
  color: var(--base);
  border-color: var(--lavender);
  box-shadow: 0 4px 12px rgba(180, 190, 254, 0.25);
}
.pin-btn.pinned:hover {
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 6px 16px rgba(137, 180, 250, 0.35);
}
.pin-btn .pin-icon { font-size: 13px; }

/* Compare tray (bottom-center floater) */
.compare-tray {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 12px;
  max-width: calc(100vw - 32px);
}
.ct-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtext);
}
.ct-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ct-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text);
  transition: all 100ms ease;
}
.ct-chip:hover {
  border-color: var(--lavender);
  background: rgba(180, 190, 254, 0.05);
}
.ct-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ct-name { font-weight: 600; }
.ct-remove {
  background: transparent;
  border: none;
  color: var(--subtext);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  transition: color 100ms ease;
}
.ct-remove:hover { color: var(--cat-4); }
.ct-btn {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  color: var(--text);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 120ms ease;
}
.ct-btn:hover { 
  background: var(--surface0); 
  border-color: var(--lavender);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.ct-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.15);
}
.ct-btn.primary {
  background: var(--lavender);
  color: var(--base);
  border-color: var(--lavender);
}
.ct-btn.primary:hover { background: var(--blue); border-color: var(--blue); }

.compare-panel h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}
.cp-hint {
  font-size: 11px;
  color: var(--subtext);
  margin: 0 0 14px;
}
.cp-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.cp-actions .export-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--sapphire), var(--blue));
  border: 1px solid rgba(48, 163, 247, 0.3);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: all 120ms ease;
}
.cp-actions .export-btn:hover {
  background: linear-gradient(135deg, var(--blue), var(--sky));
  border-color: rgba(48, 163, 247, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(48, 163, 247, 0.15);
}
.cp-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cp-card {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-left: 3px solid var(--pin-color, var(--lavender));
  border-radius: 10px;
  padding: 10px 12px 12px;
  transition: all 120ms ease;
}
.cp-card:hover {
  border-color: rgba(180, 190, 254, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.cp-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.cp-card-head h3 { margin: 0; font-size: 14px; font-weight: 700; flex: 1; }
.cp-swatch { width: 10px; height: 10px; border-radius: 50%; }
.cp-remove {
  background: transparent;
  border: none;
  color: var(--subtext);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: all 120ms ease;
}
.cp-remove:hover { 
  color: var(--cat-4); 
  background: rgba(243, 139, 168, 0.1);
  transform: scale(1.15);
}
.cp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 11px;
  color: var(--subtext);
  margin-bottom: 8px;
}
.cp-meta strong { color: var(--text); }
.cp-chart .intensity-chart { padding: 4px 4px 2px; }

.cp-table-wrap { overflow-x: auto; }
.cp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.cp-table th, .cp-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--surface0);
  white-space: nowrap;
}
.cp-table thead th {
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cp-table tbody th {
  color: var(--subtext);
  font-weight: 500;
  font-size: 11px;
}
.cp-empty {
  text-align: center;
  padding: 20px 10px;
}
.cp-empty .hint {
  font-size: 12px;
  color: var(--subtext);
  margin-top: 8px;
}

/* Diff highlighting in comparison table */
.cp-cell-max {
  background: rgba(166, 227, 161, 0.15) !important;
  font-weight: 600;
  color: #a6e3a1;
}

.cp-cell-min {
  background: rgba(243, 139, 168, 0.15) !important;
  font-weight: 600;
  color: #f38ba8;
}

.compare-track {
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

/* Decade-by-decade trends table */
.dt-host { margin: 12px 0; }
.dt-loading {
  font-size: 12px;
  color: var(--subtext);
  padding: 16px;
  text-align: center;
}
.dt-table-wrap { overflow-x: auto; }
.dt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.dt-table th, .dt-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--surface0);
}
.dt-table thead th {
  font-weight: 700;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--subtext);
  font-weight: 600;
}
.dt-table tbody th {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
.dt-row {
  transition: background-color 100ms ease;
}
.dt-row:hover {
  background: rgba(180, 190, 254, 0.05);
}
.dt-decade { width: 60px; }
.dt-named, .dt-major, .dt-ace { text-align: center; }
.dt-deadliest, .dt-costliest { font-size: 10px; color: var(--subtext); }
.dt-deadliest span, .dt-costliest span {
  color: var(--text);
  cursor: help;
  border-bottom: 1px dotted rgba(180, 190, 254, 0.3);
}
.dt-note {
  font-size: 10px;
  color: var(--subtext);
  margin: 8px 0 0;
  line-height: 1.4;
}

.wind-field-row { margin-top: 10px; }
.wf-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  user-select: none;
}
.wf-toggle:hover { border-color: var(--lavender); }
.wf-toggle input { margin: 0; cursor: pointer; }
.wind-swath { pointer-events: none; }

/* Impacts block (deaths + damage from Wikipedia) */
.impacts-block {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-left: 3px solid var(--cat-4);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}
.im-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}
.im-label {
  color: var(--subtext);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.im-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
  max-width: 65%;
}
.im-source {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--surface0);
  font-size: 10px;
  color: var(--subtext);
}
.im-source a { color: var(--sapphire); }
.storm-events-host {
  margin-top: 10px;
}
.storm-events-block {
  padding: 10px;
  border: 1px solid var(--surface0);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}
.se-row {
  display: grid;
  grid-template-columns: minmax(112px, 0.9fr) minmax(0, 1.4fr);
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--surface0) 72%, transparent);
}
.se-row:last-of-type {
  border-bottom: 0;
}
.se-label {
  color: var(--subtext);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.se-value {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}
.se-samples {
  list-style: none;
  margin: 8px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid color-mix(in srgb, var(--surface0) 72%, transparent);
  display: grid;
  gap: 5px;
}
.se-samples li {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 8px;
  color: var(--subtext);
  font-size: 11px;
}
.se-empty,
.storm-events-block--loading {
  color: var(--subtext);
  font-size: 12px;
  line-height: 1.45;
}
.se-source {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid color-mix(in srgb, var(--surface0) 72%, transparent);
  color: var(--text-dim);
  font-size: 10px;
}

/* Active storm badge (top-right, only shown during hurricane season when
   NHC is tracking storms). */
.active-badge {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.ab-main {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.ab-text,
.ab-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ab-status {
  color: var(--subtext);
  font-size: 10px;
  font-weight: 650;
}
.ab-pulse {
  display: inline-block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f38ba8;
  box-shadow: 0 0 12px #f38ba8;
  animation: ab-pulse 1.4s ease-in-out infinite;
}
.active-badge[data-state="updated"] .ab-pulse,
.active-badge[data-state="ok"] .ab-pulse {
  background: var(--success);
  box-shadow: 0 0 12px rgba(166, 227, 161, 0.78);
}
.active-badge[data-state="rate-limit"] .ab-pulse {
  background: var(--warning);
  box-shadow: 0 0 12px rgba(249, 226, 175, 0.82);
}
.active-badge[data-state="error"] .ab-pulse {
  background: var(--error);
  box-shadow: 0 0 12px rgba(243, 139, 168, 0.78);
}
@keyframes ab-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.85); }
  50%      { opacity: 1.0; transform: scale(1.15); }
}
.active-track, .active-forecast, .active-cone {
  filter: drop-shadow(0 0 6px rgba(137, 180, 250, 0.5));
}
.official-cone {
  mix-blend-mode: screen;
}
.official-forecast-track {
  stroke-linecap: round;
}
.official-observed-track {
  stroke-linecap: round;
}
.goes-realtime-pane {
  mix-blend-mode: screen;
}
.goes-realtime-image {
  filter: saturate(1.08) contrast(1.05);
}
.goes-live-badge {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 6px 11px;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.goes-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--sapphire);
  box-shadow: 0 0 12px rgba(116, 199, 236, 0.86);
}
.goes-live-badge[data-state="loading"] .goes-live-dot {
  background: var(--yellow);
  box-shadow: 0 0 12px rgba(249, 226, 175, 0.8);
}
.goes-live-badge[data-state="error"] .goes-live-dot,
.goes-live-badge[data-state="unavailable"] .goes-live-dot {
  background: var(--red);
  box-shadow: 0 0 12px rgba(243, 139, 168, 0.78);
}
.goes-live-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.goes-source-link {
  color: var(--sapphire);
  text-decoration: none;
}
.goes-source-link:hover {
  color: var(--lavender);
  text-decoration: underline;
}
.ensemble-track {
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.3));
}
.ensemble-gfs { /* GFS — blue */ }
.ensemble-ecmwf { /* ECMWF — green */ }
.ensemble-hwrf { /* HWRF — yellow */ }
.ab-link {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: all 120ms ease;
  cursor: pointer;
}
.ab-link:hover { 
  border-color: var(--lavender); 
  background: var(--surface0);
  transform: translateY(-1px);
}

.state-panel h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}
.state-sub {
  font-size: 11px;
  color: var(--subtext);
  margin: 0 0 12px;
}
.state-loading, .state-empty {
  font-size: 13px;
  color: var(--subtext);
  text-align: center;
  padding: 24px 12px;
  background: rgba(180, 190, 254, 0.02);
  border: 1px solid rgba(180, 190, 254, 0.08);
  border-radius: 10px;
  margin: 8px 0;
}
.state-empty.hint { font-size: 12px; }
.state-loading { animation: pulse-subtle 2s ease-in-out infinite; }
@keyframes pulse-subtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.state-storm-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.state-storm-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: all 120ms ease;
}
.state-storm-row:hover {
  background: var(--surface0);
  border-color: var(--lavender);
  transform: translateX(2px);
}
.ssr-name { font-weight: 600; color: var(--text); }
.ssr-year { color: var(--subtext); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.ssr-count { color: var(--subtext); font-size: 11px; }

@media (max-width: 720px) {
  .state-panel { width: calc(100% - 32px); right: 16px; left: 16px; }
}

@media (max-width: 720px) {
  .compare-panel { width: calc(100% - 32px); right: 16px; left: 16px; }
  .compare-tray { flex-wrap: wrap; bottom: auto; top: 80px; }
}

/* On this date panel */
.otd-content h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}
.otd-meta {
  font-size: 11px;
  color: var(--subtext);
  margin: 0 0 12px;
}
.otd-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.otd-item {
  padding: 10px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 8px;
  font-size: 12px;
  transition: all 120ms ease;
}
.otd-item:hover {
  background: var(--surface0);
  border-color: var(--lavender);
}
.otd-header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.otd-year {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--subtext);
  font-size: 11px;
  font-weight: 600;
  min-width: 40px;
}
.otd-link {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  padding: 0;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--lavender);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 120ms ease;
}
.otd-link:hover {
  color: var(--lavender);
}
.otd-details {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--subtext);
}
.otd-wind {
  font-weight: 600;
  color: var(--text);
}
.otd-date,
.otd-days {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (max-width: 720px) {
  .on-this-date-panel { width: calc(100% - 32px); right: 16px; left: 16px; }
}

/* Stats panel */
.stats-panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
}
.stats-panel h3 {
  font-size: 11px;
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtext);
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.bar-row .label {
  width: 110px;
  color: var(--subtext);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-row .bar {
  flex: 1;
  height: 14px;
  border-radius: 4px;
  background: var(--mantle);
  overflow: hidden;
  position: relative;
}
.bar-row .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cat-2), var(--cat-4));
  transition: width 200ms ease;
}
.bar-row .count {
  width: 40px;
  text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text);
}
.cold-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.cold-tag {
  background: var(--surface0);
  color: var(--subtext);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* `hidden` should always win over our display rules */
[hidden] { display: none !important; }

/* Info modal */
.info-modal {
  position: absolute;
  inset: 0;
  z-index: 2000;
  background: rgba(17, 17, 27, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.info-card {
  position: relative;
  max-width: 640px;
  width: 100%;
  padding: 28px 32px 24px;
  font-size: 13px;
  line-height: 1.6;
  max-height: 88vh;
  overflow-y: auto;
}
.info-card h2 { margin: 0 0 12px; font-size: 22px; }
.info-card h3 { margin: 16px 0 6px; font-size: 13px; color: var(--lavender); }
.info-card ul { padding-left: 20px; }
.data-provenance {
  margin: 18px 0 14px;
  padding: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-info);
}
.data-provenance h3 {
  margin-top: 0;
}
.provenance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.provenance-grid > div {
  min-width: 0;
}
.provenance-label,
.provenance-sources span,
.provenance-generator,
.provenance-empty {
  color: var(--subtext);
}
.provenance-label {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.provenance-grid strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}
.provenance-generator {
  margin-top: 12px;
}
.provenance-sources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 0 !important;
  list-style: none;
}
.provenance-sources li {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}
.provenance-sources strong,
.provenance-sources span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.provenance-empty {
  margin: 0;
}
@media (max-width: 520px) {
  .provenance-grid,
  .provenance-sources {
    grid-template-columns: 1fr;
  }
}
.info-card .meta {
  font-size: 11px;
  color: var(--subtext);
  margin-top: 16px;
}
.info-card a { color: var(--sapphire); }
.info-card code {
  background: var(--mantle);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Loading */
.loading {
  position: absolute;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--base);
  gap: 18px;
}
.loading.fade-out {
  opacity: 0;
  transition: opacity 380ms ease;
  pointer-events: none;
}
.spinner {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hurricane-icon {
  color: var(--lavender);
  animation: spin 2s linear infinite;
}

.loading p { color: var(--subtext); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Leaflet overrides */
.leaflet-tooltip {
  background: var(--crust);
  color: var(--text);
  border: 1px solid var(--surface0);
  box-shadow: var(--shadow);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
}
.leaflet-tooltip:before, .leaflet-tooltip-top:before { display: none; }
.leaflet-control-attribution {
  background: var(--crust) !important;
  color: var(--subtext) !important;
  border-radius: 6px 0 0 0 !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--sapphire) !important; }
.leaflet-control-zoom a {
  background: var(--mantle) !important;
  color: var(--text) !important;
  border: 1px solid var(--surface0) !important;
}
.leaflet-control-zoom a:hover { background: var(--surface0) !important; }

/* Leaflet circleMarkers render as SVG <path>; CSS transform on SVG paths
   scales relative to the SVG origin, not the dot's center, so hover-scaling
   in CSS would flicker. We change radius/weight via setStyle() in map.js. */
.landfall-marker { cursor: pointer; }

/* Track-line stroke color is set per-segment via Leaflet's `color` option,
   so we don't override it here — only width/opacity. */
.track-line { stroke-opacity: 0.9; stroke-linecap: round; }
.track-line.fade { stroke-opacity: 0.35; }

/* Hurricane animation glyph (Leaflet divIcon).
   The wrapper has Leaflet-managed transforms; we only style the inner SVG. */
.hurricane-glyph { background: transparent; border: none; pointer-events: none; }
.hurricane-glyph .hg-inner {
  display: block;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.35));
}
.hurricane-glyph svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hurricane-glyph .hg-spin {
  /* Northern-hemisphere cyclones rotate counter-clockwise (viewed from above). */
  transform-origin: 50% 50%;
  transform-box: fill-box;
  animation: hg-rotate 2.4s linear infinite;
}
@keyframes hg-rotate { to { transform: rotate(-360deg); } }

/* Bottom control bars stack vertically so they don't collide when more than
   one is active. Order from bottom up:
     8px — animation controls (primary playback, fixed to viewport)
     86px — radar controls
     92px — compare tray only while animation controls are open */

.anim-controls {
  position: fixed;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2400;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12px;
  max-width: calc(100vw - 32px);
}
.anim-btn {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 120ms ease;
}
.anim-btn:hover { 
  background: var(--surface0); 
  border-color: var(--lavender);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.anim-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.15);
}
.anim-close { color: var(--subtext); }

.anim-scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 220px;
  height: 4px;
  background: var(--surface0);
  border-radius: 4px;
  outline: none;
  transition: box-shadow 120ms ease;
}
.anim-scrubber:hover {
  box-shadow: 0 0 8px rgba(180, 190, 254, 0.3);
}
.anim-scrubber:focus {
  box-shadow: 0 0 12px rgba(180, 190, 254, 0.4);
}
.anim-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--lavender);
  cursor: pointer;
  border: 2px solid var(--mantle);
  transition: all 120ms ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.anim-scrubber::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 10px rgba(180, 190, 254, 0.3);
}
.anim-scrubber::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--lavender);
  cursor: pointer;
  border: 2px solid var(--mantle);
  transition: all 120ms ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.anim-scrubber::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 10px rgba(180, 190, 254, 0.3);
}

.anim-speed {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 120ms ease;
}
.anim-speed:hover {
  border-color: var(--lavender);
  background: rgba(180, 190, 254, 0.05);
}
.anim-speed:focus {
  border-color: var(--lavender);
  background: rgba(180, 190, 254, 0.08);
  outline: none;
}

.anim-hud {
  display: flex;
  flex-direction: column;
  min-width: 220px;
  line-height: 1.3;
}
.anim-title {
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
}
.anim-meta {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--subtext);
}

.play-anim-btn {
  margin-top: 10px;
  width: 100%;
  background: linear-gradient(135deg, var(--lavender), var(--blue));
  color: var(--base);
  border: 1px solid rgba(180, 190, 254, 0.4);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 120ms ease;
  will-change: transform, background;
  box-shadow: 0 4px 12px rgba(180, 190, 254, 0.25);
}
.play-anim-btn:hover {
  background: linear-gradient(135deg, var(--blue), #89b4fa);
  border-color: rgba(180, 190, 254, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(137, 180, 250, 0.35);
}
.play-anim-btn:active {
  transform: translateY(0);
}
.play-anim-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.2);
}
.play-anim-btn .play-icon {
  width: 0;
  height: 0;
  border-left: 8px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

/* Sticky action bar override — compact sizing */
.panel-actions-sticky .play-anim-btn {
  margin: 0;
  padding: 7px 10px;
  font-size: 11.5px;
  width: auto;
  flex: 1;
}
.panel-actions-sticky .pin-btn {
  padding: 7px 10px;
  font-size: 11.5px;
}

.panel-playback-host {
  margin-top: 10px;
  width: 100%;
}

.panel-playback-host[hidden] {
  display: none !important;
}

.panel-playback-host .anim-controls,
.anim-controls-inline {
  position: static !important;
  inset: auto !important;
  transform: none !important;
  z-index: auto !important;
  display: grid !important;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  max-width: none;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(24, 24, 37, 0.72);
}

.panel-playback-host .anim-scrubber {
  width: 100%;
}

.panel-playback-host .anim-btn {
  width: auto;
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 800;
}

.panel-playback-host .anim-speed {
  height: 30px;
  padding: 0 7px;
}

.panel-playback-host .anim-hud {
  grid-column: 1 / -1;
  min-width: 0;
  padding-top: 2px;
}

.panel-playback-host .anim-radar-toggle {
  grid-column: 1 / -1;
  justify-self: start;
}

.play-anim-btn.is-playing {
  background: linear-gradient(135deg, var(--peach), var(--yellow));
  border-color: rgba(250, 179, 135, 0.55);
  box-shadow: 0 6px 18px rgba(250, 179, 135, 0.25);
}

.play-anim-btn.is-playing .play-icon {
  width: 12px;
  height: 12px;
  border: 0;
  background: linear-gradient(90deg, currentColor 0 34%, transparent 34% 66%, currentColor 66% 100%);
}

.anim-radar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 8px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: all 120ms ease;
}
.anim-radar-toggle:hover { 
  border-color: var(--lavender);
  background: rgba(180, 190, 254, 0.05);
}
.anim-radar-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.15);
}
.anim-radar-toggle input { margin: 0; cursor: pointer; }
.anim-radar-disabled {
  color: var(--overlay);
  cursor: default;
  border-style: dashed;
}
.anim-radar-disabled:hover { border-color: var(--surface0); }

@media (max-width: 720px) {
  .anim-controls { bottom: 8px; top: auto; flex-wrap: wrap; }
  .anim-scrubber { width: 100%; order: 99; }
  .anim-radar-toggle { font-size: 10px; padding: 4px 7px; }
}

/* NEXRAD radar overlay — local PNGs are post-processed with a tRNS chunk
   (palette index 0 = black = transparent) so the basemap shows through
   no-echo areas natively. Saturation boost helps weak echoes on the dark
   basemap. Saved-via-IEM frames may still be opaque-black; the screen
   blend mode below keeps those readable too without washing out the dark
   basemap as `lighten` did. */
.radar-overlay-img {
  mix-blend-mode: screen;
  filter: saturate(1.15) contrast(1.05);
  pointer-events: none;
}

.radar-quick-btn {
  background: transparent;
  border: 1px solid var(--surface0);
  color: var(--subtext);
  padding: 1px 5px;
  margin-left: 6px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  vertical-align: middle;
  transition: all 120ms ease;
}
.radar-quick-btn:hover {
  background: var(--surface0);
  color: var(--text);
  border-color: var(--lavender);
  transform: translateY(-1px);
}
.radar-quick-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.15);
}

.radar-controls {
  position: absolute;
  bottom: 86px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  padding: 10px 14px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 280px;
  max-width: calc(100vw - 32px);
}
.radar-title {
  font-weight: 700;
  color: var(--text);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.radar-pip {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f38ba8;
  box-shadow: 0 0 8px #f38ba8;
  animation: radar-pip 1.4s ease-in-out infinite;
}
@keyframes radar-pip {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50%      { opacity: 1.0; transform: scale(1.15); }
}
.radar-controls-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.radar-btn {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  color: var(--text);
  width: 30px;
  height: 28px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 120ms ease;
}
.radar-btn:hover { 
  background: var(--surface0); 
  border-color: var(--lavender);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.radar-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.15);
}
.radar-time {
  flex: 1;
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text);
  padding: 0 6px;
}
.radar-source {
  font-size: 10px;
  color: var(--subtext);
}
.radar-close { color: var(--subtext); }

@media (max-width: 720px) {
  .radar-controls { bottom: auto; top: 140px; }
}

/* Responsive */
@media (max-width: 720px) {
  .filters { width: calc(100% - 32px); top: auto; bottom: 16px; }
  .legend { display: none; }
  .storm-panel { width: calc(100% - 32px); right: 16px; left: 16px; bottom: auto; top: 80px; max-height: 60vh; }
  .stats-panel { width: calc(100% - 32px); right: 16px; left: 16px; }
  .app-header { width: calc(100% - 32px); }
}

/* Custom scrollbars for better visual cohesion */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface1);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: all 120ms ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--lavender);
  background-clip: content-box;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface1) transparent;
}

/* Search results entrance animation */
@keyframes searchResultFadeDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-results li {
  animation: searchResultFadeDown 200ms cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.search-results li:nth-child(1) { animation-delay: 0ms; }
.search-results li:nth-child(2) { animation-delay: 40ms; }
.search-results li:nth-child(3) { animation-delay: 80ms; }
.search-results li:nth-child(4) { animation-delay: 120ms; }
.search-results li:nth-child(5) { animation-delay: 160ms; }

/* Enhanced loading animation */
@keyframes spinSmooth {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.hurricane-icon {
  animation: spinSmooth 2.5s cubic-bezier(0.4, 0.0, 0.2, 1.0) infinite;
}

/* Enhanced reduced-motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Phase 2: Panel Transitions & Animations */
.filters,
.storm-panel,
.stats-panel,
.info-modal,
.glossary-modal,
.legend {
  animation: slideInPanel 220ms cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

@keyframes slideInPanel {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Phase 2: Enhanced Hover States & Transitions */
.cat-btn {
  transition: all 120ms ease;
}

.cat-btn:hover:not(:disabled) {
  border-color: var(--lavender);
  background-color: rgba(170, 183, 255, 0.08);
  transform: translateY(-1px);
}

.cat-btn:active:not(:disabled) {
  transform: translateY(0);
  background-color: rgba(170, 183, 255, 0.15);
}

/* Stat tiles hover elevation */
.stat-tile,
.stat-group {
  transition: all 150ms cubic-bezier(0.2, 0.6, 0.3, 1);
}

.stat-tile:hover,
.stat-group:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

/* List item hover effects */
.storm-list-item,
.landfall-row,
.similar-storm-row {
  transition: all 100ms ease;
}

.storm-list-item:hover,
.landfall-row:hover,
.similar-storm-row:hover {
  background-color: rgba(170, 183, 255, 0.06);
  transform: translateX(2px);
}

/* Phase 2: Typography Scale Refinement */
h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

h3 {
  font-size: 16px;
  font-weight: 600;
}

.small-label,
.label-secondary {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--subtext);
}

/* Phase 2: Section Separators */
.section-divider {
  margin: 16px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 200ms ease;
}

.section-divider:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* Phase 2: Empty State Styling */
.empty-state,
.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--subtext);
  border-radius: var(--radius-md);
  background: rgba(170, 183, 255, 0.04);
}

.empty-state-icon,
.no-results-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title,
.no-results-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state-text,
.no-results-text {
  font-size: 14px;
  line-height: 1.5;
}

/* Phase 2: Panel Animation Stagger for Multiple Items */
.storm-list-item,
.landfall-row {
  animation: slideInItem 200ms cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.storm-list-item:nth-child(1),
.landfall-row:nth-child(1) { animation-delay: 0ms; }
.storm-list-item:nth-child(2),
.landfall-row:nth-child(2) { animation-delay: 30ms; }
.storm-list-item:nth-child(3),
.landfall-row:nth-child(3) { animation-delay: 60ms; }
.storm-list-item:nth-child(4),
.landfall-row:nth-child(4) { animation-delay: 90ms; }
.storm-list-item:nth-child(5),
.landfall-row:nth-child(5) { animation-delay: 120ms; }
.storm-list-item:nth-child(n+6),
.landfall-row:nth-child(n+6) { animation-delay: 150ms; }

@keyframes slideInItem {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Phase 2: Input Focus Enhancement */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 
    inset 0 0 0 2px rgba(170, 183, 255, 0.5),
    0 0 0 3px var(--focus-ring);
}

/* Phase 2: Button Transition Improvements */
button {
  transition: all 100ms ease;
}

button:active {
  transition: all 50ms ease;
}

/* Phase 2: Disabled State Consistency */
button:disabled,
input:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}



/* Phase 3: Elevation & Depth System */
.glass {
  position: relative;
  overflow: hidden;
}

.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, transparent 50%, rgba(255, 255, 255, 0.02) 100%);
  pointer-events: none;
  border-radius: 14px;
}

/* Elevation levels for layering */
.elevation-1 { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
.elevation-2 { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }
.elevation-3 { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25); }
.elevation-4 { box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3); }

/* Phase 3: Enhanced Focus States */
input:focus-visible::after,
select:focus-visible::after,
textarea:focus-visible::after,
button:focus-visible::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 2px solid var(--lavender);
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.5;
}

/* Phase 3: Stat Tiles Enhancement */
.stat-grid .stat {
  position: relative;
  overflow: hidden;
}

.stat-grid .stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--lavender) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 200ms ease;
}

.stat-grid .stat:hover::before {
  opacity: 1;
}

/* Phase 3: Better Panel Header */
.storm-panel h2,
.stats-panel h2 {
  position: relative;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.storm-panel h2::after,
.stats-panel h2::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 2px;
  width: 40px;
  background: linear-gradient(90deg, var(--lavender), transparent);
}

/* Phase 3: Category Button Polish */
.cat-btn {
  position: relative;
  overflow: hidden;
}

.cat-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 150ms ease;
}

.cat-btn:hover::before {
  opacity: 1;
}

/* Phase 3: Search Results Polish */
.search-results {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(170, 183, 255, 0.15);
}

.search-results li {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.search-results li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--lavender);
  opacity: 0;
  transition: opacity 150ms ease;
}

.search-results li:hover {
  background: rgba(170, 183, 255, 0.1);
}

.search-results li:hover::before {
  opacity: 1;
}

/* Phase 3: Checkbox & Toggle Polish */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--lavender);
  cursor: pointer;
  transition: all 150ms ease;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
  filter: brightness(1.2);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
}

/* Phase 3: Filter Row Polish */
.filter-row {
  transition: all 150ms ease;
  border-radius: 8px;
  padding: 8px;
  margin: -8px;
}

.filter-row:focus-within {
  background: rgba(170, 183, 255, 0.05);
}

/* Phase 3: Link & Interactive Text Styling */
a, [role="button"] {
  position: relative;
  text-decoration: none;
  transition: color 150ms ease;
}

a:hover, [role="button"]:hover {
  color: var(--lavender);
}

a:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Phase 3: Better State Feedback */
.filter-row--year.active-filter {
  background: linear-gradient(135deg, rgba(137, 180, 250, 0.12), rgba(137, 180, 250, 0.06));
  border: 1px solid rgba(137, 180, 250, 0.4);
  box-shadow: inset 0 0 0 1px rgba(137, 180, 250, 0.2);
}

/* Phase 3: Reduced Motion Enhancements */
@media (prefers-reduced-motion: reduce) {
  .glass::before,
  .stat-grid .stat::before,
  .storm-panel h2::after,
  .cat-btn::before,
  .search-results li::before {
    display: none;
  }

  .stat-tile:hover,
  .stat-group:hover,
  .cat-btn:hover {
    transform: none;
  }

  .stat-tile,
  .cat-btn,
  button,
  input,
  select {
    transition: none !important;
  }
}

/* Phase 3: Print Styles for Better Rendering */
@media print {
  .glass {
    background: white;
    border: 1px solid #ddd;
    box-shadow: none;
  }

  .icon-btn,
  .text-btn,
  .cat-btn {
    border: 1px solid #999;
  }

  button:disabled {
    opacity: 1;
    background: #f0f0f0;
  }
}

/* Phase 4: Advanced Responsive & Tablet Experience */
@media (max-width: 1024px) {
  .filters {
    width: 300px;
  }

  .app-header {
    gap: 10px;
  }

  .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow: hidden;
  }
}

@media (max-width: 768px) {
  .filters {
    width: 100%;
    max-width: 320px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  input[type="number"],
  input[type="search"],
  select {
    font-size: 16px; /* Prevent iOS zoom on input focus */
  }
}

@media (max-width: 640px) {
  .filters {
    max-width: none;
    width: calc(100% - 32px);
  }

  .app-header {
    width: calc(100% - 32px);
    flex-wrap: wrap;
    gap: 8px;
  }

  .title-block h1 {
    font-size: 18px;
  }

  .title-block .subtitle {
    font-size: 11px;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel {
    width: calc(100% - 32px) !important;
    max-height: 70vh;
    border-radius: 12px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .cat-btn {
    font-size: 12px;
    padding: 6px 8px;
    min-height: 32px;
  }

  .search-results {
    max-height: 180px;
  }

  .legend {
    display: none;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .header-actions {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
}

/* Phase 4: Ultra-Responsive (Mobile Phones) */
@media (max-width: 480px) {
  .app-header {
    padding: 8px 10px;
    gap: 6px;
  }

  .title-block h1 {
    font-size: 16px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .header-actions {
    gap: 4px;
  }

  .filters {
    padding: 12px 12px;
  }
}

/* ============================================================================
   TIMELINE — 174-year ribbon at bottom of viewport
   ============================================================================ */
.timeline-ribbon {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 140px;
  z-index: 800;
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--glass-edge);
  transition: height 200ms ease, padding 200ms ease;
}

.timeline-ribbon.collapsed {
  height: 44px;
}

.timeline-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 120ms ease;
}

.timeline-toggle:hover {
  background: rgba(180, 190, 254, 0.1);
  border-radius: 8px;
}

.timeline-toggle:focus-visible {
  outline: var(--focus-ring);
  border-radius: 8px;
}

.timeline-toggle svg {
  transition: transform 200ms ease;
}

.timeline-ribbon.collapsed .timeline-toggle svg {
  transform: rotate(180deg);
}

.timeline-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  transition: opacity 200ms ease;
}

.timeline-ribbon.collapsed .timeline-inner {
  opacity: 0;
  pointer-events: none;
}

/* Timeline axis — the bar chart container */
.timeline-axis {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5px;
  background: rgba(30, 30, 46, 0.3);
  border: 1px solid var(--glass-edge);
  border-radius: 8px;
  padding: 4px 2px 2px 2px;
  cursor: crosshair;
  user-select: none;
  transition: background 120ms ease;
}

.timeline-axis:hover {
  background: rgba(30, 30, 46, 0.5);
}

.timeline-axis.dragging {
  background: rgba(30, 30, 46, 0.6);
}

/* Year bars */
.tl-bar {
  flex: 1;
  height: 100%;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: all 80ms ease;
  opacity: 0.85;
  min-height: 4px;
  position: relative;
}

.tl-bar:hover {
  opacity: 1;
  filter: brightness(1.2);
}

.tl-bar.tl-empty {
  opacity: 0.3;
}

.tl-bar.tl-empty:hover {
  opacity: 0.5;
}

.tl-bar:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--blue);
}

/* Selection range highlight */
.tl-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(180, 190, 254, 0.2);
  border: 2px solid var(--blue);
  border-radius: 4px;
  pointer-events: none;
  transition: all 80ms ease;
}

/* Year labels below the timeline */
.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--subtext);
  padding: 0 4px;
  text-align: center;
  line-height: 1.2;
}

.timeline-labels span {
  flex: 1;
}

/* Responsive timeline */
@media (max-width: 1200px) {
  .timeline-ribbon {
    height: 120px;
    padding: 6px 10px;
    gap: 10px;
  }

  .timeline-ribbon.collapsed {
    height: 40px;
  }

  .timeline-toggle {
    width: 36px;
    height: 36px;
  }

  .timeline-labels {
    font-size: 10px;
  }
}

@media (max-width: 768px) {
  .timeline-ribbon {
    height: 110px;
    padding: 6px 8px;
    gap: 8px;
  }

  .timeline-ribbon.collapsed {
    height: 38px;
  }

  .timeline-labels {
    font-size: 9px;
  }

  .tl-bar {
    min-height: 3px;
  }
}

@media (max-width: 480px) {
  .timeline-ribbon {
    height: 100px;
    padding: 4px 6px;
    gap: 6px;
  }

  .timeline-ribbon.collapsed {
    height: 36px;
  }

  .timeline-toggle {
    width: 32px;
    height: 32px;
  }

  .timeline-labels {
    font-size: 8px;
  }

  .filter-row {
    gap: 4px;
  }

  .cat-toggles {
    grid-template-columns: repeat(3, 1fr);
  }

  .storm-panel h2,
  .stats-panel h2 {
    font-size: 18px;
  }

  .cat-pill {
    font-size: 10px;
    padding: 2px 6px;
  }

  input[type="number"],
  input[type="search"],
  select {
    font-size: 16px;
    height: 44px; /* WCAG AAA touch target */
  }

  .stat-tile,
  .stat-group {
    padding: 12px;
  }

  .text-btn {
    font-size: 12px;
    height: 36px;
  }
}

/* Phase 4: Landscape Mobile */
@media (max-height: 600px) and (max-width: 900px) {
  .filters {
    max-height: calc(100vh - 200px);
  }

  .storm-panel,
  .stats-panel {
    max-height: 85vh;
  }

  .legend {
    display: none;
  }
}

/* Phase 4: Large Screens (Desktop+) */
@media (min-width: 1600px) {
  .filters {
    width: 340px;
  }

  .legend {
    width: 200px;
  }

  .app-header {
    max-width: 720px;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel {
    width: 420px;
  }
}

/* Phase 4: Ultra-Wide Screens (4K+) */
@media (min-width: 2560px) {
  .filters {
    width: 380px;
    padding: 18px 20px;
  }

  .app-header {
    max-width: 800px;
    padding: 12px 16px;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel {
    width: 480px;
  }

  input[type="number"],
  input[type="search"],
  select {
    font-size: 15px;
    height: 44px;
  }

  .cat-pill {
    font-size: 12px;
    padding: 4px 10px;
  }
}

/* Phase 4: Landscape Optimization */
@media (orientation: landscape) and (max-height: 500px) {
  .app-header {
    top: 8px;
    padding: 6px 10px;
    gap: 8px;
  }

  .title-block h1 {
    font-size: 16px;
  }

  .filters {
    top: auto;
    bottom: 8px;
  }

  .legend {
    bottom: 8px;
  }

  .storm-panel,
  .stats-panel {
    max-height: calc(100vh - 100px);
  }
}

/* Phase 4: Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  button,
  input,
  select,
  [role="button"] {
    min-height: 44px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .cat-btn {
    min-height: 40px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  /* Remove hover effects on touch devices */
  button:hover {
    transform: none;
    background: inherit;
  }

  .stat-tile:hover,
  .stat-group:hover {
    transform: none;
  }

  .cat-btn:hover:not(:disabled) {
    background: inherit;
  }

  /* Use active states instead */
  button:active {
    opacity: 0.8;
  }

  .cat-btn:active {
    background: rgba(170, 183, 255, 0.15);
  }
}

/* Phase 4: High DPI (Retina) Adjustments */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
  .glass {
    border-width: 0.5px;
  }

  .icon-btn,
  .cat-btn,
  input[type="number"],
  input[type="search"],
  select {
    border-width: 0.5px;
  }
}

/* Phase 4: Dark Mode Only Features */
@media (prefers-color-scheme: dark) {
  .glass {
    backdrop-filter: blur(16px) saturate(140%);
  }

  .shadow,
  .shadow-sm,
  .shadow-md,
  .shadow-lg,
  .shadow-xl {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.1));
  }
}

/* Phase 4: Light Mode Only Features */
@media (prefers-color-scheme: light) {
  .glass {
    backdrop-filter: blur(12px) saturate(130%);
  }

  .icon-btn {
    background: rgba(255, 255, 255, 0.4);
  }
}

/* ==========================================================================
   Premium refinement layer
   --------------------------------------------------------------------------
   Consolidates missing secondary-surface styling and corrects late appended
   overrides without changing the app architecture.
   ========================================================================== */

:root {
  --text-secondary: var(--subtext);
  --text-dim: var(--overlay);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --control-bg: rgba(17, 17, 27, 0.72);
  --control-bg-hover: rgba(180, 190, 254, 0.10);
  --focus-color: rgba(180, 190, 254, 0.62);
  --focus-shadow: 0 0 0 3px rgba(180, 190, 254, 0.24);
  --surface-sunken: rgba(17, 17, 27, 0.54);
  --surface-raised: rgba(49, 50, 68, 0.72);
}

html.light-theme {
  --control-bg: rgba(255, 255, 255, 0.72);
  --control-bg-hover: rgba(30, 102, 245, 0.08);
  --focus-color: rgba(124, 58, 237, 0.52);
  --focus-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
  --surface-sunken: rgba(255, 255, 255, 0.64);
  --surface-raised: rgba(255, 255, 255, 0.78);
}

[hidden] {
  display: none !important;
}

.app-header.glass,
.settings-menu.glass {
  overflow: visible;
}

.app-header {
  position: absolute;
  top: 16px;
  left: 12px;
  max-width: min(960px, calc(100vw - 24px));
}

.brand-mark {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  object-fit: cover;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.34));
}

.title-block {
  min-width: 0;
}

.title-block .subtitle {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.subtitle-sep {
  color: var(--overlay);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn,
.text-btn,
.action-btn,
.export-btn,
.settings-pill,
.settings-action,
.cat-btn,
.radar-btn,
.anim-btn {
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:focus-visible,
.text-btn:focus-visible,
.action-btn:focus-visible,
.export-btn:focus-visible,
.settings-pill:focus-visible,
.settings-action:focus-visible,
.cat-btn:focus-visible,
.close-btn:focus-visible,
.radar-btn:focus-visible,
.anim-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
  box-shadow: var(--focus-shadow);
}

input[type="number"],
input[type="search"],
select {
  background: var(--surface-sunken);
  border-color: rgba(205, 214, 244, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

html.light-theme input[type="number"],
html.light-theme input[type="search"],
html.light-theme select {
  border-color: rgba(76, 79, 105, 0.16);
}

input[type="number"]:focus,
input[type="search"]:focus,
select:focus {
  background: var(--surface-raised);
  border-color: var(--focus-color);
}

.filters {
  position: absolute;
  top: 100px;
  left: 12px;
  right: auto;
  transition: opacity 180ms ease, transform 180ms ease;
}

.filters.collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-100% - 24px));
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.filter-group-label,
.layer-select-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtext);
}

.filter-layer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
}

.layer-select {
  display: grid;
  grid-template-columns: 1fr 84px;
  align-items: center;
  gap: 10px;
}

.filter-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.visible-count {
  padding: 4px 8px;
  border: 1px solid rgba(205, 214, 244, 0.10);
  border-radius: 999px;
  background: rgba(180, 190, 254, 0.06);
  white-space: nowrap;
}

.filter-legend {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(205, 214, 244, 0.10);
}

.filter-legend-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.filter-legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--subtext);
  line-height: 1.25;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 12px;
  z-index: 2600;
  width: min(380px, calc(100vw - 24px));
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  line-height: 1.35;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(108px, 0.9fr) minmax(0, 1.4fr);
  align-items: center;
  gap: 10px;
}

.settings-row--action,
.settings-row:has(.toggle-row) {
  grid-template-columns: 1fr;
}

.settings-label {
  color: var(--subtext);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.settings-pillgroup {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.settings-pill,
.settings-action {
  min-height: 34px;
  border: 1px solid rgba(205, 214, 244, 0.12);
  border-radius: 8px;
  background: var(--surface-sunken);
  color: var(--text);
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.settings-pill:hover,
.settings-action:hover {
  background: var(--control-bg-hover);
  border-color: rgba(180, 190, 254, 0.34);
  transform: translateY(-1px);
}

.settings-pill.on,
.settings-pill[aria-checked="true"] {
  background: linear-gradient(135deg, var(--lavender), var(--sapphire));
  border-color: transparent;
  color: var(--base);
}

.settings-action {
  width: 100%;
  justify-content: center;
}

.settings-meta {
  padding-top: 10px;
  border-top: 1px solid rgba(205, 214, 244, 0.10);
  color: var(--subtext);
  font-size: 12px;
}

.search-results {
  padding: 5px;
  border-radius: 12px;
}

.search-results li {
  border: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-section-label {
  color: var(--overlay);
  cursor: default !important;
  font-size: 10px !important;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-empty {
  align-items: flex-start !important;
  flex-direction: column;
  gap: 4px !important;
  padding: 12px !important;
  color: var(--subtext);
  cursor: default !important;
}

.search-empty strong {
  color: var(--text);
  font-size: 13px;
}

.search-empty span {
  font-size: 12px;
  line-height: 1.45;
}

.search-result-spark-host {
  width: 58px;
  min-width: 58px;
  height: 22px;
  display: inline-flex;
  align-items: center;
}

.search-result-text {
  min-width: 0;
}

.search-result-meta {
  color: var(--subtext);
}

.storm-panel,
.stats-panel,
.compare-panel,
.state-panel,
.on-this-date-panel {
  position: absolute;
  top: 110px;
  right: 16px;
  left: auto;
  bottom: 160px;
  background: rgba(24, 24, 37, 0.84);
}

section.storm-panel.glass {
  position: absolute;
  top: 8px;
  right: 16px;
  left: auto;
  bottom: 8px;
  max-height: calc(100vh - 16px);
}

html.light-theme .storm-panel,
html.light-theme .stats-panel,
html.light-theme .compare-panel,
html.light-theme .state-panel,
html.light-theme .on-this-date-panel {
  background: rgba(255, 255, 255, 0.90);
}

.panel-sticky-header {
  position: sticky;
  top: -18px;
  z-index: 2;
  margin: -18px -22px 14px;
  padding: 18px 44px 14px 22px;
  background: linear-gradient(180deg, rgba(24, 24, 37, 0.96), rgba(24, 24, 37, 0.86));
  border-bottom: 1px solid rgba(205, 214, 244, 0.10);
  backdrop-filter: blur(14px) saturate(135%);
}

html.light-theme .panel-sticky-header {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 241, 245, 0.88));
}

.storm-panel-header h2 {
  border: 0;
  padding: 0;
  margin: 0 0 8px;
}

.storm-panel-header h2::after {
  display: none;
}

.panel-actions-sticky {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.biography-text {
  margin: 14px 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(205, 214, 244, 0.10);
  border-radius: 10px;
  background: rgba(180, 190, 254, 0.055);
  color: var(--text-secondary);
  font-size: 13px;
  font-style: italic;
  line-height: 1.58;
}

.storm-loading-state,
.storm-error-state {
  display: grid;
  gap: 10px;
  align-content: center;
  min-height: 180px;
  padding: 24px;
  color: var(--subtext);
  text-align: center;
}

.storm-loading-dot {
  width: 34px;
  height: 34px;
  justify-self: center;
  border-radius: 50%;
  border: 3px solid rgba(180, 190, 254, 0.18);
  border-top-color: var(--lavender);
  animation: spin 0.9s linear infinite;
}

.storm-error-state {
  border: 1px solid rgba(243, 139, 168, 0.28);
  border-radius: 12px;
  background: rgba(243, 139, 168, 0.08);
}

.storm-error-state strong {
  color: var(--error);
}

.stat-grid .stat {
  background: var(--surface-sunken);
  border-color: rgba(205, 214, 244, 0.10);
}

.stat .value {
  line-height: 1.25;
}

.closest-pass-row,
.impacts-block,
.intensity-chart,
.dt-table-wrap,
.cp-table-wrap {
  background: var(--surface-sunken);
  border-color: rgba(205, 214, 244, 0.10);
}

.landfall-list li,
.similar-storm-row,
.state-storm-row {
  border-color: rgba(205, 214, 244, 0.10);
}

.action-row,
.export-row,
.chart-export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.action-btn,
.export-btn {
  min-height: 36px;
  border-radius: 8px;
}

.export-label {
  color: var(--subtext);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hm-toast-host {
  position: fixed;
  right: 18px;
  bottom: 158px;
  z-index: 3200;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.hm-toast {
  padding: 10px 12px;
  border: 1px solid rgba(205, 214, 244, 0.14);
  border-radius: 10px;
  background: rgba(24, 24, 37, 0.92);
  color: var(--text);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.hm-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.hm-toast--warn {
  border-color: rgba(249, 226, 175, 0.34);
}

.hm-update-prompt {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
}

.hm-update-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.hm-update-copy strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}

.hm-update-copy span {
  color: var(--subtext);
  font-size: 12px;
  line-height: 1.35;
}

.hm-update-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hm-update-reload {
  min-height: 34px;
  padding-inline: 12px;
}

.hm-update-dismiss {
  width: 34px;
  height: 34px;
}

.keyboard-palette {
  border: 0;
  padding: 0;
  width: min(680px, calc(100vw - 32px));
  background: var(--glass-bg);
  color: var(--text);
  box-shadow: var(--shadow-xl);
}

.keyboard-palette::backdrop {
  background: rgba(17, 17, 27, 0.64);
  backdrop-filter: blur(3px);
}

.palette-content {
  padding: 22px;
}

.palette-header,
.glossary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.palette-header h2,
.glossary-header h2 {
  margin: 0;
  font-size: 20px;
}

.palette-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.shortcut-group {
  padding: 12px;
  border: 1px solid rgba(205, 214, 244, 0.10);
  border-radius: 10px;
  background: var(--surface-sunken);
}

.shortcut-group h3 {
  margin: 0 0 10px;
  color: var(--lavender);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--subtext);
  font-size: 13px;
}

kbd {
  min-width: 28px;
  padding: 3px 6px;
  border: 1px solid rgba(205, 214, 244, 0.16);
  border-radius: 6px;
  background: var(--control-bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  text-align: center;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.22);
}

.palette-footer {
  margin: 16px 0 0;
  color: var(--subtext);
  font-size: 12px;
}

.glossary-modal {
  position: fixed;
  inset: 0;
  z-index: 2800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 17, 27, 0.64);
  backdrop-filter: blur(3px);
}

.glossary-content {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
  background: var(--glass-bg);
  box-shadow: var(--shadow-xl);
}

.glossary-search {
  width: 100%;
  margin-bottom: 14px;
}

.glossary-list {
  display: grid;
  gap: 10px;
}

.glossary-item {
  padding: 12px;
  border: 1px solid rgba(205, 214, 244, 0.10);
  border-radius: 10px;
  background: var(--surface-sunken);
}

.glossary-term {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 14px;
}

.glossary-definition {
  margin: 0;
  color: var(--subtext);
  font-size: 13px;
  line-height: 1.5;
}

.onb-overlay {
  position: fixed;
  inset: 0;
  z-index: 2900;
  background: rgba(17, 17, 27, 0.52);
  transition: opacity 180ms ease;
}

.onb-overlay.fade-out {
  opacity: 0;
}

.onb-spotlight {
  position: fixed;
  border: 2px solid rgba(180, 190, 254, 0.72);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(17, 17, 27, 0.42), 0 0 28px rgba(180, 190, 254, 0.28);
  pointer-events: none;
  transition: all 180ms ease;
}

.onb-card {
  position: fixed;
  width: min(340px, calc(100vw - 32px));
  padding: 16px;
}

.onb-step {
  color: var(--sapphire);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.onb-title {
  margin: 6px 0 6px;
  color: var(--text);
  font-size: 18px;
}

.onb-body {
  margin: 0 0 14px;
  color: var(--subtext);
  font-size: 13px;
  line-height: 1.55;
}

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

.onb-nav {
  display: flex;
  gap: 8px;
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .header-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .settings-menu {
    left: 12px;
    right: auto;
  }
}

@media (max-width: 720px) {
  .app-header {
    left: 8px;
    top: 8px;
    width: calc(100vw - 16px);
    max-width: none;
  }

  .header-actions {
    max-height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .filters {
    left: 8px;
    right: 8px;
    top: 142px;
    bottom: auto;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 252px);
  }

  .filters.collapsed {
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
  }

  .filter-layer-grid {
    grid-template-columns: 1fr;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel,
  section.storm-panel.glass {
    top: 132px;
    left: 8px;
    right: 8px;
    bottom: 104px;
    width: auto !important;
    max-width: none;
    max-height: none;
  }

  .panel-actions-sticky {
    grid-template-columns: 1fr;
  }

  .settings-menu {
    left: 8px;
    right: 8px;
    top: calc(100% + 8px);
    width: auto;
  }

  .settings-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .settings-pillgroup {
    justify-content: flex-start;
  }

  .palette-shortcuts {
    grid-template-columns: 1fr;
  }

  .hm-toast-host {
    right: 8px;
    left: 8px;
    bottom: 112px;
  }

  .hm-update-prompt {
    grid-template-columns: 1fr;
    width: auto;
  }

  .hm-update-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .title-block h1 {
    font-size: 17px;
  }

  .title-block .subtitle {
    white-space: normal;
    line-height: 1.3;
  }

  .settings-menu,
  .filters,
  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel {
    border-radius: 12px;
  }

  .year-inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) max-content;
  }

  .cat-toggles {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .storm-loading-dot,
  .hurricane-icon,
  .onb-spotlight,
  .onb-overlay,
  .hm-toast {
    animation: none !important;
    transition: none !important;
  }
}

/* ==========================================================================
   Premium polish pass v1.3.1
   System-level refinement for hierarchy, states, panels, and secondary flows.
   ========================================================================== */

:root {
  --ease-standard: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-emphasized: cubic-bezier(0.16, 1, 0.3, 1);
  --panel-bg: rgba(24, 24, 37, 0.88);
  --panel-border: rgba(205, 214, 244, 0.12);
  --panel-width: 440px;
  --category-ink: #11111b;
}

html.light-theme {
  --panel-bg: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(76, 79, 105, 0.14);
  --category-ink: #11111b;
}

html.high-contrast {
  --panel-bg: var(--glass-bg);
  --panel-border: var(--glass-edge);
  --category-ink: #ffffff;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(116, 199, 236, 0.10), transparent 28%),
    radial-gradient(circle at 86% 24%, rgba(203, 166, 247, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(17, 17, 27, 0.12), rgba(17, 17, 27, 0.34));
}

.glass {
  border-color: var(--panel-border);
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.app-header {
  min-height: 72px;
  padding: 10px 12px 10px 10px;
  border-radius: 18px;
}

.title-block h1 {
  font-size: clamp(18px, 1.5vw, 22px);
  font-weight: 800;
}

.title-block .subtitle {
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  background: rgba(17, 17, 27, 0.34);
  border-color: rgba(205, 214, 244, 0.12);
}

.icon-btn[aria-pressed="true"],
.icon-btn[aria-expanded="true"]:not(#toggle-filters) {
  color: var(--base);
  background: linear-gradient(135deg, var(--lavender), var(--sapphire));
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(116, 199, 236, 0.18);
}

.filters {
  width: 320px;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  overflow-y: auto;
  overflow-x: hidden;
}

.year-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) max-content;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.year-inputs input {
  min-width: 0;
  padding-inline: 9px;
  text-align: center;
}

.year-clear-btn {
  min-width: 0;
  padding-inline: 7px;
}

.filter-row,
.filter-group {
  padding: 10px;
  margin: -10px;
  border-radius: 12px;
}

.filter-row:focus-within,
.filter-group:focus-within {
  background: rgba(180, 190, 254, 0.055);
}

.filter-row > label,
.filter-group-label,
.layer-select-label,
.settings-label,
.panel-section-h3,
.stats-panel h3 {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.075em;
}

input[type="number"],
input[type="search"],
select {
  border-radius: 10px;
}

button:disabled,
.text-btn:disabled {
  opacity: 0.48;
  transform: none !important;
  box-shadow: none !important;
}

.cat-btn.on,
.cat-pill {
  color: var(--category-ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.16);
}

.cat-btn:not(.on) {
  opacity: 1;
  color: var(--text-dim);
  background: rgba(17, 17, 27, 0.34);
  border-style: dashed;
}

.toggle-row {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid rgba(205, 214, 244, 0.09);
  border-radius: 10px;
  background: rgba(17, 17, 27, 0.22);
  transition: background 140ms var(--ease-standard), border-color 140ms var(--ease-standard);
}

.toggle-row:hover,
.toggle-row:focus-within {
  background: var(--control-bg-hover);
  border-color: rgba(180, 190, 254, 0.26);
}

.settings-menu {
  border-radius: 16px;
}

.settings-meta {
  line-height: 1.45;
}

.search-results {
  border-radius: 14px;
  background: rgba(24, 24, 37, 0.96);
}

html.light-theme .search-results {
  background: rgba(255, 255, 255, 0.96);
}

.search-results li[role="option"] {
  min-height: 42px;
}

.search-results li.is-active,
.search-results li[aria-selected="true"] {
  background: rgba(180, 190, 254, 0.14);
  box-shadow: inset 3px 0 0 var(--lavender);
}

.search-result-text strong {
  color: var(--text);
}

.storm-panel,
.stats-panel,
.compare-panel,
.state-panel,
.on-this-date-panel,
section.storm-panel.glass {
  width: var(--panel-width);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel-bg);
  border-radius: 18px;
  scroll-padding-top: 92px;
}

.stats-panel,
.compare-panel,
.state-panel,
.on-this-date-panel {
  bottom: 152px;
}

.panel-sticky-header {
  border-radius: 18px 18px 0 0;
}

.close-btn {
  min-width: 34px;
  min-height: 34px;
}

.stat-grid {
  gap: 8px;
}

.stat-grid .stat {
  border-radius: 12px;
  padding: 12px;
}

.stat .label {
  font-weight: 800;
}

.stat .value {
  font-size: 18px;
  letter-spacing: -0.015em;
}

.biography-text {
  font-style: normal;
  color: var(--subtext);
}

.closest-pass-row,
.impacts-block,
.intensity-chart,
.chart-host,
.dai-host,
.similar-storms-host,
.clim-chart-wrap,
.climate-trends-host,
.dt-table-wrap,
.cp-table-wrap {
  border-radius: 12px;
}

.closest-pass-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(205, 214, 244, 0.10);
}

.closest-pass-label,
.return-periods-label {
  color: var(--subtext);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.closest-pass-value,
.return-periods-row {
  color: var(--subtext);
  line-height: 1.45;
}

.closest-pass-value strong {
  color: var(--text);
}

.action-btn,
.export-btn,
.ct-btn,
.settings-pill,
.settings-action,
.play-anim-btn,
.pin-btn {
  transition:
    transform 140ms var(--ease-standard),
    border-color 140ms var(--ease-standard),
    background 140ms var(--ease-standard),
    box-shadow 140ms var(--ease-standard);
}

.action-btn:hover,
.export-btn:hover,
.ct-btn:hover,
.settings-pill:hover,
.settings-action:hover,
.play-anim-btn:hover,
.pin-btn:hover {
  transform: translateY(-1px);
}

.radar-quick-btn {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.panel-empty-state,
.empty-state,
.cp-empty,
.state-empty,
.search-empty {
  display: grid;
  gap: 7px;
  padding: 18px;
  border: 1px solid rgba(205, 214, 244, 0.11);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(180, 190, 254, 0.08), rgba(116, 199, 236, 0.035)),
    var(--surface-sunken);
  color: var(--subtext);
  text-align: left;
}

.panel-empty-state strong,
.empty-state strong,
.cp-empty h2,
.state-empty strong,
.search-empty strong {
  color: var(--text);
}

.panel-empty-state span,
.empty-state span,
.cp-empty .hint,
.state-empty span,
.search-empty span {
  line-height: 1.5;
}

.stats-summary,
.stats-note,
.panel-muted,
.trend-summary {
  color: var(--subtext);
  font-size: 12px;
  line-height: 1.55;
}

.stats-summary {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(205, 214, 244, 0.10);
  border-radius: 12px;
  background: var(--surface-sunken);
}

.stats-section {
  margin-top: 14px;
}

.stats-section + .stats-section {
  padding-top: 12px;
  border-top: 1px solid rgba(205, 214, 244, 0.09);
}

.panel-inline-error,
.boot-error-state {
  color: var(--error);
}

.boot-error-state {
  display: grid;
  gap: 12px;
  width: min(520px, calc(100vw - 40px));
  padding: 24px;
  border: 1px solid rgba(243, 139, 168, 0.30);
  border-radius: 18px;
  background: rgba(24, 24, 37, 0.94);
  box-shadow: var(--shadow-xl);
  color: var(--subtext);
  text-align: left;
}

.boot-error-state strong {
  color: var(--error);
  font-size: 18px;
}

.boot-error-state code {
  color: var(--text);
}

.boot-retry-btn {
  justify-self: start;
}

.bar-row {
  min-height: 22px;
}

.bar-row .bar {
  height: 12px;
  border: 1px solid rgba(205, 214, 244, 0.08);
}

.bar-row .fill {
  border-radius: inherit;
}

.dt-table,
.cp-table {
  border-collapse: separate;
  border-spacing: 0;
}

.dt-table thead th,
.cp-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-bg);
}

.dai-host {
  padding: 10px 0 2px;
}

.dai-bar {
  display: flex;
  min-height: 30px;
  overflow: hidden;
  border: 1px solid rgba(205, 214, 244, 0.11);
  border-radius: 999px;
  background: var(--surface-sunken);
}

.dai-seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2px;
  color: var(--category-ink);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.dai-seg.cat-ts { background: var(--cat-ts); }
.dai-seg.cat-1 { background: var(--cat-1); }
.dai-seg.cat-2 { background: var(--cat-2); }
.dai-seg.cat-3 { background: var(--cat-3); }
.dai-seg.cat-4 { background: var(--cat-4); }
.dai-seg.cat-5 { background: var(--cat-5); }

.dai-legend,
.dai-empty {
  margin-top: 6px;
  color: var(--subtext);
  font-size: 11px;
}

.segmented-control {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(205, 214, 244, 0.10);
  border-radius: 999px;
  background: var(--surface-sunken);
}

.seg-btn {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--subtext);
  padding: 5px 9px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.seg-btn.active,
.seg-btn[aria-pressed="true"] {
  color: var(--base);
  background: linear-gradient(135deg, var(--lavender), var(--sapphire));
}

.state-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.season-summary {
  position: absolute;
  left: 12px;
  bottom: 156px;
  z-index: 900;
  width: 304px;
  padding: 14px;
  border-radius: 18px;
  font-size: 12px;
}

.season-summary header,
.season-summary .ss-stats,
.ss-tiers,
.ss-superlatives > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.season-summary header {
  justify-content: space-between;
  margin-bottom: 10px;
}

.season-summary h3 {
  margin: 0;
  font-size: 14px;
}

.season-close {
  border: 1px solid rgba(205, 214, 244, 0.12);
  border-radius: 8px;
  background: transparent;
  color: var(--subtext);
  cursor: pointer;
}

.ss-stats {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 10px;
}

.ss-stat {
  padding: 8px;
  border: 1px solid rgba(205, 214, 244, 0.09);
  border-radius: 10px;
  background: var(--surface-sunken);
}

.ss-stat-num {
  display: block;
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
}

.ss-stat-lbl,
.ss-meta,
.season-empty {
  color: var(--subtext);
  font-size: 11px;
}

.ss-tiers {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ss-tier {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid rgba(205, 214, 244, 0.09);
  border-radius: 999px;
  background: var(--surface-sunken);
}

.ss-tier.empty {
  opacity: 0.54;
}

.ss-tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ss-superlatives {
  display: grid;
  gap: 6px;
  margin: 0;
}

.ss-superlatives > div {
  align-items: baseline;
  justify-content: space-between;
}

.ss-superlatives dt {
  color: var(--subtext);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ss-superlatives dd {
  margin: 0;
  color: var(--text);
  text-align: right;
}

.timeline-axis {
  position: relative;
  overflow: hidden;
}

.tl-bar {
  z-index: 1;
}

.tl-selection {
  z-index: 2;
  background: rgba(180, 190, 254, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.hm-toast {
  backdrop-filter: blur(14px) saturate(130%);
}

.hm-toast--info {
  border-color: rgba(116, 199, 236, 0.28);
}

.hm-toast--warn {
  color: var(--warning);
  background: rgba(49, 39, 24, 0.95);
}

@media (max-width: 900px) {
  .title-block .subtitle {
    max-width: none;
  }

  .season-summary {
    display: none;
  }
}

@media (max-width: 720px) {
  .app-header {
    min-height: 0;
  }

  .filters {
    width: auto;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel,
  section.storm-panel.glass {
    border-radius: 16px;
  }

  .state-list-head {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Layout stabilization pass v1.3.2
   One deterministic lane for analytical panels, with the timeline and summary
   surfaces constrained below it. */
:root {
  --side-panel-gap: 16px;
  --side-panel-top: 96px;
  --side-panel-bottom: 142px;
  --side-panel-width: 440px;
}

body.side-panel-open .leaflet-control-container .leaflet-right {
  transform: translateX(-456px);
  transition: transform 180ms ease;
}

.storm-panel,
.stats-panel,
.compare-panel,
.state-panel,
.on-this-date-panel,
section.storm-panel.glass {
  position: fixed !important;
  inset: var(--side-panel-top) var(--side-panel-gap) var(--side-panel-bottom) auto !important;
  width: min(var(--side-panel-width), calc(100vw - 368px)) !important;
  min-width: 0 !important;
  max-width: calc(100vw - 32px) !important;
  max-height: none !important;
  height: auto !important;
  overflow: hidden auto !important;
  z-index: 1800 !important;
  contain: layout paint;
}

.storm-panel[hidden],
.stats-panel[hidden],
.compare-panel[hidden],
.state-panel[hidden],
.on-this-date-panel[hidden] {
  display: none !important;
}

.storm-panel > header,
.stats-panel > header,
.compare-panel > header,
.state-panel > header,
.on-this-date-panel > header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(17, 24, 39, 0.9));
  backdrop-filter: blur(14px) saturate(125%);
}

.timeline-ribbon {
  z-index: 760 !important;
  left: 344px !important;
  right: 16px !important;
}

body.side-panel-open .timeline-ribbon {
  right: calc(var(--side-panel-width) + 32px) !important;
}

.timeline-axis {
  touch-action: none;
  cursor: pointer;
}

.timeline-axis.dragging {
  cursor: ew-resize;
}

.timeline-axis .tl-bar {
  appearance: none;
  flex: 1 1 0 !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  min-height: 4px !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: inherit;
  user-select: none;
}

.tl-selection {
  pointer-events: none;
}

.season-summary {
  position: fixed !important;
  left: calc(var(--map-left-reserve) + 16px) !important;
  right: var(--overlay-right-reserve) !important;
  bottom: calc(var(--overlay-bottom-reserve) + 18px) !important;
  z-index: 1220 !important;
  width: min(356px, calc(100vw - var(--map-left-reserve) - var(--overlay-right-reserve) - 32px)) !important;
  max-height: 148px !important;
  padding: 10px 12px !important;
  overflow: hidden auto !important;
  border-radius: 16px !important;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.32) !important;
}

body.side-panel-open .season-summary {
  opacity: 0.96;
  transform: none;
}

.season-summary header {
  margin-bottom: 6px !important;
}

.season-summary h3 {
  font-size: 13px !important;
}

.season-summary .ss-stats {
  gap: 6px !important;
  margin-bottom: 6px !important;
}

.season-summary .ss-stat {
  padding: 6px 7px !important;
}

.season-summary .ss-stat-num {
  font-size: 15px !important;
}

.season-summary .ss-tiers {
  gap: 5px !important;
  margin-bottom: 6px !important;
}

.season-summary .ss-superlatives {
  gap: 4px !important;
}

.season-summary .ss-superlatives > div {
  display: grid !important;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
}

.season-summary .ss-superlatives dd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .season-summary {
    left: 16px !important;
    right: var(--overlay-right-reserve) !important;
    width: min(332px, calc(100vw - var(--overlay-right-reserve) - 32px)) !important;
  }

  body.side-panel-open .leaflet-control-container .leaflet-right {
    transform: none;
  }

  body.side-panel-open .timeline-ribbon {
    right: 442px !important;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel,
  section.storm-panel.glass {
    width: min(410px, calc(100vw - 332px)) !important;
  }

  body.side-panel-open .timeline-ribbon {
    right: 16px !important;
  }
}

@media (max-width: 860px) {
  :root {
    --side-panel-gap: 10px;
    --side-panel-top: 92px;
    --side-panel-bottom: 112px;
  }

  body.side-panel-open .filters {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-10px) scale(0.98);
  }

  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel,
  section.storm-panel.glass {
    inset: var(--side-panel-top) var(--side-panel-gap) var(--side-panel-bottom) var(--side-panel-gap) !important;
    width: auto !important;
  }

  .timeline-ribbon {
    left: 10px !important;
    right: 10px !important;
  }

  .season-summary {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.side-panel-open .leaflet-control-container .leaflet-right,
  body.side-panel-open .filters,
  body.side-panel-open .timeline-ribbon,
  body.side-panel-open .season-summary {
    transition: none !important;
    transform: none !important;
  }
}

/* Overlay shelf stabilization pass v1.3.4
   Compare and radar controls share a reserved map shelf above the timeline
   instead of floating through the chart or the side-panel lane. */
:root {
  --map-left-reserve: 344px;
  --overlay-right-reserve: 16px;
  --overlay-bottom-reserve: 156px;
}

body.side-panel-open {
  --overlay-right-reserve: calc(var(--side-panel-width) + 32px);
}

body.timeline-collapsed {
  --overlay-bottom-reserve: 60px;
}

.compare-tray,
.radar-controls {
  position: fixed !important;
  left: calc(var(--map-left-reserve) + 16px) !important;
  right: var(--overlay-right-reserve) !important;
  transform: none !important;
  width: max-content;
  max-width: min(560px, calc(100vw - var(--map-left-reserve) - var(--overlay-right-reserve) - 32px)) !important;
  margin-inline: auto;
  z-index: 1180 !important;
}

.compare-tray {
  bottom: var(--overlay-bottom-reserve) !important;
}

.radar-controls {
  bottom: calc(var(--overlay-bottom-reserve) + 64px) !important;
}

@media (max-width: 1120px) {
  :root {
    --map-left-reserve: 16px;
  }

  body.side-panel-open {
    --overlay-right-reserve: 442px;
  }
}

@media (max-width: 860px) {
  :root {
    --map-left-reserve: 10px;
    --overlay-right-reserve: 10px;
    --overlay-bottom-reserve: 128px;
  }

  body.timeline-collapsed {
    --overlay-bottom-reserve: 52px;
  }

  .compare-tray,
  .radar-controls {
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: none !important;
    margin-inline: 0;
  }

  .radar-controls {
    bottom: calc(var(--overlay-bottom-reserve) + 76px) !important;
  }

  body.side-panel-open .compare-tray,
  body.side-panel-open .radar-controls {
    display: none !important;
  }
}

/* Playback contrast fix v1.3.5 */
.play-anim-btn.is-playing,
.play-anim-btn.is-paused {
  color: var(--text) !important;
  background:
    linear-gradient(135deg, rgba(49, 50, 68, 0.98), rgba(30, 30, 46, 0.98)) !important;
  border-color: rgba(250, 179, 135, 0.68) !important;
  box-shadow:
    0 0 0 1px rgba(250, 179, 135, 0.22) inset,
    0 8px 22px rgba(0, 0, 0, 0.32) !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.55);
}

.play-anim-btn.is-playing:hover,
.play-anim-btn.is-paused:hover {
  color: var(--text) !important;
  background:
    linear-gradient(135deg, rgba(69, 71, 90, 0.98), rgba(49, 50, 68, 0.98)) !important;
  border-color: rgba(250, 179, 135, 0.84) !important;
}

.play-anim-btn.is-playing .play-icon,
.play-anim-btn.is-paused .play-icon {
  color: currentColor;
}

/* Theme system hardening v1.3.6
   Centralized semantic tokens and late overrides for surfaces that had drifted
   toward dark-only rgba values in appended polish layers. */
:root {
  color-scheme: dark;
  --background: var(--base);
  --foreground: var(--text);
  --foreground-muted: var(--subtext);
  --foreground-subtle: var(--overlay);
  --surface-app: rgba(17, 17, 27, 0.94);
  --surface-panel: rgba(24, 24, 37, 0.92);
  --surface-elevated: rgba(30, 30, 46, 0.92);
  --surface-control: rgba(17, 17, 27, 0.72);
  --surface-control-hover: rgba(180, 190, 254, 0.12);
  --surface-control-active: rgba(180, 190, 254, 0.18);
  --surface-danger: rgba(243, 139, 168, 0.16);
  --surface-warning: rgba(249, 226, 175, 0.14);
  --surface-success: rgba(166, 227, 161, 0.14);
  --surface-info: rgba(137, 180, 250, 0.14);
  --border-subtle: rgba(205, 214, 244, 0.11);
  --border-strong: rgba(205, 214, 244, 0.20);
  --border-accent: rgba(180, 190, 254, 0.42);
  --shadow-theme-lg: 0 18px 60px rgba(0, 0, 0, 0.34);
  --focus-ring-color: rgba(180, 190, 254, 0.62);
  --focus-ring-soft: 0 0 0 3px rgba(180, 190, 254, 0.24);
  --on-accent: #11111b;
  --disabled-opacity: 0.58;
  --leaflet-control-bg: rgba(24, 24, 37, 0.92);
}

html.light-theme {
  color-scheme: light;
  --background: var(--base);
  --foreground: var(--text);
  --foreground-muted: var(--subtext);
  --foreground-subtle: var(--overlay);
  --surface-app: rgba(239, 241, 245, 0.96);
  --surface-panel: rgba(255, 255, 255, 0.94);
  --surface-elevated: rgba(246, 248, 252, 0.96);
  --surface-control: rgba(255, 255, 255, 0.86);
  --surface-control-hover: rgba(30, 102, 245, 0.09);
  --surface-control-active: rgba(124, 58, 237, 0.12);
  --surface-danger: rgba(210, 15, 57, 0.10);
  --surface-warning: rgba(228, 147, 32, 0.12);
  --surface-success: rgba(64, 160, 43, 0.10);
  --surface-info: rgba(30, 102, 245, 0.10);
  --border-subtle: rgba(76, 79, 105, 0.14);
  --border-strong: rgba(76, 79, 105, 0.24);
  --border-accent: rgba(124, 58, 237, 0.40);
  --shadow-theme-lg: 0 18px 54px rgba(76, 79, 105, 0.18);
  --focus-ring-color: rgba(124, 58, 237, 0.56);
  --focus-ring-soft: 0 0 0 3px rgba(124, 58, 237, 0.18);
  --on-accent: #ffffff;
  --leaflet-control-bg: rgba(255, 255, 255, 0.94);
}

html.high-contrast {
  --surface-app: var(--base);
  --surface-panel: var(--mantle);
  --surface-elevated: var(--crust);
  --surface-control: var(--crust);
  --surface-control-hover: var(--surface0);
  --surface-control-active: var(--surface1);
  --border-subtle: var(--glass-edge);
  --border-strong: rgba(255, 255, 255, 0.38);
  --border-accent: currentColor;
  --focus-ring-color: var(--text);
  --focus-ring-soft: 0 0 0 4px rgba(255, 255, 255, 0.34);
  --disabled-opacity: 0.72;
}

.glass,
.app-header,
.filters,
.settings-menu,
.compare-tray,
.radar-controls,
.season-summary,
.keyboard-palette,
.hm-toast,
.storm-panel,
.stats-panel,
.compare-panel,
.state-panel,
.on-this-date-panel,
section.storm-panel.glass {
  background: var(--surface-panel) !important;
  border-color: var(--border-subtle) !important;
  color: var(--foreground);
  box-shadow: var(--shadow-theme-lg);
}

.icon-btn,
.text-btn,
.settings-pill,
.settings-action,
.action-btn,
.export-btn,
.ct-btn,
.radar-btn,
.anim-btn,
input[type="number"],
input[type="search"],
select,
.toggle-row,
.layer-select,
.stat-grid .stat,
.closest-pass-row,
.impacts-block,
.cp-card,
.state-storm-row,
.similar-storm-row,
.panel-playback-host .anim-controls,
.anim-radar-toggle,
.ss-stat,
.ss-tier {
  background: var(--surface-control) !important;
  border-color: var(--border-subtle) !important;
  color: var(--foreground) !important;
}

.icon-btn:hover,
.text-btn:hover,
.settings-pill:hover,
.settings-action:hover,
.action-btn:hover,
.export-btn:hover,
.ct-btn:hover,
.radar-btn:hover,
.anim-btn:hover,
.toggle-row:hover,
.toggle-row:focus-within,
.state-storm-row:hover,
.search-results li:hover,
.cat-btn:not(.on):hover {
  background: var(--surface-control-hover) !important;
  border-color: var(--border-accent) !important;
  color: var(--foreground) !important;
}

input[type="number"]::placeholder,
input[type="search"]::placeholder {
  color: var(--foreground-muted);
  opacity: 0.82;
}

input[type="number"]:focus,
input[type="search"]:focus,
select:focus,
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: none !important;
  border-color: var(--focus-ring-color) !important;
  box-shadow: var(--focus-ring-soft) !important;
}

button:disabled,
input:disabled,
select:disabled,
.text-btn:disabled,
.icon-btn:disabled {
  opacity: var(--disabled-opacity) !important;
  color: var(--foreground-subtle) !important;
  background: var(--surface-elevated) !important;
  border-color: var(--border-subtle) !important;
}

.settings-pill.on,
.settings-pill[aria-checked="true"],
.icon-btn[aria-pressed="true"],
.icon-btn[aria-expanded="true"]:not(#toggle-filters),
.ct-btn.primary,
.action-btn.primary,
.play-anim-btn:not(.is-playing):not(.is-paused),
.pin-btn.pinned {
  color: var(--on-accent) !important;
  background: linear-gradient(135deg, var(--lavender), var(--sapphire)) !important;
  border-color: transparent !important;
}

.search-results,
.search-results li,
.panel-empty-state,
.empty-state,
.cp-empty,
.state-empty,
.search-empty,
.storm-loading-state,
.storm-error-state,
.state-loading {
  background: var(--surface-elevated) !important;
  border-color: var(--border-subtle) !important;
  color: var(--foreground-muted) !important;
}

.panel-empty-state strong,
.empty-state strong,
.cp-empty h2,
.state-empty strong,
.search-empty strong,
.storm-error-state strong,
.search-result-text strong,
.stat .value,
.closest-pass-value strong,
.anim-title,
.radar-title {
  color: var(--foreground) !important;
}

.hm-toast--warn {
  color: var(--warning) !important;
  background: var(--surface-warning) !important;
  border-color: rgba(249, 226, 175, 0.32) !important;
}

.hm-toast--info,
.state-loading,
.storm-loading-state {
  background: var(--surface-info) !important;
}

.storm-error-state,
.boot-error {
  color: var(--foreground) !important;
  background: var(--surface-danger) !important;
  border-color: rgba(243, 139, 168, 0.34) !important;
}

.storm-panel > header,
.stats-panel > header,
.compare-panel > header,
.state-panel > header,
.on-this-date-panel > header,
.panel-sticky-header {
  background: linear-gradient(180deg, var(--surface-panel), var(--surface-app)) !important;
  border-color: var(--border-subtle) !important;
}

html.light-theme body::before {
  background:
    radial-gradient(circle at 18% 12%, rgba(30, 102, 245, 0.08), transparent 28%),
    radial-gradient(circle at 86% 24%, rgba(124, 58, 237, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(239, 241, 245, 0.12), rgba(220, 224, 232, 0.28));
}

.leaflet-control-zoom a,
.leaflet-control-layers,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--leaflet-control-bg) !important;
  color: var(--foreground) !important;
  border-color: var(--border-subtle) !important;
}

.leaflet-control-attribution {
  background: var(--surface-panel) !important;
  color: var(--foreground-muted) !important;
}

/* Overlay cleanup v1.3.7 */
.leaflet-top.leaflet-right {
  top: var(--side-panel-top) !important;
  right: 16px !important;
  z-index: 1250;
}

body.side-panel-open .leaflet-top.leaflet-right {
  right: calc(var(--side-panel-width) + 32px) !important;
  transform: none !important;
}

.leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow-theme-lg);
}

@media (max-width: 1120px) {
  body.side-panel-open .leaflet-top.leaflet-right {
    right: 16px !important;
  }
}

@media (max-width: 860px) {
  .leaflet-top.leaflet-right {
    top: calc(var(--side-panel-top) + 4px) !important;
    right: 10px !important;
  }

  body.side-panel-open .leaflet-top.leaflet-right {
    display: none;
  }
}

/* Premium polish pass v1.3.8
   Tightens remaining command, first-run, accessibility, and mobile states. */
:root {
  --on-category: #11111b;
  --tooltip-bg: rgba(10, 10, 18, 0.96);
  --tooltip-text: #f7f8ff;
}

html.high-contrast {
  --on-category: #ffffff;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.cat-btn.on.cat-ts,
.cat-btn.on.cat-1,
.cat-btn.on.cat-2,
.cat-btn.on.cat-3,
.cat-btn.on.cat-4,
.cat-btn.on.cat-5 {
  color: var(--on-category) !important;
}

.app-header {
  isolation: isolate;
}

.header-actions {
  scrollbar-width: none;
  overscroll-behavior-inline: contain;
}

.header-actions .icon-btn {
  position: relative;
}

.header-actions::-webkit-scrollbar {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .header-actions .icon-btn::after {
    content: attr(aria-label);
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    z-index: 3200;
    max-width: 220px;
    padding: 7px 9px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.01em;
    text-align: center;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -4px);
    transition: opacity 120ms ease, transform 120ms ease;
  }

  .header-actions .icon-btn:hover::after,
  .header-actions .icon-btn:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  .header-actions .icon-btn[aria-expanded="true"]::after {
    opacity: 0 !important;
  }
}

.filter-legend-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
}

.filter-legend-list li {
  min-width: 0;
}

.filters {
  scrollbar-gutter: stable;
}

.filters::-webkit-scrollbar,
.storm-panel::-webkit-scrollbar,
.stats-panel::-webkit-scrollbar,
.compare-panel::-webkit-scrollbar,
.state-panel::-webkit-scrollbar,
.on-this-date-panel::-webkit-scrollbar,
.settings-menu::-webkit-scrollbar {
  width: 10px;
}

.filters::-webkit-scrollbar-thumb,
.storm-panel::-webkit-scrollbar-thumb,
.stats-panel::-webkit-scrollbar-thumb,
.compare-panel::-webkit-scrollbar-thumb,
.state-panel::-webkit-scrollbar-thumb,
.on-this-date-panel::-webkit-scrollbar-thumb,
.settings-menu::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(180, 190, 254, 0.28);
  background-clip: padding-box;
}

.search-results li:hover,
.search-results li.is-active {
  padding-left: 10px !important;
  background: var(--surface-control-hover) !important;
  border-color: var(--border-accent) !important;
}

.search-results li.is-active::before {
  opacity: 1;
}

.search-results li[aria-selected="true"] {
  color: var(--foreground) !important;
}

.boot-error-state {
  max-width: min(520px, calc(100vw - 32px));
  border: 1px solid rgba(243, 139, 168, 0.34);
  border-radius: 16px;
  background: var(--surface-danger);
  color: var(--foreground);
  box-shadow: var(--shadow-theme-lg);
}

.boot-error-state .text-btn {
  margin-top: 4px;
}

.onb-card {
  width: min(340px, calc(100vw - 32px));
  padding: 18px;
  border-color: var(--border-accent) !important;
}

.onb-step {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--surface-control);
}

.onb-title {
  letter-spacing: 0;
}

.onb-body {
  color: var(--foreground-muted);
}

@media (max-width: 720px) {
  .app-header {
    top: 8px !important;
    left: 8px !important;
    width: calc(100vw - 16px) !important;
    padding: 10px 12px !important;
  }

  .header-actions {
    max-height: 50px !important;
    gap: 8px !important;
    padding: 2px 2px 4px !important;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 24px), transparent 100%);
  }

  .icon-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
  }

  .filters {
    top: 154px !important;
    max-height: calc(100vh - 264px) !important;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel,
  section.storm-panel.glass {
    inset: 142px 8px 104px 8px !important;
  }

  .settings-menu {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
  }
}

@media (max-width: 430px) {
  .filter-legend-list {
    grid-template-columns: 1fr;
  }

  .filters {
    top: 150px !important;
  }

  .year-inputs {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(58px, auto);
  }
}

/* Premium responsive command/settings polish v1.3.9-q10
   Final layer for mobile command discoverability, settings hierarchy, and map
   control collision without changing the vanilla app architecture. */
.settings-menu {
  width: min(420px, calc(100vw - 24px)) !important;
  padding: 16px !important;
  gap: 14px !important;
  background: var(--surface-panel) !important;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42) !important;
}

.settings-menu-header {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-menu-header h2 {
  margin: 0;
  color: var(--foreground);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.settings-menu-header p {
  margin: 0;
  color: var(--foreground-muted);
  font-size: 12px;
  line-height: 1.45;
}

.settings-section {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-section:last-of-type {
  padding-bottom: 0;
  border-bottom: 0;
}

.settings-section h3 {
  margin: 0;
  color: var(--foreground-subtle);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.settings-row {
  grid-template-columns: minmax(112px, 0.82fr) minmax(0, 1.65fr) !important;
  align-items: center !important;
}

.settings-row--action,
.settings-row:has(.toggle-row) {
  grid-template-columns: 1fr !important;
}

.settings-pillgroup {
  align-items: center;
}

.settings-pill,
.settings-action {
  white-space: nowrap;
}

.settings-menu .toggle-row {
  width: 100%;
  min-height: 42px;
}

.settings-meta {
  padding: 10px 2px 0 !important;
  color: var(--foreground-muted) !important;
  font-size: 11px !important;
  line-height: 1.4;
}

.mobile-more-btn {
  display: none !important;
}

.mobile-actions-menu {
  display: contents;
}

.mobile-action-label {
  display: none;
}

@media (max-width: 720px) {
  :root {
    --side-panel-top: 138px;
    --side-panel-bottom: 112px;
    --map-left-reserve: 8px;
    --overlay-right-reserve: 8px;
    --overlay-bottom-reserve: 124px;
  }

  .app-header {
    display: grid !important;
    grid-template-columns: 48px minmax(0, 1fr) !important;
    grid-template-areas:
      "brand title"
      "actions actions" !important;
    align-items: center !important;
    gap: 8px 10px !important;
    padding: 10px !important;
    border-radius: 18px !important;
    max-width: none !important;
  }

  .brand-mark {
    grid-area: brand;
    width: 48px !important;
    height: 48px !important;
    border-radius: 12px !important;
  }

  .title-block {
    grid-area: title;
    min-width: 0;
  }

  .title-block h1 {
    font-size: 24px !important;
    line-height: 1.05;
  }

  .title-block .subtitle {
    display: block !important;
    max-width: 100% !important;
    overflow: hidden;
    color: var(--foreground-muted);
    font-size: 12px !important;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .title-block .subtitle-sep {
    margin-inline: 0.35em;
  }

  .header-actions {
    grid-area: actions;
    width: 100%;
    max-height: none !important;
    margin-left: 0 !important;
    padding: 2px 4px 6px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-padding-inline: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 30px), transparent 100%) !important;
  }

  .header-actions .icon-btn {
    flex: 0 0 44px;
    scroll-snap-align: start;
  }

  .header-actions:has(.mobile-actions-menu[data-open="true"]) {
    overflow: visible !important;
    mask-image: none !important;
  }

  .mobile-more-btn {
    display: inline-flex !important;
  }

  .mobile-actions-menu {
    position: fixed;
    top: calc(var(--side-panel-top) + 2px);
    right: 10px;
    z-index: 2800;
    display: grid !important;
    width: min(282px, calc(100vw - 20px));
    padding: 8px;
    gap: 6px;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    background: var(--surface-panel);
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    transition: opacity 140ms var(--ease-standard), transform 140ms var(--ease-standard), visibility 140ms var(--ease-standard);
    visibility: hidden;
  }

  .mobile-actions-menu[data-open="true"] {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    visibility: visible;
  }

  .mobile-actions-menu .icon-btn {
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 0 12px !important;
    border-radius: 12px !important;
    scroll-snap-align: none;
  }

  .mobile-actions-menu .icon-btn::after {
    display: none !important;
  }

  .mobile-action-label {
    display: inline;
    overflow: hidden;
    color: currentColor;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .leaflet-top.leaflet-right {
    top: calc(var(--side-panel-top) + 2px) !important;
    right: 8px !important;
  }

  .filters {
    top: var(--side-panel-top) !important;
    left: 8px !important;
    width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 252px) !important;
    border-radius: 18px !important;
  }

  .filters.collapsed {
    transform: translateY(-8px) scale(0.98) !important;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel,
  section.storm-panel.glass {
    inset: var(--side-panel-top) 8px var(--side-panel-bottom) 8px !important;
  }

  .settings-menu {
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    max-height: calc(100vh - 156px) !important;
    overflow-y: auto;
    padding: 14px !important;
  }

  .settings-row {
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
    gap: 7px !important;
  }

  .settings-pillgroup {
    justify-content: flex-start !important;
  }

  .settings-pill,
  .settings-action {
    min-height: 40px;
  }

  .onb-card {
    width: min(360px, calc(100vw - 24px)) !important;
  }
}

@media (max-width: 430px) {
  :root {
    --side-panel-top: 132px;
    --side-panel-bottom: 108px;
  }

  .app-header {
    grid-template-columns: 44px minmax(0, 1fr) !important;
    gap: 7px 9px !important;
    padding: 9px !important;
  }

  .brand-mark {
    width: 44px !important;
    height: 44px !important;
  }

  .title-block h1 {
    font-size: 22px !important;
  }

  .header-actions {
    gap: 7px !important;
    padding-inline: 2px !important;
  }

  .filters {
    top: var(--side-panel-top) !important;
    max-height: calc(100vh - 238px) !important;
  }

  .settings-menu {
    max-height: calc(100vh - 150px) !important;
  }
}

/* Desktop panel fit polish v1.3.9-q11
   Reflows dense analytical panels into desktop dashboards so common laptop
   viewports expose the lower controls without panel scrolling. */
@media (min-width: 1121px) {
  :root {
    --desktop-panel-width: min(1040px, calc(100vw - 48px));
  }

  .filters:not(.collapsed) {
    bottom: 16px !important;
    width: min(620px, calc(100vw - 32px)) !important;
    max-height: calc(100vh - 116px) !important;
    padding: 12px 14px !important;
    gap: 8px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-content: start;
    column-gap: 12px !important;
    row-gap: 8px !important;
  }

  .filters .filter-row {
    margin: 0 !important;
  }

  body.side-panel-open .filters:not(.collapsed) {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-8px) scale(0.985);
  }

  #filters > .filter-row--year,
  #filters > .filter-row:nth-of-type(3),
  #filters > .filter-row:nth-of-type(4),
  #filters > .filter-footer {
    grid-column: 1;
  }

  #filters > .filter-row--cats,
  #filters > .filter-group,
  #filters > .filter-row:nth-of-type(6),
  #filters > .filter-legend {
    grid-column: 2;
  }

  .filters .cat-toggles {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .filters input[type="number"],
  .filters input[type="search"],
  .filters select {
    height: 38px !important;
  }

  .filters .toggle-row {
    min-height: 36px !important;
  }

  .filters .filter-group {
    gap: 7px !important;
    padding: 8px !important;
    margin: -6px !important;
  }

  .filters .filter-legend {
    margin-top: 2px !important;
    padding-top: 8px !important;
  }

  .filters .filter-legend-list {
    gap: 5px 10px !important;
  }

  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel,
  section.storm-panel.glass {
    inset: 88px 16px 16px auto !important;
    width: var(--desktop-panel-width) !important;
    max-width: none !important;
    padding: 14px 16px 16px !important;
    overflow-y: auto;
    line-height: 1.42;
    scrollbar-gutter: auto;
  }

  body.side-panel-open .leaflet-top.leaflet-right {
    right: calc(var(--desktop-panel-width) + 32px) !important;
  }

  body.side-panel-open .timeline-ribbon {
    right: 16px !important;
  }

  .storm-panel .panel-sticky-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(230px, 0.34fr);
    align-items: start;
    gap: 8px 12px;
    margin: -14px -16px 10px;
    padding: 12px 48px 10px 16px;
  }

  .storm-panel .storm-panel-header {
    min-width: 0;
  }

  .storm-panel .storm-panel-header h2 {
    margin-bottom: 4px !important;
    font-size: 18px;
    line-height: 1.15;
  }

  .storm-panel .meta-row {
    gap: 5px 9px;
    margin-bottom: 0 !important;
    font-size: 10.5px;
    line-height: 1.2;
  }

  .storm-panel .panel-actions-sticky {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    margin-top: 0 !important;
  }

  .storm-panel .panel-actions-sticky .play-anim-btn,
  .storm-panel .panel-actions-sticky .pin-btn {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 10.5px;
    justify-content: center;
  }

  .storm-panel .panel-playback-host {
    grid-column: 1 / -1;
    margin-top: 0;
  }

  #stats-body {
    display: grid;
    grid-template-columns: minmax(170px, 0.46fr) minmax(0, 1fr);
    gap: 7px 10px;
    align-items: start;
  }

  #stats-body > h2 {
    grid-column: 1;
    margin: 0 !important;
  }

  #stats-body > .stats-summary {
    grid-column: 2;
    margin: 0 !important;
    padding: 7px 10px !important;
    line-height: 1.28;
  }

  #seasonal-outlook-host {
    grid-column: 1 / -1;
  }

  #seasonal-outlook-host:empty {
    display: none;
  }

  #stats-body > .stats-panel-layout {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns:
      minmax(228px, 0.98fr)
      minmax(206px, 0.86fr)
      minmax(222px, 0.94fr)
      minmax(318px, 1.34fr);
    gap: 7px 9px;
    align-items: start;
  }

  .stats-panel-column {
    display: grid;
    gap: 7px;
    min-width: 0;
    align-content: start;
  }

  .stats-panel-column .stats-section {
    grid-column: auto !important;
  }

  .stats-panel .stats-section {
    min-width: 0;
    margin: 0 !important;
    padding: 7px 8px !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 12px;
    background: var(--surface-control) !important;
  }

  .stats-panel .stats-section + .stats-section {
    padding-top: 7px !important;
  }

  .stats-section--states,
  .stats-section--categories {
    grid-column: 1;
  }

  .stats-section--decades,
  .stats-section--cold {
    grid-column: 2;
  }

  .stats-section--climatology,
  .stats-section--climate,
  .stats-section--trend-table {
    grid-column: 3;
  }

  .stats-panel h3,
  .storm-panel .panel-section-h3,
  .state-panel .panel-section-h3 {
    margin: 0 0 6px !important;
    font-size: 9.5px !important;
    line-height: 1.15;
  }

  .stats-panel .bar-row,
  .state-panel .bar-row {
    min-height: 0 !important;
    margin-bottom: 2px !important;
    gap: 5px !important;
    font-size: 10.5px !important;
  }

  .stats-panel .stats-section--states,
  .stats-panel .stats-section--decades {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 8px;
    row-gap: 1px;
    align-items: start;
  }

  .stats-panel .stats-section--states > h3,
  .stats-panel .stats-section--decades > h3 {
    grid-column: 1 / -1;
  }

  .stats-panel .stats-section--states .bar-row,
  .stats-panel .stats-section--decades .bar-row {
    display: grid;
    grid-template-columns: minmax(56px, 72px) minmax(20px, 1fr) 24px;
    margin-bottom: 1px !important;
  }

  .stats-panel .bar-row .label,
  .state-panel .bar-row .label {
    width: 88px !important;
  }

  .stats-panel .stats-section--states .bar-row .label,
  .stats-panel .stats-section--decades .bar-row .label {
    width: auto !important;
  }

  .stats-panel .bar-row .bar,
  .state-panel .bar-row .bar {
    height: 7px !important;
  }

  .stats-panel .bar-row .count,
  .state-panel .bar-row .count {
    width: 28px !important;
    font-size: 9.5px !important;
  }

  .stats-panel .stats-section--states .bar-row .count,
  .stats-panel .stats-section--decades .bar-row .count {
    width: 24px !important;
  }

  .stats-panel .clim-chart-wrap,
  .stats-panel .climate-trends-host,
  .stats-panel .dt-table-wrap {
    max-height: 120px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: var(--surface-control);
  }

  .stats-panel .clim-chart,
  .stats-panel .climate-trends-host svg {
    display: block;
    width: 100% !important;
    height: 114px !important;
  }

  .stats-panel .dt-host {
    margin: 0 !important;
  }

  .stats-panel .dt-table {
    font-size: 9px !important;
  }

  .stats-panel .dt-table th,
  .stats-panel .dt-table td {
    padding: 2px 3px !important;
    line-height: 1.05 !important;
    white-space: nowrap;
  }

  .stats-panel .stats-section--trend-table .dt-table-wrap {
    max-height: none;
    overflow: visible;
  }

  .stats-panel .stats-section--trend-table .dt-note {
    margin-top: 4px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stats-panel .dt-table thead th {
    font-size: 7.5px !important;
    letter-spacing: 0.02em !important;
  }

  .stats-panel .dt-deadliest,
  .stats-panel .dt-costliest {
    font-size: 8.2px !important;
  }

  .stats-panel .dt-deadliest span,
  .stats-panel .dt-costliest span {
    display: inline-block;
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
  }

  .stats-panel .dt-note,
  .stats-panel .stats-note {
    margin-top: 4px !important;
    font-size: 9px !important;
    line-height: 1.18 !important;
  }

  .stats-panel .seasonal-outlook-banner {
    display: grid;
    grid-template-columns: minmax(0, max-content) minmax(0, 1fr) minmax(0, max-content);
    align-items: center;
    gap: 6px 10px;
    padding: 7px 9px;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--surface-control);
  }

  .stats-panel .sob-header,
  .stats-panel .sob-meta {
    min-width: 0;
  }

  .stats-panel .sob-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
  }

  .stats-panel .sob-meta {
    font-size: 9.5px;
    color: var(--subtext);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stats-panel .sob-details {
    justify-self: end;
    font-size: 9.5px;
  }

  .stats-panel .sob-details p {
    margin: 4px 0 0;
  }

  .storm-panel-layout {
    display: grid;
    grid-template-columns: minmax(250px, 0.95fr) minmax(290px, 1.05fr) minmax(220px, 0.8fr);
    gap: 8px 10px;
    align-items: start;
  }

  .storm-summary-cluster,
  .storm-analysis-cluster,
  .storm-resources-cluster {
    display: grid;
    min-width: 0;
    gap: 8px;
    align-content: start;
  }

  .storm-panel .biography-text {
    margin: 0 !important;
    padding: 10px 12px !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
  }

  .storm-panel .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px !important;
    margin: 0 !important;
  }

  .storm-panel .stat-grid .stat,
  .state-panel .stat-grid .stat {
    padding: 8px 9px !important;
  }

  .storm-panel .stat .label,
  .state-panel .stat .label {
    font-size: 9.5px !important;
  }

  .storm-panel .stat .value,
  .state-panel .stat .value {
    font-size: 18px !important;
  }

  .storm-panel .closest-pass-row,
  .storm-panel .impacts-block {
    padding: 9px 10px !important;
  }

  .storm-panel .similar-storms-list,
  .storm-panel .landfall-list,
  .state-panel .state-storm-list {
    margin: 0 !important;
    gap: 5px !important;
  }

  .storm-panel .similar-storm-row,
  .storm-panel .landfall-list li,
  .state-panel .state-storm-row {
    padding: 6px 8px !important;
  }

  .storm-panel .dai-host {
    padding: 0 !important;
  }

  .storm-panel .chart-host {
    margin: 0 !important;
  }

  .storm-panel .intensity-chart {
    padding: 6px !important;
  }

  .storm-panel .chart-legend {
    gap: 7px !important;
    margin-bottom: 2px !important;
  }

  .storm-panel .chart-export-row,
  .storm-panel .action-row,
  .storm-panel .export-row {
    gap: 6px !important;
    margin-top: 0 !important;
  }

  .storm-panel .action-btn,
  .storm-panel .export-btn,
  .storm-panel .chart-export-btn {
    min-height: 32px !important;
    padding: 6px 9px !important;
    font-size: 11px !important;
  }

  .storm-panel .export-label {
    flex-basis: 100%;
    margin-bottom: -2px;
    font-size: 10px;
  }

  .storm-panel .wind-field-row {
    margin-top: 0 !important;
  }

  #state-body {
    display: block;
  }

  #state-body > .state-panel-layout {
    display: grid;
    grid-template-columns: minmax(210px, 0.7fr) minmax(260px, 0.86fr) minmax(470px, 1.44fr);
    gap: 8px 10px;
    align-items: start;
  }

  .state-summary-cluster,
  .state-distribution-cluster,
  .state-records-cluster {
    display: grid;
    min-width: 0;
    gap: 8px;
    align-content: start;
  }

  .state-summary-cluster h2,
  .state-summary-cluster .state-sub,
  .state-summary-cluster .stat-grid,
  .state-section .panel-section-h3,
  .state-section .state-storm-list,
  .state-section .state-list-head {
    grid-column: auto;
  }

  .state-summary-cluster h2 {
    margin: 0 !important;
  }

  .state-summary-cluster .state-sub {
    margin: 0 !important;
    line-height: 1.32;
  }

  .state-summary-cluster .stat-grid {
    margin: 0 !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-panel .state-section {
    min-width: 0;
    margin: 0 !important;
    padding: 8px 10px !important;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--surface-control);
  }

  .state-panel .state-section--decade {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 8px;
  }

  .state-panel .state-section--decade > h3 {
    grid-column: 1 / -1;
  }

  .state-panel .state-section--decade .bar-row {
    display: grid;
    grid-template-columns: 52px minmax(24px, 1fr) 24px;
    margin-bottom: 1px !important;
  }

  .state-panel .state-section--decade .bar-row .label,
  .state-panel .state-section--decade .bar-row .count {
    width: auto !important;
  }

  .state-panel .state-list-head {
    margin: 0 0 6px !important;
    gap: 8px;
  }

  .state-panel .state-storm-list {
    margin: 0 !important;
    gap: 5px !important;
  }

  .state-panel .state-section--worst .state-storm-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-panel .state-section--all-storms #state-storm-list {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: calc(100vh - 368px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
  }
}

@media (min-width: 1121px) and (max-height: 820px) {
  .storm-panel,
  .stats-panel,
  .compare-panel,
  .state-panel,
  .on-this-date-panel,
  section.storm-panel.glass {
    inset-block: 72px 6px !important;
    padding: 11px 14px !important;
  }

  .stats-panel .clim-chart-wrap,
  .stats-panel .climate-trends-host,
  .stats-panel .dt-table-wrap {
    max-height: 116px;
  }

  .stats-panel .clim-chart,
  .stats-panel .climate-trends-host svg {
    height: 110px !important;
  }

  #stats-body,
  #stats-body > .stats-panel-layout,
  .stats-panel-column {
    gap: 6px !important;
  }

  .storm-panel .biography-text {
    padding-block: 7px !important;
    line-height: 1.35 !important;
  }

  .storm-panel .panel-sticky-header {
    margin-bottom: 8px;
    padding-block: 10px 8px;
  }

  .storm-panel .storm-panel-header h2 {
    font-size: 16px;
  }

  .storm-panel .meta-row {
    font-size: 10px;
  }

  .state-panel .state-section--all-storms #state-storm-list {
    max-height: calc(100vh - 308px);
  }

  .storm-panel .stat-grid .stat,
  .state-panel .stat-grid .stat {
    padding-block: 6px !important;
  }

  .storm-panel-layout,
  .storm-summary-cluster,
  .storm-analysis-cluster,
  .storm-resources-cluster {
    gap: 6px !important;
  }

  .storm-panel .closest-pass-row,
  .storm-panel .impacts-block {
    padding-block: 7px !important;
  }

  .storm-panel .similar-storm-row,
  .storm-panel .landfall-list li,
  .state-panel .state-storm-row {
    padding-block: 4px !important;
  }

  .storm-panel .action-btn,
  .storm-panel .export-btn,
  .storm-panel .chart-export-btn {
    min-height: 30px !important;
    padding-block: 5px !important;
  }

  .filters:not(.collapsed) {
    padding: 10px 12px !important;
    row-gap: 6px !important;
  }

  .filters input[type="number"],
  .filters input[type="search"],
  .filters select {
    height: 34px !important;
  }

  .filters .toggle-row {
    min-height: 32px !important;
  }

  .filters .cat-btn {
    min-height: 32px !important;
  }

  .filters .filter-group {
    gap: 5px !important;
    padding: 6px !important;
  }

  .filters .filter-legend {
    padding-top: 6px !important;
  }
}

/* Phase 13: Opt-in 3D globe visualization */
.globe3d-panel {
  position: fixed;
  inset: 0;
  z-index: 3200;
  overflow: hidden;
  color: #f5f7ff;
  background: #050813;
}

.globe3d-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #050813;
}

.globe3d-canvas .cesium-viewer,
.globe3d-canvas .cesium-viewer-cesiumWidgetContainer,
.globe3d-canvas .cesium-widget,
.globe3d-canvas canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.globe3d-topbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(10, 14, 28, 0.76);
  border-color: rgba(245, 247, 255, 0.16);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.36);
}

.globe3d-heading {
  min-width: 0;
}

.globe3d-heading h2 {
  margin: 0 0 3px;
  font-size: 17px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: 0;
}

.globe3d-heading p {
  margin: 0;
  color: rgba(245, 247, 255, 0.72);
  font-size: 12px;
  line-height: 1.35;
}

.globe3d-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.globe3d-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(245, 247, 255, 0.16);
  border-radius: 10px;
  color: #f5f7ff;
  background: rgba(245, 247, 255, 0.09);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.globe3d-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--sapphire);
}

.globe3d-toggle:focus-within {
  outline: 2px solid rgba(180, 190, 254, 0.78);
  outline-offset: 2px;
}

.globe3d-toggle.is-disabled {
  opacity: 0.55;
}

.globe3d-actions .text-btn {
  min-height: 34px;
  color: #f5f7ff;
  background: rgba(245, 247, 255, 0.09);
  border-color: rgba(245, 247, 255, 0.16);
}

.globe3d-actions .text-btn:hover,
.globe3d-actions .text-btn:focus-visible {
  background: rgba(116, 199, 236, 0.17);
  border-color: rgba(116, 199, 236, 0.42);
}

.globe3d-actions .close-btn {
  position: static;
  color: #f5f7ff;
  background: rgba(245, 247, 255, 0.09);
  border-color: rgba(245, 247, 255, 0.16);
}

.globe3d-timeline {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(150px, max-content);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.globe3d-timeline label,
.globe3d-status {
  color: rgba(245, 247, 255, 0.68);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.globe3d-timeline input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--sapphire);
}

.globe3d-timeline input[type="range"]:focus-visible {
  outline: 2px solid rgba(180, 190, 254, 0.78);
  outline-offset: 4px;
  border-radius: 999px;
}

#globe3d-time-label {
  justify-self: end;
  color: rgba(245, 247, 255, 0.84);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.globe3d-status {
  grid-column: 1 / -1;
  min-height: 16px;
}

html.high-contrast .globe3d-topbar {
  background: rgba(0, 0, 0, 0.94);
  border: 2px solid #ffffff;
}

@media (max-width: 720px) {
  .globe3d-topbar {
    top: 8px;
    left: 8px;
    right: 8px;
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 10px;
    gap: 8px;
  }

  .globe3d-actions {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr) 34px;
    justify-content: stretch;
    gap: 6px;
  }

  .globe3d-toggle,
  .globe3d-actions .text-btn {
    justify-content: center;
    width: 100%;
    min-width: 0;
    padding-inline: 7px;
    font-size: 11px;
  }

  .globe3d-actions .close-btn {
    width: 34px;
  }

  .globe3d-timeline {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  #globe3d-time-label {
    justify-self: start;
    white-space: normal;
  }
}

@media print {
  .globe3d-panel {
    display: none !important;
  }
}
