/* AURASUR Live — página pública de seguimiento.
   Concepto: la cinta de balizaje de trail (rosa fluorescente) marca lo ya recorrido;
   el dorsal impreso es la pieza protagonista. Claro = carrera de ciudad, oscuro = trail.
   Cada evento puede cambiar el acento, el tema, la tipografía y los logos desde el panel. */

:root {
  /* Ciudad (claro) */
  --bg: #edf1f5;
  --surface: #ffffff;
  --surface-2: #e3e9ef;
  --ink: #0f1c2b;
  --muted: #56677a;
  --line: #d2dbe4;
  --accent: #d81b60;
  --accent-ink: #ffffff;
  --ok: #0b8f5b;
  --est: #b86e00;
  --warn: #cf2f3a;
  --route-pending: #93a5b8;
  --paper: #ffffff;
  --paper-ink: #0f1c2b;
  --paper-muted: #5c6b7b;
  --paper-line: #d9e0e7;
  --hole: #edf1f5;
  --scrim: rgba(15, 28, 43, 0.42);
  --font-display: 'Archivo', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: clamp(16px, 3.2vw, 32px);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12202e;
    --surface: #192a3b;
    --surface-2: #213549;
    --ink: #e8eef4;
    --muted: #8fa3b7;
    --line: #2a3f55;
    --accent: #ff4f9a;
    --accent-ink: #1d0611;
    --ok: #3dd68c;
    --est: #ffb224;
    --warn: #ff6b70;
    --route-pending: #4f6884;
    --paper: #f2f5f8;
    --paper-ink: #12202e;
    --paper-muted: #5a6979;
    --paper-line: #d3dbe3;
    --hole: #12202e;
    --scrim: rgba(4, 10, 18, 0.62);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12202e;
  --surface: #192a3b;
  --surface-2: #213549;
  --ink: #e8eef4;
  --muted: #8fa3b7;
  --line: #2a3f55;
  --accent: #ff4f9a;
  --accent-ink: #1d0611;
  --ok: #3dd68c;
  --est: #ffb224;
  --warn: #ff6b70;
  --route-pending: #4f6884;
  --paper: #f2f5f8;
  --paper-ink: #12202e;
  --paper-muted: #5a6979;
  --paper-line: #d3dbe3;
  --hole: #12202e;
  --scrim: rgba(4, 10, 18, 0.62);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
body.noscroll { overflow: hidden; }
body.has-dock { padding-bottom: 110px; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
img { max-width: 100%; }
svg { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.bar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 10px;
  padding-inline: var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; flex: 1; }
.brand-mark {
  flex: none; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); overflow: hidden;
  font-family: var(--font-display); font-weight: 800; font-stretch: 75%; font-size: 15px;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: var(--surface); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-stretch: 87%; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--muted); }
