:root {
  --bg-page: #edf4fb;
  --bg-surface: rgba(15, 23, 42, 0.76);
  --bg-surface-strong: rgba(15, 23, 42, 0.9);
  --panel-border: rgba(148, 163, 184, 0.25);
  --text: #e2e8f0;
  --muted: #cbd5e1;
  --shadow: rgba(15, 23, 42, 0.18);
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-page);
  color: #0f172a;
}

body {
  padding: 12px;
  box-sizing: border-box;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 12px 18px;
  box-shadow: 0 10px 26px var(--shadow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.date-range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.range-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #cbd5e1;
  font-weight: 700;
}

.range-presets {
  display: inline-flex;
  gap: 4px;
}

.range-preset,
.range-select {
  min-height: 30px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.5);
  color: #e2e8f0;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
}

.range-preset {
  min-width: 38px;
  padding: 0 8px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.range-preset:hover,
.range-preset:focus-visible,
.range-select:focus-visible {
  border-color: #7dd3fc;
  outline: 2px solid rgba(125, 211, 252, 0.25);
  outline-offset: 1px;
}

.range-preset.is-active {
  background: #0ea5e9;
  border-color: #38bdf8;
  color: #fff;
}

.range-select {
  max-width: 116px;
  padding: 0 28px 0 9px;
  cursor: pointer;
}

.range-select option {
  background: #0f172a;
  color: #e2e8f0;
}

.visually-hidden {
  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;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #7dd3fc;
  font-weight: 700;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.3vw, 2.25rem);
  color: #f8fafc;
  line-height: 1.05;
}

.status-pill {
  white-space: nowrap;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.14);
  border: 1px solid rgba(125, 211, 252, 0.42);
  color: #e0f2fe;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 12px;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.status-pill.is-loading {
  background: rgba(247, 209, 84, 0.12);
  border-color: rgba(247, 209, 84, 0.5);
  color: #fef3c7;
  animation: pill-pulse 1.1s ease-in-out infinite;
}

.status-pill.is-error {
  background: rgba(255, 107, 107, 0.14);
  border-color: rgba(255, 107, 107, 0.55);
  color: #fecaca;
}

@keyframes pill-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(125, 211, 252, 0.45);
  background: rgba(15, 23, 42, 0.85);
  color: #7dd3fc;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.4);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
}

.help-btn:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-1px) scale(1.06);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.35);
}

.help-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.help-btn:active {
  transform: translateY(0) scale(0.95);
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 12px 22px var(--shadow);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #cbd5e1;
  font-weight: 700;
}

.stat-card strong {
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  color: #f8fafc;
}

.stat-card--energy strong {
  font-size: clamp(0.88rem, 1.35vw, 1.2rem);
  color: #fde047;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card.is-clickable {
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.stat-card.is-clickable:hover,
.stat-card.is-clickable:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(125, 211, 252, 0.55);
  outline: none;
}

#map-wrap {
  position: relative;
  min-width: 0;
}

.zoom-easter-egg {
  position: absolute;
  z-index: 12;
  top: 14px;
  left: 50%;
  width: max-content;
  max-width: min(520px, calc(100% - 300px));
  box-sizing: border-box;
  transform: translate(-50%, -10px) scale(0.97);
  padding: 9px 14px;
  border: 1px solid rgba(125, 211, 252, 0.48);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.94);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.32);
  color: #e0f2fe;
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.zoom-easter-egg.is-visible {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
}

#map-id {
  box-sizing: border-box;
  width: 100%;
  height: 72vh;
  min-height: 460px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 18px 34px var(--shadow);
  background: radial-gradient(circle at 50% 42%, #16233c 0%, #0b1220 62%, #05080f 100%);
}

.maplibregl-canvas {
  outline: none;
}

.maplibregl-canvas:focus-visible {
  outline: 3px solid #0f172a;
  outline-offset: -4px;
  box-shadow: inset 0 0 0 7px #f8fafc;
}

.maplibregl-ctrl-top-left > .maplibregl-ctrl + .maplibregl-ctrl {
  margin-top: 12px;
}

.maplibregl-ctrl button.home-control {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #333;
}

.maplibregl-ctrl button.home-control svg {
  display: block;
  margin: auto;
}

.maplibregl-ctrl button.rotation-control {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #333;
  font-size: 0.8rem;
  font-weight: 700;
}

.map-panel {
  position: absolute;
  z-index: 10;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
  padding: 12px 14px;
  box-sizing: border-box;
}

.base-panel {
  top: 12px;
  right: 12px;
}

