:root {
  --bg: #f4f6f3; --surface: #ffffff; --surface-2: #eef2ee; --ink: #10231b; --muted: #5a6a62; --line: #dfe6e0;
  --accent: #0a7d4b; --accent-ink: #ffffff; --bus: #0a7d4b; --tram: #1068d8; --warn: #b36b00; --bad: #c0392b;
  --shadow: 0 10px 30px rgba(16, 35, 27, .16), 0 1px 3px rgba(16, 35, 27, .10);
  --radius: 22px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --sheet-h: 42vh; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e1713; --surface: #15211b; --surface-2: #1c2b24; --ink: #eaf3ee; --muted: #9db0a6; --line: #263830;
    --accent: #35c486; --accent-ink: #06150e; --bus: #35c486; --tram: #5aa2ff; --warn: #f0b24a; --bad: #ff7b6b;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1713; --surface: #15211b; --surface-2: #1c2b24; --ink: #eaf3ee; --muted: #9db0a6; --line: #263830;
    --accent: #35c486; --accent-ink: #06150e; --bus: #35c486; --tram: #5aa2ff; --warn: #f0b24a; --bad: #ff7b6b;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); overscroll-behavior: none; }
body { font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, Roboto, system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, white); outline-offset: 2px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#map { position: fixed; inset: 0; }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: calc(var(--sheet-h) + 6px); transition: bottom .25s ease; }
.maplibregl-ctrl-attrib { font-size: 10px; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted) !important; border-radius: 8px; }
.maplibregl-ctrl-attrib a { color: inherit !important; }

