/* examARnow — sistema visual "Huerto de bolsillo" (ronda visual, petición M).
   Inspirado en el lenguaje de Duolingo (formas gordotas, borde inferior 3D,
   tipografía con carácter, mucho blanco, celebraciones) pero con identidad propia:
   - Motivo de marca: el BOLSILLO COSIDO (pespunte discontinuo) de la maceta de Pip.
     Aparece en las insignias de examen, estados vacíos y la marca.
   - Disciplina de color: verde brote = acción/acierto · azul = selección/info ·
     oro = XP/racha/premio · rojo = fallo · barro = marca. Nada más en la misma pantalla.
   - Contraste AA comprobado en todos los pares de texto (ver docs/agents/visual.md). */

:root {
  /* Neutros */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --surface-3: #eceef2;
  --border: #e4e6eb;
  --border-strong: #cdd2da;
  --ink: #262a35;
  --ink-2: #6b7180;            /* 4.9:1 sobre blanco */

  /* Paleta: *-bright solo rellenos/decoración; el resto vale para texto (AA). */
  --green: #12873a; --green-bright: #5cc84a; --green-dark: #0b6a2c; --green-soft: #e6f8df; --green-ink: #0b6a2c;
  --blue: #1766c8; --blue-bright: #3aa6ff; --blue-dark: #0e4f9e; --blue-soft: #e3f2ff;
  --gold: #8a5a00; --gold-bright: #ffc531; --gold-dark: #e0a100; --gold-soft: #fff5d6;
  --clay: #b5530b; --clay-bright: #ef7a3d; --clay-dark: #c9561f; --clay-soft: #fff0e6;
  /* Alias de la ronda anterior (se mantienen para no romper marcado existente). */
  --orange: var(--clay); --orange-bright: #ff9a1f; --orange-dark: var(--gold-dark); --orange-soft: #fff1df;
  --yellow: var(--gold); --yellow-bright: var(--gold-bright); --yellow-dark: var(--gold-dark); --yellow-soft: var(--gold-soft);
  --purple: #7c3aed; --purple-bright: #a066f2; --purple-soft: #f1e8ff; /* solo icono de navegación */
  --pink-bright: #ff86b0;

  --brand: #12873a;
  --brand-soft: #e6f8df;
  --focus: #1766c8;
  --success: #12873a;
  --success-soft: #e6f8df;
  --danger: #c21d36;           /* 5.0:1 sobre --danger-soft */
  --danger-bright: #ff5a5f;
  --danger-dark: #d63a40;
  --danger-soft: #ffe5e6;
  --warning: #a16207;
  --highlight: #ffe066;
  --accent: #1766c8;
  --accent-soft: #e3f2ff;
  --on-accent: #ffffff;
  --btn-bg: var(--green);
  --btn-ink: #ffffff;
  --btn-edge: var(--green-dark);

  /* Forma */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --bw: 2px;                   /* grosor de borde de todo */
  --lip: 4px;                  /* borde inferior 3D */
  --shadow-1: none;
  --shadow-2: 0 12px 32px rgb(38 42 53 / .16);
  --press: 0 var(--lip) 0 var(--btn-edge);
  --edge: 0 var(--lip) 0 var(--border);

  /* Espaciado (base 4) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* Tipografía: 8 tamaños (escala ~1.25) */
  --font-display: "Bricolage Grotesque", "Figtree", Arial, Helvetica, system-ui, sans-serif;
  --font-ui: "Figtree", Arial, Helvetica, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Source Serif 4", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --t-xs: .75rem; --t-sm: .875rem; --t-md: 1rem; --t-lg: 1.1875rem;
  --t-xl: 1.5rem; --t-2xl: 1.875rem; --t-3xl: 2.5rem; --t-hero: 3.25rem;
  --fs-base: 16px;
  --fs-passage: 18px;
  --sidebar: 248px;
  --sheet-h: 76px;             /* alto de la barra inferior de la sesión */
  color-scheme: light;
}

:root[data-font="small"] { --fs-base: 14.5px; --fs-passage: 16px; }
:root[data-font="large"] { --fs-base: 18px; --fs-passage: 20.5px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131a20; --surface: #1a232b; --surface-2: #222d37; --surface-3: #2b3742; --border: #33404c; --border-strong: #4a5866;
    --ink: #eef1f5; --ink-2: #a3adba;
    --green: #6fdc5b; --green-bright: #5cc84a; --green-dark: #2f9a33; --green-soft: #19331f; --green-ink: #8be87a;
    --blue: #6cc0ff; --blue-bright: #3aa6ff; --blue-dark: #1f74c4; --blue-soft: #15304a;
    --gold: #ffd466; --gold-soft: #3a3012; --clay: #ffa36e; --clay-soft: #3b2418; --orange-soft: #3b2814;
    --brand: #6fdc5b; --brand-soft: #19331f; --focus: #6cc0ff;
    --success: #6fdc5b; --success-soft: #19331f; --danger: #ff7b8a; --danger-soft: #3d1c22; --danger-dark: #b8303c;
    --warning: #f5b83d; --highlight: rgb(128 106 0 / .6);
    --btn-bg: #5cc84a; --btn-ink: #0a1a0c; --btn-edge: #2f9a33; --accent-soft: #222d37;
    --edge: 0 var(--lip) 0 #0b1015;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131a20; --surface: #1a232b; --surface-2: #222d37; --surface-3: #2b3742; --border: #33404c; --border-strong: #4a5866;
  --ink: #eef1f5; --ink-2: #a3adba;
  --green: #6fdc5b; --green-bright: #5cc84a; --green-dark: #2f9a33; --green-soft: #19331f; --green-ink: #8be87a;
  --blue: #6cc0ff; --blue-bright: #3aa6ff; --blue-dark: #1f74c4; --blue-soft: #15304a;
  --gold: #ffd466; --gold-soft: #3a3012; --clay: #ffa36e; --clay-soft: #3b2418; --orange-soft: #3b2814;
  --brand: #6fdc5b; --brand-soft: #19331f; --focus: #6cc0ff;
  --success: #6fdc5b; --success-soft: #19331f; --danger: #ff7b8a; --danger-soft: #3d1c22; --danger-dark: #b8303c;
  --warning: #f5b83d; --highlight: rgb(128 106 0 / .6);
  --btn-bg: #5cc84a; --btn-ink: #0a1a0c; --btn-edge: #2f9a33; --accent-soft: #222d37;
  --edge: 0 var(--lip) 0 #0b1015;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: var(--fs-base); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: var(--t-md); line-height: 1.5;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(var(--t-2xl), 3.4vw, var(--t-3xl)); font-weight: 800; }
h2 { font-size: var(--t-xl); font-weight: 800; }
h3 { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.015em; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-2); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow { font: 800 var(--t-xs) var(--font-display); text-transform: uppercase; letter-spacing: .09em; color: var(--ink-2); margin: 0 0 .4rem; }
.ic { flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--gold-bright) 55%, transparent); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.shell > * { min-width: 0; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-5) var(--sp-4); border-right: var(--bw) solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--sp-2) var(--sp-5); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px;
  background: var(--green-bright); color: #fff; font: 800 .85rem var(--font-display); position: relative;
}
.brand-mark.has-mascot { background: none; width: 40px; height: 44px; border-radius: 0; }
.brand-mark.has-mascot::after { display: none; }
.brand-mark .mascot-svg { width: 40px; height: 50px; margin-top: -6px; }
.brand-name, .onb-brand strong { position: relative; font: 800 1.55rem/1 var(--font-display); letter-spacing: -0.045em; color: var(--green); padding-top: 6px; }
/* Logotipo: "examo" en minúscula; de la "o" final brota un tallo con dos hojas (Pip). */
.brand-name::after, .onb-brand strong::after {
  content: ""; position: absolute; right: -.2em; top: -.14em; width: 1.05em; height: .62em;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 20'%3E%3Cpath d='M16 20c-.6-4 .4-7 2-9' fill='none' stroke='%232f9a33' stroke-width='2.6' stroke-linecap='round'/%3E%3Cpath d='M17 12C10 13 4 10 3 4c7-1 12 2 14 8z' fill='%235cc84a'/%3E%3Cpath d='M18 11c2-6 7-9 13-8-1 6-6 9-13 8z' fill='%234fc13f'/%3E%3C/svg%3E");
  animation: sprout-sway 4s ease-in-out infinite; transform-origin: 46% 100%;
}
@keyframes sprout-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
@media (prefers-reduced-motion: reduce) { .brand-name::after, .onb-brand strong::after { animation: none; } }
.nav-link {
  display: flex; align-items: center; gap: 16px; padding: 8px 14px; min-height: 50px; border-radius: var(--r-sm);
  text-decoration: none; font: 800 var(--t-sm) var(--font-display); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2);
  border: var(--bw) solid transparent;
}
.nav-link .ic { color: var(--nav-c, var(--ink-2)); width: 26px; height: 26px; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-bright); }
.nav-link[aria-current="page"] .ic { color: var(--blue); }
.nav-badge { margin-left: auto; font: 800 .72rem var(--font-mono); background: var(--danger-bright); color: #fff; border-radius: 999px; padding: 2px 8px; letter-spacing: 0; }
.sidebar-foot { margin-top: auto; display: grid; gap: 6px; }
.account-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface); border: var(--bw) solid var(--border); font-size: var(--t-sm); font-weight: 700; }
.account-chip .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green-ink); font-weight: 800; font-size: .8rem; flex: none; }

main { min-width: 0; padding: var(--sp-6) clamp(16px, 4vw, 48px) 96px; outline: none; }
main:focus, main:focus-visible { outline: none; }
.page { max-width: 1080px; margin: 0 auto; }