.base-panel-header {
  display: none;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: #f8fafc;
  padding: 0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.base-panel-header:hover,
.base-panel-header:focus-visible {
  color: #7dd3fc;
}

.base-panel-header:focus,
.legend-header:focus {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

.base-current {
  margin-left: auto;
  color: #bae6fd;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.base-panel-content {
  display: grid;
  gap: 7px;
}

.base-panel-content[hidden] {
  display: none;
}

.base-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.base-option input {
  accent-color: #7dd3fc;
  cursor: pointer;
  margin: 0;
}

.base-divider {
  height: 1px;
  background: rgba(148, 163, 184, 0.3);
  margin: 3px 0;
}

.legend-panel {
  position: relative;
  inset: auto;
  transform: none;
  width: fit-content;
  max-width: calc(100% - 16px);
  margin: 10px auto 0;
  padding: 7px 14px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 9999px;
  box-shadow: 0 6px 28px rgba(2, 6, 23, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.legend-panel.is-expanded {
  display: flex;
  align-items: center;
  gap: 12px;
}

.legend-panel:not(.is-expanded) {
  width: auto;
}

.legend-header {
  width: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #f8fafc;
  padding: 0 10px 0 0;
  border-right: 1px solid rgba(148, 163, 184, 0.28);
  cursor: pointer;
  flex: 0 0 auto;
}

.legend-header:hover,
.legend-header:focus-visible {
  color: #7dd3fc;
  outline: none;
}

.legend-header h3 {
  margin: 0;
  color: #f8fafc;
  font-size: 0.9rem;
  text-align: left;
  white-space: nowrap;
}

.legend-chevron {
  font-size: 0.9rem;
  transition: transform 0.18s ease;
}

.legend-header[aria-expanded="false"] .legend-chevron {
  transform: rotate(-90deg);
}

.legend-content {
  min-width: 0;
  margin-top: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px 10px;
  flex: 1 1 auto;
  overflow: visible;
}

.legend-content[hidden] {
  display: none !important;
}

.legend-depth-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-subtitle {
  margin: 0;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.legend-list {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.legend-section-divider {
  width: 1px;
  height: 22px;
  background: rgba(148, 163, 184, 0.28);
  margin: 0 2px;
  flex-shrink: 0;
}

.legend-extra {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.legend-toggle {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.4);
  color: #e2e8f0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.legend-toggle:hover,
.legend-toggle:focus-visible {
  border-color: rgba(125, 211, 252, 0.8);
  background: rgba(15, 23, 42, 0.7);
  outline: none;
}

.legend-toggle.is-off {
  opacity: 0.5;
  background: rgba(15, 23, 42, 0.2);
  border-color: rgba(148, 163, 184, 0.15);
}

.legend-label {
  flex: 1;
  text-align: left;
}

.legend-state {
  display: none;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: inset 2px 2px 3px rgba(255, 255, 255, 0.75), inset -2px -3px 4px rgba(0, 0, 0, 0.35);
  display: inline-block;
  flex-shrink: 0;
}

.plate-swatch {
  display: inline-block;
  width: 16px;
  height: 3px;
  background: #fbbf24;
  box-shadow: 0 0 6px #f59e0b;
  border-radius: 2px;
  flex-shrink: 0;
}

.magnitude-legend,
.legend-note,
.legend-reset {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.35);
  color: #cbd5e1;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-sizing: border-box;
}

.legend-reset {
  cursor: pointer;
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(125, 211, 252, 0.4);
  color: #e0f2fe;
  font-weight: 700;
}

.legend-reset:hover,
.legend-reset:focus-visible {
  background: rgba(14, 165, 233, 0.25);
  border-color: #7dd3fc;
  outline: none;
}

.magnitude-shape.is-sphere {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff 0, #7dd3fc 25%, #0284c7 68%, #082f49 100%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

.magnitude-shape.is-cube {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 45%, #b45309 100%);
  border: 1.5px solid #fbbf24;
  box-shadow: 0 0 5px rgba(245, 158, 11, 0.75);
  flex-shrink: 0;
  margin: 0 1px;
}

.champion-epicenter-badge {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

.cluster-legend-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.9);
  color: #fff;
  font-size: 0.52rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  flex-shrink: 0;
}

.maplibregl-popup-content {
  background: rgba(15, 23, 42, 0.96);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.5);
  padding: 11px 38px 11px 12px;
}

.maplibregl-popup {
  max-width: 280px !important;
  /* Above the map legend and panels, like airship popups, so a popup that
     opens near the bottom of the map stays clickable (Explain button). */
  z-index: 1000;
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: rgba(15, 23, 42, 0.96);
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: rgba(15, 23, 42, 0.96);
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: rgba(15, 23, 42, 0.96);
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: rgba(15, 23, 42, 0.96);
}

.maplibregl-popup-close-button {
  color: #94a3b8;
  font-size: 1rem;
}

.legend-note {
  margin: 0;
  font-size: 0.65rem;
  line-height: 1.25;
   color: #cbd5e1;
   display: flex;
   align-items: center;
   gap: 6px;
  max-width: 155px;
  flex: 0 0 auto;
}

.legend-mobile-copy,
.cluster-legend-icon,
.legend-reset-icon {
  display: none;
}

.champion-epicenter-badge {
  width: 26px;
  height: auto;
  display: block;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 2px rgba(2, 6, 23, 0.72));
}

.champion-badge {
  grid-column: 1 / -1;
  margin: 0 0 2px !important;
  color: #fbbf24 !important;
  font-weight: 600;
  font-size: 0.7rem !important;
  line-height: 1.3;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
}

.champion-badge .champion-epicenter-badge {
  width: 30px;
}

.quake-popup {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
}

.quake-popup h3 {
  grid-column: 1 / -1;
  margin: 0 0 1px;
  text-align: left;
  color: #f8fafc;
  font-size: 0.92rem;
  line-height: 1.25;
}

.quake-popup .popup-fact {
  min-width: 0;
  margin: 0;
  color: #cbd5e1;
  font-size: 0.76rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.popup-fact strong {
  display: block;
  margin-bottom: 2px;
  color: #94a3b8;
  font-size: 0.59rem;
  letter-spacing: 0.07em;
  line-height: 1.1;
  text-transform: uppercase;
}

.popup-fact--wide {
  grid-column: 1 / -1;
}

/* Claude quake explainer */
.quake-explain {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.quake-explain-btn {
  justify-self: start;
  padding: 7px 12px;
  border: 1px solid rgba(125, 211, 252, 0.55);
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.16);
  color: #e0f2fe;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.quake-explain-btn:hover {
  background: rgba(14, 165, 233, 0.28);
}

.quake-explain-btn:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

.quake-explain-heading {
  color: #94a3b8;
  font-size: 0.59rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.quake-explain-body {
  padding-right: 4px;
}

.quake-explain-body p {
  margin: 0 0 7px;
  color: #e2e8f0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.quake-explain-status,
.quake-explain-note {
  margin: 0;
  color: #94a3b8;
  font-size: 0.7rem;
  line-height: 1.35;
}

.quake-explain-error {
  color: #fca5a5;
}

@media (prefers-reduced-motion: no-preference) {
  .quake-explain[aria-busy="true"] .quake-explain-status {
    animation: quake-explain-pulse 1.4s ease-in-out infinite;
  }
}

@keyframes quake-explain-pulse {
  50% { opacity: 0.45; }
}

@media (max-width: 900px) {
  .stats-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px), (max-width: 1024px) and (max-height: 500px) {
  .maplibregl-ctrl-group .maplibregl-ctrl-zoom-in,
  .maplibregl-ctrl-group .maplibregl-ctrl-zoom-out {
    display: none !important;
  }
}

@media (max-width: 640px) {
  body {
    padding: 6px;
  }

  .app-shell {
    gap: 6px;
  }

  .topbar {
    position: relative;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    border-radius: 13px;
    padding: 8px 10px;
  }

  .eyebrow {
    display: none;
  }

  .topbar h1 {
    font-size: clamp(1.3rem, 6vw, 1.55rem);
    padding-right: 42px;
  }

  .help-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .header-actions,
  .date-range {
    width: 100%;
    box-sizing: border-box;
  }

  .date-range {
    flex-wrap: nowrap;
    gap: 5px;
    padding: 2px;
    border-radius: 12px;
  }

  .header-actions {
    gap: 6px;
  }

  .range-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .range-presets {
    flex: 1;
    min-width: 0;
  }

  .range-preset {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0 6px;
  }

  .range-select {
    width: 96px;
    max-width: 28%;
    min-height: 44px;
    padding-left: 8px;
  }

  .status-pill {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 5px 10px;
  }

  .stats-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .stat-card {
    min-height: 54px;
    justify-content: center;
    gap: 3px;
    border-radius: 11px;
    padding: 6px 10px;
  }

  .stat-label {
    font-size: 0.6rem;
    letter-spacing: 0.09em;
  }

  .stat-card strong {
    overflow: hidden;
    font-size: clamp(1rem, 5vw, 1.22rem);
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #map-id {
    height: clamp(400px, 66svh, 620px);
    min-height: 0;
    border-radius: 16px;
  }

  .zoom-easter-egg {
    top: 62px;
    max-width: calc(100% - 24px);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.7rem;
  }

  .maplibregl-ctrl-top-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0 0 8px;
    box-sizing: border-box;
  }

  .maplibregl-ctrl-top-left > .maplibregl-ctrl,
  .maplibregl-ctrl-top-left > .maplibregl-ctrl + .maplibregl-ctrl {
    margin: 0;
  }

  .maplibregl-ctrl-group button {
    width: 44px;
    height: 44px;
  }

  .maplibregl-popup-close-button {
    width: 44px;
    height: 44px;
  }

  .maplibregl-popup {
    max-width: min(248px, calc(100vw - 76px)) !important;
  }

  .maplibregl-popup-content {
    padding: 10px 34px 10px 11px;
  }

  .base-panel {
    top: 8px;
    right: 8px;
    width: 132px;
    padding: 2px 10px;
    border-radius: 12px;
  }

  .base-panel.is-expanded {
    width: min(210px, calc(100% - 72px));
    padding: 4px 12px 10px;
    max-height: calc(100% - 16px);
    overflow-y: auto;
  }

  .base-panel-header {
    display: flex;
    min-height: 44px;
  }

  .base-panel-content {
    margin-top: 2px;
  }

  .base-option {
    min-height: 44px;
    font-size: 0.85rem;
  }

  .base-option input {
    width: 18px;
    height: 18px;
  }

  .legend-panel {
    position: relative;
    inset: auto;
    margin: 8px 0 0;
    transform: none;
    width: 100%;
    max-width: none;
    max-height: none;
    overflow: hidden;
    border-radius: 14px;
    padding: 6px 8px;
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 -6px 20px rgba(2, 6, 23, 0.4);
  }

  .legend-panel.is-expanded {
    display: block;
    overflow: visible;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .legend-header {
    width: 100%;
    min-height: 38px;
    padding: 0 2px 6px;
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
  }

  .legend-panel.is-expanded .legend-header {
    position: static;
    width: 100%;
    min-height: 38px;
    justify-content: space-between;
    padding: 0 2px 6px;
    border: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 0;
    background: transparent;
  }

  .legend-panel.is-expanded .legend-header h3 {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: nowrap;
  }

  .legend-content {
    width: 100%;
    max-height: none;
    margin-top: 0;
    padding: 6px 0 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
  }

  .legend-depth-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .legend-subtitle,
  .legend-desktop-copy,
  .legend-unit,
  .legend-section-divider {
    display: none;
  }

  .legend-mobile-copy,
  .cluster-legend-icon,
  .legend-reset-icon {
    display: inline;
  }

  /* Row 1: All 6 Depth Toggles in a clean 6-column grid */
  .legend-list {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
    width: 100%;
  }

  .legend-toggle {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 2px;
    font-size: clamp(0.55rem, 2.25vw, 0.68rem);
    font-weight: 700;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.45);
    color: #e2e8f0;
    box-sizing: border-box;
    white-space: nowrap;
  }

  .legend-toggle .legend-swatch {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
  }

  .legend-toggle .legend-label {
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Row 2: Supporting notes and reset button in clean 5-column grid */
  .legend-extra {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    width: 100%;
  }

  .magnitude-legend,
  .legend-note,
  .legend-reset {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 2px 2px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.38);
    color: #e2e8f0;
    font-size: clamp(0.5rem, 2.1vw, 0.65rem);
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
  }

  .magnitude-legend {
    border-left: 1px solid rgba(148, 163, 184, 0.25);
  }

  .magnitude-scale,
  .magnitude-legend .magnitude-item {
    gap: 4px;
  }

  .magnitude-legend .magnitude-shape.is-sphere {
    width: 15px;
    height: 15px;
  }

  .champion-epicenter-badge {
    width: 22px;
  }

  .cluster-legend-icon {
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.9);
    color: #fff;
    font-size: 0.54rem;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    flex: 0 0 auto;
  }

  .legend-reset-icon {
    font-size: 0.9rem;
    line-height: 1;
  }

}

@media (max-width: 640px) and (max-height: 700px) {
  .eyebrow {
    display: none;
  }

  .topbar {
    padding-block: 10px;
  }

  .stat-card {
    min-height: 58px;
    padding-block: 7px;
  }

  #map-id {
    height: clamp(360px, 60svh, 460px);
  }
}

@media (max-width: 1024px) and (max-height: 500px) { /* landscape phones, Pixel XL and iPhone Pro Max (915-932 px) included */
  body {
    padding: 8px;
  }

  .app-shell {
    gap: 8px;
  }

  .topbar {
    gap: 10px;
    border-radius: 14px;
    padding: 9px 12px;
  }

  .eyebrow {
    display: none;
  }

  .topbar h1 {
    font-size: 1.45rem;
  }

  .header-actions {
    flex-wrap: nowrap;
  }

  .stats-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-card {
    min-height: 56px;
    justify-content: center;
    gap: 4px;
    padding: 7px 10px;
  }

  .stat-label {
    font-size: 0.62rem;
  }

  .stat-card strong {
    overflow: hidden;
    font-size: 1.05rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #map-id {
    height: max(320px, 76svh);
    min-height: 0;
    border-radius: 16px;
  }

  .zoom-easter-egg {
    top: 60px;
    max-width: min(460px, calc(100% - 140px));
    padding: 7px 11px;
    font-size: 0.7rem;
  }

  .maplibregl-ctrl-top-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0 0 8px;
    box-sizing: border-box;
  }

  .maplibregl-ctrl-top-left > .maplibregl-ctrl,
  .maplibregl-ctrl-top-left > .maplibregl-ctrl + .maplibregl-ctrl {
    margin: 0;
  }

  .maplibregl-ctrl-group button,
  .maplibregl-popup-close-button {
    width: 44px;
    height: 44px;
  }

  .maplibregl-popup {
    max-width: min(250px, calc(100vw - 76px)) !important;
  }

  .base-panel {
    top: 8px;
    right: 8px;
    width: 132px;
    padding: 2px 10px;
    border-radius: 12px;
  }

  .base-panel.is-expanded {
    width: min(210px, calc(100% - 72px));
    padding: 4px 12px 10px;
  }

  .base-panel-header {
    display: flex;
    min-height: 44px;
  }

  .base-panel-content {
    margin-top: 2px;
  }

  .base-option {
    min-height: 44px;
  }

  .legend-panel {
    position: relative;
    inset: auto;
    margin: 8px 0 0;
    transform: none;
    width: 100%;
    max-width: none;
    max-height: none;
    overflow: hidden;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.96);
  }

  .legend-panel.is-expanded {
    display: flex;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }

  .legend-header {
    position: static;
    width: auto;
    min-height: 44px;
    padding-right: 8px;
    border-right: 1px solid rgba(148, 163, 184, 0.28);
  }

  .legend-content {
    min-width: 0;
    max-height: none;
    margin-top: 0;
    padding: 2px 0;
    overflow-x: auto;
    overflow-y: hidden;
  }
}

/* ==========================================================================
   Toolbar, Search & Magnitude Filters
   ========================================================================== */
.toolbar-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 14px;
  box-shadow: 0 10px 22px var(--shadow);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 240px;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 10px;
  font-size: 0.85rem;
  color: #94a3b8;
  pointer-events: none;
}

.search-box input[type="search"] {
  width: 100%;
  height: 34px;
  box-sizing: border-box;
  padding: 0 32px 0 32px;
  border-radius: 9px;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #f8fafc;
  font: inherit;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-box input[type="search"]::placeholder {
  color: #94a3b8;
  font-size: 0.78rem;
}

.search-box input[type="search"]:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.22);
}

