/* ─── Design tokens ─────────────────────────────────────────── */
:root {
  --bg-app: #0c0e14;
  --bg-surface: #13161f;
  --bg-elevated: #1a1e2a;
  --bg-input: #222736;
  --bg-hover: #2a3042;

  --text-primary: #f1f3f8;
  --text-secondary: #b4bccf;
  --text-muted: #7a849c;
  --text-accent: #fb923c;

  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-focus: #fb923c;

  --accent: #f97316;
  --accent-hover: #fb923c;
  --accent-glow: rgba(249, 115, 22, 0.35);
  --accent-subtle: rgba(249, 115, 22, 0.12);

  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.15);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.15);
  --amber: #fbbf24;
  --blue: #60a5fa;

  /* Map overlay palette */
  --map-start: #2DD4BF;
  --map-end: #FB7185;
  --map-waypoint: #FBBF24;
  --map-route-best: #FB923C;
  --map-route-alt-1: #38BDF8;
  --map-route-alt-2: #C084FC;
  --map-route-alt-3: #F472B6;
  --map-route-alt-4: #34D399;
  --map-casing: #080a10;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-panel: 0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 32px var(--accent-glow);

  --font: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --sidebar-w: 400px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Layout ────────────────────────────────────────────────── */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.map-panel {
  flex: 1;
  position: relative;
  min-width: 0;
}

.map-panel--editing::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--accent);
  z-index: 500;
}

#map { width: 100%; height: 100%; }

/* ─── Map overlay chips ───────────────────────────────────────── */
.map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 700;
}

.map-overlay-chips {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

.map-chip {
  position: relative;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(12, 14, 20, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  transition: all var(--transition);
}

.map-chip:hover {
  border-color: var(--accent);
  background: rgba(19, 22, 31, 0.96);
}

.map-chip:active { transform: scale(0.97); }

.map-chip--active {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.14);
  color: var(--accent-hover);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.25), 0 4px 20px rgba(0, 0, 0, 0.45);
}

.map-chip--active .map-chip-icon {
  color: var(--accent);
}

.map-chip--favorite .map-chip-icon--heart {
  color: #fb7185;
}

.map-chip--favorite:hover {
  border-color: rgba(251, 113, 133, 0.65);
}

.map-chip--favorite.map-chip--guardado {
  border-color: #fb7185;
  background: rgba(251, 113, 133, 0.14);
  color: #fda4af;
}

.map-chip--favorite.map-chip--guardado .map-chip-icon--heart {
  fill: #fb7185;
  stroke: #fb7185;
}

.map-chip--favorite.map-chip--pop {
  animation: favorite-pop 0.45s ease;
}

@keyframes favorite-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (max-width: 768px) {
  .map-overlay-chips .map-chip {
    padding: 12px 16px;
    font-size: 14px;
  }
}

.map-chip-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-hover);
  flex-shrink: 0;
}

.map-chip-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
}

/* ─── Map editing prompt slot (hint + arrival) ─────────────────── */
.map-editing-slot {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 750;
  max-width: calc(100% - 32px);
  pointer-events: none;
}

.map-editing-slot > * {
  pointer-events: auto;
}

.map-arrival-bar {
  position: relative;
}

.map-arrival-dropdown {
  position: relative;
}

.map-arrival-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 14px;
  background: rgba(12, 14, 20, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.map-arrival-trigger:hover {
  border-color: var(--accent);
  background: rgba(19, 22, 31, 0.96);
}

.map-arrival-bar--active .map-arrival-trigger,
.map-arrival-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-hover);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.25), 0 4px 20px rgba(0, 0, 0, 0.45);
}

.map-arrival-bar--active .map-arrival-icon,
.map-arrival-trigger[aria-expanded="true"] .map-arrival-icon {
  color: var(--accent);
}

.map-arrival-icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.map-arrival-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.map-arrival-trigger[aria-expanded="true"] .map-arrival-chevron {
  transform: rotate(180deg);
  color: var(--accent-hover);
}

