/* ============ tokens ============ */
/* El tema se resuelve en <head> (index.html) y en app.js: data-theme="light" | "dark". */
:root {
  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --surface-3: #e8eef7;
  --text: #0f172a;
  --muted: #536079;
  --faint: #8592a7;
  --line: #dde5f0;
  --accent: #1d5bd8;
  --accent-ink: #ffffff;
  --accent-soft: #e6eeff;
  /* estados de aviso, en la misma familia del azul (la intensidad marca la urgencia) */
  --hit: #1d5bd8;           /* en la parada / cerca de ti */
  --hit-soft: #e4ecff;
  --soon: #3b82f6;          /* acercándose */
  --soon-soft: #eef4ff;
  --danger: #d92d3a;
  --danger-soft: #fdecee;
  --me: #0891b2;            /* tu ubicación */
  --stop: #7c3aed;          /* tus paradas */
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .06);
  --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 6px 18px rgb(29 91 216 / .07);
  --shadow-lg: 0 12px 40px rgb(15 23 42 / .18);
  --sheet-shadow: 0 -8px 24px rgb(15 23 42 / .10);
  --radius: 16px;
  --appbar-h: 60px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  /* grises neutros (sin tinte azul); el azul queda sólo como acento */
  --bg: #0d0d0f;
  --surface: #17171a;
  --surface-2: #1d1d21;
  --surface-3: #25252a;
  --text: #f1f1f3;
  --muted: #a4a4ad;
  --faint: #70707a;
  --line: #2c2c32;
  --accent: #5b9bff;
  --accent-ink: #ffffff;
  --accent-soft: #1b2638;
  --hit: #5b9bff;
  --hit-soft: #1b2740;
  --soon: #8fb8ff;
  --soon-soft: #1a2231;
  --danger: #ff7b7b;
  --danger-soft: #331b1c;
  --me: #2dd4ef;
  --stop: #b197fc;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgb(255 255 255 / .035) inset, 0 8px 24px rgb(0 0 0 / .28);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / .6);
  --sheet-shadow: 0 -10px 30px rgb(0 0 0 / .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h2 { font-size: 1rem; font-weight: 650; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ============ layout ============ */
.app { min-height: 100dvh; }

.appbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--appbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}

.map-wrap {
  position: sticky; top: calc(var(--appbar-h) + env(safe-area-inset-top)); z-index: 1;
  height: 46dvh; min-height: 260px;
}
#map { position: absolute; inset: 0; background: var(--surface-3); }

.sheet {
  position: relative; z-index: 2;
  margin-top: -20px;
  min-height: calc(100dvh - var(--appbar-h));
  padding: 6px 14px calc(18px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--sheet-shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.grabber { display: block; width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto; }
.grabber-btn {
  display: grid; place-items: center; width: 100%; height: 26px; margin: -2px 0 -6px;
  border: 0; background: transparent; cursor: pointer; touch-action: none;
}
.grabber-btn:hover .grabber { background: var(--faint); }

@media (min-width: 960px) {
  .app {
    display: grid;
    grid-template-columns: 420px 1fr;
    grid-template-rows: auto 1fr;
    height: 100dvh;
  }
  .appbar { grid-area: 1 / 1; position: relative; border-right: 1px solid var(--line); background: var(--surface); }
  .sheet {
    grid-area: 2 / 1; overflow-y: auto; margin: 0; min-height: 0;
    border-radius: 0; box-shadow: none; border-right: 1px solid var(--line);
    padding-top: 14px;
  }
  .grabber-btn { display: none; }
  .map-wrap { grid-area: 1 / 2 / 3 / 3; position: relative; top: 0; height: auto; }
}

/* ============ appbar ============ */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 10px; box-shadow: var(--shadow-sm); }
.brand-text { display: grid; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 1rem; letter-spacing: -.015em; white-space: nowrap; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live.on i { background: var(--hit); box-shadow: 0 0 0 0 color-mix(in srgb, var(--hit) 60%, transparent); animation: ping 2s infinite; }
.live.err i { background: var(--danger); }
@keyframes ping { 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.appbar-actions { display: flex; align-items: center; gap: 8px; }

.route-pick {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 12px 0 14px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 78%, #fff), var(--accent));
  color: var(--accent-ink);
  font-weight: 700; font-size: .92rem; letter-spacing: .01em; white-space: nowrap;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 32%, transparent), inset 0 1px 0 rgb(255 255 255 / .18);
  cursor: pointer; transition: transform .12s, box-shadow .2s, filter .2s;
  -webkit-tap-highlight-color: transparent;
}
.route-pick .ic { width: 16px; height: 16px; }
.route-pick .chev { width: 16px; height: 16px; opacity: .85; transition: transform .2s; }
.route-pick:hover { filter: brightness(1.06); }
.route-pick:active { transform: scale(.97); }
.route-pick:focus { outline: none; }
.route-pick:focus-visible { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
.route-pick[aria-expanded="true"] .chev { transform: rotate(180deg); }

.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); cursor: pointer;
}

/* ============ mapa ============ */
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 500; display: grid; gap: 8px; }
.map-btn {
  display: grid; place-items: center; width: 46px; height: 46px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); cursor: pointer;
}
.map-btn:active { transform: scale(.95); }

