@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');

:root {
  --ink: #20283b;
  --muted: #626b7e;
  --paper: #ffffff;
  --paper-warm: #f5f5f5;
  --blue: #263d80;
  --blue-dark: #192d69;
  --blue-pale: #e9eefb;
  --accent: #bb685b;
  --accent-pale: #f8e9e3;
  --line: rgba(32, 45, 82, .11);
  --sans: 'DM Sans', 'Noto Sans SC', 'Noto Sans Arabic', system-ui, sans-serif;
  --serif: 'Playfair Display', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: #111a32; }
body {
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background: #111a32;
  overflow: hidden;
}
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:where(button, a, [tabindex]):focus-visible { outline: 3px solid rgba(38, 61, 128, .42); outline-offset: 3px; }

.app-shell {
  position: relative;
  width: min(100vw, calc((100dvh - 24px) * 9 / 19.5));
  height: min(100dvh, calc(100vw * 19.5 / 9));
  max-width: 440px;
  max-height: 954px;
  margin: auto;
  top: 50dvh;
  transform: translateY(-50%);
  overflow: hidden;
  border-radius: 34px;
  background: var(--paper);
  border: 1px solid rgba(255,255,255,.12);
}

.topbar {
  position: absolute;
  inset: 0 0 auto;
  height: 76px;
  padding: max(14px, env(safe-area-inset-top)) 15px 8px;
  display: flex;
  align-items: center;
  z-index: 12;
  color: var(--ink);
  background: #ffffff;
}
.icon-button, .language-button, .close-button { border: 0; cursor: pointer; }
.icon-button {
  width: 42px; height: 42px; padding: 11px;
  display: grid; align-content: center; gap: 5px;
  border-radius: 14px; background: #ffffff;
  outline: 1px solid var(--line);
}
.icon-button span { display: block; width: 20px; height: 1.6px; border-radius: 3px; background: var(--ink); }
.language-button {
  margin-inline-start: auto; display: flex; align-items: center; gap: 6px;
  color: var(--ink); padding: 9px 11px; border: 1px solid rgba(32,45,82,.08);
  border-radius: 14px; white-space: nowrap; background: #ffffff;
  font-size: 12px; font-weight: 600;
}
.language-button .language-flag { display: block; width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.chevron { display: block; width: 12px; height: 12px; flex-shrink: 0; color: var(--muted); }
.home-button {
  margin-inline-start: 8px; padding: 9px 11px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 14px; color: var(--blue); background: #fff;
  font-size: 12px; font-weight: 700; text-decoration: none; transition: background .18s, border-color .18s;
}
.home-button:hover { background: var(--blue-pale); border-color: rgba(38,61,128,.22); }
.home-button svg { flex-shrink: 0; }

.reader { position: relative; height: 100%; }
.book-stage { height: 100%; width: 100%; }
.page {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  background: #ffffff;
  overflow: hidden;
  transition: opacity .18s ease, transform .22s cubic-bezier(.2,.7,.2,1);
}
.page::after { content: none; }
.page.turning-next { opacity: 0; transform: translateX(-9%) scale(.985); }
.page.turning-previous { opacity: 0; transform: translateX(9%) scale(.985); }
.page-arrow { display: none; }

.reader-footer {
  position: absolute; z-index: 10; inset: auto 0 0;
  padding: 18px 21px max(12px, env(safe-area-inset-bottom));
  color: var(--ink); background: #ffffff;
  border-top: 1px solid rgba(32,45,82,.1);
}
.progress-track { height: 3px; background: rgba(32,45,82,.09); border-radius: 10px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--blue); transition: width .25s ease; }
.footer-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 9px; }
.text-button, .page-indicator { min-height: 40px; padding: 6px 8px; border-radius: 9px; color: var(--muted); background: none; border: 0; cursor: pointer; font-size: 11px; font-weight: 600; }
.text-button:hover:not(:disabled), .page-indicator:hover { color: var(--blue); background: var(--blue-pale); }
.text-button:first-child { justify-self: start; }
.text-button:last-child { justify-self: end; }
.page-indicator { letter-spacing: .12em; color: var(--ink); }
.text-button:disabled { opacity: .24; }