.map-arrival-bar--direct .map-arrival-chevron {
  display: none;
}

.map-arrival-bar--direct .map-arrival-trigger {
  padding-right: 14px;
}

.map-arrival-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  padding: 6px;
  background: rgba(12, 14, 20, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
}

.map-arrival-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.map-arrival-option svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.map-arrival-option:hover {
  background: var(--bg-hover);
  color: var(--accent-hover);
}

.map-arrival-option:hover svg {
  color: var(--accent);
}

.map-edit-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(12, 14, 20, 0.92);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-glow);
  pointer-events: none;
}

.map-edit-hint-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: var(--shadow-panel);
}

.sidebar-header {
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(249,115,22,0.08) 0%, transparent 55%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--accent-subtle);
  border: 1px solid rgba(249, 115, 22, 0.25);
  border-radius: var(--radius-md);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}

.brand-tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.sidebar-footer {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-credit {
  margin: 2px 0 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.3;
}

.sidebar-credit-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition);
}

.sidebar-credit-link:hover {
  color: var(--accent-hover);
}

.sidebar--has-routes .sidebar-footer {
  gap: 0;
}

.sidebar--has-routes #btn-clear.btn-primary {
  padding: 16px 20px;
  font-size: 16px;
}

.btn-peek-generate.hidden {
  display: none !important;
}

/* Drawer peek — mobile only (hidden desktop via media) */
.drawer-peek {
  display: none;
}

.drawer-backdrop {
  display: none;
}

.routes-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3400;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.routes-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Routes drawer (left panel) ──────────────────────────────── */
.routes-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(360px, 92vw);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
  z-index: 3500;
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}

.routes-drawer.is-open {
  transform: translateX(0);
}

.routes-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) 18px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(249,115,22,0.08) 0%, transparent 55%);
}

.routes-drawer-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.routes-drawer-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.routes-drawer-close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font);
}

.routes-drawer-close:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.routes-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

/* ─── Panels & steps ─────────────────────────────────────────── */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.step-badge {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-subtle);
  border-radius: 8px;
  flex-shrink: 0;
}

.step-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* ─── Status ────────────────────────────────────────────────── */
.status-card {
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.45;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.status-card--active {
  color: var(--text-primary);
  border-color: rgba(249, 115, 22, 0.4);
  background: var(--accent-subtle);
}

.status-card--error {
  border-color: rgba(248, 113, 113, 0.4);
  background: var(--red-dim);
  color: var(--red);
}

/* ─── Edit toggle ─────────────────────────────────────────────── */
.btn-edit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  margin-bottom: 12px;
  background: var(--bg-input);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-edit:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--accent-subtle);
}

.btn-edit.active {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent-hover);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.2);
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ─── Mode toolbar ──────────────────────────────────────────── */
.mode-toolbar {
  margin-bottom: 12px;
  animation: slideDown 200ms ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

#mode-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  color: var(--text-muted);
}

.mode-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.mode-btn.active {
  border-color: var(--mode-color, var(--accent));
  background: color-mix(in srgb, var(--mode-color, var(--accent)) 12%, transparent);
  color: var(--text-primary);
}

.mode-btn-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  background: color-mix(in srgb, var(--mode-color, var(--accent)) 20%, transparent);
  color: var(--mode-color, var(--accent));
}

.mode-btn-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ─── Points summary ────────────────────────────────────────── */
.points-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.point-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  opacity: 0.65;
  transition: opacity var(--transition);
}

.point-chip.is-set { opacity: 1; }

.point-chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.point-chip--start .point-chip-dot { background: var(--green); box-shadow: 0 0 8px rgba(52,211,153,0.5); }
.point-chip--end .point-chip-dot { background: var(--red); box-shadow: 0 0 8px rgba(248,113,113,0.4); }
.point-chip--waypoints .point-chip-dot { background: var(--amber); }

