/* ============================================================
   CubaMaps — sistema de diseño
   Tres temas: dia (claro), noche (oscuro), satelite (imagenes).
   Todo el color vive en variables; cambiar de tema es cambiar
   un atributo en <html>, sin recargar ni repintar el mapa.
   ============================================================ */

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-full: 999px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --dur: .28s;

  --brand: #0ea5e9;
  --brand-ink: #ffffff;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
}

/* ---------- Tema: Día ---------- */
[data-theme='dia'] {
  --bg: #ffffff;
  --bg-sunken: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .07), 0 2px 4px -2px rgba(15, 23, 42, .07);
  --shadow-lg: 0 10px 24px -4px rgba(15, 23, 42, .12), 0 4px 8px -4px rgba(15, 23, 42, .08);
  --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, .22);
  --route-line: #1a73e8;
  --route-alt: #9aa5b1;
  --scrim: rgba(15, 23, 42, .32);
}

/* ---------- Tema: Noche ---------- */
[data-theme='noche'] {
  --bg: #0b1220;
  --bg-sunken: #060a13;
  --surface: #131c2e;
  --surface-2: #1b2639;
  --surface-hover: #22304a;
  --border: #26334b;
  --border-strong: #38496a;
  --ink: #e8eef8;
  --ink-2: #a3b0c6;
  --ink-3: #6b7c99;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, .55);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, .6);
  --shadow-xl: 0 24px 56px rgba(0, 0, 0, .7);
  --route-line: #4da3ff;
  --route-alt: #4a5a75;
  --scrim: rgba(0, 0, 0, .55);
}

/* ---------- Tema: Satélite ---------- */
/* Fondo de imagen aérea: los paneles se oscurecen y ganan desenfoque
   para que el texto siga legible sobre cualquier terreno. */