.live-clock {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; white-space: nowrap;
}
.lc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-clock[data-state="live"] .lc-dot { background: var(--accent); animation: pulse 1.6s ease-out infinite; }
.live-clock[data-state="warn"] .lc-dot { background: var(--est); }
.live-clock[data-state="done"] .lc-dot { background: var(--ok); }
.lc-label { color: var(--muted); }
.lc-time { font-weight: 700; font-stretch: 87%; }
.search-open {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  background: var(--ink); color: var(--bg); border: 0; cursor: pointer; font-weight: 600;
}
.search-open svg { width: 18px; height: 18px; }
@media (max-width: 640px) {
  .live-clock .lc-label { display: none; }
  .search-open span { display: none; }
  .search-open { padding: 9px; }
  .brand-sub { display: none; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  100% { box-shadow: 0 0 0 9px transparent; }
}

/* ---------- Estructura ---------- */
.main { max-width: 1280px; margin: 0 auto; padding-block: 20px 40px; padding-inline: var(--gutter); }
.view { display: grid; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 700; font-stretch: 87%; }
.panel-foot { margin: 8px 0 0; font-size: 13px; }
.link { font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 16px;
  border-radius: 12px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  font-weight: 650; cursor: pointer; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.lg-line { width: 22px; height: 0; border-top: 4px solid var(--accent); border-radius: 2px; }
.lg-line.todo { border-top: 3px dashed var(--route-pending); }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.lg-dot.conf { background: var(--ok); }
.lg-cp { width: 11px; height: 11px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--surface); }

/* ---------- Portada del evento ---------- */
.home-hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; align-items: start; }
.hh-copy { position: relative; display: grid; gap: 18px; padding-top: 6px; min-width: 0; }
.home-hero.has-cover .hh-copy { padding: 22px; border-radius: var(--radius); overflow: hidden; color: #fff; }
.cover { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: -1; }
.cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8, 14, 22, 0.25), rgba(8, 14, 22, 0.82)); }
.home-hero.has-cover .ev-meta { color: rgba(255, 255, 255, 0.82); }
.ev-title {
  margin: 0; font-family: var(--font-display); font-weight: 800; font-stretch: 72%;
  font-size: clamp(2.6rem, 5.4vw, 4.6rem); line-height: 0.92; letter-spacing: -0.012em; text-wrap: balance;
}
.ev-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 15px; }
.big-search { position: relative; }
.big-search label {
  display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 56px; border-radius: 14px;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink);
}
.big-search label:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.big-search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.big-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 17px; }
.results { list-style: none; margin: 0; padding: 0; }
.results.floating {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; max-height: 360px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.4);
}
.result {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%;
  padding: 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer;
}
.result:hover, .result.active { background: var(--surface-2); }
.r-main { display: flex; flex-direction: column; min-width: 0; }
.r-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sub { font-size: 13px; color: var(--muted); }
.r-state { font-size: 13px; font-weight: 600; color: var(--muted); }
.r-state[data-status="finished"] { color: var(--ok); }
.no-res { padding: 12px; color: var(--muted); }

.bibchip {
  display: inline-block; min-width: 3.2ch; padding: 2px 7px; border-radius: 6px; text-align: center;
  background: var(--paper); color: var(--paper-ink); border: 1px solid var(--paper-line);
  font-family: var(--font-display); font-weight: 800; font-stretch: 70%; font-size: 15px; line-height: 1.25;
}

.race-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.race-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line);
}
.race-card[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rc-code { font-family: var(--font-display); font-weight: 800; font-stretch: 62%; font-size: 34px; line-height: 0.9; letter-spacing: -0.01em; }
.race-card[aria-selected="true"] .rc-code { color: var(--accent); }
.rc-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.rc-name { font-weight: 650; font-size: 14px; }
.rc-state { font-size: 13px; font-weight: 600; }
.rc-count { font-size: 12.5px; color: var(--muted); }
.home-hero.has-cover .race-card { color: var(--ink); }

.favs-strip { display: grid; gap: 8px; }
.favs-title { margin: 0; font-size: 14px; font-weight: 650; color: var(--muted); }
.favs-strip ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fav-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; width: 100%; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer;
}
.fc-main { display: flex; justify-content: space-between; gap: 10px; min-width: 0; }
.fc-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.fc-state[data-status="finished"] { color: var(--ok); font-weight: 600; }
.fc-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.fc-bar span { display: block; height: 100%; width: 0; background: var(--accent); }

