﻿/*
   Mi Ruta  Diseño v2  |  Público / Transporte
   Tema claro + oscuro, glassmorphism, diseño moderno
*/

/* 
   VARIABLES  MODO OSCURO (default)
    */
:root {
  --topbar-h: 60px;
  --radius-2xl: 24px;
  --radius-xl:  18px;
  --radius-lg:  14px;
  --radius-md:  10px;
  --radius-sm:  8px;
  --trans:      0.22s ease;
  --trans-slow: 0.4s cubic-bezier(0.4,0,0.2,1);

  /* Fondo */
  --bg-base:    #070f1a;
  --bg-hero:    linear-gradient(145deg, #0b1828 0%, #0f1f35 40%, #0a2240 100%);
  --bg-body:    #0b1624;

  /* Superficies */
  --surface:    #0f1e33;
  --surface-2:  #162843;
  --surface-3:  #1d3454;
  --surface-4:  #254065;
  --glass:      rgba(15,30,51,0.82);
  /* Fondo del "chrome" (topbar/HUD/drawer): oscuro a propósito también en tema claro. */
  --chrome-bg:  rgba(15,30,51,0.82);
  /* Fondo de la leyenda del semáforo (control Leaflet sobre el mapa). Oscuro en
     ambos temas, igual que el chrome, para legibilidad del texto blanco. */
  --card-bg:    rgba(10,21,37,0.85);

  /* Bordes */
  --border:     rgba(255,255,255,0.08);
  --border-med: rgba(255,255,255,0.14);
  --border-hi:  rgba(255,255,255,0.24);

  /* Líneas y rellenos translúcidos. Constantes en ambos temas a propósito: el
     "chrome" (topbar/HUD/drawer) es oscuro también en tema claro, así que sus
     hairlines internos son blancos siempre. No redefinir en [data-theme="light"]. */
  --hairline:   rgba(255,255,255,0.07);
  --hairline-2: rgba(255,255,255,0.12);
  --fill-1:     rgba(255,255,255,0.05);

  /* Tripletas RGB de los colores de estado, para rgba(var(--x), α) sin color-mix
     (compatible con webviews viejos). Centraliza los tintes translúcidos de
     moving/stopped/warn/stale (marcadores, banner de unidad, chip de GPS).
     Los hex sólidos del mismo color siguen literales. */
  --st-moving-rgb:  52,211,153;
  --st-stopped-rgb: 99,102,241;
  --st-warn-rgb:    245,158,11;
  --st-stale-rgb:   239,68,68;

  /* Texto */
  --text:       #f0f6ff;
  --text-2:     #b8cee8;
  --text-muted: #7a97ba;
  /* ACC-03: ≥4.5:1 sobre --bg-body y --surface-2 (antes #425e7a, 2.2–2.7:1). */
  --text-dim:   #7591b4;

  /* Acento primario */
  --accent:       #ec483b;
  --accent-dark:  #c83830;
  --accent-glow:  rgba(236,72,59,0.32);
  --accent-light: rgba(236,72,59,0.12);

  /* Acento secundario */
  --accent-2:     #fbbf24;
  --success:      #34d399;
  --success-bg:   rgba(var(--st-moving-rgb),0.12);
  --danger:       #f87171;
  --danger-bg:    rgba(248,113,113,0.12);

  /* Paleta de rutas */
  --rc0:#ff6b2b; --rc1:#3b82f6; --rc2:#34d399; --rc3:#c084fc;
  --rc4:#fbbf24; --rc5:#22d3ee; --rc6:#f472b6; --rc7:#a3e635;
  --rc8:#fb923c; --rc9:#4ade80; --rc10:#818cf8; --rc11:#2dd4bf;

  /* Mapa: tile oscuro */
  --tile-filter: brightness(0.78) saturate(0.65) hue-rotate(5deg);

  /* Estaciones de tren: superficie gris-blanco (no el color de la línea, que pasa
     por encima). Tema oscuro → casi blanca para resaltar sobre el mapa oscuro. */
  --station-fill:     linear-gradient(150deg, #8d8d8d, #cccccc);  /* relleno (padding-box) */
  --station-edge:     linear-gradient(150deg, #ffffff, #d3d9e0);  /* borde (border-box)   */
  --station-fill-max: linear-gradient(150deg, #8d8d8d, #cccccc);  /* zoom máx: más opaco  */
  --station-glow:     rgba(226,232,240,0.55);                     /* resplandor           */
  --station-glyph:    rgba(30,41,59,0.78);                        /* glifo de respaldo    */
  --station-ripple:   rgba(255,255,255,0.85);                     /* onda de llegada      */
}

/* 
   VARIABLES  MODO CLARO
    */
[data-theme="light"] {
  --bg-base:    #f3f7fd;
  --bg-hero:    linear-gradient(145deg, #e8f0fc 0%, #dce9ff 40%, #d0e2ff 100%);
  --bg-body:    #eef3fb;

  --surface:    #ffffff;
  --surface-2:  #f0f5fd;
  --surface-3:  #e4edf9;
  --surface-4:  #d5e3f5;
  --glass:      rgba(15,30,51,0.82);
  --chrome-bg:  rgba(15,30,51,0.95);

  --border:     rgba(30,60,120,0.1);
  --border-med: rgba(30,60,120,0.16);
  --border-hi:  rgba(30,60,120,0.28);

  --text:       #0c1a30;
  --text-2:     #2a4570;
  --text-muted: #4a6898;
  /* ACC-03: ≥4.5:1 sobre blanco y --bg-body (antes #8aa3c4, 2.3–2.6:1). */
  --text-dim:   #56708f;

  --accent:       #ec483b;
  --accent-dark:  #c83830;
  --accent-glow:  rgba(236,72,59,0.22);
  --accent-light: rgba(236,72,59,0.09);

  --accent-2:     #d97706;
  --success:      #059669;
  --success-bg:   rgba(5,150,105,0.1);
  --danger:       #dc2626;
  --danger-bg:    rgba(220,38,38,0.1);

  --tile-filter: brightness(1.02) saturate(1.1);

  /* Tema claro → gris algo más marcado para separarse del mapa claro; el borde
     blanco y la sombra la despegan del fondo. */
  --station-fill:     linear-gradient(150deg, #e2e8f0, #b6c0cf);
  --station-edge:     linear-gradient(150deg, #ffffff, #c4cdda);
  --station-fill-max: linear-gradient(150deg, #eef2f7, #aab4c4);
  --station-glow:     rgba(100,116,139,0.4);
  --station-glyph:    rgba(30,41,59,0.82);
  --station-ripple:   rgba(71,85,105,0.6);
}

/* 
   RESET & BASE
    */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text);
  /* 1rem = 15px. ACC-04: ningún texto por debajo de 0.8rem (12px). */
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.35s ease, color 0.35s ease;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 4px; }

/* 
   TOPBAR
    */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--chrome-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-med);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 1000;
  box-shadow: 0 2px 24px rgba(0,0,0,0.18);
  transition: background 0.35s ease, border-color 0.35s ease;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.brand-icon {
  position: relative;
  height: calc(var(--topbar-h) - 18px);
  width: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.brand-logo {
  height: 100%;
  width: auto;
  max-width: 180px;
  object-fit: contain;
}
.brand-text {
  font-size: 1.08rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.status-label { white-space: nowrap; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.4s;
}
.dot--idle  { background: var(--text-dim); }
.dot--ok    { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot--error { background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Botón de tema */
.theme-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.2);
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.22) 0%, transparent 50%),
    linear-gradient(145deg, var(--hairline-2), rgba(255,255,255,0.04));
  color: #ffd166;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.22),
    0 8px 18px rgba(0,0,0,0.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  flex-shrink: 0;
  overflow: hidden;
}
.theme-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.32);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.32),
    0 10px 26px rgba(249,115,22,0.28);
}
.theme-btn:active {
  transform: translateY(0);
}
.theme-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(249,115,22,0.34),
    inset 0 1px 0 rgba(255,255,255,0.22),
    0 10px 22px rgba(0,0,0,0.24);
}

[data-theme="light"] .theme-btn {
  border-color: rgba(30,60,120,0.2);
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.9) 0%, transparent 52%),
    linear-gradient(145deg, rgba(255,255,255,0.92), rgba(220,232,250,0.88));
  color: #f59e0b;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.95),
    0 8px 18px rgba(18,38,74,0.16);
}