.tabbar { display: none; }
.mobile-top { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  main { padding: var(--sp-4) var(--sp-4) 108px; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; border-bottom: var(--bw) solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
  .mobile-top .brand { padding: 0; }
  .mobile-top .brand-name { font-size: 1.2rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: var(--bw) solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: grid; justify-items: center; align-content: center; gap: 2px; padding: 4px 0; margin: 0 2px; text-decoration: none; font: 800 .62rem var(--font-display); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); min-height: 54px; border-radius: var(--r-sm); border: var(--bw) solid transparent; }
  .tabbar a .ic { color: var(--nav-c, var(--ink-2)); width: 26px; height: 26px; }
  .tabbar a[aria-current="page"] { color: var(--blue); background: var(--blue-soft); border-color: var(--blue-bright); }
  .tabbar a[aria-current="page"] .ic { color: var(--blue); }
}

body.in-session .sidebar, body.in-session .tabbar, body.in-session .mobile-top { display: none; }
body.in-session .shell { grid-template-columns: 1fr; }
body.in-session main { padding: 0 0 calc(var(--sheet-h) + 24px + env(safe-area-inset-bottom)); }

/* ---------- Botones (3D: labio inferior que se hunde al pulsar) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 800 var(--t-sm) var(--font-display); text-transform: uppercase; letter-spacing: .07em;
  padding: 12px 22px; min-height: 50px;
  border: var(--bw) solid transparent; border-radius: var(--r-md); margin-bottom: var(--lip);
  background: var(--btn-bg); color: var(--btn-ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--press); transition: transform .06s ease, box-shadow .06s ease, filter .12s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(var(--lip)); box-shadow: 0 0 0 transparent; }
.btn-accent { background: var(--accent); color: var(--on-accent); box-shadow: 0 var(--lip) 0 color-mix(in srgb, var(--accent) 60%, #000); }
.btn-brand { background: var(--btn-bg); color: var(--btn-ink); }
.btn-blue { background: var(--blue); color: #fff; box-shadow: 0 var(--lip) 0 var(--blue-dark); }
.btn-ghost { background: var(--surface); color: var(--blue); border-color: var(--border); box-shadow: var(--edge); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-ghost:active { transform: translateY(var(--lip)); box-shadow: none; }
.btn-sm { min-height: 40px; padding: 7px 14px; font-size: .78rem; border-radius: var(--r-sm); }
.btn-lg { min-height: 56px; padding: 14px 28px; font-size: 1rem; letter-spacing: .08em; }
.btn-block { width: 100%; }
.btn[disabled] { background: var(--surface-3); color: var(--ink-2); border-color: transparent; cursor: not-allowed; transform: none; box-shadow: none; filter: none; opacity: 1; }
.btn-ghost[disabled] { background: var(--surface); border-color: var(--border); opacity: .55; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-sm);
  border: var(--bw) solid transparent; background: none; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-bright); }

/* ---------- Tarjetas y bloques ---------- */
.card { background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 0; font: 800 var(--t-sm) var(--font-ui); color: var(--ink); }
.pill .ic { color: var(--blue); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font: 800 var(--t-xs) var(--font-ui); background: var(--accent-soft); color: var(--accent); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.page-head h1 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin: var(--sp-7) 0 var(--sp-4); }
.section-title h2 { margin: 0; font-size: var(--t-xl); }

/* Home */
.continue-card { background: var(--accent-soft); border: var(--bw) solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); display: flex; flex-direction: column; gap: 14px; }
.continue-card h2 { margin: 0; font-size: var(--t-xl); }
.stat-card { display: flex; align-items: center; gap: 18px; }
.stat-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--sp-4); }
.big-num { font: 800 var(--t-3xl) var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.04em; line-height: 1; }

/* Tarjeta de examen: insignia-bolsillo + labio 3D. Sin franja de color arriba. */
.exam-tile {
  --accent: #1766c8;
  position: relative; display: flex; flex-direction: column; gap: var(--sp-3); text-decoration: none;
  background: var(--surface); border: var(--bw) solid var(--border); border-bottom-width: 6px; border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-5) var(--sp-4); transition: background .12s ease, border-color .12s ease;
}
.exam-tile:hover { background: var(--surface-2); }
.exam-tile:active { transform: translateY(3px); border-bottom-width: 3px; margin-bottom: 3px; }
.exam-tile .tile-top { display: flex; align-items: center; gap: 14px; }
.exam-tile h3 { margin: 0 0 2px; font-size: var(--t-lg); font-weight: 800; }
.exam-tile .meta { font-size: var(--t-sm); color: var(--ink-2); }
.exam-tile .tile-top .meta { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.exam-tile .tile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* Insignia de examen: cuadrado redondeado de color plano, siglas en blanco (tipografía limpia) y labio 3D tipo Duolingo. */
.exam-icon {
  position: relative; display: grid; place-items: center; flex: none; box-sizing: border-box;
  width: 56px; height: 56px; padding-bottom: var(--lip); border-radius: 16px;
  background: var(--accent); color: #fff; font: 800 1.05rem/1 var(--font-display); letter-spacing: -0.01em;
  box-shadow: inset 0 calc(var(--lip) * -1) 0 rgb(0 0 0 / .22);
}
.exam-icon.long { font-size: .72rem; letter-spacing: 0; }
.exam-tile.planned { background: var(--surface-2); border-style: dashed; border-bottom-width: var(--bw); }
.exam-tile.planned .exam-icon { opacity: .75; }
.exam-tile.planned:hover { transform: none; }

/* Barras de progreso gordotas con reflejo (estilo juego). */
.progress { height: 16px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > i, .xp-bar > i, .goal-bar > i {
  display: block; height: 100%; border-radius: 999px; background: var(--accent); position: relative; min-width: 16px;
  transition: width .7s cubic-bezier(.2, .9, .3, 1.15);
}
.progress > i::after, .xp-bar > i::after, .goal-bar > i::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px; border-radius: 999px; background: rgb(255 255 255 / .38);
}
.progress > i[style*="width:0%"], .xp-bar > i[style*="width:0%"], .goal-bar > i[style*="width:0%"] { min-width: 0; }

.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2, .9, .3, 1); }
.ring-label { position: absolute; font: 800 1.15rem var(--font-display); letter-spacing: -0.03em; }

/* Página de examen: cabecera tipo "banner de unidad" (bloque de color sólido con labio). */
.exam-header {
  position: relative; border-radius: var(--r-lg); background: var(--accent); color: #fff;
  border: 0; box-shadow: inset 0 -6px 0 rgb(0 0 0 / .18); padding: var(--sp-5) var(--sp-5) calc(var(--sp-5) + 6px); margin-bottom: var(--sp-5); overflow: hidden;
}
.exam-header > * { position: relative; z-index: 1; }
.exam-header h1, .exam-header .eyebrow, .exam-header .muted, .exam-header p { color: #fff; }
.exam-header .eyebrow { opacity: .88; }
.exam-header .muted { opacity: .92; }
.exam-header h1 { margin: 0 0 6px; }
.exam-header .exam-icon { background: #fff; color: var(--accent); box-shadow: inset 0 calc(var(--lip) * -1) 0 color-mix(in srgb, var(--accent) 22%, #fff); }
.exam-header .facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--sp-4); }
.exam-header .pill { background: rgb(255 255 255 / .16); color: #fff; }
.exam-header .pill .ic { color: #fff; }
.exam-header a:not(.btn) { color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: var(--bw) solid var(--border); margin: var(--sp-2) 0 var(--sp-5); overflow-x: auto; }
.tab { padding: 12px 16px; min-height: 48px; border: 0; background: none; font: 800 var(--t-sm) var(--font-display); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); cursor: pointer; border-bottom: 4px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.test-card, .section-card { display: flex; flex-direction: column; gap: 12px; }
.test-card .facts, .section-card .facts { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); }
.test-card .facts span, .section-card .facts span { display: inline-flex; align-items: center; gap: 5px; }
.section-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.skill-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 2px solid var(--border); }
.skill-row:last-child { border-bottom: 0; }
.skill-row .name { flex: 1; min-width: 0; }
.skill-row .name small { display: block; color: var(--ink-2); font-size: .8rem; }
.skill-row .count { font: 600 .8rem var(--font-mono); color: var(--ink-2); }
details.theory { border: var(--bw) solid var(--border); border-bottom-width: var(--lip); border-radius: var(--r-sm); background: var(--surface); margin: 6px 0 10px; }
details.theory summary { cursor: pointer; padding: 12px 14px; font: 800 var(--t-sm) var(--font-display); letter-spacing: .01em; }
details.theory[open] summary { border-bottom: var(--bw) solid var(--border); margin-bottom: 10px; }
details.theory .body { padding: 0 14px 12px; font-size: .92rem; }
details.theory ul { padding-left: 1.2em; margin: .3em 0 .8em; }
.info-list { display: grid; gap: 10px; }
.spec-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.spec-table th, .spec-table td { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border); vertical-align: top; }
.spec-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.spec-table td.num { font-family: var(--font-mono); white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.note { border: var(--bw) solid color-mix(in srgb, var(--blue-bright) 45%, var(--border)); background: var(--blue-soft); padding: 12px 16px; border-radius: var(--r-sm); font-size: var(--t-sm); }

/* ---------- Sesión de preguntas ---------- */
.q-top {
  position: sticky; top: 0; z-index: 15; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--sp-3);
  padding: 10px clamp(12px, 3vw, 24px); background: var(--surface); border-bottom: var(--bw) solid var(--border);
}
.q-top .where { min-width: 0; }
.q-top .where strong { display: block; font: 800 var(--t-md) var(--font-display); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-top .where small { color: var(--ink-2); font-size: var(--t-xs); font-weight: 600; }
.q-top .tools { display: flex; justify-content: flex-end; gap: 4px; }
.timer { font: 700 1.1rem var(--font-mono); font-variant-numeric: tabular-nums; padding: 6px 14px; min-height: 40px; border-radius: var(--r-sm); background: var(--surface-2); border: 0; color: var(--ink); cursor: pointer; }
.timer.warn { background: var(--warning); color: #fff; animation: tick 1s steps(2) infinite; }
@keyframes tick { 50% { filter: brightness(1.15); } }
.timer.hidden-time { color: transparent; text-shadow: none; }
.q-accent { height: 4px; background: var(--accent); }

.q-stage { max-width: 1320px; margin: 0 auto; padding: var(--sp-5) clamp(12px, 3vw, 24px); }
.q-split { display: grid; grid-template-columns: var(--split, 1fr) 6px 1fr; gap: 0; min-height: 60vh; background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-lg); }
/* Pregunta sin texto de lectura: sin caja, como una lección (más aire, menos "tarjeta"). */
.q-split.single { grid-template-columns: 1fr; max-width: 760px; margin: 0 auto; border: 0; background: none; min-height: 0; }
.q-split.single .divider, .q-split.single .pane-stim { display: none; }
.q-split.single .pane { max-height: none; overflow: visible; padding: var(--sp-4) 0 var(--sp-5); }
.divider { background: var(--border); cursor: col-resize; }
.divider:hover { background: var(--accent); }
.pane { padding: var(--sp-5) clamp(16px, 3vw, 32px); min-width: 0; overflow: auto; max-height: calc(100vh - 80px - var(--sheet-h)); }
.pane-stim { font-family: var(--font-read); font-size: var(--fs-passage); line-height: 1.65; }
.pane-stim p { margin: 0 0 .9em; }
.pane-stim .stim-title { font: 800 var(--t-md) var(--font-display); margin-bottom: 10px; }
.pane-stim .text-label { font: 800 var(--t-xs) var(--font-display); text-transform: uppercase; letter-spacing: .08em; margin: 6px 0 4px; color: var(--ink-2); }
.pane-stim ul { padding-left: 1.2em; margin: 0; }
.pane-stim li { margin-bottom: .45em; }
.pane-stim .notes-intro { font-family: var(--font-ui); font-size: .95rem; }
.pane-stim mark, .q-stem mark { background: var(--highlight); color: inherit; border-radius: 2px; }
@media (max-width: 860px) {
  .q-split { grid-template-columns: 1fr; }
  .divider { display: none; }
  .pane { max-height: none; }
  .pane-stim { border-bottom: var(--bw) solid var(--border); }
  .q-top { grid-template-columns: 1fr auto; }
  .q-top .tools { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .q-stage { padding-top: var(--sp-3); }
}

.q-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: var(--sp-4); }
.q-num { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent); font: 800 var(--t-sm) var(--font-mono); box-shadow: inset 0 -4px 0 rgb(0 0 0 / .2); }
.q-stem { font-size: var(--t-lg); font-weight: 600; line-height: 1.45; margin-bottom: var(--sp-5); }
.q-split.single .q-stem { font: 700 clamp(1.2rem, 2.4vw, 1.45rem)/1.35 var(--font-ui); letter-spacing: -0.01em; }
.q-stem p:last-child { margin-bottom: 0; }

