:root {
  --accent: #1a7f37;
  --accent-dark: #14652c;
  --accent-bright: #22a049; /* brighter gradient start (design system) */
  --bg: #ffffff;
  --text: #1f2328;
  --muted: #656d76;
  --border: #d0d7de;
  --surface-2: #eef1f4;
  --seg-active: #ffffff; /* elevated pill inside a segmented control */
  --surface-green: #f2f7f2;
  --surface-green-border: #d3e5d3;
  --surface-blue: #f2f4fa;
  --surface-blue-border: #ccd6ee;
  --chart-bg: #fbfdfb;
  --hover: #f0f4f0;
  --map-bg: #dfe8dd;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  --toast-bg: #1f2328;
  --toast-fg: #ffffff;
  --toast-border: transparent;
  --sh-fab: 0 2px 10px rgba(0, 0, 0, 0.14);
  --sh-cta: 0 6px 16px rgba(26, 127, 55, 0.32);
  --sh-sheet: 0 -8px 30px rgba(0, 0, 0, 0.16);
  --radius: 14px;
  --r-sheet: 22px;
  --sheet-z: 1100;
}

/* Dark theme applies when the device prefers dark and no light override is
   set (data-theme on <html>), or when dark is forced explicitly. The two
   blocks below must stay identical — CSS cannot share a block between a
   media query and a selector. */
@media (prefers-color-scheme: dark) {
  /* Keep the detail-rich OSM tiles but render them dark: invert + soften.
     Dedicated dark tilesets drop the footpath detail runners need. */
  :root:not([data-theme="light"]) .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(1.05) contrast(0.85) saturate(0.35);
  }

  :root:not([data-theme="light"]) .leaflet-control-attribution {
    background: rgba(22, 27, 34, 0.8) !important;
    color: #8b949e !important;
  }

  :root:not([data-theme="light"]) .leaflet-control-zoom a {
    background: #161b22 !important;
    color: #e6edf3 !important;
    border-color: #30363d !important;
  }

  :root:not([data-theme="light"]) {
    --accent: #3fb950;
    --accent-dark: #2ea043;
    --bg: #161b22;
    --text: #e6edf3;
    --muted: #8b949e;
    --border: #30363d;
    --surface-2: #21262d;
    --seg-active: #30363d;
    --surface-green: #1f2b21;
    --surface-green-border: #2f4433;
    --surface-blue: #212736;
    --surface-blue-border: #35405c;
    --chart-bg: #20262e;
    --hover: #2a313a;
    --map-bg: #14181d;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    --toast-bg: #30363d;
    --toast-fg: #ffffff;
    --toast-border: #545d68;
  }
}

:root[data-theme="dark"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(1.05) contrast(0.85) saturate(0.35);
}

:root[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(22, 27, 34, 0.8) !important;
  color: #8b949e !important;
}

:root[data-theme="dark"] .leaflet-control-zoom a {
  background: #161b22 !important;
  color: #e6edf3 !important;
  border-color: #30363d !important;
}

:root[data-theme="dark"] {
  --accent: #3fb950;
  --accent-dark: #2ea043;
  --bg: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;
  --border: #30363d;
  --surface-2: #21262d;
  --seg-active: #30363d;
  --surface-green: #1f2b21;
  --surface-green-border: #2f4433;
  --surface-blue: #212736;
  --surface-blue-border: #35405c;
  --chart-bg: #20262e;
  --hover: #2a313a;
  --map-bg: #14181d;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --toast-bg: #30363d;
  --toast-fg: #ffffff;
  --toast-border: #545d68;
}

* {
  box-sizing: border-box;
  /* No grey flash when tapping controls on iOS (the full-width sheet handle
     otherwise flashes a grey bar across the map). */
  -webkit-tap-highlight-color: transparent;
  /* No double-tap-to-zoom on the UI. The map (Leaflet), the sheet handle and
     the elevation-scrub SVG set their own touch-action via more specific
     selectors, so their gestures are unaffected. */
  touch-action: manipulation;
}

