:root {
  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-root-size: clamp(14px, 1.1vw + 10px, 18px);
  --fs-xs: clamp(11px, 0.2vw + 10px, 12px);
  --fs-sm: clamp(12px, 0.3vw + 10px, 13px);
  --fs-md: clamp(13px, 0.5vw + 10px, 15px);
  --fs-lg: clamp(16px, 0.8vw + 10px, 18px);
  --fs-xl: clamp(18px, 1.2vw + 10px, 22px);

  /* Colors (neutral dark) */
  --bg0: #0b1220;
  --bg1: #0f172a;
  --bg2: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;

  /* Spacing (8px rhythm) */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;

  /* Radius/shadows */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 4px 12px rgba(0,0,0,0.3);
}

html { font-size: var(--font-root-size); }

/* Base Reset & Layout */
html, body { height: 100%; margin: 0; background: var(--bg0); color: var(--text); overflow: hidden; font-family: var(--font-sans); }

/* Globe Container - CRITICAL: Must be visible and full screen */
#globe-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: var(--bg0);
}

/* 🚨 Critical Announcement Bar */
.announcement-bar {
  position: fixed;
  top: 50px; /* Below header */
  left: 0;
  right: 0;
  height: 0;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 0.98) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
  z-index: 2999; /* Just below header */
  display: flex;
  align-items: center;
  padding: 0 24px;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.announcement-bar.show {
  height: 56px;
}

.announcement-bar.slide-out {
  animation: slideOutLeft 0.6s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes slideOutLeft {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(-100%);
    opacity: 0;
  }
}

.announcement-content {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  opacity: 0;
  transition: opacity 0.3s ease 0.2s;
}

.announcement-bar.show .announcement-content {
  opacity: 1;
}

.announcement-icon {
  font-size: 24px;
  flex-shrink: 0;
  animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.announcement-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.announcement-title {
  font-size: 14px;
  font-weight: 600;
  color: #fca5a5;
  letter-spacing: 0.3px;
}

.announcement-message {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 400;
}

.announcement-close {
  background: rgba(51, 65, 85, 0.6);
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s;
  flex-shrink: 0;
}

.announcement-close:hover {
  background: #475569;
  transform: translateY(-1px);
}

/* Announcement bar variants */
.announcement-bar.cascade {
  border-bottom-color: rgba(239, 68, 68, 0.4);
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.95) 0%, rgba(153, 27, 27, 0.95) 100%);
}

.announcement-bar.training {
  border-bottom-color: rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.95) 0%, rgba(29, 78, 216, 0.95) 100%);
}

.announcement-bar.training .announcement-title {
  color: #93c5fd;
}

.announcement-bar.fire-risk {
  border-bottom-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(135deg, rgba(124, 45, 18, 0.95) 0%, rgba(161, 98, 7, 0.95) 100%);
}

.announcement-bar.fire-risk .announcement-title {
  color: #fbbf24;
}

/* 🔍 Disaster Search Bar Styles */
.disaster-search-container {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 1126px);
  max-width: none;
  min-width: 400px;
  z-index: 1;
}

.disaster-search-wrapper {
  position: relative;
  background: rgba(30, 41, 59, 0.6);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.disaster-search-wrapper:focus-within {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.disaster-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 10px;
}

.disaster-search-icon {
  color: #94a3b8;
  flex-shrink: 0;
  margin-right: 6px;
}

.disaster-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e2e8f0;
  font-size: 13px;
  padding: 8px 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.disaster-search-input::placeholder {
  color: #64748b;
  font-size: 12px;
}

.disaster-search-clear {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-left: 6px;
}

.disaster-search-clear:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.disaster-search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 3100;
}