.theme-icon {
  position: absolute;
  width: 19px;
  height: 19px;
  display: block;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#iconSun { filter: drop-shadow(0 0 6px rgba(253,186,116,0.45)); }
#iconMoon { color: #93c5fd; filter: drop-shadow(0 0 6px rgba(147,197,253,0.45)); }

.theme-icon.hidden {
  opacity: 0;
  transform: scale(0.65) rotate(-25deg);
  pointer-events: none;
}

/* Sync bar */
.sync-bar {
  position: fixed;
  top: calc(var(--topbar-h) - 2px);
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  pointer-events: none;
  z-index: 1001;
  transform-origin: left;
}
.sync-bar.syncing {
  opacity: 1;
  animation: syncAnim 1.8s ease-in-out infinite;
}
@keyframes syncAnim {
  0%   { clip-path: inset(0 100% 0 0); }
  55%  { clip-path: inset(0 15%  0 0); }
  80%  { clip-path: inset(0 0    0 0); }
  100% { clip-path: inset(0 0    0 100%); }
}

/* 
   MAPA
    */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--bg-base);
}
/* Semaphore legend styling (Leaflet control). Estructura en JS, estilos aquí. */
.semaphore-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-muted, #c8d1e8);
  background: var(--card-bg, rgba(10,21,37,0.85));
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  z-index: 1200 !important;
  transition: opacity 0.25s ease;
  /* Own compositor layer so it isn't repainted together with the map
     while the picker sheet animates above it. */
  transform: translateZ(0);
}
.semaphore-legend div { color: #fff; }
.semaphore-legend__item { display: flex; align-items: center; gap: 8px; }
/* ACC-05: mismas formas que los marcadores — continuo / punteado / punteado. */
.semaphore-legend__dot {
  flex-shrink: 0;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
}
.semaphore-legend__dot--ok    { background: #4ade80; }
.semaphore-legend__dot--warn  { background: #f59e0b; border-style: dashed; }
.semaphore-legend__dot--error { background: #ef4444; border-style: dashed; }

#map .leaflet-tile { filter: var(--tile-filter); }

.leaflet-control-zoom {
  border: 1px solid var(--border-med) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25) !important;
  margin-top: calc(var(--topbar-h) + 0.7rem) !important;
}
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text-muted) !important;
  border-bottom: 1px solid var(--border) !important;
  width: 38px !important; height: 38px !important;
  line-height: 38px !important;
  font-size: 1.1rem !important;
  transition: all var(--trans);
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; color: var(--text) !important; }
.leaflet-popup, .leaflet-popup.leaflet-zoom-animated { display: none !important; }

/* Marker soft glow + blinking states */
.unit-marker {
  /* REN-04: antes inline en createMarkerIcon (markers.js); el fondo (color de
     la ruta) sigue inline. La sombra la ponen las clases --fresh/--warn/--stale. */
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 10px; color: #fff;
  transition: box-shadow 0.45s cubic-bezier(.2,.9,.2,1), border-color 0.45s cubic-bezier(.2,.9,.2,1);
  border: 2.5px solid rgba(255,255,255,0.95); /* default soft white circumference */
  will-change: transform, box-shadow;
  /* Color un poco más vivo/nítido (no afecta el blanco de la flecha ni la paleta de rutas en otros lugares). */
  filter: saturate(1.2) brightness(1.07);
}
.unit-marker svg { filter: drop-shadow(0 3px 8px rgba(0,0,0,0.28)); display: block; flex-shrink: 0; }

/* Softer, slower pulses + gentler colors */
.unit-marker--fresh { 
  border-color: rgba(74,222,128,0.62); /* softer green */
  box-shadow: 0 4px 10px rgba(0,0,0,0.35), 0 8px 20px rgba(74,222,128,0.08);
  animation: marker-pulse-fresh 3.6s cubic-bezier(.25,.8,.25,1) infinite;
}
.unit-marker--warn {
  border-color: rgba(var(--st-warn-rgb),0.6); /* softer amber */
  box-shadow: 0 4px 10px rgba(0,0,0,0.35), 0 8px 18px rgba(var(--st-warn-rgb),0.08);
  animation: marker-pulse-warn 3.0s cubic-bezier(.25,.8,.25,1) infinite;
}
.unit-marker--stale {
  border-color: rgba(var(--st-stale-rgb),0.6); /* softer red */
  box-shadow: 0 4px 10px rgba(0,0,0,0.35), 0 10px 24px rgba(var(--st-stale-rgb),0.10);
  animation: marker-pulse-stale 2.6s cubic-bezier(.25,.8,.25,1) infinite;
}
/* ACC-05: segunda pista además del color (daltonismo): aro punteado en
   "señal tardía" y "sin señal". */
.unit-marker--warn,
.unit-marker--stale { border-style: dashed; }

/* Pulse: halo simétrico centrado alrededor del círculo, corto e intenso */
@keyframes marker-pulse-fresh {
  0%   { transform: scale(1);    border-color: rgba(255,255,255,0.95); box-shadow: 0 0 0 2px rgba(74,222,128,0.2), 0 2px 5px rgba(0,0,0,0.45); }
  50%  { transform: scale(1.07); border-color: rgba(74,222,128,0.80);  box-shadow: 0 0 12px 6px rgba(74,222,128,0.15), 0 2px 8px rgba(0,0,0,0.30); }
  100% { transform: scale(1);    border-color: rgba(255,255,255,0.95); box-shadow: 0 0 0 2px rgba(74,222,128,0.2), 0 2px 5px rgba(0,0,0,0.45); }
}

@keyframes marker-pulse-warn {
  0%   { transform: scale(1);    border-color: rgba(255,255,255,0.95); box-shadow: 0 0 0 2px rgba(var(--st-warn-rgb),0.2), 0 2px 5px rgba(0,0,0,0.45); }
  50%  { transform: scale(1.07); border-color: rgba(var(--st-warn-rgb),0.82);  box-shadow: 0 0 12px 6px rgba(var(--st-warn-rgb),0.15), 0 2px 8px rgba(0,0,0,0.30); }
  100% { transform: scale(1);    border-color: rgba(255,255,255,0.95); box-shadow: 0 0 0 2px rgba(var(--st-warn-rgb),0.2), 0 2px 5px rgba(0,0,0,0.45); }
}

@keyframes marker-pulse-stale {
  0%   { transform: scale(1);    border-color: rgba(255,255,255,0.95); box-shadow: 0 0 0 2px rgba(var(--st-stale-rgb),0.2), 0 2px 5px rgba(0,0,0,0.45); }
  50%  { transform: scale(1.08); border-color: rgba(var(--st-stale-rgb),0.85);   box-shadow: 0 0 15px 7px rgba(var(--st-stale-rgb),0.18), 0 2px 8px rgba(0,0,0,0.30); }
  100% { transform: scale(1);    border-color: rgba(255,255,255,0.95); box-shadow: 0 0 0 2px rgba(var(--st-stale-rgb),0.2), 0 2px 5px rgba(0,0,0,0.45); }
}
/* 
   SPINNER
    */
.map-spinner {
  position: fixed;
  top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  background: rgba(7,15,26,0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 600;
}
[data-theme="light"] .map-spinner { background: rgba(243,247,253,0.8); }
/* topbar/HUD/drawer ya usan var(--chrome-bg), que el tema claro redefine a 0.95. */
.map-spinner.hidden { display: none; }

.spinner-ring {
  width: 44px; height: 44px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.72s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { font-size: 0.88rem; color: var(--text-muted); font-weight: 500; }

/* 
   ROUTE PICKER
    */
.route-picker {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: contain;
  background: var(--bg-body);
  /* Composite as a single opaque layer above the fixed map so the map
     never bleeds through for a few frames while the body scrolls. */
  transform: translateZ(0);
  backface-visibility: hidden;
  isolation: isolate;
  contain: layout paint;
  transition: opacity var(--trans-slow), transform var(--trans-slow);
}
.route-picker.hiding {
  opacity: 0;
  transform: scale(0.96) translateY(-10px);
  pointer-events: none;
}
.route-picker.hidden { display: none; }

/* ── Header azul ── */
.picker-header {
  background: linear-gradient(135deg, #14263f 0%, #1e3658 52%, #2b4870 100%);
  padding: calc(var(--topbar-h) + 1.2rem) 1.5rem 1.6rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 0 0 28px 28px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.picker-header::after {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--hairline-2) 0%, transparent 70%);
  pointer-events: none;
}
.picker-header-title {
  font-size: clamp(1.55rem, 5vw, 2rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.18;
  letter-spacing: -0.3px;
  margin-bottom: 0.3rem;
}
.picker-header-sub {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.65);
}
.picker-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 4px;
}
.picker-avatar-img {
  width: 34px; height: 34px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

/* ── Body scrollable ── */
.picker-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1.35rem 1.2rem 0.5rem;
  /* Promote the scroller to its own layer: scrolling shifts the texture
     instead of repainting, which removes the flicker on mobile. */
  transform: translateZ(0);
  contain: layout paint;
}

/* UX-02: invitación a activar la ubicación */
.geo-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
  margin-bottom: 1.1rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.geo-prompt.hidden { display: none; }
.geo-prompt-text {
  flex: 1 1 12rem;
  font-size: 0.85rem;
  color: var(--text);
}
.geo-prompt-btn {
  padding: 0.55rem 0.95rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent-dark);   /* blanco sobre --accent no llega a 4.5:1 */
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

/* Etiqueta de sección */
.section-label {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.9rem;
}

/* ── Lista de rutas ── */
.route-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 0.5rem;
}

/* Tarjeta de ruta — angular moderno + glass */
.route-btn {
  position: relative;
  width: 100%;
  height: 144px;
  border: none;
  border-radius: 26px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  overflow: hidden;
  padding: 0;
  isolation: isolate;
  contain: layout paint;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
  background: #0f1f35;
}
.route-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 18px 34px rgba(236,72,59,0.24);
}
.route-btn:active {
  transform: scale(0.995);
}