.page-inner {
  position: relative; z-index: 2;
  height: 100%; padding: 98px 25px 126px;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none; overscroll-behavior: contain;
}
.page-inner::-webkit-scrollbar { display: none; }
.chapter-kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .17em; font-size: 9px; font-weight: 700; }
.page h1, .page h2 { font-family: var(--serif); margin: 8px 0 9px; line-height: 1.04; letter-spacing: -.035em; text-wrap: balance; }
.page h1 { font-size: clamp(43px, 12vw, 58px); }
.page h2 { max-width: 88%; font-size: clamp(31px, 8.4vw, 40px); }
.lead { color: var(--muted); font-size: 13px; line-height: 1.66; margin: 0 0 17px; }
.guide-prose { margin: -3px 0 19px; padding: 0 2px 0 14px; border-left: 2px solid rgba(38,61,128,.18); }
.guide-prose p { margin: 0; color: #3d4558; font-family: var(--sans); font-size: 13px; line-height: 1.72; letter-spacing: -.006em; }
.spanish-inline { color: var(--accent); font-weight: 700; }

.cover-page { background: #ffffff; }
.cover-page::before { content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%; background: var(--blue); top: -146px; right: -112px; }
.cover-page::after { content: none; }
.cover-content { padding-top: 100px; }
.cover-brand { font-size: 13px; font-weight: 700; letter-spacing: .06em; }
.cover-title { margin-top: auto; position: relative; z-index: 2; }
.cover-title h1 { margin-bottom: 14px; }
.cover-title h1 span { color: var(--blue); display: block; font-style: italic; font-size: .82em; line-height: 1.02; overflow-wrap: anywhere; }
.cover-title p { color: var(--muted); font-size: 15px; max-width: 330px; line-height: 1.55; margin: 0; }
.cover-art { width: 100%; flex: 0 0 auto; margin-top: 24px; border-radius: 12px; overflow: hidden; background: #f9f2e9; border: 1px solid rgba(32,45,82,.1); }

.scene-art { width: 100%; flex: 0 0 auto; margin: 4px 0 17px; border-radius: 12px; overflow: hidden; background: #ffffff; border: 1px solid var(--line); }
.scene-art svg, .scene-art img, .cover-art svg, .cover-art img, .closing-art img { width: 100%; height: auto; display: block; }

/* P10–P11: slightly larger type for comfortable café-scene reading. */
.page-10 h2, .page-11 h2 { font-size: clamp(38px, 10vw, 46px); }
.page-10 .phrase-card { padding: 16px; }
.page-10 .phrase-card .spanish { font-size: 16px; line-height: 1.42; }
.page-10 .phrase-card .meaning { font-size: 12px; line-height: 1.52; }
.page-10 .tag { font-size: 8.5px; }
.page-11 .dialogue {
  flex: none; min-height: auto; display: grid; align-content: start;
  gap: 14px; margin: 10px 0 12px;
}
.page-11 .dialogue-row { grid-template-columns: 42px 1fr; gap: 12px; }
.page-11 .avatar { width: 42px; height: 42px; font-size: 12px; }
.page-11 .bubble { padding: 15px 16px; }
.page-11 .bubble .spanish { font-size: 15px; line-height: 1.46; }
.page-11 .bubble .meaning { font-size: 12px; line-height: 1.55; }
.page-11 .page-note { margin-top: 0; font-size: 12px; line-height: 1.65; }
.scene-art.mini { margin-bottom: 14px; }

.phrase-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.phrase-card { padding: 12px; border: 1px solid rgba(32,45,82,.08); border-radius: 16px; background: rgba(255,255,255,.86); min-width: 0;  }
.phrase-card.featured { background: var(--accent-pale); border-color: rgba(187,104,91,.2); }
.phrase-card .spanish { direction: ltr; text-align: left; font-size: 13px; font-weight: 700; line-height: 1.32; color: var(--ink); }
.phrase-card .meaning { color: var(--muted); font-size: 10px; margin-top: 5px; line-height: 1.42; }
.tag { display: inline-flex; margin-bottom: 7px; padding: 4px 7px; border-radius: 999px; font-size: 7px; text-transform: uppercase; letter-spacing: .08em; color: var(--blue-dark); background: rgba(38,61,128,.11); font-weight: 700; }
.page-note { margin-top: 13px; padding: 13px 14px; background: #faf3ee; color: #665451; border-radius: 15px; font-size: 10px; line-height: 1.58; border: 1px solid rgba(187,104,91,.16); }
.page-note strong { display: inline-block; margin-bottom: 2px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 8px; }

.dialogue { display: grid; gap: 10px; }
.dialogue-row { display: grid; grid-template-columns: 34px 1fr; gap: 9px; align-items: start; }
.avatar { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; background: var(--blue); }
.dialogue-row:nth-child(even) .avatar { background: #a65950; }
.bubble { padding: 11px 12px; border-radius: 5px 16px 16px 16px; background: rgba(255,255,255,.9); border: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere;  }
.bubble .spanish { direction: ltr; text-align: left; font-weight: 700; font-size: 12px; line-height: 1.35; }
.bubble .meaning { color: var(--muted); margin-top: 4px; font-size: 9px; line-height: 1.4; }

.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.comparison { padding: 14px; border-radius: 17px; background: #fff; border: 1px solid var(--line);  }
.comparison.natural { background: var(--accent-pale); }
.comparison strong { display: block; color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.comparison .spanish { direction: ltr; text-align: left; font-weight: 700; font-size: 12px; }
.comparison p { color: var(--muted); font-size: 9px; line-height: 1.5; margin: 7px 0 0; }

.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; margin-top: 7px; }
.guide-card { padding: 16px 14px; border-radius: 18px; background: rgba(255,255,255,.88); border: 1px solid var(--line); }
.guide-card i { width: 34px; height: 34px; border-radius: 12px; background: var(--blue-pale); color: var(--blue); display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 11px; margin-bottom: 11px; }
.guide-card:nth-child(4n + 2) i { background: #f8e9e3; color: #ad5c52; }
.guide-card:nth-child(4n + 3) i { background: #f7eddd; color: #9d6b3a; }
.guide-card:nth-child(4n + 4) i { background: #e6f0ef; color: #3c7773; }
.guide-card h3 { margin: 0 0 5px; font-size: 12px; }
.guide-card p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.52; }

/* Opening page: a single reading path, not a four-card dashboard. */
.learning-path { display: grid; gap: 9px; margin-top: 5px; }
.path-step { position: relative; min-height: 67px; display: grid; grid-template-columns: 45px minmax(0, 1fr); gap: 13px; align-items: center; padding: 12px 14px 12px 11px; border: 1px solid var(--line); border-radius: 17px; background: #ffffff; }
.path-step::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; border-radius: 17px 0 0 17px; background: var(--blue); }
.path-marker { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--blue-pale); color: var(--blue); font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.path-copy h3 { margin: 0 0 3px; font-size: 13px; line-height: 1.25; }
.path-copy p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.path-step:nth-child(2)::before { background: var(--accent); }
.path-step:nth-child(2) .path-marker { background: var(--accent-pale); color: var(--accent); }
.path-step:nth-child(3)::before { background: #ac793e; }
.path-step:nth-child(3) .path-marker { background: #f8efdf; color: #9a6936; }
.path-step:nth-child(4)::before { background: #3f7b78; }
.path-step:nth-child(4) .path-marker { background: #e8f1f0; color: #3f7b78; }
.path-line { position: absolute; width: 1px; height: 10px; left: 30px; bottom: -11px; background: rgba(32,45,82,.18); z-index: 1; }

/* P03: compact editorial reading key instead of four identical cards. */
.editorial-guide { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 4px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.editorial-guide::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--line); }
.editorial-item { position: relative; min-height: 150px; padding: 22px 16px 17px; }
.editorial-item:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
.editorial-mark { display: block; margin-bottom: 30px; color: var(--blue); font-family: var(--serif); font-size: 31px; font-style: italic; font-weight: 700; line-height: .7; }
.editorial-item h3 { position: relative; margin: 0 0 6px; font-size: 12px; line-height: 1.3; z-index: 1; }
.editorial-item p { position: relative; margin: 0; color: var(--muted); font-size: 9px; line-height: 1.52; z-index: 1; }
.editorial-item:nth-child(2) .editorial-mark { color: var(--accent); }
.editorial-item:nth-child(3) .editorial-mark { color: #a9773b; }
.editorial-item:nth-child(4) .editorial-mark { color: #3f7b78; }

/* P02–P04: larger type for comfortable in-app reading. */
.page-2 .path-marker { width: 42px; height: 42px; font-size: 11px; }
.page-2 .path-step { grid-template-columns: 49px minmax(0, 1fr); min-height: 74px; gap: 14px; padding-block: 13px; }
.page-2 .path-copy h3 { font-size: 15px; line-height: 1.3; margin-bottom: 4px; }
.page-2 .path-copy p { font-size: 11px; line-height: 1.5; }
.page-3 h2, .page-4 h2 { font-size: clamp(34px, 9vw, 43px); }
.page-3 .lead, .page-4 .lead { font-size: 15px; line-height: 1.62; }
.page-3 .editorial-guide { display: grid; grid-template-columns: 1fr; }
.page-3 .editorial-guide::before { display: none; }
.page-3 .editorial-item { min-height: 91px; padding: 16px 17px 15px 70px; border-bottom: 1px solid var(--line); }
.page-3 .editorial-item:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
.page-3 .editorial-item:last-child { border-bottom: 0; }
.page-3 .editorial-mark { position: absolute; top: 24px; left: 18px; margin: 0; font-size: 35px; }
.page-3 .editorial-item h3 { font-size: 14px; line-height: 1.34; margin-bottom: 7px; }
.page-3 .editorial-item p { font-size: 11px; line-height: 1.55; }
[dir="rtl"] .page-3 .editorial-item { padding: 16px 70px 15px 17px; }
[dir="rtl"] .page-3 .editorial-mark { left: auto; right: 18px; }

/* P05–P24: generous text scale with layout-specific rhythm. */
.page-reading h2 { font-size: clamp(34px, 9vw, 42px); }
.page-reading .lead { font-size: 15px; line-height: 1.62; margin-bottom: 19px; }
.page-reading .guide-prose { margin-bottom: 20px; }
.page-reading .guide-prose p { font-size: 13.5px; line-height: 1.76; }
.page-reading .phrase-list { grid-template-columns: 1fr; gap: 11px; }
.page-reading .phrase-card { padding: 14px; }
.page-reading .phrase-card .spanish { overflow-wrap: anywhere; }

.page-reading .phrase-card .spanish { font-size: 15px; line-height: 1.36; }
.page-reading .phrase-card .meaning { font-size: 11px; line-height: 1.48; margin-top: 6px; }
.page-reading .tag { margin-bottom: 8px; padding: 4px 8px; font-size: 8px; }
.page-reading .sound-list, .page-reading .reference-list, .page-reading .compare-list { gap: 10px; margin-top: 10px; }
.page-reading .sound-row { grid-template-columns: 50px 90px 1fr; gap: 10px; padding: 13px; }
.page-reading .sound-row > strong { width: 38px; height: 38px; font-size: 16px; }
.page-reading .sound-row .spanish { font-size: 13px; }
.page-reading .sound-row small { font-size: 11px; line-height: 1.45; }
.page-reading .reference-list > div { grid-template-columns: 108px 1fr; gap: 15px; padding: 17px; }
.page-reading .reference-list strong { font-size: 18px; }
.page-reading .reference-list span { font-size: 12px; line-height: 1.45; }
.page-reading .dialogue { gap: 12px; }
.page-reading .dialogue-row { grid-template-columns: 38px 1fr; gap: 10px; }
.page-reading .avatar { width: 38px; height: 38px; font-size: 11px; }
.page-reading .bubble { padding: 13px 14px; }
.page-reading .bubble .spanish { font-size: 14px; line-height: 1.42; }
.page-reading .bubble .meaning { font-size: 11px; line-height: 1.48; margin-top: 5px; }
.page-reading .page-note { padding: 15px; font-size: 11px; line-height: 1.62; }
.page-reading .page-note strong { font-size: 9px; }
.page-reading .comparison { padding: 16px; }
.page-reading .comparison strong { font-size: 9px; }
.page-reading .comparison .spanish { font-size: 14px; }
.page-reading .comparison p { font-size: 11px; line-height: 1.55; }
.page-reading .compare-row { grid-template-columns: 1fr; gap: 7px; }
.page-reading .compare-row > div { min-width: 0; padding: 13px; gap: 5px; }
.page-reading .compare-row > b { justify-self: center; font-size: 14px; line-height: 1; transform: rotate(90deg); }
.page-reading .compare-row small { font-size: 8px; }
.page-reading .compare-row strong { font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.page-reading .compare-row span { font-size: 11px; line-height: 1.45; }
.page-reading .day-list { gap: 10px; margin-top: 11px; }
.page-reading .day-row { grid-template-columns: 66px 1fr; gap: 12px; padding: 14px; }
.page-reading .day-row strong { font-size: 10px; }
.page-reading .day-row span { font-size: 13px; line-height: 1.45; }
.page-reading .scene-art.mini { margin-bottom: 16px; }

.day-list { display: grid; gap: 8px; margin-top: 9px; }
.day-row { display: grid; grid-template-columns: 58px 1fr; gap: 11px; padding: 11px 13px; border-radius: 15px; background: rgba(255,255,255,.88); border: 1px solid var(--line); align-items: center;  }

/* P25: a quiet, editorial end page that closes the handbook without adding another task. */
.page-closing { padding-top: 82px; padding-bottom: 104px; }
.closing-page { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; }
.closing-page h2 { max-width: 100%; margin: 0 0 17px; font-size: clamp(38px, 10vw, 47px); }
.closing-art { width: 100%; flex: 0 0 auto; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f6efe4; }
.closing-page .lead { max-width: 320px; margin: 0; font-size: 15px; line-height: 1.68; }
.closing-signoff { margin-top: 24px; color: var(--blue); font-family: var(--serif); font-size: 34px; font-style: italic; font-weight: 700; }
.closing-note { margin: 8px 0 0; color: var(--accent); font-size: 12px; }
.closing-line { display: none; }
.closing-brand { margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .07em; }
[dir="rtl"] .closing-page h2 { font-family: 'Noto Sans Arabic', var(--sans); font-size: clamp(32px, 8.8vw, 40px); }
[dir="rtl"] .closing-page .lead { line-height: 1.85; }
[dir="rtl"] .closing-signoff { direction: ltr; }

.day-row strong { color: var(--blue); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.day-row span { font-size: 11px; }
.vowel-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 14px 0 17px; direction: ltr; }
.vowel { display: grid; place-items: center; padding: 14px 5px 10px; border-radius: 15px; background: #fff; border: 1px solid var(--line);  }
.vowel strong { font-family: var(--serif); font-size: 30px; color: var(--blue); line-height: 1; }
.vowel span { font-size: 8px; color: var(--muted); margin-top: 7px; }
.sound-list, .reference-list, .compare-list { display: grid; gap: 8px; margin-top: 8px; }
.sound-row { display: grid; grid-template-columns: 46px 82px 1fr; gap: 9px; align-items: center; padding: 11px 12px; border-radius: 15px; background: rgba(255,255,255,.88); border: 1px solid var(--line);  }
.sound-row > strong { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--blue-pale); color: var(--blue); font-size: 14px; }
.sound-row .spanish { font-weight: 700; font-size: 11px; direction: ltr; text-align: left; }
.sound-row small { color: var(--muted); line-height: 1.4; font-size: 9px; }
.stress-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 15px 0; direction: ltr; }
.stress-word { display: flex; justify-content: center; padding: 21px 10px; border-radius: 17px; background: #fff; border: 1px solid var(--line); font-size: 19px; font-weight: 700;  }
.stress-word span.hit { color: var(--accent); text-decoration: underline 3px; text-underline-offset: 5px; }
.reference-list > div { display: grid; grid-template-columns: 100px 1fr; gap: 14px; align-items: center; padding: 15px; border-radius: 16px; background: rgba(255,255,255,.88); border: 1px solid var(--line);  }
.reference-list strong { font-size: 16px; color: var(--blue); }
.reference-list span { color: var(--muted); font-size: 10px; }
.compare-row { display: grid; grid-template-columns: 1fr 20px 1fr; gap: 6px; align-items: stretch; }
.compare-row > div { padding: 11px; background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 14px; display: grid; gap: 4px;  }
.compare-row > div:last-child { background: var(--accent-pale); border-color: rgba(187,104,91,.18); }
.compare-row > b { align-self: center; text-align: center; color: var(--accent); font-size: 12px; }
.compare-row small { color: var(--muted); font-size: 7px; text-transform: uppercase; letter-spacing: .06em; }
.compare-row strong { font-size: 10px; direction: ltr; text-align: left; }
.compare-row span { color: var(--muted); font-size: 8px; line-height: 1.35; }

.backdrop { position: absolute; inset: 0; background: rgba(12,13,25,.54); opacity: 0; visibility: hidden; transition: .22s; z-index: 20;  }
.backdrop.visible { opacity: 1; visibility: visible; }
.drawer {
  position: absolute; inset: 0 auto 0 0; width: min(390px, 92%); padding: max(30px, env(safe-area-inset-top)) 24px 30px;
  background: var(--paper); z-index: 30; transform: translateX(-102%); transition: transform .28s cubic-bezier(.2,.75,.2,1); overflow-y: auto;
  border-inline-end: 1px solid var(--line);
}
.drawer.open { transform: translateX(0); }
.drawer-header, .sheet-heading { display: flex; justify-content: space-between; align-items: start; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .13em; font-size: 10px; font-weight: 700; }
.drawer h2, .language-sheet h2 { font-family: var(--serif); font-size: 35px; margin: 4px 0 0; }
.close-button {
  width: 32px; height: 32px; flex-shrink: 0; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--paper-warm); color: var(--ink);
}
.close-button svg { display: block; width: 18px; height: 18px; }
.chapter-list { display: grid; gap: 9px; margin-top: 26px; }
.chapter-button { width: 100%; border: 0; background: transparent; text-align: left; padding: 14px 13px; border-radius: 15px; display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; cursor: pointer; color: var(--ink); }
.chapter-button:hover, .chapter-button.active { background: var(--paper-warm); }
.chapter-button .chapter-no { color: var(--accent); font-size: 11px; }
.chapter-button .chapter-name { font-size: 15px; font-weight: 700; }
.chapter-button .chapter-pages { color: var(--muted); font-size: 11px; }

.language-sheet { position: absolute; left: 0; bottom: 0; width: 100%; max-height: 100%; overflow-y: auto; padding: 13px 24px max(28px, env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: var(--paper); z-index: 31; transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.75,.2,1); border: 1px solid var(--line); }
.language-sheet.open { transform: translateY(0); }
.sheet-handle { width: 38px; height: 4px; background: #cbd5ea; border-radius: 9px; margin: 0 auto 18px; }
.language-options { display: grid; gap: 8px; margin-top: 15px; direction: ltr; }
.language-options button { display: grid; grid-template-columns: 32px minmax(0, 1fr) 18px; column-gap: 12px; text-align: left; padding: 13px 15px; border: 1px solid var(--line); border-radius: 15px; background: #fff; cursor: pointer; color: var(--ink); }
.language-options .language-flag { grid-column: 1; grid-row: 1 / 3; align-self: center; display: block; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.language-options button span { grid-column: 2; grid-row: 1; font-weight: 700; font-size: 12px; }
.language-options button small { grid-column: 2; grid-row: 2; color: var(--muted); margin-top: 3px; font-size: 9px; }
.language-options button i { grid-column: 3; grid-row: 1 / 3; align-self: center; width: 18px; height: 18px; border: 1.5px solid #b8c4db; border-radius: 50%; }
.language-options button.selected { border-color: var(--blue); background: var(--blue-pale); }
.language-options button.selected i { border: 5px solid var(--blue); }

[dir="rtl"] .drawer { inset: 0 0 0 auto; transform: translateX(102%); }
[dir="rtl"] .drawer.open { transform: translateX(0); }
[dir="rtl"] body { font-family: 'Noto Sans Arabic', var(--sans); }
[dir="rtl"] .page h2 { max-width: 100%; font-family: 'Noto Sans Arabic', var(--sans); font-size: clamp(29px, 7.8vw, 36px); line-height: 1.2; letter-spacing: 0; }
[dir="rtl"] .page-indicator { direction: ltr; }
[dir="rtl"] .dialogue-row { grid-template-columns: 1fr 38px; direction: ltr; }
[dir="rtl"] .dialogue-row .avatar { grid-column: 2; grid-row: 1; }
[dir="rtl"] .dialogue-row .bubble { grid-column: 1; grid-row: 1; border-radius: 16px 5px 16px 16px; direction: rtl; }
[dir="rtl"] .chapter-button { text-align: right; grid-template-columns: auto 1fr 32px; }
[dir="rtl"] .chapter-button .chapter-no { grid-column: 3; }
[dir="rtl"] .chapter-button .chapter-name { grid-column: 2; grid-row: 1; }
[dir="rtl"] .chapter-button .chapter-pages { grid-column: 1; grid-row: 1; }
[dir="rtl"] .learning-path { direction: rtl; }
[dir="rtl"] .editorial-guide { direction: rtl; }
[dir="rtl"] .editorial-guide::before { left: auto; right: 50%; }
[dir="rtl"] .editorial-item { text-align: right; }
[dir="rtl"] .path-step { grid-template-columns: minmax(0, 1fr) 45px; padding: 12px 11px 12px 14px; }
[dir="rtl"] .path-marker { grid-column: 2; }
[dir="rtl"] .path-copy { grid-column: 1; grid-row: 1; text-align: right; }
[dir="rtl"] .path-step::before { inset: 0 0 0 auto; border-radius: 0 17px 17px 0; }
[dir="rtl"] .path-line { left: auto; right: 30px; }
[dir="rtl"] .spanish { direction: ltr; text-align: left; unicode-bidi: isolate; }

@media (max-width: 560px), (max-height: 760px) {
  .app-shell { width: 100vw; height: 100dvh; max-width: none; max-height: none; top: 0; transform: none; border-radius: 0; }
  .topbar { height: 70px; padding: max(10px, env(safe-area-inset-top)) 12px 6px; }
  .language-button { padding: 8px 9px; }
  .page-inner { padding: 88px 20px 116px; }
  .reader-footer { padding-inline: 18px; }
}

@media (max-height: 700px) {
  .page-inner { padding-top: 80px; }
  .lead { font-size: 11px; margin-bottom: 12px; }
  .page h2 { font-size: 29px; }
}

@media (max-width: 350px) {
  .home-button { padding: 9px; }
  .home-button span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
