/* SPDX-License-Identifier: AGPL-3.0-or-later · Trenalia */
:root {
  --bg: #f4f6fa; --panel: #ffffff; --panel-2: #eef2f8; --line: #d6dde8;
  --text: #16202f; --muted: #556378; --faint: #7d8899;
  --green: #12935c; --amber: #b57600; --red: #d93a32; --blue: #1f6fd1; --grey: #6b7686;
  --glass: rgba(255,255,255,.9); --glass-2: rgba(255,255,255,.96); --map-bg: #dfe6ef;
  --modal-bg: #ffffff; --side-bg: #ffffff; --backdrop: rgba(20,30,45,.45); --shadow: rgba(20,30,45,.18);
  --on: #16202f; --on-fg: #ffffff; --on-accent: #ffffff; --hover-line: #a9b6c9; --handle: #c3ccd9;
  --alert-red-bg: rgba(255,240,239,.97); --alert-amber-bg: rgba(255,248,232,.97); --err-fg: #b42318; --warn-fg: #c0362c; --orange: #c75a00;
  --top-fade: rgba(244,246,250,.96); --top-fade-0: rgba(244,246,250,0);
  color-scheme: light;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 10px;
}
/* Tema oscuro (botón sol/luna; por defecto, claro). La cabina va siempre en oscuro: es un panel de instrumentos */
:root[data-theme="dark"], .cab, .cab-dark {
  --bg: #0b111c; --panel: #111a29; --panel-2: #172234; --line: #22304a;
  --text: #e6ecf5; --muted: #8c9ab3; --faint: #5d6b85;
  --green: #3ecf8e; --amber: #f2b33d; --red: #ff5a52; --blue: #5aa9ff; --grey: #8b95a7;
  --glass: rgba(11,17,28,.88); --glass-2: rgba(11,17,28,.94); --map-bg: #070b12;
  --modal-bg: #0f1828; --side-bg: #0e1625; --backdrop: rgba(4,7,12,.72); --shadow: rgba(0,0,0,.45);
  --on: #e6ecf5; --on-fg: #0b111c; --on-accent: #06101f; --hover-line: #33476b; --handle: #3a4a66;
  --alert-red-bg: rgba(40,12,14,.94); --alert-amber-bg: rgba(38,28,8,.94); --err-fg: #ffb4ae; --warn-fg: #ff9a94; --orange: #ff9b3d;
  --top-fade: rgba(7,11,18,.96); --top-fade-0: rgba(7,11,18,0);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: .01em; }

.app { display: grid; grid-template-columns: 1fr 380px; height: 100vh; }
.main { display: grid; grid-template-rows: 1fr auto; min-width: 0; min-height: 0; }
.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--map-bg); }

/* Barra superior sobre el mapa */
.topbar {
  position: absolute; z-index: 600; left: 12px; right: 12px; top: 12px;
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; background: var(--glass); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 12px; }
.logo { width: 20px; height: 20px; fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.name { font-weight: 700; font-size: 16px; }
.live { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live.on i { background: var(--green); box-shadow: 0 0 0 0 rgba(62,207,142,.6); animation: pulse 2s infinite; }
.live.demo i { background: var(--amber); }
.live.off i { background: var(--red); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(62,207,142,0); } 100% { box-shadow: 0 0 0 0 rgba(62,207,142,0); } }

.search input {
  width: 210px; background: var(--glass); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r); padding: 8px 12px; font: 13px var(--sans); outline: none;
}
.search input:focus { border-color: var(--blue); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.chip {
  display: inline-flex; gap: 6px; align-items: center; padding: 5px 10px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted);
}
.chip b { font-family: var(--mono); font-weight: 700; color: var(--text); }
.chip.on { background: var(--on); color: var(--on-fg); border-color: var(--on); }
.chip.on b { color: var(--on-fg); }
.chip[disabled] { opacity: .45; cursor: not-allowed; }

/* Ficha del tren */
.card {
  max-height: calc(100% - 210px); overflow: auto;
  position: absolute; z-index: 700; left: 12px; top: 128px; width: 300px; max-width: calc(100% - 24px);
  background: var(--glass-2); border: 1px solid var(--line); border-left: 3px solid var(--red);
  border-radius: var(--r); padding: 14px 16px; box-shadow: 0 10px 30px var(--shadow);
}
.card.c-green { border-left-color: var(--green); }
.card.c-amber { border-left-color: var(--amber); }
.card h3 { margin: 0; font-size: 15px; }
.card .route { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; font-size: 13px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12.5px; }
.card dd.txt { font-family: var(--sans); font-size: 13px; }
.card .x { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1; }
.card dl.extra { margin-top: 5px; }
.card dl.extra[data-collapsed] { display: none; }
.card s.sched { color: var(--faint); font-size: 11px; margin-left: 4px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card .share { margin-top: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 12px; color: var(--muted); }

/* KPIs y leyenda */
.kpis {
  position: absolute; z-index: 600; left: 12px; bottom: 12px; display: flex; gap: 22px;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px;
}
.kpis div { display: flex; flex-direction: column; }
.kpis b { font-family: var(--mono); font-size: 22px; line-height: 1.1; }
.kpis span { color: var(--muted); font-size: 11px; }
.red { color: var(--red); }

.legend {
  position: absolute; z-index: 600; right: 12px; bottom: 12px; font-size: 11.5px; color: var(--muted);
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; display: grid; gap: 3px;
}
.legend div { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); } .dot.amber { background: var(--amber); }
.dot.red { background: var(--red); } .dot.grey { background: var(--grey); width: 7px; height: 7px; }
.dot.hollow { background: transparent; border: 2px solid var(--amber); width: 10px; height: 10px; }
.dot.fire { background: #ff7a1a; box-shadow: 0 0 0 3px rgba(255,122,26,.25); width: 9px; height: 9px; }
.dot.quake { background: #b07cff; width: 10px; height: 10px; }
.dot.wx { background: #4fc3f7; width: 9px; height: 9px; }
.dash { width: 16px; border-top: 2px dashed var(--red); display: inline-block; }

/* Paneles */
.panel { background: var(--panel); border-left: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.sub { margin: 4px 16px 10px; color: var(--faint); font-size: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.tabs.small { padding: 0; }
.tabs button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; font-size: 12px; color: var(--muted); }
.tabs button span { font-family: var(--mono); color: var(--faint); margin-left: 3px; }
.tabs button.on { background: var(--on); color: var(--on-fg); border-color: var(--on); }
.tabs button.on span { color: var(--on-fg); }

.incidents { border-left: 0; border-top: 1px solid var(--line); max-height: 34vh; display: flex; flex-direction: column; }
.inc-list { overflow: auto; padding: 0 16px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.inc { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; cursor: pointer; }
.inc:hover { border-color: var(--hover-line); }
.inc .t { display: flex; gap: 8px; align-items: flex-start; }
.inc .t i { margin-top: 5px; flex: none; }
.inc .t h4 { margin: 0; font-size: 13px; flex: 1; }
.inc .meta { text-align: right; font-size: 11px; color: var(--muted); white-space: nowrap; }
.inc .meta b { display: block; color: var(--amber); }
.inc.grave .meta b { color: var(--red); }
.inc p { margin: 6px 0 0 18px; color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.inc.open p { -webkit-line-clamp: unset; display: block; }
.inc .reg { margin: 6px 0 0 18px; color: var(--faint); font-size: 11px; }
.empty { color: var(--faint); font-size: 13px; padding: 4px 0 10px; }

.side { display: flex; flex-direction: column; min-height: 0; }
.arr-list { list-style: none; margin: 0; padding: 0 10px; overflow: auto; flex: 1; }
.arr {
  display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 8px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px;
}
.arr:hover, .arr.sel { background: var(--panel-2); }
.arr .d { font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--red); border-right: 2px solid currentColor; padding-right: 8px; text-align: right; }
.arr .d.amber { color: var(--amber); }
.arr h4 { margin: 0; font-size: 12.5px; font-weight: 600; }
.arr h4 small { color: var(--faint); font-family: var(--mono); font-weight: 500; margin-left: 4px; }
.arr .w { color: var(--faint); font-size: 11.5px; }
.arr .h { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.arr .h s { display: block; color: var(--faint); font-size: 11px; }
.more { margin: 8px 16px; background: none; border: 0; color: var(--blue); text-align: left; padding: 0; font-size: 12.5px; }
.foot { padding: 10px 16px 14px; color: var(--faint); font-size: 11px; border-top: 1px solid var(--line); }
.foot a { color: var(--muted); display: block; margin-top: 3px; }

/* Etiquetas del mapa */
.leaflet-tooltip.tlabel {
  background: var(--glass); border: 1px solid var(--line); color: var(--text); box-shadow: none;
  font: 600 10.5px var(--mono); padding: 1px 5px; border-radius: 4px;
}
.leaflet-tooltip.tlabel::before { display: none; }
.leaflet-tooltip.tlabel .r { color: var(--red); } .leaflet-tooltip.tlabel .a { color: var(--amber); }
.leaflet-tooltip.slabel { background: none; border: 0; box-shadow: none; color: var(--faint); font: 500 11px var(--sans); padding: 0; }
.leaflet-tooltip.slabel::before { display: none; }
.leaflet-container { font-family: var(--sans); }
.leaflet-control-attribution { background: var(--glass) !important; color: var(--faint) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--panel) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-top.leaflet-right { top: 128px; }

/* Botones auxiliares */
.search-btn { display: none; }
.recenter { width: 34px; height: 34px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line) !important; border-radius: 8px !important; cursor: pointer; }
.recenter svg { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; }
.recenter:hover { background: var(--panel-2); }
.sheet { display: none; }

/* ───────── Móvil y tableta vertical: mapa a pantalla completa + panel inferior deslizable ───────── */
@media (max-width: 1000px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { position: fixed; inset: 0; }
  .app { display: block; height: 100dvh; }
  .main { display: block; height: 100%; }
  .mapwrap { position: absolute; inset: 0; height: auto; min-height: 0; }
  .side, .incidents { display: none; }

  /* Barra superior compacta */
  .topbar {
    left: 0; right: 0; top: 0; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
    background: linear-gradient(to bottom, var(--top-fade) 60%, var(--top-fade-0));
    flex-wrap: wrap;
  }
  .brand { flex: 1; min-width: 0; padding: 6px 10px; gap: 8px; }
  .name { font-size: 15px; }
  .live { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search-btn {
    display: grid; place-items: center; width: 42px; height: 42px; flex: none;
    background: var(--glass); border: 1px solid var(--line); border-radius: var(--r);
  }
  .search-btn svg { width: 19px; height: 19px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
  .search { display: none; width: 100%; order: 3; }
  .search input { width: 100%; font-size: 16px; padding: 10px 12px; }
  .topbar.searching .search { display: block; }
  .topbar.searching .chips { display: none; }
  .chips {
    order: 4; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px 2px;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 24px), transparent);
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; padding: 7px 11px; font-size: 12.5px; }

  /* Controles del mapa */
  .leaflet-control-zoom { display: none; }
  .leaflet-top.leaflet-right { top: calc(112px + env(safe-area-inset-top)); }
  .leaflet-bottom { bottom: var(--sheet-visible, 0px); transition: bottom .25s ease; }
  .leaflet-control-attribution { font-size: 9.5px; max-width: 70vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Ficha del tren: flota sobre el panel */
  .card {
    top: auto; left: 8px; right: 8px; width: auto; bottom: calc(var(--sheet-visible, 0px) + 8px);
    max-height: calc(100dvh - var(--sheet-visible, 0px) - 140px); padding: 12px 14px; z-index: 900;
  }
  .card dl { gap: 4px 12px; font-size: 13px; }
  .card .x { width: 36px; height: 36px; top: 4px; right: 4px; font-size: 22px; }
  .card .share { padding: 8px 12px; font-size: 12.5px; }
  body.sheet-open .card { display: none; }
  body.card-open .tl-fab { display: none; }

  /* Panel inferior */
  .sheet {
    display: flex; flex-direction: column; position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0;
    background: var(--panel); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px var(--shadow); transition: transform .28s cubic-bezier(.2,.8,.2,1);
    will-change: transform;
  }
  .sh-grip { flex: none; touch-action: none; padding: 0 12px env(safe-area-inset-bottom); user-select: none; -webkit-user-select: none; }
  .sh-handle { display: block; width: 100%; height: 22px; background: none; border: 0; padding: 0; }
  .sh-handle span { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--handle); margin: 8px auto 0; }
  .sh-peek .kpis {
    position: static; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
    background: none; border: 0; padding: 4px 4px 10px; border-radius: 0;
  }
  .sh-peek .kpis b { font-size: 20px; }
  .sh-tabs { display: flex; gap: 6px; padding-bottom: 10px; }
  .sh-tabs button {
    flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 6px;
    font-size: 13px; font-weight: 600; color: var(--muted);
  }
  .sh-tabs button span { font-family: var(--mono); color: var(--faint); margin-left: 2px; }
  .sh-tabs button.on { background: var(--on); color: var(--on-fg); border-color: var(--on); }
  .sh-tabs button.on span { color: var(--on-fg); }
  .sh-body {
    flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--line); padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
  .sh-pane .panel-head { padding-top: 12px; }
  .sh-pane .tabs:not(.small) { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .sh-pane .tabs:not(.small)::-webkit-scrollbar { display: none; }
  .sh-pane .tabs button { flex: none; padding: 6px 10px; font-size: 12.5px; }
  .sh-pane .arr-list { overflow: visible; padding: 0 6px; }
  .arr { grid-template-columns: 54px 1fr auto; padding: 11px 6px; }
  .arr h4 { font-size: 13px; }
  .sh-pane .inc-list { grid-template-columns: 1fr; overflow: visible; }
  .sh-pane .legend { position: static; background: none; border: 0; padding: 12px 16px; font-size: 13px; gap: 8px; }
  .sh-pane .foot { border-top: 0; }
  .sh-info { margin: 14px 16px 0; color: var(--muted); font-size: 13px; }
  .more { padding: 10px 0; }

}

@media (max-width: 1000px) and (max-height: 520px) {
  /* Móvil en horizontal: panel lateral más bajo */
  .sh-peek .kpis { display: none; }
  .chips { display: none; }
  .leaflet-top.leaflet-right { top: 64px; }
}

/* Selector de mapa base */
.leaflet-control-layers { background: var(--panel) !important; color: var(--text); border: 1px solid var(--line) !important; border-radius: 8px !important; }
.leaflet-control-layers-toggle { filter: invert(1) hue-rotate(180deg) brightness(1.2); width: 32px !important; height: 32px !important; }
.leaflet-control-layers-expanded { padding: 8px 10px; font-size: 12.5px; }

/* ───────── Trenalito ───────── */
.tl-fab {
  position: fixed; z-index: 1100; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px;
  background: var(--blue); color: var(--on-accent); border: 0; border-radius: 999px; padding: 11px 18px 11px 14px;
  font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px var(--shadow);
}
.tl-fab { padding-left: 7px; }
/* Trenalito: locomotora con bocadillo (public/icons/trenalito.svg), siempre sobre círculo blanco */
.tl-ava { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.tl-ava img { width: 30px; height: 30px; display: block; }
.tl-ava-lg { width: 44px; height: 44px; margin-right: 4px; }
.tl-ava-lg img { width: 36px; height: 36px; }
.tl-fab:hover { filter: brightness(1.08); }
body.tl-open .tl-fab { display: none; }

.tl {
  position: fixed; z-index: 1200; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100vw;
  display: flex; flex-direction: column; background: var(--side-bg); border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px var(--shadow); animation: tlIn .18s ease-out;
}
@keyframes tlIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.tl[hidden] { display: none; }
.tl-head { display: flex; align-items: flex-start; gap: 6px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line); }
.tl-head > div { flex: 1; }
.tl-head h2 { font-size: 16px; }
.tl-head p { margin: 2px 0 0; color: var(--faint); font-size: 12px; }
.tl-icon { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; width: 32px; height: 32px; font-size: 17px; line-height: 1; color: var(--muted); }
.tl-icon:hover { color: var(--text); }

.tl-log { flex: 1; overflow: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.tl-msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.tl-msg p { margin: 0 0 6px; } .tl-msg p:last-child { margin-bottom: 0; }
.tl-msg ul { margin: 4px 0 6px; padding-left: 18px; } .tl-msg li { margin: 2px 0; }
.tl-msg.user { align-self: flex-end; background: var(--blue); color: var(--on-accent); border-bottom-right-radius: 4px; }
.tl-msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.tl-msg.error { border-color: rgba(255,90,82,.5); color: var(--err-fg); }
.tl-train { font: 700 12px var(--mono); background: rgba(90,169,255,.14); color: var(--blue); border: 1px solid rgba(90,169,255,.35); border-radius: 5px; padding: 0 5px; }
.tl-train:hover { background: rgba(90,169,255,.28); }
.tl-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.tl-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: tlDot 1s infinite ease-in-out; }
.tl-dots i:nth-child(2) { animation-delay: .15s; } .tl-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes tlDot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.tl-sugs { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 8px; }
.tl-sugs button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 5px 10px; font-size: 12px; text-align: left; }
.tl-sugs button:hover { border-color: var(--blue); color: var(--text); }

.tl-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px; border-top: 1px solid var(--line); }
.tl-form textarea {
  flex: 1; resize: none; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; font: 14px/1.4 var(--sans); outline: none; max-height: 120px;
}
.tl-form textarea:focus { border-color: var(--blue); }
.tl-form button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--blue); color: var(--on-accent); font-size: 16px; }
.tl-form button:disabled { opacity: .4; cursor: wait; }
.tl-note { margin: 0; padding: 0 14px 12px; color: var(--faint); font-size: 11px; }

@media (max-width: 1000px) {
  .tl { width: 100vw; border-left: 0; }
  .tl-fab { right: 12px; padding: 12px; bottom: calc(var(--sheet-visible, 0px) + 12px); transition: bottom .25s ease; }
  body.sheet-full .tl-fab { display: none; }
  /* Móvil: solo la locomotora (sin texto), grande y con aro azul para que se reconozca */
  .tl-fab > span:not(.tl-ava) { display: none; }
  .tl-fab { padding: 4px; }
  .tl-fab .tl-ava { width: 50px; height: 50px; }
  .tl-fab .tl-ava img { width: 42px; height: 42px; }
  .tl-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

/* Banner y ventana de fuentes */
.modal { position: fixed; inset: 0; z-index: 2000; background: var(--backdrop); display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.modal[hidden] { display: none; }
.modal-box {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom))); overflow: auto;
  background: var(--modal-bg); border: 1px solid var(--line); border-radius: 14px; padding: 22px 22px 18px; box-shadow: 0 20px 60px var(--shadow);
}
.modal-x { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; background: none; border: 0; color: var(--muted); font-size: 22px; }
.modal h2 { font-size: 19px; margin: 0 0 4px; }
.modal .purpose { font-size: 16px; line-height: 1.5; color: var(--text); margin: 10px 0 14px; padding: 12px 14px; border-left: 3px solid var(--blue); background: rgba(90,169,255,.08); border-radius: 0 8px 8px 0; }
.modal p { color: var(--muted); font-size: 13.5px; }
.modal .ok { margin-top: 8px; background: var(--blue); color: var(--on-accent); border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 700; font-size: 14px; }
.src-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.src-list li { display: grid; grid-template-columns: 12px 1fr; gap: 8px; align-items: start; font-size: 13px; }
.src-list li i { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; background: var(--faint); }
.src-list li i.s-ok { background: var(--green); } .src-list li i.s-bad { background: var(--red); } .src-list li i.s-demo { background: var(--amber); }
.src-list small { display: block; color: var(--faint); }
.prec { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--muted); }
.linkbtn { display: block; background: none; border: 0; padding: 0; margin-top: 4px; color: var(--muted); text-decoration: underline; font-size: 11px; }
.risk-group h5 { margin: 4px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.inc.lvl-red .meta b { color: var(--red); } .inc.lvl-orange .meta b { color: var(--orange); } .inc.lvl-yellow .meta b { color: var(--amber); }
.card .est { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 700; color: var(--amber); border: 1px solid rgba(242,179,61,.5); border-radius: 4px; padding: 0 4px; vertical-align: middle; }

/* ── Histórico ─────────────────────────────────────────────── */
.hist-f { display: flex; gap: 8px; margin: 4px 0 12px; }
.hist-f input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.hist-f button { background: var(--blue); color: var(--on-accent); border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; }
.hist-day { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 6px 0 10px; }
.hist-l { list-style: none; margin: 0 0 8px; padding: 0; }
.hist-l li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.hist-l small { color: var(--muted); }
.hist-ex { color: var(--muted); font-size: 12px; margin-top: 3px; }
.hist-l .tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; margin-right: 4px; text-transform: uppercase; letter-spacing: .02em; border: 1px solid var(--line); }
.hist-l .tag.c-red { color: var(--red); border-color: rgba(255,90,82,.45); background: rgba(255,90,82,.08); }
.hist-l .tag.c-amber { color: var(--amber); border-color: rgba(242,179,61,.45); background: rgba(242,179,61,.08); }
.hist-day .c-red, .hist-l .c-red { color: var(--red); } .hist-day .c-amber { color: var(--amber); }