.map-legend {
  position: absolute; left: 12px; top: 12px; z-index: 500;
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  font-size: .72rem; color: var(--muted);
}
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg-bus { background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.lg-base { background: var(--surface); border: 2.5px solid var(--accent); border-radius: 4px; }
.lg-stop { background: var(--stop); }

.pick-banner {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); z-index: 600;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px; border-radius: 999px;
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: .88rem; font-weight: 550;
  white-space: nowrap; max-width: calc(100% - 24px);
}
.pick-banner span { overflow: hidden; text-overflow: ellipsis; }
.pick-cancel {
  border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  background: color-mix(in srgb, var(--bg) 18%, transparent); color: inherit; font-weight: 600;
}
.picking #map { cursor: crosshair; }

/* leaflet */
.leaflet-container { font: inherit; background: var(--surface-3); }
.leaflet-tile-pane { filter: saturate(.4) hue-rotate(-6deg) contrast(.92) brightness(1.04); }
/* mapa oscuro: gris grafito con calles claras y un toque de color en parques y agua */
[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) saturate(.28) brightness(.8) contrast(.95); }
[data-theme="dark"] .leaflet-container { background: #1b1b1e; }

/* detalles del modo oscuro */
[data-theme="dark"] .appbar { background: color-mix(in srgb, var(--surface) 82%, transparent); }
[data-theme="dark"] .card,
[data-theme="dark"] .hero,
[data-theme="dark"] .watch,
[data-theme="dark"] .unit-list li,
[data-theme="dark"] .event-list { background: linear-gradient(180deg, #1a1a1e, var(--surface)); }
[data-theme="dark"] .tabs { background: var(--surface); border: 1px solid var(--line); }
[data-theme="dark"] .tabs button[aria-selected="true"] { background: var(--surface-3); box-shadow: none; }
[data-theme="dark"] .map-btn,
[data-theme="dark"] .map-legend { background: color-mix(in srgb, var(--surface) 92%, transparent); }
[data-theme="dark"] .grabber { background: #3a3a41; }
[data-theme="dark"] .hero.near { background: linear-gradient(180deg, var(--hit-soft), var(--surface) 75%); }
[data-theme="dark"] .watch.hit { background: linear-gradient(180deg, var(--hit-soft), var(--surface) 60%); }
[data-theme="dark"] .bus-dot, [data-theme="dark"] .me-dot { border-color: #f1f1f3; }
.leaflet-control-attribution {
  font-size: 10px; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted);
}
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-bar { border: 1px solid var(--line) !important; border-radius: 12px !important; overflow: hidden; box-shadow: var(--shadow) !important; }
.leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--line); width: 40px !important; height: 40px !important; line-height: 40px !important; }
.leaflet-bar a:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 959px) { .leaflet-bottom.leaflet-right { margin-bottom: 20px; } .leaflet-control-zoom { display: none; } }

.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border-radius: 14px; box-shadow: var(--shadow-lg); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 12px 14px; font-size: .86rem; line-height: 1.4; }
.leaflet-container a.leaflet-popup-close-button { color: var(--faint); }
.pop-title { font-weight: 700; font-size: .95rem; }
.pop-sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.pop-btn { margin-top: 10px; width: 100%; }

/* paradas: recuadro (las unidades son círculos) */
.stop {
  position: absolute; left: -13px; top: -13px; width: 26px; height: 26px;
  display: grid; place-items: center; border-radius: 8px;
  background: var(--surface); color: var(--accent);
  border: 2.5px solid var(--accent);
  box-shadow: 0 2px 6px rgb(0 0 0 / .28);
  cursor: pointer; transition: transform .15s;
}
.stop .ic { width: 14px; height: 14px; stroke-width: 2.4; }
.stop.shared { left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 7px; border-color: var(--muted); color: var(--muted); }
.stop.shared .ic { width: 12px; height: 12px; }
.leaflet-marker-icon:hover .stop { transform: scale(1.12); }

.leaflet-tooltip.stop-label {
  display: none; padding: 2px 7px; border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 94%, transparent); color: var(--text);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  font-size: .72rem; font-weight: 650; white-space: nowrap;
}
.leaflet-tooltip.stop-label::before { display: none; }
.leaflet-tooltip.stop-label.shared { color: var(--muted); font-weight: 600; }
#map.labels-on .leaflet-tooltip.stop-label { display: block; }