.clear-search-btn {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.28);
  color: #cbd5e1;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
  z-index: 2;
}

.clear-search-btn:hover {
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
}

/* Search suggestions dropdown */
.search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 1200;
  overflow: hidden;
  animation: searchFadeIn 0.16s ease-out;
}

@keyframes searchFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-suggestions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(2, 6, 23, 0.5);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.search-suggestions-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: #7dd3fc;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.search-suggestions-zoomall {
  background: rgba(14, 165, 233, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-suggestions-zoomall:hover {
  background: #0ea5e9;
  color: #fff;
  border-color: #38bdf8;
}

.search-suggestions-list {
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow-y: auto;
}

.search-suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s ease;
  width: 100%;
}

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

.search-suggestion-item:hover,
.search-suggestion-item:focus-visible {
  background: rgba(56, 189, 248, 0.14);
  outline: none;
}

.search-item-mag {
  font-size: 0.74rem;
  font-weight: 800;
  color: #0f172a;
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.search-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.search-item-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-meta {
  font-size: 0.68rem;
  color: #94a3b8;
}

.search-suggestions-footer {
  padding: 6px 12px;
  font-size: 0.68rem;
  color: #94a3b8;
  text-align: center;
  background: rgba(2, 6, 23, 0.35);
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.search-no-results {
  padding: 12px;
  text-align: center;
}

.search-no-results p {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: #cbd5e1;
  line-height: 1.4;
}

.search-no-results strong {
  color: #f8fafc;
}

.search-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.search-range-quickbtn {
  background: rgba(14, 165, 233, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-range-quickbtn:hover {
  background: #0ea5e9;
  color: #fff;
  border-color: #38bdf8;
}

.plate-popup h3 {
  color: #fbbf24;
  margin: 0 0 8px;
  font-size: 0.95rem;
}

/* =========================================================================
   Victorian Airship (HMS Aetheria) Styles
   ========================================================================= */

.airship-btn-indicator {
  background: rgba(180, 83, 9, 0.22) !important;
  border-color: rgba(245, 158, 11, 0.45) !important;
  color: #fef08a !important;
  white-space: nowrap !important;
}

.airship-btn-indicator:hover {
  background: rgba(217, 119, 6, 0.4) !important;
  border-color: #fbbf24 !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

.airship-maplibre-popup {
  max-width: 340px !important;
  width: 340px !important;
  z-index: 1000 !important;
}

.airship-maplibre-popup {
  max-width: min(290px, calc(100vw - 24px)) !important;
  z-index: 1000 !important;
}

.airship-maplibre-popup {
  max-width: 340px !important;
  z-index: 1000 !important;
}

.airship-maplibre-popup .maplibregl-popup-content {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 100% !important;
}

.airship-popup {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  background: linear-gradient(180deg, #1c1308 0%, #0f172a 100%) !important;
  border: 1.5px solid rgba(251, 191, 36, 0.55) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75), inset 0 0 16px rgba(245, 158, 11, 0.15) !important;
  border-radius: 14px;
  padding: 12px 14px;
  color: #fef3c7;
  width: 320px;
  max-width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(251, 191, 36, 0.4) transparent;
}

.airship-popup::-webkit-scrollbar {
  width: 5px;
}

.airship-popup::-webkit-scrollbar-thumb {
  background: rgba(251, 191, 36, 0.4);
  border-radius: 4px;
}

.airship-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(251, 191, 36, 0.3);
  padding-bottom: 6px;
  margin-bottom: 2px;
  width: 100%;
}

.airship-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.airship-insignia {
  font-size: 1.35rem;
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.6));
  animation: gearSpin 12s linear infinite;
  flex-shrink: 0;
}

@keyframes gearSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.airship-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.airship-name {
  font-size: 1.05rem;
  font-weight: 900;
  color: #fef08a;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.45);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.airship-tier-tag {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.22);
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.45);
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.airship-subtitle {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: #cbd5e1;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.airship-steam-puff {
  font-size: 1.15rem;
  opacity: 0.6;
  transition: all 0.2s ease;
  user-select: none;
  cursor: pointer;
  flex-shrink: 0;
}

.airship-steam-puff:hover {
  opacity: 1;
  transform: scale(1.2);
}

.airship-steam-puff.puff-active {
  animation: steamBlast 0.8s ease-out;
}

@keyframes steamBlast {
  0% { transform: scale(1) translateY(0); opacity: 1; filter: drop-shadow(0 0 8px #fff); }
  50% { transform: scale(1.5) translateY(-6px); opacity: 0.8; }
  100% { transform: scale(1.9) translateY(-12px); opacity: 0; }
}

.airship-fleet-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  width: 100%;
  box-sizing: border-box;
}

.airship-fleet-tab {
  padding: 6px 2px;
  font-size: 0.74rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  text-align: center;
  font-family: inherit;
}

.airship-fleet-tab:hover {
  color: #fef08a;
  background: rgba(255, 255, 255, 0.08);
}

.airship-fleet-tab.is-active[data-vessel="0"] {
  background: #b45309;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.45);
}

.airship-fleet-tab.is-active[data-vessel="1"] {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.45);
}

.airship-fleet-tab.is-active[data-vessel="2"] {
  background: #e11d48;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.45);
}

.airship-3d-viewport {
  position: relative;
  width: 100%;
  height: 110px;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.9) 0%, rgba(2, 6, 23, 0.98) 100%);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.8);
  cursor: grab;
  box-sizing: border-box;
}