.point-chip-body { min-width: 0; flex: 1; }

.point-chip-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.point-chip-value {
  display: block;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.point-chip.is-set .point-chip-value { color: var(--text-primary); }

/* ─── Distance hero ─────────────────────────────────────────── */
.distance-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.distance-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.distance-step-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.distance-step-btn:hover:not(:disabled) {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.distance-step-btn:active:not(:disabled) { transform: scale(0.94); }

.distance-step-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.distance-stepper-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  min-width: 130px;
}

.distance-display {
  font-family: var(--font-mono);
  font-size: 52px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -2px;
  line-height: 1;
}

.distance-hero-unit {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-muted);
}

.distance-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
}

.distance-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--bg-elevated);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform var(--transition);
}

.distance-slider::-webkit-slider-thumb:hover { transform: scale(1.12); }

/* ─── Accordion ───────────────────────────────────────────────── */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: hidden;
}

.accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color var(--transition);
}

.accordion-trigger::-webkit-details-marker { display: none; }

.accordion-trigger:hover { color: var(--text-primary); }

.accordion[open] .accordion-trigger {
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.accordion-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.accordion[open] .accordion-chevron { transform: rotate(180deg); }

.accordion-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.accordion-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-input {
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  transition: border-color var(--transition);
}

.field-input--sm { width: 52px; }

.field-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.field-sep {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.field-suffix {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── Map style grid ──────────────────────────────────────────── */
.map-style-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-style-btn {
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
}

.map-style-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.map-style-btn.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent-hover);
}

/* ─── Toggles ─────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  cursor: pointer;
}

.toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.35;
}

.toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border-radius: 24px;
  border: 1px solid var(--border-strong);
  transition: all var(--transition);
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}

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

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--accent);
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
  letter-spacing: -0.2px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-primary.loading { pointer-events: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
  border-color: #f87171;
  color: #fecaca;
}

.btn-ghost:hover {
  color: var(--text-secondary);
  background: var(--bg-input);
}

/* ─── Progress ────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #fbbf24);
  border-radius: 2px;
  transition: width 200ms ease;
  width: 0%;
}

/* ─── Results ─────────────────────────────────────────────────── */
.panel-results { padding-bottom: 12px; }

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.results-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.results-count {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 3px 9px;
  background: var(--bg-input);
  border-radius: 999px;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.route-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  padding: 28px 16px;
  text-align: center;
}

.empty-state.hidden { display: none; }

.empty-state-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.6; }

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Route cards ─────────────────────────────────────────────── */
.route-card {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.route-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--route-color, var(--accent));
}

.route-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.route-card.selected {
  border-color: var(--route-color, var(--accent));
  background: color-mix(in srgb, var(--route-color, var(--accent)) 8%, var(--bg-input));
}

.route-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.route-badge {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
}

.route-match {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--green);
}

.route-metrics {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
}

.route-metric { text-align: center; }

.route-metric--primary .route-metric-value {
  font-size: 26px;
  color: var(--text-primary);
}

.route-metric-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.2;
}

.route-metric-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.route-time-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
  text-align: center;
}

.route-diff {
  margin-top: 10px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.diff-good { background: var(--green-dim); color: var(--green); }
.diff-ok { background: rgba(251, 191, 36, 0.12); color: var(--amber); }
.diff-far { background: var(--red-dim); color: var(--red); }

/* ─── Leaflet overrides ───────────────────────────────────────── */
.leaflet-container { background: #1a1e2a; }

.leaflet-control-zoom a {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover { background: var(--bg-hover) !important; }

.leaflet-control-attribution {
  background: rgba(12, 14, 20, 0.88) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  backdrop-filter: blur(8px);
}

.leaflet-control-attribution a { color: var(--text-secondary) !important; }

.leaflet-popup-content-wrapper {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border) !important;
}

.leaflet-popup-tip { background: var(--bg-elevated) !important; }

.leaflet-popup-content {
  margin: 10px 14px !important;
  font-size: 13px !important;
}

.leaflet-popup-content a { color: var(--red) !important; text-decoration: none; }

/* ─── Markers ─────────────────────────────────────────────────── */
.custom-marker { background: none !important; border: none !important; }

.marker-pin {
  --pin-color: var(--map-start);
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--pin-color) 72%, white) 0%,
    var(--pin-color) 48%,
    color-mix(in srgb, var(--pin-color) 75%, black) 100%
  );
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: box-shadow var(--transition), transform var(--transition);
}

