:root {
  --azul: #1a73e8;
  --azul-osc: #0b57d0;
  --azul-claro: #e8f0fe;
  --texto: #1f1f1f;
  --gris: #5f6368;
  --gris-claro: #f1f3f4;
  --borde: #e0e3e7;
  --fondo: #ffffff;
  --verde: #188038;
  --verde-nav: #0d652d;
  --naranja: #e8710a;
  --rojo: #d93025;
  --sombra: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
  --sombra-suave: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --arriba: env(safe-area-inset-top, 0px);
  --abajo: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fondo); color: var(--texto);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; }
[hidden] { display: none !important; }
svg { display: block; }

#mapa { position: fixed; inset: 0; }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: var(--hoja-alto, 0px); transition: bottom .25s; }
.maplibregl-ctrl-attrib.maplibregl-compact { margin: 0 8px 8px; }

/* ---------- barra de búsqueda ---------- */
.barra { position: fixed; top: calc(var(--arriba) + 10px); left: 12px; right: 12px; display: flex; gap: 8px; z-index: 5; }
.pill { flex: 1; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-radius: 24px;
  background: var(--fondo); box-shadow: var(--sombra); color: var(--gris); text-align: left; min-width: 0; }
.pill span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pill .marca { width: 26px; height: 26px; flex: none; }
.redondo { width: 48px; height: 48px; border-radius: 50%; background: var(--fondo); box-shadow: var(--sombra);
  display: grid; place-items: center; color: var(--gris); flex: none; }
.redondo.chico { width: 40px; height: 40px; }
.redondo.activo { color: var(--azul); }

/* ---------- botones flotantes ---------- */
.flotantes { position: fixed; right: 12px; bottom: calc(var(--hoja-alto, 0px) + 14px); display: flex; flex-direction: column;
  gap: 12px; z-index: 4; transition: bottom .25s; }
.flotantes .redondo { width: 52px; height: 52px; }
#btn-brujula svg { transition: transform .2s; }
.boton-3d { font-weight: 700; font-size: 15px; color: var(--texto) !important; letter-spacing: .02em; }

/* ---------- hoja inferior ---------- */
.hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--fondo); border-radius: 18px 18px 0 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,.12); height: var(--hoja-alto, 0px); transition: height .25s;
  display: flex; flex-direction: column; padding-bottom: var(--abajo); max-width: 640px; margin: 0 auto; }