.airship-3d-viewport:active {
  cursor: grabbing;
}

.airship-3d-viewport canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.airship-3d-badge {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.airship-gauge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.airship-gauge {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 8px;
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gauge-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fbbf24;
  font-weight: 800;
}

.gauge-val {
  font-size: 0.86rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.airship-dispatch-card {
  background: rgba(15, 23, 42, 0.85);
  border-left: 3px solid #f59e0b;
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-left-width: 3px;
}

.dispatch-title {
  margin: 0 0 3px;
  font-size: 0.76rem;
  color: #fde68a;
  line-height: 1.25;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dispatch-tag {
  font-size: 0.58rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.3);
  color: #fef08a;
  letter-spacing: 0.04em;
}

.dispatch-note {
  margin: 0;
  font-size: 0.72rem;
  color: #e2e8f0;
  font-style: italic;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.airship-actions {
  display: flex;
  gap: 6px;
  width: 100%;
}

.airship-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(180, 83, 9, 0.35);
  color: #fef08a;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.airship-btn:hover {
  background: #d97706;
  color: #ffffff;
  border-color: #fef08a;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.airship-btn-follow.is-active {
  background: #0ea5e9;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.5);
}

/* Magnitude Filter Group Base Styles */
.mag-filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.mag-filter-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #cbd5e1;
  font-weight: 700;
  margin-right: 4px;
}

.mag-filter-chip {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.5);
  color: #cbd5e1;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.mag-filter-chip:hover {
  border-color: #7dd3fc;
  color: #f8fafc;
}