.marker-pin::after {
  content: '';
  position: absolute;
  inset: 3px 3px auto;
  height: 35%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent);
  pointer-events: none;
}

.marker-pin svg {
  position: relative;
  z-index: 1;
  transform: rotate(45deg);
  width: 15px;
  height: 15px;
  color: rgba(255, 255, 255, 0.96);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.marker-pin--start { --pin-color: var(--map-start); }
.marker-pin--end { --pin-color: var(--map-end); }
.marker-pin--loop { --pin-color: var(--map-start); }

.marker-pin span {
  position: relative;
  z-index: 1;
  transform: rotate(45deg);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.96);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.waypoint-pin {
  --pin-color: var(--map-waypoint);
  width: 30px;
  height: 30px;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--pin-color) 72%, white) 0%,
    var(--pin-color) 48%,
    color-mix(in srgb, var(--pin-color) 75%, black) 100%
  ) !important;
}

/* ─── Variations selector ─────────────────────────────────────── */
.variations-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}

.variations-select {
  width: auto;
  min-width: 110px;
  text-align: left;
  cursor: pointer;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  transition: border-color var(--transition);
}

.variations-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ─── Pace & Stops ────────────────────────────────────────────── */
.pace-stops-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 0;
}

.metric-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: var(--text-muted);
  text-align: center;
}

.metric-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.metric-stepper-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
}

.metric-stepper-value--inline {
  flex-direction: row;
  align-items: baseline;
  gap: 3px;
  min-width: auto;
}

.metric-display {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.metric-display--sm {
  font-size: 18px;
  min-width: 20px;
  text-align: center;
}

.metric-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

.metric-unit--sm {
  margin-top: 0;
  font-size: 10px;
}

.metric-step-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.metric-step-btn--sm {
  width: 30px;
  height: 30px;
  font-size: 17px;
}

.metric-step-btn:hover:not(:disabled) {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.metric-step-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.metric-step-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.stops-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  flex-wrap: nowrap;
}

.stops-stepper-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.stops-multiply {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  padding: 0 1px;
}

.pace-stops-hint {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.45;
}

/* ─── Route lines ──────────────────────────────────────────────── */
.route-casing {
  pointer-events: none !important;
}

.route-polyline {
  --route-glow: var(--map-route-best);
  transition: filter 220ms ease-out;
}

.route-polyline.route-flow {
  animation: route-dash-flow 1.1s linear infinite;
}

@keyframes route-dash-flow {
  to { stroke-dashoffset: -26; }
}

.route-polyline.route-selected {
  filter:
    drop-shadow(0 0 5px color-mix(in srgb, var(--route-glow) 70%, transparent))
    drop-shadow(0 0 12px color-mix(in srgb, var(--route-glow) 35%, transparent))
    drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}

@media (prefers-reduced-motion: reduce) {
  .route-polyline.route-flow { animation: none; }
}

/* ─── Route anchor handles (edit mode) ─────────────────────────── */
.route-anchor-marker {
  background: none !important;
  border: none !important;
}

.route-anchor-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fdba74, var(--accent));
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: grab;
  transition: transform var(--transition), box-shadow var(--transition);
}

.route-anchor-dot--corner {
  width: 14px;
  height: 14px;
  border-width: 2.5px;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent),
    0 2px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.leaflet-marker-draggable .route-anchor-dot {
  cursor: grabbing;
}

