:root {
  color-scheme: light;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #eef2f7;
  --bg-hover: rgba(15, 23, 42, 0.05);
  --text-primary: #111827;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-primary: #d9e2ec;
  --border-secondary: #c4d0dd;
  --shadow-md: rgba(15, 23, 42, 0.18);
  --shadow-lg: rgba(15, 23, 42, 0.24);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --live: #0ea5e9;
  --live-tint: #e0f2fe;
  --store: #7c3aed;
  --store-tint: #ede9fe;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

body {
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ------------------------- Routing / profile panel ----------------------- */

.routing-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  /* Leave a strip at the very bottom so the MapLibre attribution control
     (bottom-right) isn't covered by the panel. */
  bottom: 40px;
  width: 400px;
  max-width: calc(100vw - 32px);
  background: var(--bg-primary);
  border-radius: 16px;
  border: 1px solid var(--border-primary);
  box-shadow: 0 14px 40px var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 5;
}

.routing-panel.is-collapsed {
  bottom: auto;
  height: auto;
}

.routing-panel.is-collapsed .routing-content,
.routing-panel.is-collapsed .panel-map-controls {
  display: none;
}

.routing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px 18px;
  border-bottom: 1px solid var(--border-primary);
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.panel-kicker {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

#panel-title {
  margin: 2px 0 0 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.panel-subtitle {
  margin: 4px 0 0 0;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.35;
  max-width: 32ch;
}

.routing-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.panel-toggle,
.unpin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  color: var(--text-secondary);
  padding: 0;
}

.panel-toggle svg,
.unpin-button svg { width: 18px; height: 18px; }
.panel-toggle:hover,
.unpin-button:hover { background: var(--bg-tertiary); }

.unpin-button {
  color: var(--accent-strong);
  border-color: #c7d2fe;
  background: #eef2ff;
}

.unpin-button:hover {
  background: #e0e7ff;
}

.pin-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Explicit class+[hidden] selector — needed because `display: inline-flex`
   above otherwise outranks the user-agent `[hidden] { display: none }`. */
.pin-indicator[hidden],
.unpin-button[hidden] {
  display: none;
}

.pin-indicator svg { width: 12px; height: 12px; }

.routing-note kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-secondary);
  background: var(--bg-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
}

.routing-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 18px 14px 18px;
  overflow-y: auto;
}

.routing-note {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-primary);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* ------------------------- Route chips (multi-pin) ----------------------- */

.route-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #f5f3ff 0%, #ffffff 100%);
  border: 1px solid #ddd6fe;
  border-radius: 12px;
}

.route-chips[hidden] { display: none; }

.route-chips-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.route-chips-header strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--store);
}

.route-chips-hint {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.route-chips-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.route-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
  background: #ffffff;
  border: 1px solid var(--border-primary);
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
  max-width: 100%;
}

.route-chip:hover {
  border-color: var(--store);
  transform: translateY(-1px);
}

.route-chip.is-focused {
  border-color: var(--store);
  box-shadow: 0 0 0 1px var(--store) inset;
  background: #faf5ff;
}

.route-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.route-chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.route-chip-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.route-chip-meta {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.route-chip-remove {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.route-chip-remove:hover {
  background: rgba(124, 58, 237, 0.12);
  color: var(--store);
}

/* ------------------------- Segment metadata ------------------------------ */

.segment-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.segment-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.segment-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  min-width: 0;
}

.osm-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.osm-link svg,
.osm-link img {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.osm-link:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(126, 188, 111, 0.25);
}

.osm-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segment-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.segment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.segment-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.76rem;
  font-weight: 500;
  border: 1px solid var(--border-primary);
}

.segment-chip-warn {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

/* ------------------------- Section blocks (live vs. store) --------------- */

.section-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-primary);
}

.section-block-live {
  background: linear-gradient(180deg, var(--live-tint) 0%, #ffffff 70%);
  border-color: #bae6fd;
}

.section-block-store {
  background: linear-gradient(180deg, var(--store-tint) 0%, #ffffff 70%);
  border-color: #ddd6fe;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 600;
}

.section-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
}

.section-badge-live {
  background: var(--live);
  color: #ffffff;
}

.section-badge-store {
  background: var(--store);
  color: #ffffff;
}

/* ------------------------- Profile block (heightgraph) ------------------- */

.profile-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  border: 1px solid var(--border-primary);
  font-size: 0.88rem;
}