.route-card-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  pointer-events: none;
}
.route-btn:hover .route-card-bg {
  transform: scale(1.08);
}

.route-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(15,23,42,0.94) 0%, rgba(15,23,42,0.72) 56%, rgba(15,23,42,0) 100%);
  z-index: 1;
}

.route-card-glass {
  position: absolute;
  inset: 0;
  /* backdrop-filter: blur(2px) removed — a per-card backdrop blur inside a
     scrolling list re-blurs every frame and was the main scroll-flicker
     cause on mobile. A slightly stronger flat tint keeps the same look. */
  background: rgba(15,23,42,0.66);
  clip-path: polygon(0 0, 60% 0, 45% 100%, 0 100%);
  z-index: 2;
}

.route-card-accent {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(53% - 2px);
  width: 4px;
  transform: skewX(-23deg);
  background: linear-gradient(180deg, #fb923c 0%, #f97316 45%, #f59e0b 100%);
  z-index: 3;
  box-shadow: 0 0 14px rgba(251,146,60,0.45);
}

.route-card-float-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  /* backdrop-filter removed for scroll performance (see .route-card-glass). */
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}
.route-card-float-bus {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.85;
  pointer-events: none;
}

.route-card-content {
  position: relative;
  z-index: 5;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.15rem 1.4rem;
}

/* Trial / Beta modal */
.trial-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(5,10,20,0.55);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  z-index: 2500;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
.trial-modal--hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.trial-modal-card {
  position: relative;
  width: min(440px, 100%);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-med);
  padding: 1.6rem 1.5rem 1.35rem;
  border-radius: 20px;
  box-shadow: 0 28px 70px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  color: var(--text);
  overflow: hidden;
  transform: translateY(12px) scale(0.97);
  opacity: 0;
  transition: transform 0.34s cubic-bezier(0.22,1,0.36,1), opacity 0.28s ease;
}
.trial-modal-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2, #fbbf24));
}
.trial-modal:not(.trial-modal--hidden) .trial-modal-card { transform: none; opacity: 1; }
.trial-modal-badge {
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; margin: 0.2rem auto 0.9rem;
  border-radius: 14px; color: var(--accent);
  background: var(--accent-light); border: 1px solid var(--accent-glow);
}
.trial-modal-card--notice { text-align: center; }
.trial-modal-title { font-size: 1.2rem; margin-bottom: 0.5rem; font-weight: 800; letter-spacing: -0.01em; }
.trial-modal-body { color: var(--text-2); margin-bottom: 1rem; line-height: 1.55; font-size: 0.96rem; }
.trial-modal-ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
  margin: 0 auto 1.1rem; padding: 0.5rem 0.9rem; border-radius: 999px;
  background: var(--fill-1); border: 1px solid var(--hairline);
  color: var(--text-2); font-weight: 600; font-size: 0.9rem; cursor: pointer;
}
.trial-modal-ctl input { margin: 0; width: 16px; height: 16px; vertical-align: middle; accent-color: var(--accent); }
.trial-modal-actions { display: flex; justify-content: flex-end; }
.trial-modal .btn { padding: 0.7rem 1rem; border-radius: 12px; border: none; cursor: pointer; font-weight: 700; font-size: 0.96rem; transition: background var(--trans), transform 0.1s ease; }
.trial-modal .btn--block { width: 100%; }
/* ACC-03: blanco sobre --accent da 3.8:1; sobre --accent-dark 5.2:1. */
.trial-modal .btn--primary { background: var(--accent-dark); color: #fff; box-shadow: 0 12px 28px var(--accent-glow); border: 1px solid rgba(0,0,0,0.12); }
.trial-modal .btn--primary:hover { background: #b5322b; }
.trial-modal .btn--primary:active { transform: translateY(0.5px); }
.trial-modal-legal { margin: 0.95rem 0 0; font-size: 0.8rem; color: var(--text-muted); }
.trial-modal-legal a { color: var(--text-2); text-decoration: none; font-weight: 600; }
.trial-modal-legal a:hover { color: var(--text); text-decoration: underline; }

/* Enlace legal tenue al final de la pantalla de selección */
.picker-footer {
  margin-top: 1.75rem;
  padding: 1.25rem 0 calc(1.25rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  border-top: 1px solid var(--hairline);
}
.legal-link {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--trans);
}
.legal-link:hover { color: var(--text-2); text-decoration: underline; }

/* Develop / En desarrollo modal */
.develop-modal-card { text-align: center; }
.develop-modal-icon { font-size: 2.4rem; margin-bottom: 0.6rem; line-height: 1; }
.develop-modal-card .trial-modal-actions { justify-content: center; }
.develop-modal-credit { margin-top: 1.1rem; font-size: 0.8rem; opacity: 0.35; text-align: center; letter-spacing: 0.03em; }


/* Próximamente / Coming soon modal */
.comingsoon-modal-card { text-align: center; }
.comingsoon-modal-icon { font-size: 2.4rem; margin-bottom: 0.6rem; line-height: 1; }
.comingsoon-modal-card .trial-modal-actions { justify-content: center; }
.btn--comingsoon { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%) !important; box-shadow: 0 10px 26px rgba(109,40,217,0.35) !important; }
.btn--comingsoon:hover { background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%) !important; }