[data-theme='satelite'] {
  --bg: #0d1117;
  --bg-sunken: #05080d;
  --surface: rgba(16, 22, 33, .93);
  --surface-2: rgba(28, 37, 52, .93);
  --surface-hover: rgba(40, 52, 72, .95);
  --border: rgba(255, 255, 255, .12);
  --border-strong: rgba(255, 255, 255, .24);
  --ink: #f3f6fb;
  --ink-2: #b9c4d6;
  --ink-3: #7d8ba3;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .6);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .65);
  --shadow-lg: 0 14px 32px rgba(0, 0, 0, .7);
  --shadow-xl: 0 28px 60px rgba(0, 0, 0, .8);
  --route-line: #00e5ff;
  --route-alt: #5f7183;
  --scrim: rgba(0, 0, 0, .6);
  --panel-blur: saturate(140%) blur(14px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* ============================================================
   Mapa
   ============================================================ */

#map { position: absolute; inset: 0; background: var(--bg-sunken); z-index: 0; }
.leaflet-container { font-family: var(--font); background: var(--bg-sunken); }
.leaflet-control-attribution {
  background: var(--surface) !important;
  color: var(--ink-3) !important;
  font-size: 10px !important;
  padding: 2px 8px !important;
  border-radius: var(--r-full) 0 0 0;
}
.leaflet-control-attribution a { color: var(--ink-2) !important; }
.leaflet-control-zoom { display: none; }  /* usamos controles propios */

/* En tema noche las teselas claras se atenúan un punto para no deslumbrar. */
[data-theme='noche'] .leaflet-tile-pane { filter: brightness(.92); }

/* ============================================================
   Marcadores
   ============================================================ */

/* Pin de lugar: gota con emoji dentro. */
.pin {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-size: 16px; line-height: 1;
  background: var(--pin-color, var(--brand));
  border: 2.5px solid var(--surface);
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  box-shadow: var(--shadow-md);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.pin > span { transform: rotate(45deg); }
.pin:hover { transform: rotate(-45deg) scale(1.16); box-shadow: var(--shadow-lg); z-index: 500; }
.pin.is-active { transform: rotate(-45deg) scale(1.25); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pin-color) 35%, transparent), var(--shadow-lg); }

/* Reporte: círculo con halo que late, para que salte a la vista. */
.report-pin {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-size: 17px;
  background: var(--pin-color, var(--danger));
  border: 2.5px solid var(--surface);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  position: relative;
}
.report-pin::after {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--pin-color, var(--danger));
  opacity: .75;
  animation: ping 2.2s var(--ease) infinite;
}
@keyframes ping {
  0%   { transform: scale(.85); opacity: .75; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Punto azul de "tú estás aquí", con cono de rumbo cuando hay brújula. */
.me-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 8px rgba(26, 115, 232, .18), var(--shadow-md);
  position: relative;
}
.me-dot.has-heading::before {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-bottom: 26px solid rgba(26, 115, 232, .3);
  transform: translate(-50%, -100%) rotate(var(--heading, 0deg));
  transform-origin: 50% 100%;
}

/* Pin arrastrable que aparece al tocar el mapa. */
.drop-pin {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 22px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35));
  animation: drop-in .45s var(--ease);
}
@keyframes drop-in {
  0%   { transform: translateY(-32px) scale(.6); opacity: 0; }
  60%  { transform: translateY(4px) scale(1.06); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Racimo de marcadores agrupados por cercanía. */
.cluster {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 650;
  font-size: 13px;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Barra superior — búsqueda
   ============================================================ */

.topbar {
  position: absolute; z-index: 800;
  top: var(--sp-4); left: var(--sp-4);
  width: 400px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; gap: var(--sp-2);
}

.searchbar {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.searchbar:focus-within {
  border-color: var(--brand);
  box-shadow: var(--shadow-lg), 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.searchbar input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: none;
  font-size: 15px; padding: var(--sp-2) 0;
}
.searchbar input::placeholder { color: var(--ink-3); }

.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff; font-size: 15px;
  flex-shrink: 0;
}

.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform .15s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.is-on { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.icon-btn svg { width: 20px; height: 20px; }

/* Sugerencias del buscador */
.suggestions {
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  max-height: 60vh; overflow-y: auto;
  animation: slide-down .2s var(--ease);
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.suggestion {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  transition: background .15s var(--ease);
}
.suggestion:last-child { border-bottom: none; }
.suggestion:hover, .suggestion.is-cursor { background: var(--surface-hover); }
.suggestion-icon {
  display: grid; place-items: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 16px;
}
.suggestion-text { min-width: 0; flex: 1; }
.suggestion-name { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.suggestion-badge { font-size: 10px; font-weight: 600; color: var(--ink-3); flex-shrink: 0; text-transform: uppercase; letter-spacing: .04em; }

/* Filtros por categoría */
.chips { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-sm);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.chip.is-on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* ============================================================
   Controles flotantes (derecha)
   ============================================================ */

.controls {
  position: absolute; z-index: 700;
  right: var(--sp-4); bottom: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-3);
  align-items: flex-end;
}

.fab {
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  color: var(--ink-2);
  box-shadow: var(--shadow-lg);
  transition: all var(--dur) var(--ease);
}
.fab:hover { color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow-xl); }
.fab:active { transform: scale(.94); }
.fab svg { width: 22px; height: 22px; }
.fab.is-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.fab-primary {
  width: 58px; height: 58px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border-color: transparent;
  color: #fff;
}
.fab-primary:hover { background: linear-gradient(135deg, #fb923c, #f97316); color: #fff; }
.fab-primary svg { width: 26px; height: 26px; }

.zoom-stack {
  display: flex; flex-direction: column;
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.zoom-stack button {
  width: 46px; height: 44px;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: background .15s var(--ease);
}
.zoom-stack button:hover:not(:disabled) { background: var(--surface-hover); color: var(--ink); }
.zoom-stack button:disabled { opacity: .35; cursor: default; }
.zoom-stack button + button { border-top: 1px solid var(--border); }
.zoom-stack svg { width: 18px; height: 18px; }

/* ============================================================
   Selector de tema
   ============================================================ */

.theme-switch {
  position: absolute; z-index: 750;
  right: var(--sp-4); top: var(--sp-4);
  display: flex; gap: var(--sp-1);
  padding: var(--sp-1);
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
}
.theme-opt {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-full);
  font-size: 13px; font-weight: 550;
  color: var(--ink-3);
  transition: all var(--dur) var(--ease);
}
.theme-opt:hover { color: var(--ink); background: var(--surface-hover); }
.theme-opt.is-on { background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-sm); }
.theme-opt svg { width: 16px; height: 16px; }
a.theme-opt { text-decoration: none; font-weight: 700; letter-spacing: .03em; }

.theme-sep {
  width: 1px;
  align-self: stretch;
  margin: 4px 2px;
  background: var(--border);
}

/* ============================================================
   Panel lateral (detalle de lugar, ruta, formularios)
   ============================================================ */

.panel {
  position: absolute; z-index: 900;
  top: 0; left: 0; bottom: 0;
  width: 400px; max-width: 100vw;
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column;
  transform: translateX(-102%);
  transition: transform var(--dur) var(--ease);
}
.panel.is-open { transform: translateX(0); }

.panel-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title { font-size: 17px; font-weight: 650; flex: 1; min-width: 0; }
.panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.panel-foot {
  padding: var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--sp-2);
  flex-shrink: 0;
}

/* Cabecera del detalle de un lugar */
.place-hero {
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  background: linear-gradient(160deg, color-mix(in srgb, var(--hero-color, var(--brand)) 18%, transparent), transparent 70%);
}
.place-cat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--hero-color, var(--brand)) 16%, transparent);
  color: var(--hero-color, var(--brand));
  font-size: 12px; font-weight: 600;
}
.place-name { font-size: 24px; font-weight: 700; line-height: 1.2; margin: var(--sp-3) 0 var(--sp-2); }
.place-meta { font-size: 13px; color: var(--ink-2); line-height: 1.6; }

.rating-row { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.stars { display: inline-flex; gap: 1px; color: var(--warn); font-size: 15px; letter-spacing: -1px; }
.rating-num { font-weight: 650; font-size: 15px; }
.rating-count { font-size: 13px; color: var(--ink-3); }

/* Distribución de estrellas (barras 5→1) */
.dist-row { display: flex; align-items: center; gap: var(--sp-2); font-size: 12px; color: var(--ink-3); margin-bottom: 5px; }
.dist-bar { flex: 1; height: 7px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.dist-fill { height: 100%; background: var(--warn); border-radius: var(--r-full); transition: width .6s var(--ease); }

.section { padding: var(--sp-4); border-top: 1px solid var(--border); }
.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3);
  margin: 0 0 var(--sp-3);
}

.info-row { display: flex; gap: var(--sp-3); padding: var(--sp-2) 0; font-size: 14px; align-items: flex-start; }
.info-row svg { width: 18px; height: 18px; color: var(--ink-3); flex-shrink: 0; margin-top: 1px; }
.info-row a { word-break: break-word; }

/* Reseñas */
.review { padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.review:last-child { border-bottom: none; }
.review-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: 6px; }
.avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #6366f1);
  color: #fff; font-size: 13px; font-weight: 650;
  flex-shrink: 0;
}
.review-author { font-size: 14px; font-weight: 600; }
.review-level { font-size: 11px; color: var(--ink-3); }
.review-date { font-size: 12px; color: var(--ink-3); margin-left: auto; flex-shrink: 0; }
.review-text { font-size: 14px; color: var(--ink-2); line-height: 1.55; }

