/*
  LEER · SISTEMA DE DISEÑO V3
  Hoja completa. No importa otros estilos, no redefine frameworks ni utiliza parches.
  Orden: tokens → base → estructura → lector → aprendizaje → biblioteca → contenido → modos → responsive.
*/

/* 01 — Design tokens */
:root {
  color-scheme: light;
  --page: #fbfaf7;
  --surface: #fffefa;
  --side: #f3f4ee;
  --text: #26362d;
  --ink: #1b2d24;
  --muted: #576b5e;
  --quiet: #647669;
  --accent: #265943;
  --accent-strong: #194735;
  --accent-tint: #e8f0e8;
  --accent-contrast: #ffffff;
  --border: #dce3da;
  --border-strong: #becdc1;
  --focus: #458e66;
  --positive: #245f43;
  --positive-tint: #e7f2e9;
  --negative: #a2382f;
  --negative-tint: #fff1ed;
  --shadow-menu: 0 12px 44px rgb(23 46 31 / 14%);
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --serif: "Iowan Old Style", "Baskerville", "Palatino Linotype", Palatino, Georgia, serif;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-width: 220px;
  --reader-width: 680px;
  --content-width: 920px;
  --nav-mobile-height: 66px;
}

/* 02 — Baseline and accessibility */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 280px; background: var(--page); color: var(--text); font: 400 16px/1.65 var(--sans); }
body [hidden] { display: none; }
:where(h1,h2,h3,h4,p,figure,blockquote,ul,ol) { margin-top: 0; }
:where(h1,h2,h3,h4) { color: var(--ink); line-height: 1.2; }
:where(p,li) { overflow-wrap: break-word; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { opacity: .55; cursor: not-allowed; }
:where(a,button,input,select,textarea,summary):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
img,svg { max-width: 100%; }
img { height: auto; }
fieldset { min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 150; top: -150px; left: 16px; padding: 9px 14px; border-radius: var(--radius-sm); color: #fff; background: var(--accent); }
.skip-link:focus { top: 12px; color: #fff; }
.ui-icon { display: inline-block; vertical-align: middle; flex: none; }
.app-section-label, .finish-mini, .side-small, .sidebar-caption, .settings-caption, .reader-quiz summary small {
  font-size: 11px; line-height: 1.45; font-weight: 750; letter-spacing: .095em; text-transform: uppercase; color: var(--muted);
}

/* 03 — Persistent application shell */
.app-layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0,1fr); min-height: 100svh; }
.app-sidebar {
  position: sticky; top: 0; align-self: start; display: flex; flex-direction: column;
  height: 100svh; padding: 28px 18px 24px; background: var(--side);
  border-right: 1px solid var(--border); z-index: 20;
}
.app-logo { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; margin: 0 0 0 10px; color: var(--ink); }
.app-logo:hover { color: var(--ink); }
.logo-square, .mobile-logo-square { display: grid; place-items: center; background: var(--accent); color: #fff; border-radius: 11px; }
.logo-square { width: 38px; height: 38px; }
.logo-word { font-size: 26px; line-height: 1; font-weight: 790; letter-spacing: -.065em; }
.logo-stop, .footer-brand span, .app-mobile-logo strong span { color: #7aa58a; }
.sidebar-caption { margin: 64px 0 12px 14px; }
.app-primary-nav { display: grid; gap: 5px; }
.app-nav-link { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 13px; border-radius: var(--radius); color: var(--muted); font-size: 14px; font-weight: 640; }
.app-nav-link:hover { background: var(--accent-tint); color: var(--accent); }
.app-nav-link.is-active { background: #e1ece2; color: var(--accent-strong); font-weight: 740; }
.sidebar-choose { margin-top: 52px; padding: 0 13px; }
.sidebar-choose .side-small { display: block; margin-bottom: 12px; }
.side-levels { display: flex; gap: 8px; }
.side-levels a { display: grid; place-items: center; min-width: 43px; min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; font-weight: 750; }
.side-levels a:hover { border-color: var(--border-strong); background: var(--accent-tint); }
.sidebar-bottom { margin-top: auto; padding: 0 13px; }
.sidebar-ornament { display: block; font: italic 48px/1 var(--serif); color: #87a892; }
.sidebar-bottom p { margin: 4px 0 12px; color: #3c6148; font: 400 17px/1.5 var(--serif); }
.sidebar-bottom > span:last-child { color: var(--quiet); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.app-stage { display: flex; flex-direction: column; min-width: 0; min-height: 100svh; background: var(--page); }
.app-topbar { display: flex; justify-content: flex-end; align-items: center; min-height: 54px; padding: 0 36px; border-bottom: 1px solid var(--border); }
.topbar-motto { color: var(--quiet); font-size: 12px; letter-spacing: .015em; }
.app-mobile-logo, .app-bottom-nav { display: none; }
.app-main { flex: 1; min-width: 0; width: 100%; margin-inline: auto; padding-inline: 32px; }
.app-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; max-width: 900px; width: 100%; margin: 0 auto; padding: 24px 32px 34px; border-top: 1px solid var(--border); }
.footer-brand { color: var(--ink); font-size: 18px; line-height: 1; font-weight: 800; letter-spacing: -.065em; }
.app-footer p { margin: 0; color: var(--muted); font-size: 12px; }
.app-footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 16px; }
.app-footer nav a { color: var(--muted); font-size: 12px; }
.app-footer nav a:hover { color: var(--accent-strong); text-decoration: underline; }

/* 04 — Reader layout, hierarchy, typography */
.app-reader-main { max-width: 820px; padding-bottom: 88px; }
.story-shell { width: 100%; margin: 0; padding: 0; }
.story-content { width: 100%; max-width: var(--reader-width); margin-inline: auto; padding-top: var(--s-6); }
.reader-intro { margin: 0; }
.reader-intro-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); margin-bottom: 15px; }
.reader-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 680; letter-spacing: .07em; }
.reader-current-level { display: inline-grid; place-items: center; padding: 3px 8px; min-height: 24px; border-radius: 6px; color: var(--accent); background: var(--accent-tint); font-size: 11px; font-weight: 800; letter-spacing: .025em; }
.reader-small-dot { color: #88978b; }
.quiet-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.quiet-link:hover { text-decoration: underline; }
.reader-intro h1 { max-width: 100%; margin: 0 0 5px; font: 600 clamp(40px, 4vw, 55px)/1.12 var(--serif); letter-spacing: -.035em; text-wrap: balance; }
.reader-english { margin: 0; color: var(--muted); font-size: 12px; }
.reader-controls { position: relative; margin: 17px 0 24px; padding: 0 0 11px; border-bottom: 1px solid var(--border); }
.reader-controls-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.read-control { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 7px 11px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-size: 13px; font-weight: 620; white-space: nowrap; }
.read-control:hover, .reader-settings[open] > .read-control { background: var(--accent-tint); color: var(--accent-strong); }
.reader-settings { position: relative; margin: 0; padding: 0; border: 0; background: transparent; z-index: 40; }
.reader-settings summary { list-style: none; }
.reader-settings summary::-webkit-details-marker { display: none; }
.settings-menu { position: absolute; z-index: 45; top: calc(100% + 8px); left: 0; width: min(310px, calc(100vw - 32px)); max-height: min(570px,75dvh); overflow-y: auto; padding: 17px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-menu); }
.settings-caption { display: block; margin: 0 0 8px; }
.settings-row { display: flex; gap: 8px; margin-bottom: 17px; }
.settings-row:last-child { margin-bottom: 0; }
.settings-row button, .theme-option { min-height: 44px; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f6f8f3; color: var(--accent-strong); font-size: 13px; font-weight: 650; }
.settings-row button { flex: 1; }
.theme-option { width: 100%; margin-bottom: 18px; text-align: left; }
.settings-row button:hover, .theme-option:hover { background: var(--accent-tint); }
.story-text { --reader-scale: 1; margin: 0; padding: 0; color: var(--ink); font: 400 calc(21px * var(--reader-scale))/1.78 var(--serif); letter-spacing: -.012em; }
.story-text p { margin: 0 0 1.26em; color: inherit; font: inherit; letter-spacing: inherit; text-wrap: pretty; }
.story-text p:last-child { margin-bottom: 0; }
.functional-text-block { white-space: pre-line; overflow-wrap: anywhere; }
/* Un toque en cualquier palabra ofrece significado y audio; sin envolver cada token. */
.vocab-trigger { display: inline; padding: 0 1px; border: 0; border-bottom: 1px dotted #538364; border-radius: 0; background: linear-gradient(to top, #e6efe2 26%, transparent 26%); color: inherit; font: inherit; cursor: pointer; }
.vocab-trigger:hover, .vocab-trigger:focus-visible { background: #dcebdc; }
.vocab-popup {
  position: fixed; z-index: 90; top: 24px; left: 24px; width: min(348px,calc(100vw - 32px));
  max-height: min(540px,85dvh); overflow-y: auto; padding: 19px 20px 20px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-menu); background: var(--surface); color: var(--text);
}
.vocab-popup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.vocab-popup-head h2 { min-width: 0; margin: 0; color: var(--ink); font: 600 26px/1.25 var(--serif); overflow-wrap: anywhere; }
.vocab-header-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.vocab-replay, .vocab-close { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); }
.vocab-replay { color: var(--accent-strong); }
.vocab-close { font-size: 26px; line-height: 1; }
.vocab-replay:hover, .vocab-close:hover { background: var(--accent-tint); color: var(--ink); }
.vocab-replay:disabled { opacity: .45; cursor: default; }
.vocab-meaning { margin: 7px 0 11px; color: var(--accent-strong); font-size: 16px; line-height: 1.5; }
.vocab-example { margin: 12px 0 4px; padding: 0 0 0 12px; border-left: 2px solid var(--border-strong); color: var(--muted); font: 400 15px/1.6 var(--serif); }
.vocab-context-actions { margin: 7px 0 0; }
.vocab-sentence-link { display: inline-flex; align-items: center; min-height: 40px; padding: 7px 0; border: 0; background: transparent; color: var(--accent-strong); font-size: 13px; font-weight: 650; }
.vocab-sentence-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.vocab-sentence-link:disabled { opacity: .45; cursor: default; }
.selection-action { position: fixed; z-index: 89; top: 12px; left: 12px; min-height: 44px; max-width: calc(100vw - 24px); padding: 9px 13px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-menu); color: var(--accent-strong); font-size: 13px; font-weight: 680; }
.selection-action:hover { background: var(--accent-tint); }
.voice-preferences { display: grid; gap: 7px; padding-top: 2px; }
.voice-preferences .settings-caption:not(:first-child) { margin-top: 7px; }
.voice-choice { display: block; width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 13px; }
.settings-hint { margin: 15px 0 0; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1.55; }
.scroll-indicator { position: fixed; z-index: 55; top: 0; right: 0; left: var(--sidebar-width); height: 3px; pointer-events: none; }
.scroll-indicator span { display: block; width: 0; height: 100%; background: #6b9b7a; }

/* 05 — Common buttons and feedback */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent); color: var(--accent-contrast); font-size: 14px; line-height: 1.3; font-weight: 710; text-align: center; }
.btn:hover { border-color: var(--accent-strong); background: var(--accent-strong); color: #fff; }
.btn.secondary, .btn.ghost { border-color: var(--border-strong); background: var(--surface); color: var(--accent-strong); }
.btn.secondary:hover, .btn.ghost:hover { background: var(--accent-tint); }
.btns, .reading-actions, .finished-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.notice { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--accent-tint); color: var(--text); font-size: 14px; }
.no-results { color: var(--muted); font-size: 14px; }
.danger-action { color: var(--negative); border-color: #dfbbb5; background: #fff8f6; }
.danger-action:hover { color: #fff; border-color: var(--negative); background: var(--negative); }

/* 06 — After reading: one optional comprehension quiz */
.reader-finished { margin: var(--s-7) 0 var(--s-4); padding: 28px 30px; border: 1px solid #d4e4d5; border-radius: var(--radius-lg); background: var(--accent-tint); }
.finished-copy { margin-bottom: 19px; }
.finished-copy h2 { margin: 8px 0 8px; font: 600 27px/1.22 var(--serif); letter-spacing: -.025em; }
.finished-copy p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.reader-to-quiz { margin-top: 14px; }
.reader-finished .notice { margin: 0 0 14px; background: var(--surface); }
.reader-quiz { margin: 12px 0 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.reader-quiz > summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 91px; padding: 18px 24px; list-style: none; cursor: pointer; }
.reader-quiz > summary::-webkit-details-marker { display: none; }
.reader-quiz summary strong { display: block; margin: 4px 0 3px; color: var(--ink); font: 600 23px/1.3 var(--serif); letter-spacing: -.018em; }
.reader-quiz summary em { display: block; color: var(--muted); font-size: 13px; font-style: normal; font-weight: 400; letter-spacing: 0; }
.extra-plus { font: 300 29px/1 var(--sans); color: var(--accent); transition: transform .18s ease; }
.reader-quiz[open] .extra-plus { transform: rotate(45deg); }
.reader-quiz[open] > summary { border-bottom: 1px solid var(--border); }
.reader-quiz > :not(summary) { margin: 0; }
.reader-quiz .quiz-box { border: 0; border-radius: 0; background: transparent; margin: 0; padding: 20px 24px 26px; }
.reader-quiz .quiz-box > h2 { margin: 0 0 16px; font-size: 18px; }
.support { margin: 16px 0; padding: 22px 24px; border: 1px solid var(--border); border-radius: var(--radius); background: #f2f7f1; }
.support[hidden] { display: none; }
.support h2 { margin: 0 0 12px; font-size: 20px; }
.support p { margin: 0 0 11px; font-size: 15px; line-height: 1.75; }
.support p:last-child { margin-bottom: 0; }
.quiz-box { margin: 16px 0; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.quiz-box h2 { margin: 0 0 12px; font-size: 21px; }
.quiz-box form { width: 100%; }
.question { margin: 0; padding: 23px 0; border: 0; border-top: 1px solid var(--border); }
.question legend { display: table; width: 100%; padding: 0 0 12px; color: var(--ink); font-size: 16px; line-height: 1.5; font-weight: 720; }
.options { display: grid; gap: 9px; }
.option { display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.5; cursor: pointer; }
.option:hover, .option:has(input:checked) { border-color: #82ae8a; background: #f0f7ef; }
.option input { flex: none; margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--accent); }
.option.correct { border-color: #6aa77e; background: var(--positive-tint); color: var(--positive); }
.option.wrong { border-color: #df988d; background: var(--negative-tint); color: var(--negative); }
.answer-feedback { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-tint); color: var(--text); font-size: 14px; line-height: 1.6; }
.quiz-result { min-height: 24px; margin: 18px 0 0; color: var(--ink); font-size: 15px; font-weight: 740; }
.app-next-stories { margin-top: var(--s-7); padding-top: 30px; border-top: 1px solid var(--border); }
.app-next-stories h2 { margin: 0 0 16px; font: 600 27px/1.25 var(--serif); }
.app-next-stories .grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.app-next-stories .card { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.app-next-stories .card strong { color: var(--ink); font-size: 15px; }
.app-next-stories .card p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

/* 07 — Minimal home: invitation to read, no reader embedded */
.app-home-main { max-width: 920px; padding-top: clamp(44px,7vh,92px); padding-bottom: 86px; }
.welcome { max-width: 720px; padding-bottom: 68px; }
.welcome-eyebrow { margin: 0 0 19px; color: var(--accent); font-size: 11px; line-height: 1.4; letter-spacing: .13em; font-weight: 750; }
.welcome h1 { margin: 0 0 21px; color: var(--ink); font: 560 clamp(44px,5.15vw,69px)/1.12 var(--serif); letter-spacing: -.037em; text-wrap: balance; }
.welcome h1 em { font-style: normal; color: var(--accent); }
.welcome-lead { max-width: 530px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.78; }
.welcome-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 17px 25px; margin-top: 32px; }
.welcome-start { display: inline-flex; align-items: center; justify-content: space-between; gap: 27px; min-height: 51px; padding: 11px 20px; background: var(--accent); border: 1px solid var(--accent); border-radius: 11px; color: #fff; font-size: 14px; font-weight: 740; }
.welcome-start:hover { background: var(--accent-strong); color: #fff; }
.welcome-continue { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border-strong); font-size: 14px; font-weight: 660; }
.welcome-continue[hidden] { display: none; }
.welcome-levels { border-top: 1px solid var(--border); }
.welcome-section-top { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin: 31px 0 19px; }
.welcome-section-top h2 { margin: 0; font: 570 27px/1.3 var(--serif); }
.welcome-section-top > a { color: var(--muted); font-size: 12px; text-decoration: underline; }
.welcome-level-list { border-top: 1px solid var(--border); }
.welcome-level { display: grid; align-items: center; grid-template-columns: 57px minmax(0,1fr) 22px; gap: 19px; min-height: 106px; padding: 19px 8px; border-bottom: 1px solid var(--border); color: var(--ink); }
.welcome-level:hover { background: var(--accent-tint); color: var(--ink); }
.welcome-level-mark { font: 570 32px/1 var(--serif); color: var(--accent); letter-spacing: -.04em; }
.welcome-level-body { display: flex; flex-direction: column; gap: 4px; }
.welcome-level-body strong { color: var(--ink); font-size: 15px; font-weight: 680; }
.welcome-level-body small { color: var(--muted); font-size: 13px; line-height: 1.5; }
.welcome-level-arrow { color: var(--accent); font-size: 19px; }
.welcome-pick { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px 30px; margin-top: 56px; padding: 28px 0 32px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.welcome-pick .welcome-eyebrow { margin-bottom: 11px; }
.welcome-pick h2 { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0 0 8px; color: var(--ink); font: 570 28px/1.3 var(--serif); }
.welcome-pick h2 span { color: var(--muted); font: 550 12px/1.4 var(--sans); }
.welcome-pick p:not(.welcome-eyebrow) { margin: 0; max-width: 480px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.welcome-pick > a { display: inline-flex; flex: none; align-items: center; gap: 14px; min-height: 44px; font-size: 13px; font-weight: 700; }
.welcome-footnote { margin: 20px 0 0; color: var(--quiet); font-size: 12px; line-height: 1.7; }
.welcome-footnote a { text-decoration: underline; }

/* 08 — Library and reading lists */
.app-list-main { max-width: 1030px; padding-top: var(--s-7); padding-bottom: 96px; }
.app-list-intro { margin-bottom: 28px; }
.app-list-intro h1 { margin: 8px 0 12px; font: 600 clamp(38px,4vw,53px)/1.16 var(--serif); letter-spacing: -.035em; }
.app-list-intro h1 span, .punctuation { color: #608a6b; }
.app-list-intro p { max-width: 680px; margin: 0; color: var(--muted); font-size: 15px; }
.app-filter-controls { margin-bottom: 20px; }
.app-library-tools { display: flex; align-items: center; gap: 12px; }
.app-search { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; min-height: 48px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--muted); }
.app-search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.app-search input { min-width: 0; width: 100%; height: 46px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.app-search input::placeholder { color: var(--muted); opacity: .8; }
.app-filter-bar { display: flex; gap: 9px; }
.select-wrap { position: relative; display: flex; align-items: center; min-width: 132px; height: 48px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.select-wrap select { appearance: none; width: 100%; height: 100%; min-width: 0; padding: 0 34px 0 12px; border: 0; border-radius: inherit; background: transparent; color: var(--text); font-size: 13px; font-weight: 650; }
.select-wrap .ui-icon { position: absolute; right: 11px; pointer-events: none; color: var(--muted); }
.app-library-chips { display: flex; gap: 8px; margin-top: 16px; padding: 2px 0 7px; overflow-x: auto; scrollbar-width: thin; }
.app-library-chips button { flex: none; min-height: 44px; padding: 8px 15px; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 660; white-space: nowrap; }
.app-library-chips button span { font-size: 12px; font-weight: 400; }
.app-library-chips button:hover, .app-library-chips button.is-active { border-color: #a5c3aa; color: var(--accent-strong); background: var(--accent-tint); }
.app-library-counter { min-height: 28px; margin-bottom: 6px; }
.app-library-counter p { margin: 0; color: var(--muted); font-size: 12px; }
.app-story-list { border-top: 1px solid var(--border); }
.app-story-item { position: relative; min-width: 0; border-bottom: 1px solid var(--border); }
.app-story-link { display: grid; grid-template-columns: 38px minmax(0,1fr) 36px; align-items: center; gap: 18px; min-height: 120px; padding: 20px 10px 20px 4px; color: var(--text); }
.app-story-link:hover { color: var(--text); background: #f1f5ee; }
.story-number { align-self: start; margin-top: 12px; color: var(--quiet); font: 400 22px/1.3 var(--serif); }
.item-content { display: block; min-width: 0; }
.item-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.item-level { display: inline-grid; place-items: center; min-width: 30px; min-height: 24px; padding: 3px 7px; border: 1px solid #bfd5c2; border-radius: 6px; background: #e6f1e7; color: #275c3a; font-size: 11px; font-weight: 800; }
.level-a2 { background: #fff3e0; border-color: #e6cc9c; color: #7c541b; }
.level-b1 { background: #ebf0ff; border-color: #c0cdec; color: #395994; }
.item-title { display: block; margin-bottom: 5px; color: var(--ink); font: 600 clamp(21px,2vw,25px)/1.25 var(--serif); letter-spacing: -.018em; }
.item-desc { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; max-width: 630px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.item-arrow { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; background: var(--accent-tint); color: var(--accent); }
.app-story-item .completed-badge { position: absolute; top: 11px; right: 54px; padding: 3px 8px; border-radius: 6px; background: var(--positive-tint); color: var(--positive); font-size: 11px; }
.app-showmore-wrap { padding: 24px 0; text-align: center; }
.library-seo { max-width: 690px; margin-top: 35px; padding-top: 30px; border-top: 1px solid var(--border); }
.library-seo h2 { font: 600 23px/1.3 var(--serif); }
.library-seo p { color: var(--muted); font-size: 14px; }
.more-learning { margin: 32px 0; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.more-learning summary { font-size: 14px; color: var(--accent-strong); font-weight: 650; }
.more-learning-content { padding-top: 16px; }
.more-learning-content .section { padding: 22px 0; }

/* 09 — Search landing pages, guides, progress and information */
.app-content-main, .app-dashboard-main { max-width: var(--content-width); padding-top: 38px; padding-bottom: 92px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.hero { padding: 16px 0 30px; border-bottom: 1px solid var(--border); }
.hero h1 { max-width: 790px; margin: 10px 0 16px; color: var(--ink); font: 600 clamp(37px,4vw,50px)/1.16 var(--serif); letter-spacing: -.025em; text-wrap: balance; }
.hero .lead { max-width: 750px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.hero-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(240px,300px); align-items: start; gap: 30px; }
.hero-card { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.hero-card p { font-size: 14px; }
.eyebrow { display: block; color: var(--accent); font-size: 12px; font-weight: 770; letter-spacing: .06em; text-transform: uppercase; }
.lead { color: var(--muted); font-size: 17px; }
.section { padding: var(--s-6) 0; border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: 0; }
.section h2 { margin: 0 0 18px; color: var(--ink); font: 600 29px/1.27 var(--serif); }
.section h3 { margin: 0 0 9px; color: var(--ink); font-size: 18px; }
.section h4 { margin: 16px 0 7px; font-size: 16px; }
.section p { max-width: 72ch; margin: 0 0 13px; font-size: 15px; line-height: 1.8; }
.section li { margin-bottom: 9px; font-size: 15px; line-height: 1.75; }
.section a:not(.btn) { text-decoration: underline; text-decoration-color: #afc8b5; }
.section ul, .section ol { padding-left: 24px; }
.grid { display: grid; gap: 14px; }
.grid.two, .grid.cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.card, .day { position: relative; display: block; min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.card:hover { border-color: var(--border-strong); background: #f6f9f4; }
.card h2, .card h3 { margin: 0 0 9px; font: 600 20px/1.35 var(--sans); }
.card h3 a { color: var(--ink); }
.card p { margin: 6px 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.card .eyebrow { margin: 0 0 9px; font-size: 11px; }
.card strong { color: var(--ink); }
.story-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.story-card { min-height: 165px; }
.story-card .completed-badge { display: inline-block; margin-bottom: 10px; border-radius: 6px; padding: 3px 8px; color: var(--positive); background: var(--positive-tint); font-size: 11px; }
.story-card h3 { margin: 6px 0 9px; }
.story-card p { line-height: 1.6; }
.route { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 24px 0; }
.day .tag { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.day h3 { margin: 0 0 8px; font-size: 18px; }
.day p { margin: 0; font-size: 14px; }
.day.done { background: var(--positive-tint); }
.day.done::after { content: "Leído"; position: absolute; top: 11px; right: 11px; font-size: 11px; font-weight: 730; color: var(--positive); }
.toc, .section details, .more-learning-content details { margin: 14px 0; padding: 17px 19px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.section details > summary { line-height: 1.5; }
.section details p { margin-top: 13px; }
.check-list { padding-left: 24px; }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.content-table { width: 100%; min-width: 450px; border-collapse: collapse; font-size: 14px; }
.content-table :is(th,td) { padding: 13px 15px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.content-table th { color: var(--ink); background: var(--accent-tint); font-weight: 740; }
.content-table tr:last-child td { border-bottom: 0; }
.guide-section, .topic-exercise { scroll-margin-top: 30px; }
/* Progress dashboard — quiet hierarchy, readable metrics and generous section rhythm */
.app-dashboard-main { max-width: 880px; padding-top: 56px; padding-bottom: 104px; }
.page-legal .app-content-main { max-width: 800px; }
.page-legal .app-content-main h1 { font-size: clamp(36px,4vw,48px); }

/* 10 — Theme variants: reading surface only, navigation remains stable */
body[data-reading-theme="white"] { --page: #ffffff; --surface: #ffffff; }
body[data-reading-theme="night"] {
  --page: #1a2721; --surface: #26382d; --ink: #f2efe6; --text: #e7e8db;
  --muted: #c0cbbd; --quiet: #b5c3b4; --accent: #aed6b8;
  --accent-strong: #cbe6cd; --accent-tint: #304438; --accent-contrast: #13241a;
  --border: #415448; --border-strong: #5d7765; --focus: #96d7ad;
  --positive: #b6e9c0; --positive-tint: #30483a;
}
body[data-reading-theme="night"] .app-sidebar { background: #f3f4ee; border-color: #dce3da; }
body[data-reading-theme="night"] .app-sidebar :is(.app-logo,.app-nav-link,.side-levels a) { color: #265943; }
body[data-reading-theme="night"] .app-nav-link.is-active { color: #194735; }
body[data-reading-theme="night"] .app-sidebar .side-levels a { background: #fffefa; border-color: #dce3da; }
body[data-reading-theme="night"] .app-sidebar .sidebar-caption,body[data-reading-theme="night"] .app-sidebar .side-small { color: #576b5e; }
body[data-reading-theme="night"] .app-sidebar .sidebar-bottom p { color: #3c6148; }
body[data-reading-theme="night"] .app-sidebar .sidebar-bottom > span:last-child { color: #576b5e; }
body[data-reading-theme="night"] .app-sidebar .logo-square { color: #fff; background: #265943; }
body[data-reading-theme="night"] .read-control:hover { background: #304438; }
body[data-reading-theme="night"] .vocab-trigger { background: none; border-color: #a5d6a7; color: inherit; }
body[data-reading-theme="night"] .vocab-trigger:hover { background: #385842; }
body[data-reading-theme="night"] .btn { color: #13241a; }
body[data-reading-theme="night"] .btn.secondary { color: #e7e8db; }
body[data-reading-theme="night"] .option:hover,body[data-reading-theme="night"] .option:has(input:checked) { background: #38533e; }
body[data-reading-theme="night"] .app-bottom-nav { background: #1a2721; }

/* 11 — Concentration mode. Exit control stays visible. */
body.reading-mode .app-layout { grid-template-columns: minmax(0,1fr); }
body.reading-mode :is(.app-sidebar,.app-topbar,.app-bottom-nav,.app-footer,.reader-intro-top,.reader-english,.reader-finished,.reader-quiz,.app-next-stories) { display: none; }
body.reading-mode .app-stage { min-height: 100svh; padding-bottom: 0; }
body.reading-mode .story-content { padding-top: 26px; }
body.reading-mode .reader-intro h1 { font-size: clamp(31px,3.5vw,44px); margin-bottom: 12px; }
body.reading-mode .reader-controls { position: sticky; z-index: 60; top: 0; display: flex; justify-content: flex-end; margin: 0 0 23px; padding: 7px 0; border: 0; background: var(--page); }
body.reading-mode .reader-settings { display: none; }
body.reading-mode .scroll-indicator { left: 0; }

/* 12 — Narrow desktop: navigation becomes a rail */
@media (max-width: 1050px) and (min-width: 701px) {
  :root { --sidebar-width: 76px; }
  .app-sidebar { align-items: center; padding: 22px 8px; }
  .app-logo { margin: 0; }
  .app-sidebar :is(.logo-word,.sidebar-caption,.app-primary-nav span,.sidebar-choose,.sidebar-bottom) { display: none; }
  .app-primary-nav { width: 100%; margin-top: 54px; }
  .app-nav-link { justify-content: center; padding: 10px 0; }
  .hero-grid { grid-template-columns: 1fr; }
}

/* 13 — Handheld app: reading takes nearly the entire width */
@media (max-width: 700px) {
  html { scroll-padding-top: 72px; }
  .app-layout { display: block; }
  .app-sidebar { display: none; }
  .app-stage { min-height: 100svh; padding-bottom: calc(var(--nav-mobile-height) + env(safe-area-inset-bottom)); }
  .app-topbar { position: relative; justify-content: space-between; min-height: 54px; padding: 0 20px; }
  .app-mobile-logo { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); }
  .mobile-logo-square { width: 30px; height: 30px; border-radius: 9px; }
  .app-mobile-logo strong { font-size: 21px; line-height: 1; font-weight: 780; letter-spacing: -.07em; }
  .topbar-motto { font-size: 11px; }
  .app-bottom-nav {
    position: fixed; z-index: 80; right: 0; bottom: 0; left: 0;
    display: flex; align-items: stretch; justify-content: space-around;
    min-height: calc(var(--nav-mobile-height) + env(safe-area-inset-bottom));
    padding: 5px max(8px,env(safe-area-inset-left)) calc(5px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-right));
    border-top: 1px solid var(--border); background: var(--page);
  }
  .app-bottom-link { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; min-height: 52px; border-radius: var(--radius-sm); color: var(--muted); font-size: 11px; font-weight: 660; }
  .app-bottom-link.is-active { color: var(--accent); }
  .app-bottom-link:hover { background: var(--accent-tint); }
  .app-main { padding-inline: clamp(18px,5.1vw,24px); }
  .app-reader-main { padding-bottom: 60px; }
  .story-content { padding-top: 24px; }
  .reader-intro-top { align-items: flex-start; gap: 8px; margin-bottom: 15px; }
  .reader-kicker { gap: 6px; font-size: 10px; letter-spacing: .03em; }
  .reader-kicker > span:nth-last-child(-n+2) { display: none; }
  .quiet-link { font-size: 11px; }
  .reader-change svg { width: 14px; }
  .reader-intro h1 { font-size: clamp(35px,9.3vw,43px); letter-spacing: -.03em; line-height: 1.14; }
  .reader-english { font-size: 11px; }
  .reader-controls { margin: 12px 0 20px; padding-bottom: 9px; }
  .reader-controls-main { justify-content: space-between; gap: 2px; }
  .read-control { min-height: 44px; padding: 8px 7px; gap: 5px; font-size: 12px; }
  .read-control .ui-icon { width: 18px; height: 18px; }
  .settings-menu { position: fixed; top: auto; right: 16px; bottom: calc(var(--nav-mobile-height) + env(safe-area-inset-bottom) + 12px); left: 16px; width: auto; max-height: calc(100dvh - var(--nav-mobile-height) - env(safe-area-inset-bottom) - 40px); transform: none; }
  body.reading-mode .settings-menu { bottom: 18px; }
  .story-text { font-size: calc(20px * var(--reader-scale)); line-height: 1.75; letter-spacing: -.012em; }
  .story-text p { margin-bottom: 1.22em; }
  .reader-finished { margin-top: 39px; padding: 23px 20px; }
  .finished-copy h2 { font-size: 25px; }
  .reading-actions, .finished-actions { align-items: stretch; flex-direction: column; }
  .reader-finished .btn { width: 100%; }
  .reader-to-quiz { width: 100%; }
  .reader-quiz > summary { padding: 16px 18px; min-height: 82px; }
  .reader-quiz summary strong { font-size: 21px; }
  .reader-quiz summary em { font-size: 12px; }
  .reader-quiz .quiz-box { padding: 17px 18px 24px; }
  .question { padding: 19px 0; }
  .question legend { font-size: 15px; }
  .option { padding: 12px; font-size: 14px; }
  .app-next-stories .grid { grid-template-columns: 1fr; }
  .vocab-popup { top: auto; right: 14px; bottom: calc(var(--nav-mobile-height) + env(safe-area-inset-bottom) + 12px); left: 14px; width: auto; max-height: calc(100dvh - var(--nav-mobile-height) - env(safe-area-inset-bottom) - 46px); padding: 17px 18px; }
  body.reading-mode .vocab-popup { bottom: 18px; }
  .selection-action { top: auto; right: 16px; bottom: calc(var(--nav-mobile-height) + env(safe-area-inset-bottom) + 12px); left: auto; }
  body.reading-mode .selection-action { bottom: 18px; }
  .scroll-indicator { left: 0; }
  .app-home-main { padding-top: 49px; padding-bottom: 56px; }
  .welcome { padding-bottom: 51px; }
  .welcome h1 { font-size: clamp(40px,9vw,53px); }
  .welcome-lead { font-size: 15px; line-height: 1.7; }
  .welcome-section-top { margin-top: 26px; }
  .welcome-level { grid-template-columns: 48px minmax(0,1fr) 18px; gap: 13px; min-height: 98px; padding: 16px 4px; }
  .welcome-level-mark { font-size: 27px; }
  .welcome-pick { align-items: flex-start; flex-direction: column; gap: 12px; margin-top: 44px; }
  .welcome-pick h2 { font-size: 25px; }
  .app-list-main { padding-top: 33px; padding-bottom: 70px; }
  .app-list-intro { margin-bottom: 24px; }
  .app-list-intro h1 { font-size: 38px; }
  .app-list-intro p { font-size: 14px; }
  .app-library-tools { align-items: stretch; flex-direction: column; gap: 9px; }
  .app-filter-bar { display: flex; gap: 9px; }
  .select-wrap { flex: 1; min-width: 0; }
  .app-library-chips { margin-top: 12px; }
  .app-library-chips button { min-height: 44px; padding: 8px 12px; }
  .app-story-link { grid-template-columns: 27px minmax(0,1fr) 28px; gap: 10px; min-height: 108px; padding: 17px 4px 17px 0; }
  .story-number { margin-top: 11px; font-size: 18px; }
  .item-title { font-size: 22px; }
  .item-desc { font-size: 12px; }
  .item-tags { font-size: 11px; gap: 5px; }
  .item-arrow { width: 28px; height: 28px; }
  .item-arrow svg { width: 16px; height: 16px; }
  .app-story-item .completed-badge { top: 6px; right: 37px; }
  .app-content-main { padding-top: 26px; padding-bottom: 66px; }
  .app-dashboard-main { padding-top: 38px; padding-bottom: 76px; }
  .hero { padding: 12px 0 26px; }
  .hero h1 { font-size: 37px; }
  .hero .lead { font-size: 15px; }
  .section { padding: 29px 0; }
  .section h2 { font-size: 26px; }
  .section p { font-size: 15px; }
  .grid.two, .grid.three, .grid.cards, .story-list, .route, .hero-grid { grid-template-columns: 1fr; }
  .card, .day { padding: 18px; }
  .app-footer { padding: 22px 20px 25px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .app-footer nav { justify-content: flex-start; gap: 8px 14px; }
  body.reading-mode .story-content { padding-top: 18px; }
  body.reading-mode .reader-controls { padding: 6px 0; }
}

@media (max-width: 370px) {
  .app-main { padding-inline: 16px; }
  .reader-intro h1 { font-size: 34px; }
  .topbar-motto { font-size: 10px; }
  .reader-kicker { font-size: 10px; }
  .reader-change { font-size: 10px; }
  .read-control { font-size: 11px; padding-inline: 5px; }
  .story-text { font-size: calc(19px * var(--reader-scale)); }
  .welcome h1 { font-size: 39px; }
}

/* 14 — User preferences and non-visual media */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms; transition-duration: .01ms; }
}
@media print {
  body { background: #fff; color: #000; }
  .app-layout { display: block; }
  .app-sidebar, .app-topbar, .app-bottom-nav, .app-footer, .reader-controls, .reader-finished, .reader-quiz, .app-next-stories, .scroll-indicator, .welcome-levels, .welcome-pick { display: none; }
  .app-main, .story-content { max-width: none; margin: 0; padding: 0; }
  .story-text { font-size: 13pt; line-height: 1.6; }
  .vocab-trigger { border: 0; background: transparent; }
}


/* Letruna brand */
.logo-accent { color: var(--accent-soft); }
.footer-brand { letter-spacing: -0.04em; }
.footer-brand span, .app-mobile-logo strong span { color: var(--accent-soft); }


/* Letruna branding */
.app-logo { margin-left: 0; }
.brand-wordmark { display: block; width: 176px; height: auto; }
.brand-mobile-icon { width: 22px; height: 22px; display: block; }
.footer-brandmark { display: block; width: 156px; height: auto; }
.app-mobile-logo strong { font-size: 1.06rem; line-height: 1; font-weight: 760; letter-spacing: -0.04em; color: var(--ink); }
.app-mobile-logo { gap: 10px; }
.app-logo .logo-word, .app-logo .logo-square, .app-mobile-logo .mobile-logo-square { display: none; }
.footer-brand { display: block; }
.footer-brand span { color: inherit; }
@media (max-width: 700px) {
  .brand-wordmark { width: 160px; }
  .footer-brandmark { width: 144px; }
}