.data-table { border-collapse: collapse; margin: 8px 0 14px; font-family: var(--font-ui); font-size: .92rem; }
.data-table caption { text-align: left; font-weight: 700; padding-bottom: 6px; }
.data-table th, .data-table td { border: 1px solid var(--border); padding: 7px 12px; text-align: center; }
.data-table th { background: var(--surface-2); font-weight: 700; }

.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.choice-row { display: flex; align-items: stretch; gap: 8px; }
.choice {
  flex: 1; display: flex; align-items: center; gap: 14px; min-height: 60px; text-align: left; font: inherit; color: inherit;
  background: var(--surface); border: var(--bw) solid var(--border); border-bottom-width: var(--lip); border-radius: var(--r-md); padding: 12px 16px; cursor: pointer;
  transition: border-color .1s ease, background .1s ease, transform .06s ease; -webkit-tap-highlight-color: transparent;
}
.choice:hover:not([disabled]):not(.selected) { background: var(--surface-2); }
.choice:active:not([disabled]) { transform: translateY(2px); border-bottom-width: var(--bw); margin-bottom: 2px; }
.choice .letter { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--r-xs); border: var(--bw) solid var(--border); font: 700 var(--t-sm) var(--font-mono); color: var(--ink-2); }
.choice .ctext { font-weight: 600; line-height: 1.4; }
.choice.selected { border-color: var(--blue-bright); background: var(--blue-soft); animation: sel-pop .16s ease-out; }
.choice.selected .ctext { color: var(--blue-dark); }
.choice.selected .letter { background: var(--blue-bright); border-color: var(--blue-bright); color: #fff; }
.choice.is-correct { border-color: var(--green-bright); background: var(--success-soft); animation: right-pop .45s cubic-bezier(.3, 1.6, .5, 1); }
.choice.is-correct .ctext { color: var(--green-ink); }
.choice.is-correct .letter { background: var(--green-bright); border-color: var(--green-bright); color: #fff; }
.choice.is-wrong { border-color: var(--danger-bright); background: var(--danger-soft); animation: wrong-shake .42s ease-in-out; }
.choice.is-wrong .ctext { color: var(--danger); }
.choice.is-wrong .letter { background: var(--danger-bright); border-color: var(--danger-bright); color: #fff; }
:root[data-theme="dark"] .choice.selected .ctext { color: var(--blue); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .choice.selected .ctext { color: var(--blue); } }
.choice.eliminated .ctext, .choice.eliminated .letter { opacity: .4; text-decoration: line-through; }
.choice[disabled] { cursor: default; }
.elim-btn { width: 44px; border-radius: var(--r-sm); border: var(--bw) solid var(--border); border-bottom-width: var(--lip); background: var(--surface); color: var(--ink-2); cursor: pointer; font: 700 .75rem var(--font-mono); }
.elim-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
@keyframes sel-pop { 0% { transform: scale(.98); } 60% { transform: scale(1.012); } 100% { transform: none; } }
@keyframes right-pop { 0% { transform: scale(1); } 35% { transform: scale(1.035); } 100% { transform: none; } }
@keyframes wrong-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

.text-input {
  font: 700 1.2rem var(--font-mono); padding: 12px 14px; border: var(--bw) solid var(--border); border-bottom-width: var(--lip); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink); width: 200px;
}
.text-input:focus { border-color: var(--blue-bright); background: var(--surface); outline: none; }
.hint { font-size: .85rem; color: var(--ink-2); margin-top: 8px; }

.gap-text { font-family: var(--font-read); font-size: var(--fs-passage); line-height: 2.1; }
.gap { display: inline-flex; align-items: baseline; white-space: nowrap; flex-wrap: wrap; max-width: 100%; }
.gap .prefix { font-weight: 600; }
.gap input {
  font: 600 .95em var(--font-read); width: calc(var(--len, 5) * 0.7em + 1.2em); min-width: 3.2em; padding: 0 4px; margin: 0 1px;
  border: 0; border-bottom: 2px solid var(--accent); background: var(--accent-soft); color: var(--ink); border-radius: 4px 4px 0 0;
}
.gap input:focus { outline: none; background: var(--surface-2); }
.gap input.letters { font-family: var(--font-mono); letter-spacing: .35em; width: calc(var(--len) * 1.05em + .6em); min-width: 0; padding-left: .2em; }
.gap input.letters::placeholder { color: var(--ink-2); opacity: .7; }
.gap.ok input { border-color: var(--success); background: var(--success-soft); }
.gap.bad input { border-color: var(--danger); background: var(--danger-soft); }
.gap .fix { font: 600 .8em var(--font-ui); color: var(--success); margin-left: 3px; white-space: normal; overflow-wrap: anywhere; }
.gap input { max-width: 100%; } /* respuestas largas (Key word transformation) sin scroll horizontal en móvil */
.gap-num { font: 700 .7em var(--font-mono); color: var(--accent); margin-right: 2px; }

.order-built { min-height: 56px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border: 1.5px dashed var(--border); border-radius: 12px; margin-bottom: 12px; font-size: 1.05rem; }
.order-fixed { font-weight: 600; color: var(--ink-2); }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile { font: 700 1rem var(--font-ui); padding: 10px 16px; min-height: 44px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 var(--border); margin-bottom: 4px; }
.tile:active { transform: translateY(4px); box-shadow: none; }
.tile.used { visibility: hidden; }
.tile.placed { background: var(--accent-soft); border-color: var(--accent); box-shadow: none; }
.context-bubble { display: inline-block; background: var(--surface-2); border-radius: 14px 14px 14px 4px; padding: 10px 14px; margin-bottom: 14px; }

.audio-box { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: var(--accent-soft); margin-bottom: 14px; }
.audio-box .play { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 0 var(--blue-dark); }
.audio-box .play[disabled] { opacity: .45; cursor: not-allowed; }
.audio-box .meta { font-size: .85rem; color: var(--ink-2); }
.transcript { font-family: var(--font-read); font-size: .98rem; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.transcript p { margin: 0 0 .4em; }

textarea.answer {
  width: 100%; min-height: 220px; font: 1rem/1.6 var(--font-ui); padding: 14px; border: 1.5px solid var(--border);
  border-radius: 12px; background: var(--surface); color: var(--ink); resize: vertical;
}
textarea.answer:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.word-count { font: 500 .85rem var(--font-mono); color: var(--ink-2); margin-top: 6px; display: flex; justify-content: space-between; }
.word-count.bad { color: var(--danger); }
.self-score { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.self-score button { min-width: 44px; height: 40px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); font: 700 .95rem var(--font-mono); color: var(--ink); cursor: pointer; }
.self-score button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.rec-btn { display: inline-flex; align-items: center; gap: 8px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
/* Análisis automático del Speaking (js/speaking-eval-ui.js) */
.se-main { margin: 4px 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.se-badge { font: 700 .72rem var(--font-mono); text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: var(--warning); color: var(--surface); }
.se-crit { margin: 0 0 10px; padding-left: 18px; }
.se-bars { display: grid; gap: 6px; }
.se-row { display: grid; grid-template-columns: minmax(90px, 9rem) 1fr 2.4rem; align-items: center; gap: 8px; }
.se-row .se-hint { grid-column: 1 / -1; font-size: .82rem; color: var(--ink-2); margin: -2px 0 2px; }
.se-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.se-bar i { display: block; height: 100%; border-radius: inherit; background: var(--success); }
.se-bar.mid i { background: var(--warning); }
.se-bar.low i { background: var(--danger); }
.se-val { font: 700 .9rem var(--font-mono); text-align: right; }
.se-words { line-height: 1.9; overflow-wrap: anywhere; }
.se-w.se-bad { color: var(--danger); text-decoration: underline wavy; text-underline-offset: 3px; font-weight: 700; }
.se-w.se-miss { color: var(--danger); text-decoration: line-through; opacity: .8; }
.se-tips { margin: 10px 0 6px; padding-left: 18px; }
.se-disclaimer { font-size: .82rem; margin-top: 10px; }
@keyframes blink { 50% { opacity: .2; } }

/* Corrección de práctica (estilo hoja inferior de Duolingo).
   - En la sesión, la cabecera de .feedback se "despega" y se fija abajo, encima de
     la barra inferior: juntas forman una hoja verde (acierto) o roja (fallo) con
     Pip asomando por arriba. El botón principal se tiñe del mismo color.
   - La explicación queda en el panel, en una tarjeta con el borde del mismo color. */
.feedback { margin-top: var(--sp-4); border-radius: var(--r-md); overflow: hidden; border: var(--bw) solid var(--border); }
.feedback header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; font: 800 var(--t-lg) var(--font-display); letter-spacing: -0.01em; }
.feedback header .mascot { margin: -14px 0 -10px -6px; }
.feedback.ok { border-color: color-mix(in srgb, var(--green-bright) 70%, var(--border)); }
.feedback.ok header { background: var(--success-soft); color: var(--green-ink); }
.feedback.bad { border-color: color-mix(in srgb, var(--danger-bright) 60%, var(--border)); }
.feedback.bad header { background: var(--danger-soft); color: var(--danger); }
.feedback.neutral header { background: var(--surface-2); color: var(--ink); }
.feedback .body { padding: 14px 16px; background: var(--surface); }
.feedback .body p:last-child { margin-bottom: 0; }
.feedback .body pre { white-space: pre-wrap; font: inherit; margin: 0; }

#qpane > .feedback { animation: fb-fade .35s ease-out; }
#qpane > .feedback > header {
  position: fixed; left: 0; right: 0; z-index: 16; bottom: calc(var(--sheet-h) + env(safe-area-inset-bottom));
  padding: 16px max(20px, calc((100vw - 980px) / 2)) 4px; font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  animation: sheet-up .34s cubic-bezier(.2, .9, .3, 1.08) both;
}
#qpane > .feedback > header .mascot { margin: -46px 0 -8px -4px; align-self: flex-end; }
#qpane > .feedback > header .mascot-svg { width: 64px; height: 80px; }
#qpane:has(> .feedback) { padding-bottom: 150px; }
.q-split.single #qpane:has(> .feedback) { padding-bottom: 120px; }
@keyframes fb-fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(110%); } }

.q-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: calc(var(--sheet-h) + env(safe-area-inset-bottom)); padding: 0 max(16px, calc((100vw - 980px) / 2)) env(safe-area-inset-bottom);
  background: var(--surface); border-top: var(--bw) solid var(--border);
}
.q-bottom .btn { margin-bottom: 0; }
.q-bottom .right .btn { min-width: 150px; }
.q-stage:has(#qpane > .feedback.ok) ~ .q-bottom { background: var(--success-soft); border-top-color: transparent; animation: sheet-tint .34s ease-out; }
.q-stage:has(#qpane > .feedback.bad) ~ .q-bottom { background: var(--danger-soft); border-top-color: transparent; animation: sheet-tint .34s ease-out; }
#qpane > .feedback.ok > header { background: var(--success-soft); }
#qpane > .feedback.bad > header { background: var(--danger-soft); }
.q-stage:has(#qpane > .feedback.bad) ~ .q-bottom :is(#next, #finish, #next-part) { background: var(--danger); color: #fff; box-shadow: 0 var(--lip) 0 color-mix(in srgb, var(--danger) 62%, #000); }
:root[data-theme="dark"] .q-stage:has(#qpane > .feedback.bad) ~ .q-bottom :is(#next, #finish, #next-part) { background: var(--danger-bright); color: #1a0508; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .q-stage:has(#qpane > .feedback.bad) ~ .q-bottom :is(#next, #finish, #next-part) { background: var(--danger-bright); color: #1a0508; } }
.q-stage:has(#qpane > .feedback) ~ .q-bottom .nav-toggle { background: transparent; border-color: color-mix(in srgb, currentColor 18%, transparent); }
@keyframes sheet-tint { from { background: var(--surface); } }
.nav-toggle { font: 800 var(--t-sm) var(--font-display); letter-spacing: .02em; padding: 8px 14px; min-height: 44px; border-radius: var(--r-sm); border: var(--bw) solid var(--border); background: var(--surface-2); color: var(--ink); cursor: pointer; white-space: nowrap; }
.q-bottom .right { display: flex; gap: 8px; }
@media (max-width: 600px) {
  .q-bottom .right .btn { min-width: 0; }
  #qpane > .feedback > header { padding-left: 16px; padding-right: 16px; }
  #qpane > .feedback > header .mascot-svg { width: 54px; height: 68px; }
}
@media (max-width: 420px) { .nav-toggle { padding: 8px 10px; font-size: .78rem; } .q-bottom .btn { padding-left: 14px; padding-right: 14px; } }
.navigator { position: fixed; left: 50%; bottom: calc(var(--sheet-h) + 10px); transform: translateX(-50%); z-index: 30; width: min(560px, calc(100vw - 24px)); background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 18px; }
.navigator[hidden] { display: none; }
.navigator .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 8px; margin-top: 12px; }
.navigator .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-2); }
.q-dot { position: relative; height: 44px; border-radius: var(--r-sm); border: var(--bw) dashed var(--ink-2); background: var(--surface); color: var(--ink); font: 700 .85rem var(--font-mono); cursor: pointer; }
.q-dot.answered { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.q-dot.current { outline: 3px solid var(--ink); outline-offset: 1px; }
.q-dot.flagged::after { content: ""; position: absolute; top: -5px; right: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.q-dot.ok { border-style: solid; border-color: var(--success); background: var(--success-soft); }
.q-dot.bad { border-style: solid; border-color: var(--danger); background: var(--danger-soft); }

.break-screen { max-width: 560px; margin: 12vh auto 0; text-align: center; }
.break-screen .big-num { font-size: 4rem; margin: 20px 0; }

.calc-panel { position: fixed; right: 16px; top: 72px; z-index: 25; width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 14px; }
.calc-panel[hidden] { display: none; }
.calc-display { width: 100%; font: 600 1.2rem var(--font-mono); padding: 10px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--ink); text-align: right; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.calc-keys button { height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: 600 .95rem var(--font-mono); cursor: pointer; }
.calc-keys button.op { background: var(--surface-2); }
.calc-keys button.eq { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.ref-panel { position: fixed; right: 16px; top: 72px; z-index: 25; width: min(420px, calc(100vw - 32px)); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 18px; font-size: .92rem; }
.ref-panel[hidden] { display: none; }
.ref-panel ul { padding-left: 1.1em; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

/* ---------- Resultados ---------- */
.result-hero { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-5); align-items: center; background: var(--surface); border: var(--bw) solid var(--border); border-bottom-width: 6px; border-radius: var(--r-xl); padding: var(--sp-5) var(--sp-6); margin-bottom: var(--sp-4); }
.result-hero .big-num { font-size: clamp(2.8rem, 8vw, var(--t-hero)); }
@media (max-width: 600px) { .result-hero { grid-template-columns: 1fr; padding: var(--sp-5); } }
/* Cajas de datos estilo "lección completada": etiqueta en franja de color + valor grande.
   Máximo 3 colores (oro, verde, azul); el resto en neutro. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.kpi { --kpi-c: var(--ink-2); --kpi-ink: #fff; display: flex; flex-direction: column-reverse; justify-content: flex-end; background: var(--kpi-c); border: var(--bw) solid var(--kpi-c); border-radius: var(--r-md); padding: 0; overflow: hidden; }
.kpi strong { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1; min-height: 64px; margin: 0 2px 2px; border-radius: calc(var(--r-md) - 4px); background: var(--surface); font: 800 var(--t-xl) var(--font-display); letter-spacing: -0.03em; color: var(--kpi-t, var(--ink)); padding: 10px 8px; font-variant-numeric: tabular-nums; }
.kpi span { display: block; padding: 6px 10px 5px; text-align: center; font: 800 var(--t-xs)/1.25 var(--font-display) !important; text-transform: uppercase; letter-spacing: .07em; color: var(--kpi-ink) !important; }
.kpi:nth-child(1) { --kpi-c: var(--gold-bright); --kpi-ink: #3d2a00; --kpi-t: var(--gold); }
.kpi:nth-child(2) { --kpi-c: var(--green); --kpi-t: var(--green-ink); }
.kpi:nth-child(3) { --kpi-c: var(--blue); --kpi-t: var(--blue); }
:root[data-theme="dark"] .kpi:nth-child(2), :root[data-theme="dark"] .kpi:nth-child(3) { --kpi-ink: #0b1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kpi:nth-child(2), :root:not([data-theme="light"]) .kpi:nth-child(3) { --kpi-ink: #0b1220; } }
.kpi:nth-child(n+4) { --kpi-c: var(--border-strong); --kpi-ink: var(--ink); }
.kpis .kpi { animation: kpi-in .5s cubic-bezier(.3, 1.4, .5, 1) both; }
.kpis .kpi:nth-child(2) { animation-delay: .08s; } .kpis .kpi:nth-child(3) { animation-delay: .16s; } .kpis .kpi:nth-child(n+4) { animation-delay: .24s; }
@keyframes kpi-in { from { opacity: 0; transform: translateY(14px) scale(.94); } }
.bar-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr 70px auto; gap: var(--sp-3); align-items: center; padding: var(--sp-3) 0; border-bottom: var(--bw) solid var(--border); }
.bar-row:last-child { border-bottom: 0; }
.progress.lvl-hi > i { background: var(--green-bright); }
.progress.lvl-mid > i { background: var(--gold-bright); }
.progress.lvl-lo > i { background: var(--danger-bright); }
.bar-row .num { font: 700 var(--t-sm) var(--font-mono); text-align: right; }
@media (max-width: 600px) { .bar-row { grid-template-columns: 1fr auto auto; } .bar-row .progress { grid-column: 1 / -1; order: 3; } }
.review-list { display: grid; gap: var(--sp-4); }
.review-item { background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.review-item > header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: var(--bw) solid var(--border); font-size: var(--t-sm); background: var(--surface-2); }
.review-item .inner { padding: var(--sp-4); }
.review-item .inner.is-pending { min-height: 120px; } /* cuerpo aún sin pintar (revisión perezosa): esqueleto */
.review-item .inner.is-pending::before { content: ""; display: block; height: 72px; border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface-2), var(--surface-3)); }
.review-item .stim { font-family: var(--font-read); font-size: .98rem; margin-bottom: 12px; }
.review-item:has(.res-ok) > header { background: var(--success-soft); }
.review-item:has(.res-bad) > header { background: var(--danger-soft); }
.res-ok { color: var(--green-ink); font-weight: 800; }
.res-bad { color: var(--danger); font-weight: 800; }
.res-neutral { color: var(--ink-2); font-weight: 800; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-sm); padding: 4px; gap: 2px; }
.seg button { border: 0; background: none; padding: 8px 14px; min-height: 40px; border-radius: 9px; font: 800 var(--t-xs) var(--font-display); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--blue); box-shadow: 0 2px 0 var(--border); }

/* ---------- Historial ---------- */
.chart { width: 100%; height: 180px; }
.chart .line { fill: none; stroke: var(--blue-bright); stroke-width: 3; }
.chart .dot { fill: var(--blue); }
.chart .axis { stroke: var(--border); }
.chart text { fill: var(--ink-2); font: 11px var(--font-mono); }
.attempt-row { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 4px; border-bottom: var(--bw) solid var(--border); }
.attempt-row:last-child { border-bottom: 0; }
.attempt-row .score { font: 800 var(--t-lg) var(--font-display); letter-spacing: -0.02em; text-align: right; }
.attempt-row small { color: var(--ink-2); }

/* ---------- Ajustes ---------- */
.settings-group { margin-bottom: 18px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: var(--bw) solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting label, .setting .label { font-weight: 700; }
.setting small { display: block; color: var(--ink-2); font-weight: 400; font-size: .82rem; }
select, input[type="date"], input[type="number"] {
  font: 700 .95rem var(--font-ui); padding: 9px 12px; min-height: 44px; border-radius: var(--r-sm); border: var(--bw) solid var(--border); border-bottom-width: var(--lip); background: var(--surface); color: var(--ink);
}
.switch { position: relative; width: 56px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; pointer-events: none; box-shadow: inset 0 -3px 0 rgb(0 0 0 / .12); }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .18s cubic-bezier(.3, 1.5, .5, 1); box-shadow: 0 2px 0 rgb(0 0 0 / .18); }
.switch input:checked + span { background: var(--green-bright); }
.switch input:checked + span::after { transform: translateX(24px); }

/* ---------- Planes ---------- */
.plan-card { display: flex; flex-direction: column; gap: 12px; }
.plan-card .price { font: 800 var(--t-2xl) var(--font-display); letter-spacing: -0.03em; }
.plan-card ul { margin: 0; padding-left: 1.1em; color: var(--ink-2); font-size: .92rem; }
.plan-card .btn { margin-top: auto; }

/* ---------- Diálogos ---------- */
.dialog { width: min(440px, calc(100vw - 32px)); border: var(--bw) solid var(--border); border-bottom-width: 6px; border-radius: var(--r-xl); padding: 10px 24px 24px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); }
.dialog[open] { animation: dlg-in .26s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
.dialog::backdrop { background: rgb(19 26 32 / .6); }
.dialog-close-row { display: flex; justify-content: flex-end; margin-right: -12px; }
.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 4px; font-weight: 700; font-size: var(--t-sm); }
.stack input { font: inherit; padding: 12px 14px; min-height: 50px; border: var(--bw) solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); }
.stack input:focus { border-color: var(--blue-bright); outline: none; background: var(--surface); }
.divider-text { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: .8rem; margin: 16px 0; }
.divider-text { font: 800 var(--t-xs) var(--font-display); text-transform: uppercase; letter-spacing: .08em; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; border-top: var(--bw) solid var(--border); }
.form-error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 10px 0 0; }
.btn-google { background: var(--surface); color: var(--ink); border-color: var(--border); box-shadow: var(--edge); font-family: var(--font-ui); text-transform: none; letter-spacing: 0; font-weight: 700; }
.mobile-top > * { min-width: 0; }
.mobile-top .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Estado vacío: Pip pensativa (copia del dibujo de js/mascot.js, etapa 3, ánimo "thinking";
   si se redibuja Pip, regenerar con scratchpad/visual/svgout.cjs) + texto corto + botón. */