/* ============================================================
   Formularios
   ============================================================ */

.field { margin-bottom: var(--sp-4); }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; line-height: 1.45; }

.input, .select, .textarea {
  width: 100%;
  padding: 11px var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.5; font-family: inherit; }
.select { appearance: none; cursor: pointer; padding-right: var(--sp-6); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 11px var(--sp-4);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 600;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 17px; height: 17px; }

.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 88%, #000); box-shadow: var(--shadow-md); }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); }
.btn-nav { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.btn-nav:hover:not(:disabled) { background: linear-gradient(135deg, #34d399, #10b981); }
.btn-block { width: 100%; }

/* Selector de estrellas para calificar */
.star-input { display: flex; gap: var(--sp-1); }
.star-input button {
  font-size: 30px; line-height: 1;
  color: var(--border-strong);
  transition: transform .15s var(--ease), color .15s var(--ease);
}
.star-input button:hover { transform: scale(1.2); }
.star-input button.is-on { color: var(--warn); }

/* Rejilla de tipos de reporte */
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.report-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: var(--sp-3) var(--sp-2);
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  font-size: 11px; font-weight: 600; text-align: center;
  line-height: 1.25;
  transition: all var(--dur) var(--ease);
}
.report-opt:hover { background: var(--surface-hover); transform: translateY(-2px); }
.report-opt.is-on { border-color: var(--opt-color); background: color-mix(in srgb, var(--opt-color) 14%, transparent); }
.report-opt .emoji { font-size: 26px; }

/* Rejilla de categorías del formulario de lugares */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--sp-2); }
.cat-opt {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: var(--sp-3) 6px;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  font-size: 11px; font-weight: 550; text-align: center; line-height: 1.2;
  transition: all var(--dur) var(--ease);
}
.cat-opt:hover { background: var(--surface-hover); }
.cat-opt.is-on { border-color: var(--opt-color); background: color-mix(in srgb, var(--opt-color) 14%, transparent); }
.cat-opt .emoji { font-size: 22px; }