.route-anchor-dot:hover {
  transform: scale(1.12);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent),
    0 2px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.anchor-popup-wrap .leaflet-popup-content-wrapper {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  padding: 0;
}

.anchor-popup-wrap .leaflet-popup-content {
  margin: 0 !important;
  min-width: 140px;
}

.anchor-popup-wrap .leaflet-popup-tip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
}

.anchor-menu {
  padding: 6px;
}

.anchor-menu-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  background: transparent;
  color: var(--text-primary);
  transition: background var(--transition);
}

.anchor-menu-btn:hover {
  background: var(--bg-hover);
}

.anchor-menu-btn--danger {
  color: #fca5a5;
}

.anchor-menu-btn--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fecaca;
}

.anchor-menu-hint {
  margin: 0;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Route edit hover circle ──────────────────────────────────── */
.route-hover-circle {
  animation: hover-pulse 1.2s ease-in-out infinite;
  pointer-events: none;
  transform-origin: center;
}

@keyframes hover-pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.4; }
}

.map-panel--editing .route-polyline {
  cursor: pointer;
}

.map-panel--editing .route-polyline:hover {
  filter:
    drop-shadow(0 0 6px color-mix(in srgb, var(--route-glow, var(--accent)) 75%, transparent))
    drop-shadow(0 0 14px color-mix(in srgb, var(--route-glow, var(--accent)) 40%, transparent));
}

/* ─── KM markers along route ───────────────────────────────────── */
.km-marker-wrap {
  background: none !important;
  border: none !important;
}

.km-marker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid color-mix(in srgb, var(--km-color, var(--accent)) 65%, transparent);
  background: color-mix(in srgb, var(--map-casing) 78%, transparent);
  backdrop-filter: blur(4px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.km-marker-label {
  position: relative;
  z-index: 1;
  line-height: 1;
}

.km-marker--minor {
  width: 16px;
  height: 16px;
  font-size: 7px;
  font-weight: 600;
  opacity: 0.72;
  animation: km-pulse-soft 3.2s ease-in-out infinite;
}

.km-marker--major {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  box-shadow: none;
}

.km-marker-dot {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.97);
  background: color-mix(in srgb, var(--map-casing) 88%, transparent);
  border: 1.5px solid var(--km-color, var(--accent));
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 0 8px color-mix(in srgb, var(--km-color, var(--accent)) 30%, transparent),
    0 2px 6px rgba(0, 0, 0, 0.45);
  animation: km-pulse-soft 2.6s ease-in-out infinite;
}

.km-marker-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--km-color, var(--accent)) 80%, transparent);
  animation: km-ring-grow 2.6s ease-out infinite;
}

@keyframes km-pulse-soft {
  0%, 100% { transform: scale(1); opacity: 0.78; }
  50% { transform: scale(1.05); opacity: 1; }
}

@keyframes km-ring-grow {
  0% { transform: scale(0.55); opacity: 0.45; }
  100% { transform: scale(1.75); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .km-marker--minor,
  .km-marker-dot,
  .km-marker-ring { animation: none; }
}

/* ─── App modals ────────────────────────────────────────────────── */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4100;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 4200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  pointer-events: none;
}

.app-modal:not(.hidden) {
  pointer-events: auto;
}

.app-modal-card {
  width: min(400px, 100%);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 22px 20px 18px;
  box-shadow: var(--shadow-panel);
  animation: modal-in 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.app-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.app-modal-sub {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.app-modal-input {
  width: 100%;
  margin-top: 16px;
  text-align: left;
}

.app-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.app-modal-actions .btn {
  flex: 1;
}

body.modal-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .app-modal-card { animation: none; }
  .map-chip--favorite.map-chip--pop { animation: none; }
}

/* ─── Save panel ────────────────────────────────────────────────── */
.save-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─── Saved routes list ────────────────────────────────────────── */
.saved-routes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-route-card {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.saved-route-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.saved-route-thumb {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.saved-route-thumb-placeholder {
  width: 100%;
  height: 60px;
  background: var(--bg-app);
}

.saved-route-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saved-route-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-route-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.saved-route-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 14, 20, 0.85);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--red);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
  padding: 0;
  backdrop-filter: blur(4px);
}