.mag-filter-chip.is-active {
  background: #0ea5e9;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35);
}

/* Origin Filter Group Base Styles */
.origin-filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.origin-filter-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #cbd5e1;
  font-weight: 700;
  margin-right: 4px;
}

.origin-filter-chip {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.5);
  color: #cbd5e1;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.origin-filter-chip:hover {
  border-color: #f59e0b;
  color: #fef3c7;
}

.origin-filter-chip.is-active {
  background: #d97706;
  border-color: #fbbf24;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.origin-filter-chip.induced-chip.is-active {
  background: linear-gradient(135deg, #b45309, #d97706);
  border-color: #fde68a;
  color: #fffbeb;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.45);
}

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

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(2, 6, 23, 0.5);
  color: #e2e8f0;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.toolbar-btn:hover {
  background: rgba(14, 165, 233, 0.18);
  border-color: #38bdf8;
  color: #f8fafc;
}

.toolbar-btn.is-active,
.toolbar-btn[aria-expanded="true"],
.toolbar-btn[aria-pressed="true"] {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.btn-icon {
  font-size: 0.82rem;
}

/* ==========================================================================
   Timelapse Scrubber Bar
   ========================================================================== */
.timelapse-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.95));
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.4);
  animation: slide-down 0.25s ease-out;
}

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

