:root {
  --fondo: #08131a;
  --caja: #11242f;
  --linea: #22404f;
  --texto: #eef6f8;
  --suave: #93b3bf;
  --coral: #ff6b4a;
  --agua: #45cdd3;
  --sobre-color: #07141a;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--fondo); color: var(--texto); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; font: 16px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .35; cursor: default; }
:focus-visible { outline: 3px solid var(--agua); outline-offset: 2px; }
h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin-top: 6px; }
.suave { color: var(--suave); }
.pequeno { font-size: 13px; }
.error { color: #ffb3a3; min-height: 1.4em; }
.icono { width: 24px; height: 24px; fill: currentColor; flex: none; }

input[type="text"] {
  width: 100%; min-height: 48px; padding: 0 14px; font-size: 16px;
  border: 1px solid var(--linea); border-radius: 12px; background: var(--caja);
}
.boton {
  min-height: 52px; padding: 0 22px; border-radius: 14px;
  background: var(--coral); color: var(--sobre-color); font-weight: 700;
}
.boton.secundario { background: var(--caja); color: var(--texto); border: 1px solid var(--linea); }

.puerta {
  min-height: 100dvh; max-width: 420px; margin: 0 auto; padding: 32px 24px;
  display: flex; flex-direction: column; justify-content: center; gap: 16px; text-align: center;
}
.puerta form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- web de las personas grabadas ---------- */
.app {
  height: 100dvh; max-width: 860px; margin: 0 auto; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.cabecera { display: flex; align-items: center; gap: 8px; padding: 10px 16px 6px; }
.cabecera h1, .cabecera h2 { flex: 1; min-width: 0; }
.cabecera h1 small { display: block; font-size: 12px; font-weight: 400; color: var(--suave); }
.contador {
  display: flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--coral); color: var(--coral); font-weight: 700;
}
.contador .icono { width: 18px; height: 18px; }
.contador[aria-pressed="true"] { background: var(--coral); color: var(--sobre-color); }

.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--linea);
  font-size: 14px; white-space: nowrap; color: var(--suave); flex: none;
}
.chip[aria-pressed="true"] { background: var(--texto); border-color: var(--texto); color: var(--sobre-color); font-weight: 600; }
.persona { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; color: var(--texto); }
.fila-chips { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 3px 16px; scrollbar-width: none; }
.fila-chips::-webkit-scrollbar { display: none; }
.herramientas { padding-bottom: 8px; }
.herramientas span { margin-left: auto; font-size: 13px; white-space: nowrap; }