/* ── Vista de cabina (panel de instrumentos) ─────────────────── */
.cab-btn { display: inline-flex; align-items: center; gap: 6px; flex: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px 6px 9px; font-weight: 600; font-size: 13px; }
.cab-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cab-btn:hover { border-color: var(--blue); }
body.cab-open .cab-btn { border-color: var(--blue); color: var(--blue); }
body.cab-open .cab-btn svg { stroke: var(--blue); }
body.cab-open .tl-fab { display: none; }

.cab { position: fixed; z-index: 1150; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100vw; display: flex; flex-direction: column;
  background: #0a111d; border-left: 1px solid var(--line); box-shadow: -12px 0 32px var(--shadow); animation: tlIn .18s ease-out; }
.cab[hidden] { display: none; }
.cab.alarm { border-left-color: var(--red); }
.cab-h { display: flex; align-items: center; gap: 6px; padding: 12px 12px 8px 16px; }
.cab-title { flex: 1; min-width: 0; }
.cab-title b { display: block; font-size: 20px; letter-spacing: .01em; font-family: var(--mono); }
.cab-sub { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab.following .cab-sub { cursor: pointer; }
.cab-ib { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; font-size: 22px; line-height: 1; color: var(--muted); }
.cab-ib svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cab-ib.off svg { stroke: var(--faint); }
.cab-expand { display: none; }
.cab-note { margin: 0 16px 6px; color: #e9c47a; font-size: 11.5px; }
.cab-f { display: flex; gap: 8px; padding: 4px 16px 8px; }
.cab.following .cab-f { display: none; }
.cab-f input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
.cab-f button { background: var(--blue); color: var(--on-accent); border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; font-size: 15px; }

.cab-alert { margin: 0 12px 8px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--amber); background: rgba(242,179,61,.12); }
.cab-alert[hidden] { display: none; }
.cab-alert.alta { border-color: var(--red); background: rgba(255,90,82,.16); animation: cabPulse 1.2s ease-in-out infinite; }
.cab-alert .ca-t { font-weight: 800; font-size: 16px; color: var(--red); letter-spacing: .02em; }
.cab-alert.media .ca-t { color: var(--amber); }
.cab-alert .ca-t small { font-weight: 600; font-size: 12px; color: var(--muted); }
.cab-alert .ca-m { font-size: 14px; margin-top: 4px; }
.cab-alert .ca-d { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.35; }
@keyframes cabPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,90,82,0); } 50% { box-shadow: 0 0 0 6px rgba(255,90,82,.25); } }