.timelapse-control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.timelapse-control-btn:hover {
  background: #0ea5e9;
  color: #ffffff;
  border-color: #38bdf8;
}

.timelapse-progress-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
}

.timelapse-progress-wrap input[type="range"] {
  width: 100%;
  accent-color: #38bdf8;
  cursor: pointer;
  height: 6px;
  border-radius: 4px;
}

.timelapse-time-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #93c5fd;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Activity Feed Drawer
   ========================================================================== */
.feed-drawer {
  position: absolute;
  top: 56px;
  right: 12px;
  width: 320px;
  max-height: min(480px, calc(72vh - 72px));
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(2, 6, 23, 0.6);
  z-index: 15;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drawer-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.feed-drawer[hidden] {
  display: none !important;
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

.feed-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 23, 0.4);
}

.feed-drawer-title h3 {
  margin: 0;
  font-size: 0.88rem;
  color: #f8fafc;
  font-weight: 700;
}

.feed-drawer-count {
  font-size: 0.7rem;
  color: #7dd3fc;
  font-weight: 600;
}

.feed-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: none;
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.feed-drawer-close:hover {
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
}

.feed-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overscroll-behavior: contain;
}

.feed-drawer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.16);
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  box-sizing: border-box;
}

.feed-drawer-item:hover,
.feed-drawer-item:focus-visible {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateX(-2px);
  outline: none;
}

.feed-drawer-mag {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 32px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.8rem;
  color: #0f172a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.feed-drawer-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.feed-drawer-place {
  font-size: 0.78rem;
  font-weight: 650;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-drawer-meta {
  font-size: 0.68rem;
  color: #94a3b8;
  display: flex;
  gap: 8px;
}

.feed-drawer-empty {
  text-align: center;
  font-size: 0.76rem;
  color: #94a3b8;
  padding: 24px 12px;
  margin: 0;
}

/* ==========================================================================
   Airship Expedition Drawer / Modal Overlay
   ========================================================================== */
.airship-drawer {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 330px;
  max-height: calc(100% - 20px);
  background: linear-gradient(180deg, rgba(28, 19, 10, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(251, 191, 36, 0.55);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8), inset 0 0 16px rgba(245, 158, 11, 0.15);
  z-index: 25;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drawer-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.airship-drawer[hidden] {
  display: none !important;
}

.airship-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.3);
  background: rgba(2, 6, 23, 0.4);
  flex-shrink: 0;
}

.airship-drawer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.airship-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(148, 163, 184, 0.18);
  color: #fef08a;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.airship-drawer-close:hover {
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
  border-color: #ef4444;
}

.airship-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(251, 191, 36, 0.4) transparent;
}

.airship-drawer-body::-webkit-scrollbar {
  width: 5px;
}

.airship-drawer-body::-webkit-scrollbar-thumb {
  background: rgba(251, 191, 36, 0.4);
  border-radius: 4px;
}

/* ==========================================================================
   Live 3D Airship Map Markers
   ========================================================================== */
.airship-3d-marker {
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
}

.airship-marker-inner {
  position: relative;
  width: 76px;
  height: 44px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.85));
  transition: transform 0.15s ease-out, filter 0.15s ease-out;
  transform-origin: center center;
}

.airship-marker-inner::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  border: 2.5px solid var(--ping-depth-color, #fbbf24);
  background: radial-gradient(circle, var(--ping-depth-color, #fbbf24) 0%, rgba(0, 0, 0, 0) 70%);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.airship-3d-marker:hover .airship-marker-inner {
  filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.95)) drop-shadow(0 10px 20px rgba(0, 0, 0, 0.95));
  transform: scale(1.15);
}

.airship-marker-inner.is-depth-pinging {
  animation: airshipDepthGlow 1.8s ease-out 2;
}

.airship-marker-inner.is-depth-pinging::before {
  animation: airshipDepthSonarRing 1.8s cubic-bezier(0.1, 0.8, 0.3, 1) 2;
}

@keyframes airshipDepthGlow {
  0% {
    filter: drop-shadow(0 0 4px var(--ping-depth-color, #fbbf24)) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.85));
    transform: scale(1);
  }
  25% {
    filter: drop-shadow(0 0 12px var(--ping-depth-color, #fbbf24)) drop-shadow(0 0 20px var(--ping-depth-color, #fbbf24)) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.9));
    transform: scale(1.08);
  }
  50% {
    filter: drop-shadow(0 0 8px var(--ping-depth-color, #fbbf24)) drop-shadow(0 0 12px var(--ping-depth-color, #fbbf24));
    transform: scale(1.03);
  }
  100% {
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.85));
    transform: scale(1);
  }
}

@keyframes airshipDepthSonarRing {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0.6;
  }
  60% {
    opacity: 0.35;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.6);
    opacity: 0;
  }
}

.airship-marker-inner canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   Quick Guide / Help Modal Dialog
   ========================================================================== */
.guide-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: guideFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.guide-modal-backdrop[hidden] {
  display: none !important;
}

.guide-modal {
  position: relative;
  width: 100%;
  max-width: 740px;
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  outline: none;
  animation: guideSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.guide-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.6);
}

.guide-modal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-header-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.guide-modal-title {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.01em;
}

.guide-modal-subtitle {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

.guide-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(148, 163, 184, 0.1);
  color: #cbd5e1;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.guide-modal-close:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  transform: scale(1.05);
}

.guide-modal-close:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.guide-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

.guide-modal-body::-webkit-scrollbar {
  width: 6px;
}

.guide-modal-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}

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

