:root {
  --morado: #3B1F4A;
  --morado-2: #5A2E6E;
  --oro: #C9A227;
  --oro-claro: #E9D9A0;
  --crema: #FBF7EF;
  --papel: #FFFFFF;
  --tinta: #22182A;
  --gris: #6E6575;
  --linea: #E7E0EC;
  --verde: #2F7D4F;
  --sombra: 0 8px 28px rgba(34, 24, 42, .18);
  --r: 16px;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Playfair Display", Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: var(--sans); color: var(--tinta); background: var(--crema); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

#map { position: fixed; inset: 0; }

/* ---------- barra superior ---------- */
.top {
  position: fixed; top: calc(10px + var(--safe-t)); left: 12px; right: 12px; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px;
  background: var(--morado); color: #fff; border-radius: 14px; box-shadow: var(--sombra);
}
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--oro); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; fill: var(--morado); }
.brand-name { font-family: var(--serif); font-size: 17px; line-height: 1.1; }
.brand-name em { color: var(--oro-claro); }
.jornada { background: none; border: 0; padding: 0; display: flex; align-items: center; gap: 2px; font-size: 13px; color: #E8DDEE; }
.jornada svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.top-actions { display: flex; gap: 8px; }
.round {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--papel);
  box-shadow: var(--sombra); display: grid; place-items: center; flex: none;
}
.round svg { width: 22px; height: 22px; fill: none; stroke: var(--morado); stroke-width: 2; }
.avatar-btn svg { width: 34px; height: 34px; stroke: none; }

.aviso {
  position: fixed; z-index: 5; left: 12px; right: 12px; top: calc(74px + var(--safe-t));
  background: #FFF6D6; border: 1px solid #EAD48A; color: #5B4A12; font-size: 12.5px;
  padding: 7px 12px; border-radius: 10px; box-shadow: var(--sombra);
}