/* Cinta de estado en la tarjeta de ruta: base compartida + modificador de color. */
.route-card-ribbon {
  position: absolute;
  top: 19px;
  right: -40px;   /* ACC-04: más ancha (120→140) para que quepa "PRÓXIMAMENTE" a 12px; mismo centro */
  width: 140px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-align: center;
  padding: 5px 0;
  transform: rotate(40deg);
  z-index: 6;
  text-transform: uppercase;
  pointer-events: none;
}
.route-card-ribbon--develop {
  background: linear-gradient(90deg, #eab308 0%, #a16207 100%);
  color: #1a0e00;
  box-shadow: 0 2px 12px rgba(234,179,8,0.6);
}
.route-card-ribbon--comingsoon {
  background: linear-gradient(90deg, #7c3aed 0%, #6d28d9 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(109,40,217,0.55);
}

/* Card modifier for coming-soon routes */
.route-btn--comingsoon { opacity: 0.8; }
.route-btn--comingsoon .route-card-accent {
  background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 45%, #6d28d9 100%);
  box-shadow: 0 0 14px rgba(139,92,246,0.45);
}
.route-btn--comingsoon .route-card-badge {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  box-shadow: 0 7px 16px rgba(109,40,217,0.3);
}

.route-btn--comingsoon .route-btn-select {
  background: linear-gradient(90deg, #7c3aed 0%, #6d28d9 100%);
}


.route-btn--comingsoon:hover { box-shadow: 0 18px 34px rgba(109,40,217,0.28); }

/* Card modifier for develop routes */
.route-btn--develop:hover { box-shadow: 0 18px 34px rgba(234,179,8,0.28); }

/* Hide bus float-icon on cards that show a status ribbon */
.route-btn--comingsoon .route-card-float-icon,
.route-btn--develop .route-card-float-icon { display: none; }

.route-card-heading {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
}

.route-card-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fb923c 0%, #f59e0b 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 7px 16px rgba(var(--st-warn-rgb),0.3);
}

.route-card-texts {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.route-btn-name {
  font-size: 1.02rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-btn-sub {
  margin-top: 2px;
  font-size: 0.8rem;
  color: rgba(253,186,116,0.9);
  font-weight: 600;
}

/* Service tag — eyebrow label above the route name */
.route-card-service-tag {
  display: inline-flex;
  align-self: flex-start;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  /* backdrop-filter removed for scroll performance (see .route-card-glass). */
  background: rgba(255,255,255,0.17);
  border: 1px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.88);
  margin-bottom: 9px;
}

.route-btn-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  padding: 0.52rem 1.25rem;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(90deg, #f97316 0%, #f59e0b 100%);
  box-shadow: 0 8px 20px rgba(249,115,22,0.35);
  transition: transform 0.25s ease, filter 0.25s ease;
}

.route-btn:hover .route-btn-select {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

/* Tarjetas con diseño propio (card.type en rutas.json): fondo, borde y botón comunes */
.route-btn--tren,
.route-btn--mitransporte,
.route-btn--alimentadora,
.route-btn--aeropuerto,
.route-btn--vallarta,
.route-btn--plataforma {
  /* Tema oscuro: claro apagado con tinte del color de la línea, para no
     deslumbrar y que los logos (verde, magenta…) conserven contraste. */
  background: #d6dce5;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--route-card-color, #cc213f) 10%, #dfe4ec) 0%,
    color-mix(in srgb, var(--route-card-color, #cc213f) 4%, #c9d0db) 100%);
  border: 2px solid var(--route-card-color, #cc213f);
}
[data-theme="light"] .route-btn--tren,
[data-theme="light"] .route-btn--mitransporte,
[data-theme="light"] .route-btn--alimentadora,
[data-theme="light"] .route-btn--aeropuerto,
[data-theme="light"] .route-btn--vallarta,
[data-theme="light"] .route-btn--plataforma {
  background: #e8e8e8;
}

/* Tarjeta tipo "tren": logo + icono de la línea */
.route-card-tren {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr) auto;
  column-gap: 7%;
  row-gap: 0.75rem;
  padding: 1.4rem 9% 1.15rem;
}
.route-card-tren-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
  pointer-events: none;
}
.route-card-tren-icon {
  grid-column: 2;
  grid-row: 1;
  height: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  pointer-events: none;
  transition: transform 0.5s ease;
}
.route-btn--tren:hover .route-card-tren-icon {
  transform: scale(1.06);
}
.route-card-footer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.route-btn--tren:not(.route-btn--comingsoon) .route-btn-select,
.route-btn--mitransporte:not(.route-btn--comingsoon) .route-btn-select,
.route-btn--alimentadora:not(.route-btn--comingsoon) .route-btn-select,
.route-btn--aeropuerto:not(.route-btn--comingsoon) .route-btn-select,
.route-btn--vallarta:not(.route-btn--comingsoon) .route-btn-select,
.route-btn--plataforma:not(.route-btn--comingsoon) .route-btn-select {
  background: #e8821a;
  box-shadow: none;
}
.route-btn--tren .route-btn-select,
.route-btn--mitransporte .route-btn-select,
.route-btn--alimentadora .route-btn-select,
.route-btn--aeropuerto .route-btn-select,
.route-btn--vallarta .route-btn-select,
.route-btn--plataforma .route-btn-select {
  padding: 0.4rem 1rem;
}
.route-card-dist {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fuente Garet (licenciada): Fat para el código (R01…) y Bold para el nombre.
   Rutas absolutas: este CSS se sirve desde /assets/<versión>/. */
/* Plus Jakarta Sans (OFL, @fontsource-variable 5.2.8): un archivo variable
   con todos los pesos, solo subconjunto latin. Local para no depender de Google. */
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/static/fonts/PlusJakartaSans-latin-wght.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Garet';
  src: url('/static/fonts/Garet-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Garet Fat';
  src: url('/static/fonts/Garet-Fat.woff2') format('woff2');
  font-display: swap;
}

/* Tarjetas de código + nombre | icono + logo (renderCodeCard en grid.js).
   "mitransporte" (R01…): camión + logo Mi Transporte, en rojo.
   "alimentadora" (A01…): tren + logo Línea 4, en naranja.
   "aeropuerto" (T01…): autobús + logo Línea 5, en azul petróleo; nombre en
   dos renglones y distancia junto al botón.
   "vallarta" (T02/T03 PV): igual que aeropuerto, en verde, con logo Mi
   Transporte Puerto Vallarta; el nombre respeta los 
 de rutas.json y en
   móvil puede ocupar tres renglones. */
.route-btn--mitransporte {
  --route-card-color: #dc6376;
  --route-card-code-color: #c8102c;
}
.route-btn--alimentadora {
  --route-card-color: #ea8118;
  --route-card-code-color: #ea8118;
}
.route-btn--aeropuerto {
  --route-card-color: #1f8199;
  --route-card-code-color: #1f8199;
}
.route-btn--vallarta {
  --route-card-color: #329245;
  --route-card-code-color: #329245;
}
.route-card-mt {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr);
  column-gap: 4%;
  padding: 0.8rem 6%;
}
.route-card-mt-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  min-width: 0;
}
.route-card-mt-code {
  font-family: 'Garet Fat', 'Plus Jakarta Sans', sans-serif;
  font-size: 2.4rem;
  line-height: 0.95;
  color: var(--route-card-code-color, #c8102c);
  white-space: nowrap;
}
.route-card-mt-name {
  font-family: 'Garet', 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.3;
  color: #5e6770;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}
.route-card-mt .route-card-footer {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}
.route-card-mt .route-card-dist {
  padding-left: 0.15rem;
}
/* Etiqueta opcional en el mismo renglón, tras el código (card.label, p. ej.
   "A04 ALIMENTADORA"). El código conserva el tamaño de las demás tarjetas; la
   etiqueta toma el espacio que sobra del renglón (que es su propio contenedor),
   así nunca excede el ancho. 2.35em = ancho del código más ancho (A04) en
   Garet Fat; 9.5em = ancho de "ALIMENTADORA" con su espaciado; 0.35rem = gap. POPEYE */
.route-card-mt-codeline {
  --mt-code-size: 2.4rem;
  container-type: inline-size;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  min-width: 0;
}
@media (max-width: 480px) {
  .route-card-mt-codeline { --mt-code-size: 2.1rem; }
}
.route-card-mt-codeline .route-card-mt-code {
  font-size: var(--mt-code-size);
}

.route-card-mt-label {
  font-family: 'Garet Fat', 'Plus Jakarta Sans', sans-serif;
  font-size: min(0.8rem, calc((100cqw - 2.35 * var(--mt-code-size) - 0.35rem) / 9.5));
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--route-card-code-color, #c8102c);
  white-space: nowrap;
  flex-shrink: 0;
}
/* Aeropuerto: nombres largos ("AEROPUERTO CHAPALITA INN") en dos renglones;
   la distancia sube junto al botón para que todo quepa en la altura. */
.route-btn--aeropuerto .route-card-mt-info,
.route-btn--vallarta .route-card-mt-info {
  container-type: inline-size;
}
.route-btn--aeropuerto .route-card-mt-name,
.route-btn--vallarta .route-card-mt-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.route-btn--aeropuerto .route-card-footer,
.route-btn--vallarta .route-card-footer {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.route-btn--aeropuerto .route-card-dist,
.route-btn--vallarta .route-card-dist {
  padding-left: 0;
}
.route-btn--vallarta .route-card-mt-name {
  white-space: pre-line;
}
@media (max-width: 480px) {
  .route-btn--vallarta .route-card-mt-code { font-size: 1.9rem; }
  .route-btn--vallarta .route-card-mt-name {
    font-size: 0.8rem;
    line-height: 1.2;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }
}
/* En tarjetas angostas (móvil) la distancia queda en "A 2.1 km" */
@container (max-width: 180px) {
  .route-card-dist-suffix { display: none; }
}
/* Teléfonos muy angostos: compacta el pie para que "A 2.1 km" no se corte */
@container (max-width: 150px) {
  .route-card-mt-info .route-card-footer { gap: 0.3rem; }
  .route-card-mt-info .route-btn-select { padding-left: 0.75rem; padding-right: 0.75rem; }
}
@media (max-width: 480px) {
  .route-card-mt { padding: 0.7rem 6%; }
  .route-card-mt-info { gap: 0.2rem; }
  .route-card-mt-code { font-size: 2.1rem; }
}
.route-card-mt-divider {
  width: 3px;
  margin: 0.5rem 0;
  border-radius: 2px;
  background: #ea8118;
}
.route-card-mt-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 0;
}
.route-card-mt-icon {
  height: 52px;
  aspect-ratio: 1;
  object-fit: contain;
  pointer-events: none;
  transition: transform 0.5s ease;
}
.route-btn--mitransporte:hover .route-card-mt-icon,
.route-btn--alimentadora:hover .route-card-mt-icon,
.route-btn--aeropuerto:hover .route-card-mt-icon,
.route-btn--vallarta:hover .route-card-mt-icon {
  transform: scale(1.06);
}
.route-card-mt-logo {
  width: 100%;
  max-width: 160px;
  object-fit: contain;
  pointer-events: none;
}

/* Tarjeta tipo "plataforma" (Loop): franja de marca de lado a lado + botón */
.route-btn--plataforma {
  --route-card-color: #ea8118;
}
.route-card-banner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem 5%;
}
.route-card-banner-img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  object-position: left top;
  pointer-events: none;
}

/* Estados de carga / vacío */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 3.5rem 0 2rem;
  color: var(--text-dim);
  font-size: 0.88rem;
}
.loading-dots { display: flex; gap: 6px; }
.loading-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #1e3658;
  animation: dotPulse 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.18s; }
.loading-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dotPulse { 0%,100%{transform:scale(0.6);opacity:0.4} 50%{transform:scale(1);opacity:1} }

.no-results {
  text-align: center;
  padding: 2.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/*
   HUD (tarjeta de ruta activa)
    */
.active-hud {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 800;
  background: var(--chrome-bg);
  backdrop-filter: blur(40px) saturate(200%) brightness(0.95);
  -webkit-backdrop-filter: blur(40px) saturate(200%) brightness(0.95);
  border-top: 1px solid rgba(255,255,255,0.13);
  border-radius: 24px 24px 0 0;
  padding: 0 0 calc(env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: 0 -12px 48px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(0);
  transition: transform var(--trans-slow), background 0.35s ease;
  overflow: hidden;
}
.active-hud.hidden {
  transform: translateY(110%);
  pointer-events: none;
}

/* Cabecera del HUD */
.hud-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.2rem 0.9rem;
  border-bottom: 1px solid var(--hairline);
}
.hud-route-badge {
  width: 46px; height: 46px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  border: 1.5px solid rgba(255,107,43,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  overflow: hidden;
  transition: background 0.3s ease;
}
.hud-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hud-eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);   /* ACC-03: sin opacity, 4.6:1 sobre el chrome */
}
.hud-route-name {
  font-size: 1.0rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-conn { flex-shrink: 0; }

/* Aviso de paro de línea (integración con despacho) */
.line-stop-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.7rem 1.2rem 0;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  border: 1.5px solid var(--danger);
  animation: lineStopPulse 2s ease-in-out infinite;
}
.line-stop-banner.hidden { display: none; }
.line-stop-icon { font-size: 1.1rem; line-height: 1.2; flex-shrink: 0; }
.line-stop-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.line-stop-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--danger);
}
.line-stop-message {
  font-size: 0.82rem;
  font-weight: 500;
  color: #f0f6ff;
  line-height: 1.35;
}
@keyframes lineStopPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.35); }
  50%      { box-shadow: 0 0 0 5px rgba(248,113,113,0); }
}