.empty-state { display: grid; justify-items: center; gap: var(--sp-2); text-align: center; padding: var(--sp-6) var(--sp-5) var(--sp-5); border: 0; border-radius: var(--r-xl); background: var(--surface-2); }
.empty-state::before { content: ""; display: block; width: 112px; height: 140px; margin-bottom: var(--sp-1); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -18 120 150' width='120' height='150'%3E%3Cellipse cx='60' cy='128' rx='36' ry='4.5' fill='%23000' opacity='.1'/%3E%3Cg%3E%3Cpath d='M60 53.316 v -11' stroke='%232f9a33' stroke-width='3.4' stroke-linecap='round'/%3E%3Cg transform='translate(60.0 43.3) rotate(-44)'%3E%3Cpath d='M0 0 C -9.7 -6.3 -6.8 -18.1 0 -21.0 C 6.8 -18.1 9.7 -6.3 0 0 Z' fill='%234fc13f'/%3E%3Cpath d='M0 0 C 9.7 -6.3 6.8 -18.1 0 -21.0 Q 1.2 -10.5 0 0 Z' fill='%232f9a33'/%3E%3C/g%3E%3Cg transform='translate(60.0 43.3) rotate(44)'%3E%3Cpath d='M0 0 C -9.7 -6.3 -6.8 -18.1 0 -21.0 C 6.8 -18.1 9.7 -6.3 0 0 Z' fill='%234fc13f'/%3E%3Cpath d='M0 0 C 9.7 -6.3 6.8 -18.1 0 -21.0 Q 1.2 -10.5 0 0 Z' fill='%232f9a33'/%3E%3C/g%3E%3Cg transform='translate(60.0 43.3) rotate(0)'%3E%3Cpath d='M0 0 C -6.9 -4.5 -4.8 -12.9 0 -15.0 C 4.8 -12.9 6.9 -4.5 0 0 Z' fill='%234fc13f'/%3E%3Cpath d='M0 0 C 6.9 -4.5 4.8 -12.9 0 -15.0 Q 0.8 -7.5 0 0 Z' fill='%232f9a33'/%3E%3C/g%3E%3Cellipse cx='60' cy='76.696' rx='28.2' ry='25.38' fill='%233fa53a'/%3E%3Cellipse cx='56.6' cy='76.2' rx='24.8' ry='24.9' fill='%235cc84a'/%3E%3Cellipse cx='60' cy='88.1' rx='15.5' ry='8.9' fill='%238fe07c' opacity='.55'/%3E%3Cellipse cx='45.9' cy='62.7' rx='5.6' ry='3.0' fill='%23fff' opacity='.5' transform='rotate(-28 45.9 62.7)'/%3E%3Cg%3E%3Cellipse cx='44.9' cy='84.5' rx='4.3' ry='2.7' fill='%23ff93aa' opacity='.8'/%3E%3Cellipse cx='75.1' cy='84.5' rx='4.3' ry='2.7' fill='%23ff93aa' opacity='.8'/%3E%3Cg%3E%3Cellipse cx='50.8' cy='75.8' rx='5.8' ry='7.0' fill='%23ffffff'/%3E%3Ccircle cx='52.3' cy='74.0' r='3.8' fill='%232b2f3a'/%3E%3Ccircle cx='53.8' cy='72.5' r='1.3' fill='%23ffffff'/%3E%3C/g%3E%3Cg%3E%3Cellipse cx='69.2' cy='75.8' rx='5.8' ry='7.0' fill='%23ffffff'/%3E%3Ccircle cx='70.8' cy='74.0' r='3.8' fill='%232b2f3a'/%3E%3Ccircle cx='72.3' cy='72.5' r='1.3' fill='%23ffffff'/%3E%3C/g%3E%3Cpath d='M46.4 66.1 Q 50.8 63.1 55.1 66.1' stroke='%232b2f3a' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3Cpath d='M64.9 61.2 Q 69.2 59.7 73.6 64.1' stroke='%232b2f3a' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3Cpath d='M56.1 87.4 Q 61.0 85.5 65.8 87.9' stroke='%232b2f3a' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/g%3E%3Cg%3E%3Cg transform='translate(35.7 81.3) rotate(-118)'%3E%3Cpath d='M0 0 C -9.7 -6.3 -6.8 -18.1 0 -21.1 C 6.8 -18.1 9.7 -6.3 0 0 Z' fill='%234fc13f'/%3E%3Cpath d='M0 0 C 9.7 -6.3 6.8 -18.1 0 -21.1 Q 1.2 -10.6 0 0 Z' fill='%232f9a33'/%3E%3C/g%3E%3C/g%3E%3Cg%3E%3Cg transform='translate(84.3 78.2) rotate(-96)'%3E%3Cpath d='M0 0 C -10.8 -7.0 -7.6 -20.2 0 -23.5 C 7.6 -20.2 10.8 -7.0 0 0 Z' fill='%234fc13f'/%3E%3Cpath d='M0 0 C 10.8 -7.0 7.6 -20.2 0 -23.5 Q 1.3 -11.7 0 0 Z' fill='%232f9a33'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3Cg%3E%3Cpath d='M32 101 H88 L82.5 124 Q81.5 128 77.5 128 H42.5 Q38.5 128 37.5 124 Z' fill='%23ef7a3d'/%3E%3Cpath d='M73 101 H88 L82.5 124 Q81.5 128 77.5 128 H70 Z' fill='%23d2602a'/%3E%3Crect x='27' y='92' width='66' height='13' rx='6' fill='%23d65f27'/%3E%3Crect x='31' y='93.5' width='40' height='3' rx='1.5' fill='%23f39363' opacity='.8'/%3E%3Cpath d='M45 108 H75 V114 Q60 122.5 45 114 Z' fill='%23000' opacity='.08'/%3E%3Cpath d='M46.5 109.5 H73.5 M46.5 109.5 V113.4 Q60 120.6 73.5 113.4 V109.5' stroke='%23ffe3c9' stroke-width='1.6' stroke-dasharray='2.6 2.4' stroke-linecap='round' fill='none'/%3E%3C/g%3E%3Cg fill='%2338a6ff'%3E%3Ctext x='92' y='55.316' font-family='Bricolage Grotesque, Figtree, system-ui, sans-serif' font-weight='800' font-size='22'%3E%3F%3C/text%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat; animation: m-bob 3.2s ease-in-out infinite; }
.empty-state > .ic { display: none; }
.empty-state h2 { margin: 0; font-size: var(--t-xl); }
.empty-state p { margin: 0 0 var(--sp-3); max-width: 42ch; color: var(--ink-2); font-weight: 600; }
.empty-state .btn { margin-top: var(--sp-2); }
.footer-note { max-width: 1120px; margin: 40px auto 0; font-size: .78rem; color: var(--ink-2); text-align: center; }

#toast-host { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--r-md); font-weight: 700; font-size: var(--t-sm); box-shadow: 0 var(--lip) 0 rgb(0 0 0 / .25); transition: opacity .3s; animation: toast-in .25s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast.out { opacity: 0; }

.loading { display: grid; place-items: center; min-height: 40vh; color: var(--ink-2); }

.tutor-box { margin-top: 14px; padding-top: 12px; border-top: var(--bw) dashed var(--border); }
.tutor-answer { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); }
.tutor-answer p:last-child { margin-bottom: 0; }