.guide-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.guide-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(15, 23, 42, 0.85);
  transform: translateY(-1px);
}

.guide-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1.2;
}

.guide-card-text {
  flex: 1;
  min-width: 0;
}

.guide-card-text h3 {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #7dd3fc;
}

.guide-card-text p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.guide-card-text strong {
  color: #f8fafc;
}

.guide-card-text em {
  color: #bae6fd;
  font-style: normal;
}

.guide-card-wide {
  grid-column: 1 / -1;
}

.guide-ship-list {
  margin: 8px 0 10px;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.guide-ship-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.guide-ship-item.is-north {
  border-left: 3px solid #fbbf24;
}

.guide-ship-item.is-equator {
  border-left: 3px solid #38bdf8;
}

.guide-ship-item.is-south {
  border-left: 3px solid #f43f5e;
}

.guide-ship-name {
  font-size: 0.82rem;
  font-weight: 700;
}

.guide-ship-item.is-north .guide-ship-name {
  color: #fde68a;
}

.guide-ship-item.is-equator .guide-ship-name {
  color: #bae6fd;
}

.guide-ship-item.is-south .guide-ship-name {
  color: #fecdd3;
}

.guide-ship-desc {
  font-size: 0.73rem;
  color: #94a3b8;
  line-height: 1.35;
}

.guide-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.7);
}

.guide-footer-tip {
  font-size: 0.78rem;
  color: #94a3b8;
}

.guide-footer-tip kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-family: inherit;
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 4px;
  color: #e2e8f0;
}

.guide-done-btn {
  padding: 8px 24px;
  min-height: 38px;
  border-radius: 12px;
  border: 0;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.guide-done-btn:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.45);
  transform: translateY(-1px);
}

.guide-done-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

@keyframes guideFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes guideSlideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 900px) {
  .toolbar-panel {
    gap: 10px;
  }

  .feed-drawer {
    width: 290px;
  }

  .airship-drawer {
    width: 300px;
  }
}

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .app-shell {
    gap: 8px;
  }

  .feed-drawer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 16px;
    z-index: 30;
  }

  .airship-drawer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 16px;
    z-index: 30;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }

  .header-actions {
    justify-content: space-between;
    width: 100%;
  }

  .date-range {
    flex: 1;
    justify-content: space-between;
    padding: 3px 6px 3px 8px;
  }

  .toolbar-panel {
    padding: 8px 10px;
    gap: 8px;
  }

  .search-box {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .mag-filters {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
  }

  .mag-filter-label {
    display: none;
  }

  .mag-filter-chip {
    flex: 1;
    min-width: 0;
    min-height: 32px;
    padding: 0 2px;
    font-size: clamp(0.65rem, 2.8vw, 0.76rem);
    text-align: center;
    width: 100%;
    box-sizing: border-box;
  }

  .toolbar-actions {
    flex: 1 1 100%;
    display: flex;
    gap: 6px;
    width: 100%;
  }

  .toolbar-btn {
    flex: 1;
    min-width: 0;
    min-height: 34px;
    justify-content: center;
    padding: 0 4px;
    font-size: clamp(0.65rem, 2.6vw, 0.74rem);
    white-space: nowrap;
    overflow: hidden;
  }

  .airship-maplibre-popup {
    position: fixed !important;
    top: auto !important;
    bottom: 12px !important;
    left: 12px !important;
    right: 12px !important;
    transform: none !important;
    max-width: none !important;
    width: auto !important;
    margin: 0 !important;
    z-index: 1000 !important;
  }

  .airship-maplibre-popup .maplibregl-popup-tip {
    display: none !important;
  }

  .airship-popup {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.8) !important;
    max-height: 60vh !important;
    padding: 12px 14px !important;
  }

  .stats-panel {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .stat-card {
    padding: 8px 10px;
    min-height: 52px;
  }

  .stat-card strong {
    font-size: 1.15rem;
  }

  #map-id {
    height: clamp(360px, 56vh, 520px);
    border-radius: 16px;
  }

  .feed-drawer {
    position: absolute;
    top: auto;
    bottom: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 48%;
    z-index: 25;
    border-radius: 14px;
    box-shadow: 0 -8px 28px rgba(2, 6, 23, 0.75);
    animation: drawer-slide-up 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes drawer-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .feed-drawer[hidden] {
    display: none !important;
  }

  .guide-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .guide-ship-list {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .guide-modal {
    max-height: 92vh;
    border-radius: 16px;
  }

  .guide-modal-header {
    padding: 12px 14px;
  }

  .guide-modal-body {
    padding: 12px 14px;
  }

  .guide-modal-footer {
    padding: 10px 14px;
  }

  .guide-footer-tip {
    display: none;
  }

  .guide-done-btn {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 360px) {
  .stats-panel {
    grid-template-columns: 1fr;
  }

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

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ==========================================================================
   Tsunami Warning Alert System Styles
   ========================================================================== */

.tsunami-alert-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(8, 47, 73, 0.95), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-left: 5px solid #38bdf8;
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: tsunamiBannerGlow 3s infinite alternate ease-in-out;
}

.tsunami-alert-banner[hidden] {
  display: none !important;
}

@keyframes tsunamiBannerGlow {
  0% {
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(56, 189, 248, 0.45);
  }
  100% {
    box-shadow: 0 8px 30px rgba(56, 189, 248, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(125, 211, 252, 0.85);
  }
}

.tsunami-alert-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tsunami-alert-icon {
  font-size: 1.5rem;
  line-height: 1;
  display: inline-flex;
  animation: tsunamiWaveBob 2s infinite ease-in-out;
}

@keyframes tsunamiWaveBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.1); }
}

.tsunami-alert-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tsunami-alert-text strong {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #38bdf8;
  font-weight: 800;
}