/* Alarma de emergencia (badge superior derecho, paro de línea activo) */
.hud-line-stop-alarm {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 1;
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hud-line-stop-alarm.hidden { display: none; }
.hud-line-stop-alarm-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--danger);
  animation: lineStopAlarmRing 1.1s ease-out infinite;
}
.hud-line-stop-alarm-icon {
  position: relative;
  font-size: 1.15rem;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.45));
  animation: lineStopAlarmBlink 1.1s ease-in-out infinite;
}
@keyframes lineStopAlarmRing {
  0%   { box-shadow: 0 0 0 0 rgba(248,113,113,0.55); opacity: 1; }
  100% { box-shadow: 0 0 0 12px rgba(248,113,113,0); opacity: 0; }
}
@keyframes lineStopAlarmBlink {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

/* Chips de stats */
.hud-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--hairline);
}
.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0.75rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  border: none;
  border-right: 1px solid var(--hairline);
  background: transparent;
  color: var(--text-2);
  transition: background 0.2s ease;
}
.stat-chip:last-child { border-right: none; }
.stat-chip--total { background: transparent; }
.stat-chip--moving {
  background: rgba(var(--st-moving-rgb),0.06);
  color: var(--success);
}
.stat-chip--time {
  background: transparent;
  color: rgba(255,255,255,0.75);
}
.chip-icon { font-size: 0.82rem; opacity: 0.7; }
.chip-val  { font-size: 1.05rem; font-weight: 800; color: #fff; line-height: 1.1; }
.chip-val--sm { font-size: 0.8rem; font-weight: 600; color: rgba(255,255,255,0.8); line-height: 1.3; text-align: center; }
/* ACC-03: sin opacity (bajaba a 3.6–4.1:1); hereda el color del chip. */
.chip-lbl  { font-size: 0.8rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

/* ACC-09: el chip de unidades es el botón que abre la lista en texto. */
.stat-chip--button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: background var(--trans);
}
.stat-chip--button:hover { background: var(--fill-1); }
.stat-chip--button:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }
.chip-action {
  margin-top: 2px;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Acciones */
.hud-actions {
  display: flex;
  gap: 0.6rem;
  padding: 0.85rem 1.2rem calc(0.85rem + env(safe-area-inset-bottom));
}
.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.72rem 1rem;
  transition: all var(--trans);
  white-space: nowrap;
}
.hud-btn--secondary {
  background: var(--hairline);
  border: 1.5px solid var(--hairline-2);
  color: rgba(255,255,255,0.8);
  min-width: 110px;
}
.hud-btn--secondary:hover {
  background: var(--hairline-2);
  border-color: rgba(255,255,255,0.22);
  color: #fff;
}
.hud-btn--primary {
  flex: 1;
  background: var(--accent-dark);   /* ACC-03: blanco sobre --accent no llega a 4.5:1 */
  color: #fff;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.hud-btn--primary:hover {
  background: #b5322b;   /* oscurecer: brightness(1.1) bajaba el contraste a 4.4:1 */
  box-shadow: 0 6px 24px var(--accent-glow);
  transform: translateY(-1px);
}
.hud-btn--primary:active { transform: translateY(0); filter: brightness(0.95); }

/* 
   TOAST
    */
.toast {
  position: fixed;
  bottom: calc(180px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-lg);
  padding: 0.7rem 1.3rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  max-width: min(88vw, 400px);
  z-index: 900;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-align: center;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.4;
}
.toast--hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}
.toast--error { border-color: var(--danger); color: var(--danger); }
.toast--info  { border-color: rgba(59,130,246,0.3); }

/* 
   DRAWER (detalle de unidad)
    */
.drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-height: 65vh;
  background: var(--chrome-bg);
  backdrop-filter: blur(36px) saturate(180%) brightness(0.96);
  -webkit-backdrop-filter: blur(36px) saturate(180%) brightness(0.96);
  border-top: 1px solid rgba(255,255,255,0.13);
  border-radius: 24px 24px 0 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -12px 48px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(0);
  transition: transform var(--trans-slow);
  overflow: hidden;
}
.drawer--hidden { transform: translateY(100%); }
/* ACC-02: el drawer recibe el foco al abrir (para que el lector anuncie su
   título); el contorno sería un marco sobre todo el panel. Tab pasa a sus botones. */