.plan-today { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-top: var(--sp-4); border-bottom-width: 6px; }

/* ---------- Gamificación ---------- */
/* Oro = XP, nivel y premios. Llama (racha) = naranja. */
.progress-card { display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-4); }
.xp-bar { height: 16px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 6px 0 4px; }
.xp-bar > i { background: var(--gold-bright); }
.week-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 72px; }
.week-bars .wb { display: grid; justify-items: center; gap: 6px; }
.week-bars i { display: block; width: 100%; max-width: 26px; min-height: 10px; border-radius: 8px; background: var(--surface-3); }
.week-bars i.on { background: var(--orange-bright); box-shadow: inset 0 -4px 0 rgb(0 0 0 / .14); }
.week-bars .wb.today i:not(.on) { background: none; border: var(--bw) dashed var(--border-strong); }
.week-bars .wb.today span { color: var(--ink); font-weight: 800; }
.week-bars span { font: 800 .68rem var(--font-display); text-transform: uppercase; color: var(--ink-2); }
.pill.streak .ic { color: var(--ink-2); }
.pill.streak.lit { background: var(--orange-soft); color: var(--clay); }
.pill.streak.lit .ic { color: var(--orange-bright); fill: var(--orange-bright); animation: flame 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes flame { 0%, 100% { transform: scale(1) rotate(0); } 30% { transform: scale(1.08, .95) rotate(-4deg); } 60% { transform: scale(.96, 1.06) rotate(3deg); } }
.xp-pill { background: var(--gold-soft); color: var(--gold); }
.xp-pill .ic { color: var(--gold-dark) !important; }
/* "+XP" flotante: ficha dorada que sube */
.xp-pop {
  position: fixed; left: 50%; top: 34%; transform: translateX(-50%); z-index: 60; pointer-events: none;
  font: 800 1.5rem var(--font-display); letter-spacing: -0.02em; color: #3d2a00; background: var(--gold-bright);
  padding: 6px 16px; border-radius: 999px; box-shadow: 0 var(--lip) 0 var(--gold-dark); animation: xppop 1.25s cubic-bezier(.2, .9, .3, 1) forwards;
}
@keyframes xppop { 0% { opacity: 0; transform: translate(-50%, 14px) scale(.6); } 18% { opacity: 1; transform: translate(-50%, 0) scale(1.12); } 30% { transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -54px) scale(.95); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -16px; width: 10px; height: 16px; border-radius: 3px; animation: fall cubic-bezier(.25, .4, .55, 1) forwards; }
.confetti i.round { width: 11px; height: 11px; border-radius: 50%; }
.confetti i.strip { width: 6px; height: 20px; }
@keyframes fall { to { top: 105vh; transform: translateX(var(--dx, 40px)) rotate(var(--rot, 720deg)); } }
/* Diálogo de celebración: rayos dorados detrás de Pip, título grande, XP en ficha. */
.celebrate { text-align: center; border-color: var(--gold-bright); border-bottom-color: var(--gold-dark); padding-top: 0; overflow: hidden; }
.celebrate-hero { position: relative; display: grid; place-items: center; height: 150px; margin: 0 -24px 4px; background: var(--gold-soft); }
.celebrate-hero::before {
  content: ""; position: absolute; width: 340px; height: 340px; left: 50%; top: 50%; margin: -170px 0 0 -170px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--gold-bright) 40%, transparent) 0deg 12deg, transparent 12deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%); mask: radial-gradient(circle, #000 25%, transparent 70%);
  animation: rays 14s linear infinite;
}
@keyframes rays { to { transform: rotate(360deg); } }
.celebrate-hero .mascot { position: relative; margin-top: 18px; }
.celebrate-body { display: grid; gap: 14px; padding-top: 14px; }
.celebrate-item { display: flex; gap: 14px; align-items: center; text-align: left; }
.celebrate-item h2 { margin: 0 0 2px; font-size: var(--t-lg); }
.celebrate-item p { margin: 0; }
.badge-ic { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--gold-bright); color: #4a3300; flex: none; box-shadow: inset 0 -5px 0 var(--gold-dark); }
.celebrate-xp { justify-self: center; font: 800 var(--t-xl) var(--font-display); color: #3d2a00; background: var(--gold-bright); padding: 4px 18px; border-radius: 999px; box-shadow: 0 var(--lip) 0 var(--gold-dark); margin: 4px 0 8px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: var(--r-md); border: var(--bw) solid var(--border); border-bottom-width: var(--lip); background: var(--surface); }
.ach .badge-ic { width: 42px; height: 42px; border-radius: 12px; box-shadow: inset 0 -4px 0 var(--gold-dark); }
.ach.locked { opacity: .5; filter: grayscale(1); border-style: dashed; border-bottom-width: var(--bw); }
.ach strong { display: block; font-size: var(--t-sm); line-height: 1.2; }
.ach small { color: var(--ink-2); font-size: var(--t-xs); }
.cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.cal i { width: 14px; height: 14px; border-radius: 4px; background: var(--surface-3); }
.cal i.l1 { background: color-mix(in srgb, var(--orange-bright) 35%, var(--surface)); }
.cal i.l2 { background: color-mix(in srgb, var(--orange-bright) 65%, var(--surface)); }
.cal i.l3 { background: var(--orange-bright); }
.cal i.fz { background: var(--blue-bright); }
.level-hero { display: flex; gap: 18px; align-items: center; }
/* Insignia de nivel: escudo dorado (oro = progreso) */
.level-badge { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px 22px 36px 36px; background: var(--gold-bright); color: #3d2a00; font: 800 1.8rem var(--font-display); flex: none; box-shadow: inset 0 -6px 0 var(--gold-dark); }

/* ---------- Mascota Pip (js/mascot.js) ---------- */
/* Movimiento con intención: respira siempre, parpadea, y cada ánimo tiene su gesto
   (saluda, salta, puño arriba, cabecea dormida, piensa). */
.mascot { display: inline-block; line-height: 0; flex: none; }
.mascot-svg { display: block; overflow: visible; }
.mascot .m-body { transform-origin: 60px 100px; animation: m-bob 3.2s ease-in-out infinite; }
.mascot .m-eye { transform-box: fill-box; transform-origin: center; animation: m-blink 4.6s infinite; }
.mascot .m-wave { animation: m-wave 1.1s ease-in-out 3; }
.mascot .m-pump { animation: m-pump .7s ease-in-out 3; }
.mascot--proud .m-body { animation: m-jump .8s cubic-bezier(.3, 1.6, .5, 1) 2, m-bob 3.2s ease-in-out 1.6s infinite; }
.mascot--proud .m-arm { animation: m-cheer .4s ease-in-out 4 alternate; }
.mascot--sleepy .m-body { animation: m-nod 4s ease-in-out infinite; }
.mascot--thinking .m-body { animation: m-tilt 3.6s ease-in-out infinite; }
.mascot .m-zz, .mascot .m-q { animation: m-float 2.4s ease-in-out infinite; }
.mascot .m-heart { transform-box: fill-box; transform-origin: center; animation: m-beat 1.2s ease-in-out infinite; }
.mascot .m-spark { transform-box: fill-box; transform-origin: center; animation: m-twinkle 1.8s ease-in-out infinite; }
.mascot .m-spark:nth-of-type(2n) { animation-delay: .6s; }
@keyframes m-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes m-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes m-jump { 0%, 100% { transform: translateY(0) scale(1, 1); } 30% { transform: translateY(2px) scale(1.07, .93); } 60% { transform: translateY(-14px) scale(.96, 1.05); } }
@keyframes m-nod { 0%, 100% { transform: rotate(0) translateY(0); } 50% { transform: rotate(-3deg) translateY(1px); } }
@keyframes m-tilt { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(3deg); } }
@keyframes m-wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(22deg); } }
@keyframes m-pump { 0%, 100% { transform: rotate(0) translateY(0); } 50% { transform: rotate(-12deg) translateY(-3px); } }
@keyframes m-cheer { to { transform: translateY(-3px); } }
@keyframes m-float { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-4px); opacity: .6; } }
@keyframes m-beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } 45% { transform: scale(1.15); } }
@keyframes m-twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(.6) rotate(45deg); opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .mascot * { animation: none !important; } }