/* ---------- barra superior ---------- */
.topbar { position: fixed; z-index: 5; left: 0; right: 0; top: 0; padding: calc(var(--safe-t) + 10px) 12px 0; display: grid; gap: 8px; pointer-events: none; max-width: 520px; }
.topbar > * { pointer-events: auto; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 16px; padding: 0 8px 0 14px; height: 48px; box-shadow: var(--shadow); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; height: 100%; font-size: 16px; color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search:focus-within { outline: 2px solid var(--accent); }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); }
.results { list-style: none; margin: -2px 0 0; padding: 6px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); max-height: 46vh; overflow: auto; }
.results li { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; cursor: pointer; }
.results li[aria-selected="true"], .results li:hover { background: var(--surface-2); }
.results .sub { color: var(--muted); font-size: 13px; }
.results .none { color: var(--muted); cursor: default; }
.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; flex: none; border-radius: 999px; border: 0; background: var(--surface); box-shadow: 0 2px 8px rgba(16, 35, 27, .14); white-space: nowrap; font-weight: 600; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chip.status { margin-left: auto; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.bus { background: var(--bus); } .dot.tram { background: var(--tram); border-radius: 3px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.pulse.ok { background: var(--accent); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); animation: pulse 2s infinite; }
.pulse.warn { background: var(--warn); } .pulse.bad { background: var(--bad); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.linechip { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 8px 8px 8px 10px; box-shadow: var(--shadow); width: fit-content; max-width: 100%; }
.linechip .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fab { position: fixed; z-index: 6; right: 12px; bottom: calc(var(--sheet-h) + 14px); width: 48px; height: 48px; border-radius: 16px; border: 0; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; transition: bottom .25s ease; }
.fab.on { color: var(--accent); }

/* ---------- panel inferior ---------- */
.sheet { position: fixed; z-index: 7; left: 0; right: 0; bottom: 0; height: var(--sheet-h); max-height: 92vh; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -8px 30px rgba(16, 35, 27, .18); display: flex; flex-direction: column; transition: height .25s cubic-bezier(.2, .8, .2, 1); touch-action: none; }
.sheet.dragging { transition: none; }
.grab { flex: none; height: 26px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.grab span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 14px calc(var(--safe-b) + 18px); touch-action: pan-y; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 8px; }
.sheet-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.sheet-head .hint { color: var(--muted); font-size: 13px; white-space: nowrap; }
.section-t { margin: 14px 2px 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.stop { background: var(--surface-2); border-radius: 16px; padding: 12px 12px 6px; margin-bottom: 10px; border: 2px solid transparent; }
.stop[aria-current="true"] { border-color: var(--accent); }
.stop-h { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 0 0 8px; text-align: left; }
.stop-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex: none; }
.stop-ic.bus { background: var(--bus); color: var(--accent-ink); } .stop-ic.tram { background: var(--tram); color: #fff; }
.stop-ic .ic { width: 18px; height: 18px; }
.stop-n { flex: 1; min-width: 0; }
.stop-n b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-n small { color: var(--muted); font-size: 13px; }
.fav { border: 0; background: none; color: var(--muted); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.fav[aria-pressed="true"] { color: #e8a317; } .fav[aria-pressed="true"] .ic { fill: currentColor; }
.arr { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.badge { min-width: 46px; padding: 3px 8px; border-radius: 9px; text-align: center; font-weight: 800; font-size: 15px; letter-spacing: .01em; }
.arr .to { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arr .to small { display: block; color: var(--muted); font-size: 12px; white-space: normal; line-height: 1.25; }
.eta { text-align: right; font-variant-numeric: tabular-nums; line-height: 1.05; }
.eta b { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.eta span { font-size: 13px; color: var(--muted); margin-left: 3px; }
.eta.soon b { color: var(--accent); }
.eta .src { display: block; font-size: 11px; font-weight: 600; margin-top: 2px; color: var(--muted); }
.eta.live .src { color: var(--accent); }
.empty { color: var(--muted); padding: 6px 0 10px; font-size: 14px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 14px 0 calc(var(--safe-b) + 10px); }
.note { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin: 0 0 10px; }
.cta { display: block; width: 100%; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 13px; margin-top: 8px; }
.cta.ghost { background: var(--surface-2); color: var(--ink); }
.back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--accent); font-weight: 700; padding: 4px 0 10px; }
.kv { display: grid; gap: 10px; margin: 8px 0 14px; }
.kv div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.kv dt { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kv dd { margin: 2px 0 0; font-weight: 600; }
.skeleton { height: 78px; border-radius: 16px; margin-bottom: 10px; background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in srgb, var(--surface-2) 60%, var(--surface)) 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: sh 1.4s infinite linear; }
@keyframes sh { to { background-position: -200% 0; } }

.toast { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(var(--sheet-h) + 70px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: 90vw; box-shadow: var(--shadow); }
.demo-ribbon { position: fixed; z-index: 30; top: calc(var(--safe-t) + 4px); right: -34px; transform: rotate(35deg); background: #e4572e; color: #fff; font-weight: 800; font-size: 11px; letter-spacing: .12em; padding: 3px 38px; pointer-events: none; }

@media (min-width: 900px) {
  :root { --sheet-h: 100vh; }
  .sheet { left: 12px; top: 12px; bottom: 12px; right: auto; width: 400px; height: auto !important; border-radius: var(--radius); }
  .grab { display: none; }
  .sheet-body { padding-top: 16px; }
  .topbar { left: 424px; }
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: 0; }
  .fab { bottom: 28px; }
  .toast { bottom: 28px; left: calc(50% + 200px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.search input::-webkit-search-cancel-button { display: none; }

/* ---------- avisos de llegada ---------- */
.bell, .bell-sp { width: 36px; height: 36px; flex: none; }
.bell { border: 0; background: none; color: var(--muted); border-radius: 50%; display: grid; place-items: center; }
.bell:hover { background: var(--surface-2); }
.bell[aria-pressed="true"] { color: var(--accent); } .bell[aria-pressed="true"] .ic { fill: currentColor; }
.bellmenu { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0 10px; font-size: 13px; color: var(--muted); }
.bellmenu .chip { padding: 5px 12px; }

/* ---------- capa de tráfico ---------- */
.dot.traffic { background: linear-gradient(90deg, #2fa83a 0 33%, #f5a623 33% 66%, #e0322b 66%); }