.hh-map { padding-bottom: 12px; }
.leaders { display: grid; gap: 8px; }
.leaders:empty { display: none; }
.ld-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ld-col h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ld-col ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ld-row { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; align-items: center; width: 100%; padding: 6px 4px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.ld-row:hover { background: var(--surface); }
.ld-pos { font-family: var(--font-display); font-weight: 800; font-stretch: 62%; font-size: 26px; line-height: 1; color: var(--accent); }
.ld-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ld-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) { .ld-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 980px) {
  .home-hero { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Ruta ---------- */
.route-wrap { position: relative; }
.route-svg { width: 100%; height: auto; max-height: 64vh; touch-action: manipulation; }
.route-grid-dot { fill: var(--line); }
.route-img { opacity: 0.95; }
.route-casing { fill: none; stroke: var(--surface); stroke-linecap: round; stroke-linejoin: round; }
.route-pending { fill: none; stroke: var(--route-pending); stroke-linecap: round; stroke-linejoin: round; }
.route-done { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; }
.route-cp { cursor: pointer; }
.cp-ring { fill: var(--surface); stroke: var(--ink); }
.route-cp.kind-start .cp-ring, .route-cp.kind-finish .cp-ring { fill: var(--ink); stroke: var(--surface); }
.cp-label { fill: var(--muted); font-family: var(--font-body); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.cp-label-name { fill: var(--ink); font-weight: 650; }
.route-cp.untimed .cp-ring { stroke: var(--muted); stroke-dasharray: 2 2; }
.route-cp:hover .cp-ring, .route-cp:focus-visible .cp-ring { stroke: var(--accent); }
.field-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.2px; vector-effect: non-scaling-stroke; opacity: 0.9; }
.field-dot[data-status="confirmed"] { fill: var(--ok); }
.field-dot[data-status="arriving"], .field-dot[data-status="overdue"] { fill: var(--est); }
.field-dot[data-status="dnf"], .field-dot[data-status="dsq"] { fill: var(--muted); opacity: 0.5; }
.field-bin { fill: var(--accent); fill-opacity: 0.38; stroke: var(--accent); stroke-opacity: 0.85; stroke-width: 1.2px; vector-effect: non-scaling-stroke; }
.view-loading { min-height: 50vh; display: grid; place-items: center; color: var(--muted); }
.mk-halo { fill: var(--accent); opacity: 0.2; transform-box: fill-box; transform-origin: center; }
.mk-dot { fill: var(--accent); stroke: var(--surface); }
.mk-tag-bg { fill: var(--ink); }
.mk-tag-text { fill: var(--bg); font-family: var(--font-display); font-weight: 800; font-stretch: 75%; }
.route-marker[data-status="estimated"] .mk-halo, .route-marker[data-status="arriving"] .mk-halo { animation: halo 1.8s ease-out infinite; }
.route-marker[data-status="confirmed"] .mk-dot, .route-marker[data-status="finished"] .mk-dot { fill: var(--ok); }
.route-marker[data-status="confirmed"] .mk-halo, .route-marker[data-status="finished"] .mk-halo { fill: var(--ok); }
.route-marker[data-status="overdue"] .mk-dot, .route-marker[data-status="arriving"] .mk-dot { fill: var(--est); }
.route-marker[data-status="overdue"] .mk-halo { fill: var(--est); }
.route-marker.fav .mk-tag-bg { fill: var(--surface-2); stroke: var(--line); }
.route-marker.fav .mk-tag-text { fill: var(--ink); }
.route-marker.fav .mk-dot { fill: var(--surface); stroke: var(--accent); }
@keyframes halo { 0% { transform: scale(0.55); opacity: 0.45; } 100% { transform: scale(1.35); opacity: 0; } }

.route-tip, .pf-tip {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, -120%);
  padding: 6px 10px; border-radius: 9px; background: var(--ink); color: var(--bg); font-size: 13px; white-space: nowrap;
  display: flex; flex-direction: column; line-height: 1.3;
}
.pf-tip { transform: none; }
.route-tip span, .pf-tip span { opacity: 0.8; font-size: 12px; }
.cp-pop {
  position: absolute; z-index: 6; width: min(280px, calc(100% - 16px)); padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 20px 44px -20px rgba(0, 0, 0, 0.5);
}
.pop-close { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); }
.pop-title { display: block; font-size: 16px; font-family: var(--font-display); font-stretch: 87%; padding-right: 26px; }
.pop-km { font-size: 13px; color: var(--muted); }
.pop-dl { margin: 10px 0; display: grid; gap: 6px; }
.pop-dl div { display: flex; justify-content: space-between; gap: 12px; }
.pop-dl dt { color: var(--muted); font-size: 13px; }
.pop-dl dd { margin: 0; font-weight: 650; text-align: right; }
.pop-flag { display: inline-block; font-size: 12px; font-weight: 650; padding: 3px 8px; border-radius: 999px; }
.pop-flag.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pop-flag.est { color: var(--est); background: color-mix(in srgb, var(--est) 14%, transparent); }
.pop-note { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- Mapa real ---------- */
.map-box { height: min(62vh, 520px); min-height: 320px; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.map-box .leaflet-container { font-family: var(--font-body); }
.map-mk { position: relative; }
.mm-dot { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.mm-dot[data-status="confirmed"], .mm-dot[data-status="finished"] { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); }
.mm-dot[data-status="arriving"], .mm-dot[data-status="overdue"] { background: var(--est); }
.mm-tag { position: absolute; left: 0; top: -34px; transform: translateX(-50%); padding: 1px 7px; border-radius: 5px; background: var(--ink); color: var(--bg); font-family: var(--font-display); font-weight: 800; font-stretch: 75%; font-size: 13px; white-space: nowrap; }
.map-mk.fav .mm-dot { width: 13px; height: 13px; left: -6.5px; top: -6.5px; background: var(--surface); border-color: var(--accent); box-shadow: none; }
.map-mk.fav .mm-tag { top: -28px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-size: 12px; }
.map-pop .pop-dl { margin: 8px 0; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface) !important; color: var(--ink) !important; }

/* ---------- Altimetría ---------- */
.profile-wrap { position: relative; }
.profile-svg { width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.pf-grid { stroke: var(--line); stroke-dasharray: 2 4; }
.pf-axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.pf-area { fill: var(--surface-2); }
.pf-line { fill: none; stroke: var(--route-pending); stroke-width: 1.6; }
.pf-grad-top { stop-color: var(--accent); stop-opacity: 0.5; }
.pf-grad-bottom { stop-color: var(--accent); stop-opacity: 0.05; }
.pf-line-done { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linejoin: round; }
.pf-cp { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.pf-cp.kind-start, .pf-cp.kind-finish { stroke: var(--ink); opacity: 0.6; }
.pf-cp-label { fill: var(--muted); font-size: 11px; font-weight: 650; font-family: var(--font-body); }
.pf-marker-line { stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 4 3; }
.pf-marker-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 3; }
.pf-marker[data-status="confirmed"] .pf-marker-dot, .pf-marker[data-status="finished"] .pf-marker-dot { fill: var(--ok); }
.pf-marker[data-status="overdue"] .pf-marker-dot { fill: var(--est); }
.pf-marker-bg { fill: var(--ink); }
.pf-marker-km { fill: var(--bg); font-size: 12.5px; font-weight: 700; font-family: var(--font-body); }
.pf-marker-ele { fill: var(--bg); font-size: 12px; opacity: 0.8; font-family: var(--font-body); }
.pf-hover-line { stroke: var(--muted); stroke-width: 1; }
.pf-hover-dot { fill: var(--ink); }
.mini-stats, .pf-stats { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.mini-stats div, .pf-stats div { display: flex; flex-direction: column; }
.mini-stats dt, .pf-stats dt { font-size: 12px; color: var(--muted); }
.mini-stats dd, .pf-stats dd { margin: 0; font-weight: 700; font-stretch: 87%; }
.pf-stats { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 2fr); gap: 10px 18px; }
.pf-stats dd { font-size: 17px; }
.pf-stats .wide dd { font-size: 15px; font-weight: 600; font-stretch: 100%; }
@media (max-width: 860px) {
  .pf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-stats .wide { grid-column: 1 / -1; }
}

/* ---------- Participante ---------- */
.crumbs { margin-bottom: -4px; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; color: var(--muted); padding: 4px 0; }
.back svg { width: 18px; height: 18px; }
.back:hover { color: var(--ink); }
.runner-top { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .runner-top { grid-template-columns: minmax(0, 1fr); } }

/* El dorsal: la única pieza con volumen */
.bib {
  position: relative; overflow: hidden; border-radius: 14px; padding-bottom: 16px;
  background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 1px 0 var(--paper-line), 0 26px 50px -26px rgba(0, 0, 0, 0.55);
  transform: rotate(-0.6deg);
}
.bib-band {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 46px;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-display); font-weight: 700; font-stretch: 85%; font-size: 15px;
}
.bib-event { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bib-race { font-weight: 800; font-stretch: 70%; font-size: 20px; }
.pin { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--hole); box-shadow: inset 0 1.5px 2.5px rgba(0, 0, 0, 0.45); z-index: 2; }
.pin.tl { top: 14px; left: 16px; } .pin.tr { top: 14px; right: 16px; }
.pin.bl { bottom: 14px; left: 16px; } .pin.br { bottom: 14px; right: 16px; }
.bib-num {
  padding: 8px 20px 0; text-align: center; font-family: var(--font-display); font-weight: 800; font-stretch: 62%;
  font-size: clamp(6.2rem, 15vw, 10rem); line-height: 0.84; letter-spacing: -0.02em;
}
.bib-num[data-len="5"], .bib-num[data-len="6"] { font-size: clamp(4.8rem, 12vw, 7.6rem); }
.bib-name { text-align: center; padding: 10px 20px 2px; font-family: var(--font-display); font-weight: 700; font-stretch: 87%; font-size: 22px; line-height: 1.15; text-wrap: balance; }
.bib-meta { list-style: none; margin: 4px 0 0; padding: 0 24px; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; color: var(--paper-muted); font-size: 14px; }
.bib-meta .flag { margin-right: 5px; }
.bib-sponsors { margin: 14px 34px 0; padding-top: 10px; border-top: 1px dashed var(--paper-line); display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; font-family: var(--font-display); font-weight: 700; font-stretch: 80%; font-size: 13px; color: var(--paper-muted); }

.runner-live { display: grid; gap: 14px; min-width: 0; }
.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px 6px 11px; border-radius: 999px;
  font-weight: 700; font-size: 14px; color: var(--muted); background: var(--surface-2);
}
.status-pill i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.status-pill[data-status="confirmed"], .status-pill[data-status="finished"] { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.status-pill[data-status="estimated"], .status-pill[data-status="arriving"] { color: var(--est); background: color-mix(in srgb, var(--est) 15%, transparent); }
.status-pill[data-status="estimated"] i, .status-pill[data-status="arriving"] i { animation: blink 1.6s ease-in-out infinite; }
.status-pill[data-status="overdue"], .status-pill[data-status="dnf"], .status-pill[data-status="dsq"] { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.status-pill.flash { animation: flash 1.2s ease-out; }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.status-note { margin: -6px 0 0; color: var(--muted); font-size: 14.5px; max-width: 62ch; }
.km-now { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.km-val { font-family: var(--font-display); font-weight: 800; font-stretch: 62%; font-size: clamp(3.6rem, 9vw, 5.6rem); line-height: 0.85; letter-spacing: -0.01em; }
.km-unit { font-family: var(--font-display); font-weight: 800; font-stretch: 75%; font-size: 26px; }
.km-of { color: var(--muted); font-size: 15px; }
.progress { position: relative; height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.pg-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 999px; }
.pg-tick { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: var(--ink); opacity: 0.35; border-radius: 1px; }
.stat-grid { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.stat-grid > div { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.stat-grid dt { font-size: 12.5px; color: var(--muted); }
.stat-grid dd { margin: 2px 0 0; font-size: 22px; font-weight: 750; font-stretch: 82%; line-height: 1.15; overflow-wrap: anywhere; }
.stat-grid small { display: block; font-size: 12.5px; color: var(--muted); }
.stat-grid .wide { grid-column: span 3; }
.stat-grid .wide dd { font-size: 26px; }
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid .wide { grid-column: span 2; }
  .stat-grid dd { font-size: 19px; }
}
.runner-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.fav-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.track-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .track-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Checkpoints ---------- */
.cp-list { list-style: none; margin: 0; padding: 0; }
.cp-item { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; padding-bottom: 16px; }
.cp-item::before { content: ''; position: absolute; left: 14px; top: 26px; bottom: 0; width: 2px; background: var(--line); }
.cp-item.done::before { background: var(--accent); }
.cp-item:last-child::before { display: none; }
.cp-item:last-child { padding-bottom: 0; }
.node { grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; margin-left: 2px; z-index: 1; }
.node svg { width: 15px; height: 15px; color: var(--surface); }
.node.done { background: var(--ok); }
.node.current { background: var(--surface); border: 3px solid var(--est); box-shadow: 0 0 0 4px color-mix(in srgb, var(--est) 20%, transparent); }
.node.current.overdue { border-color: var(--warn); }
.node.pending { background: var(--surface); border: 2px solid var(--route-pending); }
.node.missed { background: var(--surface); border: 2px dashed var(--muted); }
.node.info-passed { width: 14px; height: 14px; margin: 6px 0 0 8px; background: var(--accent); }
.cp-item.info-passed::before { background: var(--accent); }
.cp-main { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.cp-name { font-weight: 650; }
.cp-item.pending .cp-name { color: var(--muted); font-weight: 600; }
.cp-km { font-size: 13px; color: var(--muted); white-space: nowrap; }
.cp-data { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.cp-clock { font-weight: 700; font-size: 15px; }
.cp-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--muted); }
.cp-eta { font-weight: 600; color: var(--est); }
.cp-eta.muted { color: var(--muted); font-weight: 500; }
.seg-bar { display: block; height: 5px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.seg-bar span { display: block; height: 100%; background: var(--est); }

/* ---------- Clasificación ---------- */
.board-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); }
.seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.sel select { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 0 10px; max-width: 220px; }
.board-search { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); flex: 1 1 180px; min-width: 0; }
.board-search svg { width: 16px; height: 16px; color: var(--muted); }
.board-search input { border: 0; outline: 0; background: transparent; min-width: 0; flex: 1; }
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; color: var(--muted); }
.chip-toggle svg { width: 16px; height: 16px; }
.chip-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.table-scroll { overflow-x: auto; margin: 0 -4px; }
.board-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.board-table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.board-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.board-table tbody tr { cursor: pointer; }
.board-table tbody tr:hover { background: var(--surface-2); }
.board-table tr.me { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.board-table tr.out td { color: var(--muted); }
.board-table tr.empty td { cursor: default; color: var(--muted); padding: 22px 8px; text-align: center; }
.c-fav { width: 36px; padding-right: 0 !important; }
.c-pos { font-weight: 750; font-stretch: 82%; font-size: 16px; white-space: nowrap; }
.c-name .nm { display: block; font-weight: 650; }
.c-name .sub, .c-last .sub { display: flex; flex-wrap: wrap; gap: 0 8px; font-size: 12.5px; color: var(--muted); }
.c-name .sub-cat, .c-name .sub-last { display: none; }
.c-last .lp { display: block; font-weight: 550; }
.c-km .est { color: var(--est); font-weight: 600; }
.c-km .conf { color: var(--ok); font-weight: 600; }
.c-time { font-weight: 650; white-space: nowrap; }
.c-gap, .c-pace { white-space: nowrap; }
.star { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--route-pending); cursor: pointer; }
.star svg { width: 19px; height: 19px; }
.star.on { color: var(--accent); }
.star:hover { color: var(--accent); }
.board-foot { display: flex; justify-content: center; padding-top: 12px; font-size: 13px; }
.board.compact .board-foot { display: none; }
@media (max-width: 760px) {
  .c-opt { display: none; }
  .c-name .sub-cat { display: inline; }
}
@media (max-width: 560px) {
  .c-opt2 { display: none; }
  .board-table { font-size: 14px; }
  .c-bib, .c-last { display: none; }
  .c-name .sub-last { display: inline; }
  .c-name .sub-team { display: none; }
}

/* ---------- Búsqueda ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: flex; justify-content: center; align-items: flex-start; padding: max(6vh, env(safe-area-inset-top, 0px)) 16px 16px; }
.sheet-box { width: min(640px, 100%); max-height: 86vh; overflow: auto; background: var(--surface); border-radius: 18px; padding: 12px; box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.6); }
.sheet-head { display: flex; gap: 8px; position: sticky; top: 0; background: var(--surface); padding-bottom: 8px; }
.sheet-input { flex: 1; display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--accent); }
.sheet-input svg { width: 20px; height: 20px; color: var(--muted); }
.sheet-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 17px; min-width: 0; }
.sheet-close { width: 50px; height: 50px; }
.sheet-favs h3 { margin: 10px 8px 4px; font-size: 13px; color: var(--muted); font-weight: 650; }
.sheet-hint { padding: 8px 10px; margin: 0; font-size: 14px; }
@media (max-width: 640px) {
  .sheet { padding: 0; }
  .sheet-box { border-radius: 0; max-height: 100%; height: 100%; padding-top: max(12px, env(safe-area-inset-top, 0px)); }
}

/* ---------- Avisos ---------- */
.toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 50; display: grid; gap: 8px; justify-items: end; }
body.has-dock .toasts { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: min(360px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 12px; border: 0; text-align: left; cursor: pointer;
  background: var(--ink); color: var(--bg); box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.6); animation: toastIn 0.35s ease-out;
}
.toast svg { width: 20px; height: 20px; color: var(--ok); flex: none; }
.toast span { display: flex; flex-direction: column; line-height: 1.3; }
.toast small { opacity: 0.75; }
.toast.out { opacity: 0; transform: translateY(8px); transition: 0.35s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Controles de la demo ---------- */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 8px; width: max-content; max-width: calc(100vw - 24px);
  border-radius: 18px; background: var(--ink); color: var(--bg); box-shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.6);
}
.dock .btn.start-demo { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 800; font-stretch: 85%; letter-spacing: 0.02em; }
.dock .icon-btn { border-color: color-mix(in srgb, var(--bg) 25%, transparent); color: var(--bg); }
.dock .btn.ghost { color: var(--bg); border-color: color-mix(in srgb, var(--bg) 25%, transparent); min-height: 40px; }
.dock .seg { background: transparent; border-color: color-mix(in srgb, var(--bg) 25%, transparent); }
.dock .seg button { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.dock .seg button[aria-checked="true"] { background: var(--bg); color: var(--ink); }
.dock .sel select { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 25%, transparent); }
.dock .sel option { color: #111; background: #fff; }
.dock-note { font-size: 12.5px; opacity: 0.75; padding: 0 6px; }
@media (max-width: 700px) {
  .dock { left: 8px; right: 8px; transform: none; width: auto; max-width: none; border-radius: 16px; }
  .dock .theme-sel, .dock-note { display: none; }
  body.has-dock { padding-bottom: 150px; }
}

/* ---------- Pie ---------- */
.foot { max-width: 1280px; margin: 0 auto; padding-block: 8px 36px; padding-inline: var(--gutter); display: grid; gap: 18px; }
.sponsors { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.foot-label { font-size: 13px; color: var(--muted); }
.sponsors ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 30px; align-items: center; }
.sponsors li span { font-family: var(--font-display); font-weight: 800; font-stretch: 75%; font-size: 19px; color: var(--muted); }
.sponsors img { height: 36px; width: auto; object-fit: contain; }
.sponsors a { text-decoration: none; }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 30px; align-items: center; }
.foot-note { margin: 0; max-width: 72ch; font-size: 13px; color: var(--muted); }
.foot-org { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.foot-org img { height: 26px; width: auto; }

.fatal { max-width: 560px; margin: 18vh auto; padding: 0 16px; text-align: center; }
.fatal h1 { font-family: var(--font-display); font-stretch: 80%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