/* Burbuja de diálogo de la mascota (cola dibujada con un rombo para que herede borde). */
.bubble {
  position: relative; background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-md);
  padding: 12px 16px; font-weight: 700; font-size: var(--t-md); line-height: 1.4; color: var(--ink);
}
.bubble::before, .bubble::after { content: ""; position: absolute; top: 22px; width: 0; height: 0; border: 10px solid transparent; }
.bubble::before { left: -21px; border-right-color: var(--border); }
.bubble::after { left: -17px; border-right-color: var(--surface); }

/* ---------- Inicio (simplificado, P0.2) ----------
   Un solo marcador de juego (.home-stats), un héroe con UNA acción, el plan como
   camino compacto y tus exámenes en filas. Escritorio: columna + carril derecho
   (como Duolingo). Móvil: el marcador es una fila de iconos arriba. */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-5); align-items: start; }
.home-main { display: grid; gap: var(--sp-4); min-width: 0; grid-column: 1; grid-row: 1; }
.home-side { grid-column: 2; grid-row: 1; position: sticky; top: var(--sp-5); }
.home-main > #classes-home:empty { display: none; }

/* Tarjetas de Inicio con labio 3D (borde inferior más grueso). */
.home .card { border-bottom-width: 5px; }

/* Marcador */
.home-stats { display: grid; gap: var(--sp-4); padding: var(--sp-4); color: var(--ink); text-decoration: none; transition: background .12s; }
.home-stats:hover { background: var(--surface-2); }
.home-stats:active { transform: translateY(2px); }
.hs-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.hs {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center;
  padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); min-width: 0;
}
.hs > .ic, .hs > .hs-lvl { grid-row: span 2; }
.hs:last-child:nth-child(odd) { grid-column: 1 / -1; }
.hs b { font: 800 var(--t-xl)/1 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hs small { font-size: var(--t-xs); font-weight: 700; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-streak .ic { color: var(--ink-2); }
.hs-streak.lit { background: var(--clay-soft); }
.hs-streak.lit b { color: var(--clay); }
.hs-streak.lit .ic { color: var(--orange-bright); fill: var(--orange-bright); animation: flame 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
.hs-xp { background: var(--gold-soft); }
.hs-xp b { color: var(--gold); }
.hs-lvl {
  display: grid; place-items: center; width: 26px; height: 28px; border-radius: 8px 8px 13px 13px;
  font: 800 .85rem/1 var(--font-display); color: #5a3a00; background: var(--gold-bright); box-shadow: inset 0 -3px 0 var(--gold-dark);
}
.hs-freeze .ic { color: var(--blue); }
.hs-exam .ic { color: var(--danger-bright); }
.hs-level { display: grid; gap: 2px; }
.hs-level-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hs-level-head strong { font: 800 var(--t-md) var(--font-display); }
.hs-level-head .mono { font-size: var(--t-xs); color: var(--ink-2); }
.hs-level small { font-size: var(--t-xs); color: var(--ink-2); font-weight: 700; }

/* Héroe: Pip + saludo + UNA acción */
.home-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "pip greet" "pip cta"; gap: var(--sp-3) var(--sp-5); align-items: center; padding: var(--sp-5); }
.home-hero .hero-mascot { grid-area: pip; display: grid; justify-items: center; gap: 6px; align-self: center; }
.home-hero .hero-greet { grid-area: greet; min-width: 0; }
.home-hero .hero-cta { grid-area: cta; }
.home-hero h1 { margin: 0 0 var(--sp-3); font-size: var(--t-2xl); }
.stage-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font: 800 .68rem var(--font-display); text-transform: uppercase; letter-spacing: .06em; background: var(--green-soft); color: var(--green-dark); white-space: nowrap; }
:root[data-theme="dark"] .stage-chip { color: var(--green); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stage-chip { color: var(--green); } }
.hero-cta { display: grid; gap: 6px; }
.hero-cta .btn { width: 100%; max-width: 440px; }
.hero-cta small { color: var(--ink-2); font-weight: 700; }

/* Mis exámenes: filas tocables con insignia-bolsillo y botón ▶ */
.home-exams .section-title { margin: var(--sp-4) 0 var(--sp-3); }
.exam-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.exam-row {
  --accent: var(--blue);
  display: flex; align-items: center; gap: var(--sp-2); min-width: 0; padding: var(--sp-3);
  background: var(--surface); border: var(--bw) solid var(--border); border-bottom-width: 5px; border-radius: var(--r-lg);
}
.exam-row-main { display: flex; align-items: center; gap: var(--sp-3); flex: 1; min-width: 0; color: var(--ink); text-decoration: none; }
.exam-row-main .exam-icon { width: 48px; height: 48px; border-radius: 14px; font-size: .9rem; }
.exam-row-main .exam-icon.long { font-size: .62rem; }
.exam-row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.exam-row-text strong { font: 800 var(--t-lg) var(--font-display); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-row-text small { font-size: var(--t-xs); font-weight: 700; color: var(--ink-2); line-height: 1.3; }
.exam-row-chev { color: var(--border-strong); flex: none; }
.exam-row:has(.exam-row-go) .exam-row-chev { display: none; }
.exam-row:hover { background: var(--surface-2); }
.exam-row-go {
  flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 70%, #000);
}
.exam-row-go .ic { fill: currentColor; margin-left: 3px; }
.exam-row-go:active { transform: translateY(4px); box-shadow: none; }
.exam-row-add { justify-content: center; border-style: dashed; border-bottom-width: var(--bw); color: var(--ink-2); text-decoration: none; min-height: 82px; }
.exam-row-add .add-exam-plus { width: 40px; height: 40px; font-size: 1.5rem; }
.exam-row-add:hover { color: var(--blue); }

@media (max-width: 900px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
  .home-side { grid-column: 1; grid-row: 1; position: static; }
  .home-main { grid-row: 2; }
  /* Marcador = barra de iconos (sin etiquetas visibles, con title) */
  .home-stats { padding: 0; background: none; border: 0 !important; }
  .home-stats:hover { background: none; }
  .hs-row { display: flex; justify-content: space-between; gap: var(--sp-2); }
  .hs { display: flex; gap: 6px; padding: 6px 12px; flex: 1; justify-content: center; }
  .hs b { font-size: var(--t-lg); }
  .hs small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .hs-level { display: none; }
}
@media (max-width: 600px) {
  .home-hero { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "pip greet" "cta cta"; gap: var(--sp-3); padding: var(--sp-4); }
  .home-hero .hero-mascot .mascot-svg { width: 92px; height: 115px; }
  .home-hero .stage-chip { font-size: .6rem; padding: 3px 8px; }
  .home-hero h1 { font-size: var(--t-xl); margin-bottom: var(--sp-2); }
  .home-hero .bubble { font-size: var(--t-sm); padding: 10px 12px; }
  .home-hero .hero-cta .btn { max-width: none; }
  .bubble::before, .bubble::after { display: none; }
  .exam-rows { grid-template-columns: minmax(0, 1fr); }
  .exam-row-add { min-height: 64px; flex-direction: row; }
}

/* Pastillas de estadística: fondo suave, sin borde (menos ruido). */
.pill.c-orange { background: var(--orange-soft); color: var(--clay); }
.pill.c-orange .ic { color: var(--orange-bright); fill: var(--orange-bright); }
.pill.c-yellow { background: var(--gold-soft); color: var(--gold); }
.pill.c-yellow .ic { color: var(--gold-dark); }
.pill.c-blue { background: var(--blue-soft); color: var(--blue); }
.pill.c-blue .ic { color: var(--blue); }
.pill.c-purple { background: var(--blue-soft); color: var(--blue); }
.pill.c-purple .ic { color: var(--blue); }
.pill.c-grey { color: var(--ink-2); }
.pill.c-grey .ic { color: var(--ink-2); }
.level-row { display: flex; align-items: center; gap: 14px; }
.level-row .level-badge { width: 56px; height: 58px; border-radius: 16px 16px 28px 28px; font-size: 1.4rem; }
.stage-next { display: flex; align-items: center; gap: 10px; font-size: var(--t-xs); color: var(--ink-2); font-weight: 800; }
.stage-next .progress { flex: 1; height: 10px; }
.stage-next .progress > i { background: var(--green-bright); min-width: 10px; }
.stage-next .progress > i::after { top: 2px; height: 2px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; font: 800 var(--t-lg) var(--font-display); letter-spacing: -0.02em; }

/* Resultados: "lección completada". Pip delante de rayos que giran; el título toma el
   color del ánimo (oro = muy bien, verde = bien, azul = ánimo). Fondo blanco: el color
   está en el título, las cajas y los rayos, no en todo el bloque. */
.result-hero.with-mascot { grid-template-columns: auto auto 1fr; }
.result-hero .res-mascot { position: relative; display: grid; justify-items: center; gap: 6px; isolation: isolate; }
.result-hero .res-mascot::before {
  content: ""; position: absolute; z-index: -1; width: 220px; height: 220px; left: 50%; top: 50%; margin: -118px 0 0 -110px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--mood-c) 34%, transparent) 0deg 11deg, transparent 11deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%); mask: radial-gradient(circle, #000 30%, transparent 70%);
  animation: rays 18s linear infinite;
}
.result-hero h1 { margin: 0 0 6px; font-size: clamp(var(--t-xl), 3.2vw, var(--t-2xl)); color: var(--mood-t, var(--ink)); }
.result-hero.mood-proud { --mood-c: var(--gold-bright); --mood-t: var(--gold); border-bottom-color: var(--gold-bright); }
.result-hero.mood-happy { --mood-c: var(--green-bright); --mood-t: var(--green-ink); border-bottom-color: var(--green-bright); }
.result-hero.mood-encouraging { --mood-c: var(--blue-bright); --mood-t: var(--blue); border-bottom-color: var(--blue-bright); }
.result-hero .ring-fill { stroke: var(--mood-c, var(--accent)); }
.result-hero .bubble { margin-top: 12px; display: inline-block; background: var(--surface-2); border-color: transparent; }
.result-hero .bubble::before, .result-hero .bubble::after { display: none; }
.result-hero .res-main > .big-num { color: var(--ink); }
@media (max-width: 760px) {
  .result-hero.with-mascot { grid-template-columns: auto 1fr; }
  .result-hero.with-mascot { justify-content: center; justify-items: center; }
  .result-hero.with-mascot .res-main { grid-column: 1 / -1; justify-self: stretch; text-align: center; }
  .result-hero.with-mascot .stat-strip { justify-content: center; }
}
@media (max-width: 420px) { .result-hero .ring, .result-hero .ring svg { width: 92px !important; height: 92px !important; } }

