/* Notebook look from the prototype: ruled paper, red margin, rings,
   Atkinson Hyperlegible for reading and Kalam for "handwritten" titles. */

@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url("/fonts/atkinson-400.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("/fonts/atkinson-700.woff2") format("woff2"); }
@font-face { font-family: "Kalam"; font-weight: 400; font-display: swap; src: url("/fonts/kalam-400.woff2") format("woff2"); }
@font-face { font-family: "Kalam"; font-weight: 700; font-display: swap; src: url("/fonts/kalam-700.woff2") format("woff2"); }

:root {
  --paper: #FFFFFC;
  --ink: #2A3348;
  --ink-soft: #557399;
  --blue: #1F4FD1;
  --blue-dark: #163A9C;
  --rule: #BCD0E8;
  --margin: #EE9AAE;
  --ring: #C3CBD7;
  --ring-fill: #E4E8EE;
  --ok: #1E7B4F;
  --ok-bg: #E3F4EA;
  --bad: #B3261E;
  --bad-bg: #FBE7E6;
  --highlight: #FFE98A;
  --tab-hoy: #FFE07A;
  --tab-temas: #F6C3D2;
  --tab-tutor: #C9DAF3;
  --line: 32px;
  --left: 66px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: transparent; /* the paper lives on html and .paper */
  color: var(--ink);
  font: 17px/var(--line) "Atkinson Hyperlegible", system-ui, sans-serif;
}

/* Ruled paper, margin lines and rings, fixed behind the content. */
.paper {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 14px 14px, var(--ring-fill) 0 5px, var(--ring) 5.5px 6.5px, transparent 7px) 0 4px / 28px 30px repeat-y,
    linear-gradient(var(--margin), var(--margin)) 52px 0 / 1.5px 100% no-repeat,
    linear-gradient(var(--margin), var(--margin)) 56px 0 / 1.5px 100% no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px) var(--line)) 0 128px / 100% 100% no-repeat;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(110px + env(safe-area-inset-bottom, 0px)) var(--left);
  outline: none;
}

h1, h2, .hand {
  font-family: "Kalam", cursive;
  color: var(--blue);
  font-weight: 700;
}
h1 { font-size: 40px; line-height: 1.1; margin: 8px 0 16px; }
h2 { font-size: 26px; line-height: 1.2; margin: 24px 0 8px; }
p { margin: 0 0 var(--line); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.fecha {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
}
.fecha .hand { font-size: 20px; font-weight: 400; border-bottom: 1.5px solid #9DB6D6; padding: 0 6px; }

/* ---------- buttons ---------- */

button, .btn, a, [role="button"], input[type="radio"] + label { touch-action: manipulation; }
button, .btn, .tab, .option {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 12px 20px;
  font: 700 19px/1.2 "Atkinson Hyperlegible", system-ui, sans-serif;
  color: #fff; background: var(--blue);
  border: 0; border-bottom: 4px solid var(--blue-dark); border-radius: 14px;
  cursor: pointer; text-decoration: none;
  transition: transform 120ms var(--ease-out), border-bottom-width 120ms var(--ease-out);
}
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .45; cursor: default; }
.btn.secundario { background: #fff; color: var(--ink); border: 1.5px solid #9DB6D6; border-bottom-width: 1.5px; }
.btn.secundario:active { transform: scale(0.98); }
.btn + .btn { margin-top: 12px; }

.link { background: none; border: 0; padding: 4px 0; color: var(--blue); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(1.08); }
  .option:hover { border-color: var(--blue); }
  .tab:hover { filter: brightness(1.03); }
}

:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 6px; }

/* ---------- home ---------- */

.tareas { list-style: none; padding: 0; margin: 0 0 var(--line); }
.tareas li { display: grid; grid-template-columns: 22px 1fr; column-gap: 14px; margin-left: -36px; }
.tareas .check { width: 20px; height: 20px; margin-top: 6px; border: 2px solid var(--ink); border-radius: 4px; display: grid; place-items: center; font-size: 14px; line-height: 1; color: var(--blue); }
.tareas .check.hecho { border-color: var(--blue); }
.tareas strong { font-size: 18px; }
.tareas .detalle { grid-column: 2; color: var(--ink-soft); }
.marcador { background: var(--highlight); padding: 0 6px; border-radius: 3px; }

.semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 8px 0 var(--line); }
.dia { border: 1.5px solid #9DB6D6; border-radius: 10px; background: #fff; text-align: center; line-height: 1.2; padding: 6px 0; font-size: 14px; font-family: "Kalam", cursive; font-weight: 700; }
.dia small { display: block; font-family: "Atkinson Hyperlegible", sans-serif; font-weight: 400; font-size: 12px; color: var(--ink-soft); }
.dia.hoy { border: 2px dashed var(--blue); color: var(--blue); }
.dia.estudiado { background: var(--ok-bg); border-color: var(--ok); }
.dia.examen { background: var(--tab-temas); border-color: var(--bad); }
.racha { display: flex; justify-content: space-between; align-items: baseline; }
.racha h2 { margin: 0; color: var(--ink); }

/* ---------- session ---------- */

.barra-sesion { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.salir { min-height: 44px; padding: 6px 16px; border-radius: 22px; border: 1.5px solid #9DB6D6; background: #fff; font: 700 16px "Atkinson Hyperlegible", sans-serif; color: var(--ink); cursor: pointer; }
.salir:active { transform: scale(0.97); }
.bloque-nombre { font-family: "Kalam", cursive; font-weight: 700; color: var(--blue); font-size: 18px; text-align: right; line-height: 1.2; }
.progreso { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.progreso progress { flex: 1; height: 10px; accent-color: var(--blue); }

.consigna { font-family: "Kalam", cursive; color: var(--blue); font-weight: 700; font-size: 20px; margin: 16px 0 0; line-height: 1.3; }
.enunciado { font-size: 20px; font-weight: 700; line-height: 1.5; margin: 4px 0 20px; }

fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
.opciones { display: grid; gap: 10px; }
.opciones.dos { grid-template-columns: 1fr 1fr; }
.option { position: relative; }
.option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.option span {
  display: block; min-height: 52px; padding: 12px 16px;
  background: #fff; border: 2px solid #9DB6D6; border-radius: 14px;
  line-height: 1.35; font-size: 18px;
  transition: transform 100ms var(--ease-out), border-color 100ms;
}
.option input:active + span { transform: scale(0.98); }
.option input:checked + span { border-color: var(--blue); background: #EEF3FD; box-shadow: inset 0 0 0 1px var(--blue); }
.option input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.option.correcta span { border-color: var(--ok); background: var(--ok-bg); }
.option.incorrecta span { border-color: var(--bad); background: var(--bad-bg); }
.opciones.dos .option span { text-align: center; font-weight: 700; font-size: 20px; }

input[type="text"], textarea, select {
  font: 16px/1.5 "Atkinson Hyperlegible", system-ui, sans-serif; /* >= 16px: no iOS zoom */
  font-size: max(16px, 1em);
  width: 100%; padding: 10px 12px; color: var(--ink);
  background: #fff; border: 2px solid #9DB6D6; border-radius: 12px;
}
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px #C9DAF3; }
textarea { min-height: 140px; resize: vertical; }
.contador { font-size: 13px; color: var(--ink-soft); text-align: right; }

.ordenar { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; }
.ordenar li {
  position: relative; display: grid; grid-template-columns: 22px 22px 1fr auto; align-items: center; gap: 8px;
  min-height: 64px; padding: 8px 8px 8px 10px;
  background: #fff; border: 2px solid #9DB6D6; border-bottom-width: 4px; border-radius: 16px;
  line-height: 1.35; font-size: 17px;
  touch-action: none; /* the card owns the drag; scroll the page from outside the cards */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: grab;
  transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
  view-transition-name: match-element;
}
.ordenar .agarre { color: #9DB6D6; font-size: 22px; line-height: 1; text-align: center; }
.ordenar .num { font-family: "Kalam", cursive; font-weight: 700; color: var(--blue); font-size: 22px; }
/* Track phase: the card is the finger, so no transition while dragging. */
.ordenar li.arrastrando {
  z-index: 3; cursor: grabbing; transition: none;
  border-color: var(--blue); box-shadow: 0 12px 24px rgb(31 79 209 / .22);
}
.ordenar li.arrastrando .agarre { color: var(--blue); }
.ordenar.ordenando li:not(.arrastrando) { transition: transform 200ms var(--ease-out); }
.ordenar li:active:not(.arrastrando) { border-color: var(--blue); }
.ordenar .mover { display: flex; gap: 6px; }
.ordenar .mover button {
  display: grid; place-items: center; width: 48px; height: 48px;
  border-radius: 12px; border: 2px solid #9DB6D6; border-bottom-width: 4px;
  background: #EEF3FD; color: var(--blue); cursor: pointer;
  transition: transform 100ms var(--ease-out);
}
.ordenar .mover button svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.ordenar .mover button:active { transform: translateY(2px); border-bottom-width: 2px; }
.ordenar .mover button:disabled { opacity: .3; }
.ordenar.bloqueada li { cursor: default; touch-action: auto; }

.unir { display: grid; gap: 12px; margin-bottom: 20px; }
.unir label { display: grid; gap: 4px; font-weight: 700; line-height: 1.35; }

/* feedback */
.feedback { border-radius: 14px; padding: 14px 16px; margin: 0 0 20px; line-height: 1.45; border: 2px solid; }
.feedback.bien { background: var(--ok-bg); border-color: var(--ok); }
.feedback.mal { background: var(--bad-bg); border-color: var(--bad); }
.feedback.neutro { background: #fff; border-color: #9DB6D6; }
.feedback .titulo { font-family: "Kalam", cursive; font-size: 24px; font-weight: 700; line-height: 1.2; display: block; margin-bottom: 6px; }
.feedback.bien .titulo { color: var(--ok); }
.feedback.mal .titulo { color: var(--bad); }
.feedback p { margin: 6px 0 0; }
.feedback .pagina { font-size: 14px; color: var(--ink-soft); }
.feedback .ia { margin-top: 10px; padding-top: 10px; border-top: 1.5px dashed #9DB6D6; }
.feedback .ia[aria-busy="true"] { color: var(--ink-soft); }
.autoevaluacion { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.autoevaluacion .btn + .btn { margin-top: 0; }

.aparece { animation: aparece 180ms var(--ease-out); }
@keyframes aparece { from { opacity: 0; transform: translateY(6px); } }

/* end of session */
.estrellas { font-size: 44px; letter-spacing: 6px; color: #E2B100; line-height: 1.2; margin: 8px 0 16px; }

/* ---------- topics ---------- */
.bloque { background: #fff; border: 1.5px solid #9DB6D6; border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; line-height: 1.4; }
.bloque h3 { margin: 0 0 6px; font-size: 18px; }
.barra { height: 12px; background: var(--ring-fill); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.barra > i { display: block; height: 100%; background: var(--blue); border-radius: 6px; }
.bloque ul { margin: 8px 0 0; padding-left: 18px; font-size: 15px; color: var(--ink-soft); }
.bloque .estrella { color: #E2B100; }

/* ---------- tutor ---------- */
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 15px; line-height: 1.35; margin-bottom: 20px; }
th, td { border: 1px solid #9DB6D6; padding: 6px 8px; text-align: left; vertical-align: top; }
th { background: #EEF3FD; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.bajo { color: var(--bad); font-weight: 700; }
.tarjeta { background: #fff; border: 1.5px solid #9DB6D6; border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; line-height: 1.45; }
.tarjeta ul { padding-left: 20px; margin: 6px 0; }
.version { font-size: 12px; color: var(--ink-soft); text-align: center; margin-top: 24px; }
.aviso { background: var(--highlight); border-radius: 10px; padding: 10px 12px; line-height: 1.4; margin-bottom: 16px; }

/* ---------- playful interactions ---------- */
.conectar-ayuda { font-size: 14px; color: var(--ink-soft); line-height: 1.4; margin: 6px 0 16px; }

/* Conectar con líneas */
.conectar { position: relative; display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; margin-bottom: 4px; touch-action: none; }
.conectar-col { display: grid; gap: 10px; align-content: start; position: relative; z-index: 1; }
.conectar-lineas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
.conectar-lineas line { stroke-width: 4; stroke-linecap: round; }
.conectar-lineas line.temporal { stroke-dasharray: 2 8; }
.conectar-lineas line.bien { stroke: var(--ok); }
.conectar-lineas line.mal { stroke: var(--bad); stroke-dasharray: 8 6; }
.conectar-ficha {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 10px;
  background: #fff; border: 2px solid #9DB6D6; border-bottom-width: 4px; border-radius: 14px;
  font: 600 15px/1.3 "Atkinson Hyperlegible", system-ui, sans-serif; color: var(--ink); text-align: left; cursor: pointer;
  transition: transform 120ms var(--ease-out), border-color 120ms, background 120ms;
}
.conectar-ficha.der { flex-direction: row-reverse; text-align: right; }
.conectar-punto { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 3px solid #9DB6D6; background: #fff; }
.conectar-ficha.izq .conectar-punto { margin-left: auto; order: 2; }
.conectar-ficha.der .conectar-punto { margin-right: auto; order: 2; }
.conectar-ficha:active { transform: scale(0.97); }
.conectar-ficha[aria-pressed="true"] { border-color: var(--blue); background: #EEF3FD; transform: translateY(-2px); }
.conectar-ficha.unida { border-color: var(--color); }
.conectar-ficha.unida .conectar-punto { border-color: var(--color); background: var(--color); }
.conectar.bloqueado .conectar-ficha { cursor: default; }

/* Encuentra las parejas */
.parejas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pareja {
  min-height: 64px; padding: 10px; border-radius: 14px; border: 2px solid; border-bottom-width: 5px;
  font: 600 15px/1.3 "Atkinson Hyperlegible", system-ui, sans-serif; color: var(--ink); cursor: pointer;
  transition: transform 140ms var(--ease-out), opacity 220ms var(--ease-out);
}
.pareja.izq { background: #EEF3FD; border-color: #8FA9E6; }
.pareja.der { background: #FDEEF3; border-color: #E79AB4; }
.pareja:active { transform: scale(0.96); }
.pareja[aria-pressed="true"] { transform: translateY(-4px) rotate(-1.5deg); box-shadow: 0 8px 16px rgb(42 51 72 / .18); border-color: var(--ink); }
.pareja.encontrada { animation: pop 420ms var(--ease-out) forwards; cursor: default; }
@keyframes pop { 40% { transform: scale(1.12); background: var(--ok-bg); border-color: var(--ok); } 100% { transform: scale(0.85); opacity: 0.18; background: var(--ok-bg); border-color: var(--ok); } }
.pareja.sacude { animation: sacude 320ms ease-in-out; border-color: var(--bad); }
@keyframes sacude { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Clasificar en canastas */
.clasificar { display: grid; gap: 10px; margin-bottom: 12px; }
.clasificar.g2 { grid-template-columns: 1fr 1fr; }
.clasificar.g3 { grid-template-columns: 1fr; }
.canasta {
  min-height: 120px; border: 2.5px dashed var(--color); border-radius: 16px; padding: 6px;
  background: color-mix(in srgb, var(--color) 6%, white);
  transition: transform 140ms var(--ease-out), background 140ms;
}
.clasificar.g3 .canasta { min-height: 88px; }
.canasta-nombre {
  display: block; width: 100%; min-height: 44px; border: 0; border-radius: 10px; padding: 6px;
  background: var(--color); color: #fff; font: 700 16px/1.2 "Kalam", cursive; cursor: pointer;
}
.canasta.lista .canasta-nombre { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color) 30%, white); }
.canasta.encima { transform: scale(1.03); background: color-mix(in srgb, var(--color) 16%, white); }
.canasta-fichas { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; }
.bandeja { display: flex; flex-wrap: wrap; gap: 8px; min-height: 48px; margin: 0 0 4px; }
.bandeja.vacia { min-height: 0; }
.ficha {
  min-height: 44px; padding: 8px 12px; border-radius: 22px; border: 2px solid #9DB6D6; border-bottom-width: 4px;
  background: #fff; color: var(--ink); font: 600 15px/1.25 "Atkinson Hyperlegible", system-ui, sans-serif;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform 120ms var(--ease-out), opacity 120ms;
}
.ficha:active { transform: scale(0.96); }
.ficha[aria-pressed="true"] { border-color: var(--blue); background: #EEF3FD; transform: translateY(-3px); }
.ficha.levantada { opacity: 0.3; }
.ficha.bien { border-color: var(--ok); background: var(--ok-bg); }
.ficha.mal { border-color: var(--bad); background: var(--bad-bg); text-decoration: line-through; }
.ficha-fantasma { position: fixed; z-index: 100; margin: 0; pointer-events: none; box-shadow: 0 12px 24px rgb(31 79 209 / .25); border-color: var(--blue); transition: none; }

/* Completar con fichas */
.hueco {
  display: inline-block; min-width: 96px; min-height: 36px; margin: 0 4px; padding: 0 10px; vertical-align: baseline;
  border: 0; border-bottom: 3px dashed var(--blue); border-radius: 6px 6px 0 0; background: #EEF3FD;
  font: inherit; color: var(--blue); cursor: pointer;
}
.hueco.vacio { color: transparent; }
.hueco.cae { animation: cae 260ms var(--ease-out); }
@keyframes cae { from { transform: translateY(-10px) scale(1.1); } }
.completar-fichas .bandeja { margin-bottom: 20px; }
.completar-fichas .ficha { cursor: pointer; touch-action: manipulation; }

/* ---------- video player ---------- */
.video { margin: 0 0 20px; }
.video-escenario {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 14px; border: 2px solid var(--ink); background: #10141f;
}
.video-escenario iframe, .video-escenario > div:first-child { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Transparent layer: taps toggle play and never reach YouTube's own links. */
.video-capa { position: absolute; inset: 0; z-index: 1; cursor: pointer; touch-action: manipulation; }
/* Cover while paused/ended: hides YouTube's pause and end screens. */
.video-portada {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 0; cursor: pointer; color: var(--blue);
  background:
    repeating-linear-gradient(to bottom, transparent 0 23px, var(--rule) 23px 24px),
    var(--paper);
  font: 700 22px/1.2 "Kalam", cursive;
}
.video-portada[hidden] { display: none; }
.video-play-grande {
  display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%;
  background: var(--blue); color: #fff; font: 32px/1 system-ui, sans-serif; padding-left: 6px;
  border-bottom: 4px solid var(--blue-dark);
  transition: transform 120ms var(--ease-out);
}
.video-portada:active .video-play-grande { transform: scale(0.94); }
.video-portada-titulo { max-width: 85%; text-align: center; }
.video-controles { margin-top: 10px; display: grid; gap: 6px; }
.video-fila { display: flex; align-items: center; gap: 8px; }
.video-btn {
  min-width: 48px; height: 48px; padding: 0 10px; border-radius: 12px;
  border: 1.5px solid #9DB6D6; background: #fff; color: var(--ink);
  font: 700 17px/1 "Atkinson Hyperlegible", system-ui, sans-serif; cursor: pointer;
  transition: transform 100ms var(--ease-out);
}
.video-btn:active { transform: scale(0.95); }
.video-fila .video-btn:nth-child(2) { background: var(--blue); color: #fff; border-color: var(--blue-dark); min-width: 64px; }
.video-tiempo { flex: 1; text-align: center; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.video-barra { width: 100%; height: 32px; accent-color: var(--blue); margin: 0; touch-action: pan-y; }
.video-estado { font-size: 14px; color: var(--ink-soft); margin: 6px 0 0; }
.video-estado:empty { display: none; }

/* Fullscreen: real API where it exists, viewport fill on iPhone. */
.video:fullscreen, .video.video-llena {
  background: #000; display: flex; flex-direction: column; justify-content: center; padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.video.video-llena { position: fixed; inset: 0; z-index: 50; margin: 0; }
.video:fullscreen .video-escenario, .video.video-llena .video-escenario { border: 0; border-radius: 0; max-height: 82dvh; margin: 0 auto; width: 100%; }
.video:fullscreen .video-controles, .video.video-llena .video-controles { padding: 0 12px 8px; }
.video:fullscreen .video-tiempo, .video.video-llena .video-tiempo { color: #cfd8e8; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 0 10px env(safe-area-inset-bottom, 0px);
  background: linear-gradient(to bottom, transparent, var(--paper) 30%);
  max-width: 560px; margin: 0 auto;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 64px; padding-top: 8px;
  border: 1.5px solid #9DB6D6; border-bottom: 0; border-radius: 14px 14px 0 0;
  font-weight: 700; font-size: 15px; line-height: 1.2; color: var(--ink); text-decoration: none;
  transform: translateY(8px);
  transition: transform 160ms var(--ease-out);
}
.tab span { font-size: 18px; }
.tab-hoy { background: var(--tab-hoy); }
.tab-temas { background: var(--tab-temas); }
.tab-tutor { background: var(--tab-tutor); }
.tab[aria-current="page"] { transform: translateY(0); border-color: var(--ink); }
body.en-sesion .tabs { display: none; }

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

.noscript { margin: 40px var(--left); }

/* AI practice */
.etiqueta-extra { display: block; font: 700 12px/1.2 "Atkinson Hyperlegible", sans-serif; color: #fff; background: #6A3DB8; border-radius: 10px; padding: 2px 8px; margin-top: 2px; width: max-content; margin-left: auto; }
.feedback .truco { font-size: 15px; }
.interruptor { display: flex; gap: 10px; align-items: center; line-height: 1.4; margin-bottom: 10px; }
.interruptor input { width: 24px; height: 24px; accent-color: var(--blue); }
.lista-ia { padding-left: 18px; font-size: 15px; line-height: 1.4; }
.lista-ia li { margin-bottom: 6px; }
.lista-ia .link { margin-left: 6px; font-size: 14px; }

/* ---------- gamification ---------- */
.cabecera-hoy { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.monedero {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 20px;
  background: #FFF3C4; border: 2px solid #E2B100; border-bottom-width: 4px;
  font: 700 18px/1 "Atkinson Hyperlegible", sans-serif; color: var(--ink); text-decoration: none;
}
.monedero:active { transform: translateY(2px); border-bottom-width: 2px; }
.tarjeta-simulacro {
  display: grid; gap: 4px; margin: 20px 0; padding: 14px 16px; border-radius: 16px; text-decoration: none; color: var(--ink);
  background: #F1EAFB; border: 2px solid #6A3DB8; border-bottom-width: 5px; line-height: 1.4;
}
.tarjeta-simulacro .hand { color: #6A3DB8; font-size: 22px; }
.tarjeta-simulacro:active { transform: translateY(2px); border-bottom-width: 3px; }
.sello-oro { font-weight: 700; color: #9A6B00; }
.puntos-hoy { background: #FFF3C4; border: 2px solid #E2B100; border-radius: 16px; padding: 12px 16px; margin-bottom: 20px; line-height: 1.4; }
.puntos-hoy .hand { font-size: 28px; color: #9A6B00; }
.puntos-hoy ul { margin: 6px 0 0; padding-left: 18px; font-size: 15px; }
.bloque .medalla { margin: 4px 0 0; font-weight: 700; font-size: 18px; line-height: 1.3; }
.bloque .siguiente { margin: 2px 0 0; color: var(--ink-soft); line-height: 1.3; }
.bloque.medalla-oro { border-color: #E2B100; background: #FFFBEA; }
.bloque.medalla-plata { border-color: #9AA6B8; }
.bloque.medalla-bronce { border-color: #C58B5A; }
.meta-simulacro { display: grid; gap: 4px; background: #F1EAFB; border: 2px dashed #6A3DB8; border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; line-height: 1.4; }
.meta-simulacro .hand { color: #6A3DB8; font-size: 24px; }
.reloj { font: 700 18px/1 "Atkinson Hyperlegible", sans-serif; font-variant-numeric: tabular-nums; background: #fff; border: 1.5px solid #9DB6D6; border-radius: 12px; padding: 8px 12px; }
.sello-meta { font: 700 22px/1.3 "Kalam", cursive; color: #9A6B00; background: #FFF3C4; border: 2px solid #E2B100; border-radius: 16px; padding: 12px 16px; }
.repaso-simulacro { padding-left: 18px; line-height: 1.4; }
.repaso-simulacro li { margin-bottom: 12px; }
.repaso-simulacro p { margin: 2px 0 0; }
.monedero-grande { display: flex; align-items: baseline; gap: 8px; margin: 0 0 16px; }
.monedero-grande strong { font: 700 48px/1 "Kalam", cursive; color: #9A6B00; }
.monedero-grande span:first-child { font-size: 36px; }
.premio { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; background: #fff; border: 2px solid #9DB6D6; border-bottom-width: 4px; border-radius: 16px; padding: 12px; margin-bottom: 12px; line-height: 1.35; }
.premio .btn { grid-column: 1 / -1; min-height: 48px; font-size: 17px; }
.premio-icono { font-size: 40px; text-align: center; }
.premio .precio { display: block; font-weight: 700; color: #9A6B00; }
.premio .candado { display: block; font-size: 14px; color: var(--ink-soft); }
.premio.bloqueado { opacity: .75; }
.canjes { padding-left: 18px; line-height: 1.5; }
.como-gano { margin-top: 16px; line-height: 1.4; }
.como-gano summary { font-weight: 700; color: var(--blue); cursor: pointer; }

.monedero small { font-size: 12px; font-weight: 700; color: #9A6B00; margin-left: 4px; }
.nivel-actual { display: grid; gap: 6px; background: #fff; border: 2px solid #E2B100; border-radius: 16px; padding: 12px 14px; margin-bottom: 16px; line-height: 1.35; }
.nivel-actual .hand { font-size: 24px; color: #9A6B00; }
.nivel-actual .barra > i { background: #E2B100; }
.insignias { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.insignia { display: grid; justify-items: center; gap: 2px; text-align: center; padding: 8px 2px; border-radius: 14px; border: 2px dashed #C3CBD7; background: #F6F7FA; line-height: 1.15; }
.insignia span { font-size: 28px; filter: grayscale(1); opacity: .5; }
.insignia small { font-size: 11px; color: var(--ink-soft); }
.insignia.ganada { border: 2px solid #E2B100; background: #FFFBEA; }
.insignia.ganada span { filter: none; opacity: 1; }
.insignia.ganada small { color: var(--ink); font-weight: 700; }
.grupo-nivel.cerrado .premio { opacity: .6; }
.premio.caro .btn { opacity: .55; }

/* ---------- habit loop: daily goal, chest, next reward, combos ---------- */
.meta-dia { display: grid; grid-template-columns: 56px 1fr; gap: 4px 12px; align-items: center; background: #fff; border: 2px solid #9DB6D6; border-bottom-width: 4px; border-radius: 16px; padding: 10px 12px; margin: 0 0 12px; line-height: 1.3; }
.meta-dia strong { display: block; font-size: 17px; }
.meta-dia span { color: var(--ink-soft); font-size: 15px; }
.meta-dia.cumplida { border-color: #E2B100; background: #FFFBEA; }
.meta-dia .cofre, .meta-dia .cofre-resultado { grid-column: 1 / -1; }
.anillo { width: 56px; height: 56px; transform: rotate(-90deg); }
.anillo circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.anillo .fondo { stroke: var(--ring-fill); }
.anillo .avance { stroke: var(--blue); transition: stroke-dasharray 400ms var(--ease-out); }
.meta-dia.cumplida .anillo .avance { stroke: #E2B100; }
.btn.cofre { background: #E2B100; border-bottom-color: #9A6B00; color: #2A2000; margin-top: 6px; }
.cofre-resultado { margin: 0; text-align: center; font: 700 30px/1.2 "Kalam", cursive; color: #9A6B00; }
.cofre-resultado:empty { display: none; }
.cofre-resultado.abierto { animation: cofre 600ms var(--ease-out); }
@keyframes cofre { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(1); } }
.proximo-premio { display: grid; gap: 4px; background: #F1EAFB; border: 2px solid #6A3DB8; border-bottom-width: 4px; border-radius: 16px; padding: 10px 14px; margin: 0 0 16px; color: var(--ink); text-decoration: none; line-height: 1.35; }
.proximo-premio .hand { color: #6A3DB8; font-size: 20px; }
.comodin { font-size: 15px; color: var(--ink-soft); }
.feedback { position: relative; }
.mas-uno { position: absolute; right: 14px; top: 10px; font: 700 18px/1 "Atkinson Hyperlegible", sans-serif; color: #9A6B00; animation: sube 900ms var(--ease-out) forwards; pointer-events: none; }
@keyframes sube { from { transform: translateY(8px); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(-18px); opacity: 0; } }
.combo { margin: 8px 0 0; font: 700 20px/1.2 "Kalam", cursive; color: #C2410C; }
.desbloqueo { display: grid; gap: 6px; background: #FFF3C4; border: 2px solid #E2B100; border-radius: 16px; padding: 12px 16px; margin-bottom: 16px; line-height: 1.35; }
.desbloqueo .hand { font-size: 26px; color: #9A6B00; }
.desbloqueo p { margin: 0; font-size: 20px; font-weight: 700; }
.casi { font: 700 18px/1.35 "Atkinson Hyperlegible", sans-serif; color: #6A3DB8; }
.explica { color: var(--ink-soft); line-height: 1.35; margin-bottom: 8px; }
.escalera { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.escalon { display: grid; grid-template-columns: 44px 1fr; gap: 4px 10px; align-items: center; background: #F6F7FA; border: 2px dashed #C3CBD7; border-radius: 14px; padding: 8px 12px; line-height: 1.3; }
.escalon .premio-icono { font-size: 30px; filter: grayscale(.8); opacity: .7; grid-row: span 2; }
.escalon .btn, .escalon .requisito, .escalon .estado-canje { grid-column: 2; }
.escalon .btn { min-height: 44px; font-size: 16px; }
.escalon .requisito { font-size: 14px; color: var(--ink-soft); }
.escalon.logrado { background: #FFFBEA; border: 2px solid #E2B100; }
.escalon.logrado .premio-icono { filter: none; opacity: 1; }
.estado-canje { font-weight: 700; color: #9A6B00; }
.estado-canje.entregado { color: var(--ok); }
.boton-sonido { margin-left: auto; margin-right: 8px; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid #9DB6D6; background: #fff; font-size: 20px; cursor: pointer; }
.boton-sonido:active { transform: scale(0.94); }

/* ---------- guided home + welcome ---------- */
body.en-hoy main { padding-bottom: calc(180px + env(safe-area-inset-bottom, 0px)); }
.barra-estado { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.chip { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; padding: 4px 12px; border-radius: 20px; font: 700 17px/1 "Atkinson Hyperlegible", sans-serif; text-decoration: none; color: var(--ink); border: 2px solid; border-bottom-width: 4px; }
.chip small { font-size: 13px; font-weight: 700; }
.racha-chip { background: #FFEDE0; border-color: #F08A3C; }
.estrellas-chip { background: #FFF3C4; border-color: #E2B100; }
.barra-estado .boton-sonido { margin-left: auto; margin-right: 0; }
.saludo { margin: 6px 0 8px; font-size: 36px; }
.semana-compacta { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.punto-dia { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #C3CBD7; background: #fff; font: 700 13px/1 "Atkinson Hyperlegible", sans-serif; color: var(--ink-soft); }
.punto-dia.estudiado { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.punto-dia.hoy { border: 2px dashed var(--blue); color: var(--blue); }
.punto-dia.examen { background: var(--tab-temas); border-color: var(--bad); }
.examen-en { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-left: 4px; }
.paso { display: grid; grid-template-columns: 56px 1fr; gap: 4px 12px; align-items: center; background: #fff; border: 2px solid var(--blue); border-bottom-width: 5px; border-radius: 18px; padding: 12px 14px; margin-bottom: 12px; line-height: 1.3; }
.paso strong { display: block; font: 700 22px/1.2 "Kalam", cursive; color: var(--blue); }
.paso span { color: var(--ink-soft); font-size: 15px; }
.paso-icono { font-size: 40px; text-align: center; }
.paso-simulacro { border-color: #6A3DB8; }
.paso-simulacro strong { color: #6A3DB8; }
.paso-listo { border-color: var(--ok); }
.paso-listo strong { color: var(--ok); }
/* The main action is always on screen, above the tabs. */
.cta-fija {
  position: fixed; z-index: 5; left: 0; right: 0; margin: 0 auto;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  width: min(560px - 82px, calc(100% - 82px)); transform: translateX(25px);
  min-height: 64px; font-size: 22px; box-shadow: 0 6px 18px rgb(31 79 209 / .25);
}
body.en-sesion .cta-fija { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.cta-fija.dos { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; min-height: 0; box-shadow: none; }
.cta-fija.dos .btn + .btn { margin-top: 0; }
.tutorial-icono { font-size: 72px; line-height: 1.1; margin: 12px 0 0; text-align: center; }
.tutorial-texto { font-size: 19px; line-height: 1.5; }
.puntos-tutorial { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.puntos-tutorial span { width: 10px; height: 10px; border-radius: 50%; background: var(--ring-fill); }
.puntos-tutorial span.hecho { background: #9DB6D6; }
.puntos-tutorial span.activo { background: var(--blue); width: 26px; border-radius: 6px; }
#nombre { font-size: 22px; padding: 14px; margin-top: 8px; }

/* Exam-style stimulus box ("Lea la siguiente información:") */
.estimulo { margin: 8px 0 4px; }
.estimulo span { display: block; font-size: 14px; font-weight: 700; color: var(--ink-soft); margin-bottom: 4px; }
.estimulo p { margin: 0; padding: 10px 12px; background: #fff; border: 2px solid var(--ink); line-height: 1.45; font-size: 17px; }
.nota-simulacro { display: flex; align-items: baseline; gap: 10px; }
.nota-simulacro span { font-weight: 700; color: var(--ink-soft); }
.nota-simulacro strong { font: 700 56px/1 "Kalam", cursive; color: var(--blue); }
.indicadores { list-style: none; padding: 0; margin: 8px 0 0; font-size: 15px; line-height: 1.35; }
.indicadores li { margin-bottom: 4px; color: var(--ink-soft); }
.indicadores li.dominado { color: var(--ok); font-weight: 700; }
.indicadores li.en-camino { color: var(--ink); }
.retro { margin-top: 8px; }
.retro ul { margin: 4px 0 0; padding-left: 20px; }
.retro.ok strong { color: var(--ok); }
.retro.falta strong { color: #9A6B00; }
.retro.confusion strong { color: var(--bad); }
.feedback .libro { margin-top: 10px; padding-top: 10px; border-top: 1.5px dashed #9DB6D6; }
.ia-retro { font-size: 15px; color: #6A3DB8; }