/* display:flex/grid rules would otherwise override the hidden attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  overscroll-behavior: none;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--map-bg);
}

/* Floating action buttons */
.fabs {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* keep single FABs at the right edge when the undo/redo row widens the column */
  gap: 10px;
  z-index: var(--sheet-z);
}

/* Undo + redo share one row so the column doesn't outgrow the screen */
.fab-pair { display: flex; gap: 10px; }

.fab {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: var(--bg);
  box-shadow: var(--sh-fab);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.fab svg {
  width: 22px;
  height: 22px;
  fill: var(--text);
}

.fab:active { transform: scale(0.94); }

/* Draw mode toggled on */
.fab.active { background: var(--accent); }
.fab.active svg { fill: #fff; }

/* Bottom sheet */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--sheet-z);
  background: var(--bg);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--sh-sheet);
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
}

.sheet {
  transition: transform 0.2s ease;
}

.sheet-handle {
  border: none;
  background: none;
  padding: 10px 0 6px;
  cursor: grab;
  width: 100%;
  touch-action: none; /* the handle drags the sheet, never scrolls the page */
}

.sheet-handle span {
  display: block;
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  margin: 0 auto;
}

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #b5c2b5 transparent;
}

/* iOS hides its overlay scrollbar until you scroll — style one that is
   always visible so it's clear the controls can scroll */
.sheet-body::-webkit-scrollbar { width: 5px; }

.sheet-body::-webkit-scrollbar-thumb {
  background: #b5c2b5;
  border-radius: 3px;
}

/* While more content sits below the fold, fade the bottom edge as a cue */
.sheet-body.more-below {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent);
}

.sheet.collapsed .sheet-body { display: none; }

.sheet-footer { padding-top: 10px; }

.field { margin-bottom: 14px; }

.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type="text"],
input[type="number"],
input[type="password"] {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  background: var(--bg);
  color: var(--text);
}

input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 6px 0 0;
}

.hint a { color: var(--accent); }

/* Start location row */
.loc-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.loc-search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 10;
  max-height: 220px;
  overflow-y: auto;
}