/* ============================================================
   Navegación activa
   ============================================================ */

/* Tarjeta de maniobra en curso, arriba y a la vista. */
.nav-banner {
  position: absolute; z-index: 950;
  top: var(--sp-4); left: 50%;
  transform: translate(-50%, -140%);
  width: 460px; max-width: calc(100vw - 32px);
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-4);
  transition: transform .4s var(--ease);
}
.nav-banner.is-open { transform: translate(-50%, 0); }
.nav-arrow {
  display: grid; place-items: center;
  width: 56px; height: 56px; flex-shrink: 0;
  background: rgba(255, 255, 255, .2);
  border-radius: var(--r-md);
  font-size: 30px;
}
.nav-dist { font-size: 26px; font-weight: 750; line-height: 1; }
.nav-instr { font-size: 15px; opacity: .95; margin-top: 5px; line-height: 1.35; }

/* Barra inferior con ETA y control de la navegación. */
.nav-bottom {
  position: absolute; z-index: 950;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-4);
  transform: translateY(110%);
  transition: transform .4s var(--ease);
}
.nav-bottom.is-open { transform: translateY(0); }
.nav-stat { text-align: center; }
.nav-stat-val { font-size: 21px; font-weight: 700; line-height: 1.1; }
.nav-stat-lab { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.nav-eta { color: var(--ok); }

/* Aviso de peligro cercano durante la navegación. */
.alert-toast {
  position: absolute; z-index: 960;
  top: 120px; left: 50%;
  transform: translate(-50%, -20px);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-left: 4px solid var(--alert-color, var(--danger));
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xl);
  opacity: 0; pointer-events: none;
  transition: all var(--dur) var(--ease);
}
.alert-toast.is-open { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.alert-emoji { font-size: 26px; }
.alert-title { font-size: 14px; font-weight: 650; }
.alert-sub { font-size: 12px; color: var(--ink-3); }

/* ============================================================
   Planificador de rutas (origen → destino)
   ============================================================ */

.trip-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

/* Raíl vertical que une el punto A con el B, como en Google Maps. */
.trip-rail {
  display: flex; flex-direction: column; align-items: center;
  height: 100%; padding: 14px 0;
}
.trip-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.trip-dot-a { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.trip-dot-b { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.trip-line {
  flex: 1; width: 2px; min-height: 22px;
  margin: 5px 0;
  background: repeating-linear-gradient(var(--border-strong) 0 3px, transparent 3px 7px);
}

.trip-fields { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.trip-field { position: relative; }
.trip-field .input { padding-right: 38px; }
.trip-clear {
  position: absolute; right: 3px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
}
.trip-clear svg { width: 15px; height: 15px; }

.trip-swap {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.trip-swap:hover { background: var(--surface-hover); }

/* Modo de transporte */
.mode-chips {
  display: flex; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.mode-chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  flex: 1;
  padding: 9px var(--sp-2);
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 600;
  transition: all var(--dur) var(--ease);
}
.mode-chip:hover { background: var(--surface-hover); }
.mode-chip.is-on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.mode-chip span:first-child { font-size: 17px; }

/* Marcadores A y B de los extremos del viaje */
.trip-marker {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  background: var(--tm-color, var(--brand));
  color: #fff; font-weight: 700; font-size: 14px;
  border: 2.5px solid var(--surface);
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  box-shadow: var(--shadow-md);
}
.trip-marker > span { transform: rotate(45deg); }

/* Aviso informativo dentro de un panel */
.notice {
  display: flex; gap: var(--sp-2);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  background: color-mix(in srgb, var(--brand) 9%, transparent);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-sm);
  font-size: 12.5px; line-height: 1.5; color: var(--ink-2);
}

/* Tarjetas de alternativas de ruta */
.route-card {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; text-align: left;
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
  transition: all var(--dur) var(--ease);
}
.route-card:hover { background: var(--surface-hover); }
.route-card.is-on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.route-badge {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--brand); color: #fff;
  font-size: 18px;
}
.route-time { font-size: 17px; font-weight: 700; }
.route-dist { font-size: 13px; color: var(--ink-3); }
.route-alerts { font-size: 12px; color: var(--warn); margin-top: 3px; font-weight: 550; }

/* Lista de maniobras */
.step {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.step:last-child { border-bottom: none; }
.step-icon {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 16px;
}
.step-instr { line-height: 1.4; }
.step-dist { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ============================================================
   Tarjeta de reporte (popup al pulsar un reporte)
   ============================================================ */

.report-card {
  position: absolute; z-index: 880;
  left: 50%; bottom: var(--sp-5);
  transform: translate(-50%, 130%);
  width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-4);
  transition: transform var(--dur) var(--ease);
}
.report-card.is-open { transform: translate(-50%, 0); }
.report-card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.report-card-emoji {
  display: grid; place-items: center;
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--rc-color, var(--danger)) 16%, transparent);
  font-size: 24px;
}
.report-card-title { font-size: 16px; font-weight: 650; }
.report-card-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.vote-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }

/* ============================================================
   Avisos flotantes (toast)
   ============================================================ */

.toast-stack {
  position: fixed; z-index: 1100;
  bottom: var(--sp-5); left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-xl);
  font-size: 14px; font-weight: 500;
  animation: toast-in .3s var(--ease);
  max-width: 90vw;
}
.toast.is-out { animation: toast-out .25s var(--ease) forwards; }
.toast-ok { border-left: 4px solid var(--ok); }
.toast-err { border-left: 4px solid var(--danger); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(16px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.96); } }