.cab-b { flex: 1; overflow-y: auto; padding: 0 12px 20px; -webkit-overflow-scrolling: touch; }
.cab-empty, .cab-none { color: var(--muted); font-size: 13px; margin: 6px 4px 10px; }
.g-l { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.g-u { display: block; color: var(--muted); font-size: 12.5px; }
.g-u s { color: var(--faint); }
.g-u i { font-style: normal; }
.cab-gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.cab-gauges > div, .cab-next, .cab-near { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.g-speed b, .g-delay b { display: block; font-family: var(--mono); font-size: 40px; line-height: 1.05; font-weight: 700; letter-spacing: -.02em; }
.g-delay b { font-size: 30px; padding-top: 6px; white-space: nowrap; }
.cab-next { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.cab-next b { display: block; font-size: 18px; }
.cab-next-r { text-align: right; flex: none; }
.cab-next-r b { font-family: var(--mono); font-size: 22px; }
.cab-near { margin-bottom: 8px; }
.cab-near.warn { border-color: rgba(242,179,61,.55); }
.cab-near-row { display: flex; align-items: baseline; gap: 10px; }
.cab-near-row b { font-family: var(--mono); font-size: 26px; flex: none; }
.cab-near-row span { font-size: 13px; color: var(--muted); }
.cab-near-t { margin-top: 2px; color: var(--amber); font-size: 13px; font-weight: 600; }
.cab-rel { font-size: 12px; padding: 6px 10px; border-radius: 8px; margin: 6px 0; }
.cab-rel.ok { background: rgba(62,207,142,.08); color: var(--green); }
.cab-rel.low { background: rgba(255,90,82,.08); color: var(--warn-fg); }
.cab-d { border-top: 1px solid var(--line); }
.cab-d summary { cursor: pointer; padding: 12px 4px; font-weight: 600; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 6px; }
.cab-d summary::-webkit-details-marker { display: none; }
.cab-d summary::before { content: '▸'; color: var(--faint); transition: transform .15s; }
.cab-d[open] summary::before { transform: rotate(90deg); }
.cab-d summary small { color: var(--faint); font-weight: 400; }
.cab-l { list-style: none; margin: 0 0 8px; padding: 0 4px; }
.cab-l li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.cab-l li:last-child { border-bottom: 0; }
.cab-l small { color: var(--muted); }
.cab-close { margin-top: 3px; font-size: 12.5px; color: var(--blue); }
.cab-close.warn { color: var(--amber); font-weight: 600; }
.cab .tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); margin-right: 4px; }
.cab .tag.c-red { color: var(--red); border-color: rgba(255,90,82,.4); }
.cab .tag.c-amber { color: var(--amber); border-color: rgba(242,179,61,.4); }
.cab .c-red { color: var(--red); } .cab .c-amber { color: var(--amber); } .cab .c-green { color: var(--green); }
.cab-strip { width: 100%; height: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 4px; display: block; }
.cab-strip .trk { fill: #4a6390; }
.cab-strip .tick { stroke: var(--faint); stroke-width: 1; }
.cab-strip .lbl { fill: var(--muted); font-size: 10px; text-anchor: middle; font-family: var(--sans); }
.cab-strip .lbl.l { text-anchor: start; font-size: 10.5px; }
.cab-strip .st { fill: #8c9ab3; }
.cab-strip .me { fill: var(--blue); stroke: #fff; stroke-width: 1.5; }
.cab-strip .ot circle { stroke: #0b111c; stroke-width: 1.5; fill: var(--grey); }
.cab-strip .ot.mismo circle { fill: var(--amber); } .cab-strip .ot.contrario circle { fill: var(--green); } .cab-strip .ot.parado circle { fill: var(--red); }
.cab-strip .ot.est circle { fill-opacity: .15; stroke: var(--amber); stroke-width: 2; stroke-dasharray: 3 2; }
.cab-strip .ot-l { fill: var(--text); font-size: 10px; text-anchor: middle; font-family: var(--mono); }
.cab-strip .hz circle { fill: rgba(242,179,61,.2); stroke: var(--amber); stroke-width: 1.5; }
.cab-strip .hz text { fill: var(--amber); font-size: 12px; font-weight: 800; text-anchor: middle; }
.cab-strip .hz.alto circle { fill: rgba(255,90,82,.2); stroke: var(--red); } .cab-strip .hz.alto text { fill: var(--red); }
.cab-strip .lg-me { fill: var(--blue); } .cab-strip .lg-s { fill: var(--amber); } .cab-strip .lg-c { fill: var(--green); } .cab-strip .lg-p { fill: var(--red); } .cab-strip .lg-h { fill: var(--amber); font-weight: 800; }
.cab-foot { color: var(--faint); font-size: 11px; margin: 12px 4px 0; line-height: 1.4; }

@media (max-width: 760px) {
  /* Móvil: panel inferior que deja ver el tren; botón para pantalla completa */
  .cab { top: auto; width: 100vw; height: 66dvh; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 32px var(--shadow); animation: cabUp .2s ease-out; }
  .cab.full { top: 0; height: 100dvh; border-radius: 0; }
  .cab.alarm { border-top: 3px solid var(--red); }
  .cab-expand { display: grid; }
  .cab-h { padding: 10px 10px 6px 14px; }
  .cab-title b { font-size: 19px; }
  .cab-note { margin: 0 14px 6px; }
  .cab-b { padding: 0 10px calc(16px + env(safe-area-inset-bottom)); }
  .g-speed b { font-size: 44px; }
  .cab-btn span { display: none; }
  .cab-btn { padding: 6px; }
  body.cab-open .card, body.cab-open .sheet { display: none !important; }
}
@media (max-width: 760px) and (max-height: 600px) { .cab { height: 82dvh; } }
@keyframes cabUp { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ── Ficha del tren: acciones principales ───────────────────── */
.card-cta { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin: 10px 0 8px; }
.card-cta button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; padding: 10px 12px; font-weight: 700; font-size: 14px; border: 1px solid var(--line); min-height: 42px; }
.cta-cab { background: var(--blue); color: var(--on-accent); border-color: var(--blue) !important; }
.cta-cab svg { width: 18px; height: 18px; fill: none; stroke: var(--on-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cta-more { background: var(--panel-2); color: var(--text); }
.card-alert { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--red); background: rgba(255,90,82,.10); border: 1px solid rgba(255,90,82,.4); }
.card-alert.media { color: var(--amber); background: rgba(242,179,61,.10); border-color: rgba(242,179,61,.4); }
.card-alert .linkbtn { font-weight: 700; color: inherit; text-decoration: underline; }
.card-anom { margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; color: var(--amber); background: rgba(242,179,61,.08); }
.card-anom.desviado { color: var(--warn-fg); background: rgba(255,90,82,.08); }

/* ── Barra de alerta de alcance (modo normal) ───────────────── */
.alertbar { position: absolute; z-index: 650; left: 12px; right: 12px; max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: var(--alert-red-bg); border: 2px solid var(--red); box-shadow: 0 10px 28px var(--shadow); backdrop-filter: blur(6px); }
.alertbar[hidden] { display: none; }
.alertbar.media { background: var(--alert-amber-bg); border-color: var(--amber); }
.alertbar.alta { animation: cabPulse 1.4s ease-in-out infinite; }
.ab-ic { font-size: 22px; color: var(--red); flex: none; }
.alertbar.media .ab-ic { color: var(--amber); }
.ab-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ab-tx b { font-size: 14px; }
.ab-tx span { font-size: 13px; color: var(--text); }
.ab-tx small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.ab-act { display: flex; gap: 6px; flex: none; }
.ab-act button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-weight: 700; font-size: 13px; }
.ab-act .ab-x { padding: 8px 10px; color: var(--muted); }
/* El latido va en un pseudo-elemento: Leaflet posiciona el marcador con transform y no se puede animar ese mismo transform */
.conf-pulse { position: relative; }
.conf-pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: rgba(255,90,82,.35); border: 2px solid var(--red); animation: confPulse 1.4s ease-out infinite; }
.conf-pulse.media::after { background: rgba(242,179,61,.3); border-color: var(--amber); }
@keyframes confPulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }

/* ── Panel de capas ──────────────────────────────────────────── */
.layers-ctl { position: relative; }
.layers-btn { width: 40px; height: 40px; display: grid; place-items: center; background: var(--panel) !important; border: 1px solid var(--line) !important; border-radius: 10px !important; }
.layers-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linejoin: round; }
.layers-btn[aria-expanded="true"] { border-color: var(--blue) !important; }
.layers-panel { position: absolute; right: 0; top: 46px; width: 440px; max-width: calc(100vw - 24px); max-height: 60vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 8px; box-shadow: 0 12px 32px var(--shadow); color: var(--text); z-index: 1000; }
.layers-panel[hidden] { display: none; }
.lp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 4px; }
.lp-h { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 3px; font-weight: 600; }
.lp-row { display: flex; align-items: center; gap: 9px; padding: 6px 10px; font-size: 13px; line-height: 1.25; cursor: pointer; border-radius: 8px; }
.lp-row:hover { background: var(--panel-2); }
.lp-row input { width: 16px; height: 16px; accent-color: var(--blue); flex: none; margin: 0; }
.lp-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 0 4px; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.lp-foot > div:only-child { grid-column: 1 / -1; }
.lp-base[hidden] { display: none; }
.lp-seg { display: flex; gap: 2px; margin: 2px 10px 4px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.lp-seg label { flex: 1; cursor: pointer; }
.lp-seg input { position: absolute; opacity: 0; pointer-events: none; }
.lp-seg span { display: block; text-align: center; padding: 6px 6px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.lp-seg input:checked + span { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }
.lp-seg input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.lp-note { font-size: 11.5px; color: var(--faint); padding: 4px 10px 2px; line-height: 1.35; }

@media (max-width: 760px) {
  .card-cta button { min-height: 44px; font-size: 14.5px; }
  .alertbar { left: 8px; right: 8px; padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .ab-tx small { display: none; }
  .ab-act { width: 100%; }
  .ab-act button { flex: 1; padding: 9px 8px; }
  .ab-act .ab-x { flex: 0 0 44px; }
  .layers-panel { position: fixed; right: 8px; left: 8px; top: auto; bottom: calc(var(--sheet-visible, 0px) + 12px); width: auto; max-height: 60dvh; }
  .lp-row { padding: 9px 10px; font-size: 13.5px; }
}
/* La ficha del tren baja si hay una alerta visible (escritorio) */
@media (min-width: 761px) {
  body.has-alert .card { top: calc(128px + var(--alert-h, 0px)); max-height: calc(100% - 140px - var(--alert-h, 0px)); overflow-y: auto; }
  .card-cta { grid-template-columns: 1.5fr 1fr; }
  .card-cta button { font-size: 13.5px; white-space: nowrap; padding: 9px 10px; }
}
@media (max-width: 760px) {
  .alertbar { right: 60px; }
  body.cab-open .alertbar { display: none; }
}

/* ── Formulario de colaboración en Trenalito ─────────────────── */
.tl-collab { width: 100%; }
.collab-f { display: flex; flex-direction: column; gap: 8px; }
.collab-f label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.collab-f input, .collab-f select, .collab-f textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; }
.collab-f .chk { flex-direction: row; align-items: flex-start; gap: 8px; }
.collab-f .chk input { margin-top: 2px; accent-color: var(--blue); }
.collab-f .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.collab-f button { background: var(--blue); color: var(--on-accent); border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 700; align-self: flex-start; }
.collab-f button:disabled { opacity: .6; }
.collab-st { margin: 0; font-size: 12.5px; color: var(--amber); }
.tl-msg.tl-collab { max-width: 100%; }

/* ── Menú al pulsar un tren ──────────────────────────────────── */
.train-menu .leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px var(--shadow); padding: 0; }
.train-menu .leaflet-popup-content { margin: 12px 14px; font: 14px/1.4 var(--sans); }
.train-menu .leaflet-popup-tip { background: var(--panel); border: 1px solid var(--line); }
.train-menu a.leaflet-popup-close-button { color: var(--muted); font-size: 22px; width: 32px; height: 32px; top: 4px; right: 4px; }
.tm-h { display: flex; align-items: center; gap: 8px; padding-right: 22px; }
.tm-h b { font-size: 16px; font-family: var(--mono); }
.tm-h .est { font-size: 10.5px; font-weight: 700; color: var(--amber); border: 1px solid rgba(242,179,61,.5); border-radius: 4px; padding: 0 5px; }
.tm-r { color: var(--muted); font-size: 12.5px; margin: 2px 0 10px; }
.tm-d.red { color: var(--red); } .tm-d.amber { color: var(--amber); } .tm-d.green { color: var(--green); }
.tm-a { color: var(--red); font-size: 12.5px; font-weight: 600; margin: -4px 0 10px; }
.tm-b { display: grid; grid-template-columns: 1fr; gap: 8px; }
.tm-b button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 10px; font-weight: 700; font-size: 14.5px; border: 1px solid var(--line); cursor: pointer; }
.tm-cab { background: var(--blue); color: var(--on-accent); border-color: var(--blue) !important; }
.tm-cab svg { width: 18px; height: 18px; fill: none; stroke: var(--on-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tm-det { background: var(--panel-2); color: var(--text); }

/* ── Campana: historial de alertas ───────────────────────────── */
.bell-btn { position: relative; flex: none; width: 38px; height: 38px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; }
.bell-btn svg { width: 19px; height: 19px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bell-btn.on { border-color: var(--red); }
.bell-btn.on svg { stroke: var(--red); }
.bell-n { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.bell-n[hidden] { display: none; }
.hist-note { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; }
.al-row .tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; margin-right: 4px; border: 1px solid var(--line); }
.al-row .tag.c-red { color: var(--red); border-color: rgba(255,90,82,.45); background: rgba(255,90,82,.08); }
.al-row .tag.c-amber { color: var(--amber); border-color: rgba(242,179,61,.45); background: rgba(242,179,61,.08); }
.al-row b { display: block; margin-top: 3px; }

/* Menú del tren: tres opciones */
.tm-b2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tm-det svg { width: 17px; height: 17px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tm-a.amber { color: var(--amber); }
@media (max-width: 760px) {
  .bell-btn { width: 44px; height: 44px; }
}

/* Esquema de vía de la cabina: escala y agrupación */
.cab-strip-w { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 4px; padding: 6px 6px 4px; }
.cab-strip-w .cab-strip { border: 0; margin: 0; background: transparent; }
.cab-scale { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.cab-scale button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; font-size: 11.5px; color: var(--muted); min-height: 28px; }
.cab-scale button.on { color: var(--on-accent); background: var(--blue); border-color: var(--blue); font-weight: 700; }
.cab-legend { font-size: 11px; color: var(--muted); padding: 2px 6px; line-height: 1.6; }
.cab-legend span { font-weight: 800; margin-left: 4px; }
.cab-legend .lg-me { color: var(--blue); margin-left: 0; } .cab-legend .lg-s { color: var(--amber); } .cab-legend .lg-c { color: var(--green); } .cab-legend .lg-p { color: var(--red); } .cab-legend .lg-h { color: var(--amber); }
.cab-strip .ot.mixto circle { fill: #8b95a7; }
.cab-strip .ot.cl circle { stroke: #fff; stroke-width: 1.5; }
.cab-strip .cl-n { fill: var(--on-accent); font-size: 10.5px; font-weight: 800; text-anchor: middle; font-family: var(--sans); pointer-events: none; }
/* Con el menú de un tren abierto, la barra de alerta se aparta y no captura pulsaciones */
body.tm-open .alertbar { visibility: hidden; }

/* Menú del tren en móvil: panel inferior */
.tm-sheet { position: fixed; z-index: 1300; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: 0 -14px 34px var(--shadow); padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: cabUp .18s ease-out; }
.tm-sheet[hidden] { display: none; }
.tm-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 10px; }
.tm-x { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 22px; line-height: 1; }
.tm-sheet .tm-h b { font-size: 18px; }
.tm-sheet .tm-b button { min-height: 50px; font-size: 15.5px; }
body.tm-open .sheet { visibility: hidden; }
body.tm-open .tl-fab { display: none; }

/* Perfil del terreno en la cabina */
.cab-prof { display: block; width: 100%; height: auto; margin-top: -6px; }
.cab-prof .pf-area { fill: rgba(90,169,255,.14); }
.cab-prof .pf-line { fill: none; stroke: #7fb6ff; stroke-width: 1.6; stroke-linejoin: round; }
.cab-prof .pf-me { stroke: var(--blue); stroke-width: 1.5; stroke-dasharray: 3 3; }
.cab-prof .pf-band.rampa { fill: rgba(242,179,61,.18); }
.cab-prof .pf-band.pendiente { fill: rgba(62,207,142,.16); }
.cab-prof .lbl { fill: var(--faint); font-size: 9.5px; font-family: var(--sans); }
.cab-scale { align-items: center; }
.cab-grade { margin-right: auto; font-size: 12.5px; font-weight: 700; color: var(--muted); padding-left: 4px; }
.cab-grade.up { color: var(--amber); } .cab-grade.down { color: var(--green); }
.cab-legend .lg-r { color: rgba(242,179,61,.8); } .cab-legend .lg-d { color: rgba(62,207,142,.8); }
@media (max-width: 760px) {
  .cab-scale { gap: 3px; }
  .cab-grade { flex-basis: 100%; padding: 0 2px 4px; }
  .cab-scale button { padding: 3px 7px; font-size: 11px; }
}

/* ── Vista 3D de cabina ──────────────────────────────────────── */
.cab-3dbtn { font-weight: 800; font-size: 13px; color: var(--text); width: auto; padding: 0 10px; }
.cab-3dbtn.on { background: var(--blue); color: var(--on-accent); border-color: var(--blue); }
/* Sprint 230: el botón «3D» parpadea hasta que se pulsa por primera vez; el mapa 2D ocupa menos alto en el móvil */
.cab-3dbtn.blink { animation: cab3dBlink 1.1s ease-in-out infinite; border-color: var(--blue); color: var(--blue); }
@keyframes cab3dBlink { 0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, .0); background: var(--panel); } 50% { box-shadow: 0 0 0 4px rgba(37, 99, 235, .35); background: rgba(37, 99, 235, .16); } }
@media (prefers-reduced-motion: reduce) { .cab-3dbtn.blink { animation: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .35); } }
.cab.map2d .cab-3d { height: 240px; }
@media (min-width: 761px) { .cab.map2d.with3d .cab-3d { height: 300px; } }
.c3d-me.flat svg { filter: drop-shadow(0 0 3px rgba(0,0,0,.6)); }
.cab-3d { position: relative; height: 300px; margin: 0 12px 8px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #0b111c; flex: none; }
.cab-3d[hidden] { display: none; }
.c3d-msg { color: var(--muted); font-size: 13px; padding: 16px; margin: 0; }
.c3d-me { width: 34px; height: 34px; filter: drop-shadow(0 2px 4px var(--shadow)); }
.c3d-me svg { width: 100%; height: 100%; fill: var(--blue); stroke: #fff; stroke-width: 2.5; stroke-linejoin: round; }
.c3d-lbl { background: var(--glass); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font: 600 11px/1.25 var(--sans); color: var(--text); white-space: nowrap; pointer-events: none; text-align: center; }
.c3d-lbl small { display: block; font-weight: 400; color: var(--muted); font-size: 10px; }
.c3d-lbl.conf { border-color: var(--red); color: var(--err-fg); }
.c3d-lbl.cross { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.c3d-follow { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 2; display: none; background: var(--blue); color: var(--on-accent); border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 13px; box-shadow: 0 6px 16px rgba(0,0,0,.4); }
.cab-3d.free .c3d-follow { display: block; }
.cab-3d .maplibregl-ctrl-attrib { font-size: 10px; background: var(--glass); color: var(--muted); }
.cab-3d .maplibregl-ctrl-attrib a { color: var(--muted); }
.cab-3d .maplibregl-ctrl-group { background: var(--panel); }
.cab-3d .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(1.4); }
@media (min-width: 761px) { .cab.with3d { width: 520px; } .cab.with3d .cab-3d { height: 340px; } }
@media (max-width: 760px) { .cab.with3d .cab-3d { height: 44dvh; margin: 0 8px 8px; } }

/* Silenciar avisos */
.alertbar { flex-wrap: wrap; }
.ab-sil { flex-basis: 100%; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding-left: 32px; cursor: pointer; user-select: none; }
.ab-sil input, .al-sil input { width: 16px; height: 16px; accent-color: var(--amber); margin: 0; }
.al-sil { display: inline-flex; align-items: center; gap: 5px; margin-left: 10px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tag.sil { background: rgba(140,154,179,.18); color: var(--muted); }
@media (max-width: 760px) { .ab-sil { padding-left: 0; padding-top: 2px; } .al-sil { margin: 6px 0 0; display: flex; } }

/* Créditos */
.cred-btn svg { width: 20px; height: 20px; }
.cr-notice { background: rgba(90,169,255,.08); border: 1px solid rgba(90,169,255,.3); border-radius: 10px; padding: 10px 12px; margin: 4px 0 12px; }
.cr-author { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.cr-author b { font-size: 15px; } .cr-author span { color: var(--muted); font-size: 13px; }
.cr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cr-list li { display: flex; flex-direction: column; gap: 1px; padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.cr-list span { color: var(--muted); font-size: 13px; } .cr-list small { color: var(--muted); font-size: 12px; }
.cr-author a, .cr-list a { color: var(--blue, #5aa9ff); text-decoration: none; }
.cr-author a:hover, .cr-list a:hover { text-decoration: underline; }
.cr-list b a { color: var(--text); text-decoration: underline; text-decoration-color: rgba(90,169,255,.6); text-underline-offset: 3px; }
.modal-box a { color: var(--blue); }

.ab-sils { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 18px; padding-left: 32px; }
.ab-sils .ab-sil { flex-basis: auto; padding: 0; }
.al-all { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 12px; margin: 4px 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 13px; cursor: pointer; }
.al-all input { width: 17px; height: 17px; accent-color: var(--amber); margin: 0; }
.al-all.on { border-color: var(--amber); }
.al-all small { color: var(--muted); }
.bell-btn.muted { border-style: dashed; }
.bell-btn.muted::after { content: ''; position: absolute; width: 24px; height: 2px; background: var(--muted); transform: rotate(-45deg); border-radius: 2px; }
.bell-btn.muted.on::after { background: var(--red); }
@media (max-width: 760px) { .ab-sils { padding-left: 0; gap: 2px 14px; } }

/* Botón de tema */
.theme-btn svg { width: 19px; height: 19px; }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
/* Ajustes del tema claro */
.cab { color: var(--text); }

/* Trenes según horario oficial (sin datos en vivo) */
.dot.sched { background: transparent; border: 2px dashed var(--grey); width: 10px; height: 10px; }
.est.sch { color: var(--muted); border-color: var(--line); }
.card-sched { margin: 0 0 8px; padding: 7px 10px; border-radius: 8px; font-size: 12.5px; color: var(--muted); background: var(--panel-2); border: 1px dashed var(--line); }

.tm-d.none, dd.muted { color: var(--muted) !important; font-weight: 500; }
.card.c-none { border-left-color: var(--grey); }
.lang-btn { font-weight: 800; font-size: 12.5px; letter-spacing: .02em; color: var(--text); }

/* Vista de andén: botón de la barra superior y ventana de las estaciones del mapa */
a.and-btn { color: var(--text); text-decoration: none; }
.st-pop { display: grid; gap: 8px; min-width: 170px; font: 13px var(--sans); }
.st-pop b { font-size: 14px; }
.st-pop-btn { display: inline-flex; justify-content: center; min-height: 36px; align-items: center; padding: 0 12px; border-radius: 9px; background: var(--blue); color: var(--on-accent) !important; text-decoration: none; font-weight: 700; }
.slabel.leaflet-interactive { cursor: pointer; }
/* En móvil el botón de créditos deja sitio al de la vista de andén (los créditos siguen en «Leyenda» → pie) */
@media (max-width: 1500px) { a.and-btn span { display: none; } a.and-btn { padding: 6px; } }
/* «Horarios» es la entrada principal a horarios y viajes: su etiqueta se ve siempre fuera del móvil */
@media (min-width: 761px) { a.and-btn.vj-btn span { display: inline; } a.and-btn.vj-btn { padding: 6px 12px 6px 9px; } }
@media (max-width: 760px) { .cred-btn { display: none; } }

/* ── Indemnización orientativa y «Sigue mi tren» (public/compensation.js, public/follow.js) ── */
.comp { margin: 10px 0 2px; border: 1px solid color-mix(in srgb, var(--green) 45%, var(--line)); background: color-mix(in srgb, var(--green) 9%, var(--panel)); border-radius: 10px; font-size: 12.5px; color: var(--text); }
.comp summary { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; list-style: none; line-height: 1.35; }
.comp summary::-webkit-details-marker { display: none; }
.comp-i { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; font-weight: 700; font-size: 11px; }
.comp-q { margin-left: auto; color: var(--muted); }
.comp ul { margin: 0; padding: 0 12px 9px 34px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.comp li + li { margin-top: 3px; }
.cab .comp { margin: 8px 0; }
.fol-btn.on, .tm-fol.on { border-color: var(--blue) !important; color: var(--blue) !important; }
.tm-fol { width: 100%; margin-top: 6px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; }
.cab-fol.on { background: var(--blue); color: #fff; }
.fol-chips { position: fixed; z-index: 1150; left: 244px; top: calc(64px + env(safe-area-inset-top)); display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100vw - 680px); pointer-events: none; }
.fol-chips[hidden] { display: none; }
.fol-chip { display: inline-flex; align-items: center; pointer-events: auto; background: var(--panel); border: 1px solid var(--blue); border-radius: 999px; box-shadow: 0 4px 14px var(--shadow); overflow: hidden; }
.fol-chip button { background: none; border: 0; color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 6px 4px 6px 10px; }
.fol-chip .fol-chip-x { padding: 6px 10px 6px 6px; color: var(--muted); font-size: 15px; line-height: 1; }
.fol-toasts { position: fixed; z-index: 4500; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.fol-toast { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 10px 34px 10px 12px; border-radius: 12px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--blue); box-shadow: 0 12px 32px var(--shadow); font-size: 13px; }
.fol-toast span { color: var(--muted); }
.fol-toast button { position: absolute; top: 6px; right: 6px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.fol-back { position: fixed; inset: 0; z-index: 4000; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: var(--backdrop, rgba(20, 30, 45, .45)); }
.fol-dlg { width: min(400px, 100%); background: var(--modal-bg, var(--panel)); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.fol-dlg h3 { margin: 0 0 4px; font-size: 17px; }
.fol-sub, .fol-note { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.fol-note { margin: 10px 0 0; }
.fol-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; font-size: 14px; border-bottom: 1px solid var(--line); }
.fol-row input { width: 18px; height: 18px; accent-color: var(--blue); flex: none; }
.fol-row span { flex: 1; }
.fol-row select { max-width: 48%; padding: 5px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; }
.fol-b { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.fol-b button { min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.fol-b .fol-ok { background: var(--blue); border-color: var(--blue); color: var(--on-accent, #fff); }
.fol-b .fol-stop { margin-right: auto; color: var(--red); background: none; border-color: color-mix(in srgb, var(--red) 50%, var(--line)); }
@media (max-width: 760px) {
  .fol-chips { left: 8px; right: 8px; top: auto; max-width: none; bottom: calc(var(--sheet-visible, 0px) + 74px); }
  .fol-toasts { left: 12px; right: 12px; max-width: none; top: 112px; bottom: auto; }
  .fol-dlg { align-self: end; border-radius: 16px 16px 12px 12px; }
}
body.an-page .fol-chips { left: auto; right: 16px; top: auto; bottom: 16px; max-width: calc(100vw - 32px); justify-content: flex-end; }
body.an-page.sheet-open .fol-chips { display: none; }
/* ── fin indemnización / seguimiento ── */
/* Estado parcial: alguna fuente no responde */
.live.partial i { background: var(--amber); }
.live[title] { cursor: help; }
/* Retraso proyectado (posición frente a horario), complemento del oficial */
.proj { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 11.5px; font-weight: 700; color: var(--red); background: rgba(217,58,50,.10); border: 1px dashed currentColor; cursor: help; white-space: nowrap; }
.arr .d .proj-s { display: block; font-size: 10.5px; font-weight: 700; opacity: .85; }
.cab-near-i { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Enlaces en riesgo (connections.js) ─────────────────────────── */
.ln-dlg { width: min(520px, 100%); max-height: min(86vh, 760px); overflow-y: auto; }
.ln-f { display: grid; gap: 4px; margin: 10px 0; font-size: 13px; color: var(--muted); position: relative; }
.ln-f select, .ln-f input { font: inherit; font-size: 14px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; min-height: 42px; }
.ln-sug { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 24px var(--shadow); }
.ln-sug button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; border-radius: 7px; }
.ln-sug button:hover, .ln-sug button:focus-visible { background: var(--panel-2); }
.ln-arr { font-size: 14px; margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); }
.ln-arr small { display: block; color: var(--muted); margin-top: 2px; }
.ln-d { color: var(--amber); font-weight: 600; }
.ln-list { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 6px; }
.ln-row { display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 10px; }
.ln-row.ln-safe { border-left-color: var(--green); }
.ln-row.ln-at_risk { border-left-color: var(--amber); }
.ln-row.ln-missed { border-left-color: var(--red); opacity: .85; }
.ln-time b { display: block; font: 700 15px var(--mono); }
.ln-time s { font: 12px var(--mono); color: var(--muted); }
.ln-tr b { display: block; font-size: 13.5px; }
.ln-tr small { color: var(--muted); font-size: 12px; }
.ln-chip { text-align: right; font-size: 12.5px; font-weight: 700; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.ln-chip small { display: block; font-weight: 500; font-size: 11.5px; }
.ln-safe .ln-chip { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.ln-at_risk .ln-chip { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.ln-missed .ln-chip { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.ln-h { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ln-empty { color: var(--muted); font-size: 13.5px; margin: 8px 0; }
.ln-note { color: var(--faint, var(--muted)); font-size: 11.5px; line-height: 1.4; margin: 10px 0 2px; }
@media (max-width: 760px) { .ln-row { grid-template-columns: 52px 1fr; } .ln-chip { grid-column: 1 / -1; text-align: left; display: flex; gap: 8px; align-items: baseline; } .ln-chip small { display: inline; } }

/* ---- Tramos en riesgo y capas de aGIS Open Geodata ---- */
.dot.rz1 { background: #f29900; } .dot.rz2 { background: #e8590c; } .dot.rz3 { background: #d93025; }
.rz-note { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }
.inc.rz.lvl-3 { border-left: 3px solid #d93025; } .inc.rz.lvl-2 { border-left: 3px solid #e8590c; } .inc.rz.lvl-1 { border-left: 3px solid #f29900; }
.card-rz { margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; color: var(--amber); background: rgba(242,179,61,.08); }
.card-rz.lvl-3, .card-rz.lvl-2 { color: var(--warn-fg); background: rgba(255,90,82,.08); }
.agis-legend { position: absolute; left: 12px; bottom: 78px; z-index: 550; max-width: min(420px, calc(100% - 20px)); padding: 6px 10px; border-radius: 8px;
  background: var(--glass-2); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.18); font-size: 11.5px; line-height: 1.6; pointer-events: none; }
.agis-legend[hidden] { display: none; }
.agis-legend i { display: inline-block; width: 14px; height: 3px; margin: 0 4px 2px 6px; vertical-align: middle; border-radius: 2px; }
.agis-legend i.dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; border: 1.5px solid #5f6368; }
.agis-legend i.dot.board { border-color: #0f9d58; }
.agis-legend .src { opacity: .7; font-size: 10.5px; }
@media (max-width: 760px) { .agis-legend { bottom: calc(var(--sheet-visible, 0px) + 12px); font-size: 11px; } }
body.card-open .agis-legend { display: none; }
/* Alertas de red de Trenalia */
.inc.na.lvl-3 { border-left: 3px solid #d93025; } .inc.na.lvl-2 { border-left: 3px solid #e8590c; } .inc.na.lvl-1 { border-left: 3px solid #f29900; }
.inc.na.ltv { border-left: 3px dashed var(--amber); }
.inc.na .reg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* Hipótesis de incidencia (estimaciones de Trenalia; ver docs/HIPOTESIS.md) */
.hyp { --hyp-amber: #8a5a00; --hyp-red: #b42318; --hyp-red-bg: #c9302a; --hyp-red-fg: #ffffff; --hyp-green: #0b7a4b;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--hyp-amber); border-radius: var(--r); padding: 10px 12px; min-width: 0; overflow-wrap: anywhere; }
:root[data-theme="dark"] .hyp { --hyp-amber: #f2b33d; --hyp-red: #ff8a84; --hyp-red-bg: #ff5a52; --hyp-red-fg: #1a0505; --hyp-green: #3ecf8e; }
.hyp.incident { border-left-color: var(--hyp-red-bg); }
.hyp.closed { opacity: .82; }
.hyp-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.hyp-lbl { display: inline-block; font-weight: 800; font-size: 13px; letter-spacing: .01em; border-radius: 6px; padding: 3px 9px; line-height: 1.25;
  color: var(--hyp-amber); border: 1.5px solid var(--hyp-amber); background: transparent; }
.hyp.incident .hyp-lbl { color: var(--hyp-red-fg); background: var(--hyp-red-bg); border-color: var(--hyp-red-bg); }
.hyp-st { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 9px; border: 1px solid currentColor; }
.hyp-st.ok { color: var(--hyp-green); } .hyp-st.ko { color: var(--muted); }
.hyp-t { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.hyp h4 { margin: 8px 0 2px; font-size: 14px; }
.hyp p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.hyp-where { color: var(--text) !important; font-weight: 600; }
.hyp-map { background: none; border: 0; padding: 0 2px; margin-left: 4px; color: var(--blue); font: inherit; font-weight: 600; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.hyp-trig span { font-weight: 700; color: var(--text); }
.hyp-k { margin-top: 8px !important; font-weight: 700; color: var(--text) !important; font-size: 12px !important; }
.hyp-trains { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; }
.hyp-trains li { display: grid; grid-template-columns: minmax(0, 1fr) 54px 3.4em 7.4em; gap: 8px; align-items: center; font-size: 12.5px; }
.hyp-trains a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hyp-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.hyp-bar i { display: block; height: 100%; width: 0; background: var(--hyp-amber); border-radius: 3px; }
.hyp.incident .hyp-bar i { background: var(--hyp-red-bg); }
.hyp-p { font-family: var(--mono); font-size: 12px; text-align: right; }
.hyp-m { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.hyp-m small { display: block; font-family: var(--sans); font-size: 11px; color: var(--faint); }
.hyp-more summary { cursor: pointer; font-size: 12px; color: var(--blue); margin-top: 4px; }
.hyp-conf { color: var(--text) !important; }
.hyp-hz { font-size: 12px !important; }
.hyp-disc { font-size: 11.5px !important; color: var(--faint) !important; border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 8px !important; }
.hyp-fb { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.hyp-fb:focus { outline: none; } .hyp-fb:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.hyp-fb p { margin: 0; }
.hyp-fb-q b { color: var(--text); font-size: 13px; }
.hyp-fb-sel { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.hyp-fb-sel select { min-width: 0; max-width: 100%; flex: 1 1 140px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; font: inherit; font-size: 12.5px; }
.hyp-fb-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hyp-fb-btns button { flex: 1 1 140px; min-height: 36px; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.hyp-fb-btns .hyp-yes { border-color: var(--hyp-red-bg); color: var(--hyp-red); }
.hyp-fb-btns .hyp-no { border-color: var(--hyp-green); color: var(--hyp-green); }
.hyp-fb-btns button:hover:not(:disabled) { background: var(--panel); }
.hyp-fb-btns button:disabled { opacity: .55; cursor: progress; }
.hyp-fb-btns button:focus-visible, .hyp-map:focus-visible, .hyp-fb-sel select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.hyp-fb-msg:empty { display: none; }
.hyp-fb-msg { margin-top: 6px !important; font-size: 12px; }
.hyp-fb-msg.err { color: var(--err-fg); }
.hyp-fb.done p b { color: var(--hyp-green); font-size: 12.5px; }
.hyp-fb-n { font-size: 12px; color: var(--muted); margin-top: 2px !important; }
@media (max-width: 420px) { .hyp-trains li { grid-template-columns: minmax(0, 1fr) 36px 3.2em 7.2em; gap: 6px; } }

/* Hipótesis que afectan a un tren que sigues, y aviso en la ficha del tren */
.hyp.mine { box-shadow: inset 4px 0 0 #1f6fd6; }
.hyp-mine { margin: 4px 0 8px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, #1f6fd6 12%, transparent); color: inherit; font-weight: 600; font-size: 13.5px; }
.hyp-mine small { display: block; font-weight: 400; opacity: .85; margin-top: 2px; }
.hyp.flash { outline: 2px solid #1f6fd6; outline-offset: 2px; transition: outline-color .6s; }
#nHyp.mine { background: #1f6fd6; color: #fff; border-radius: 99px; padding: 0 6px; }
.card-hyp { margin: 8px 0; padding: 7px 10px; border-radius: 8px; font-size: 13.5px; border: 1px dashed #7a3fd1; background: color-mix(in srgb, #7a3fd1 8%, transparent); }
.card-hyp.incident { border-color: #d93a32; background: color-mix(in srgb, #d93a32 8%, transparent); }
:root[data-theme="dark"] .hyp.mine { box-shadow: inset 4px 0 0 #6ea8ff; }
:root[data-theme="dark"] .hyp-mine { background: color-mix(in srgb, #6ea8ff 18%, transparent); }
:root[data-theme="dark"] #nHyp.mine { background: #6ea8ff; color: #0b1220; }
:root[data-theme="dark"] .card-hyp { border-color: #b388ff; }
@media (prefers-reduced-motion: reduce) { .hyp.flash { transition: none; } }

/* «Ver la estación»: botón en la ficha de estación del mapa y en la vista de andén, y ventana con la foto (Wikimedia Commons) */
.st-photo-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: 600 13px var(--sans); }
.st-photo-btn:hover { border-color: var(--hover-line); }
.st-photo-btn.pending { visibility: hidden; }
.st-photo-btn[hidden] { display: none; }
.st-photo-btn svg, .an-photo svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; flex: none; }
.st-photo-btn:focus-visible, .an-photo:focus-visible, .st-photo a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.st-photo { margin: 12px 0 0; }
.st-photo img { display: block; width: 100%; height: auto; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.st-photo figcaption { margin-top: 8px; font-size: 12.5px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.st-photo figcaption a { color: var(--blue); }
.st-photo-note { display: block; margin-top: 2px; color: var(--faint); }

/* Fuente del retraso mostrado: Renfe (oficial), Trenalia (proyectado, solo donde la validación dice que acierta más) o Adif (paneles) */
.dsrc { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; vertical-align: 1px; cursor: help; white-space: nowrap; border: 1px solid currentColor; }
.dsrc-renfe { color: #5b6472; }
.dsrc-adif { color: #5b6472; }
.dsrc-trenalia { color: #1f6fd6; }
:root[data-theme="dark"] .dsrc-renfe, :root[data-theme="dark"] .dsrc-adif { color: #aab4c3; }
:root[data-theme="dark"] .dsrc-trenalia { color: #6ea8ff; }
.arr .d .dsrc-s { text-transform: uppercase; letter-spacing: .03em; font-weight: 800; opacity: .7; }
.proj { color: inherit; opacity: .85; }

/* «¿Sabías que…?» de Trenalito (public/tips.js): bocadillo pequeño junto al botón de Trenalito */
.tip-card { position: fixed; z-index: 1100; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 300px; max-width: calc(100vw - 32px); display: grid; grid-template-columns: 1fr auto; gap: 2px 6px;
  background: var(--panel, #fff); color: var(--text, #16202f); border: 1px solid var(--line, #d5dce6); border-radius: 14px; box-shadow: 0 10px 28px rgba(0,0,0,.18); padding: 10px 8px 6px 12px; animation: tipIn .25s ease-out; }
.tip-card::after { content: ''; position: absolute; right: 34px; bottom: -7px; width: 12px; height: 12px; background: inherit; border-right: 1px solid var(--line, #d5dce6); border-bottom: 1px solid var(--line, #d5dce6); transform: rotate(45deg); }
@keyframes tipIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.tip-main { grid-column: 1; grid-row: 1 / span 2; text-align: left; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }
.tip-k { display: block; font-size: 12px; font-weight: 800; letter-spacing: .02em; color: #1f6fd6; }
.tip-b { display: block; font-size: 14px; line-height: 1.35; margin-top: 2px; }
.tip-go { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 700; color: #1f6fd6; }
.tip-main:hover .tip-go, .tip-main:focus-visible .tip-go { text-decoration: underline; }
.tip-x { grid-column: 2; grid-row: 1; background: none; border: 0; font-size: 20px; line-height: 1; padding: 0 4px; color: var(--muted, #5b6472); cursor: pointer; }
.tip-off { grid-column: 1 / -1; justify-self: start; background: none; border: 0; padding: 4px 0 0; font-size: 12px; color: var(--muted, #5b6472); text-decoration: underline; cursor: pointer; }
.tip-main:focus-visible, .tip-x:focus-visible, .tip-off:focus-visible { outline: 2px solid #1f6fd6; outline-offset: 2px; border-radius: 6px; }
:root[data-theme="dark"] .tip-k, :root[data-theme="dark"] .tip-go { color: #6ea8ff; }
@media (max-width: 760px) { .tip-card { bottom: calc(var(--sheet-visible, 0px) + 76px); right: 12px; } }
@media (prefers-reduced-motion: reduce) { .tip-card { animation: none; } }

/* ── Servicio alterado (sprints 072–074): chips de los avisos, estado de líneas, ficha del tren, andén y viaje ── */
.svc-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 2px; }
.svc-k, .svc-c { font-size: 12px; line-height: 1.3; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); text-decoration: none; }
a.svc-c { color: var(--blue); }
.svc-k { font-weight: 700; }
.svc-k.svc-bus { border-color: var(--orange); color: var(--orange); }
.svc-k.svc-noservice, .svc-k.svc-train { border-color: var(--red); color: var(--err-fg); }
.svc-k.svc-single, .svc-k.svc-delay { border-color: var(--amber); color: var(--amber); }
.svc-k.svc-recovered { border-color: var(--green); color: var(--green); }
.svc-c.svc-up { font-weight: 700; }
.svc-lines, .svc-acc { grid-column: 1 / -1; }
.svc-lines { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 10px; font-size: 13px; }
.svc-lines > b { width: 100%; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.svc-ln { display: inline-flex; flex-direction: column; padding: 4px 9px; border-radius: 8px; border: 1px solid var(--line); border-left: 4px solid var(--grey); background: var(--panel); font-weight: 800; }
.svc-ln small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.svc-ln.svc-bus { border-left-color: var(--orange); }
.svc-ln.svc-noservice, .svc-ln.svc-train { border-left-color: var(--red); }
.svc-ln.svc-single, .svc-ln.svc-delay { border-left-color: var(--amber); }
.svc-ln.svc-recovering { border-left-color: var(--green); }
.svc-acc { margin: 10px 0; border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; background: var(--panel); }
.svc-acc summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.svc-acc p { font-size: 13px; color: var(--muted); margin: 6px 0; }
.svc-acc p b { color: var(--text); }
.svc-card { margin: 8px 0; padding: 8px 10px; border-radius: var(--r); background: var(--alert-amber-bg); border: 1px solid var(--amber); color: var(--text); font-size: 13.5px; }
.svc-card b { display: block; color: var(--amber); margin-bottom: 2px; }
.svc-card p { margin: 3px 0; }
.svc-tip-t { display: inline-block; max-width: 300px; white-space: normal; }
.svc-busicon { background: none; border: 0; }
.svc-busicon svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }

/* Menú del tren: «Voy en este tren» y accesos que usan el número del tren (sprint 076) */
.tm-vtr { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 6px; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--blue); background: var(--panel); color: var(--blue); font-weight: 800; font-size: 13.5px; text-decoration: none; box-sizing: border-box; }
.tm-vtr svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tm-vtr:hover { background: var(--panel-2); }
.tm-b3 { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tm-lnk { flex: 1 1 auto; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; text-decoration: none; text-align: center; cursor: pointer; }
.tm-lnk:hover { border-color: var(--hover-line); }
a.and-btn.vtr-btn.on { border-color: var(--blue); color: var(--blue); }
/* Suscripción por correo a una línea (sprint 078) */
.svc-sub { margin-top: 5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--blue); background: var(--panel); color: var(--blue); font: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer; }
.svc-sub:hover { background: var(--panel-2); }
.svc-pop .svc-sub { margin-top: 8px; font-size: 13px; padding: 6px 10px; }
/* Barra superior en escritorio: el estado se recorta (el texto completo está en el título) para que el menú ☰ no salte de línea */
@media (min-width: 761px) {
  .brand { min-width: 0; flex: 0 1 auto; }
  .live { min-width: 0; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .live i { display: inline-block; margin-right: 6px; vertical-align: 1px; }
}
.st-pop-trip { margin-top: 6px; }

/* Incidencia abierta desde un correo (sprint 080) */
.inc-dlg { max-width: 520px; }
.inc-dlg-k { margin: 0 0 4px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted, #6b778a); }
.inc-dlg h3 { margin: 0 0 8px; }
.inc-dlg-seg { margin: 4px 0 10px; padding-left: 18px; font-size: 14px; }

/* Avisos de servicio posiblemente suspendido (sprint 123) */
.adv-badge { display: inline-block; margin: 2px 0 0 6px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.5; background: #fff3cd; color: #7a4b00; border: 1px solid #e0a800; white-space: nowrap; }
.adv-badge.adv-soft { background: #f1f3f5; color: #495057; border-color: #adb5bd; font-weight: 600; }
.adv-box { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: #fff8e1; color: #5c3b00; border: 1px solid #f0b429; border-left: 5px solid #d97706; font-size: 14px; line-height: 1.45; text-align: left; }
.adv-box.adv-soft { background: #f8f9fa; color: #343a40; border-color: #ced4da; border-left-color: #868e96; }
.adv-box b { display: block; margin-bottom: 2px; }
.adv-box p { margin: 4px 0; }
.adv-box .adv-keep { font-size: 12.5px; opacity: .85; }
.adv-box a { color: inherit; font-weight: 700; text-decoration: underline; }
.adv-banner { margin: 6px 0 10px; }
/* Sprint 159: ocupación esperada (con texto: el color no es lo único que la distingue) */
.occ-badge { display: inline-block; margin: 2px 0 0 6px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid; cursor: help; }
.occ-badge.occ-low { background: #e6f4ea; color: #1e5631; border-color: #7bbf8e; }
.occ-badge.occ-mid { background: #eef2f7; color: #36506b; border-color: #9fb3c8; }
.occ-badge.occ-high { background: #fdecea; color: #8a1c14; border-color: #e3958c; }
.occ-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
/* Sprint 177: ocupación aproximada (borde discontinuo), sin datos (gris) y precio medio orientativo de la CNMC */
.occ-badge.occ-approx { border-style: dashed; }
.occ-badge.occ-none { background: transparent; color: var(--muted); border-color: currentColor; font-weight: 500; opacity: .85; }
.fare-chip { display: inline-block; margin: 2px 0 0 6px; padding: 1px 7px; border-radius: 999px; font-size: 12px; line-height: 1.5; white-space: nowrap; border: 1px dotted currentColor; color: var(--muted); cursor: help; }
.fare-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.fare-note a { color: inherit; text-decoration: underline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .adv-badge { background: #4a3500; color: #ffe08a; border-color: #b7791f; }
  :root:not([data-theme="light"]) .occ-badge.occ-low { background: #16301f; color: #a8e0b8; border-color: #2f6b43; }
  :root:not([data-theme="light"]) .occ-badge.occ-mid { background: #1f2a36; color: #bcd0e4; border-color: #3d5670; }
  :root:not([data-theme="light"]) .occ-badge.occ-high { background: #3a1714; color: #f5b5ad; border-color: #8a3a31; }
  :root:not([data-theme="light"]) .adv-box { background: #2f2410; color: #ffe8b3; border-color: #8a6100; border-left-color: #f59f00; }
  :root:not([data-theme="light"]) .adv-badge.adv-soft, :root:not([data-theme="light"]) .adv-box.adv-soft { background: #25292e; color: #ced4da; border-color: #495057; }
}
:root[data-theme="dark"] .adv-badge { background: #4a3500; color: #ffe08a; border-color: #b7791f; }
:root[data-theme="dark"] .occ-badge.occ-low { background: #16301f; color: #a8e0b8; border-color: #2f6b43; }
:root[data-theme="dark"] .occ-badge.occ-mid { background: #1f2a36; color: #bcd0e4; border-color: #3d5670; }
:root[data-theme="dark"] .occ-badge.occ-high { background: #3a1714; color: #f5b5ad; border-color: #8a3a31; }
:root[data-theme="dark"] .adv-box { background: #2f2410; color: #ffe8b3; border-color: #8a6100; border-left-color: #f59f00; }
:root[data-theme="dark"] .adv-badge.adv-soft, :root[data-theme="dark"] .adv-box.adv-soft { background: #25292e; color: #ced4da; border-color: #495057; }
.adv-box.adv-early { background: #eef4ff; color: #1d3557; border-color: #9db7e8; border-left-color: #2b6cb0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .adv-box.adv-early { background: #16233a; color: #cfe0ff; border-color: #2d4a7a; border-left-color: #5b8def; } }
:root[data-theme="dark"] .adv-box.adv-early { background: #16233a; color: #cfe0ff; border-color: #2d4a7a; border-left-color: #5b8def; }

/* Material rodante (sprint 130) */
.rl-box { margin: 8px 0; border: 1px solid var(--line, #d9dee5); border-radius: 12px; overflow: hidden; background: var(--panel, transparent); }
.rl-photo img { display: block; width: 100%; height: auto; max-height: 220px; object-fit: cover; }
.rl-photo .rl-cred { display: block; padding: 3px 8px; font-size: 11px; opacity: .75; }
.rl-photo .rl-cred a { color: inherit; }
.rl-txt { padding: 8px 10px; display: grid; gap: 2px; }
.rl-txt span { font-size: 13px; }
.rl-txt .rl-u { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.rl-txt small { font-size: 11.5px; opacity: .7; }

/* ── Sprint 135 ── */
/* Ficha del tren: que nada se salga a lo ancho (antes el retraso con «Trenalia estima» y la fuente empujaban la columna) */
.card { overflow-x: hidden; }
@media (min-width: 761px) { .card { width: 336px; } }
.card dl { grid-template-columns: minmax(78px, max-content) minmax(0, 1fr); }
.card dt { min-width: 0; }
.card dd { min-width: 0; overflow-wrap: anywhere; }
.card dd .proj { white-space: normal; margin: 3px 0 0; display: inline-block; text-align: left; }
.card dd .src, .card dd .badge, .card dd [class*="src-"] { max-width: 100%; }
.card .card-cta { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.card .card-cta button { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card .card-alert, .card .card-anom, .card .card-sched { overflow-wrap: anywhere; }
.card .route { overflow-wrap: anywhere; padding-right: 18px; }

/* Vista rápida al pasar el ratón (escritorio) */
.hv { position: absolute; left: 0; top: 0; z-index: 760; width: 272px; pointer-events: none; background: var(--glass-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px var(--shadow); overflow: hidden; font: 13px/1.35 var(--sans); }
.hv.in { animation: hvIn .12s ease-out; }
@keyframes hvIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hv.in { animation: none; } }
.hv-ph { height: 0; overflow: hidden; background: var(--panel-2); }
.hv-ph.ok { height: auto; }
.hv-ph img { display: block; width: 100%; height: 132px; object-fit: cover; }
.hv-ph small { display: block; padding: 2px 8px; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hv-b { padding: 9px 11px 9px; }
.hv-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hv-h b { font-size: 14px; }
.hv-d { font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.hv-d.c-green { color: var(--green); background: rgba(18,147,92,.12); } .hv-d.c-amber { color: var(--amber); background: rgba(181,118,0,.12); }
.hv-d.c-red { color: var(--red); background: rgba(217,58,50,.12); } .hv-d.c-none { color: var(--muted); background: var(--panel-2); }
.hv-r { color: var(--muted); font-size: 12px; margin-top: 1px; }
.hv-f { list-style: none; margin: 7px 0 0; padding: 0; display: grid; gap: 3px; }
.hv-f:empty { display: none; }
.hv-f li { font-size: 12.5px; padding-left: 12px; position: relative; }
.hv-f li::before { content: ""; position: absolute; left: 2px; top: .55em; width: 5px; height: 5px; border-radius: 50%; background: var(--blue); opacity: .7; }
.hv-f li span { color: var(--muted); }
.hv-f li.hv-warn { color: var(--warn-fg); } .hv-f li.hv-warn::before { display: none; }
.hv-f li.hv-sw::before, .hv-f li.hv-term::before, .hv-f li.hv-gc::before { background: var(--orange); }
.hv-tip { margin-top: 7px; font-size: 11px; color: var(--faint); }

/* «Ver la estación» (sprint 136): foto y ficha, igual en el mapa y en el andén */
.sv-head h2 { margin: 0; }
.sv-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.sv .st-photo { margin-top: 12px; }
.sv .st-photo img { max-height: 320px; object-fit: cover; border-radius: 12px; }
.sf { margin-top: 16px; }
.sf-h { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.sf-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.sf-stat { padding: 10px 12px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); min-width: 0; }
.sf-stat b { display: block; font: 700 21px/1.1 var(--sans); letter-spacing: -.01em; color: var(--text); font-variant-numeric: tabular-nums; }
.sf-stat span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); line-height: 1.25; }
.sf-stat small { display: block; font-size: 11px; color: var(--faint); }
.sf-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 16px; margin: 14px 0 0; font-size: 13.5px; }
.sf-dl dt { color: var(--muted); } .sf-dl dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.sf-lines { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; }
.sf-lines span { font-size: 13.5px; color: var(--muted); margin-right: 8px; }
.sf-lines i { font-style: normal; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.sf-notes { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.sf-notes li { position: relative; padding: 8px 10px 8px 34px; border-radius: 10px; background: var(--panel-2); font-size: 13px; color: var(--text); }
.sf-notes li::before { content: ""; position: absolute; left: 11px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); background: currentColor; opacity: .75;
  -webkit-mask: var(--sf-i) center / contain no-repeat; mask: var(--sf-i) center / contain no-repeat; }
.sf-n-term { --sf-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 14V6M3 5h10'/%3E%3C/svg%3E"); }
.sf-n-gc { --sf-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h12l-3-3M17 11H5l3 3'/%3E%3C/svg%3E"); color: var(--orange); }
.sf-n-sw, .sf-n-el { --sf-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 15V8M8 8 3 2M8 8l5-6'/%3E%3C/svg%3E"); }
.sf-n-x { --sf-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 3l10 10M13 3 3 13'/%3E%3C/svg%3E"); }
.sf-src { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--faint); }
.sf-src a { color: var(--blue); }
.sf-none { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.st-pop-sub { color: var(--muted); font-size: 12.5px; margin-top: -4px; }
/* Capa «Vía»: agujas, cruces, topes y cambiadores de ancho */
.tp { display: flex; align-items: center; justify-content: center; }
.tp svg { width: 14px; height: 14px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 1.5px var(--panel)); }
.tp-sw svg { stroke: var(--text); opacity: .55; width: 11px; height: 11px; }
.tp-x svg { stroke: var(--blue); }
.tp-bs svg { stroke: var(--red); }
.tp-gc { background: var(--orange); border-radius: 7px; box-shadow: 0 1px 4px var(--shadow); }
.tp-gc svg { width: 20px; height: 16px; stroke: #fff; filter: none; }
.lp-row .lp-hint { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 1px; }
/* Sprint 139: con el dedo, varios trenes juntos → lista corta para elegir */
.tpick { position: absolute; z-index: 1100; width: min(300px, calc(100% - 16px)); padding: 8px; border-radius: 14px; background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: 0 12px 32px var(--shadow); font: 14px/1.35 var(--sans); }
.tpick-h { margin: 2px 6px 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tpick button { display: grid; grid-template-columns: 12px 1fr; column-gap: 10px; align-items: center; width: 100%; min-height: 48px; padding: 7px 8px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.tpick button + button { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
.tpick button:active { background: var(--line); }
.tpick button b { font-weight: 650; }
.tpick button small { grid-column: 2; color: var(--muted); font-size: 12.5px; }
.tpick-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); grid-row: span 2; }
.tpick-dot.amber { background: var(--amber); } .tpick-dot.red { background: var(--red); } .tpick-dot.sched { background: transparent; border: 2px dashed var(--grey); }
.tpick-dot.st { border-radius: 3px; background: var(--panel); border: 2.5px solid var(--text); width: 11px; height: 11px; }   /* sprint 139b: estación en la lista */

/* Sprint 165: botón de la sala de juegos en la barra superior (ordenador y móvil en vista completa) */
.jg-top-btn { position: relative; border-color: #ff3ea5 !important; color: #fff !important; background: linear-gradient(180deg, #3a1a6e, #1d0f3f) !important; box-shadow: 0 0 12px rgba(255, 62, 165, .35); }
.jg-top-btn svg { stroke: #ffe04a !important; }
.jg-top-btn .jg-new { position: absolute; top: -8px; right: -6px; background: #ff3ea5; color: #fff; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 5px; border-radius: 6px; line-height: 1.2; }
/* Sprint 170 · Compartir avisos */
.inc-sh { margin-top: 6px; }
.inc-share { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; }
.inc-share:hover { color: var(--text); border-color: var(--hover-line); }
.fol-b .inc-share { font-size: 14px; padding: 8px 12px; border-radius: 9px; }

/* Sprint 178: franja «Mapa en pausa · Seguir en directo» (inactividad) */
.live-pause { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 1200; max-width: calc(100vw - 32px); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; padding: 8px 12px; border-radius: 12px; background: var(--glass-2); color: var(--text); border: 1px solid var(--line); box-shadow: 0 4px 16px var(--shadow); font-size: 14px; }
.live-pause[hidden] { display: none; }
.live-pause button { font: inherit; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: 0; background: var(--blue); color: var(--on-accent); cursor: pointer; }

/* Sprint 184: jornada de huelga (franja plegable en todas las páginas y etiqueta «sin confirmar · huelga») */
#strikeBar { position: fixed; z-index: 1500; left: 50%; transform: translateX(-50%); bottom: max(calc(76px + env(safe-area-inset-bottom)), min(calc(var(--sheet-visible, 0px) + 12px), 45dvh));   /* sprint 228: encima del panel inferior del mapa */
  width: min(560px, calc(100% - 24px)); }
.strk-bar { position: relative; border-radius: 14px; background: #fff4e5; color: #5c3200; border: 1px solid #f0a33a; box-shadow: 0 6px 20px rgba(0,0,0,.18); font: 14px/1.4 system-ui, sans-serif; }
.strk-bar.strk-today { background: #fdecec; color: #6b1010; border-color: #e35d5d; }
.strk-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; width: 100%; padding: 10px 40px 10px 14px; background: none; border: 0; color: inherit; font: 700 14px/1.3 system-ui, sans-serif; text-align: left; cursor: pointer; }
.strk-more { flex: none; font-weight: 600; font-size: 12px; text-decoration: underline; }
.strk-x { position: absolute; top: 4px; right: 6px; width: 30px; height: 30px; border: 0; background: none; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; }
.strk-body { padding: 0 14px 12px; max-height: 50vh; overflow: auto; }
.strk-body p { margin: 6px 0; } .strk-body ul { margin: 4px 0 6px; padding-left: 18px; }
.strk-body a { color: inherit; font-weight: 600; }
.strk-small { font-size: 12px; opacity: .85; }
.adv-badge.adv-strike { background: #fdecec; color: #8a1414; border-color: #e35d5d; }
.adv-box.adv-strike { background: #fdecec; color: #6b1010; border-color: #e35d5d; border-left-color: #c92a2a; }
:root[data-theme="dark"] .strk-bar { background: #3a2710; color: #ffe2b8; border-color: #a86a12; }
:root[data-theme="dark"] .strk-bar.strk-today, :root[data-theme="dark"] .adv-box.adv-strike, :root[data-theme="dark"] .adv-badge.adv-strike { background: #3d1717; color: #ffd0d0; border-color: #a33a3a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .strk-bar { background: #3a2710; color: #ffe2b8; border-color: #a86a12; }
  :root:not([data-theme="light"]) .strk-bar.strk-today, :root:not([data-theme="light"]) .adv-box.adv-strike, :root:not([data-theme="light"]) .adv-badge.adv-strike { background: #3d1717; color: #ffd0d0; border-color: #a33a3a; }
}
.adv-badge.adv-strike-ok { background: #e7f6ec; color: #135c2c; border-color: #4caf6e; }
.adv-box.adv-strike-ok { background: #eef8f1; color: #14532d; border-color: #4caf6e; border-left-color: #2f9e57; }
:root[data-theme="dark"] .adv-badge.adv-strike-ok, :root[data-theme="dark"] .adv-box.adv-strike-ok { background: #13301e; color: #c8f0d4; border-color: #2f7a4a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .adv-badge.adv-strike-ok, :root:not([data-theme="light"]) .adv-box.adv-strike-ok { background: #13301e; color: #c8f0d4; border-color: #2f7a4a; } }
/* «Sin confirmar · huelga»: ámbar (no se sabe); «Suprimido»: rojo; «En servicios mínimos»: verde */
.adv-badge.adv-strike-unk { background: #fff4e5; color: #7a4100; border-color: #f0a33a; }
.adv-box.adv-strike-unk { background: #fff8ec; color: #5c3200; border-color: #f0a33a; border-left-color: #e8890c; }
:root[data-theme="dark"] .adv-badge.adv-strike-unk, :root[data-theme="dark"] .adv-box.adv-strike-unk { background: #3a2710; color: #ffe2b8; border-color: #a86a12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .adv-badge.adv-strike-unk, :root:not([data-theme="light"]) .adv-box.adv-strike-unk { background: #3a2710; color: #ffe2b8; border-color: #a86a12; } }

/* Sprint 185: minimizado (botón pequeño que vuelve a abrir el aviso) */
.strk-mini { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid #f0a33a; background: #fff4e5; color: #5c3200; font: 700 13px/1 system-ui, sans-serif; box-shadow: 0 4px 14px rgba(0,0,0,.18); cursor: pointer; }
.strk-mini.strk-today { background: #fdecec; color: #6b1010; border-color: #e35d5d; }
#strikeBar:has(.strk-mini) { width: auto; left: 12px; transform: none; }
/* Sprint 231: en el móvil, solo un icono (se abre al tocarlo) */
#strikeBar:has(.strk-ico) { width: auto; left: 12px; transform: none; bottom: max(calc(16px + env(safe-area-inset-bottom)), min(calc(var(--sheet-visible, 0px) + 12px), 45dvh)); }
.strk-ico { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1.5px solid #f0a33a; background: #fff4e5; color: #8a4b00; font: 700 20px/1 system-ui, sans-serif; box-shadow: 0 4px 14px rgba(0,0,0,.22); cursor: pointer; }
.strk-ico.strk-today { background: #fdecec; color: #b3261e; border-color: #e35d5d; }
:root[data-theme="dark"] .strk-ico { background: #3a2710; color: #ffe2b8; border-color: #a86a12; }
:root[data-theme="dark"] .strk-ico.strk-today { background: #3d1717; color: #ffd0d0; border-color: #a33a3a; }
:root[data-theme="dark"] .strk-mini { background: #3a2710; color: #ffe2b8; border-color: #a86a12; }
:root[data-theme="dark"] .strk-mini.strk-today { background: #3d1717; color: #ffd0d0; border-color: #a33a3a; }
/* Sprint 191 · animación del botón de GPS */
@keyframes geoPulse { 50% { opacity: .35; } }
/* Sprint 202 · botón de GPS en la barra (normal = centrar al abrir; tachado = no) */
.geo-top.busy svg { animation: geoPulse 1s ease-in-out infinite; }
.geo-top:not(.muted) { border-color: var(--blue); }
.geo-top:not(.muted) svg { stroke: var(--blue); }
@media (prefers-reduced-motion: reduce) { .geo-top.busy svg { animation: none; } }
/* En el móvil la barra no tiene sitio: el mismo botón va pequeño en la esquina del mapa (arriba a la derecha) */
.geo-map { display: none !important; }
@media (max-width: 640px) {
  .bell-btn.geo-top { display: none; }
  .geo-map.leaflet-bar { display: block !important; border: 0; box-shadow: 0 1px 5px rgba(0,0,0,.25); border-radius: 999px; overflow: hidden; }
  .geo-map .bell-btn { width: 36px; height: 36px; border-radius: 999px; }
}
.bell-btn.geo-top[hidden] { display: none; }
/* Sprint 203 · «Tu tren» en el mapa: diana que late y etiqueta (tocarla abre la ficha) */
.mt-wrap { pointer-events: none; }
.mt-ring { position: absolute; inset: 8px; border: 3px solid #2f7bff; border-radius: 50%; box-shadow: 0 0 0 2px #fff; animation: mtPulse 2s ease-out infinite; }
.mt-ring2 { inset: 18px; border-width: 2px; animation: none; }
.mt-lab { pointer-events: auto; position: absolute; left: 50%; top: 52px; transform: translateX(-50%); white-space: nowrap; border: 0; border-radius: 999px; padding: 3px 9px;
  background: #2f7bff; color: #fff; font: 700 12px/1.3 system-ui, sans-serif; box-shadow: 0 2px 6px rgba(0,0,0,.3); cursor: pointer; }
@keyframes mtPulse { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.25); opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .mt-ring { animation: none; } }
body.tl-open #strikeBar, body.sns-open #strikeBar { display: none; }   /* sprint 203: no tapar la caja de Trenalito ni la pantalla del sensor */
/* Sprint 203: en el iPhone, un campo de texto con letra de menos de 16 px hace que Safari amplíe la página al escribir (la
   caja de Trenalito se veía cortada por la derecha). En pantallas táctiles, 16 px en los campos de escribir. */
@media (pointer: coarse) {
  .tl-form textarea, input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="number"], input:not([type]), textarea { font-size: 16px; }
}
/* Sprint 204 · un viaje a la vez: «Voy en este tren» de otros trenes, sombreado; ventana para ir a tu tren */
a.vtr-blocked { opacity: .45; filter: grayscale(1); }
.tg-ov { position: fixed; inset: 0; z-index: 4000; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: rgba(10, 14, 24, .45); }
.tg-card { width: min(420px, 100%); background: var(--panel, #fff); color: var(--text, #1d2433); border-radius: 16px; padding: 18px 18px 14px; box-shadow: 0 12px 40px rgba(0,0,0,.3); font: 15px/1.45 system-ui, sans-serif; }
.tg-card h2 { margin: 0 0 6px; font-size: 18px; }
.tg-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tg-btns a, .tg-btns button { border-radius: 999px; padding: 9px 14px; font: 700 14px/1.2 system-ui, sans-serif; border: 1px solid var(--line, #d5dae3); background: none; color: inherit; cursor: pointer; text-decoration: none; }
.tg-btns .tg-go { background: #2f7bff; border-color: #2f7bff; color: #fff; }

/* Sprint 213 · panel de incidencias de abajo: bisel para subirlo, bajarlo o recogerlo (solo ordenador) */
.main > .incidents { position: relative; z-index: 650; }
.inc-grip { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); width: 72px; height: 18px; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--panel, var(--bg)); cursor: ns-resize; display: grid; place-items: center; touch-action: none; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.inc-grip span { width: 32px; height: 4px; border-radius: 4px; background: var(--muted); }
.inc-grip:hover span, .inc-grip:focus-visible span { background: var(--blue); }
.inc-grip:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.incidents.inc-collapsed .sub, .incidents.inc-collapsed .inc-list { display: none; }
.incidents.inc-collapsed { max-height: none; }
.inc-list { min-height: 0; }
body.inc-dragging, body.inc-dragging * { cursor: ns-resize !important; user-select: none; }
@media (max-width: 1000px) { .inc-grip { display: none; } }
.main > .incidents .inc-list { flex: 1 1 auto; }

/* Sprint 213 · barra de arriba del mapa (ordenador): se ajusta al ancho para que los botones y el buscador quepan en una
   línea y los filtros de servicio en otra. Cuando falta sitio, los botones se quedan en icono (llevan su nombre en
   title/aria-label), el estado «Demo/En vivo» se recorta y el buscador ocupa lo que sobra; los filtros, deslizables. */
@media (min-width: 1001px) {
  .mapwrap { container: mapw / inline-size; }
  .topbar { gap: 8px; }
  .brand { min-width: 0; }
  .brand .live { min-width: 0; max-width: clamp(80px, 14cqi, 260px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .search { flex: 1 1 140px; min-width: 120px; max-width: 280px; }
  .search input { width: 100%; box-sizing: border-box; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; white-space: nowrap; }
  @container mapw (max-width: 1400px) {
    .cab-btn span, a.and-btn.vj-btn span { display: none; }
    .cab-btn, a.and-btn.vj-btn { padding: 6px; }
    .chip { padding: 4px 8px; font-size: 11.5px; gap: 4px; }
  }
  @container mapw (max-width: 1000px) {
    .bell-btn { width: 34px; height: 34px; }
    .brand { padding: 6px 10px; }
    .brand .live { max-width: clamp(60px, 10cqi, 120px); }
  }
  /* Muy estrecho: el buscador pasa a la lupa (al pulsarla se abre debajo, como en el móvil) */
  @container mapw (max-width: 800px) {
    .search-btn { display: grid; place-items: center; width: 34px; height: 34px; flex: none; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; }
    .search-btn svg { width: 17px; height: 17px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
    .search { display: none; }
    .topbar.searching .search { display: block; flex-basis: 100%; max-width: none; }
  }
}

/* Sprint 218 · al entrar: para qué sirve Trenalia y la petición de compartirla */
.mission { margin: 10px 0 14px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--blue, #2f6fed) 10%, transparent); border: 1px solid color-mix(in srgb, var(--blue, #2f6fed) 35%, transparent); }
.mission p { margin: 0 0 8px; line-height: 1.45; }
.mission .mission-t { font-weight: 800; font-size: 1.05em; }
.mission-sh { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mission-sh a, .mission-go { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line, #ccd); color: inherit; text-decoration: none; font: inherit; font-size: 14px; font-weight: 600; background: var(--panel, #fff); cursor: pointer; }
.mission-go { background: #25d366; border-color: #25d366; color: #fff; }
.mission-ok { margin: 6px 0 0 !important; font-size: 13px; color: var(--muted, #667); min-height: 1em; }

/* Sprint 230 · Paneles a pantalla completa en el móvil (Trenalito, cabina): nada bajo la isla ni la barra de inicio */
.tl, .cab { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); box-sizing: border-box; }

/* Sprint 243 · Metro y tranvía (public/urban-layer.js) */
.urb-chip { display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 6px; font-weight: 800; font-size: 12px; line-height: 1.5; text-align: center; vertical-align: middle; }
.urb-pop .leaflet-popup-content { margin: 10px 12px; min-width: 230px; }
.urb-h { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.urb-sub { font-size: 13px; opacity: .85; margin-bottom: 6px; }
.urb-lines { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.urb-load { font-size: 13px; opacity: .75; padding: 4px 0; }
.urb-alerts { margin: 4px 0 6px; }
.urb-alert { font-size: 12.5px; background: color-mix(in srgb, #e0a020 18%, transparent); border-radius: 6px; padding: 4px 6px; margin-bottom: 3px; }
.urb-deps, .urb-stops { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.urb-dep { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; width: 100%; background: none; border: 0; border-bottom: 1px solid rgba(128,128,128,.2); padding: 5px 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.urb-dep:hover { background: rgba(128,128,128,.08); }
.urb-to { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urb-min { font-weight: 800; font-size: 13px; text-align: right; white-space: nowrap; }
.urb-min small { display: block; font-weight: 400; opacity: .7; font-size: 11px; }
.urb-stops li { display: grid; grid-template-columns: 14px 1fr auto; gap: 6px; align-items: center; font-size: 13px; padding: 2px 0; }
.urb-stops li small { opacity: .7; }
.urb-stops li.done { opacity: .5; }
.urb-stops li.cur { font-weight: 800; }
.urb-dot { width: 10px; height: 10px; border-radius: 50%; border: 3px solid #555; background: #fff; box-sizing: border-box; }
.urb-note { margin-top: 6px; font-size: 11px; opacity: .7; }
.urb-ref { margin-top: 6px; padding: 6px 8px; border-radius: 6px; font-size: 12px; line-height: 1.35; background: rgba(242, 179, 61, .14); border: 1px solid rgba(242, 179, 61, .45); }   /* sprint 251: horario de referencia */
/* Sprint 272 · Avisos por correo: que se vea que hay que confirmar en el correo */
.em-step { margin: 12px 0 0; padding: 9px 11px; border-radius: 9px; background: rgba(90,169,255,.12); border: 1px solid rgba(90,169,255,.35); font-size: 13px; line-height: 1.45; }
.em-done { text-align: left; }
.em-done-ico { font-size: 34px; line-height: 1; margin-bottom: 6px; }
.em-steps { margin: 10px 0 8px; padding-left: 1.3em; font-size: 14px; line-height: 1.5; }
.em-steps li { margin: 4px 0; }
.em-spam { margin: 0 0 6px; font-size: 12.5px; color: var(--muted, #8c9ab3); line-height: 1.4; }
.em-done .fol-b { flex-wrap: wrap; gap: 6px; }
/* Sprint 291: capa «Aviones en vuelo» */
.acft-ic { background: none; border: 0; }
.acft-ic svg { display: block; filter: drop-shadow(0 0 1px rgba(0,0,0,.45)); transition: transform .4s; }
.acft-popup .leaflet-popup-content { margin: 10px 12px; min-width: 190px; }
.acft-h { font-weight: 800; font-size: 15px; }
.acft-al { font-size: 13px; opacity: .85; margin-bottom: 4px; }
.acft-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0; font-size: 13px; }
.acft-pop dt { opacity: .7; } .acft-pop dd { margin: 0; font-weight: 600; }
.acft-note { font-size: 11px; opacity: .75; line-height: 1.35; }
/* Sprint 292: tráfico en carretera (DGT) */
.rd-popup .leaflet-popup-content { margin: 10px 12px; min-width: 200px; }
.rd-h { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rd-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.rd-sub { font-size: 12px; opacity: .85; margin: 3px 0; }
.rd-det { font-size: 13px; margin: 4px 0; }
.rd-note { font-size: 11px; opacity: .75; }
.tpick-dot.gen { background: none; border-radius: 0; width: auto; height: auto; font-size: 16px; line-height: 1; }   /* sprint 304: avión, aeropuerto, puerto, barco */
/* Sprint 304: aeropuertos, puertos y barcos en el mapa */
.hub-ic { background: none; border: 0; }
.hub-ic span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; line-height: 1; background: var(--panel, #fff); border: 2px solid var(--text, #16202f); box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.hub-ic.ap span { border-radius: 6px; }
.hub-ic.pt span, .hub-ic.fe span { border-color: #0e7490; }
.hub-ic.fe span { background: #e0f2fe; }
.hub-popup .leaflet-popup-content, .acft-popup .leaflet-popup-content { max-width: 280px; }
.hub-pop .hub-h { font-weight: 700; font-size: 1.05em; }
.hub-pop .hub-sub, .hub-muted, .hub-src { color: var(--muted, #5b6573); font-size: .88em; }
.hub-p { margin: 4px 0; font-size: .92em; }
.hub-t { margin: 8px 0 2px; font-weight: 600; font-size: .9em; }
.hub-l { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: .9em; }
.hub-l small { color: var(--muted, #5b6573); }
.hub-a { margin: 8px 0 0; font-size: .9em; }
.hub-dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 6px 0; font-size: .92em; }
.hub-dl dt { color: var(--muted, #5b6573); }
.hub-ph img, .acft-ph img { width: 100%; max-height: 150px; object-fit: cover; border-radius: 8px; margin-top: 6px; display: block; }
.hub-ph small, .acft-ph small { display: block; font-size: .78em; color: var(--muted, #5b6573); margin-top: 2px; }
.acft-more { color: var(--muted, #5b6573); font-size: .88em; }
/* Sprint 310 · Autobuses en directo */
.bus-mk { background: none; border: 0; }
.bus-ic { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 18px; padding: 0 4px; box-sizing: border-box;
  border-radius: 6px; background: #c2410c; color: #fff; font: 700 10.5px/1 system-ui, sans-serif; border: 1.5px solid #fff; box-shadow: 0 0 2px rgba(0,0,0,.5); white-space: nowrap; }
.bus-ic b { font-weight: 700; max-width: 40px; overflow: hidden; text-overflow: ellipsis; }
.bus-dir { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; pointer-events: none; }
.bus-dir::before { content: ''; position: absolute; left: 50%; top: -1px; margin-left: -4px; border: 4px solid transparent; border-bottom: 6px solid #c2410c; border-top: 0; }
/* Sprint 311 · Otro país (fr., pt.trenalia.org): fuera lo que solo tiene datos en España */
html[class*="cty-"] .panel.incidents, html[class*="cty-"] .legend .dot.fire, html[class*="cty-"] .legend .dot.quake, html[class*="cty-"] .legend .dot.wx,
html[class*="cty-"] .cerc-legend { display: none !important; }
html[class*="cty-"] .legend div:has(> .dot.fire), html[class*="cty-"] .legend div:has(> .dot.quake), html[class*="cty-"] .legend div:has(> .dot.wx) { display: none !important; }
/* Sprint 322 · Bienvenida: invitación a compartir en grande (titular, cifra en directo, botón claro y redes de un toque) */
.modal .mx-title { font-size: 15px; font-weight: 700; color: var(--muted, #667); margin: 0 0 8px; padding-right: 36px; }
.mission.mx { margin: 0 0 12px; padding: 0; border: 0; background: none; }
.mx-hero { position: relative; overflow: hidden; padding: 18px 16px 14px; border-radius: 16px; color: #fff; text-align: center;
  background: radial-gradient(120% 90% at 100% 0%, #3ddc97 0%, rgba(61,220,151,0) 55%), linear-gradient(135deg, #1747c8 0%, #2f6fed 55%, #6b4ce6 100%);
  box-shadow: 0 10px 30px -12px rgba(31,71,200,.6); }
.mx-hero::after { content: ''; position: absolute; inset: auto -30% -60% -30%; height: 70%; background: radial-gradient(closest-side, rgba(255,255,255,.18), transparent); pointer-events: none; }
.mx-hero p { color: inherit !important; margin: 0; }
.mx-badge { display: inline-block; font-size: 11.5px !important; font-weight: 700; letter-spacing: .02em; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.18); margin-bottom: 10px !important; }
.mx-h { font-size: 22px !important; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
.mx-live { margin-top: 8px !important; font-size: 13.5px !important; font-weight: 600; opacity: .95; display: flex; align-items: center; justify-content: center; gap: 7px; }
.mx-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc97; box-shadow: 0 0 0 0 rgba(61,220,151,.7); animation: mxPing 1.8s infinite; flex: none; }
.mx-sub { margin-top: 8px !important; font-size: 14px !important; line-height: 1.45; opacity: .92; }
.mx-go { position: relative; z-index: 1; display: flex; width: 100%; align-items: center; justify-content: center; gap: 9px; margin: 14px 0 0; min-height: 52px; padding: 0 18px; border: 0; border-radius: 14px;
  background: #fff; color: #1747c8; font: inherit; font-size: 16px; font-weight: 800; white-space: nowrap; cursor: pointer; box-shadow: 0 6px 18px -6px rgba(0,0,0,.45); animation: mxPulse 2.6s ease-in-out 1.2s infinite; }
.mx-go svg { width: 22px; height: 22px; flex: none; }
.mx-go:hover { transform: translateY(-1px); }
.mx-go:focus-visible { outline: 3px solid #3ddc97; outline-offset: 2px; }
.mx-nets { position: relative; z-index: 1; display: flex; justify-content: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.mx-net, .modal-box a.mx-net { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; border: 2px solid rgba(255,255,255,.55); color: #fff; text-decoration: none; cursor: pointer; padding: 0; transition: transform .15s; }
.mx-net svg { width: 22px; height: 22px; }
.mx-net:hover, .mx-net:focus-visible { transform: scale(1.08); outline: none; border-color: #fff; }
.mx-wa { background: #25d366; } .mx-tg { background: #229ed9; } .mx-x { background: #111; } .mx-fb { background: #1877f2; } .mx-copy { background: rgba(255,255,255,.18); }
.mx-ok { position: relative; z-index: 1; margin: 10px 0 0 !important; min-height: 1.2em; font-size: 13.5px !important; font-weight: 700; }
.mx-done .mx-go { animation: none; background: #3ddc97; color: #0b3d27; }
.mx-enter { display: block; width: 100%; margin: 0 0 10px !important; min-height: 46px; font-size: 15px !important; }
.mx-more { border-top: 1px solid var(--line, #dde); padding-top: 8px; margin-top: 4px; }
.mx-more > summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--muted, #667); padding: 6px 0; list-style: none; }
.mx-more > summary::-webkit-details-marker { display: none; }
.mx-more > summary::before { content: '▸ '; display: inline-block; transition: transform .15s; }
.mx-more[open] > summary::before { transform: rotate(90deg); }
.mx-more .mx-t2 { font-weight: 700; color: var(--text, inherit) !important; }
.mx-legal { margin: 6px 0 0 !important; font-size: 12px !important; text-align: center; }
@keyframes mxPing { 0% { box-shadow: 0 0 0 0 rgba(61,220,151,.7); } 70% { box-shadow: 0 0 0 9px rgba(61,220,151,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); } }
@keyframes mxPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
@media (prefers-reduced-motion: reduce) { .mx-go, .mx-dot { animation: none; } }
@media (max-width: 380px) { .mx-h { font-size: 19px !important; } .mx-net { width: 40px; height: 40px; } }