.hoja.arrastrando { transition: none; }
.asa { flex: none; height: 22px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.asa::before { content: ""; width: 36px; height: 4px; border-radius: 2px; background: #dadce0; }
.hoja-cont { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 12px; }

.lugar-titulo { font-size: 22px; font-weight: 500; margin: 2px 0 2px; }
.lugar-detalle { color: var(--gris); margin-bottom: 14px; }
.fila-botones { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.fila-botones::-webkit-scrollbar { display: none; }
.boton { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 20px;
  font-weight: 500; white-space: nowrap; flex: none; }
.boton.primario { background: var(--azul); color: #fff; }
.boton.primario:active { background: var(--azul-osc); }
.boton.secundario { border: 1px solid var(--borde); color: var(--azul); background: var(--fondo); }
.boton.grande { height: 48px; padding: 0 26px; font-size: 16px; border-radius: 24px; }
.boton svg { width: 20px; height: 20px; }

/* ---------- tarjeta desde/hasta ---------- */
.tarjeta-ruta { position: fixed; top: 0; left: 0; right: 0; z-index: 5; background: var(--fondo); box-shadow: var(--sombra-suave);
  padding: calc(var(--arriba) + 8px) 8px 10px 4px; display: grid; grid-template-columns: 44px 18px 1fr 44px; align-items: center; column-gap: 6px; row-gap: 8px; }
.tarjeta-ruta .volver { grid-row: 1; grid-column: 1; }
.tarjeta-ruta .puntos { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.puntos i { display: block; width: 3px; height: 3px; border-radius: 50%; background: #9aa0a6; }
.punto-origen { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--azul); }
.punto-destino { width: 12px; height: 16px; color: var(--rojo); }
.campo { height: 40px; border-radius: 8px; border: 1px solid var(--borde); padding: 0 12px; display: flex; align-items: center;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; width: 100%; background: var(--fondo); }
.campo.mi-ubicacion { color: var(--azul); }
.tarjeta-ruta .intercambiar { grid-row: 1 / span 2; grid-column: 4; }
.tarjeta-ruta .chips { grid-column: 1 / -1; display: flex; gap: 8px; padding: 0 8px 0 12px; overflow-x: auto; scrollbar-width: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 16px;
  border: 1px solid var(--borde); font-size: 14px; white-space: nowrap; color: var(--texto); background: var(--fondo); flex: none; }
.chip.on { background: var(--azul-claro); border-color: var(--azul-claro); color: var(--azul-osc); }
.chip svg { width: 16px; height: 16px; }

/* ---------- opciones de ruta ---------- */
.resumen { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; }
.resumen .tiempo { font-size: 24px; font-weight: 500; color: var(--verde); }
.resumen .tiempo.demora { color: var(--naranja); }
.resumen .dist { color: var(--gris); font-size: 17px; }
.comparacion { color: var(--gris); font-size: 14px; margin-bottom: 12px; }
.comparacion b { color: var(--texto); font-weight: 500; }
.opcion { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 12px; border-radius: 12px; margin: 0 -4px 6px;
  border: 1px solid var(--borde); text-align: left; width: calc(100% + 8px); }
.opcion.sel { border-color: var(--azul); background: #f8fbff; box-shadow: inset 0 0 0 1px var(--azul); }
.opcion .t { font-size: 18px; font-weight: 500; }
.opcion .t.ok { color: var(--verde); } .opcion .t.demora { color: var(--naranja); }
.opcion .km { color: var(--gris); text-align: right; align-self: center; }
.opcion .det { grid-column: 1 / -1; color: var(--gris); font-size: 13.5px; }
.etq { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 10px; margin-left: 6px; vertical-align: 2px; }
.etq-rec { background: #e6f4ea; color: var(--verde); }
.etq-rap { background: #fef7e0; color: #b06000; }
.etq-men { background: var(--azul-claro); color: var(--azul-osc); }
.av-cero { color: var(--verde); font-weight: 500; }
.nota { font-size: 12.5px; color: var(--gris); margin: 10px 0 4px; }
.nota a { color: var(--azul); }
.acciones { display: flex; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; }

/* ---------- pasos ---------- */
.pasos { list-style: none; margin: 8px 0 0; padding: 0; }
.pasos li { display: grid; grid-template-columns: 36px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--gris-claro); }
.pasos li .ic { width: 28px; height: 28px; color: var(--gris); }
.pasos li .d { color: var(--gris); font-size: 13px; }
.pasos li.av .txt::after { content: "avenida"; font-size: 11px; font-weight: 500; color: #b06000; background: #fef7e0; border-radius: 8px; padding: 1px 6px; margin-left: 6px; }

/* ---------- marcadores y burbujas ---------- */
.pin { width: 30px; height: 40px; color: var(--rojo); filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.pin-origen { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid #3c4043; box-shadow: var(--sombra-suave); }
.yo { width: 22px; height: 22px; position: relative; }
.yo .punto { position: absolute; inset: 0; border-radius: 50%; background: var(--azul); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.yo .halo { position: absolute; inset: -14px; border-radius: 50%; background: rgba(26,115,232,.18); animation: halo 2s ease-out infinite; }
.yo .cono { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-origin: 0 0; display: none; }
.yo.con-rumbo .cono { display: block; }
.yo .cono::before { content: ""; position: absolute; left: -22px; top: -46px; width: 44px; height: 46px;
  background: radial-gradient(ellipse at 50% 100%, rgba(26,115,232,.45), rgba(26,115,232,0) 70%); clip-path: polygon(50% 100%, 0 0, 100% 0); }
.yo.navegando { width: 34px; height: 34px; }
.yo.navegando .punto { background: none; border: 0; box-shadow: none; }
.yo.navegando .punto::before { content: ""; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 34'%3E%3Ccircle cx='17' cy='17' r='16' fill='%23fff'/%3E%3Cpath d='M17 5 L27 28 L17 22 L7 28 Z' fill='%231a73e8'/%3E%3C/svg%3E") center/contain no-repeat; filter: drop-shadow(0 1px 3px rgba(0,0,0,.4)); }
.yo.navegando .halo, .yo.navegando .cono { display: none; }
@keyframes halo { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
.burbuja { background: var(--fondo); border-radius: 8px; padding: 4px 8px; font-size: 13px; font-weight: 500; box-shadow: var(--sombra-suave);
  white-space: nowrap; cursor: pointer; line-height: 1.25; }
.burbuja small { display: block; font-weight: 400; color: var(--gris); font-size: 11px; }
.burbuja.sel { background: var(--azul); color: #fff; }
.burbuja.sel small { color: #d2e3fc; }
.burbuja.normal { background: #3c4043; color: #fff; }
.burbuja.normal small { color: #dadce0; }

/* ---------- buscador ---------- */
.buscador { position: fixed; inset: 0; z-index: 20; background: var(--fondo); display: flex; flex-direction: column; padding-top: var(--arriba); }
.buscador-top { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 4px; border-bottom: 1px solid var(--borde); }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.buscador-top input { flex: 1; height: 44px; border: 0; outline: 0; font-size: 17px; min-width: 0; background: transparent; }
.icono-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--gris); border-radius: 50%; flex: none; }
.icono-btn:active { background: var(--gris-claro); }
.buscador-lista { flex: 1; overflow-y: auto; padding-bottom: calc(var(--abajo) + 16px); }
.favs { display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto; scrollbar-width: none; }
.item { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; padding: 10px 16px; width: 100%; text-align: left; }
.item:active { background: var(--gris-claro); }
.item .circ { width: 36px; height: 36px; border-radius: 50%; background: var(--gris-claro); display: grid; place-items: center; color: var(--gris); }
.item .circ.azul { background: var(--azul-claro); color: var(--azul); }
.item .tt { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dd { color: var(--gris); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .km { color: var(--gris); font-size: 12.5px; }
.seccion { font-size: 13px; font-weight: 500; color: var(--gris); padding: 14px 16px 4px; }
.vacio { color: var(--gris); padding: 24px 16px; text-align: center; }

/* ---------- panel de capas / ajustes ---------- */
.panel { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.32); display: flex; align-items: flex-end; justify-content: center; }
.panel-caja { background: var(--fondo); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 8px 16px calc(var(--abajo) + 16px); max-height: 85vh; overflow-y: auto; }
.panel h2 { font-size: 18px; font-weight: 500; margin: 10px 0 8px; }
.ajuste { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gris-claro); }
.ajuste > div { flex: 1; }
.ajuste small { display: block; color: var(--gris); font-size: 13px; }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #bdc1c6; border-radius: 12px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--azul); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:disabled + span { opacity: .45; }

/* ---------- navegación ---------- */
.nav-banner { position: fixed; top: calc(var(--arriba) + 8px); left: 8px; right: 8px; z-index: 7; background: var(--verde-nav); color: #fff;
  border-radius: 14px; padding: 12px 14px; display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center; box-shadow: var(--sombra);
  max-width: 640px; margin: 0 auto; }
.nav-banner.avenida { background: #9a4a00; }
.nav-icono { width: 48px; height: 48px; color: #fff; }
.nav-dist { font-size: 26px; font-weight: 600; line-height: 1.1; }
.nav-texto { font-size: 19px; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nav-luego { position: fixed; top: calc(var(--arriba) + 8px + var(--banner-alto, 90px)); left: 20px; z-index: 6; background: #0a4f23; color: #fff;
  border-radius: 0 0 12px 12px; padding: 6px 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.nav-luego svg { width: 20px; height: 20px; }
.nav-pie { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; background: var(--fondo); border-radius: 18px 18px 0 0; box-shadow: 0 -2px 10px rgba(0,0,0,.15);
  padding: 12px 12px calc(var(--abajo) + 12px); display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; max-width: 640px; margin: 0 auto; }
.nav-pie .eta { text-align: center; }
.nav-pie .eta .min { font-size: 24px; font-weight: 600; color: var(--verde); }
.nav-pie .eta .min.demora { color: var(--naranja); }
.nav-pie .eta .sub { color: var(--gris); font-size: 14px; }
.nav-pie .salir { width: 48px; height: 48px; border-radius: 50%; background: #fce8e6; color: var(--rojo); display: grid; place-items: center; }
.nav-flot { position: fixed; right: 12px; bottom: calc(var(--abajo) + 124px); z-index: 7; display: flex; flex-direction: column; gap: 12px; }
.btn-centrar { position: fixed; left: 12px; bottom: calc(var(--abajo) + 124px); z-index: 7; height: 44px; padding: 0 16px; border-radius: 22px;
  background: var(--fondo); color: var(--azul); box-shadow: var(--sombra); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.velocidad { position: fixed; left: 12px; bottom: calc(var(--abajo) + 180px); z-index: 7; width: 58px; height: 58px; border-radius: 50%; background: var(--fondo);
  box-shadow: var(--sombra); display: grid; place-items: center; text-align: center; line-height: 1; font-weight: 600; font-size: 20px; }
.velocidad small { display: block; font-size: 10px; color: var(--gris); font-weight: 400; }
.aviso-mejor { position: fixed; left: 8px; right: 8px; bottom: calc(var(--abajo) + 96px); z-index: 8; background: #202124; color: #fff; border-radius: 14px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--sombra); max-width: 624px; margin: 0 auto; }
.aviso-mejor div { flex: 1; font-size: 15px; }
.aviso-mejor button { color: #8ab4f8; font-weight: 600; padding: 8px; }

/* ---------- elegir en el mapa ---------- */
.mira { position: fixed; left: 50%; top: 50%; width: 30px; height: 40px; margin: -40px 0 0 -15px; z-index: 4; pointer-events: none; color: var(--rojo); }
.mira-barra { position: fixed; left: 12px; right: 12px; bottom: calc(var(--abajo) + 20px); z-index: 8; display: flex; gap: 8px; justify-content: center; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; z-index: 50; background: var(--fondo); display: grid; place-items: center; padding: 24px; }
.login-caja { width: 100%; max-width: 340px; text-align: center; }
.login-caja img { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 12px; }
.login-caja h1 { font-size: 24px; font-weight: 500; margin: 0 0 4px; }
.login-caja p { color: var(--gris); margin: 0 0 20px; }
.login-caja input { width: 100%; height: 48px; border: 1px solid var(--borde); border-radius: 10px; padding: 0 14px; font-size: 17px; margin-bottom: 12px; }
.login-caja .error { color: var(--rojo); min-height: 20px; font-size: 14px; }

/* ---------- toast y carga ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--hoja-alto, 0px) + 20px); transform: translate(-50%, 20px); z-index: 60; background: #323232; color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.ver { opacity: 1; transform: translate(-50%, 0); }
.cargando { display: flex; align-items: center; gap: 12px; color: var(--gris); padding: 18px 0; }
.rueda { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--azul-claro); border-top-color: var(--azul); animation: gira .8s linear infinite; flex: none; }
@keyframes gira { to { transform: rotate(360deg); } }
.barra-carga { position: fixed; top: 0; left: 0; height: 3px; background: var(--azul); z-index: 100; width: 0; transition: width .3s; }

@media (min-width: 700px) {
  .barra { right: auto; width: 420px; }
  .tarjeta-ruta { right: auto; width: 420px; left: 12px; top: 12px; border-radius: 14px; padding-top: 8px; }
  .hoja { left: 12px; right: auto; width: 420px; margin: 0; }
  .nav-pie, .nav-banner { max-width: 460px; }
}
