:root {
  color-scheme: dark;
  --bg: #050506;
  --panel: rgba(16, 18, 21, 0.94);
  --panel-soft: rgba(24, 26, 31, 0.92);
  --ink: #f4f4f2;
  --muted: #adb3bc;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --font-ui: "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #050506;
  color: var(--ink);
  font-family: var(--font-ui);
}

body {
  min-height: 100vh;
}

.map-stage {
  position: relative;
  min-height: 100vh;
  background: #050506;
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.03), transparent 42%),
    linear-gradient(180deg, #0a0b0c 0%, #040404 100%);
}

.topbar {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  gap: 10px;
}

.topbar-button,
.status-pill {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
}

.topbar-button {
  padding: 0 14px;
  background: rgba(16, 18, 21, 0.88);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.topbar-button--strong {
  margin-left: auto;
  background: rgba(245, 245, 240, 0.12);
}

.topbar-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.map-overlay {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 15;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.overlay-card,
.panel-card {
  background: var(--panel);
  backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.overlay-card {
  min-width: 180px;
  padding: 12px 14px;
  border-radius: 18px;
}

.overlay-label,
.eyebrow,
.caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay-value {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.35;
}

.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(74vh, 760px);
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  background: linear-gradient(180deg, rgba(9, 10, 12, 0.2), rgba(9, 10, 12, 0.84));
  overflow: auto;
  transform: translateY(calc(100% - 96px));
  transition: transform 220ms ease;
}

.panel.is-open {
  transform: translateY(0);
}

.panel-handle {
  width: 48px;
  height: 5px;
  margin: 0 auto 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.panel-card {
  padding: 18px;
  border-radius: var(--radius-lg);
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
}

h1 {
  margin-top: 8px;
  font-size: clamp(1.8rem, 7vw, 2.5rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
}

h2 {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.lede,
.section-heading p,
.notes-list,
.caption {
  color: var(--muted);
}

.lede {
  margin: 14px 0 0;
  line-height: 1.5;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 16px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 0.88rem;
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.section-heading p {
  margin: 0;
  line-height: 1.45;
}

.range-row,
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-row {
  margin-bottom: 10px;
}

.range-row--compact {
  margin: 2px 0 6px;
}

output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin: 0 0 18px;
  accent-color: #ffffff;
}

input[type="range"]:disabled {
  opacity: 0.38;
}

.control-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opacity-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.option-block {
  padding: 10px 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.option-block:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.opacity-row {
  margin-top: 8px;
}

.opacity-slider {
  width: 100%;
  margin: 0;
}

.opacity-stack:not(.opacity-stack--open) .opacity-row,
.opacity-stack:not(.opacity-stack--open) .opacity-slider {
  display: none;
}

.opacity-toggle {
  align-self: center;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.opacity-toggle span:last-child {
  display: inline-block;
  transition: transform 160ms ease;
}

.opacity-toggle--open span:last-child {
  transform: rotate(180deg);
}

.switch-row {
  min-height: 42px;
  padding: 0 2px;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: #ffffff;
}

.switch-row input:disabled {
  opacity: 0.4;
}

.switch-row--loading .option-loader {
  display: inline-flex;
}

.switch-row--loading .switch-checkbox {
  display: none;
}

.switch-row--ready .option-loader {
  display: none;
}

.switch-row--ready .switch-checkbox {
  display: inline-block;
}

.option-loader {
  --progress: 0;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  position: relative;
  background:
    conic-gradient(#ffffff calc(var(--progress) * 1turn), rgba(255, 255, 255, 0.15) 0);
  mask:
    radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  -webkit-mask:
    radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  transition: background 120ms linear;
}

.option-loader::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #050506;
}

.notes-list {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.55;
}

.panel-card--notes .caption {
  margin-top: 14px;
}

.maplibregl-popup-content {
  border-radius: 18px;
  background: rgba(17, 17, 18, 0.96);
  color: var(--ink);
  padding: 14px 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

.popup-title {
  margin: 0;
  font-weight: 650;
}

.popup-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (min-width: 960px) {
  .topbar {
    left: 20px;
    right: auto;
    width: 360px;
  }

  .map-overlay {
    left: 20px;
    right: auto;
    bottom: 20px;
    width: 280px;
  }

  .panel {
    top: 20px;
    bottom: 20px;
    left: 20px;
    right: auto;
    width: 360px;
    max-height: none;
    padding: 64px 0 0;
    background: transparent;
    border-radius: 0;
    transform: none;
    transition: transform 220ms ease;
  }

  .panel.is-collapsed {
    transform: translateX(calc(-100% - 24px));
  }

  .panel-handle {
    display: none;
  }

  .panel-card {
    margin: 0 0 12px;
  }

  .topbar-button:first-child {
    display: inline-flex;
    align-items: center;
  }
}