.profile-canvas-shell {
  position: relative;
  background: linear-gradient(180deg, #f4fbff 0%, #dfeff7 100%);
  border-radius: 10px;
  border: 1px solid var(--border-primary);
  padding: 6px;
}

#heightgraph-canvas {
  width: 100%;
  height: 150px;
  display: block;
  border-radius: 6px;
}

/* Neutral 4-column grid shared by the Live (Referenz) and PMTiles (Kandidaten)
   summary blocks. Identical layout in both sections makes the values
   line-up directly comparable. .metric-grid is the container, .metric-cell
   is a single labeled value (prefix on top, big value below). */
.metric-grid,
.profile-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.metric-cell {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-cell strong {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.summary-metric-prefix {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Hint shown below the Live cells when the stitched DEM-path length differs
   noticeably from the PMTiles `length_m` attribute — typically because the
   way is split across tile boundaries and MapLibre's queryRenderedFeatures
   returns fragments that don't fully reconstruct the original geometry. */
.live-length-warning {
  margin: 6px 0 0 0;
  padding: 6px 10px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(245, 158, 11, 0.08);
  border-left: 2px solid rgba(245, 158, 11, 0.5);
  border-radius: 4px;
}
.live-length-warning[hidden] { display: none; }

/* ------------------------- Store blocks ---------------------------------- */

.store-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.store-block[hidden] { display: none; }

.store-multi-pin-hint {
  margin: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed #c4b5fd;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.store-multi-pin-hint[hidden] { display: none; }

.store-block-title {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

/* Inline annotation on a store-block-title, e.g. "aus 'Geglättet'" — same line
   as the title, dropped weight and case to read as a parenthetical. */
.store-block-suffix {
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-style: italic;
  color: var(--text-secondary);
}

.metric-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-list-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.metric-list-item:hover {
  background: #ffffff;
  border-color: #c4b5fd;
  transform: translateX(1px);
}

.metric-list-item:focus-visible {
  outline: 2px solid var(--store);
  outline-offset: 2px;
}

.metric-list-item.is-active {
  background: #ffffff;
  border-color: var(--store);
  box-shadow: 0 0 0 1px var(--store) inset;
}

.metric-list-item.is-active:hover {
  /* Don't shift the already-highlighted row on hover — keeps the
     "this is the picked one" anchor visually steady. */
  transform: none;
}

.metric-list-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.metric-list-label {
  color: var(--text-secondary);
}

.metric-list-value {
  font-variant-numeric: tabular-nums;
}

/* (.store-grid / .store-cell merged into .metric-grid / .metric-cell above —
   identical layout, now shared by both the Live and PMTiles sections.) */

/* ------------------------- Slope distribution ---------------------------- */

.slope-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 8px;
}

.slope-row-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.slope-bar {
  display: flex;
  height: 18px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
}

.slope-slice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2px;
  color: rgba(15, 23, 42, 0.65);
  font-size: 0.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.slope-slice-slope-flat { background: #e5e7eb; }
.slope-slice-slope-1 { background: #fee08b; }
.slope-slice-slope-2 { background: #fdae61; }
.slope-slice-slope-3 { background: #f46d43; color: rgba(255,255,255,0.95); }
.slope-slice-slope-4 { background: #d73027; color: #ffffff; }

.slope-slice-empty {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: italic;
}

.slope-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.slope-legend li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.slope-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.slope-swatch-flat { background: #e5e7eb; }
.slope-swatch-1 { background: #fee08b; }
.slope-swatch-2 { background: #fdae61; }
.slope-swatch-3 { background: #f46d43; }
.slope-swatch-4 { background: #d73027; }

/* ------------------------- Map controls (pinned) ------------------------- */

.panel-map-controls {
  border-top: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  padding: 12px 18px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-map-controls-title {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-picker {
  display: flex;
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  background: var(--bg-primary);
  overflow: hidden;
}

.metric-picker-btn {
  flex: 1 1 0;
  border: none;
  border-right: 1px solid var(--border-primary);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 8px 6px;
  min-height: 36px;
}

.metric-picker-btn:last-child { border-right: none; }

.metric-picker-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.metric-picker-btn.selected {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-range {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
}

.legend-bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 8px;
  border-radius: 999px;
  /* Stops match GRADIENT_COLOR_STOPS in initMap.js, mapped against the
     slider's 0-20% range. Stays in lock-step with the map ramp so the
     slider preview equals what the map paints. */
  background: linear-gradient(
    90deg,
    #93a39a 0%,
    #fee08b 10%,
    #fdae61 20%,
    #f46d43 30%,
    #d73027 50%,
    #7a0177 100%
  );
  pointer-events: none;
}

/* Greyed-out areas left/right of the active slider range. Positioned by JS
   via inline left/right widths; defaults to "no dimming". */
.legend-dim {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 8px;
  background: rgba(248, 250, 252, 0.78);
  pointer-events: none;
  border-radius: 999px;
}
.legend-dim-left { left: 0; width: 0; }
.legend-dim-right { right: 0; width: 0; }

/* Two stacked invisible range inputs share the same track and overlap; the
   custom thumbs are the only thing the user sees. pointer-events: none on
   the track keeps the click target on the thumb only, so both thumbs are
   draggable without one stealing the other's hit-test. */
.legend-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
  z-index: 2;
}

.legend-thumb::-webkit-slider-runnable-track,
.legend-thumb::-moz-range-track {
  background: transparent;
  border: none;
  height: 18px;
}

.legend-thumb::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  cursor: grab;
  margin-top: 0;
}

.legend-thumb::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  cursor: grab;
}

.legend-thumb:active::-webkit-slider-thumb,
.legend-thumb:active::-moz-range-thumb { cursor: grabbing; }

.legend-thumb:focus { outline: none; }
.legend-thumb:focus-visible::-webkit-slider-thumb,
.legend-thumb:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.legend-filter-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.legend-filter-reset {
  background: transparent;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.7rem;
  color: var(--accent-strong);
  min-height: 0;
  cursor: pointer;
}
.legend-filter-reset:hover { background: var(--bg-tertiary); }

/* ------------------------- Panel footer (GitHub/Issues) ------------------ */

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border-primary);
}

.panel-footer-badge {
  height: 18px;
  border-radius: 4px;
}

.panel-footer-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.panel-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  transition: background 120ms ease, color 120ms ease;
}

.panel-footer-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.panel-footer-link svg {
  width: 16px;
  height: 16px;
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------- Karte / map settings panel ------------------- */

.map-settings-toggle {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 6;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  box-shadow: 0 6px 16px var(--shadow-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  padding: 0;
}

.map-settings-toggle:hover { background: var(--bg-tertiary); }
.map-settings-toggle svg { width: 22px; height: 22px; }

.map-settings-panel {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 300px;
  max-width: calc(100vw - 32px);
  background: var(--bg-primary);
  border-radius: 16px;
  border: 1px solid var(--border-primary);
  box-shadow: 0 14px 40px var(--shadow-md);
  z-index: 5;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-settings-panel.is-collapsed {
  display: none;
}

.map-settings-panel-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.map-settings-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.basemap-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.basemap-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 7px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  text-align: left;
  min-height: 0;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.basemap-btn:hover { background: var(--bg-tertiary); }
.basemap-btn.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.basemap-preview {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  border: 1px solid var(--border-primary);
  margin-bottom: 6px;
  background-size: cover;
  background-position: center;
}

.basemap-preview-positron {
  background-color: #eef3f7;
  background-image: url('./assets/basemaps/positron-thumb.png');
}
.basemap-preview-osm {
  background-color: #f5f1df;
  background-image: url('./assets/basemaps/osm-thumb.png');
}
.basemap-preview-satellite {
  background-color: #516146;
  background-image: url('./assets/basemaps/satellite-thumb.png');
}

.basemap-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
}

.terrain-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-primary);
  background: var(--bg-secondary);
}

.terrain-row strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.85rem;
}

.terrain-row p {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.25;
  color: var(--text-secondary);
}

/* Toggle switch (copied from hilo_profiler — same visual language). */
.switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 160ms ease;
  cursor: pointer;
}

.switch-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 160ms ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.switch input:checked + .switch-slider {
  background: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* ------------------------- MapLibre controls ----------------------------- */

.maplibregl-ctrl-top-left {
  margin-left: 8px;
  margin-top: 8px;
}

.maplibregl-ctrl-attrib {
  font-size: 0.7rem;
}

@media (max-width: 720px) {
  .routing-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: 65vh;
    border-radius: 16px 16px 0 0;
  }
}
