:root {
  --fondo: #F6F1EA;
  --tarjeta: #FFFFFF;
  --tinta: #2A2622;
  --suave: #7A7068;
  --borde: #E8DFD4;
  --acento: #B5654A;
  --acento-osc: #95503A;
  --salvia: #6F8F76;
  --salvia-claro: #E6EEE6;
  --radio: 18px;
  --sombra: 0 6px 24px rgba(60, 40, 20, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fondo);
  color: var(--tinta);
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
img, video, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.contenedor { max-width: 560px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }

/* ── Entrada ─────────────────────────────── */
.entrada {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: flex-end;
  background:
    linear-gradient(180deg, rgba(246,241,234,0) 0%, rgba(246,241,234,.55) 45%, var(--fondo) 72%),
    url("/fondos/entrada.jpg") center top / cover no-repeat,
    radial-gradient(120% 70% at 50% 0%, #E9D6C4 0%, #F1E6DA 45%, var(--fondo) 100%);
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
}
.entrada .caja { max-width: 440px; width: 100%; margin: 0 auto; }
.marca { font-weight: 800; letter-spacing: .02em; color: var(--acento); font-size: 15px; text-transform: uppercase; }
.entrada h1 { font-size: 32px; line-height: 1.12; margin: 8px 0 8px; font-weight: 800; }
.entrada p { color: var(--suave); margin: 0 0 20px; }
.campo {
  width: 100%; padding: 16px 18px; border-radius: 14px; border: 1.5px solid var(--borde);
  background: #fff; font-size: 17px; outline: none;
}
.campo:focus { border-color: var(--salvia); box-shadow: 0 0 0 4px var(--salvia-claro); }
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px 20px; margin-top: 12px; border: 0; border-radius: 14px;
  background: var(--acento); color: #fff; font-weight: 800; font-size: 17px;
  transition: transform .08s ease, background .2s ease;
}
.boton:active { transform: scale(.98); }
.boton:hover { background: var(--acento-osc); }
.boton[disabled] { opacity: .6; }
.boton.secundario { background: var(--salvia-claro); color: var(--tinta); }
.error { color: #A23B2A; font-size: 15px; margin-top: 10px; min-height: 1.4em; }
.error button { background: none; border: 0; color: var(--acento); font-weight: 800; text-decoration: underline; padding: 0; }

/* ── Barra superior ──────────────────────── */
.barra {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(246,241,234,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--borde);
}
.barra .titulo { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .acciones { display: flex; gap: 6px; align-items: center; }
.chico {
  border: 1px solid var(--borde); background: #fff; color: var(--tinta);
  border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 700;
}
select.chico { appearance: none; padding-right: 12px; }

/* ── Biblioteca ──────────────────────────── */
.seccion { margin: 22px 0 10px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--suave); }
.grilla { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tarjeta {
  background: var(--tarjeta); border-radius: var(--radio); overflow: hidden; box-shadow: var(--sombra);
  border: 0; padding: 0; text-align: left; color: inherit; display: flex; flex-direction: column;
}
.tarjeta .tapa { position: relative; aspect-ratio: 4 / 5; background: linear-gradient(160deg, #EAD7C5, #D9C3B0); }
.tarjeta .tapa img, .tarjeta .tapa video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.inicial { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; font-weight: 800; color: rgba(255,255,255,.85); }
.tarjeta .cuerpo { padding: 10px 12px 12px; }
.tarjeta h3 { margin: 0; font-size: 15px; line-height: 1.25; }
.tarjeta small { color: var(--suave); font-size: 13px; }
.sello {
  position: absolute; left: 8px; top: 8px; z-index: 1;
  background: rgba(255,255,255,.92); color: var(--salvia); font-weight: 800; font-size: 12px;
  padding: 4px 9px; border-radius: 999px;
}
.bloqueada .tapa::after { content: ""; position: absolute; inset: 0; background: rgba(42,38,34,.38); }
.candado {
  position: absolute; inset: 0; z-index: 1; display: grid; place-items: center;
}
.candado span {
  background: rgba(255,255,255,.95); width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 24px; box-shadow: var(--sombra);
}
.etiqueta-off {
  position: absolute; right: 8px; top: 8px; z-index: 2;
  background: var(--acento); color: #fff; font-weight: 800; font-size: 12px; padding: 4px 9px; border-radius: 999px;
}
.precio { margin-top: 6px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.precio b { font-size: 16px; }
.precio s { color: var(--suave); font-size: 13px; }
.mini-boton { display: block; text-align: center; margin-top: 8px; width: 100%; padding: 9px; border-radius: 10px; border: 0; background: var(--acento); color: #fff; font-weight: 800; font-size: 14px; }

/* ── Curso ───────────────────────────────── */
.reproductor { background: #000; border-radius: var(--radio); overflow: hidden; margin-top: 14px; aspect-ratio: 16 / 9; }
.reproductor video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.clase-actual { margin: 12px 2px 4px; font-weight: 800; font-size: 18px; }
.fila-botones { display: flex; gap: 8px; }
.fila-botones .boton { margin-top: 8px; font-size: 15px; padding: 12px; }
.avance { margin: 18px 0 4px; }
.avance .barra-av { height: 8px; border-radius: 999px; background: var(--borde); overflow: hidden; }
.avance .barra-av i { display: block; height: 100%; background: var(--salvia); border-radius: 999px; transition: width .4s ease; }
.avance small { color: var(--suave); }
.modulo h4 { margin: 20px 0 8px; font-size: 15px; }
.clase {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: #fff; border: 1.5px solid transparent; border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; color: inherit;
}
.clase.activa { border-color: var(--salvia); }
.clase .tilde {
  flex: 0 0 28px; height: 28px; border-radius: 50%; border: 2px solid var(--borde);
  display: grid; place-items: center; font-size: 14px; color: #fff;
}
.clase.hecha .tilde { background: var(--salvia); border-color: var(--salvia); }
.clase .info { flex: 1; min-width: 0; }
.clase .info b { display: block; font-size: 15px; }
.clase .info small { color: var(--suave); }

/* ── Lector PDF ──────────────────────────── */
.lector { padding-top: 12px; }
.pagina-pdf { background: #fff; margin: 0 auto 12px; box-shadow: var(--sombra); border-radius: 6px; overflow: hidden; }
.pagina-pdf canvas { width: 100%; height: auto; }
.contador {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 6;
  background: rgba(42,38,34,.85); color: #fff; font-weight: 700; font-size: 14px; padding: 7px 14px; border-radius: 999px;
}

/* ── Mini landing (desbloquear) ──────────── */
.velo { position: fixed; inset: 0; z-index: 20; background: rgba(42,38,34,.5); display: flex; align-items: flex-end; justify-content: center; }
.hoja {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--fondo);
  border-radius: 24px 24px 0 0; padding: 0 0 calc(20px + env(safe-area-inset-bottom));
  animation: subir .25s ease-out;
}
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
.hoja .tapa-grande { position: relative; aspect-ratio: 16 / 10; background: linear-gradient(160deg, #EAD7C5, #D9C3B0); }
.hoja .tapa-grande img, .hoja .tapa-grande video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hoja .dentro { padding: 16px; }
.hoja h2 { margin: 6px 0 6px; font-size: 24px; line-height: 1.15; }
.hoja p { color: var(--suave); margin: 0 0 12px; }
.hoja ul { padding: 0; margin: 0 0 16px; list-style: none; }
.hoja li { padding: 8px 0 8px 30px; position: relative; border-bottom: 1px solid var(--borde); }
.hoja li::before { content: "✓"; position: absolute; left: 4px; color: var(--salvia); font-weight: 800; }
.hoja .precio-grande { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hoja .precio-grande b { font-size: 30px; }
.hoja .precio-grande s { color: var(--suave); }
.hoja .nota { font-size: 14px; background: var(--salvia-claro); border-radius: 12px; padding: 10px 12px; margin-top: 12px; color: var(--tinta); }
.cerrar-hoja { position: absolute; right: 10px; top: 10px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.95); font-size: 18px; }

/* ── Aviso flotante ──────────────────────── */
.aviso {
  position: fixed; left: 16px; right: 16px; top: calc(12px + env(safe-area-inset-top)); z-index: 30;
  max-width: 528px; margin: 0 auto; background: var(--tinta); color: #fff; border-radius: 14px;
  padding: 12px 16px; font-weight: 700; box-shadow: var(--sombra);
}
.cargando { text-align: center; color: var(--suave); padding: 48px 0; }
.pie { text-align: center; color: var(--suave); font-size: 14px; margin-top: 28px; }
.pie a { color: var(--acento); }

@media (min-width: 640px) {
  .grilla { grid-template-columns: repeat(3, 1fr); }
  .velo { align-items: center; }
  .hoja { border-radius: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