/* ---------- reloj ---------- */
.reloj {
  position: fixed; z-index: 6; left: 12px; right: 12px; bottom: calc(var(--hoja-h, 42vh) + 10px);
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px;
  background: var(--papel); border-radius: var(--r); box-shadow: var(--sombra);
  transition: bottom .25s ease;
}
.play { width: 40px; height: 40px; background: var(--morado); box-shadow: none; }
.play svg { fill: #fff; stroke: none; }
.play .i-pause, .play.on .i-play { display: none; }
.play.on .i-pause { display: block; }
.reloj-cuerpo { flex: 1; min-width: 0; }
.reloj-fila { display: flex; align-items: baseline; gap: 8px; }
.hora { font-family: var(--serif); font-size: 22px; font-variant-numeric: tabular-nums; color: var(--morado); }
.modo { font-size: 12px; color: var(--gris); flex: 1; }
.modo.real { color: var(--verde); font-weight: 600; }
.ahora { border: 1px solid var(--linea); background: var(--crema); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
input[type=range] { width: 100%; accent-color: var(--morado); margin: 4px 0 0; }

/* ---------- hoja inferior ---------- */
.hoja {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; height: var(--hoja-h, 42vh);
  background: var(--crema); border-radius: 20px 20px 0 0; box-shadow: 0 -6px 24px rgba(34,24,42,.14);
  display: flex; flex-direction: column; transition: height .25s ease;
  padding-bottom: var(--safe-b);
}
.asa { width: 44px; height: 5px; background: #D5CCDB; border-radius: 3px; margin: 8px auto 2px; flex: none; cursor: grab; touch-action: none; }
.vista { overflow-y: auto; padding: 4px 16px 18px; flex: 1; overscroll-behavior: contain; }
.hoja-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 0 8px; position: sticky; top: 0; background: var(--crema); z-index: 1; }
h2, h3 { font-family: var(--serif); margin: 0; color: var(--morado); }
h2 { font-size: 22px; }
.sub { color: var(--gris); font-size: 13px; }

.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cof {
  display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; align-items: center;
  background: var(--papel); border: 1px solid var(--linea); border-radius: 14px; padding: 12px 12px 12px 0;
  overflow: hidden; width: 100%; text-align: left;
}
.cof .barra { align-self: stretch; background: var(--c); }
.cof-nombre { font-weight: 700; font-size: 15.5px; }
.cof-estado { font-size: 13px; color: var(--gris); margin-top: 2px; }
.cof-estado b { color: var(--tinta); font-weight: 600; }
.pill { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 4px 9px; white-space: nowrap; }
.pill.antes { background: #EFEAF3; color: var(--morado-2); }
.pill.calle { background: var(--c); color: #fff; }
.pill.recogida { background: #EEE; color: #888; }
.pie { font-size: 12px; color: var(--gris); margin: 14px 2px 0; line-height: 1.45; }

/* ---------- ficha ---------- */
.ficha-cab { display: flex; align-items: center; gap: 10px; padding: 6px 0 10px; position: sticky; top: 0; background: var(--crema); z-index: 1; }
.volver { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--linea); background: var(--papel); display: grid; place-items: center; flex: none; }
.volver svg { width: 18px; height: 18px; fill: none; stroke: var(--morado); stroke-width: 2.2; }
.ficha-cab h2 { flex: 1; }
.ficha-cab .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; }
.nombre-largo { font-size: 12.5px; color: var(--gris); font-style: italic; margin: 0 0 12px; line-height: 1.4; }
.datos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.dato { background: var(--papel); border: 1px solid var(--linea); border-radius: 12px; padding: 9px 11px; }
.dato .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--gris); }
.dato .v { font-weight: 600; font-size: 14px; margin-top: 2px; }
.dato.ancho { grid-column: 1 / -1; }
.ahora-box { background: var(--morado); color: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.45; }
.ahora-box b { color: var(--oro-claro); }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--morado-2); margin: 18px 0 8px; }
.paso { background: var(--papel); border: 1px solid var(--linea); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.paso-tipo { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--oro); font-weight: 700; }
.paso-tit { font-family: var(--serif); font-size: 16.5px; color: var(--morado); margin: 2px 0 6px; }
.paso ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.5; }
.musica { margin-top: 8px; font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.musica svg { width: 16px; height: 16px; fill: var(--morado-2); flex: none; margin-top: 2px; }
table.horario { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--papel); border-radius: 12px; overflow: hidden; border: 1px solid var(--linea); }
.horario td { padding: 7px 10px; border-top: 1px solid var(--linea); }
.horario tr:first-child td { border-top: 0; }
.horario td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.horario .ref { font-size: 11px; color: var(--gris); font-weight: 400; }
.horario tr.pasado td { color: #A69CAD; }
.calles { font-size: 13px; line-height: 1.6; color: #4A3F52; }
.notas { padding-left: 18px; font-size: 13.5px; line-height: 1.5; }
.fuentes { font-size: 12px; padding-left: 18px; color: var(--gris); }
.fuentes a { color: var(--morado-2); }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; background: var(--morado); color: #fff; font-weight: 600; }
.btn.sec { background: var(--papel); color: var(--morado); border: 1px solid var(--linea); }
.acciones { display: flex; gap: 8px; margin: 4px 0 6px; flex-wrap: wrap; }

/* ---------- diálogos ---------- */
.dlg { border: 0; border-radius: 20px; padding: 20px; width: min(92vw, 420px); background: var(--crema); color: var(--tinta); box-shadow: var(--sombra); }
.dlg::backdrop { background: rgba(34,24,42,.45); }
.dlg h3 { font-size: 21px; }
.avatares { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.av { border: 2px solid var(--linea); background: var(--papel); border-radius: 14px; padding: 10px 4px 8px; display: grid; justify-items: center; gap: 4px; font-size: 12.5px; }
.av svg { width: 56px; height: 56px; }
.av[aria-pressed=true] { border-color: var(--morado); background: #F3ECF7; }
.dlg-pie { display: flex; justify-content: flex-end; }
.jornadas { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.jornadas button { width: 100%; text-align: left; border: 1px solid var(--linea); background: var(--papel); border-radius: 12px; padding: 10px 12px; display: flex; justify-content: space-between; }
.jornadas button[disabled] { opacity: .5; cursor: default; }
.jornadas .f { color: var(--gris); font-size: 13px; }

/* ---------- mapa ---------- */
.mk-cruz { width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); display: grid; place-items: center; cursor: pointer; }
.mk-cruz svg { width: 16px; height: 16px; fill: #fff; }
.mk-cruz .et { position: absolute; left: 34px; top: 4px; white-space: nowrap; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.92); color: var(--tinta); padding: 2px 7px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.2); pointer-events: none; }
.mk-paso { width: 26px; height: 26px; border-radius: 8px; background: #fff; border: 2.5px solid var(--c); color: var(--c); box-shadow: 0 2px 6px rgba(0,0,0,.3); display: grid; place-items: center; cursor: pointer; }
.mk-paso svg { width: 17px; height: 17px; fill: var(--c); }
.pop-tit { font-family: var(--serif); color: var(--morado); font-size: 14.5px; margin: 0 0 4px; }
.pop-nota { margin-top: 4px; font-size: 11.5px; }
.btn.mini { padding: 6px 10px; font-size: 12.5px; margin-top: 8px; border-radius: 9px; }
.jornadas button[aria-current=true] { border-color: var(--morado); background: #F3ECF7; }
.mk-yo svg { width: 44px; height: 44px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.maplibregl-popup-content { border-radius: 14px; padding: 12px 14px; font-family: var(--sans); box-shadow: var(--sombra); }
.pop h5 { margin: 0 0 6px; font-size: 13px; color: var(--morado); }
.pop ul { list-style: none; margin: 0; padding: 0; font-size: 13px; display: grid; gap: 4px; }
.pop li { display: flex; gap: 8px; align-items: center; }
.pop .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.pop .t { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; padding-left: 10px; }

/* ---------- escritorio ---------- */
@media (min-width: 900px) {
  .hoja { top: 86px; bottom: 12px; left: 12px; right: auto; width: 400px; height: auto; border-radius: var(--r); }
  .asa { display: none; }
  .reloj { left: 424px; right: auto; width: min(520px, calc(100vw - 448px)); bottom: 16px; }
  .aviso { left: 424px; right: auto; max-width: 520px; top: 74px; }
}
