:root {
  color-scheme: light;
  --fondo: #f7f5fa;
  --texto: #2b2638;
  --texto-suave: #6b6480;
  --acento: #6d4c8f;
  --acento-texto: #ffffff;
  --acento-suave: #ece6f3;
  --tarjeta: #ffffff;
  --borde: #ddd6e8;
  --borde-fuerte: #7d7290;
  --aviso: #eef3ea;
  --aviso-texto: #3f5a3a;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(42, 33, 25, 0.06), 0 4px 14px rgba(42, 33, 25, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fondo: #1b1823;
    --texto: #efeaf6;
    --texto-suave: #aca3bf;
    --acento: #b79be0;
    --acento-texto: #1b1823;
    --acento-suave: #2d2640;
    --tarjeta: #26212f;
    --borde: #3a3347;
    --borde-fuerte: #6e6584;
    --aviso: #26322a;
    --aviso-texto: #c5dcc0;
    --sombra: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --fondo: #1b1823;
  --texto: #efeaf6;
  --texto-suave: #aca3bf;
  --acento: #b79be0;
  --acento-texto: #1b1823;
  --acento-suave: #2d2640;
  --tarjeta: #26212f;
  --borde: #3a3347;
  --borde-fuerte: #6e6584;
  --aviso: #26322a;
  --aviso-texto: #c5dcc0;
  --sombra: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

a { color: var(--acento); }

img, audio, input, button { max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--acento);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Cabecera de la app ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 16px;
  background: var(--tarjeta);
  border-bottom: 1px solid var(--borde);
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--texto);
}

.estado {
  font-size: 0.9rem;
  color: var(--texto-suave);
  white-space: nowrap;
}

/* ---------- Contenedor y tipografía ---------- */

.contenedor {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  font-weight: 700;
  margin: 6px 0 8px;
  text-wrap: balance;
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 28px 0 4px;
}

p { margin: 0 0 0.75em; }

.suave { color: var(--texto-suave); }

.etiqueta {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--acento);
}

.nota {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--texto-suave);
}

.cargando {
  text-align: center;
  color: var(--texto-suave);
  padding: 40px 0;
}

/* ---------- Cabecera de la ruta (inicio) ---------- */

.ruta-cabecera {
  margin: 8px 0 4px;
  padding: 20px 18px 18px;
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-top: 4px solid var(--acento);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
}

.ruta-cabecera h1 {
  font-size: 1.85rem;
  margin: 4px 0 6px;
}

.ruta-meta {
  margin: 0;
  font-size: 1rem;
  color: var(--texto-suave);
}

.ruta-acceso {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--borde);
}

.ruta-acceso .etiqueta { color: var(--texto-suave); }

.precio {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.ruta-acceso .boton {
  width: auto;
  margin-top: 0;
  padding-left: 22px;
  padding-right: 22px;
}

/* ---------- Tarjetas, avisos y botones ---------- */

.tarjeta {
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 18px;
  margin: 14px 0;
}

.tarjeta > p:last-child,
.tarjeta > :last-child { margin-bottom: 0; }

.aviso {
  background: var(--aviso);
  color: var(--aviso-texto);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: 0.95rem;
  line-height: 1.45;
  box-shadow: inset 4px 0 0 var(--aviso-texto);
}

.aviso code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--tarjeta);
  color: var(--texto);
  font-family: ui-monospace, Consolas, "Courier New", monospace;
}

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  margin-top: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--acento);
  color: var(--acento-texto);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.boton.secundario {
  background: transparent;
  color: var(--acento);
  border-color: var(--acento);
}

.boton:disabled { opacity: 0.5; cursor: default; }

@media (hover: hover) {
  .boton:not(:disabled):hover { opacity: 0.9; }
  .boton.secundario:not(:disabled):hover { background: var(--acento-suave); opacity: 1; }
}

.mensaje {
  min-height: 1.5em;
  margin: 10px 0 0;
  font-size: 0.95rem;
}

label {
  display: block;
  font-weight: 600;
}

input[type="text"], input[type="number"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  margin-top: 8px;
  font: inherit;
  font-size: 1rem;
  color: var(--texto);
  background: var(--fondo);
  border: 1px solid var(--borde-fuerte);
  border-radius: 12px;
}

/* ---------- Lista de paradas ---------- */

.lista {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lista li a {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 10px 16px 10px 12px;
  margin: 8px 0;
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  text-decoration: none;
  color: var(--texto);
}

.lista .parada-titulo {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  line-height: 1.3;
}

.lista .parada-estado {
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  font-size: 1rem;
  color: var(--acento);
}

@media (hover: hover) {
  .lista li a:hover {
    background: var(--acento-suave);
    border-color: var(--acento);
  }
}

.numero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--acento);
  color: var(--acento-texto);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ---------- Vista de parada ---------- */

.parada-imagen {
  display: block;
  width: 100%;
  height: auto;
  margin: 14px 0 0;
  border-radius: var(--radio);
}

.parada-texto {
  margin: 20px 0 0;
  padding-bottom: 4px;
}

.parada-texto p {
  font-size: 1.05rem;
  line-height: 1.65;
  margin: 0 0 0.9em;
}

.parada-texto p:last-child { margin-bottom: 0; }

.reproductor {
  margin-top: 22px;
}

audio {
  display: block;
  width: 100%;
  margin-top: 4px;
}

.nav-paradas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 28px;
}

.nav-paradas a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 66px;
  padding: 10px 12px;
  text-align: center;
  border: 1px solid var(--borde-fuerte);
  border-radius: 12px;
  background: var(--tarjeta);
  color: var(--acento);
  font-weight: 700;
  text-decoration: none;
}

.nav-paradas small {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--texto-suave);
}

.nav-paradas .nav-ruta {
  grid-column: 1 / -1;
  flex-direction: row;
  min-height: 44px;
  border: 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (hover: hover) {
  .nav-paradas a:hover { background: var(--acento-suave); }
}

/* ---------- Mapa y guía GPS ---------- */

.mapa {
  width: 100%;
  height: min(58vh, 480px);
  min-height: 300px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  overflow: hidden;
  background: var(--acento-suave);
}

.sig-fila {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 12px;
}

.flecha {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--acento);
  color: var(--acento-texto);
  font-size: 1.4rem;
  transition: transform 0.3s ease;
}

.pin-n {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--acento);
  color: var(--acento-texto);
  border: 2px solid #fff;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.pin-n.visitada { background: var(--texto-suave); }

.parada-figura { margin: 12px 0 16px; }

.parada-figura figcaption { margin-top: 6px; }

/* ---------- Movimiento (solo si el usuario no pide reducirlo) ---------- */

@media (prefers-reduced-motion: no-preference) {
  .lista li a,
  .boton,
  .nav-paradas a {
    transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  }
}