/* marcadores */
.mk { position: absolute; transform: translate(-50%, -50%); }
.bus { position: absolute; left: -16px; top: -16px; cursor: pointer; }
.bus-dot {
  position: relative; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--rc, var(--accent)); color: #fff;
  border: 2.5px solid #fff; box-shadow: 0 2px 8px rgb(0 0 0 / .32);
}
.bus-dot .ic { width: 16px; height: 16px; }
.bus-dir { position: absolute; inset: -2.5px; pointer-events: none; }
.bus-dir svg {
  position: absolute; left: 50%; top: -14px; margin-left: -10px;
  width: 20px; height: 13px; overflow: visible;
  fill: var(--rc, var(--accent)); stroke: #fff; stroke-width: 1.6; stroke-linejoin: round;
  filter: drop-shadow(0 1px 1.5px rgb(0 0 0 / .35));
}
.bus-tag {
  position: absolute; left: 30px; top: 50%; transform: translateY(-50%);
  padding: 1px 6px; border-radius: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px rgb(0 0 0 / .18); white-space: nowrap;
}
.bus.near .bus-dot { background: var(--hit); box-shadow: 0 0 0 4px color-mix(in srgb, var(--hit) 30%, transparent), 0 2px 8px rgb(0 0 0 / .32); }
.bus.near .bus-dir svg { fill: var(--hit); }
.bus.stale { opacity: .6; }
.bus.stale .bus-dot { background: #8a919c; }
.bus.stale .bus-dir { display: none; }

.me-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--me); border: 3px solid #fff; box-shadow: 0 0 0 0 color-mix(in srgb, var(--me) 55%, transparent), 0 2px 6px rgb(0 0 0 / .3);
  animation: me 2.2s infinite;
}
.me-dot.manual { animation: none; }
@keyframes me { 70% { box-shadow: 0 0 0 12px transparent, 0 2px 6px rgb(0 0 0 / .3); } 100% { box-shadow: 0 0 0 0 transparent, 0 2px 6px rgb(0 0 0 / .3); } }

.stop-mk {
  display: grid; place-items: center; width: 30px; height: 30px;
  transform: translate(-50%, -100%);
  color: #fff;
}
.stop-mk svg { width: 30px; height: 30px; fill: var(--stop); stroke: #fff; stroke-width: 1.6; filter: drop-shadow(0 2px 3px rgb(0 0 0 / .35)); }
.stop-mk.off svg { fill: #8a919c; }
.stop-mk.hit svg { fill: var(--hit); }
.stop-mk.draft svg { fill: var(--soon); }

/* ============ hoja ============ */
.tabs {
  position: sticky; top: calc(var(--appbar-h) + env(safe-area-inset-top)); z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 4px; border-radius: 14px;
  background: var(--surface-3);
}
@media (min-width: 960px) { .tabs { top: 0; } }
.tabs button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px 6px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font-size: .74rem; font-weight: 600; cursor: pointer;
}
.tabs button .ic { width: 18px; height: 18px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.tabs button[aria-selected="true"] .ic { color: var(--accent); }
.tab-count {
  position: absolute; top: 3px; right: calc(50% - 22px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--accent); color: #fff; font-size: .64rem; line-height: 16px; text-align: center;
}

.tabpanel { display: flex; flex-direction: column; gap: 12px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 4px 2px 0; }
.section-head.compact { align-items: center; margin-top: 8px; }
.section-head .hint { margin-top: 2px; }

.hint { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.section-head .hint, .about .hint { margin-top: 4px; }
.value { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .74rem; font-weight: 600; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted);
}
.pill.on { background: var(--hit-soft); color: var(--hit); }
.pill.manual { background: var(--surface-3); color: var(--muted); }
.pill.off { background: var(--danger-soft); color: var(--danger); }

/* ============ callout ============ */
.callout {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 14px; border-radius: 14px;
  background: var(--accent-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.callout .ic { color: var(--accent); }
.callout p { flex: 1; font-size: .84rem; }

/* ============ botones ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid transparent; border-radius: 12px;
  min-height: 44px; padding: 9px 16px; font-size: .95rem; font-weight: 650;
  cursor: pointer; white-space: nowrap;
  transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.97); }
.btn .ic { width: 17px; height: 17px; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: .86rem; border-radius: 10px; }
.btn-sm .ic { width: 15px; height: 15px; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn { flex: 1 1 auto; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: .86rem; font-weight: 650; cursor: pointer; padding: 10px 8px; min-height: 44px; }
.link-btn.strong { color: var(--accent); padding: 4px 0; min-height: 0; }
.link-btn:hover { color: var(--accent); }

/* ============ hero ============ */
.hero {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.hero::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--line);
}
.hero-label { font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.hero-big { font-size: 2.9rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.05; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero-big small { font-size: 1.15rem; font-weight: 650; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.hero-detail { margin-top: 6px; font-size: .9rem; color: var(--muted); }
.hero-meter { margin-top: 14px; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.hero-meter span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--faint); transition: width .5s ease, background .3s; }
.hero.near::before, .hero.near .hero-meter span { background: var(--hit); }
.hero.near .hero-big { color: var(--hit); }
.hero.near { border-color: color-mix(in srgb, var(--hit) 45%, var(--line)); background: linear-gradient(180deg, var(--hit-soft), var(--surface) 75%); }
.hero.approach::before, .hero.approach .hero-meter span { background: var(--soon); }
.hero.approach .hero-big { color: var(--soon); }
.hero.far .hero-meter span { background: var(--accent); }
.hero.alerting { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--hit) 25%, transparent); } }

/* ============ controles ============ */
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 4px 0 0; }
.range-scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--faint); }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0 0; margin-top: 12px; border-top: 1px solid var(--line); cursor: pointer;
}
.switch-row span { display: grid; gap: 1px; }
.switch-row strong { font-size: .92rem; font-weight: 600; }
.switch-row small { font-size: .78rem; color: var(--muted); }
.settings .switch-row:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.settings .switch-row { padding-top: 14px; margin-top: 14px; }