.saved-route-delete:hover {
  background: var(--red-dim);
  border-color: var(--red);
}

/* ─── Live GPS mode ──────────────────────────────────────────── */

.map-chip--live {
  border-color: rgba(96, 165, 250, 0.45);
  color: #93c5fd;
}

.map-chip--live:hover {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
  color: #bfdbfe;
}

.map-chip--live-active {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.15);
  color: #bfdbfe;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3), 0 4px 20px rgba(0, 0, 0, 0.45);
}

.map-chip--live-active .map-chip-icon--gps {
  color: #60a5fa;
  animation: gps-pulse 2s ease-in-out infinite;
}

.map-chip-icon--gps {
  color: #93c5fd;
  width: 18px;
  height: 18px;
}

@keyframes gps-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.map-chip--center {
  border-color: rgba(96, 165, 250, 0.25);
  color: #93c5fd;
}

.map-chip--center:hover {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
  color: #bfdbfe;
}

.map-chip--center.map-chip--center-active {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.15);
  color: #bfdbfe;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3);
}

/* Status badge — overlay at top-center of map */
.live-status-badge {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  background: rgba(12, 14, 20, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  pointer-events: none;
  z-index: 710;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.live-status-badge--green {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.1);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.25), 0 4px 20px rgba(0, 0, 0, 0.45);
}

.live-status-badge--amber {
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.1);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.25), 0 4px 20px rgba(0, 0, 0, 0.45);
}

.live-status-badge--red {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.3), 0 4px 20px rgba(0, 0, 0, 0.45);
  animation: badge-shake 0.5s ease-in-out;
}

@keyframes badge-shake {
  0%, 100% { transform: translateX(-50%) translateX(0); }
  20% { transform: translateX(-50%) translateX(-4px); }
  40% { transform: translateX(-50%) translateX(4px); }
  60% { transform: translateX(-50%) translateX(-3px); }
  80% { transform: translateX(-50%) translateX(3px); }
}

.live-status-text {
  display: block;
  line-height: 1.4;
}

/* Progress bar — under the status badge */
.live-progress-bar {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 46px);
  left: 50%;
  transform: translateX(-50%);
  width: min(280px, calc(100% - 64px));
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  z-index: 710;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.live-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #38bdf8);
  border-radius: 2px;
  transition: width 0.6s ease-out;
  width: 0%;
}

/* Live position dot — blue pulsing circle */
.live-dot-marker {
  background: none !important;
  border: none !important;
}

.live-dot-outer {
  position: relative;
  width: 28px;
  height: 28px;
}

.live-dot-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #60a5fa;
  border: 2.5px solid #fff;
  box-shadow:
    0 0 12px rgba(96, 165, 250, 0.8),
    0 0 24px rgba(96, 165, 250, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.4);
  animation: live-dot-pulse 2s ease-in-out infinite;
}

.live-dot-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 2px solid rgba(96, 165, 250, 0.5);
  animation: live-ring-grow 2.6s ease-out infinite;
}

@keyframes live-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.85); opacity: 0.7; }
}

