:root {
  --bg-dark: #0f1720;
  --panel-bg: rgba(15, 23, 32, 0.94);
  --panel-border: #23313f;
  --accent: #2a9df4;
  --accent-soft: #1c3a52;
  --text: #e7edf3;
  --muted: #8ba0b3;
  --danger: #e0563f;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 14px;
}

#map-frame {
  position: absolute;
  top: 52px; left: 0; right: 320px; bottom: 0;
  z-index: 0;
  overflow: hidden;
  transition: right 0.2s ease;
}
body.panel-collapsed #map-frame { right: 0; }

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #0b1119;
}

/* ---------- Top bar ---------- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(4px);
}
#brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-weight: 700; font-size: 20px; letter-spacing: 1px; color: var(--accent); }
.brand-sub { font-size: 12px; color: var(--muted); }
#cycle-badge {
  margin-left: auto;
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
}
#panel-toggle {
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 16px;
}
#panel-toggle:hover { background: rgba(255,255,255,0.06); }

/* ---------- Side panel ---------- */
#panel {
  position: absolute;
  top: 52px; right: 0; bottom: 0;
  z-index: 900;
  width: 320px;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  transition: transform 0.2s ease;
  overflow: hidden;
}
#panel.collapsed { transform: translateX(320px); }
.panel-scroll { height: 100%; overflow-y: auto; padding: 12px 16px 24px; }

.panel-section { margin-bottom: 18px; }
.panel-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}

.category-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tab {
  flex: 1 1 auto;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.cat-tab.active { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.cat-tab.disabled { opacity: 0.4; cursor: not-allowed; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
}
.chip.active { background: var(--accent); color: #06202f; border-color: var(--accent); font-weight: 600; }
.chip:disabled { opacity: 0.35; cursor: not-allowed; }

.layer-group-heading {
  font-size: 11px;
  color: var(--accent);
  margin: 10px 0 4px;
  font-weight: 600;
}
.layer-option {
  padding: 3px 0;
  font-size: 13px;
}
.layer-option label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.layer-option.unavailable label { color: var(--muted); cursor: not-allowed; }
.layer-option input { accent-color: var(--accent); }
.layer-note { font-size: 11px; color: var(--muted); margin-left: 24px; }
.issue-note {
  font-size: 11px;
  color: var(--danger);
  margin: 4px 0 0 24px;
  line-height: 1.4;
}

.synthetic-note {
  font-size: 11px;
  color: #ffb020;
  background: rgba(255, 176, 32, 0.1);
  border: 1px solid rgba(255, 176, 32, 0.35);
  border-radius: 4px;
  margin: 6px 0 0 24px;
  padding: 5px 7px;
  line-height: 1.4;
  font-weight: 600;
}

.info-note {
  font-size: 11px;
  color: var(--accent);
  background: rgba(42, 157, 244, 0.1);
  border: 1px solid rgba(42, 157, 244, 0.35);
  border-radius: 4px;
  margin: 6px 0 0 24px;
  padding: 5px 7px;
  line-height: 1.4;
  font-weight: 600;
}

#synthetic-wind-banner {
  position: absolute;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  max-width: 620px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
#synthetic-wind-banner.hidden { display: none; }
#synthetic-wind-banner.info { background: #0d2436; border: 1px solid var(--accent); color: #bfe3ff; }
#synthetic-wind-banner.warn { background: #2a1c05; border: 1px solid #ffb020; color: #ffd88a; }

#level-slider { width: 100%; accent-color: var(--accent); }
#level-readout { font-size: 12px; color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); font-size: 11px; }

#dataset-info-body { font-size: 12px; line-height: 1.6; }
#dataset-info-body b { color: var(--text); }

/* ---------- Legend ---------- */
#legend {
  position: absolute;
  left: 16px; bottom: 74px;
  z-index: 900;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 220px;
}
#legend-title { font-size: 12px; margin-bottom: 6px; color: var(--text); }
#legend-bar { height: 10px; border-radius: 3px; }
#legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}
#legend-bands { display: flex; flex-direction: column; gap: 4px; max-width: 260px; }
.legend-band-row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.legend-band-swatch {
  width: 16px; height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.25);
  flex: none;
}
.legend-band-label { color: var(--text); }
.legend-band-range { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
#legend-note {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.4;
  max-width: 280px;
}

/* ---------- Playback bar ---------- */
#playback-bar {
  position: absolute;
  left: 16px; right: 352px; bottom: 16px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 12px;
}
#play-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: not-allowed;
}
.playback-track {
  flex: 1;
  display: flex;
  gap: 4px;
}
.playback-frame {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}
.playback-frame.active { background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent); }
.playback-speed select {
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  font-size: 11px;
  padding: 4px;
}
.playback-note {
  font-size: 10.5px;
  color: var(--muted);
  max-width: 260px;
  line-height: 1.3;
}

