:root {
  --fondo: #f4f4f6;
  --tarjeta: #ffffff;
  --texto: #18181b;
  --secundario: #63636e;
  --borde: #d9d9df;
  --acento: #d6332d;
  --acento-texto: #ffffff;
  --ok: #1f8a4c;
  --mal: #b42318;
  --aviso: #8a5a00;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #16161a;
    --tarjeta: #222228;
    --texto: #f1f1f3;
    --secundario: #a3a3ad;
    --borde: #3a3a43;
    --acento: #e5483f;
    --ok: #3fbf74;
    --mal: #f0645a;
    --aviso: #e0b04a;
  }
}

* { box-sizing: border-box; }

/* Reglas como "label { display: flex }" anularían el atributo hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h1 small { font-size: 0.85rem; font-weight: normal; color: var(--secundario); }
h2 { font-size: 1rem; margin: 0 0 12px; }

.tarjeta {
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.campos { display: grid; gap: 12px; }
@media (min-width: 640px) {
  .campos { grid-template-columns: 1fr 1fr; }
  .campos .formato { grid-column: 1 / -1; }
}

label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--secundario); }
input[type="text"], select {
  font: inherit;
  color: var(--texto);
  background: var(--fondo);
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: 10px;
  min-height: 44px;
}

fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
legend { font-size: 0.9rem; color: var(--secundario); margin-bottom: 4px; padding: 0; }
fieldset label { flex-direction: row; align-items: center; gap: 6px; color: var(--texto); font-size: 1rem; min-height: 32px; }

.escuchar { text-align: center; margin: 24px 0; }

/* El botón es un vinilo: el disco va en ::before para que gire sin girar el texto. */
#boton-escuchar {
  position: relative;
  isolation: isolate;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: #fff;
  font: 600 1.15rem system-ui, sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
#boton-escuchar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background:
    /* marca de luz en la etiqueta: hace visible el giro */
    radial-gradient(circle at 50% 33%, rgba(255, 255, 255, 0.55) 0 3px, transparent 4px),
    /* etiqueta central */
    radial-gradient(circle, var(--acento) 0 32%, #0c0c0e 32.5% 35%, transparent 35.5%),
    /* reflejos de la luz sobre los surcos */
    conic-gradient(from 20deg, transparent 0 8%, rgba(255, 255, 255, 0.13) 12%, transparent 17% 58%,
      rgba(255, 255, 255, 0.09) 62%, transparent 67%),
    /* surcos */
    repeating-radial-gradient(circle, #151517 0 2px, #1f1f23 2px 3px);
  box-shadow: inset 0 0 0 2px #0c0c0e, inset 0 0 0 5px #2a2a2f;
}
#boton-escuchar.girando::before { animation: girar 1.8s linear infinite; } /* 33⅓ RPM */
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  #boton-escuchar.girando::before { animation-duration: 8s; }
}
#boton-escuchar:disabled { cursor: default; }
#boton-escuchar:disabled:not(.girando) { opacity: 0.75; }
#boton-escuchar:focus-visible { outline: 3px solid var(--texto); outline-offset: 4px; }

.medidor {
  height: 10px;
  max-width: 280px;
  margin: 16px auto 0;
  background: var(--borde);
  border-radius: 5px;
  overflow: hidden;
}
#medidor-barra { height: 100%; width: 0; background: var(--ok); transition: width 60ms linear; }
#medidor-barra.bajo { background: var(--aviso); }

#estado { min-height: 1.4em; margin-top: 12px; color: var(--secundario); }
#proximo { margin: 4px 0 0; }

.boton-secundario {
  margin-top: 8px;
  font: inherit;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--borde);
  background: var(--tarjeta);
  color: var(--texto);
  cursor: pointer;
}
#estado.error { color: var(--mal); }

.ficha { display: flex; gap: 16px; align-items: center; }
.ficha img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.ficha p { margin: 2px 0; }
.titulo { font-size: 1.2rem; font-weight: 600; }
.secundario { color: var(--secundario); font-size: 0.9rem; }
.aviso { color: var(--aviso); }

.boton-youtube {
  display: block;
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  background: var(--acento);
  color: var(--acento-texto);
  font-weight: 600;
  font-size: 1.1rem;
  text-align: center;
  text-decoration: none;
}
.boton-youtube[hidden] { display: none; }
.boton-youtube:focus-visible { outline: 3px solid var(--texto); outline-offset: 3px; }

.video { margin-top: 16px; position: relative; aspect-ratio: 16 / 9; }
.video iframe, #reproductor { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }

.sincronia {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.botones-sincronia { display: flex; gap: 6px; }
.botones-sincronia button {
  font: inherit;
  min-width: 52px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--borde);
  background: var(--fondo);
  color: var(--texto);
  cursor: pointer;
  touch-action: manipulation;
}

.evaluacion { margin-top: 16px; display: grid; gap: 8px; }
.fila-evaluacion { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fila-evaluacion span { flex: 1 1 140px; }
.fila-evaluacion button {
  font: inherit;
  min-width: 64px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--borde);
  background: var(--fondo);
  color: var(--texto);
  cursor: pointer;
}
.fila-evaluacion button.elegido[data-valor="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.fila-evaluacion button.elegido[data-valor="false"] { background: var(--mal); border-color: var(--mal); color: #fff; }