.disaster-search-suggestions-title {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.disaster-search-suggestion {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #cbd5e1;
  font-size: 13px;
}

.disaster-search-suggestion:hover,
.disaster-search-suggestion.selected {
  background: rgba(59, 130, 246, 0.15);
  color: #e2e8f0;
}

.disaster-search-suggestion-icon {
  color: #64748b;
  flex-shrink: 0;
  margin-right: 10px;
}

.disaster-search-suggestion strong {
  color: #3b82f6;
  font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .disaster-search-container {
    max-width: 300px;
  }

  .disaster-search-input {
    font-size: 12px;
    padding: 7px 0;
  }

  .disaster-search-input::placeholder {
    font-size: 11px;
  }
}

@media (max-width: 768px) {
  .disaster-search-container {
    display: none; /* Hide on mobile to save space */
  }
}

/* Satellite/Map Layer dropdown items (used in header dropdown) */
.mlc-item {
  width: 100%;
  text-align: left;
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 4px;
}
.mlc-item:hover {
  background: rgba(255,255,255,0.08);
  border-color: #475569;
}
.mlc-item.active {
  background: #133253;
  color: #eaf3ff;
  border-color: #1e4976;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #374151;
  border: 1px solid #4b5563;
  color: #e5e7eb;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.modal-close:hover { background: #4b5563; }

.modal h2 {
  margin: 0 0 16px;
  color: #06b6d4;
  font-size: 20px;
}

.modal p {
  line-height: 1.6;
  margin: 0 0 12px;
  color: #d1d5db;
}

.modal ul {
  margin: 12px 0 12px 20px;
  padding: 0;
}

.modal li {
  margin: 4px 0;
  color: #9ca3af;
  font-size: 14px;
}

/* Attribution */
.attribution {
  position: fixed;
  bottom: 8px;
  left: 8px;
  z-index: 1000;
  background: rgba(10, 14, 26, 0.9);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  color: #6b7280;
  border: 1px solid #374151;
}

/* Status indicator */
.status {
  position: fixed;
  top: 60px;
  left: 12px;
  z-index: 1000;
  background: #1e293b;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #06b6d4;
  border: 1px solid #374151;
  transition: opacity 0.3s;
}

.status.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Header Styling */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #1e293b;
  z-index: 3000; /* raised to ensure dropdown overlays */
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 20px;
  font-family: system-ui, -apple-system, sans-serif;
  overflow: visible; /* allow dropdown to escape */
  gap: 20px;
}

.header h1 {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  grid-column: 1;
}

.header-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(51, 65, 85, 0.6);
  border: 1px solid #475569;
  border-radius: 6px;
  color: #e2e8f0;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.header-tab:hover {
  background: rgba(71, 85, 105, 0.8);
  border-color: #60a5fa;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(96, 165, 250, 0.2);
}

.header-tab .tab-icon {
  font-size: 14px;
  line-height: 1;
}

.header-tab .tab-label {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 3;
  justify-self: end;
}

.header button {
  background: #334155;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.header button:hover {
  background: #475569;
  transform: translateY(-1px);
}

/* old map-layer-* styles removed in favor of .mlc */

.clock {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.7);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #374151;
}

.alert-tabs {
  display: flex;
  gap: 4px;
}

.alert-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid #374151;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.alert-tab:hover {
  background: rgba(51, 65, 85, 0.8);
}

/* Dropdown panel for Fire Alerts tab */
.dropdown-parent { position: relative; }
.dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(12px);
  border: 1px solid #334155;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.5);
  z-index: 9999;
  display: none;
  flex-direction: column;
  padding: 8px;
  gap: 6px;
  animation: dropdown-pop .2s cubic-bezier(.4,.14,.3,1);
}
.dropdown-panel.show { display: flex; }
.dropdown-header {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  padding: 4px 8px;
  letter-spacing: 0.5px;
}
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 12px;
  color: #cbd5e1;
}
.dropdown-item:hover {
  background: rgba(255,255,255,0.08);
  border-color: #475569;
}
.dropdown-item .label { font-weight: 500; }
.dropdown-item .count {
  font-weight: 700;
  color: #38bdf8;
  font-size: 11px;
}
.dropdown-divider {
  height: 1px;
  background: #334155;
  margin: 4px 0;
}

.tab-icon {
  font-size: 14px;
}

.tab-label {
  font-size: 11px;
  font-weight: 500;
  color: #cbd5e1;
}

.alert-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  display: none;
}

.alert-dot.active {
  display: block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Alert Panel Styling (compact dropdown anchored to Fire tab) */
#alert-panel {
  position: fixed;
  top: 55px;
  right: 12px; /* keep near edge to avoid off-screen on small widths */
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  background: linear-gradient(145deg,rgba(17,25,39,0.95),rgba(15,23,42,0.98));
  backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid #1e293b;
  border-radius: 14px;
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.7), 0 0 0 1px rgba(56,72,95,0.3);
  z-index: 9999; /* ensure panel sits above header and all other layers */
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: dropdown-pop .22s cubic-bezier(.4,.14,.3,1);
}