/* ---------- Inspect panel ---------- */
#inspect-panel {
  position: absolute;
  left: 16px; top: 68px;
  z-index: 950;
  width: 300px;
  max-height: calc(100% - 160px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}
#inspect-panel.hidden { display: none; }
#inspect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 13px;
  font-weight: 600;
}
#inspect-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
#inspect-body { padding: 10px 12px; }
#inspect-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 10px; }
#inspect-table td { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
#inspect-table td:first-child { color: var(--muted); }
#inspect-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#sounding-chart-wrap { position: relative; height: 240px; width: 100%; }

/* ---------- Toast ---------- */
#toast {
  position: absolute;
  bottom: 90px; left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: #241417;
  border: 1px solid var(--danger);
  color: #ffd9d0;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  max-width: 480px;
}
#toast.hidden { display: none; }

/* City pin popups (MapLibre GL / MapTiler SDK popup classes) */
.maplibregl-popup-content { background: #101820; color: var(--text); padding: 10px 12px; }
.maplibregl-popup-tip { border-top-color: #101820 !important; border-bottom-color: #101820 !important; }
.city-popup table { font-size: 12px; border-collapse: collapse; }
.city-popup td { padding: 2px 6px 2px 0; }
.city-popup td:first-child { color: var(--muted); }
.city-marker-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #0f1720;
  border: 2px solid var(--accent);
  cursor: pointer;
}
.city-marker-label {
  background: rgba(10,16,22,0.85);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

/* SAF training area pins -- square/olive to read as distinct from round blue city pins */
.training-marker-icon {
  width: 14px; height: 14px;
  background: #6b7a3d;
  border: 2px solid #cfe0a0;
  transform: rotate(45deg);
  box-shadow: 0 0 3px rgba(0,0,0,0.6);
  cursor: pointer;
}
.training-popup .kind-tag {
  display: inline-block;
  font-size: 10px;
  color: #a8bf78;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.training-popup .caveat {
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
  max-width: 220px;
}

/* ---------- Location search ---------- */
#search-wrap { position: relative; width: 260px; margin-left: 16px; }
#location-search {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12.5px;
}
#location-search:focus { outline: none; border-color: var(--accent); }
#search-results {
  position: absolute;
  top: 34px; left: 0; right: 0;
  background: #101820;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1300;
}
#search-results.hidden { display: none; }
.search-result-item {
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(255,255,255,0.06); }
.search-result-item .sr-type { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.search-result-empty { padding: 8px 10px; font-size: 12px; color: var(--muted); }

/* ---------- Notification bell ---------- */
#notif-bell {
  position: relative;
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 15px;
  margin-left: 10px;
}
#notif-bell:hover { background: rgba(255,255,255,0.06); }
#notif-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
#notif-badge.hidden { display: none; }
#notif-panel {
  position: absolute;
  top: 52px; right: 16px;
  z-index: 1300;
  width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: #101820;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}
#notif-panel.hidden { display: none; }
.notif-item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 12px;
  line-height: 1.4;
}
.notif-item:last-child { border-bottom: none; }
.notif-item .notif-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notif-item .notif-body { color: var(--muted); }
.notif-empty { padding: 14px 12px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Custom map navigation control widget ---------- */
.nav-control-widget {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 10px 10px 0 0;
}
.nav-dpad {
  display: grid;
  grid-template-columns: 24px 24px 24px;
  grid-template-rows: 24px 24px 24px;
  gap: 2px;
}
.nav-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.nav-btn:hover { background: var(--accent-soft); }
.nav-center { font-size: 13px; }
.nav-zoom { display: flex; gap: 4px; }
.nav-zoom .nav-btn { width: 24px; height: 24px; font-size: 14px; font-weight: 700; }

/* ---------- Saved views ---------- */
#saved-views-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.saved-view-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
}
.saved-view-row .sv-name { cursor: pointer; flex: 1; }
.saved-view-row .sv-name:hover { color: var(--accent); }
.saved-view-row .sv-delete { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; }
#save-view-row { display: flex; gap: 6px; margin-top: 8px; }
#save-view-name {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 4px;
  padding: 5px 7px;
  font-size: 12px;
}
#save-view-btn {
  background: var(--accent);
  color: #06202f;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Disabled category placeholder ---------- */
#category-unavailable.hidden { display: none; }
.cu-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cu-title::before { content: "⚠"; color: #ffb020; }
.cu-body { font-size: 12px; color: var(--muted); line-height: 1.6; }
.cu-body b { color: var(--text); }
.cu-body ul { margin: 8px 0 0; padding-left: 18px; }
.cu-body li { margin-bottom: 4px; }