/* ---------- Clases (panel de profesor, js/teacher-views.js) ---------- */
.cls-exams { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.cls-exams legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; padding: 0; }
.stack .cls-check, .cls-check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.cls-join { display: flex; gap: 8px; flex-wrap: wrap; }
.cls-code-input { font: 700 1.1rem var(--font-mono); letter-spacing: .2em; text-transform: uppercase; width: 11ch; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--ink); }
.cls-invite { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.cls-code { font-size: 2rem; font-weight: 700; letter-spacing: .18em; margin: 2px 0 4px; }
.cls-form summary { cursor: pointer; }
.cls-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 14px; }
.cls-grid label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.cls-grid label[hidden] { display: none; }
.cls-grid input[name="title"] { font: inherit; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink); }
.cls-grid .cls-wide { grid-column: 1 / -1; }
.cls-assign-row { grid-template-columns: minmax(160px, 1.6fr) 2fr 60px auto; }
.cls-home { margin-top: 16px; }
.cls-home .section-title h2 { display: inline-flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.cls-heat-wrap { max-height: 70vh; }
.cls-heat { border-collapse: separate; border-spacing: 2px; font: 600 .8rem var(--font-mono); }
.cls-heat th { font: 600 .78rem var(--font-ui); color: var(--ink-2); text-align: left; }
.cls-heat thead th { position: sticky; top: 0; background: var(--surface); vertical-align: bottom; height: 130px; }
.cls-heat thead th span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; max-height: 124px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cls-heat tbody th { position: sticky; left: 0; background: var(--surface); padding-right: 10px; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.cls-heat td { min-width: 34px; height: 30px; text-align: center; border-radius: 6px; color: var(--ink); }
.cls-heat .cls-heat-total th, .cls-heat .cls-heat-total td { border-top: 2px solid var(--border); font-weight: 800; }
.hm-none { color: var(--ink-2); background: var(--surface-2); }
.hm-0 { background: var(--danger-soft); }
.hm-1 { background: color-mix(in srgb, var(--warning) 22%, var(--surface)); }
.hm-2 { background: color-mix(in srgb, var(--success) 18%, var(--surface)); }
.hm-3 { background: color-mix(in srgb, var(--success) 38%, var(--surface)); }
.cls-legend { display: flex; gap: 6px; flex-wrap: wrap; }
.cls-legend span { padding: 2px 8px; border-radius: 6px; color: var(--ink); }
@media (max-width: 600px) { .cls-assign-row { grid-template-columns: 1fr 60px auto; } }

/* Botón "Reportar un problema" (widgets.css): en sesión, por encima de la barra
   inferior para no tapar "Siguiente"/"Comprobar". */
html body.in-session .fb-fab { top: 78px; bottom: auto; }

/* ---------- Matemáticas (KaTeX, js/mathtext.js) ---------- */
.katex { font-size: 1.1em; line-height: 1.25; text-rendering: auto; }
.katex-display { margin: .5em 0; }
.math-block { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; padding: 1px 0; }
.math-block > .katex-display { margin: .4em 0; }
.math-pending { opacity: .6; }
.choice .ctext .katex { font-size: 1.12em; }
.ctext, .q-stem, .ex-quick, .theory .body { min-width: 0; }
.spr-preview { min-height: 2.4em; margin: 6px 0 0; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.spr-preview .lbl { color: var(--ink-2); }
.spr-preview .lbl { font-size: .8rem; opacity: .7; }

/* Móvil estrecho: menos relleno anidado en la corrección y ecuaciones en bloque que caben (revisión visual G3/F6). */
@media (max-width: 480px) {
  .feedback .body { padding: 12px 10px; }
  details.theory summary { padding: 12px 10px; }
  details.theory .body { padding: 0 10px 10px; }
  .math-block .katex { font-size: clamp(.8em, 4.3vw, 1.1em); }
}

/* Sección o simulacro con candado mientras no haya audio con voz natural (js/audio.js). */
.audio-soon { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2, #f3f4f6); color: var(--muted, #555); font-weight: 600; font-size: .92rem; }

/* ---------- Menú lateral con grupos plegables (Exámenes ▾ · IB ▾ · Idiomas ▾; dueño, 2026-10-15) ---------- */
.nav-group { display: grid; gap: 2px; }
.nav-group-head { display: flex; align-items: stretch; gap: 2px; }
.nav-group-head .nav-link { flex: 1; min-width: 0; }
.nav-group-head .nav-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link.has-active { color: var(--ink); }
.nav-fold {
  flex: none; width: 40px; min-height: 50px; display: grid; place-items: center; border: var(--bw) solid transparent; border-radius: var(--r-sm);
  background: none; color: var(--ink-2); cursor: pointer; padding: 0;
}
.nav-fold:hover { background: var(--surface-2); color: var(--ink); }
.nav-fold { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.nav-fold .ic { transition: transform .22s ease; }
.nav-group:not(.is-open) .nav-fold .ic { transform: rotate(-90deg); }
.nav-sub { display: grid; gap: 2px; padding: 0 0 4px 22px; position: relative; }
/* Plegado (bug del dueño 2026-10-16): display:grid anulaba el atributo hidden y los hijos nunca se ocultaban. */
.nav-sub[hidden] { display: none; }
.nav-sub.is-anim { overflow: hidden; transition: height .22s ease, opacity .22s ease; }
/* La barra mide --sidebar: los hijos de rejilla no pueden crecer con nombres largos (el texto se corta con …). */
#side-nav > *, .nav-group > *, .nav-sub > * { min-width: 0; }
/* Aro de foco del menú lateral por dentro del elemento: no sobresale de la barra ni pisa la página. */
.sidebar .nav-link:focus-visible, .sidebar .nav-sub-link:focus-visible, .sidebar .nav-fold:focus-visible { outline-offset: -3px; border-radius: var(--r-sm); }
.nav-sub::before { content: ""; position: absolute; left: 26px; top: 2px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--border); }
.nav-sub-link {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 10px 4px 12px; border-radius: var(--r-sm); text-decoration: none;
  font: 700 var(--t-sm) var(--font-ui); color: var(--ink-2); border: var(--bw) solid transparent;
}
.nav-sub-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-sub-link[aria-current="page"] { background: color-mix(in srgb, var(--nav-c) 14%, var(--surface)); color: var(--ink); border-color: var(--nav-c); }
.nav-sub-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-dot {
  flex: none; width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: var(--nav-c, var(--blue));
  color: #fff; font: 800 .6rem var(--font-display); letter-spacing: 0;
}
.nav-sub-link .nav-badge { margin-left: 0; }

/* Pie de la ficha de examen / mapa de idioma: Resultados y Repaso solo de ese examen/idioma. */
.exam-foot { margin-top: var(--sp-6); }
.exam-foot-link {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); padding: 14px 16px; min-height: 72px;
  border-color: color-mix(in srgb, var(--nav-c) 35%, var(--border));
}
.exam-foot-link > .ic:first-child { flex: none; color: var(--nav-c); }
.exam-foot-link > span { flex: 1; min-width: 0; display: grid; gap: 2px; }
.exam-foot-link strong { font: 800 var(--t-md) var(--font-display); letter-spacing: -0.01em; }
.exam-foot-link small { color: var(--ink-2); font-size: .85rem; line-height: 1.3; }
.exam-foot-link > .ic:last-child { color: var(--ink-2); flex: none; }
.exam-foot-link .nav-badge { flex: none; margin: 0; width: auto; min-width: 0; }
.exam-foot-link:hover { background: color-mix(in srgb, var(--nav-c) 8%, var(--surface)); }
.lmap .exam-foot, .ladmap .exam-foot { margin: var(--sp-6) var(--sp-2) 0; }
.res-scope .exam-icon { width: 28px; height: 28px; font-size: .7rem; }

/* Ajustes: Resultados y logros generales. */
.settings-h { font-size: 1.05rem; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.settings-links { display: flex; gap: 8px; flex-wrap: wrap; }