.suggest li {
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.suggest li:hover, .suggest li:focus { background: var(--hover); }

/* Weather line under the start location */
.weather {
  margin: 2px 2px 12px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.weather-advice {
  font: inherit;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: var(--accent);
  padding: 4px 10px;
  cursor: pointer;
}

/* Distance */
.distance-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.distance-row input { width: 88px; flex: none; }

.pace-input { width: 88px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  height: 34px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.chip:active, .chip.selected { background: var(--accent); color: #fff; }

/* Direction grid */
/* Direction: one horizontally-scrollable row of pills, each with an arrow
   pointing to that compass bearing. */
.dir-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.dir-row::-webkit-scrollbar { display: none; }

.dir {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  border: none;
  background: var(--surface-2);
  cursor: pointer;
  color: var(--text);
}

.dir.selected { background: var(--accent); color: #fff; }

.dir-tick { width: 13px; height: 13px; flex: none; }

/* ---- Redesigned home sheet (design-system home screen) ---- */

/* Start / finish field with the yellow start dot */
.start-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }

.start-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 13px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.start-field:focus-within { border-color: var(--accent); }

.start-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: #ffd749;
  box-shadow: 0 0 0 3px rgba(255, 215, 73, 0.28);
}

.start-field input {
  border: none;
  background: none;
  padding: 0;
  height: 100%;
  font-size: 16px; /* >= 16px so iOS Safari doesn't auto-zoom on focus */
  color: var(--text);
}

.start-field input:focus { outline: none; }

/* Square icon button (locate, clear) sitting beside a field */
.icon-btn {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--accent);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 16px;
}

.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(0.95); }

/* Section caption with a trailing info toggle (keeps the chips on one row) */
.cap-row { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.cap-row .field-cap { margin: 0; }

.info-btn {
  width: 26px;
  height: 26px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.info-btn svg { width: 15px; height: 15px; }
.info-btn[aria-expanded="true"] { background: var(--accent); color: #fff; }
.info-btn:active { transform: scale(0.94); }

/* Distance stepper + pace field, side by side */
.field-pair { display: flex; gap: 8px; margin-bottom: 12px; }

.stepper {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px; /* keep the value clear of the +/- buttons */
  height: 46px;
  padding: 0 6px 0 13px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg);
}

/* Pace: same box as the stepper, label + value, no +/- buttons. Sized to its
   content so the distance stepper (which grows) gets the extra room. */
.mini-field {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 46px;
  padding: 0 13px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.mini-field .field-cap { margin: 0; font-size: 10px; }
.mini-field:focus-within { border-color: var(--accent); }

/* Compact km/mi toggle sitting beside the distance + pace fields. Stacked
   vertically so it stays narrow and the distance stepper keeps its room. */
.units-inline {
  flex: none;
  align-self: stretch; /* match the 46px field height */
  flex-direction: column;
  gap: 2px;
  padding: 3px;
}
.units-inline .seg {
  flex: 1;
  padding: 0 11px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper .field-cap { margin: 0; font-size: 10px; }

.stepper-value { display: flex; align-items: baseline; gap: 3px; }

.stepper-value input {
  border: none;
  background: none;
  padding: 0;
  width: 44px;
  font-size: 16px; /* >= 16px so iOS Safari doesn't auto-zoom on focus */
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.stepper-value input:focus { outline: none; }
.stepper-value .unit { font-size: 12px; font-weight: 700; color: var(--muted); }

.stepper-btns { display: flex; gap: 4px; }

.step-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.step-btn.plus { background: var(--accent); color: #fff; }
.step-btn:active { transform: scale(0.94); }

/* Result card: metrics + elevation + action row */
.result-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 13px;
  margin-bottom: 12px;
  background: var(--surface-2);
}

.result-metrics { display: flex; align-items: flex-end; gap: 18px; }

.metric-cap {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric strong {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
}
.metric:first-child strong { font-size: 27px; letter-spacing: -0.02em; }

.result-actions { display: flex; gap: 7px; margin-top: 11px; }

.result-act {
  flex: 1;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.result-act.act-primary { background: var(--accent); color: #fff; font-weight: 700; }
.result-act:active { transform: scale(0.97); }

/* Variant button beside Generate */
.btn-variant {
  width: 104px;
  flex: none;
  height: 52px;
  border-radius: 15px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn-variant:disabled { opacity: 0.55; }

/* Lightning icon inside the primary Generate button */
.gen-icon { width: 19px; height: 19px; flex: none; }
#btn-generate { display: flex; align-items: center; justify-content: center; gap: 8px; }

/* Segmented control — sunken track with an elevated active pill */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 4px;
  gap: 2px;
}

.seg {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border: none;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.seg.selected {
  background: var(--seg-active);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

/* Buttons */
.btn-row { display: flex; gap: 8px; }

.primary, .secondary {
  font: inherit;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 15px;
  border: none;
  cursor: pointer;
}

.primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--sh-cta);
}

.primary:active { background: var(--accent-dark); }

.primary:disabled, .secondary:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

.secondary {
  background: var(--surface-2);
  color: var(--text);
}

.result-card.imported { background: var(--surface-blue); border-color: var(--surface-blue-border); }

/* Elevation profile chart (bare inside the result card) */
.elevation { margin: 11px 0 0; }

.elevation svg {
  display: block;
  width: 100%;
  touch-action: none; /* keep the crosshair drag from scrolling the sheet */
}

.elevation .ep-label {
  font-size: 11px;
  fill: var(--muted);
}

.elevation .ep-tip {
  font-size: 11px;
  font-weight: 600;
  fill: var(--text);
}

/* Saved-routes list in the modal */
.routes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.routes-list li {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.route-thumb {
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-green);
  border: 1px solid var(--surface-green-border);
}
.route-thumb svg { display: block; width: 100%; height: 100%; }

.route-load {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}

.route-info { flex: 1; min-width: 0; }
.route-info strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.route-meta { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.route-chip {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.route-del {
  flex: none;
  width: 44px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.result-stats strong {
  font-size: 17px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-stats span { font-size: 13px; color: var(--muted); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal {
  background: var(--bg);
  border-radius: var(--r-sheet);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.modal h2 { margin: 0 0 10px; font-size: 19px; }

.modal label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 12px 0 6px;
}

.modal .btn-row { margin-top: 16px; }

.modal .primary { flex: none; }

.modal-footnote {
  margin: 14px 0 0;
  text-align: center;
}

/* Sheet-style modals (settings, saved routes) */
.sheet-modal {
  padding: 0;
  max-width: 400px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.modal-grab {
  display: flex;
  justify-content: center;
  padding: 9px 0 2px;
}
.modal-grab span {
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px 14px;
}
.modal-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }

.modal-x {
  width: 32px;
  height: 32px;
  flex: none;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-scroll {
  padding: 0 20px 20px;
  max-height: min(80dvh, 680px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Keep each block at its natural height; when the content is taller than the
   modal, the scroll area scrolls instead of squeezing a child (which would
   clip the last link row inside the overflow:hidden list). */
.modal-scroll > * { flex-shrink: 0; }

.field-cap {
  display: block; /* so margin-bottom applies even when used on a <span> */
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}

.segmented.full { display: flex; }
.segmented.full .seg { flex: 1; text-align: center; }

.link-list {
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
}
.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 15px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.link-row + .link-row { border-top: 1px solid var(--border); }
.link-row span { color: var(--muted); font-size: 18px; }
.link-row:active { background: var(--hover); }

.coffee-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  border-radius: 13px;
  background: #ffd749;
  color: #3d2f00;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}
.coffee-btn:active { filter: brightness(0.95); }

.modal-note { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }

/* Finish marker (point-to-point routes) */
.finish-flag {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  cursor: grab;
}

/* Visually hidden but readable by crawlers and screen readers */
.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;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
  background: var(--toast-bg);
  color: var(--toast-fg);
  border: 1px solid var(--toast-border);
  padding: 12px 16px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  max-width: min(92vw, 420px);
  text-align: center;
  z-index: 1400;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  pointer-events: none; /* purely informational — never block taps beneath it */
}

/* Km markers along the route */
.km-marker { pointer-events: none; }

.km-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Debug waypoint markers */
.wp-marker { pointer-events: none; }

.wp-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #7b2fbf;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Settings checkbox row */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.check input { width: auto; }

/* Direction arrows along the route */
.dir-arrow-wrap { pointer-events: none; }

.dir-arrow {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}

.dir-arrow svg {
  width: 14px;
  height: 14px;
  stroke: var(--accent);
}

/* Draggable handle dropped by tapping the route */
/* The 44x44 icon is one big finger target; the visible dot is drawn centered
   inside it so it's easy to grab even when it sits right on the route line. */
.edit-handle {
  display: grid;
  place-items: center;
  cursor: grab;
}
.edit-handle::before {
  content: "";
  width: 24px;
  height: 24px;
  background: #fff;
  border: 5px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}
.edit-handle:active { cursor: grabbing; }

/* Pulse animation shown when the start marker is (re)placed */
.pulse-marker { pointer-events: none; }

.pulse-ring {
  position: absolute;
  left: -26px;
  top: -26px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  opacity: 0;
  animation: pulse-ring 0.9s ease-out 2;
}

@keyframes pulse-ring {
  0% { transform: scale(0.2); opacity: 0.9; }
  100% { transform: scale(1); opacity: 0; }
}

/* Route line colors are set from JS; imported uses distinct color */

/* Desktop: sheet becomes a left panel */
@media (min-width: 768px) {
  .sheet {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 420px;
    max-height: none;
    border-radius: 0;
    padding: 16px 20px 20px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .sheet-handle { display: none; }

  .sheet.collapsed .sheet-body { display: block; }

  .sheet-body { flex: 1; }
}