.drawer:focus { outline: none; }

.drawer-grip {
  width: 40px; height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 4px;
  margin: 0.75rem auto 0;
  flex-shrink: 0;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem 0.8rem;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.drawer-header-info {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.drawer-bus-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: var(--hairline);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.drawer-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--hairline);
  border: 1px solid var(--hairline-2);
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--trans);
}
.drawer-close:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.24);
  color: #fff;
}

.drawer-body {
  overflow-y: auto;
  padding: 1rem 1.25rem 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ── LISTA DE UNIDADES (ACC-09) ── mismo "chrome" oscuro que la ficha.
   Más baja que la ficha para dejar ver las unidades en el mapa. */
.unit-list-drawer { max-height: 45vh; max-height: 45dvh; }
.unit-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem 0.2rem;
  flex-shrink: 0;
}
.unit-list-note {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: rgba(255,255,255,0.78);
}
.unit-list-locate {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: var(--hairline);
  border: 1.5px solid var(--hairline-2);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.unit-list-locate.hidden { display: none; }
.unit-list-locate:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.unit-list {
  list-style: none;
  margin: 0;
  padding: 0.6rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.unit-list-item {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 0.75rem;
  align-items: baseline;
  padding: 0.7rem 0.9rem;
  font-family: inherit;
  text-align: left;
  color: #fff;
  background: var(--fill-1);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--trans), border-color var(--trans);
}
.unit-list-item:hover { background: var(--hairline-2); border-color: rgba(255,255,255,0.18); }
.unit-list-item:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.unit-list-name { font-size: 0.95rem; font-weight: 700; }
.unit-list-dist { font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.unit-list-status {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.78);
}
.unit-list-status::first-letter { text-transform: uppercase; }
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--fill-1);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  transition: background 0.2s ease;
}
.detail-item:hover {
  background: rgba(255,255,255,0.08);
}
.detail-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: rgba(255,255,255,0.6);   /* ACC-03: 0.38 daba ≈3.4:1 */
}
.detail-value {
  font-size: 0.97rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}
.detail-item.full { grid-column: 1 / -1; }

/*
   DRAWER ESTACIÓN — layout vertical, temático por color de línea
    */
/* Badge del encabezado: relleno con el color de la línea + icono blanco. */
.station-drawer .drawer-bus-icon {
  width: 44px; height: 44px;
  background: linear-gradient(150deg, var(--station-c, #2a6df0), rgba(0,0,0,0.32));
  border: 1px solid var(--station-mid, rgba(255,255,255,0.18));
  box-shadow: 0 8px 20px -6px var(--station-c, rgba(0,0,0,0.4)),
              inset 0 1px 0 rgba(255,255,255,0.28);
  overflow: hidden;
}
.station-drawer .st-hero-icon {
  width: 26px; height: 26px;
  display: block;
  object-fit: contain;
}

/* Cuerpo: una sola columna apilada (más vertical), sin la rejilla del de unidad. */
.station-drawer .drawer-body {
  display: flex;
  flex-direction: column;
}
.st-detail {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Banner de línea: franja a color con su nombre. */
.st-line-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--station-soft, var(--fill-1));
  border: 1px solid var(--station-mid, rgba(255,255,255,0.1));
  border-left: 3px solid var(--station-c, rgba(255,255,255,0.3));
}
.st-line-dot {
  width: 12px; height: 12px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--station-c, #fff);
  box-shadow: 0 0 0 4px var(--station-soft, var(--hairline-2));
}
.st-line-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.st-line-eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: rgba(255,255,255,0.6);   /* ACC-03: 0.4 daba ≈3.6:1 */
}
.st-line-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Filas de dato: icono + etiqueta/valor, alineadas verticalmente. */
.st-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  background: var(--fill-1);
  border: 1px solid rgba(255,255,255,0.08);
  transition: background var(--trans), border-color var(--trans);
}
.st-row:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--station-mid, rgba(255,255,255,0.16));
}
.st-row--col {
  flex-direction: column;
  align-items: stretch;
  gap: 0.7rem;
}
.st-row-ico {
  width: 36px; height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--station-soft, rgba(255,255,255,0.06));
  color: var(--station-c, rgba(255,255,255,0.7));
}
.st-row-head { display: flex; align-items: center; gap: 0.7rem; }
.st-row-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.st-row-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: rgba(255,255,255,0.6);   /* ACC-03: 0.4 daba ≈3.6:1 */
}
.st-row-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

/* Insignia de accesibilidad. */
.st-badge {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  line-height: 1;
}
.st-badge--ok  { background: rgba(var(--st-moving-rgb),0.14); border: 1px solid rgba(var(--st-moving-rgb),0.3); color: #6ee7b7; }
.st-badge--off { background: rgba(255,255,255,0.06); border: 1px solid var(--hairline-2); color: rgba(255,255,255,0.5); }

/* Chips de transbordo. */
.st-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.st-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--station-soft, rgba(255,255,255,0.06));
  border: 1px solid var(--station-mid, var(--hairline-2));
}
.st-chip b {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--station-c, #fff);
}
.st-chip--empty {
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}