/* ============================================================
   Modales
   ============================================================ */

.modal-scrim {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: var(--sp-4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.modal-scrim.is-open { opacity: 1; pointer-events: auto; }
.modal {
  width: 420px; max-width: 100%;
  max-height: 88vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  transform: scale(.94) translateY(12px);
  transition: transform var(--dur) var(--ease);
}
.modal-scrim.is-open .modal { transform: none; }
.modal-head { padding: var(--sp-5) var(--sp-5) 0; }
.modal-title { font-size: 20px; font-weight: 700; }
.modal-sub { font-size: 14px; color: var(--ink-2); margin-top: 6px; line-height: 1.5; }
.modal-body { padding: var(--sp-5); }

/* ============================================================
   Utilidades
   ============================================================ */

.stack > * + * { margin-top: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--ink-3); }
.empty-emoji { font-size: 42px; margin-bottom: var(--sp-3); opacity: .55; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 650;
  background: var(--surface-2);
  color: var(--ink-2);
}
.badge-ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }

/* ============================================================
   Móvil — el panel pasa a ser hoja inferior
   ============================================================ */

@media (max-width: 640px) {
  .topbar { top: var(--sp-2); left: var(--sp-2); right: var(--sp-2); width: auto; }
  .theme-switch { top: auto; bottom: 96px; right: var(--sp-2); padding: 3px; }
  .theme-opt { padding: 7px 10px; }
  .theme-opt span { display: none; }   /* solo iconos, no cabe el texto */
  .controls { right: var(--sp-2); bottom: var(--sp-3); gap: var(--sp-2); }
  .fab { width: 44px; height: 44px; }
  .fab-primary { width: 54px; height: 54px; }
  .zoom-stack { display: none; }       /* en táctil se hace zoom con los dedos */

  .panel {
    top: auto; right: 0;
    width: 100%;
    height: 78vh;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(102%);
  }
  .panel.is-open { transform: translateY(0); }
  /* Asidero para arrastrar, como en cualquier hoja inferior nativa. */
  .panel::before {
    content: '';
    position: absolute; top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    background: var(--border-strong);
    border-radius: var(--r-full);
  }
  .panel-head { padding-top: var(--sp-5); }

  .nav-banner { top: var(--sp-2); padding: var(--sp-3); gap: var(--sp-3); }
  .nav-arrow { width: 46px; height: 46px; font-size: 24px; }
  .nav-dist { font-size: 21px; }
  .nav-instr { font-size: 13px; }
  .report-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