@keyframes live-ring-grow {
  0% { transform: scale(0.4); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Breadcrumb trail */
.live-breadcrumb-line {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .live-dot-inner,
  .live-dot-ring,
  .map-chip--live-active .map-chip-icon--gps {
    animation: none;
  }
  .live-status-badge--red { animation: none; }
}

/* ─── Mobile app layout ───────────────────────────────────────── */
@media (max-width: 768px) {
  body.is-mobile { overflow: hidden; }

  .app-container {
    display: block;
    position: relative;
    height: 100vh;
    height: 100dvh;
  }

  .map-panel {
    position: fixed;
    inset: 0;
    z-index: 1;
  }

  .map-editing-slot {
    top: auto;
    bottom: calc(92px + env(safe-area-inset-bottom));
    font-size: 12px;
  }

  .map-edit-hint {
    font-size: 12px;
  }

  body.controls-open .map-editing-slot {
    bottom: calc(78vh + env(safe-area-inset-bottom));
  }

  /* Bottom sheet controls */
  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1900;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
  }

  .drawer-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(88vh, 100dvh);
    max-height: min(88vh, 100dvh);
    border-left: none;
    border-top: 1px solid var(--border-strong);
    border-radius: 20px 20px 0 0;
    z-index: 2000;
    transform: translateY(calc(100% - 92px));
    transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.55);
    padding-bottom: env(safe-area-inset-bottom);
  }

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

  .drawer-peek {
    display: block;
    flex-shrink: 0;
    padding: 8px 16px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    border-radius: 20px 20px 0 0;
    touch-action: pan-y;
  }

  .drawer-handle {
    display: flex;
    width: 100%;
    justify-content: center;
    padding: 6px 0 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    touch-action: none;
  }

  .drawer-handle-bar {
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: var(--border-strong);
  }

  .drawer-peek-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .drawer-peek-credit {
    margin: 4px 0 0;
    text-align: center;
    font-size: 11px;
    line-height: 1.2;
  }

  .sidebar-footer .sidebar-credit {
    display: none;
  }

  .drawer-peek-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .drawer-peek-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
  }

  .drawer-peek-summary {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn-peek-generate {
    flex-shrink: 0;
    padding: 10px 18px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 12px var(--accent-glow);
    transition: all var(--transition);
  }

  .btn-peek-generate:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
  }

  .btn-peek-generate:not(:disabled):active {
    transform: scale(0.96);
  }

  .sidebar:not(.drawer-open) .sidebar-header,
  .sidebar:not(.drawer-open) .sidebar-scroll,
  .sidebar:not(.drawer-open) .sidebar-footer {
    visibility: hidden;
    pointer-events: none;
    height: 0;
    overflow: hidden;
    padding: 0;
    border: none;
  }

  .sidebar.drawer-open .sidebar-header {
    display: none;
  }

  .sidebar-scroll {
    flex: 1;
    padding: 12px 14px 8px;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-footer {
    padding: 12px 14px max(14px, env(safe-area-inset-bottom));
  }

  .panel { padding: 14px; }

  .distance-display { font-size: 44px; }

  .distance-step-btn {
    width: 48px;
    height: 48px;
  }

  .metric-step-btn {
    width: 40px;
    height: 40px;
  }

  .btn {
    padding: 16px 20px;
    font-size: 16px;
  }

  .mode-btn {
    padding: 12px 8px;
  }

  .point-chip {
    padding: 11px 12px;
  }

  .pace-stops-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .metric-card {
    flex-direction: row;
    justify-content: space-between;
    padding: 12px 14px;
  }

  .metric-card-label {
    text-align: left;
    min-width: 88px;
  }

  .leaflet-top.leaflet-right {
    top: max(14px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .leaflet-bottom.leaflet-left {
    bottom: calc(88px + env(safe-area-inset-bottom));
    transition: bottom 0.42s cubic-bezier(0.32, 0.72, 0, 1);
  }

  body.controls-open .leaflet-bottom.leaflet-left {
    bottom: calc(78vh + env(safe-area-inset-bottom));
  }

  .saved-route-card {
    flex-direction: column;
  }

  .saved-route-thumb,
  .saved-route-thumb-placeholder {
    width: 100%;
    height: 120px;
  }
}

@media (min-width: 769px) {
  .drawer-peek { display: none !important; }
}