/* Entrada escalonada: solo transform/opacity (compositor GPU, sin reflow). */
@keyframes stRise {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
.station-drawer:not(.drawer--hidden) .st-detail > * {
  animation: stRise 0.42s cubic-bezier(0.22,1,0.36,1) both;
}
.station-drawer:not(.drawer--hidden) .st-detail > *:nth-child(1) { animation-delay: 0.04s; }
.station-drawer:not(.drawer--hidden) .st-detail > *:nth-child(2) { animation-delay: 0.10s; }
.station-drawer:not(.drawer--hidden) .st-detail > *:nth-child(3) { animation-delay: 0.16s; }
.station-drawer:not(.drawer--hidden) .st-detail > *:nth-child(4) { animation-delay: 0.22s; }
@media (prefers-reduced-motion: reduce) {
  .station-drawer:not(.drawer--hidden) .st-detail > * { animation: none; }
}

/* ── Unit status banner ── */
.unit-status-banner {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  transition: background 0.4s ease, border-color 0.4s ease;
}
.unit-status-banner--moving  { background: rgba(var(--st-moving-rgb),0.1);  border: 1px solid rgba(var(--st-moving-rgb),0.25); }
.unit-status-banner--stopped { background: rgba(var(--st-stopped-rgb),0.1);  border: 1px solid rgba(var(--st-stopped-rgb),0.25); }
.unit-status-banner--warn    { background: rgba(var(--st-warn-rgb),0.1);  border: 1px solid rgba(var(--st-warn-rgb),0.25); }
.unit-status-banner--stale   { background: rgba(var(--st-stale-rgb),0.1);   border: 1px solid rgba(var(--st-stale-rgb),0.25); }
.usb-pulse {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}
.unit-status-banner--moving  .usb-pulse { background: #34d399; box-shadow: 0 0 8px rgba(var(--st-moving-rgb),0.6);  animation: usb-moving  1.8s ease-in-out infinite; }
.unit-status-banner--stopped .usb-pulse { background: #818cf8; box-shadow: 0 0 6px rgba(var(--st-stopped-rgb),0.5); }
.unit-status-banner--warn    .usb-pulse { background: #f59e0b; box-shadow: 0 0 6px rgba(var(--st-warn-rgb),0.5);  animation: usb-warn    2.4s ease-in-out infinite; }
.unit-status-banner--stale   .usb-pulse { background: #ef4444; box-shadow: 0 0 8px rgba(var(--st-stale-rgb),0.6);   animation: usb-stale   1.1s ease-in-out infinite; }
@keyframes usb-moving { 0%,100%{transform:scale(1);opacity:1}  50%{transform:scale(1.5);opacity:0.6} }
@keyframes usb-warn   { 0%,100%{transform:scale(1);opacity:.8} 50%{transform:scale(1.35);opacity:0.5} }
@keyframes usb-stale  { 0%,100%{opacity:1}                     50%{opacity:0.25} }
.usb-content  { display:flex; flex-direction:column; gap:2px; flex:1; }
.usb-label    { font-size:0.9rem; font-weight:700; line-height:1.2; }
.unit-status-banner--moving  .usb-label { color: #6ee7b7; }
.unit-status-banner--stopped .usb-label { color: #a5b4fc; }
.unit-status-banner--warn    .usb-label { color: #fcd34d; }
.unit-status-banner--stale   .usb-label { color: #fca5a5; }
.usb-speed    { font-size:0.8rem; font-weight:600; color:rgba(255,255,255,0.5); }

/* ── GPS detail ── */
.gps-detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.gps-age-chip {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.gps-age-chip--moving  { background:rgba(var(--st-moving-rgb),0.15);  color:#34d399; border:1px solid rgba(var(--st-moving-rgb),0.3); }
.gps-age-chip--stopped { background:rgba(var(--st-stopped-rgb),0.15);  color:#818cf8; border:1px solid rgba(var(--st-stopped-rgb),0.3); }
.gps-age-chip--warn    { background:rgba(var(--st-warn-rgb),0.15);  color:#f59e0b; border:1px solid rgba(var(--st-warn-rgb),0.3); }
.gps-age-chip--stale   { background:rgba(var(--st-stale-rgb),0.15);   color:#ef4444; border:1px solid rgba(var(--st-stale-rgb),0.3);  }

/* 
   RESPONSIVE
    */

/* ── Móvil & tablet (< 1024px): picker como hoja inferior, mapa visible detrás ── */
@media (max-width: 1023px) {
  .route-picker {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 42vh;
    min-height: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -6px 40px rgba(0,0,0,0.42);
    overflow: hidden;
  }
  .route-picker.hiding {
    opacity: 1;
    transform: translateY(110%);
    transition: transform 0.35s cubic-bezier(0.32,0.72,0,1) !important;
  }
  /* Manija de arrastre (ACC-07: <button>, área táctil 64×24 alrededor de la barra) */
  .sheet-handle {
    display: block;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 64px; height: 24px;
    padding: 0;
    border: none;
    border-radius: 0 0 10px 10px;
    background: transparent;
    cursor: inherit;
    z-index: 1;
  }
  .sheet-handle::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 12px;
    width: 40px; height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.35);
  }
  .sheet-handle:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
  /* Header compacto sin offset del topbar */
  .picker-header {
    padding: 1.5rem 1.4rem 1.8rem;
    border-radius: 22px 22px 0 0;
    cursor: grab;
  }
  .picker-header:active { cursor: grabbing; }
  /* Cuando la hoja está en peek, ocultar body para evitar scroll indeseado */
  .route-picker.sheet--peek .picker-body { opacity: 0; pointer-events: none; }
}

@media (max-width: 480px) {
  :root { --topbar-h: 56px; }
  .picker-header { padding: 1.3rem 1.2rem 1.6rem; }
  .picker-header-title { font-size: 1.55rem; }
  .picker-body  { padding: 1.2rem 1rem 0.5rem; }
  .route-btn { height: 132px; border-radius: 22px; }
  .route-card-content { padding: 1rem 1rem 1rem 1.05rem; }
  .route-card-badge { width: 38px; height: 38px; border-radius: 10px; font-size: 0.8rem; }
  .route-btn-name { font-size: 0.92rem; }
  .route-btn-sub { font-size: 0.8rem; }
  .route-btn-select { font-size: 0.8rem; padding: 0.46rem 1rem; }
  .active-hud   { gap: 0; }
  .hud-header   { padding: 0.85rem 1rem 0.75rem; }
  .hud-actions  { padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom)); }
  .chip-val     { font-size: 0.95rem; }
  .hud-btn--secondary { min-width: 90px; font-size: 0.82rem; }
  .drawer-body  { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .topbar-status .status-label { display: none; }
}

@media (min-width: 640px) and (max-width: 1023px) {
  .active-hud {
    left: 50%;
    right: auto;
    width: min(500px, 96vw);
    transform: translateX(-50%);
    bottom: 3.5rem;
    border-radius: var(--radius-2xl);
    border: 1px solid rgba(255,255,255,0.13);
  }
  .active-hud.hidden { transform: translateX(-50%) translateY(200%); }
  .drawer {
    left: 50%;
    right: auto;
    width: min(440px, 96vw);
    transform: translateX(-50%);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }
  .drawer--hidden { transform: translateX(-50%) translateY(100%); }
  /* La lista mide lo mismo que la tarjeta de la ruta activa. */
  .unit-list-drawer { width: min(500px, 96vw); }
  .toast { bottom: 12rem; }
}

/* ══════════════════════════════════════════════════════
   DESKTOP  ≥ 1024px — Sidebar izquierdo + mapa derecho
══════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  :root {
    --topbar-h:  68px;
    --sidebar-w: 400px;
  }

  /* Topbar más espacioso */
  .topbar { padding: 0 2rem 0 1.5rem; }
  .brand-text { font-size: 1.15rem; letter-spacing: -0.4px; }

  /* Mapa desplazado al costado del sidebar */
  #map { left: var(--sidebar-w); }

  /* Spinner solo sobre el área de mapa */
  .map-spinner { left: var(--sidebar-w); }

  /* ─ Route Picker: panel izquierdo fijo ─ */
  .route-picker {
    width: var(--sidebar-w);
    right: auto;
    bottom: auto;
    height: 100dvh;
    border-radius: 0;
    border-right: 1px solid var(--border-med);
    box-shadow: 2px 0 24px rgba(0,0,0,0.22);
    cursor: default;
  }
  .route-picker.hiding {
    opacity: 0;
    transform: translateX(-24px);
  }
  /* Ocultar handle de arrastre en desktop */
  .sheet-handle { display: none; }
  .picker-header {
    padding: calc(var(--topbar-h) + 1.6rem) 1.6rem 2.5rem;
    border-radius: 0;
    cursor: default;
  }
  .picker-header:active { cursor: default; }
  /* Asegurarse de que el body sea siempre visible en desktop */
  .route-picker.sheet--peek .picker-body { opacity: 1; pointer-events: auto; }
  .picker-body        { padding: 1.4rem 1.4rem 1rem; }
  .section-label      { font-size: 0.85rem; }

  /* ─ Active HUD: sidebar completo izquierdo ─ */
  .active-hud {
    left: 0;
    right: auto;
    width: var(--sidebar-w);
    top: var(--topbar-h);
    bottom: 0;
    border-top: none;
    border-right: 1px solid rgba(255,255,255,0.08);
    border-radius: 0;
    padding: 0;
    flex-direction: column;
    gap: 0;
    justify-content: flex-start;
    transform: none;
    overflow-y: auto;
    box-shadow: 2px 0 32px rgba(0,0,0,0.28);
  }
  .active-hud.hidden {
    transform: translateX(-110%);
    pointer-events: none;
  }
  .hud-header {
    padding: 1.6rem 1.6rem 1.2rem;
    border-bottom: 1px solid var(--hairline);
  }
  .hud-route-badge {
    width: 60px; height: 60px;
    font-size: 1.7rem;
    border-radius: var(--radius-lg);
  }
  .hud-route-name { font-size: 1.2rem; }
  .hud-eyebrow    { font-size: 0.8rem; }
  .hud-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--hairline);
  }
  .stat-chip      { padding: 1.1rem 0.5rem; font-size: 0.88rem; }
  .chip-val       { font-size: 1.2rem; }
  .hud-actions {
    margin-top: auto;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.4rem 1.6rem;
  }
  .hud-btn {
    width: 100%;
    padding: 0.9rem 1.25rem;
    font-size: 0.95rem;
    justify-content: center;
  }
  .hud-btn--secondary { min-width: unset; }

  /* ─ Drawer: sobre el área de mapa ─ */
  .drawer {
    left: var(--sidebar-w);
    right: 0;
    width: auto;
    max-height: 52vh;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    transform: translateY(0);
  }
  .drawer--hidden { transform: translateY(100%); }
  /* La lista ocupa el ancho del sidebar de la ruta activa, sin tapar el mapa. */
  .unit-list-drawer {
    left: 0;
    right: auto;
    width: var(--sidebar-w);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }

  /* ─ Toast: centrado en el área de mapa ─ */
  .toast {
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2);
    bottom: 2.5rem;
    transform: translateX(-50%);
  }
  .toast--hidden {
    transform: translateX(-50%) translateY(8px);
  }

  /* Legend smaller offset on desktop where HUD is sidebar */
  .semaphore-legend { margin-bottom: 20px; }
}

@media (min-width: 1280px) {
  :root { --sidebar-w: 440px; }
}

/* ══════════════════════════════════════════════════════
   BOTÓN MI UBICACIÓN
══════════════════════════════════════════════════════ */
.locate-btn {
  position: fixed;
  z-index: 500;
  /* Se coloca debajo del control de zoom de Leaflet (topright) */
  top: calc(var(--topbar-h) + 96px);
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border-med);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,0.36);
  transition: color var(--trans), background var(--trans), box-shadow var(--trans);
}
.locate-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.locate-btn:active { opacity: 0.8; }

.locate-btn--active {
  color: #3b82f6;
  border-color: rgba(59,130,246,0.45);
  box-shadow: 0 1px 5px rgba(0,0,0,0.36), 0 0 0 2px rgba(59,130,246,0.18);
}

/* Spinner mientras carga el GPS */
.locate-btn--loading svg {
  animation: spin 1s linear infinite;
  opacity: 0.5;
}

@media (min-width: 1024px) {
  .locate-btn { top: calc(var(--topbar-h) + 106px); right: 10px; }
}

/* ══════════════════════════════════════════════════════
   MARCADOR DE UBICACIÓN DEL USUARIO
══════════════════════════════════════════════════════ */
.user-location-dot {
  width: 24px;
  height: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-location-pulse {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(59,130,246,0.22);
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  animation: user-pulse 2s ease-out infinite;
  pointer-events: none;
}
.user-location-core {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.6);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
@keyframes user-pulse {
  0%   { transform: translate(-50%,-50%) scale(0.4); opacity: 0.8; }
  70%  { transform: translate(-50%,-50%) scale(1.4); opacity: 0;   }
  100% { transform: translate(-50%,-50%) scale(1.4); opacity: 0;   }
}

/* ══════════════════════════════════════════════════════
            ESTACIONES DE LÍNEAS DE TREN 
══════════════════════════════════════════════════════ */

/* Marcador de estación (S2/S5/S6). --c = color de la línea, inyectado inline. */
.station-marker {
  position: relative;
  width: clamp(38px, 8vw, 38px);          /* S6: responsivo — 122% del tamaño base */
  height: clamp(38px, 8vw, 38px);
  display: flex; align-items: center; justify-content: center;
}
.station-marker .station-core {
  width: 100%; height: 100%; border-radius: 7px;  /* cuadrado redondeado → distingue de las unidades (círculos) */
  /* Superficie gris-blanco adaptable al tema (no el color de la línea, que pasa por
     encima). Doble capa de degradado: la 1ª (padding-box) rellena el cuadrado, la 2ª
     (border-box) pinta el borde — así fondo y contorno comparten el degradado. */
  background:
    var(--station-fill) padding-box,
    var(--station-edge) border-box;
  color: var(--station-glyph);             /* el SVG de respaldo usa currentColor */
  border: 2px solid transparent;           /* el degradado border-box pinta el borde */
  display: flex; align-items: center; justify-content: center;
  /* Glow tipo "blur" compuesto en GPU (box-shadow, sin filter: blur por frame). */
  box-shadow: 0 0 7px 0 var(--station-glow), 0 3px 9px rgba(0,0,0,0.45);
  position: relative; z-index: 1;
  transition: transform .2s cubic-bezier(.2,.9,.2,1),
              width .2s ease, height .2s ease, border-width .2s ease,
              box-shadow .2s ease, background .2s ease;
}
/* Zoom máximo del mapa: relleno y glow opacos → diferenciación nítida. */
.leaflet-container.stations-max .station-marker .station-core {
  background:
    var(--station-fill-max) padding-box,
    var(--station-edge) border-box;
  box-shadow: 0 0 10px 1px var(--station-glow), 0 3px 9px rgba(0,0,0,0.5);
}
/* SVG propio de la estación: silueta blanca centrada dentro del núcleo.
   ~68% para que la figura quede holgada dentro del círculo. object-fit:contain
   preserva la proporción de cada icono recortado. */
.station-marker .station-icon {
  width: 68%; height: 68%;
  object-fit: contain;
  pointer-events: none;
  user-select: none; -webkit-user-drag: none;
  /* El SVG es una silueta blanca; sobre el relleno gris-blanco se oscurece a un gris
     translúcido (brightness(0) → negro, opacity → gris) para que se lea en ambos temas. */
  filter: brightness(0) opacity(0.62);
  transition: opacity .15s ease;
  /* BUG-07: borde sutil para que el glifo blanco conserve contraste sobre el
     relleno translúcido (sobre todo en tema claro), sin tocar la translucidez. */
  filter: drop-shadow(0 1px 1.5px rgba(0,0,0,0.5));
}
/* Mismo refuerzo para el glifo de respaldo (SVG inline, sin clase .station-icon). */
.station-marker .station-core > svg { filter: drop-shadow(0 1px 1.5px rgba(0,0,0,0.5)); }

/* Vista alejada (zoom < STATION_DETAIL_ZOOM): la estación se colapsa a un punto
   pequeño para no tapar las unidades. El contenedor de 37px se conserva (área de
   toque cómoda); solo encoge el núcleo y se oculta la figura. */
.leaflet-container.stations-far .station-marker .station-core {
  width: 12px; height: 12px;
  border-width: 1.5px;
  box-shadow: 0 0 5px 1px var(--station-glow), 0 1px 3px rgba(0,0,0,0.5);
}
.leaflet-container.stations-far .station-marker .station-icon { opacity: 0; }
/* Sin etiqueta "Más cercana" ni realce de escala en vista de línea completa. */
.leaflet-container.stations-far .station-marker--nearest .station-core { transform: none; }
.leaflet-container.stations-far .station-marker--nearest::after { display: none; }
.station-marker:hover .station-core,
.station-marker:focus-visible .station-core { transform: scale(1.12); }
.station-marker:focus-visible {              /* S9: foco visible por teclado */
  outline: 3px solid rgba(100,116,139,0.9);
  outline-offset: 3px; border-radius: 50%;
}

/* Ondas concéntricas de llegada (S7): 3 anillos escalonados (scale + opacity + border).
   En reposo opacity:0 y sin animación → coste cero hasta que pasa una unidad. */
.station-ripple {
  position: absolute; left: 50%; top: 50%;
  width: 100%; height: 100%; border-radius: 50%;
  border: 3px solid var(--station-ripple);
  box-sizing: border-box;
  transform: translate(-50%, -50%) scale(1);
  opacity: 0; pointer-events: none; z-index: 0;
}
.station-marker--arriving .station-ripple {
  will-change: transform, opacity;             /* promoción solo durante el burst */
  animation: station-ripple 1.5s ease-out 1;
}
.station-marker--arriving .station-ripple--2 { animation-delay: .4s; }
.station-marker--arriving .station-ripple--3 { animation-delay: .8s; }
@keyframes station-ripple {
  0%   { transform: translate(-50%,-50%) scale(1);   opacity: .8; }
  100% { transform: translate(-50%,-50%) scale(2.6); opacity: 0;  }
}

/* Estación más cercana al usuario (S8). */
.station-marker--nearest .station-core {
  box-shadow: 0 0 0 4px rgba(251,191,36,0.5), 0 0 12px 2px var(--station-glow), 0 4px 12px rgba(0,0,0,0.5);
  transform: scale(1.12);
}
.station-marker--nearest::after {       /* etiqueta sutil "más cercana" */
  content: "Más cercana";
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: 12px; font-weight: 700; color: var(--accent-2, #fbbf24);
  white-space: nowrap; text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Objetivo de toque cómodo en móvil (S6). */
@media (max-width: 640px) {
  .station-marker { width: 41px; height: 41px; }
}

/* prefers-reduced-motion: señal de llegada sin movimiento (§10). */
@media (prefers-reduced-motion: reduce) {
  .station-marker--arriving .station-ripple { animation: none; }
  /* Señal de llegada alternativa sin movimiento. */
  .station-marker--arriving .station-core {
    box-shadow: 0 0 0 5px var(--station-glow), 0 3px 9px rgba(0,0,0,0.5);
  }
}

/* Líneas de rutas — cursor pointer para indicar que son clicables */
.leaflet-overlay-pane path {
  cursor: pointer;
}