@keyframes dropdown-pop {
  from { opacity:0; transform: translateY(-8px) scale(.96); }
  to { opacity:1; transform: translateY(0) scale(1); }
}

#alert-panel.show { display: flex; }

.panel-fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes panel-slide-in {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Seismic Waves Panel Styles */
.seismic-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.5);
}

.seismic-panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #f1f5f9;
}

.seismic-panel-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.seismic-panel-close:hover {
  background: rgba(148, 163, 184, 0.1);
  color: #f1f5f9;
}

.seismic-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.seismic-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.seismic-earthquake-card {
  transition: all 0.2s ease;
}

.seismic-earthquake-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

#alert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px 8px;
  background: rgba(30,41,59,0.55);
  border-bottom: 1px solid #243246;
  backdrop-filter: blur(6px) saturate(150%);
}

/* Heartbeat chip */
.hb-chip {
  display:inline-flex; align-items:center; gap:6px;
  background:#0f172a; border:1px solid #334155; color:#93c5fd;
  padding:4px 8px; border-radius:999px; font-size:10px; font-weight:600;
}
.hb-chip.ok { color:#86efac; border-color:#3f9f6b; }
.hb-chip.move { color:#facc15; border-color:#ca8a04; }
.hb-chip.pulse { animation: hb-pulse 1s ease-in-out infinite; }
@keyframes hb-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(148,163,184,0.2); }
  50% { box-shadow: 0 0 0 6px rgba(148,163,184,0.08); }
}

.alert-panel-tabs {
  display: flex;
  gap: 8px;
}

.panel-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(51, 65, 85, 0.7);
  border: 1px solid #475569;
  border-radius: 6px;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.panel-tab:hover {
  background: rgba(71, 85, 105, 0.8);
}

.panel-tab.active {
  background: #0891b2;
  border-color: #06b6d4;
  color: white;
}

#alert-header button {
  background: #334155;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}

#alert-header button:hover {
  background: #475569;
}

.alert-content {
  flex: 1;
  overflow: auto; /* allow scrolling instead of clipping */
  padding: 10px 14px 12px;
  display: none;
  background: radial-gradient(circle at 20% 15%, rgba(24,35,52,0.55), rgba(15,23,42,0.4));
  min-height: 0; /* critical: allows flex child to shrink and scroll */
}

.alert-content.active {
  display: flex; /* use flex to properly size children */
  flex-direction: column;
}

/* Minimal Controls Panel */
#controls {
  position: fixed;
  top: 60px;
  left: 12px;
  z-index: 1200; /* ensure below floating AI bubble (1500) but above globe */
  background: rgba(15,23,42,0.88);
  backdrop-filter: blur(10px) saturate(160%);
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 10px 12px 12px;
  font-size: 11px;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 6px 22px -6px rgba(0,0,0,0.55), 0 0 0 1px rgba(148,163,184,0.05);
  transition: width .25s, height .25s, padding .25s, background .25s;
  max-height: 62vh; /* leave space for floating panels */
  overflow-y: auto;
  overflow-x: hidden;
}

#controls.collapsed {
  width: 58px;
  min-width: 58px;
  padding: 8px 6px 10px;
  gap:6px;
}

#controls.collapsed .control-section,
#controls.collapsed .field,
#controls.collapsed h3,
#controls.collapsed button:not(.collapse-toggle),
#controls.collapsed #data-summary,
#controls.collapsed #legend {
  display: none !important;
}

#controls .collapse-toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background:#1e293b;
  border:1px solid #334155;
  color:#94a3b8;
  cursor:pointer;
  font-size:14px;
  display:flex;
  align-items:center;
  justify-content:center;
}

#controls .collapse-toggle:hover {
  background:#334155;
  color:#e2e8f0;
}

#controls.collapsed .collapse-toggle {
  position: static;
  margin:0 auto;
  width:38px;
  height:38px;
  font-size:16px;
}

#controls h3 {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .5px;
  color: #38bdf8;
}