.tsunami-alert-text span {
  font-size: 0.78rem;
  color: #e2e8f0;
}

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

.tsunami-action-btn {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: rgba(14, 165, 233, 0.15);
  color: #e0f2fe;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.tsunami-action-btn:hover,
.tsunami-action-btn:focus-visible {
  background: rgba(14, 165, 233, 0.35);
  border-color: #38bdf8;
  color: #fff;
  outline: 2px solid rgba(56, 189, 248, 0.3);
  outline-offset: 1px;
}

.tsunami-action-btn.is-active,
.tsunami-action-btn[aria-pressed="true"] {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.tsunami-action-btn--primary {
  background: #0284c7;
  border-color: #38bdf8;
  color: #fff;
}

.tsunami-action-btn--primary:hover {
  background: #0369a1;
}

/* Tsunami Filter Chip */
.mag-filter-chip.tsunami-chip {
  background: rgba(2, 132, 199, 0.2);
  border-color: rgba(56, 189, 248, 0.4);
  color: #7dd3fc;
}

.mag-filter-chip.tsunami-chip:hover,
.mag-filter-chip.tsunami-chip:focus-visible {
  background: rgba(2, 132, 199, 0.4);
  border-color: #38bdf8;
  color: #ffffff;
}

.mag-filter-chip.tsunami-chip.is-active,
.mag-filter-chip.tsunami-chip[aria-pressed="true"] {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* Tsunami Popup Badge */
.tsunami-popup-badge {
  margin: 6px 0 8px 0;
  padding: 5px 9px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(8, 47, 73, 0.9), rgba(2, 132, 199, 0.85));
  border: 1px solid rgba(56, 189, 248, 0.6);
  color: #f0f9ff;
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

/* Feed Drawer Tsunami Tag */
.feed-drawer-tsunami-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #38bdf8;
  background: rgba(2, 132, 199, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
}

/* ==========================================================================
   Seismic Sonification Audio Controls
   ========================================================================== */

.toolbar-btn.audio-btn {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #94a3b8;
  transition: all 0.2s ease;
}

.toolbar-btn.audio-btn:hover {
  border-color: #38bdf8;
  color: #e2e8f0;
}

.toolbar-btn.audio-btn.is-active,
.toolbar-btn.audio-btn[aria-pressed="true"] {
  background: rgba(14, 165, 233, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.toolbar-btn.audio-btn.is-active .btn-icon {
  animation: audioWavePulse 2s infinite ease-in-out;
}

@keyframes audioWavePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ==========================================================================
   Feed Drawer Actions & Data Export Buttons
   ========================================================================== */
.feed-drawer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.feed-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(14, 165, 233, 0.15);
  color: #7dd3fc;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.feed-action-btn:hover,
.feed-action-btn:focus-visible {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  outline: none;
}

/* ==========================================================================
   PAGER Emergency Badges & Feed Tags
   ========================================================================== */
.pager-popup-badge {
  margin: 6px 0 8px 0;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
}

.pager-popup-badge.pager-green {
  background: linear-gradient(135deg, rgba(20, 83, 45, 0.9), rgba(34, 197, 94, 0.85));
  border: 1px solid rgba(74, 222, 128, 0.6);
  color: #f0fdf4;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.pager-popup-badge.pager-yellow {
  background: linear-gradient(135deg, rgba(113, 63, 18, 0.9), rgba(234, 179, 8, 0.85));
  border: 1px solid rgba(250, 204, 21, 0.6);
  color: #fefce8;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.3);
}

.pager-popup-badge.pager-orange {
  background: linear-gradient(135deg, rgba(124, 45, 18, 0.9), rgba(249, 115, 22, 0.85));
  border: 1px solid rgba(251, 146, 60, 0.6);
  color: #fff7ed;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.pager-popup-badge.pager-red {
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.9), rgba(239, 68, 68, 0.9));
  border: 1px solid rgba(248, 113, 113, 0.6);
  color: #fef2f2;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.feed-drawer-pager-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 4px;
}

.feed-drawer-pager-tag.pager-green {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(74, 222, 128, 0.45);
  color: #86efac;
}

.feed-drawer-pager-tag.pager-yellow {
  background: rgba(234, 179, 8, 0.2);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: #fde047;
}

.feed-drawer-pager-tag.pager-orange {
  background: rgba(249, 115, 22, 0.2);
  border: 1px solid rgba(251, 146, 60, 0.45);
  color: #fdba74;
}

.feed-drawer-pager-tag.pager-red {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(248, 113, 113, 0.55);
  color: #fca5a5;
}

.feed-drawer-felt-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.18);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #cbd5e1;
  margin-left: 4px;
}

/* ==========================================================================
   Human-Induced Origin Badges & Tags
   ========================================================================== */
.origin-popup-badge {
  margin: 6px 0 8px 0;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
}

.origin-popup-badge.origin-induced {
  background: linear-gradient(135deg, rgba(146, 64, 14, 0.9), rgba(217, 119, 6, 0.85));
  border: 1px solid rgba(251, 191, 36, 0.65);
  color: #fffbeb;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
}

.feed-drawer-tag.feed-drawer-induced-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(217, 119, 6, 0.25);
  border: 1px solid rgba(251, 191, 36, 0.55);
  color: #fef08a;
  margin-left: 4px;
}

.stat-card.stat-card--induced strong {
  color: #fcd34d;
}

.feed-drawer-mag.feed-drawer-mag-induced {
  border-radius: 6px !important;
  border: 2px solid #fbbf24 !important;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.55) !important;
}


/* Tsunami flag wording (2026-11): the badge holds text plus a tsunami.gov link */
.tsunami-popup-badge {
  display: block;
  grid-column: 1 / -1;
  line-height: 1.35;
}

.tsunami-popup-badge a {
  color: #fff;
  text-decoration: underline;
}

a.tsunami-action-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