.pista {
  flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
}
.pista::-webkit-scrollbar { display: none; }
.pase {
  flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 2px 16px 16px;
}
.marco {
  --forma: 1.7778; position: relative; flex: none; margin: 0 auto; overflow: hidden;
  aspect-ratio: var(--forma); width: min(100%, calc(48dvh * var(--forma)));
  background: #000; border-radius: 12px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.marco img, .marco video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.marco video:fullscreen { pointer-events: auto; }
.toque { position: absolute; inset: 0; width: 100%; display: grid; place-content: center; color: #fff; }
.toque .icono { width: 64px; height: 64px; opacity: 0; filter: drop-shadow(0 1px 6px rgb(0 0 0 / .7)); }
.marco.pausado .toque .icono { opacity: .92; }
.controles {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 4px;
  padding: 18px 4px 0; background: linear-gradient(transparent, rgb(0 0 0 / .65));
}
.controles button { width: 44px; height: 44px; display: grid; place-content: center; color: #fff; flex: none; }
.barra { flex: 1; min-width: 0; height: 44px; accent-color: var(--coral); touch-action: none; }

.datos { font-size: 13px; color: var(--suave); text-align: center; }
.quiero {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px;
  border: 2px solid var(--coral); border-radius: 16px; color: var(--coral); font-size: 18px; font-weight: 700;
}
.quiero[aria-pressed="true"] { background: var(--coral); color: var(--sobre-color); }
.etiquetas { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { color: var(--texto); }
.tag.otros { border-color: var(--agua); color: var(--agua); }
.tag.mia, .tag.mia[aria-pressed="true"] { background: var(--agua); border-color: var(--agua); color: var(--sobre-color); font-weight: 600; }
.etiquetas form { display: flex; gap: 8px; }
.etiquetas form input { min-height: 44px; }
.anadir { flex: none; padding: 0 16px; border-radius: 12px; border: 1px solid var(--linea); background: var(--caja); }

.vacio { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; padding: 24px; }
footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 16px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--linea);
}
footer span { font-size: 14px; color: var(--suave); font-variant-numeric: tabular-nums; }
.paso { width: 64px; height: 44px; display: grid; place-content: center; border-radius: 12px; background: var(--caja); }

.hoja {
  width: min(100%, 560px); max-width: 100%; max-height: 85dvh; margin: auto auto 0; overflow-y: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--fondo); color: var(--texto); border: 1px solid var(--linea); border-radius: 20px 20px 0 0;
}
.hoja[open] { display: flex; flex-direction: column; gap: 12px; }
dialog::backdrop { background: rgb(0 0 0 / .65); }
.botones { display: flex; gap: 10px; }
.botones .boton { flex: 1; }

.rejilla {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; border: 0; overflow-y: auto;
  background: var(--fondo); color: var(--texto); padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.rejilla .cabecera { position: sticky; top: 0; z-index: 2; background: var(--fondo); }
.miniaturas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; padding: 6px 10px 20px; }
.mini { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.mini img { width: 100%; height: 100%; object-fit: contain; }
.mini span { position: absolute; right: 4px; bottom: 4px; padding: 0 5px; border-radius: 5px; background: rgb(0 0 0 / .7); font-size: 12px; }
.mini b { position: absolute; left: 4px; top: 4px; display: grid; place-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--coral); color: var(--sobre-color); }
.mini b .icono { width: 17px; height: 17px; }
.mini.actual { outline: 3px solid var(--texto); outline-offset: -3px; }

#aviso {
  position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px);
  width: max-content; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; z-index: 10;
  background: var(--texto); color: var(--sobre-color); font-size: 14px; text-align: center;
  opacity: 0; visibility: hidden; transition: opacity .2s, transform .2s, visibility .2s;
}
#aviso.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* Móvil tumbado: vídeo a la izquierda, botones a la derecha */
@media (orientation: landscape) and (max-height: 560px) {
  .app { max-width: none; }
  .app header { display: flex; align-items: center; }
  .app header .cabecera { padding-block: 4px; }
  .app header .cabecera h1 { display: none; }
  .app header .fila-chips { padding: 4px 6px; flex: 1; min-width: 0; }
  .herramientas span { display: none; }
  .pase { display: grid; grid-template-columns: auto minmax(220px, 1fr); grid-template-rows: auto auto 1fr; column-gap: 14px; align-content: start; }
  .marco { grid-row: 1 / span 3; align-self: start; width: min(60vw, calc((100dvh - 122px) * var(--forma))); }
  footer { padding-top: 2px; padding-bottom: calc(2px + env(safe-area-inset-bottom)); }
  .paso { height: 36px; }
}

/* ---------- panel ---------- */
.panel { max-width: 860px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.panel .cabecera { padding-inline: 0; }
.panel .fila-chips { padding-inline: 0; }
.resumen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.resumen div { background: var(--caja); border-radius: 12px; padding: 10px; text-align: center; }
.resumen b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.resumen span { font-size: 12px; color: var(--suave); }
.contenido, .grupo { display: flex; flex-direction: column; gap: 12px; }
.grupo + .grupo { margin-top: 8px; }
.tarjeta { background: var(--caja); border: 1px solid var(--linea); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tarjeta.coincide { border-color: var(--coral); border-width: 2px; }
.ficha { display: flex; gap: 12px; align-items: flex-start; }
.ficha > div { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.ver { position: relative; width: 120px; flex: none; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; display: grid; place-content: center; }
.ver img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.ver .icono { position: relative; filter: drop-shadow(0 1px 4px #000); }
.quienes { display: flex; flex-wrap: wrap; gap: 6px; }
.quienes span { padding: 2px 10px; border-radius: 999px; background: var(--coral); color: var(--sobre-color); font-weight: 600; font-size: 14px; }
.quienes span.insignia { background: var(--texto); }
.rotulos { display: flex; flex-wrap: wrap; gap: 6px; }
.rotulos span { padding: 1px 8px; border-radius: 999px; border: 1px solid var(--agua); color: var(--agua); font-size: 13px; }
.hecho { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.hecho input { width: 24px; height: 24px; accent-color: var(--agua); }
.tarjeta.editado .ficha { opacity: .55; }
.reproductor { width: min(100%, 860px); max-width: 100%; margin: auto; padding: 10px; background: #000; color: var(--texto); border: 1px solid var(--linea); border-radius: 14px; }
.reproductor video { display: block; width: 100%; max-height: 75dvh; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