.switch {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 44px; height: 26px; border-radius: 99px; margin: 0;
  background: var(--surface-3); border: 1px solid var(--line);
  position: relative; cursor: pointer; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  transition: transform .2s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible, .btn:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ paradas ============ */
.watch-list, .unit-list, .event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.watch {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 10px; box-shadow: var(--shadow);
}
.watch.off { opacity: .6; }
.watch.hit { border-color: color-mix(in srgb, var(--hit) 55%, var(--line)); }
.watch-top { display: flex; align-items: flex-start; gap: 12px; }
.watch-ico {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 12px;
  background: color-mix(in srgb, var(--stop) 14%, transparent); color: var(--stop);
}
.watch.hit .watch-ico { background: var(--hit-soft); color: var(--hit); }
.watch-main { flex: 1; min-width: 0; }
.watch-name { font-weight: 650; font-size: .98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-meta { font-size: .78rem; color: var(--muted); margin-top: 1px; }
.watch-meta b { color: var(--accent); font-weight: 700; }

.watch-status {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 9px 11px; border-radius: 11px;
  background: var(--surface-2); font-size: .84rem;
}
.watch-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.watch-status.hit { background: var(--hit); color: #fff; font-weight: 650; }
.watch-status.hit .dot { background: #fff; animation: ping 1.6s infinite; }
.watch-status.near { background: var(--soon-soft); }
.watch-status.near .dot { background: var(--soon); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .76rem; font-weight: 600; color: var(--muted);
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line);
}
.chip .ic { width: 12px; height: 12px; }
.chip.dim { opacity: .45; text-decoration: line-through; }

.watch-last { font-size: .76rem; color: var(--faint); margin-top: 8px; }
.watch-actions { display: flex; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.watch-actions .btn { flex: 1; min-height: 44px; background: transparent; color: var(--muted); border: 0; padding: 6px; font-size: .84rem; }
.watch-actions .btn:hover { background: var(--surface-2); color: var(--text); filter: none; }
.watch-actions .btn.del:hover { color: var(--danger); }

.empty {
  display: grid; justify-items: center; gap: 8px; text-align: center;
  padding: 22px 16px; border: 1.5px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: .86rem;
}
.empty .ic { width: 26px; height: 26px; color: var(--faint); }
.empty strong { color: var(--text); }

.event-list { gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.event-list:empty { display: none; }
.event-list li { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: .84rem; }
.event-list li:first-child { border-top: 0; }
.ev-ico { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 9px; background: var(--surface-3); color: var(--muted); }
.ev-ico .ic { width: 15px; height: 15px; }
.ev-arrive .ev-ico, .ev-near .ev-ico { background: var(--hit-soft); color: var(--hit); }
.ev-depart .ev-ico, .ev-pass .ev-ico { background: var(--surface-3); color: var(--muted); }
.ev-approach .ev-ico { background: var(--soon-soft); color: var(--soon); }
.ev-text { flex: 1; min-width: 0; }
.ev-time { font-size: .74rem; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ============ unidades ============ */
.unit-list li {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color .15s;
}
.unit-list li:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.unit-list li.stale { opacity: .5; }
.unit-list li.near { border-color: color-mix(in srgb, var(--hit) 55%, var(--line)); }
.u-ico { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.unit-list li.near .u-ico { background: var(--hit-soft); color: var(--hit); }
.unit-list li.stale .u-ico { background: var(--surface-3); color: var(--faint); }
.u-info { flex: 1; min-width: 0; }
.u-name { display: block; font-weight: 650; font-size: .93rem; }
.u-sub { display: block; font-size: .77rem; color: var(--muted); margin-top: 1px; }
.u-dist { font-weight: 750; font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.u-dist.near { color: var(--hit); }
.u-dist.none { font-weight: 500; font-size: .78rem; color: var(--faint); }

/* ============ pie ============ */
.foot { text-align: center; padding: 8px 0 4px; margin-top: auto; }
.foot p { font-size: .76rem; color: var(--faint); }

.about p { font-size: .86rem; color: var(--muted); margin-top: 6px; }

/* ============ diálogo ============ */
.dlg {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 1px solid var(--line); border-radius: 20px; padding: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dlg::backdrop { background: rgb(10 12 16 / .45); backdrop-filter: blur(2px); }
@media (max-width: 600px) {
  .dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; border-bottom: 0; max-height: 92dvh; }
}
.dlg form { padding: 16px 18px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { font-size: 1.1rem; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.dlg-foot .btn { min-width: 110px; }

.field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > label, .field legend { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 0; }
.field legend { margin-bottom: 6px; }
.field .hint { margin-top: 0; }
.field input[type="text"], .field select, .inline-select select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 9px 11px; font-size: .95rem; min-width: 0;
}
.field input[type="text"]:focus, .field select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-size: .92rem; padding: 5px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.inline-select select { width: auto; padding: 6px 9px; font-size: .88rem; }
.form-error { font-size: .84rem; color: var(--danger); font-weight: 600; }

/* ============ sentido y horarios ============ */
.trend {
  display: inline-block; vertical-align: 1px; margin-left: 6px;
  padding: 1px 7px; border-radius: 999px;
  font-size: .68rem; font-weight: 700; letter-spacing: .01em;
}
.trend.in { background: var(--hit-soft); color: var(--hit); }
.trend.out { background: var(--surface-3); color: var(--muted); }
.pop-title .trend { font-size: .66rem; }

.base-pop { min-width: 210px; }
.hor { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.hor-msg { color: var(--muted); font-size: .8rem; }
.hor-next { display: flex; align-items: baseline; gap: 8px; }
.hor-next span { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.hor-next b { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hor-next small { color: var(--hit); font-weight: 650; font-size: .8rem; }
.hor-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.hor-list span {
  padding: 2px 7px; border-radius: 7px; background: var(--surface-3);
  font-size: .76rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.hor-list span.more { background: transparent; color: var(--muted); }
.hor-note { margin-top: 8px; font-size: .7rem; color: var(--faint); }
.map-wrap:has(.leaflet-popup) .map-legend { display: none; }
@media (max-width: 959px) {
  .leaflet-popup-content { margin: 10px 12px; }
  .hor { margin-top: 8px; padding-top: 8px; }
  .hor-note { display: none; }
  .pop-btn { margin-top: 8px; }
}

.watch-hor { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: .84rem; }
.watch-hor .ic { width: 15px; height: 15px; color: var(--muted); }
.watch-hor b { font-variant-numeric: tabular-nums; }
.watch-hor small { color: var(--muted); font-size: .78rem; }
.watch-hor.muted { color: var(--muted); }

/* control segmentado (formato de hora) */
.seg { display: inline-flex; flex: none; padding: 3px; border-radius: 11px; background: var(--surface-3); }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 5px 12px; border-radius: 8px;
  font-size: .82rem; font-weight: 650; color: var(--muted);
}
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* botón de tema */
.icon-btn { color: var(--text); }
.icon-btn .i-sun { display: none; }
[data-theme="dark"] .icon-btn .i-sun { display: block; }
[data-theme="dark"] .icon-btn .i-moon { display: none; }

/* ============ horario de avisos ============ */
.sched { display: grid; gap: 10px; }
.sched .seg { justify-self: start; }
.sched-custom { display: grid; gap: 10px; }
.sched-times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sched-times label { display: grid; gap: 4px; font-size: .74rem; font-weight: 600; color: var(--muted); }
.sched-times input {
  width: 100%; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 8px 10px; font-size: .95rem; font-variant-numeric: tabular-nums; color: var(--text);
}
.sched-times input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.sched-days { display: flex; gap: 6px; }
.sched-days label { flex: 1; cursor: pointer; }
.sched-days input { position: absolute; opacity: 0; pointer-events: none; }
.sched-days span {
  display: grid; place-items: center; height: 34px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: .8rem; font-weight: 700; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.sched-days input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sched-days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.sched-row { display: grid; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sched-label { display: flex; align-items: center; gap: 7px; font-size: .92rem; font-weight: 600; }
.sched-label .ic { width: 16px; height: 16px; color: var(--muted); }
.sched-hint { margin-top: 0; color: var(--muted); }

.chip.paused { color: var(--muted); border-color: var(--line); background: var(--surface-3); }

/* ============ cerca de mí ============ */
.near-card > .switch-row { margin-top: 0; padding-top: 0; border-top: 0; }
.near-opts { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); transition: opacity .2s; }
.near-opts.off { opacity: .4; filter: grayscale(.6); }

/* ============ selector de ruta ============ */
.dlg-body { padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.dlg-head .hint { margin-top: 2px; }
.route-dlg { width: min(520px, calc(100vw - 24px)); }
@media (max-width: 600px) { .route-dlg { width: 100vw; } }
.route-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.route-chip {
  position: relative; display: grid; place-items: center; gap: 0;
  padding: 10px 4px 9px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
}
.route-chip small { font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.route-chip b { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.route-chip:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.route-chip:active { transform: scale(.96); }
.route-chip:focus { outline: none; }
.route-chip:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.route-chip[aria-selected="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
.route-chip[aria-selected="true"] small { color: rgb(255 255 255 / .8); }
.rc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stop); display: inline-block; }
.route-chip .rc-dot { position: absolute; top: 8px; right: 8px; box-shadow: 0 0 0 2px var(--surface-2); }
.route-chip[aria-selected="true"] .rc-dot { background: #fff; box-shadow: none; }
.route-legend { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); }

/* ============ modales de aviso y confirmación ============ */
.pop-dlg,
.pop-dlg[open] {
  width: min(380px, calc(100vw - 32px));
  max-width: none; margin: auto;
  border: 1px solid var(--line); border-radius: 24px;
  max-height: calc(100dvh - 32px);
}
.pop-dlg[open] { animation: popIn .22s cubic-bezier(.2, .9, .3, 1.2); }
.pop-dlg[open]::backdrop { animation: fadeIn .2s ease; }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.95); } }
@keyframes fadeIn { from { opacity: 0; } }
@media (max-width: 600px) {
  .pop-dlg { width: calc(100vw - 32px); max-width: none; margin: auto; border-radius: 24px; border-bottom: 1px solid var(--line); }
}

.alert-body { display: grid; justify-items: center; text-align: center; padding: 26px 22px 20px; }
.alert-ico {
  position: relative; display: grid; place-items: center;
  width: 64px; height: 64px; border-radius: 20px; margin-bottom: 14px;
  background: var(--surface-3); color: var(--muted);
}
.alert-ico .ic { width: 30px; height: 30px; stroke-width: 2; }
/* llegó / cerca de ti: lo más urgente, azul sólido con pulso */
.alert-ico.k-arrive, .alert-ico.k-near { background: var(--hit); color: #fff; box-shadow: 0 8px 22px color-mix(in srgb, var(--hit) 40%, transparent); }
.alert-ico.k-arrive::after, .alert-ico.k-near::after {
  content: ""; position: absolute; inset: -6px; border-radius: 26px;
  border: 2px solid color-mix(in srgb, var(--hit) 45%, transparent);
  animation: ring 1.6s ease-out infinite;
}
@keyframes ring { from { opacity: 1; transform: scale(.92); } to { opacity: 0; transform: scale(1.18); } }
.alert-ico.k-approach { background: var(--soon-soft); color: var(--soon); }
.alert-ico.danger { background: var(--danger-soft); color: var(--danger); }

.alert-kicker { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.alert-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.alert-text { margin-top: 8px; font-size: .95rem; color: var(--muted); max-width: 30ch; }
.alert-meta { margin-top: 10px; font-size: .76rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.alert-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 20px; }
.alert-actions .btn { padding: 11px 12px; }
.alert-actions .btn[hidden] + .btn, .alert-actions .btn:only-child { grid-column: 1 / -1; }
.alert-queue { margin-top: 12px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.btn-danger-solid { background: #d93a44; color: #fff; }

/* ============ facilidad de uso ============ */
.btn-lg { min-height: 52px; padding: 12px 20px; font-size: 1.02rem; border-radius: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* aviso de estado */
.callout.err { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.callout.err .ic { color: var(--danger); }
.callout .btn { flex: none; }

/* bienvenida (sin paradas) */
.welcome {
  display: grid; justify-items: center; gap: 10px; text-align: center;
  padding: 26px 18px 22px; border-radius: 20px;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 80%);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.welcome-ico { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; background: var(--accent); color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent); }
.welcome-ico .ic { width: 28px; height: 28px; }
.welcome h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.welcome p { color: var(--muted); max-width: 30ch; }
.welcome .btn { margin-top: 6px; width: 100%; max-width: 320px; }
.add-watch { width: 100%; }

/* tarjeta de parada: la llegada en grande */
.watch-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: .78rem; font-weight: 650; color: var(--muted); }
.eta { margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.eta-big { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.eta-sub { margin-top: 3px; font-size: .88rem; color: var(--muted); }
.eta-next { margin-top: 6px; font-size: .84rem; font-weight: 600; color: var(--text); }
.eta.soon { background: var(--soon-soft); border-color: color-mix(in srgb, var(--soon) 35%, var(--line)); }
.eta.soon .eta-big { color: var(--soon); }
.eta.hit { background: var(--hit); border-color: var(--hit); color: #fff; }
.eta.hit .eta-sub, .eta.hit .eta-next { color: rgb(255 255 255 / .88); }
.eta.none .eta-big { font-size: 1.1rem; color: var(--muted); }
.watch.off .eta { opacity: .75; }

/* formulario: opciones avanzadas plegadas */
.more { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.more summary { cursor: pointer; padding: 12px 14px; font-weight: 650; font-size: .92rem; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: "+"; font-size: 1.2rem; color: var(--muted); }
.more[open] summary::after { content: "−"; }
.more-body { display: grid; gap: 14px; padding: 4px 14px 14px; }

/* asistente */
.wiz-dlg { width: min(520px, calc(100vw - 24px)); }
@media (max-width: 600px) { .wiz-dlg { width: 100vw; max-height: 94dvh; } }
.wiz-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wiz-steps { display: flex; gap: 6px; }
.wiz-steps i { width: 26px; height: 6px; border-radius: 99px; background: var(--surface-3); transition: background .2s; }
.wiz-steps i.on { background: var(--accent); }
.wiz-kicker { font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-top: 4px; }
.wiz-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.025em; line-height: 1.2; }
.wiz-sub { color: var(--muted); margin-top: -8px; }
.wiz-content { display: grid; gap: 12px; }
.wiz-h3 { font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 6px 0 -4px; }
.wiz-near, .wiz-map { width: 100%; }
.wiz-list { display: grid; gap: 8px; }
.wiz-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; text-align: left;
  padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); cursor: pointer; transition: border-color .15s, transform .1s;
}
.wiz-item:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.wiz-item:active { transform: scale(.98); }
.wiz-item.best { border-color: var(--accent); background: var(--accent-soft); }
.wl-main { flex: 1; display: grid; gap: 1px; min-width: 0; }
.wl-main b { font-size: 1rem; font-weight: 700; }
.wl-main small { font-size: .82rem; color: var(--muted); }
.wl-badge { display: grid; place-items: center; min-width: 44px; height: 40px; padding: 0 8px; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 800; }
.wl-pin { color: var(--stop); width: 22px; height: 22px; }
.wl-go { transform: rotate(180deg); color: var(--faint); }
.wiz-opts { display: grid; gap: 8px; }
.wiz-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px;
  padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
}
.wiz-opt span { display: flex; align-items: center; gap: 10px; }
.wiz-opt .ic { color: var(--accent); }
.wiz-note { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px 10px; padding: 12px 14px; border-radius: 14px; font-size: .9rem; }
.wiz-note > span { flex: 1; min-width: 200px; }
.wiz-note.info { background: var(--accent-soft); }
.wiz-note.info .ic { color: var(--accent); flex: none; margin-top: 2px; }
.wiz-note.warn { background: var(--danger-soft); color: var(--text); }
.wiz-note.warn .ic { color: var(--danger); flex: none; margin-top: 2px; }
p.wiz-note.warn { display: block; }
.wiz-done { width: 100%; margin-top: 4px; }

/* guías */
.guide-dlg .dlg-body { padding: 24px 22px 20px; gap: 14px; }
.guide-dlg .alert-text { margin-top: -6px; max-width: none; }
.guide-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.guide-steps li { display: flex; align-items: flex-start; gap: 12px; font-size: .95rem; line-height: 1.4; }
.gs-num { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; font-size: .86rem; }
.ic.inline { width: 17px; height: 17px; vertical-align: -3px; color: var(--accent); }
.guide-ok { width: 100%; }
.about-btn { margin-top: 10px; }

/* ventana de un camión: llegada a mis paradas */
.pop-eta { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: .86rem; }
.pop-eta .ic { width: 14px; height: 14px; color: var(--stop); }

/* aviso breve con «Deshacer» */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 3000;
  transform: translate(-50%, 20px); opacity: 0;
  display: flex; align-items: center; gap: 14px;
  max-width: min(520px, calc(100vw - 24px)); padding: 12px 12px 12px 18px; border-radius: 16px;
  background: #1c1d22; color: #fff; box-shadow: var(--shadow-lg); font-size: .92rem;
  transition: transform .22s ease, opacity .22s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-btn { flex: none; min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: rgb(255 255 255 / .12); color: #9cc2ff; font-weight: 750; cursor: pointer; }
[data-theme="dark"] .toast { background: #f1f1f3; color: #111; }
[data-theme="dark"] .toast-btn { background: rgb(0 0 0 / .08); color: var(--hit); }

/* respetar «reducir movimiento» del sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ============ ver sólo el mapa ============ */
.map-btn .i-min { display: none; }
body.map-only .map-btn .i-min { display: block; }
body.map-only .map-btn .i-max { display: none; }
body.map-only #btnMapOnly { background: var(--accent); color: #fff; border-color: var(--accent); }

.peek {
  display: grid; gap: 8px; width: 100%; padding: 6px 4px 4px;
  border: 0; background: transparent; color: var(--text); cursor: pointer; touch-action: none;
}
.peek-row { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; font-weight: 650; }
.peek-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peek .ic { color: var(--accent); flex: none; }

@media (max-width: 959px) {
  .map-wrap { transition: height .25s ease; }
  body.map-only { overflow: hidden; }
  /* el mapa ocupa todo menos la barra mínima de abajo */
  body.map-only .map-wrap { height: calc(100dvh - var(--appbar-h) - env(safe-area-inset-top) - 72px - env(safe-area-inset-bottom) + 20px); }
  body.map-only .sheet { min-height: 0; padding-top: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  body.map-only .sheet > :not(.peek) { display: none !important; }
}
@media (min-width: 960px) {
  .peek { display: none !important; }
  /* escritorio: el mapa a pantalla completa; se vuelve con el mismo botón */
  body.map-only .app { grid-template-columns: 0 1fr; }
  body.map-only .appbar, body.map-only .sheet { display: none; }
}

/* ============ panel simplificado ============ */
/* menú «Más» al final de Mis paradas */
.more-menu { display: grid; gap: 8px; margin-top: 8px; }
.menu-title { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 2px; }
.menu-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; text-align: left;
  padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer; box-shadow: var(--shadow-sm);
}
.menu-row:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.mr-ico { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px; background: var(--surface-3); color: var(--muted); }
.mr-main { flex: 1; display: grid; gap: 1px; min-width: 0; }
.mr-main b { font-weight: 650; }
.mr-main small { font-size: .82rem; color: var(--muted); }
.mr-go { transform: rotate(180deg); color: var(--faint); }

/* secciones secundarias con «Volver» */
.subpage-head { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.subpage-head h2 { flex: 1; font-size: 1.15rem; font-weight: 750; }

/* tarjeta de parada: opciones plegadas */
.paused-tag { color: var(--muted); font-weight: 600; }
.watch-more { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.watch-more .switch-row { margin-top: 8px; padding-top: 8px; border-top: 0; }
.watch-actions.sub { border-top: 0; margin-top: 4px; }
.watch-actions [aria-expanded="true"] { color: var(--accent); }

/* actividad plegada */
.activity { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.activity summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 52px; padding: 0 16px; cursor: pointer; list-style: none; font-weight: 650;
}
.activity summary::-webkit-details-marker { display: none; }
.activity summary::after { content: "+"; font-size: 1.2rem; color: var(--muted); }
.activity[open] summary::after { content: "−"; }
.activity summary span:first-child { flex: 1; }
.act-count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--muted); font-size: .76rem; line-height: 22px; text-align: center; }
.act-count:empty { display: none; }
.activity .event-list { border: 0; border-radius: 0; box-shadow: none; border-top: 1px solid var(--line); }
.activity > .hint { padding: 0 16px 12px; margin: 0; }
.activity > .link-btn { margin: 0 8px 4px; }

/* varias rutas: leyenda de colores y etiquetas */
.lg-line { display: inline-block; width: 16px; height: 4px; border-radius: 2px; }
.map-legend span { font-weight: 700; color: var(--text); }
.bus-tag b { color: var(--rc, var(--accent)); margin-right: 4px; }
#map.multi:not(.labels-on) .stop-icon { display: none; }
.u-route { display: inline-grid; place-items: center; min-width: 28px; height: 20px; padding: 0 6px; margin-right: 6px; border-radius: 6px; color: #fff; font-size: .74rem; font-weight: 800; vertical-align: 1px; }

/* selector de ruta: una o varias */
.route-mode { justify-self: start; }
.route-dlg .hint { margin-top: -6px; }
.route-grid.many .route-chip { border-left: 5px solid var(--rc); }
.route-grid.many .route-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--rc) 14%, var(--surface)); border-color: var(--rc); }
.rc-check { position: absolute; left: 6px; top: 6px; display: none; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--rc); color: #fff; }
.rc-check .ic { width: 12px; height: 12px; stroke-width: 3; }
.route-chip[aria-pressed="true"] .rc-check { display: grid; }
#routeApply { width: 100%; }

/* ============ camión 3D ============ */
/* el punto del mapa (lat/lng) es el centro de la sombra, «en el suelo» */
.bus3d { position: absolute; left: 0; top: 0; color: var(--rc, var(--accent)); cursor: pointer; transform-origin: 0 0; transition: transform .2s; }
.bus3d-shadow {
  position: absolute; left: -24px; top: -7px; width: 48px; height: 14px; border-radius: 50%;
  background: radial-gradient(closest-side, rgb(0 0 0 / .34), rgb(0 0 0 / .12) 70%, transparent);
}
.bus3d-art { position: absolute; left: -33px; top: -40px; width: 66px; height: 46px; overflow: visible; filter: drop-shadow(0 0 1px rgb(255 255 255 / .9)); }
.bus3d.west .bus3d-art { transform: scaleX(-1); }
/* rumbo exacto: insignia con flecha junto a la parte trasera del camión */
.bus3d-dir {
  position: absolute; left: -52px; top: -21px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; border: 2px solid var(--rc, var(--accent));
  box-shadow: 0 1px 4px rgb(0 0 0 / .3); pointer-events: none;
}
.bus3d.west .bus3d-dir { left: 32px; }
.bus3d-dir svg { width: 13px; height: 13px; fill: var(--rc, var(--accent)); }
.bus3d .bus-tag { left: 30px; top: -34px; transform: none; }
.bus3d.west .bus-tag { left: auto; right: 30px; }
.bus3d.west .bus3d-dir + .bus-tag { right: 30px; }
.bus3d.near .bus3d-shadow { background: radial-gradient(closest-side, color-mix(in srgb, var(--hit) 55%, transparent), transparent); animation: ping 1.6s infinite; }
.bus3d.stale { opacity: .55; filter: grayscale(1); }
.bus3d.stale .bus3d-dir { display: none; }
#map.zoom-far .bus3d { transform: scale(.72); }
#map.zoom-far .bus3d .bus-tag { display: none; }

/* vistas de frente / espaldas: más angostas que la de lado */
.bus3d.v-n .bus3d-shadow, .bus3d.v-s .bus3d-shadow { left: -17px; width: 34px; }
.bus3d.v-n .bus3d-dir, .bus3d.v-s .bus3d-dir { left: -40px; }
.bus3d.v-n .bus-tag, .bus3d.v-s .bus-tag { left: 18px; }
