:root {
  /* Backgrounds */
  --bg-panel:  #0d1f3c;
  --bg-hover:  #142d4e;
  --bg-active: #1a4a78;

  /* Structural blues (used in borders and fills) */
  --ui-blue:      #1e4976;
  --border-mid:   #1a3a5c;
  --border-dark:  #112038;
  --border-bright:#2e6aa0;

  /* Text */
  --accent:        #7ec8e3;
  --text-bright:   #d0e8f5;
  --text-mid:      #c8e4f5;
  --text-muted:    #8ab8d4;
  --text-dim:      #6a9ab8;
  --text-label:    #9ad4f0;
  --text-section:  #4a8fb5;
  --text-verified: #5aaa7a;

  --transition-bg: background 0.15s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', sans-serif;
  background: #0a1628;
  color: var(--text-bright);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  background: var(--bg-panel);
  border-bottom: 2px solid var(--ui-blue);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

header .icon { font-size: 1.6rem; }

header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
}

header p {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 1px;
}

.container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#sidebar {
  width: 240px;
  background: var(--bg-panel);
  border-right: 1px solid var(--ui-blue);
  overflow-y: auto;
  flex-shrink: 0;
}

#sidebar h2 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-section);
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border-mid);
}

/* Group row — the collapsed "first view" entry */
.group-item { border-bottom: 1px solid var(--border-dark); }

.group-row {
  padding: 9px 14px;
  cursor: pointer;
  transition: var(--transition-bg);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.group-row:hover { background: var(--bg-hover); }
.group-row.selected { background: var(--bg-active); border-left: 3px solid #4aa0d4; }

/* Shared dot base */
.dive-dot,
.source-dot-sm,
.legend-dot {
  border-radius: 50%;
  flex-shrink: 0;
}

.dive-dot { width: 10px; height: 10px; margin-top: 3px; }
.legend-dot,
.source-dot-sm { width: 7px; height: 7px; }

.site-name {
  font-size: 0.82rem;
  color: var(--text-mid);
  line-height: 1.3;
  flex: 1;
}

.site-alias {
  font-size: 0.7rem;
  color: var(--text-section);
  font-style: italic;
  margin-top: 1px;
}

/* Badge showing variant count */
.variant-badge {
  background: var(--ui-blue);
  border: 1px solid var(--border-bright);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
  align-self: center;
}

/* Expanded variant sub-list */
.variant-list { background: #081626; display: none; }

.variant-item,
.legend-item,
.legend-hint,
.popup-variant-row {
  display: flex;
  align-items: center;
}

.variant-item {
  padding: 6px 14px 6px 30px;
  cursor: pointer;
  gap: 7px;
  font-size: 0.74rem;
  color: var(--text-muted);
  border-top: 1px solid #0f2438;
  transition: var(--transition-bg);
}

.variant-item:hover { background: #0f2540; color: var(--text-mid); }
.variant-item.selected { background: #122a4a; color: var(--text-bright); }

#legend {
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--border-mid);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.legend-item {
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
  transition: var(--transition-bg), opacity 0.15s;
  user-select: none;
}
.legend-item:hover { background: var(--bg-hover); }
.legend-item.inactive { opacity: 0.28; }
.legend-hint {
  font-size: 0.66rem;
  color: #3a6a8a;
  margin-top: 3px;
  padding-top: 5px;
  border-top: 1px solid var(--border-dark);
  gap: 5px;
}

#map { flex: 1; }

/* Leaflet popup */
.leaflet-popup-content-wrapper {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  color: var(--text-bright);
}
.leaflet-popup-tip { background: var(--bg-panel); }
.leaflet-popup-content { margin: 10px 14px; }

.popup-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}
.popup-coord {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: monospace;
}
.popup-label,
.variant-label {
  font-style: italic;
  color: var(--text-label);
}
.popup-label  { font-size: 0.78rem; margin-bottom: 4px; }
.variant-label { margin-right: 1px; }

.popup-author {
  font-size: 0.72rem;
  margin-top: 4px;
}
.popup-variant-row {
  gap: 6px;
  padding: 2px 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.approx-badge,
.verified-badge {
  font-size: 0.65rem;
  line-height: 1;
  border-radius: 3px;
  padding: 1px 3px 2px 3px;
  flex-shrink: 0;
  cursor: help;
}
.approx-badge {
  color: #c8922a;
  background: #1c1005;
  border: 1px solid #6a4a10;
}
.verified-badge {
  color: var(--text-verified);
  background: #051a0e;
  border: 1px solid #2a6a45;
}

.leaflet-control-layers {
  background: var(--bg-panel) !important;
  border: 1px solid var(--ui-blue) !important;
  color: var(--text-bright) !important;
}
.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label { color: #a8d4ec; }
.leaflet-control-zoom a {
  background: var(--bg-panel) !important;
  color: var(--accent) !important;
  border-color: var(--ui-blue) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-active) !important; }
.leaflet-control-locate a { background: var(--bg-panel) !important; color: var(--accent) !important; border-color: var(--ui-blue) !important; }
.leaflet-control-locate a:hover { background: var(--bg-active) !important; }
@keyframes gps-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(74, 168, 232, 0.8); }
  50%       { box-shadow: 0 0 0 5px rgba(74, 168, 232, 0.0); }
}
.leaflet-control-locate a.active {
  background: #1260a8 !important;
  color: #9adcf8 !important;
  border-color: #4aa8e8 !important;
  animation: gps-pulse 2s ease-in-out infinite;
}

/* ── Bearing / distance indicator ───────────────────────────────────── */
#nav-indicator {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(13, 31, 60, 0.92);
  border: 1px solid var(--border-bright);
  border-radius: 28px;
  padding: 9px 12px 9px 16px;
  font-size: 1rem;
  color: var(--text-bright);
  backdrop-filter: blur(4px);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}

.nav-arrow { flex-shrink: 0; transition: transform 0.4s; }

.nav-cancel {
  pointer-events: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 2px 0 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.nav-cancel:hover { color: var(--text-bright); }

/* ── Mobile toggle button (hidden on desktop) ────────────────────────── */
#menu-toggle {
  display: none;
  margin-left: auto;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  background: var(--bg-active);
  border: 1px solid var(--border-bright);
  color: var(--accent);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
}
#menu-toggle:hover { background: #1a5a90; }

/* ── Drawer drag handle (hidden on desktop) ──────────────────────────── */
.drawer-handle {
  display: none;
  width: 38px;
  height: 4px;
  background: var(--border-bright);
  border-radius: 2px;
  margin: 10px auto 4px;
  flex-shrink: 0;
}

/* ── Overlay behind the drawer ───────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1099;
}
#sidebar-overlay.visible { display: block; }

/* ── Mobile: bottom-sheet drawer ─────────────────────────────────────── */
@media (max-width: 600px) {
  #menu-toggle  { display: flex; }
  .drawer-handle { display: block; }

  #sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 68vh;
    border-right: none;
    border-top: 2px solid var(--border-bright);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.55);
    transform: translateY(100%);
    transition: transform 0.28s ease;
    z-index: 1100;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #sidebar.open { transform: translateY(0); }
}