#controls .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#controls label {
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
}

#controls select, #controls input {
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  color: #e5e7eb;
  border-radius: 6px;
  padding: 6px 7px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color .18s, background .18s;
}

#controls select:focus, #controls input:focus {
  outline: none;
  border-color: #06b6d4;
  background: #253244;
}

#controls button {
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  padding: 7px 10px;
  transition: background .2s, transform .15s;
}

#controls button.primary {
  background: #06b6d4;
  color: #fff;
  border: none;
}

#controls button.primary:hover {
  background: #0891b2;
}

#controls button.secondary {
  background: #334155;
  color: #e5e7eb;
  border: 1px solid #475569;
}

#controls button.secondary:hover {
  background: #475569;
}

#controls button:active {
  transform: translateY(1px);
}

#controls #data-summary {
  font-size: 10px;
  color: #64748b;
  line-height: 1.35;
  border-top: 1px solid #1e2d3f;
  padding-top: 5px;
  margin-top: 2px;
}

#controls .note {
  font-size: 10px;
  color: #64748b;
  margin-top: -4px;
  line-height: 1.3;
}

#legend {
  margin-top:4px;
  padding:8px 8px 10px;
  border:1px solid #243247;
  border-radius:10px;
  background:linear-gradient(145deg,rgba(31,41,55,0.55),rgba(17,25,39,0.55));
  box-shadow: inset 0 0 0 1px rgba(148,163,184,0.05);
}

#legend-title {
  font-weight:600;
  font-size:11px;
  letter-spacing:.5px;
  color:#38bdf8;
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:6px;
}

#legend .gradient-bar {
  height:8px;
  background:linear-gradient(90deg,#00ff66,#b8ff33,#ffa600,#ff5e00,#ff0000);
  border-radius:4px;
  margin-bottom:4px;
}

#legend .legend-scale {
  display:flex;
  justify-content:space-between;
  color:#94a3b8;
  font-size:9px;
  margin-bottom:4px;
}

#legend small {
  display:block;
  font-size:9px;
  color:#64748b;
  margin-top:2px;
}

#legend button {
  margin-top:6px;
  width:100%;
  background:#1e293b !important;
  border:1px solid #334155 !important;
  padding:5px 6px !important;
  font-size:10px !important;
}

#legend button:hover {
  background:#2b3a4f !important;
}

@media (max-height: 760px) {
  #controls { max-height: 60vh; }
}


/* Mobile Bottom Sheet for Fast Panel V2 */
@media (max-width: 768px) {
  #hex-fast-panel-v2.bottom-sheet {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    background: var(--bg1);
    color: var(--text);
    border: 1px solid #1f2937;
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.45);
    padding: var(--space-2);
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    z-index: 10000;
    overflow: hidden;
    transition: height .2s ease, transform .18s ease;
    backdrop-filter: saturate(140%) blur(8px);
  }

  #hex-fast-panel-v2.bottom-sheet .sheet-content {
    overflow-y: auto;
    height: calc(100% - 28px - var(--space-2));
    -webkit-overflow-scrolling: touch;
    padding-right: 6px; /* avoid overlay with scrollbar */
  }

  #hex-fast-panel-v2.bottom-sheet .sheet-handle {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(148,163,184,0.6);
    margin: 6px auto 8px auto;
  }

  #hex-fast-panel-v2.bottom-sheet .close-btn {
    top: 8px;
    right: 10px;
  }

  #hex-fast-panel-v2.bottom-sheet[data-state="peek"] {
    height: 76px; /* header row visible */
  }
  #hex-fast-panel-v2.bottom-sheet[data-state="half"] {
    height: 52vh;
  }
  #hex-fast-panel-v2.bottom-sheet[data-state="full"] {
    height: calc(100vh - 16px - env(safe-area-inset-top));
  }

  /* Mobile header overflow fix: make right-side nav horizontally scrollable */
  .header {
    padding: 0 var(--space-2);
  }
  .header-right {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: var(--space-2);
    max-width: 100vw;
    scrollbar-width: none; /* Firefox */
  }
  .header-right::-webkit-scrollbar { display: none; }
  .header-right > * {
    flex: 0 0 auto;
    min-width: max-content;
  }

}
