:root {
  color-scheme: dark;
  --bg: #0c241c;
  /* Cristal iOS v4.0: superficies translúcidas grises (no sólidas), borde de
     luz, brillo superior y sombra profunda. El blur solo va en el cromo
     flotante (header, dock, modales), donde hay contenido detrás que
     desenfocar; en las tarjetas sobre fondo plano no se vería y costaría
     rendimiento. --bg NO cambia: el fondo del osito del héroe es #0c241c. */
  --card: rgba(255, 255, 255, .07);
  --ink: #f3eedc;
  --mut: #b2c3b7;
  --line: rgba(255, 255, 255, .14);
  --soft: rgba(255, 255, 255, .11);
  --green: #c9efb9;
  --green-d: #b8e4a8;
  --green-soft: rgba(201, 239, 185, .14);
  --button-ink: #10281d;
  --track: rgba(255, 255, 255, .18);
  --warm: #f0b27c;
  --blue: #417482;
  --blue-d: #305d68;
  --red: #f1a895;
  --red-d: #8b4034;
  --yellow: #f1c68d;
  --yellow-d: #d9a76a;
  --purple: #d2badd;
  --r: 12px;
  --glass: rgba(255, 255, 255, .07);
  --glass-strong: rgba(20, 40, 30, .55);
  --glass-border: rgba(255, 255, 255, .14);
  --glass-blur: blur(22px) saturate(160%);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 12px 28px rgba(0, 0, 0, .38);
  --shadow-sm: inset 0 1px 0 rgba(255, 255, 255, .12), 0 4px 12px rgba(0, 0, 0, .3);
  --font: -apple-system, BlinkMacSystemFont, "Noto Sans Thai", system-ui, sans-serif;
  --body: var(--font);
  --measure: 1020px;
  --gutter: clamp(20px, 5.6vw, 38px);
  --bottom-nav-height: 62px;
}
*, *::before, *::after { box-sizing: border-box; }
html { margin: 0; background: var(--bg); touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--bg); font-family: var(--body);
  font-size: 16px; line-height: 1.58; min-width: 280px;
  padding-bottom: calc(var(--bottom-nav-height) + 14px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
/* Ambiente tras el cristal: brillos suaves SOLO abajo, lejos del héroe —
   la zona del osito queda en #0c241c puro para que su fondo no se note. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(70% 45% at 90% 100%, rgba(65, 116, 130, .10), transparent 70%),
    radial-gradient(60% 40% at 0% 78%, rgba(201, 239, 185, .07), transparent 70%);
}
button, input, select { font: inherit; color: inherit; }
input, select, textarea { font-size: max(16px, 1em); }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, summary, input { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--warm); outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
img { vertical-align: middle; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.topbar {
  /* Empieza NO fijo: en Safari el sticky pintado en el primer frame puede
     quedar desplazado y tapar la cabeza del osito del héroe hasta el primer
     scroll. Al esconder el splash, bootFern añade body.ready y el header
     pasa a ser sticky (en scroll 0 la posición es la misma, sin salto). */
  position: relative; top: 0; z-index: 22; background: transparent;
  padding-top: env(safe-area-inset-top);
}
body.ready .topbar { position: sticky; }
.hud {
  /* v4.4: SIN contenedor — el logo y los idiomas flotan nativos sobre el
     fondo, alineados con los bordes del contenido. Nada de píldora. */
  width: min(var(--measure), calc(100% - max(var(--gutter), env(safe-area-inset-left)) - max(var(--gutter), env(safe-area-inset-right))));
  min-height: 62px; margin: 10px auto 0;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 0;
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.logo {
  min-height: 44px; display: inline-flex; align-items: center;
  border: 0; padding: 0; background: transparent; font-size: 31px; font-weight: 780;
  letter-spacing: -.067em; color: var(--ink);
}
.logo-period { color: var(--warm); }
.quick-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
  margin: 0 0 19px;
}
.stat { display: grid; gap: 2px; color: var(--mut); font-size: 13px; }
.stat dd { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 19px; font-weight: 680; margin: 0; }
.langtog { display: flex; align-items: center; gap: 7px; }
.langtog button {
  min-width: 37px; min-height: 44px; border: 0; padding: 0 3px; background: transparent;
  color: var(--ink); font-size: 14px; font-weight: 670;
}
.langtog button.on { color: var(--green); text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1.5px; }
.wrap { width: min(var(--measure), calc(100% - max(var(--gutter), env(safe-area-inset-left)) - max(var(--gutter), env(safe-area-inset-right)))); margin: 0 auto; padding: 14px 0 28px; }
.view { display: none; }
.view.on { display: block; }
.hero {
  display: grid; grid-template-areas: "copy art"; grid-template-columns: minmax(0, .9fr) minmax(0, 1fr);
  gap: 15px; align-items: center; isolation: isolate;
}
.hero-text { grid-area: copy; padding: 12px 0 30px; position: relative; z-index: 1; }
.hero h1 { font-size: clamp(36px, 5vw, 66px); overflow-wrap: break-word; }
.kicker {
  font-size: 13px; font-weight: 710; color: var(--green); margin: 0 0 8px;
  letter-spacing: .16em; text-transform: uppercase;
}
html[lang="th"] .kicker { letter-spacing: normal; }
h1 { font-size: clamp(39px, 6.45vw, 73px); line-height: 1.04; font-weight: 730; letter-spacing: -.065em; }
html[lang="th"] h1 { letter-spacing: -.035em; line-height: 1.16; }
h1[tabindex]:focus { outline: none; }
.hero-note { color: var(--mut); margin: 7px 0 18px; line-height: 1.5; font-size: 16px; }
.hero-count { color: var(--green); font-size: 15.5px; font-weight: 700; margin: -8px 0 18px; }
.hero-art { grid-area: art; position: relative; min-width: 0; margin-block-start: -12px; }
.hero-art img { display: block; width: 100%; height: auto; object-fit: contain; }
.btn {
  min-height: 47px; padding: 9px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 14px; background: var(--green); color: var(--button-ink);
  text-align: center; font-size: 15px; font-weight: 690;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 8px 20px rgba(0, 0, 0, .35);
  transition: background .16s ease, opacity .16s ease, transform .12s ease;
}
.btn:hover { background: #dcf6cf; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .63; }
.btn.blue { background: var(--blue-d); color: var(--ink); }
.btn.blue:hover { background: var(--blue); }
.btn.red { background: var(--red-d); color: var(--ink); }
.btn.red:hover { background: #9b4b3d; }
.btn.yellow, .btn.ghost, .btn.secondary {
  background: var(--glass); color: var(--green); border-color: var(--glass-border);
  box-shadow: var(--shadow-sm);
}
.btn.yellow:hover, .btn.ghost:hover, .btn.secondary:hover { background: var(--soft); }
.text-action, .chip, .xbtn {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; padding: 0 1px; background: transparent; color: var(--green);
  font-size: 14px; font-weight: 670; text-align: start;
}
.chip {
  padding: 8px 14px; border: 1px solid var(--track); border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow-sm);
}
.chip:hover, .chip.on { text-decoration: none; background: var(--green-soft); }
.chip:active { transform: scale(.97); }
.text-action:hover { text-decoration: underline; text-underline-offset: 4px; }
.xbtn { min-width: 44px; font-size: 19px; color: var(--mut); }
.chiprow { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.chiprow > .chip { padding-inline: 9px; }
.hero .primary { min-width: 166px; padding-inline: 20px; font-size: 16px; font-weight: 750; }
/* Lista agrupada estilo iOS (Centro de mando): una sola tarjeta de cristal
   con las filas dentro, separadas por líneas finas. */
.home-actions {
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 22px; box-shadow: var(--shadow); overflow: hidden;
}
.home-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px;
  border: 0; padding: 6px 16px 6px 18px; background: transparent; color: var(--ink);
  text-align: start; line-height: 1.35; font-size: 16px; font-weight: 690;
}
.home-actions > button, .study-disclosure[open] > summary { border-bottom: 1px solid var(--line); }
.home-row:hover { color: var(--green); }
.home-row::after, .study-disclosure[open] > .home-row::after {
  position: static; flex: 0 0 7px; height: 7px; margin-inline-start: auto;
  content: ""; transform: rotate(-45deg); border-block-end: 1.5px solid var(--mut);
  border-inline-end: 1.5px solid var(--mut);
}
.study-disclosure > summary { color: var(--green); cursor: pointer; list-style: none; }
.study-disclosure[open] > .home-row::after { transform: rotate(45deg) translateY(-2px); }
.study-content { padding: 0 0 5px 10px; }
.study-content .path { border-top: 0; }
.study-content .text-action { margin-top: 4px; }
.quiet-count { color: var(--mut); font-size: 14px; font-weight: 630; font-variant-numeric: tabular-nums; }
.today { padding: 17px 0 2px; }
.today-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.today-head h2 { font-size: 16px; font-weight: 710; }
.today-head output { color: var(--green); font-size: 15px; font-weight: 720; font-variant-numeric: tabular-nums; white-space: nowrap; }
.today progress {
  display: block; appearance: none; width: 100%; height: 7px; margin-top: 9px;
  border: 0; border-radius: 99px; overflow: hidden; background: var(--track); color: var(--green);
}
.today progress::-webkit-progress-bar { background: var(--track); border-radius: inherit; }
.today progress::-webkit-progress-value { background: var(--green); border-radius: inherit; }
.today progress::-moz-progress-bar { background: var(--green); border-radius: inherit; }
.bar { height: 5px; overflow: hidden; background: var(--track); border-radius: 9px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: inherit; transition: width .28s ease; }
.bar.blue i { background: #a1cfda; }
.path, .native-list { display: grid; gap: 10px; }
.path details, .native-list details {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  border-top: 3px solid var(--subj, var(--line));
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.path summary, .native-list summary, .plain-details > summary {
  min-height: 68px; list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  position: relative; padding: 12px 40px 12px 14px; font-size: 16px; font-weight: 665;
}
.path summary:active, .native-list summary:active { background: var(--soft); }
.path details[open] > summary, .native-list details[open] > summary { background: var(--soft); }
summary::-webkit-details-marker { display: none; }
summary::after {
  content: ''; position: absolute; width: 9px; height: 9px; right: 16px;
  border-bottom: 2px solid var(--green); border-right: 2px solid var(--green);
  transform: translateY(-2px) rotate(45deg); transition: transform .18s ease;
}
details[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.subj-ic {
  flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 13px; background: var(--green-soft);
  background: color-mix(in srgb, var(--subj, #58cc02) 20%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--subj, #58cc02) 30%, transparent);
  font-size: 21px;
}
.mini-bar { display: block; height: 5px; background: var(--track); border-radius: 9px; overflow: hidden; margin-top: 5px; }
.mini-bar i { display: block; height: 100%; background: var(--subj, var(--green)); border-radius: inherit; }
.summary-title { display: grid; min-width: 0; gap: 1px; }
.summary-title small, .utility-row small { font-size: 13px; color: var(--mut); font-weight: 460; }
.completion-count { color: var(--mut); font-size: 13px; font-variant-numeric: tabular-nums; margin-inline-start: auto; white-space: nowrap; }
.completion-count.is-done { background: var(--green); color: var(--button-ink); font-weight: 700; padding: 4px 9px; border-radius: 999px; }
/* v4.4: franja de progreso general de Lessons. */
.learn-progress { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 15px 16px 16px; box-shadow: var(--shadow-sm); }
.learn-progress-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; font-size: 14px; color: var(--mut); }
.learn-progress-top b { font-size: 26px; font-weight: 800; letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.learn-progress-pct { margin-inline-start: auto; font-size: 15px; font-weight: 750; color: var(--green); font-variant-numeric: tabular-nums; }
.learn-progress .bar { height: 8px; }
.lesson-rows { margin: 0; padding: 0 12px 12px; list-style: none; display: grid; gap: 8px; }
.lesson-row {
  width: 100%; min-height: 52px; background: var(--soft); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; text-align: start;
  font-size: 15px; color: var(--ink);
}
.lesson-row::before { content: '📖'; font-size: 17px; flex: 0 0 auto; }
.lesson-row[aria-disabled="true"]::before { content: '🔒'; }
.lesson-row.is-done::before { content: '✓'; color: var(--green); font-weight: 800; }
.lesson-row:active { transform: scale(.985); }
.lesson-row b { font-weight: 670; }
.lesson-row span[data-status] {
  margin-inline-start: auto; font-size: 12px; font-weight: 700; white-space: nowrap;
  padding: 5px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green);
  border: 1px solid var(--line);
}
.lesson-row span[data-status="done"] { background: var(--green); color: var(--button-ink); border-color: var(--green); }
.lesson-row span[data-status="locked"] { background: transparent; color: var(--mut); border-color: var(--line); }
.lesson-row span.mut { margin-inline-start: auto; }
.subject-row, .utility-row {
  width: 100%; min-height: 64px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 12px 40px 12px 14px; position: relative;
  display: flex; align-items: center; gap: 12px; text-align: start;
  font-size: 15px; color: var(--ink); box-shadow: var(--shadow-sm);
}
.subject-row { border-top: 3px solid var(--subj, var(--line)); }
.subject-row::after {
  content: ''; position: absolute; width: 9px; height: 9px; right: 16px; top: 50%;
  border-bottom: 2px solid var(--green); border-right: 2px solid var(--green);
  transform: translateY(-50%) rotate(-45deg);
}
.subject-row:active, .utility-row:active { transform: scale(.985); background: var(--soft); }
.subject-row b, .utility-row b { font-weight: 670; }
.subject-row .mut { margin-inline-start: auto; }
.utility-row small, .subject-row small { display: block; }
.score-pill {
  font-size: 12px; font-weight: 700; white-space: nowrap; padding: 4px 9px;
  border-radius: 999px; background: var(--green-soft); color: var(--green);
  border: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
/* v4.4: Practice — tarjetas visuales 2×2 con icono grande. */
.utility-list { margin-bottom: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.utility-row { flex-direction: column; align-items: flex-start; gap: 10px; padding: 15px 14px; min-height: 128px; }
.utility-row::after { display: none; }
.utility-row .quiet-count { margin-inline-start: 0; }
.util-ic {
  width: 46px; height: 46px; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: 14px; background: var(--green-soft); font-size: 24px;
}
.util-ic.daily { background: rgba(255, 150, 0, .18); }
.util-ic.mistakes { background: rgba(255, 75, 75, .16); }
.util-ic.extra { background: rgba(165, 96, 232, .18); }
.util-ic.mock { background: rgba(201, 239, 185, .16); }
#quiz-list { display: grid; gap: 10px; }

.inner-view { max-width: 720px; margin-inline: auto; }
.inner-view.on { display: block; }
.screen-heading { min-height: 108px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 18px; }
.screen-heading h1 { font-size: clamp(32px, 5.5vw, 54px); }
.screen-heading p { margin-top: 7px; }
.screen-mascot { flex: 0 0 100px; max-width: 24vw; }
.screen-mascot img { --mascot-size: 104px; }
.subheading { font-size: 19px; font-weight: 720; margin: 19px 0 9px; }
.big { font-size: clamp(23px, 4vw, 36px); font-weight: 730; line-height: 1.22; letter-spacing: -.035em; margin-bottom: 8px; }
.mut { color: var(--mut); font-size: 14px; line-height: 1.55; }
.readable { max-width: 65ch; }
.readable p { margin-bottom: 10px; }
.readable .btn { margin-top: 10px; }
.back-link { margin-bottom: 3px; }
.card, .guide-sec {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 16px 18px; margin: 0 0 12px; box-shadow: var(--shadow);
}
.card p, .guide-sec p, .card ul { margin: 8px 0; }
.card h3 { font-size: 17px; margin-top: 15px; }
.card ul { padding-inline-start: 20px; }
.card ul li { margin: 6px 0; }
.hl { border-inline-start: 2px solid var(--track); padding: 5px 0 5px 11px; color: var(--green); margin: 11px 0; }
.simple-box, .recap-box { border-top: 1px solid var(--line); padding-top: 12px; margin: 15px 0; }
.simple-box .step-label, .recap-box .step-label { color: var(--green); font-size: 13px; font-weight: 700; margin-bottom: 5px; }

body.quiz-on { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
body.quiz-on .topbar, body.quiz-on .tabs { display: none; }
body.quiz-on .wrap { padding-top: max(15px, env(safe-area-inset-top)); }
#quiz-box, #mock-box { max-width: 668px; margin: 0 auto; }
.prow { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.prow > span { font-size: 14px; font-variant-numeric: tabular-nums; }
.prow .bar { flex: 1; }
#quiz-box .big { margin-bottom: 12px; }
.opt {
  display: flex; align-items: start; gap: 12px; width: 100%; text-align: start;
  min-height: 54px; padding: 13px 14px; margin: 0 0 9px; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px; font-weight: 560;
  line-height: 1.5; font-size: 16px; box-shadow: var(--shadow-sm);
}
.opt:active:not(:disabled) { transform: scale(.99); }
.opt .key {
  display: grid; place-items: center; border: 1px solid var(--track); border-radius: 50%;
  width: 24px; height: 24px; flex: 0 0 24px; color: var(--mut); font-size: 12px; font-weight: 700;
}
.opt:hover:not(:disabled), .opt.sel { color: var(--green); background: var(--soft); border-color: var(--green); }
.opt.sel .key { border-color: var(--green-d); color: var(--green); }
.opt.ok, .opt.correct { color: var(--green); background: var(--green-soft); border-color: #71987b; }
.opt.no, .opt.wrong { color: var(--red); background: rgba(139, 64, 52, .4); border-color: #aa7160; }
.opt.ok .key, .opt.correct .key { color: var(--green); border-color: #71987b; }
.opt.no .key, .opt.wrong .key { color: var(--red); border-color: #aa7160; }
.feedback {
  padding: 12px 14px; margin: 10px 0; background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 16px; line-height: 1.55;
  box-shadow: var(--shadow-sm);
}
.feedback.ok { color: var(--green); }
.feedback.no { color: var(--red); }
.feedback-line { display: flex; align-items: start; gap: 8px; }
.feedback-line img { flex: 0 0 69px; width: 69px; margin: -7px 0; }
.feedback-line p { margin: 2px 0; color: var(--mut); }
#quiz-box #nxt { margin-top: 7px; min-width: min(175px, 100%); }
.mock-panel { max-width: 668px; margin: 0 auto; }
.timerbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  padding: 12px 3px; font-size: 14px; color: var(--green-d); font-weight: 700;
}
.unit-banner { background: none !important; border-bottom: 1px solid var(--line); padding: 12px 0; margin-top: 13px; display: flex; justify-content: space-between; gap: 10px; font-size: 17px; font-weight: 690; }
table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 15px; }
td, th { text-align: start; padding: 7px 4px; border-bottom: 1px solid var(--line); }
td:last-child { text-align: end; }
input:not([type="date"]) {
  min-height: 44px; width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--track); padding: 5px 0;
}
input.blank {
  width: 100%; min-height: 54px; padding: 12px 16px; margin: 6px 0 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  color: var(--ink); font-size: 17px; box-shadow: var(--shadow-sm);
}
input.blank:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px #c9efb91f; }
.matchgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.matchbtn { min-height: 47px; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow-sm); }
.matchbtn.sel, .matchbtn.done { color: var(--green); background: var(--soft); border-color: var(--green); }
.matchbtn.done { opacity: .68; }

.fc {
  display: grid; text-align: center; justify-items: center; align-content: center;
  min-height: 250px; width: 100%; margin: 0 0 14px; padding: 24px 18px;
  border: 1px solid var(--line); border-radius: 24px;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
}
.fc:hover { background: var(--soft); }
.fc:active { transform: scale(.99); }
.fc .q, .fc .a { font-size: clamp(20px, 5vw, 36px); font-weight: 690; letter-spacing: -.03em; line-height: 1.38; margin: 10px 0; }
.fc .meta, .fc .hint { color: var(--mut); font-size: 14px; }
#fc-box .chip { flex: 1 1 40%; text-align: center; }
#fc-box .chiprow { margin-top: 9px; }
.datepick {
  position: absolute; inset: 0; background: transparent; border: 0; opacity: 0;
  width: 100%; height: 100%; cursor: pointer;
}
.datepick::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; cursor: pointer; }
.date-note { color: var(--mut); font-size: 13px; margin-top: 6px; }
.plain-details {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-sm); margin-bottom: 12px; overflow: hidden;
}
.plain-details > p { margin: 7px 0; }
.plain-details > summary { min-height: 60px; padding: 12px 40px 12px 16px; }
.plain-details > :not(summary) { padding-inline: 16px; }
.plain-details > :last-child { padding-bottom: 14px; }
.plain-details .card { border: 0; box-shadow: none; margin: 0; padding: 4px 16px 14px; border-radius: 0; }
.plan-steps { display: grid; gap: 9px; margin: 12px 0; }
.plan-step { display: flex; gap: 11px; align-items: flex-start; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px; }
.plan-step .n {
  flex: 0 0 26px; width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; background: var(--green); color: var(--button-ink); font-size: 13px; font-weight: 800; margin-top: 1px;
}
.plan-step p { margin: 0 !important; }
.week-list { list-style: none; padding: 0 !important; margin: 10px 0 4px !important; display: grid; gap: 8px; }
.week-list li { display: flex; gap: 10px; align-items: baseline; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 10px 13px; margin: 0 !important; }
.week-tag {
  flex: 0 0 auto; font-size: 12px; font-weight: 800; color: var(--green);
  background: var(--green-soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.guide-sec h3 { font-size: 19px; }
#badges .badge { padding: 8px 0; min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); }
.badge.off { color: var(--mut); }

/* Dock flotante de cristal (como la píldora inferior de iOS): flota sobre
   el contenido con blur, en vez de una barra pegada al borde. */
.tabs {
  position: fixed; z-index: 20;
  inset: auto 12px calc(10px + env(safe-area-inset-bottom)) 12px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 14px 32px rgba(0, 0, 0, .45);
}
.tabs .in { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 660px; margin: auto; padding: 6px; }
.tabs button {
  min-height: calc(var(--bottom-nav-height) - 12px); display: grid; align-content: center; justify-items: center; gap: 4px;
  border: 0; padding: 3px; margin: 0 2px; background: transparent; color: var(--ink);
  font-size: 12px; font-weight: 570; line-height: 1.15; border-radius: 999px;
}
.tabs button.on { color: var(--green); font-weight: 770; background: rgba(255, 255, 255, .12); }
.tabs button:hover { color: var(--green-d); }
.nav-icon { display: block; position: relative; width: 19px; height: 19px; }
.nav-icon::before, .nav-icon::after { content: ''; position: absolute; }
.route-icon::before {
  width: 14px; height: 14px; border-block: 1.6px solid; border-inline-start: 1.6px solid;
  border-block-start: 0; transform: rotate(-45deg); inset: 2px auto auto 3px; border-radius: 2px;
}
.route-icon::after { width: 11px; height: 11px; border-inline-end: 1.6px solid; border-block-end: 1.6px solid; transform: rotate(-45deg); inset: 2px auto auto 3px; }
.learn-icon { border: 1.6px solid; border-radius: 2px; width: 17px; height: 15px; margin-block: 2px; }
.learn-icon::before { width: 1.5px; height: 100%; background: currentColor; left: calc(50% - .75px); }
.quiz-icon::before { width: 17px; height: 12px; inset: 3px 1px; background: linear-gradient(currentColor,currentColor) left 1px / 16px 1.5px,linear-gradient(currentColor,currentColor) left 5px / 12px 1.5px,linear-gradient(currentColor,currentColor) left 9px / 14px 1.5px; background-repeat: no-repeat; }
.cards-icon::before, .cards-icon::after { width: 12px; height: 14px; border: 1.5px solid; border-radius: 3px; top: 1px; left: 2px; }
.cards-icon::after { background: var(--bg); left: 6px; top: 4px; }
.plan-icon::before { width: 17px; height: 15px; border: 1.5px solid; border-radius: 3px; left: 1px; top: 3px; }
.plan-icon::after { width: 15px; border-top: 1.5px solid; left: 2px; top: 8px; }

.modal {
  position: fixed; z-index: 40; inset: 0; overflow: auto; display: grid; place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: #071910c9;
}
/* El velo desenfoca el fondo; el lector (pantalla completa opaca) queda fuera. */
.modal:not(.reader-modal) {
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.modal > div { width: min(100%, 416px); padding: 19px; background: var(--card); border-radius: 18px; }
/* Tarjeta de cristal solo para el modal centrado (div, no dialog): el lector
   y las hojas usan sus propias reglas y no deben heredar este fondo. */
.modal:not(dialog) > div {
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 24px 48px rgba(0, 0, 0, .5);
}
.modal > div .mascot-art { margin-inline: auto; }
.reader-modal { display: block; padding: 0; background: var(--bg); }
body:has(.modal) { overflow: hidden; }
.reader { width: min(670px, calc(100% - 36px)); margin: auto; min-height: 100%; display: flex; flex-direction: column; padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); padding-bottom: max(28px, env(safe-area-inset-bottom)); }
.reader-head {
  position: sticky; top: 0; z-index: 1; padding-top: env(safe-area-inset-top);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--glass-border); min-height: 53px; gap: 10px; color: var(--mut); font-size: 14px; font-weight: 640;
}
.reader-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 18px; }
.reader-title h1 { font-size: clamp(31px, 6vw, 48px); }
.reader-title .mascot-art { flex-shrink: 0; --mascot-size: 93px; }
.lesson-body { margin-top: 13px; flex: 1; }
.lesson-body h3 { font-size: 21px; margin: 16px 0 8px; }
.lesson-body p, .lesson-body ul { margin: 7px 0; }
.lesson-body ul, .guide-sec ul { padding-inline-start: 23px; }
.reader-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 13px 0 max(13px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--glass-border); margin-top: 16px; position: sticky; bottom: 0;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
#splash {
  position: fixed; z-index: 100; inset: 0; display: grid; place-content: center; justify-items: center;
  padding: 20px; background: var(--bg); color: var(--mut); font-size: 14px; gap: 4px;
  transition: opacity .24s ease;
}
#splash img { width: min(240px, 66vw); height: auto; }
#splash.hide { opacity: 0; pointer-events: none; }
.toast {
  position: fixed; z-index: 52; bottom: calc(var(--bottom-nav-height) + 16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); text-align: center; padding: 10px 16px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); color: var(--ink); border-radius: 999px; font-size: 14px; font-weight: 620;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 12px 28px rgba(0, 0, 0, .4);
}
.confetti { pointer-events: none; position: fixed; inset: 0; z-index: 42; overflow: hidden; }
.confetti i { position: absolute; top: -10px; width: 5px; height: 7px; animation: fern-fall 1.8s ease-out both; }
@keyframes fern-fall { to { opacity: 0; transform: translateY(55vh) rotate(180deg); } }
#fx:empty { display: none; }

@media (max-width: 760px) {
  :root { --bottom-nav-height: 56px; }
  .hud { min-height: 55px; }
  .logo { font-size: 27px; }
  .langtog { gap: 4px; }
  .wrap { padding-block-start: 0; }
  .hero { grid-template: "art" "copy" / minmax(0, 1fr); gap: 0; }
  h1 { font-size: clamp(33px, 8.1vw, 49px); }
  .hero h1 { font-size: clamp(34px, 9.4vw, 52px); }
  .hero-text { padding: 6px 0 19px; }
  .hero-art { margin: 6px calc(-1 * var(--gutter)) 0; }
  .hero-art img { height: min(92vw, 40svh, 430px); }
  .kicker { line-height: 1.35; margin-bottom: 7px; }
  .hero-note { margin: 5px 0 14px; }
  .hero .btn { min-height: 46px; }
  .screen-heading { margin-top: 0; min-height: 89px; }
  .screen-mascot { flex-basis: 83px; }
  .tabs button { font-size: 11.5px; }
  .reader-title .mascot-art { --mascot-size: 72px; }
  .reader-actions .btn { flex: 1; }
}
@media (max-width: 352px) {
  :root { --gutter: 17px; }
  .hero h1 { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  #splash, .bar i { transition: none; }
  .confetti { display: none; }
}

.reader-modal { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0; color: var(--ink); }
.reader-modal:not([open]) { display: none; }
.question-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin: 11px 0 17px; }
.question-head .mascot-art { flex: 0 0 74px; }
.question-title { font-size: clamp(22px, 4.75vw, 35px); letter-spacing: -.025em; margin-top: 6px; }
#fb #chk { min-width: min(175px,100%); margin-top: 13px; }
.option-details { margin: 0 0 8px; }
.option-details > ul { margin: 0 0 12px; padding-inline-start: 18px; }
.option-details li { margin-block: 5px; }
.timerbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 1px; }

/* ---- Mi perfil (estilo Mis Costuritas, adaptado al tema oscuro) ---- */
.profile-head { display: flex; flex-direction: column; align-items: center; text-align: center; margin: 6px 0 20px; }
.profile-avatar {
  position: relative; width: 92px; height: 92px; padding: 0; border: 0; background: transparent;
  border-radius: 50%; margin-bottom: 14px; cursor: pointer;
}
.profile-avatar__img {
  display: block; width: 92px; height: 92px; border-radius: 50%; overflow: hidden;
  border: 3px solid #f3eedc; box-shadow: 0 0 0 1px var(--line), 0 10px 24px #00000055;
  background: radial-gradient(circle, #2a4a3c 0%, var(--card) 70%);
}
.profile-avatar__img img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar__badge {
  position: absolute; right: 0; bottom: 2px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--card); color: var(--green); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 8px #00000055;
}
.profile-head h1 { font-size: 27px; letter-spacing: -.03em; }
.profile-sub { color: var(--mut); font-size: 13px; margin-top: 5px; }
.profile-edit {
  border: 0; background: transparent; color: var(--green); font-size: 14px; font-weight: 670;
  padding: 10px 6px 0; cursor: pointer;
}
.profile-pill {
  margin-top: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  font-size: 12px; font-weight: 750; letter-spacing: .04em; color: var(--green);
  background: var(--green-soft); text-transform: uppercase;
}
.profile-xpbar { width: min(100%, 280px); height: 6px; background: var(--track); border-radius: 9px; overflow: hidden; margin-top: 13px; }
.profile-xpbar i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.profile-xpnote { color: var(--mut); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 14px; }
.stat-cell {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 12px 6px 10px; text-align: center; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0;
}
.stat-cell__ic { font-size: 17px; }
.stat-cell b { font-size: 18px; font-weight: 780; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-cell small { color: var(--mut); font-size: 11px; font-weight: 600; }
.plan-bar {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 15px 16px; margin-bottom: 6px; text-align: start;
  border: 1px solid rgba(201, 239, 185, .25); border-radius: 22px; cursor: pointer;
  background: rgba(201, 239, 185, .10);
  box-shadow: var(--shadow-sm);
}
.plan-bar__icon {
  flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card); font-size: 20px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.plan-bar__txt { flex: 1; min-width: 0; display: grid; gap: 1px; }
.plan-bar__txt strong { font-size: 15px; font-weight: 700; }
.plan-bar__txt small { color: var(--mut); font-size: 12px; }
.plan-bar__value {
  color: var(--green); font-size: 13px; font-weight: 700; white-space: nowrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
}
.plan-bar__chev { color: var(--green); font-size: 22px; font-weight: 400; }
.plan-bar:focus-within { outline: 2px solid var(--warm); outline-offset: 3px; }
.sec-head { display: flex; align-items: center; gap: 12px; margin: 24px 0 10px; }
.sec-head h2 { font-size: 21px; font-weight: 730; letter-spacing: -.028em; white-space: nowrap; }
.sec-rule { height: 1px; background: var(--line); flex: 1; }
.menu-group {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 6px;
}
.menu-row {
  width: 100%; min-height: 66px; display: flex; align-items: center; gap: 13px;
  padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--ink); text-align: start; cursor: pointer;
}
.menu-group .menu-row:last-child { border-bottom: 0; }
.menu-row:active { background: var(--soft); }
.menu-ic {
  flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; background: var(--green-soft); font-size: 20px;
}
.menu-txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.menu-txt strong { font-size: 15px; font-weight: 670; }
.menu-txt small { color: var(--mut); font-size: 12px; }
.menu-chev { color: var(--mut); font-size: 23px; font-weight: 400; }
.install-hint { cursor: default; }
.install-hint .menu-txt small { line-height: 1.45; }
.install-hint-x { min-width: 40px; }
/* Cuenta / sincronización (v4.3) */
.account-info { cursor: default; }
.account-info:active { background: transparent; }
.menu-ic.acct-g { font-weight: 800; font-size: 21px; font-family: var(--font); }
.acct-email-row { gap: 10px; cursor: default; }
.acct-email-row:active { background: transparent; }
.acct-email-row input {
  flex: 1; min-width: 0; background: var(--soft); border: 1px solid var(--line);
  color: var(--ink); border-radius: 12px; padding: 11px 12px;
  font: inherit; font-size: 16px;
}
.acct-email-row input::placeholder { color: var(--mut); }
.acct-email-row input:focus { outline: 2px solid var(--green); outline-offset: 0; }
.btn.acct-link-btn { flex: 0 0 auto; min-height: 44px; padding: 9px 13px; font-size: 14px; margin: 0; }
.account-group .menu-row .btn.acct-link-btn { margin-left: 6px; }
.acct-msg { margin: 0; padding: 10px 14px 12px; color: var(--mut); font-size: 13px; line-height: 1.5; }
.acct-msg[hidden] { display: none; }
.profile-icon::before {
  width: 8px; height: 8px; border: 1.6px solid; border-radius: 50%;
  left: 5px; top: 1px;
}
.profile-icon::after {
  width: 15px; height: 8px; border: 1.6px solid; border-bottom: 0;
  border-radius: 8px 8px 0 0; left: 2px; top: 11px;
}
/* Hoja inferior (estilo login de Costuras) */
.sheet-modal {
  margin: 0; width: 100%; height: 100%; max-width: none; max-height: none; border: 0;
  align-items: end; padding: 0;
}
.sheet-modal > div {
  width: 100%; max-width: 480px; margin: 0 auto; padding: 10px max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border-radius: 28px 28px 0 0;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); border-bottom: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 -12px 32px rgba(0, 0, 0, .4);
}
.sheet-handle { display: block; width: 36px; height: 4px; margin: 0 auto 14px; border-radius: 4px; background: var(--track); }
.sheet h2 { font-size: 21px; font-weight: 730; letter-spacing: -.025em; margin-bottom: 14px; text-align: center; }
.auth-field { display: grid; gap: 6px; margin-bottom: 14px; }
.auth-field > span { padding-left: 3px; color: var(--mut); font-size: 12px; font-weight: 680; }
.auth-field input {
  height: 54px; border: 1px solid var(--line); border-radius: 15px; background: var(--glass);
  padding: 0 16px; font-size: 16px; outline: 0; box-shadow: var(--shadow-sm);
}
.auth-field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px #c9efb91f; }
.sheet-submit { width: 100%; margin-bottom: 8px; }
.sheet-cancel { width: 100%; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.avatar-opt {
  aspect-ratio: 1; border: 2px solid var(--line); border-radius: 16px; background: var(--glass);
  display: grid; place-items: center; padding: 4px; cursor: pointer;
}
.avatar-opt img { width: 100%; height: 100%; object-fit: contain; }
.avatar-opt.on { border-color: var(--green); background: var(--green-soft); }
.avatar-opt:active { transform: scale(.96); }

/* Pantallas bajas (móvil en horizontal): el héroe no debe tapar el botón */
@media (max-height: 480px) {
  .hero { grid-template: "copy art" / minmax(0, 1fr) minmax(0, 0.85fr); gap: 12px; align-items: center; }
  .hero-text { padding: 4px 0 12px; }
  .hero h1 { font-size: clamp(26px, 7vh, 38px); }
  .hero-note { margin: 5px 0 12px; }
  .hero-art { margin-block-start: 0; }
  .hero-art img { max-height: 62vh; width: auto; max-width: 100%; margin-inline: auto; }
}

/* Fern Academy — entradas DESTACADAS en el inicio (v3.8, corrección de
   Kevin: como filas planas nadie veía que eran clicables). Tarjetas grandes
   con icono, borde verde claro y sello NUEVO/NEW. Los !important vencen los
   estilos en línea que pone el launcher. */
#fern-academia-entry {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 10px !important;
  margin: 2px 0 16px !important;
}
#fern-academia-entry::before {
  content: "ใหม่";
  align-self: flex-start;
  background: var(--green); color: var(--button-ink);
  font-size: 12px; font-weight: 800; letter-spacing: .04em;
  padding: 3px 10px; border-radius: 999px;
}
html[lang="en"] #fern-academia-entry::before { content: "NEW"; }
#fern-academia-entry a {
  width: 100%; min-height: 64px !important;
  padding: 12px 16px !important;
  background: rgba(201, 239, 185, .12);
  border: 1.5px solid rgba(201, 239, 185, .5);
  border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 12px 28px rgba(0, 0, 0, .35);
  text-decoration: none; color: var(--ink);
  font-size: 17px; gap: 12px;
}
#fern-academia-entry a:active { transform: scale(.98); }
#fern-academia-entry a[href*="#home"]::before { content: "📚"; font-size: 26px; line-height: 1; }
#fern-academia-entry a[href*="#games"]::before { content: "🎮"; font-size: 26px; line-height: 1; }
#fern-academia-entry a::after {
  content: ""; flex: 0 0 9px; height: 9px; margin-inline-start: auto;
  transform: rotate(-45deg); border-block-end: 2px solid var(--green);
  border-inline-end: 2px solid var(--green);
}
