/* Lao web fonts, self-hosted (variable weight 100-900; OFL, see fonts/OFL.txt). font-display: block keeps the fallback
   font from drawing a mark and its dotted circle in two different fonts. U+25CC is the dotted circle. */
@font-face { font-family: 'Noto Sans Lao'; src: url('fonts/NotoSansLao.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: block; unicode-range: U+0E81-0EDF, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Sans Lao Looped'; src: url('fonts/NotoSansLaoLooped.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: block; unicode-range: U+0E81-0EDF, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Serif Lao'; src: url('fonts/NotoSerifLao.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: block; unicode-range: U+0E81-0EDF, U+200C-200D, U+25CC; }
/* Colour tokens (A7 step 7). The default palette is Lao blue + red (owner 2026-11-13, DESIGN "Presentation"); Indigo +
   saffron and Teal + gold are colour themes picked in Settings (html[data-palette], settings.js). Light or dark is a
   separate choice (html[data-theme]). Every text token is at least 4.5:1 on --bg and --card, --on-accent on --accent
   and --on-warm on --warm; --control-border is 3:1 (WCAG 1.4.11).
   --warm is the brand colour (the brand dot, the Culture badge). It is never used for an answer state:
   right is --ok (green) and wrong is --danger, always with a mark or text as well, so the Lao red is never read as
   "wrong". A [data-palette] on any element (the Settings swatches) gives its subtree that palette's tokens. */
:root, [data-palette='lao'] {
  --bg: #f5f7fb;
  --fg: #141a26;
  --muted: #566073;
  --card: #ffffff;
  --border: #d3d9e4;
  --accent: #12408f; --accent-fill: #12408f;
  --on-accent: #ffffff; /* text on an accent fill (button.primary) */
  /* --accent-fill: the fill of primary buttons; in dark it is a little deeper than --accent, which stays for text and edges */
  --control-border: #838b9a; /* the idle edge of an option, tile or answer line */
  --danger: #b3261e;
  --ok: #1b7a43;
  --warm: #c8102e;
  --on-warm: #ffffff;
}
:root {
  accent-color: var(--accent);
  /* layout tokens (A7): the reading column's width and the corner of cards, options and tiles */
  --content-max: 720px;
  /* A23 tokens: type scale, 4px spacing grid, radii (8px small, 12px cards, pill, circle), one colour ease.
     Lao display sizes are not on the scale (A18). */
  --fs-xs: 0.75rem; --fs-sm: 0.875rem; --fs-md: 1rem; --fs-lg: 1.25rem; --fs-xl: 1.5rem; --fs-2xl: 2rem;
  /* Lao ink (see "Lao ink" below): fallbacks for Noto Sans Lao, replaced by the measured numbers (js/lao_ink.js) */
  --lao-lh: 1.67;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-sm: 8px; --radius: 12px; --r-pill: 999px; --r-circle: 50%;
  --ease: 160ms ease;
  color-scheme: light dark;
  /* the check and chevron icons (icons.js shapes) as masks, for the few marks drawn from CSS */
  --mask-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --mask-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E");
}
/* Dark: the device's setting, unless the learner picked Light or Dark in Settings (html[data-theme], settings.js),
   which wins. Each palette's two dark blocks hold the same tokens. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']), :root:not([data-theme='light']) [data-palette='lao'] {
    --bg: #0f1420; --fg: #e9edf5; --muted: #9ba6ba; --card: #182032; --border: #2f3a52; --accent: #86abff; --accent-fill: #6f97f5;
    --on-accent: #0a1630; --control-border: #66718a; --danger: #ff8a7a; --ok: #5fd08a; --warm: #ff7a8a; --on-warm: #2a0710;
  }
}
:root[data-theme='dark'], :root[data-theme='dark'] [data-palette='lao'] {
  --bg: #0f1420; --fg: #e9edf5; --muted: #9ba6ba; --card: #182032; --border: #2f3a52; --accent: #86abff; --accent-fill: #6f97f5;
  --on-accent: #0a1630; --control-border: #66718a; --danger: #ff8a7a; --ok: #5fd08a; --warm: #ff7a8a; --on-warm: #2a0710;
}
:root[data-theme='dark'] { color-scheme: dark; }
:root[data-theme='light'] { color-scheme: light; }

/* Indigo + saffron */
[data-palette='indigo'] {
  --bg: #f7f6fb; --fg: #1d1b2a; --muted: #5b586e; --card: #ffffff; --border: #dad7e6; --accent: #4b3fb5; --accent-fill: #4b3fb5;
  --on-accent: #ffffff; --control-border: #8a879b; --danger: #b3261e; --ok: #1b7a43; --warm: #9c5a00; --on-warm: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root[data-palette='indigo']:not([data-theme='light']), :root:not([data-theme='light']) [data-palette='indigo'] {
    --bg: #13121c; --fg: #ecebf5; --muted: #a19fb6; --card: #1d1b2b; --border: #383552; --accent: #a99fff; --accent-fill: #a99fff;
    --on-accent: #17123a; --control-border: #6f6c88; --danger: #ff8a7a; --ok: #5fd08a; --warm: #ffb84d; --on-warm: #2a1700;
  }
}
:root[data-palette='indigo'][data-theme='dark'], :root[data-theme='dark'] [data-palette='indigo'] {
  --bg: #13121c; --fg: #ecebf5; --muted: #a19fb6; --card: #1d1b2b; --border: #383552; --accent: #a99fff; --accent-fill: #a99fff;
  --on-accent: #17123a; --control-border: #6f6c88; --danger: #ff8a7a; --ok: #5fd08a; --warm: #ffb84d; --on-warm: #2a1700;
}

/* Teal + gold */
[data-palette='teal'] {
  --bg: #f4f7f6; --fg: #16211f; --muted: #52605c; --card: #ffffff; --border: #d0dbd8; --accent: #0b6461; --accent-fill: #0b6461;
  --on-accent: #ffffff; --control-border: #7e8c88; --danger: #b3261e; --ok: #1b7a43; --warm: #9a6200; --on-warm: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root[data-palette='teal']:not([data-theme='light']), :root:not([data-theme='light']) [data-palette='teal'] {
    --bg: #101615; --fg: #e7efed; --muted: #9aaba7; --card: #18211f; --border: #2f3e3b; --accent: #4fc7c0; --accent-fill: #4fc7c0;
    --on-accent: #062523; --control-border: #63736f; --danger: #ff8a7a; --ok: #7ad67f; --warm: #f0b54a; --on-warm: #2a1a00;
  }
}
:root[data-palette='teal'][data-theme='dark'], :root[data-theme='dark'] [data-palette='teal'] {
  --bg: #101615; --fg: #e7efed; --muted: #9aaba7; --card: #18211f; --border: #2f3e3b; --accent: #4fc7c0; --accent-fill: #4fc7c0;
  --on-accent: #062523; --control-border: #63736f; --danger: #ff8a7a; --ok: #7ad67f; --warm: #f0b54a; --on-warm: #2a1a00;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.col { display: grid; gap: 2px; margin: 4px 0; }
input[type='date'] { min-height: 42px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
a { color: var(--accent); } /* links in the palette, not the browser's blue (A7 step 7) */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--border);
}
.card {
  max-width: var(--content-max); margin: 16px auto; padding: 20px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.card.narrow { max-width: 420px; margin-top: 48px; }
@media (max-width: 760px) {
  /* the page fills the screen: no grey strip under the card (the body takes the card colour) */
  body { background: var(--card); }
  .card { margin: 0; border: 0; border-radius: 0; }
  .card.narrow { margin-top: 0; padding-top: var(--sp-5); }
  /* room under the last button on scrolling pages (sign-up, forms) so a phone's bottom toolbar never covers it */
  body:not(:has(.lesson-frame)) { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
}

h1 { margin: 0 0 var(--sp-2); font-size: var(--fs-xl); line-height: 1.25; } /* the one page-title style */
h2 { margin-top: 0; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 4px; font-size: var(--fs-sm); }
label.check, label.pill { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
label.pill { padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--r-pill); }
input[type='text'], input[type='email'], input[type='password'], input:not([type]), textarea, input[type='date'], select {
  width: 100%; padding: 10px; font: inherit; color: inherit;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm);
}
input[type='radio'], input[type='checkbox'] { width: 20px; height: 20px; flex: none; }
button {
  font: inherit; padding: 10px 16px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--control-border); background: var(--card); color: inherit;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); font-weight: 600; }
button.secondary { background: var(--card); border-color: var(--control-border); color: var(--fg); }
button.danger { background: var(--card); border-color: var(--danger); color: var(--danger); }
button.link { border: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; }
/* Underlined links are for running text only. A back link is a chevron and its label. */
.back-link { text-decoration: none; gap: var(--sp-1); font-weight: 600; }
.back-link .icon { margin-left: -4px; }
a.back-link, button.back-link { color: var(--accent); text-decoration: none; }
.icon { display: block; flex: none; }
.brand-title { display: flex; align-items: center; }
.brand-title .brand-dot { width: 0.55em; height: 0.55em; }
/* Interaction states (A23): a short colour ease and a 1px pressed shift on every control; the shift and the ease only
   where the learner has not asked for less motion. Hover only where there is a hover. */
@media (prefers-reduced-motion: no-preference) {
  button, a.btn, .tile, .path-link, .word-row, .letters-cell, .write-cell, .role-card, .path-side {
    transition: background-color var(--ease), border-color var(--ease), color var(--ease), transform 90ms ease;
  }
  :where(button:not(:disabled), a.btn, a.tile, a.path-link, a.word-row, a.letters-cell, a.write-cell, a.path-side):active { transform: translateY(1px); }
}
:where(button:not(:disabled), a.btn):active, button.secondary:not(:disabled):active, button.danger:not(:disabled):active, a.btn.secondary:active { background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
button.danger:not(:disabled):active { background: color-mix(in srgb, var(--danger) 14%, var(--card)); }
button.small, a.btn.small { min-height: 44px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
button.primary:not(:disabled):active, a.btn.primary:active { background: color-mix(in srgb, var(--accent-fill) 80%, #000); border-color: color-mix(in srgb, var(--accent-fill) 80%, #000); }
button.link:not(:disabled):active { background: none; }
a.tile:active, a.path-link:active, a.word-row:active, a.letters-cell:active, a.write-cell:active, a.path-side:active, button.role-card:active {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}
/* 44px touch targets for text buttons and links (topbar, sign-in toggle, dialogs, "All lessons"): taller, not bigger */
button.link, a.link, a.back-link { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
/* in the topbar and the lesson head the extra height reaches into the padding around them, so those rows keep their height */
.topbar .link, .lesson-head .link, .page-head .link, .page-head .back-link { margin-block: -10px; }
/* Keyboard focus: one ring in the accent colour, for every control (A6b #11) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); font-size: var(--fs-sm); margin: 4px 0; }
.error { color: var(--danger); }
.info { color: var(--ok); }
.counter { text-align: right; margin: 0; }

.sentence { text-align: center; padding: 16px 8px 24px; }
/* The Lao font is a learner setting (js/settings.js sets --lao-font). Default: Leelawadee UI (Windows), else the
   device's own Lao font. */
.read-more { margin-top: 12px; }
.style-choice { margin-top: 0; }
.rule-text { font-size: var(--fs-md); line-height: 2; }
/* Recap table (rule cards): a header row, then one shaded row per case; the columns line up through subgrid. */
.recap { display: grid; grid-template-columns: auto auto 1fr; margin: 14px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.recap-row { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; gap: 0 16px; align-items: center; padding: 8px 14px; }
.recap-row:not(.recap-head) { border-top: 1px solid var(--border); }
.recap-row:not(.recap-head):nth-child(odd) { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.recap-head { padding-top: 6px; padding-bottom: 6px; background: color-mix(in srgb, var(--fg) 8%, transparent); }
.recap-lao { font-size: calc(2.6rem * var(--lao-scale, 1)); font-weight: 600; }
.recap-sound { font-size: var(--fs-xl); font-weight: 600; }
.recap-cue { line-height: 1.4; }
/* L3 tone table (teach_card toneTable): Lao | sounds like | means | tone | play */
.recap.tone-table { grid-template-columns: auto auto 1fr auto auto; }
.recap.tone-table.with-marks { grid-template-columns: auto auto 1fr auto auto auto; }
.tone-mk-cell { font-size: calc(2rem * var(--lao-scale, 1)); font-weight: 600; text-align: center; }
.tone-mk-none { color: var(--muted); text-align: center; font-size: var(--fs-xl); }
.tone-table .recap-row { gap: 0 12px; padding: 6px 10px; }
.tone-table .tone-contour { width: 48px; height: 32px; }
@media (max-width: 420px) { .tone-table .tone-contour { width: 36px; height: 24px; } .tone-table .tone-mk-cell { font-size: calc(1.5rem * var(--lao-scale, 1)); } .tone-table .recap-row { gap: 0 8px; padding: 6px 8px; } .tone-table .recap-lao { font-size: calc(2rem * var(--lao-scale, 1)); } .tone-table .recap-sound { font-size: var(--fs-md); } }
.lao-in { font-size: calc(1.4em * var(--lao-scale, 1)); padding-inline: 2px; } /* Lao quoted inside English prose: the one size */
.font-sample { font-size: 1.3rem; margin-left: 8px; }
[lang='lo'] { font-family: var(--lao-font, 'Leelawadee UI', 'Noto Sans Lao', sans-serif); }
/* Lao ink: every box of Lao text contains its own ink, in every font, size and media query. Lao stacks a vowel and a
   tone mark above a consonant (1.04em above the baseline in Leelawadee UI, 1.14em in Noto Sans Lao) and marks below
   (up to 0.5em); a guessed line-height clips them or lets them cover the label above. js/lao_ink.js measures the
   font in use once and sets --lao-lh, the line-height at which the ink fits on both sides of the centred text (a
   unitless number, so em of the element's own font size). It is the same for every word, so nothing jumps between
   steps. A Lao class must not set its own line-height (it would undo this): change its font-size, margin or the
   container instead. */
.lao, .lao-in, .glyph, .bw-word, .fb-sentence, .rc-lao, .fb-lao, .recap-lao, .tone-mk-cell, .say-sentence, .dlg-lao, .unit-word-lao, .word-lao, .ilw-lao { line-height: var(--lao-lh, 1.67); }
.lao { font-family: var(--lao-font, 'Leelawadee UI', 'Noto Sans Lao', sans-serif); font-size: calc(2rem * var(--lao-scale, 1)); margin: 0; word-break: break-word; }
.english { color: var(--muted); margin: 8px 0 0; }

fieldset { border: 1px solid var(--border); border-radius: var(--r-sm); margin: 0 0 16px; padding: 12px 14px; }
legend { font-weight: 600; padding: 0 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.indent { margin-top: 8px; padding-left: 8px; display: grid; gap: 6px; }
.actions { display: flex; align-items: center; gap: 20px; margin-top: 16px; }
.recorder { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.recorder audio { max-width: 100%; }
.recorder .rec-big { width: 100%; min-height: 64px; font-size: var(--fs-lg); padding: 14px 20px; }

.lang-toggle { display: flex; justify-content: flex-end; gap: 14px; margin: -6px 0 8px; }
.lang-toggle button[aria-pressed='true'] { color: var(--fg); font-weight: 600; border-color: var(--accent); }
.roles { display: grid; gap: 12px; margin: 12px 0 16px; }
.role-card {
  display: grid; gap: 4px; text-align: left; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.role-card:hover, .role-card:focus-visible { border-color: var(--accent); }
.role-card strong { font-size: var(--fs-md); }

/* Learner view: lesson list and teach cards (learn.js) */
.block { display: block; }
.center { text-align: center; }
.lesson-num { font-weight: 600; color: var(--accent); min-width: 1.5em; }
/* Session (session.js): progress bar, summary */
.session-progress { flex: 1; min-width: 0; height: 10px; accent-color: var(--accent); }
/* the bar on its track is 4:1 in both themes (the browser's own dark track was about 1.3:1 on the page) */
.session-progress { appearance: none; -webkit-appearance: none; border: 0; border-radius: var(--r-pill); background: var(--border); overflow: hidden; }
.session-progress::-webkit-progress-bar { background: var(--border); border-radius: var(--r-pill); }
.session-progress::-webkit-progress-value { background: var(--accent); border-radius: var(--r-pill); }
.session-progress::-moz-progress-bar { background: var(--accent); border-radius: var(--r-pill); }
.stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-2); margin: var(--sp-4) 0; padding: var(--sp-3) var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius); }
.stat { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
/* A16 summary: the completion mark, "You learned" and the missed items as word rows */
.done-mark { display: flex; align-items: center; justify-content: center; width: 72px; height: 72px; margin: var(--sp-2) auto var(--sp-3); border-radius: var(--r-circle); background: var(--ok); color: var(--card); }
.done-mark .icon { stroke-width: 3; }
@media (prefers-reduced-motion: no-preference) {
  .done-mark { animation: done-pop 360ms cubic-bezier(0.3, 1.5, 0.6, 1) both; }
}
@keyframes done-pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.summary-list { list-style: none; padding: 0; margin: 0 0 var(--sp-4); display: grid; gap: var(--sp-1); }
.summary-list .word-row { padding-right: var(--sp-1); }
.summary-list .word-tools { flex: none; display: flex; align-items: center; gap: var(--sp-1); }
.summary-list .word-tools .audio-ctl, .summary-list .word-tools button.info-btn { margin: 0; }
.summary-section h2 { font-size: var(--fs-md); margin: var(--sp-4) 0 var(--sp-2); }
.summary-read { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.summary-read p { margin: 0; }
.summary-read-line { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.summary-practise { margin: 0 0 var(--sp-4); }
.summary-head { margin-bottom: 0; }
/* Multiple choice (activities/multiple_choice.js) */
.mc-question { text-align: center; color: var(--muted); margin: 4px 0; }
.mc-prompt { text-align: center; margin: 0 0 12px; }
.mc-prompt-en { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.4; padding: 16px 0; }
.mc-prompt-sound { text-align: center; margin: -6px 0 10px; } /* pick the meaning, answered: the Lao's romanization */
.mc-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mc-options.wide { grid-template-columns: 1fr; }
.mc-option { position: relative; min-height: 56px; font-size: var(--fs-lg); background: var(--bg); border-color: var(--control-border); border-radius: var(--radius); }
/* A Lao option never breaks inside a word: fitOptions (dom.js) drops the grid to one column instead (A6 #9).
   The check / x icon sits in the corner, so marking the answer never widens or rewraps an option. */
.mc-option .lao { font-size: calc(2.2rem * var(--lao-scale, 1)); white-space: nowrap; word-break: keep-all; }
.mc-options.wide .mc-option .lao { white-space: normal; }
.mc-mark { display: inline-flex; vertical-align: middle; margin-right: var(--sp-1); }
.mc-option .mc-mark { position: absolute; top: 6px; left: 8px; margin: 0; line-height: 1; }
@media (hover: hover) {
  .mc-option:not(:disabled):hover, .bs-tile:not(:disabled):hover { border-color: var(--accent); }
}
.mc-option:not(:disabled):active, .bs-tile:not(:disabled):active { background: color-mix(in srgb, var(--accent) 16%, var(--bg)); }
@media (prefers-reduced-motion: no-preference) {
  .mc-option, .bs-tile { transition: background-color var(--ease), border-color var(--ease), color var(--ease), transform 90ms ease; }
  .mc-option:not(:disabled):active, .bs-tile:not(:disabled):active { transform: translateY(1px); }
}
.mc-option:disabled { opacity: 0.6; }
.mc-option.selected { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); font-weight: 600; }
.mc-option.right { opacity: 1; border: 2px solid var(--ok); color: var(--ok); font-weight: 600; background: color-mix(in srgb, var(--ok) 10%, var(--card)); }
.mc-option.wrong { opacity: 1; border: 2px solid var(--danger); color: var(--danger); }
/* Matching (activities/match.js, M1): Lao left, labels right, a gap between them wide enough for the lines. Each
   column is a grid of equal rows, both columns stretch to the board's height, so the rows line up (the curved
   lines' table, match.js BOWS, assumes it). Lines are one SVG under the tiles: a curved <path> per pair (fill: none),
   a straight <line> for the drag. Nothing on the board moves: the selected and wrong states draw their 2px edge with
   an inset shadow, so no border width changes. */
.match-board { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: clamp(40px, 14vw, 96px); margin-top: auto; padding-top: 8px; }
.lesson-frame section.mc > .match-board { flex: none; }
.match-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; }
.match-line { stroke: var(--muted); stroke-width: 2; stroke-linecap: round; fill: none; }
.match-col { position: relative; z-index: 1; display: grid; grid-auto-rows: 1fr; row-gap: 8px; min-width: 0; }
.match-tile {
  position: relative; min-width: 0; padding: 2px 8px; background: var(--bg); border-color: var(--control-border); border-radius: var(--radius);
  min-height: max(44px, calc(clamp(52px, 9vh, 72px) * var(--fit, 1))); min-height: max(44px, calc(clamp(52px, 9dvh, 72px) * var(--fit, 1))); /* vh first: older iPhones have no dvh */
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.match-tile .lao { font-size: calc(1.6rem * var(--lao-scale, 1)); white-space: nowrap; word-break: keep-all; }
.match-en { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-size: var(--fs-md); line-height: 1.25; overflow-wrap: break-word; }
@media (hover: hover) { .match-tile:not(:disabled):hover { border-color: var(--accent); } }
.match-tile:not(:disabled):active { background: color-mix(in srgb, var(--accent) 16%, var(--bg)); }
.match-tile.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
.match-tile.wrong { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); color: var(--danger); }
.match-tile.matched:disabled { opacity: 0.45; cursor: default; } /* used up: dimmed, no colour of its own */
@media (prefers-reduced-motion: no-preference) {
  .match-tile { transition: background-color var(--ease), border-color var(--ease), color var(--ease), opacity var(--ease); }
  .match-tile.wrong { animation: match-shake 600ms ease; }
}
@keyframes match-shake { 0%, 100% { translate: 0 0; } 15%, 55% { translate: -4px 0; } 35%, 75% { translate: 4px 0; } }
.match > .feedback.ok { margin: 0; } /* only the fixed "Correct!" toast: it takes no room, so the board stays put */
/* the missed pairs at the end, in place of the board: one compact answer row each (Lao, sound, meaning, ⓘ, 🔊) */
.match-missed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.match-row { padding: 4px 10px; }
.match-row .rc-left { flex-direction: row; align-items: center; gap: var(--sp-3); }
.match-row .rc-lao { font-size: calc(1.6rem * var(--lao-scale, 1)); }
.match-row .answer-sound { font-size: var(--fs-md); }
/* keys (session.js onKey): 1-5 pick the Lao row, a-e the label row; the number stays with its row */
@media (hover: hover) and (pointer: fine) and (min-width: 561px) {
  .lesson-frame .match-col { counter-reset: key; }
  .lesson-frame .match-tile { counter-increment: key; }
  .lesson-frame .match-tile:not(:disabled)::before {
    content: counter(key); position: absolute; top: 3px; left: 6px;
    font-size: var(--fs-xs); line-height: 1; color: var(--muted); font-weight: 400;
  }
  .lesson-frame .match-labels .match-tile:not(:disabled)::before { content: counter(key, lower-alpha); }
  .no-keys .lesson-frame .match-tile::before { content: none; }
}
/* Listen and pick (activities/listen_pick.js, L2): the play icon is the question */
.lp-prompt { padding: 8px 0 4px; }
.lp-prompt .audio-ctl { margin-left: 0; }
.audio-btn.audio-big { width: 88px; height: 88px; padding: 0; border-radius: var(--r-circle); display: inline-flex; align-items: center; justify-content: center; }
.audio-big.spent { display: inline-flex; width: 88px; height: 88px; align-items: center; justify-content: center; border-radius: var(--r-circle); border: 1px solid var(--border); color: var(--muted); }
/* the ▶ under a Lao -> meaning prompt is gone once answered (the panel has the speaker): its slot keeps the height */
.audio-slot { display: inline-block; width: 44px; height: 44px; }
/* A16 tool row under the prompt: "Can't listen now" and "Hint", quieter than the options; it keeps its height when
   they go, so the options never move */
.tool-row { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--sp-2); min-height: 44px; margin: 4px 0 8px; }
.tool-row button { color: var(--muted); border-color: var(--border); }
.say { align-items: center; text-align: center; }
.say .mc-prompt { margin-bottom: 0; }
.say-sentence { font-size: calc(1.7rem * var(--lao-scale, 1)); font-weight: 600; }
.say-en { font-size: var(--fs-lg); margin: 0 0 4px; }
.say-na { display: flex; justify-content: center; min-height: 44px; margin-bottom: 8px; }
.say-na .audio-ctl { margin-left: 0; }
.say-rec { width: 100%; max-width: 420px; }
.say-rec .recorder { justify-content: center; }
.say-done { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); width: 100%; }
.say-done button { min-height: 56px; }
.say-sound { margin: 0; font-weight: 600; }
.say-privacy { font-size: var(--fs-sm); margin: 0; }
.tool-row .hint-shown { margin: 0; align-self: center; } /* the opened hint, where the Hint button was */
/* a hint's room inside each option, kept from the start (hint.js reserve) */
.lesson-frame .stage .pending { visibility: hidden; }
.lesson-frame .stage[data-squeeze] .pending { display: none; } /* the step cannot fit even at the floor (dom.js fitStage) */
.listen-pause { margin: 4px 0 8px; }
.bs-prompt { font-size: var(--fs-xl); font-weight: 600; line-height: 1.4; padding: 8px 0; }
/* never squeezed below the wrapped tiles inside the scrolling lesson column (the line's border cut through them) */
section.mc > .bs-line, section.mc > .bs-bank, section.mc > .cmp { flex: none; }
.bs-line, .bs-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.bs-line { min-height: 72px; align-items: center; padding: 8px; margin-bottom: 16px; border-bottom: 2px solid var(--control-border); }
.bs-line.right { border-color: var(--ok); }
.bs-tile { min-width: 56px; min-height: 52px; padding: 0 14px; background: var(--bg); border-color: var(--control-border); border-radius: var(--radius); }
.bs-tile .lao { font-size: calc(1.8rem * var(--lao-scale, 1)); }
.bs-tile:disabled { opacity: 1; }
button.bs-tile { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.bs-tile.dragging { opacity: 0.3; }
.bs-tile.marker { border: 2px dashed var(--accent); background: transparent; min-width: 40px; }
.drag-float { position: fixed; z-index: 1000; pointer-events: none; margin: 0; display: inline-flex; align-items: center;
  justify-content: center; border: 2px solid var(--accent); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); }
.bs-tile.ghost { display: inline-flex; align-items: center; font-size: var(--fs-2xl); border: 1px dashed var(--border); visibility: visible; color: transparent; }
.feedback { --state: var(--ok); display: grid; gap: var(--sp-2); margin-top: 10px; }
.feedback.miss { --state: var(--danger); }
/* U1 answer cards (activities/panel.js), in place of the options: right = one card (the word large) and a "Correct!"
   toast; wrong = ✗ "You picked" over ✓ "Answer", each tinted and labelled (colour is never the only sign).
   A card: label, then [Lao ⓘ] [sound / meaning] [🔊]; a sentence stacks Lao, sound, meaning, then ⓘ left, 🔊 right. */
.feedback-head { display: flex; align-items: center; gap: var(--sp-2); margin: 0; font-weight: 600; color: var(--state); }
.fb-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; border-radius: var(--r-circle); background: var(--state); color: var(--card); }
.fb-icon .icon { stroke-width: 3; }
.rc { --state: var(--ok); min-width: 0; padding: 6px 12px 8px; border: 1px solid var(--state); border-radius: var(--radius); background: color-mix(in srgb, var(--state) 10%, var(--card)); }
.rc-pick { --state: var(--danger); }
.rc-label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--state); }
.rc-label .fb-icon { width: 20px; height: 20px; }
.rc-main { display: flex; align-items: center; gap: 0 var(--sp-3); }
.rc-left { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; } /* the sound centred under the Lao */
.rc-side { flex: none; display: flex; align-items: center; gap: 10px; margin-left: auto; } /* ⓘ a hair away from 🔊 */
.rc-word { display: inline-flex; align-items: center; gap: 2px; min-width: 0; }
.rc-lao, .rc .fb-lao { font-size: calc(2rem * var(--lao-scale, 1)); font-weight: 600; }
.feedback.ok .rc-answer:not(.sentence) .rc-lao { font-size: calc(2.6rem * var(--lao-scale, 1)); } /* right: the word large */
.rc-text { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.rc-text .tone-strip { justify-content: center; }
.rc-main > .audio-ctl { margin-left: auto; }
.rc .info-btn, .rc .audio-ctl { margin: 0; }
.rc .answer-sound { font-size: var(--fs-lg); line-height: 1.3; }
.fb-meaning { font-size: var(--fs-lg); line-height: 1.35; }
.rc.sentence { display: grid; gap: 2px; }
.rc.sentence .lao, .rc.sentence .fb-lao { font-size: calc(1.6rem * var(--lao-scale, 1)); }
.rc.sentence .rc-text { flex: none; }
.rc-tools { display: flex; justify-content: space-between; align-items: center; }
.rc.rc-slim { padding: 0; border: 0; background: none; } /* only ⓘ and 🔊: the screen above shows the answer */
/* cheer (fill in the blank): a right answer's word of praise stays above the card */
.feedback-head.cheer { margin: 0 0 6px; font-size: var(--fs-lg); }
/* "Correct!": a toast over the top bar, gone after a moment; it takes no room in the step */
.feedback-head.toast {
  position: fixed; z-index: 40; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; transform: translateX(-50%);
  padding: 6px 16px 6px 8px; border-radius: var(--r-pill); background: var(--ok); color: var(--card); white-space: nowrap;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.2); pointer-events: none; animation: toast-out 1.6s ease forwards;
}
.feedback-head.toast .fb-icon { background: var(--card); color: var(--ok); }
@keyframes toast-out { 0%, 70% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: no-preference) {
  .feedback-head.toast { animation-name: toast-in-out; }
  @keyframes toast-in-out { 0% { opacity: 0; translate: 0 -8px; } 12%, 70% { opacity: 1; translate: 0 0; } 100% { opacity: 0; visibility: hidden; } }
}
.rule-notes { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.rule-notes p:not(.feedback-head) { margin: 0 0 6px; line-height: 1.8; }
.answer-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.answer-sound { font-size: var(--fs-xl); font-weight: 600; }
button.info-btn { margin-left: auto; width: 44px; height: 44px; padding: 0; border-radius: var(--r-circle); display: inline-flex; align-items: center; justify-content: center; }
.stat-num { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.2; color: var(--accent); }
.center-row { justify-content: center; }
.lesson-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.teach { position: relative; padding: 8px 0; }
.glyph { font-size: calc(clamp(4rem, 22vw, 6rem) * var(--lao-scale, 1)); font-weight: 600; text-align: center; }
.teach > .lao { font-size: calc(2.2rem * var(--lao-scale, 1)); font-weight: 600; }
.meaning { font-size: var(--fs-lg); margin: 4px 0 12px; }
.badge {
  position: absolute; top: 0; right: 0; font-size: var(--fs-xs); padding: 2px 10px; border-radius: var(--r-pill);
  border: 1px solid var(--accent); color: var(--accent);
}
.badge.recycle { border-color: var(--muted); color: var(--muted); }
/* A7 step 7: the Bonus badge and the Culture badge stand out (owner: "need more oomph"): a solid fill and a mark.
   Bonus is the accent, Culture the brand's warm colour; both are only on teach cards, never on an answer. */
.badge.bonus, .note-badge.culture {
  font-weight: 700; letter-spacing: 0.02em; overflow: hidden; box-shadow: 0 2px 8px rgb(0 0 0 / 0.18);
}
.badge.bonus { padding: 3px 12px; font-size: var(--fs-sm); border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.badge.bonus::before { content: '\2605\00a0'; content: '\2605\00a0' / ''; } /* a star, decorative */
.teach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 8px 0 4px; text-align: center; }
.cell { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-width: 0; }
.cell-label { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cell .glyph { margin: 0; }
/* The Lao is the focus: it takes the whole first row, and the English cells sit under it (two per row; a lone
   last cell takes a whole row too). */
.teach-grid > .cell:first-child,
.teach-grid > .cell:last-child:nth-child(even) { grid-column: 1 / -1; }
.cell-big { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.5; }
.cell-mid { font-size: var(--fs-xl); line-height: 1.4; padding-top: 6px; }
.hint { font-size: var(--fs-md); margin: 4px 0 12px; }
/* Teach text one sentence per line, left-aligned (owner, 2026-11-13). */
.text-lines { text-align: left; line-height: 1.6; }
/* teach text reads as a caption under the glyph: left-aligned, about 30em wide, centred, 1rem */
.hint, .text-lines { font-size: var(--fs-md); line-height: 1.6; max-width: 30em; margin-inline: auto; text-align: left; }
.rule-text.text-lines { line-height: 2; max-width: none; }
.cell .hint { margin: 0 auto 4px; }
details.more { margin: 12px 0 0; border-top: 1px solid var(--border); padding-top: 8px; }
details.more summary { cursor: pointer; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.tone-row { display: flex; justify-content: center; gap: 16px; margin: 4px 0 8px; }
.tone { margin: 0; text-align: center; }
.tone figcaption.lao { font-size: calc(1.25rem * var(--lao-scale, 1)); }
.tone-frame { fill: color-mix(in srgb, var(--fg) 4%, transparent); stroke: var(--muted); stroke-width: 1.5; }
.tone-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.tone-line { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.tone-end { fill: var(--accent); }
/* tone twins / tone pictures in listening questions: the mark's accent colour only (no box changes: shaping) */
.tone-mk { color: var(--accent); }
.mc-option.right .tone-mk, .mc-option.wrong .tone-mk { color: inherit; }
.tone-strip { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.mc-option:has(.tone-strip) { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.mc-option .tone-contour { width: 48px; height: 32px; }
.rc .tone-strip .tone-contour { width: 36px; height: 24px; }
.mc-option .lm-gloss { font-size: var(--fs-lg); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
button.chip { padding: 6px 12px; min-height: 44px; border-radius: var(--r-pill); }
.info-icon { color: var(--accent); }
dialog.info {
  max-width: min(560px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); color: var(--fg); padding: 16px;
}
dialog.info::backdrop { background: rgb(0 0 0 / 0.4); }
/* modal.js locks the page scroll; these stop scroll chaining and touch panning through a dialog */
dialog.info, dialog.menu, dialog.info .sheet-body { overscroll-behavior: contain; }
dialog.info, dialog.menu { touch-action: pan-y; }
dialog.info::backdrop, dialog.menu::backdrop { touch-action: none; }
button.info-x { color: var(--muted); }
/* Lesson frame (session.js): a lesson step fills the visible screen and the page itself never scrolls, so a
   mobile browser's address bar stays put and nothing hides under it (dvh is the height left by the browser's
   bars). Progress on top, the activity in the middle (it scrolls inside itself if too tall), the button pinned at
   the bottom. Every activity renders [content, .actions] into .stage. */
body:has(.lesson-frame) { height: 100vh; height: 100dvh; height: var(--app-h, 100dvh); display: flex; flex-direction: column; overflow: hidden; }
body:has(.lesson-frame) #app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card.lesson-frame {
  flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.lesson-frame .lesson-head { flex: none; margin-bottom: 10px; }
.lesson-frame .stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* U1 fit-to-box (dom.js fitStage sets --fit on the stage, 1 down to the learner's floor): the stage's Lao and
   English sizes multiply by it. Phones start a little smaller (--base-lao, --base-en; owner 2026-11-20). */
.lesson-frame .stage {
  --lao-scale: calc(var(--lao-user, 1) * var(--base-lao, 1) * var(--fit, 1));
  --f: calc(var(--base-en, 1) * var(--fit, 1));
  font-size: calc(1rem * var(--f));
  --fs-xs: calc(0.75rem * var(--f)); --fs-sm: calc(0.875rem * var(--f)); --fs-md: calc(1rem * var(--f));
  --fs-lg: calc(1.25rem * var(--f)); --fs-xl: calc(1.5rem * var(--f)); --fs-2xl: calc(2rem * var(--f));
}
@media (max-width: 760px) { .lesson-frame .stage { --base-lao: 0.92; --base-en: 0.94; } }
/* U1 step 6: each new step slides in a little from the right (the stage is new per step), unless the learner asked
   for reduced motion. No fill mode: after 180 ms nothing is left transformed (the toast and popovers are fixed). */
@media (prefers-reduced-motion: no-preference) {
  .lesson-frame .stage { animation: step-in 180ms ease-out; }
}
/* a redraw of the same step (Settings closed) neither slides again nor shows an answered step's toast again */
.lesson-frame .stage.redrawn { animation: none; }
.stage.toasted .feedback-head.toast { display: none; }
@keyframes step-in { from { opacity: 0; translate: 16px 0; } to { opacity: 1; translate: 0 0; } }
.lesson-frame .stage > :first-child { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.lesson-frame .stage > .actions { flex: none; margin-top: 8px; min-height: 48px; }
.lesson-frame .stage > .actions button.primary { min-height: 48px; min-width: 140px; margin-left: auto; } /* right side, thumb reach (owner 2026-11-13) */
/* a question shows its button only once answered: keep its space so nothing moves */
.lesson-frame .stage:not(:has(> .actions))::after { content: ''; flex: none; height: 56px; }
/* A7 step 9 thumb zone (owner 2026-11-13): the options sit in the middle of the space left under the prompt, with
   bigger targets. The options box grows from its own height and the slot under it (.mc-after, the feedback) from
   zero, so idle they share the free space equally (centred). Answered, the slot only grows past its share when the
   feedback needs it, so the options stay put unless the feedback would not fit, then move up just enough. */
.lesson-frame .stage > section.mc { display: flex; flex-direction: column; }
.lesson-frame section.mc > .mc-options { flex: 1 1 auto; align-content: end; grid-auto-rows: max-content; }
.lesson-frame section.mc > .mc-after { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: flex-end; } /* U1: the answer cards where the options were */
.lesson-frame .mc-option { min-height: max(44px, calc(clamp(56px, 11vh, 88px) * var(--fit, 1))); min-height: max(44px, calc(clamp(56px, 11dvh, 88px) * var(--fit, 1))); } /* vh first: older iPhones (iOS < 15.4) have no dvh */
.lesson-frame .mc-options.wide .mc-option { min-height: max(44px, calc(clamp(56px, 8vh, 72px) * var(--fit, 1))); min-height: max(44px, calc(clamp(56px, 8dvh, 72px) * var(--fit, 1))); }
/* short phone screens: a little less air */
@media (max-height: 720px) {
  .card.lesson-frame { padding-top: 10px; }
  .glyph { font-size: calc(clamp(3.2rem, 18vw, 5rem) * var(--lao-scale, 1)); }
  .mc-prompt-en { font-size: var(--fs-xl); padding: 8px 0; }
  .bs-line { min-height: 64px; margin-bottom: 10px; }
  .mc-options { gap: 8px; }
}
/* Letter writing practice (write.js, writing/pad.js) */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.write-grid { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.write-cell {
  position: relative; display: flex; align-items: center; justify-content: center; min-height: 76px; color: inherit;
  text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.write-cell:hover, .write-cell:focus-visible { border-color: var(--accent); }
.write-cell.done { border-color: var(--ok); }
.write-cell .lao { font-size: calc(2.4rem * var(--lao-scale, 1)); }
.write-mark { position: absolute; top: 2px; right: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--ok); }
.write-head-letter { font-size: 1.6rem; font-weight: 600; }
.write-hint { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 16px; text-align: center; }
.write-hint:empty { display: none; }
.write-hint-sound { font-weight: 600; }
.write-hint-word { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; }
.write-body { display: flex; flex-direction: column; align-items: center; text-align: center; }
.write-instruction { margin: 0 0 8px; min-height: 3em; }
.write-feedback { min-height: 3.2em; margin-top: 8px; }
.write-feedback p { margin: 0; }
.write-result { display: flex; align-items: center; gap: var(--sp-1); font-weight: 600; }
.write-feedback .write-result, .write-body .write-result { justify-content: center; }
.write-result.ok { color: var(--ok); }
.write-result.miss { color: var(--danger); }
.write-frame .stage > .actions { flex-wrap: wrap; justify-content: center; gap: 10px; }
.write-frame .actions button { min-height: 48px; min-width: 96px; }
/* The pad: a square that leaves room for the instruction and the buttons on one phone screen. */
.write-pad {
  flex: none; display: block; width: min(100%, 420px, 55vh); width: min(100%, 420px, 55dvh); aspect-ratio: 1;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.write-pad.drawable { cursor: crosshair; border-color: var(--accent); }
.write-pad polyline, .write-arrow { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.write-rule { stroke: var(--border); stroke-width: 0.4; stroke-dasharray: 1.5 1.5; }
.write-guide { stroke: var(--border); stroke-width: 7; }
.write-highlight { stroke: var(--accent); stroke-width: 7; opacity: 0.4; }
.write-solid { stroke: var(--fg); stroke-width: 4; }
.write-ink { stroke: var(--fg); stroke-width: 3.5; }
/* off the path: dashed as well as coloured */
.write-ink.off { stroke: var(--danger); stroke-dasharray: 0.5 5; }
.write-answer { stroke: var(--accent); stroke-width: 4; opacity: 0.4; }
.write-answer.ok { stroke: var(--ok); opacity: 0.85; }
.write-demo { stroke: var(--fg); stroke-width: 4; }
.write-pen, .write-dot { fill: var(--accent); }
.write-arrow { stroke: var(--fg); stroke-width: 1.3; }
@media (max-height: 720px) {
  .write-instruction { min-height: 0; }
  .write-feedback { min-height: 2.6em; }
}

/* S7b: dry run label, leave dialog, audio button */
.badge.dry { position: static; flex: none; align-self: flex-start; width: fit-content; margin: 0 0 8px; border-color: var(--muted); color: var(--muted); } /* under the lesson head, not the corner */
dialog.confirm { max-width: 26rem; }
dialog.confirm .actions { flex-wrap: wrap; gap: var(--sp-3); }
dialog.confirm .actions.leave-discard { margin-top: var(--sp-3); }
.audio-btn { min-width: 44px; min-height: 44px; margin-left: 8px; vertical-align: middle; }
/* A1: play + report chips, voice credit */
.audio-ctl { display: inline-flex; flex: none; margin-left: 8px; flex-wrap: nowrap; align-items: center; gap: 4px; vertical-align: middle; }
.audio-ctl .audio-btn { margin-left: 0; }
.answer-line .audio-ctl { margin-left: 0; }
/* A7 step 5: the speaker is the one audio control on a card face, in the accent colour; the voice credit and the report are in
   "More" (the info sheet), small and quiet */
.audio-btn { border-color: var(--accent); color: var(--accent); }
/* the quiet 0.75x button beside the speaker: small text, no tint, same 44px touch height, inline in .audio-ctl */
.audio-slow { min-width: 44px; min-height: 44px; margin: 0; padding: 0 var(--sp-3); gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-pill); color: var(--accent); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.audio-slow:hover { background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
/* the icon is bigger than the old emoji, inside the same 44px button; a pale tint behind it makes the waves show */
.audio-btn:not(.audio-big) { background: color-mix(in srgb, var(--accent) 12%, var(--card)); padding: 0; width: 44px; height: 44px; border-radius: var(--r-circle); display: inline-flex; align-items: center; justify-content: center; }
.speaker-icon { display: block; }
.audio-extras { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.audio-extras .audio-credit { font-size: var(--fs-sm); margin: 0; }
button.link.audio-report { color: var(--muted); font-size: var(--fs-sm); justify-content: flex-start; gap: 6px; }

/* S7e: fill in the blank */
.fb-sentence { font-size: calc(clamp(1.9rem, 8.5vw, 2.6rem) * var(--lao-scale, 1)); font-weight: 600; text-align: center; margin: 4px 0 16px; }
.fb-sentence.long { font-size: calc(1.7rem * var(--lao-scale, 1)); }
.fb-gap { display: inline-block; min-width: 2.2em; border-bottom: 3px solid var(--accent); vertical-align: baseline; }
.fb-fill { text-decoration: underline; text-underline-offset: 0.2em; }
.fb-fill.right { color: var(--ok); }

/* S7d: build the word; the pieces line on word cards */
.bw-meaning { padding: 4px 0; }
.bw-line .bs-tile.placed { display: inline-flex; align-items: center; justify-content: center; }
.bw-plus { font-size: var(--fs-xl); color: var(--muted); }
.bw-word { font-size: calc(clamp(2.6rem, 14vw, 3.6rem) * var(--lao-scale, 1)); }
.bw-answer { display: flex; justify-content: center; } /* the word once, large, under the compare grid */
/* "= word" stays together on one line (its height comes from the Lao ink rule) */
.bw-equals { display: inline-flex; align-items: center; gap: 10px; }
.bs-tile.wrong { border: 2px solid var(--danger); color: var(--danger); }
/* L1c: build the word slots (one per piece, in reading position); "Your answer" over "Right answer" (compare.js),
   one column per word on wide screens (scrolling sideways if a long answer does not fit), wrapping rows under the label below 560px; the first-time how-to */
.bs-tile.slot { display: inline-flex; border: 2px dashed var(--control-border); background: transparent; }
.cmp { overflow-x: auto; margin: 0 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--danger); }
.cmp-grid { display: grid; grid-template-columns: auto repeat(var(--cols), auto); gap: 6px 8px; justify-content: center;
  align-items: center; width: max-content; min-width: 100%; }
.cmp-row { display: contents; }
.cmp-label { font-size: var(--fs-sm); color: var(--muted); text-align: left; white-space: nowrap; }
@media (max-width: 559px) {
  /* the rows wrap instead of scrolling; each label is a narrow two-line column at its row's start (U1: a row of its
     own cost ~45px of a phone screen) */
  .cmp-grid { display: block; width: auto; }
  .cmp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-bottom: 6px; }
  .cmp-label { flex: none; width: 4.6em; white-space: normal; line-height: 1.15; }
  .cmp .cmp-cell { min-width: 44px; padding: 0 6px; }
  .cmp-cell.empty { display: none; }
}
.cmp-cell { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 48px;
  padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-sm); white-space: nowrap; }
.cmp-cell .lao { font-size: calc(1.6rem * var(--lao-scale, 1)); }
.cmp-cell .mc-mark { font-weight: 700; }
.cmp-cell.bad { border: 2px solid var(--danger); color: var(--danger); }
.cmp-cell.need { border: 2px solid var(--ok); color: var(--ok); font-weight: 600; }
.cmp-cell.gap { border: 2px dashed var(--danger); color: var(--danger); font-size: var(--fs-sm); }
.cmp-cell.empty { border-color: transparent; }
.cmp-note { margin: 8px 0 0; }
.cmp-note .lao { font-size: calc(1.4em * var(--lao-scale, 1)); }
.howto { margin: 2px auto 10px; max-width: 34em; text-align: center; font-size: var(--fs-sm); color: var(--muted); }
.howto p { margin: 2px 0; }
.howto .lao { font-size: calc(1.4em * var(--lao-scale, 1)); }
.same-sound .lao { font-size: calc(1.4rem * var(--lao-scale, 1)); }
.pieces { margin: 4px 0 8px; }
.pieces .lao { font-size: calc(1.8rem * var(--lao-scale, 1)); }
/* R1 register tag: a quiet outline pill, text and edge from existing tokens (works in every palette, light and dark). */
.register-row { margin: 2px 0 6px; }
.register-tag { display: inline-block; font-size: var(--fs-xs); font-weight: 600; padding: 1px 10px; border-radius: var(--r-pill); border: 1px solid var(--control-border); color: var(--muted); white-space: nowrap; }
/* A5 usage note under the meaning: a quiet box, the culture badge inline next to its label (not the corner badge). */
.usage-note { margin: 8px 0 4px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: var(--r-sm); }
.usage-note p { margin: 0; line-height: 1.6; }
.usage-note .usage-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.note-badge { font-size: var(--fs-xs); padding: 1px 8px; border-radius: var(--r-pill); border: 1px solid var(--ok); color: var(--ok); }
.note-badge.culture { position: relative; padding: 2px 10px; font-size: var(--fs-xs); border-color: var(--warm); background: var(--warm); color: var(--on-warm); }
.note-badge.culture::before { content: '\2726\00a0'; content: '\2726\00a0' / ''; } /* a four-pointed star, decorative */
/* the flourish: the badge pops in once and a light sweeps across it; none with reduced motion */
.badge.bonus::after, .note-badge.culture::after { content: none; }
@media (prefers-reduced-motion: no-preference) {
  .badge.bonus, .note-badge.culture { animation: badge-pop 420ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
  .badge.bonus::after, .note-badge.culture::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 30%, rgb(255 255 255 / 0.45) 50%, transparent 70%);
    transform: translateX(-120%); animation: badge-shine 900ms ease-out 350ms 1 both;
  }
}
@keyframes badge-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes badge-shine { to { transform: translateX(120%); } }
.pieces .piece.fresh { font-weight: 700; text-decoration: underline; text-underline-offset: 0.25em; color: var(--accent); }
.piece-note { font-size: var(--fs-sm); }

/* Unit cards: "Hear it in a word" (unit_word.js). The unit's characters inside the word are in the accent colour
   and underlined (colour is not the only signal). */
.unit-word { display: flex; flex-direction: column; align-items: center; margin: 4px 0 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg); }
.unit-word-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; margin: 0; }
.unit-word-lao { font-size: calc(1.7rem * var(--lao-scale, 1)); }
.unit-hl { color: var(--accent); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.unit-word-sound { font-size: var(--fs-md); font-weight: 600; }
.unit-word-means { color: var(--muted); }
.unit-word .audio-ctl { margin-left: 0; }

/* Native home and recording mode (record.js) */
a.role-card { color: inherit; text-decoration: none; }
.role-card.primary-task { border: 2px solid var(--accent); }
.back-home { max-width: var(--content-max); margin: 8px auto 0; padding: 0 16px; }
.back-home a { display: inline-block; padding: 10px 0; color: var(--accent); }
.tips { padding-left: 20px; line-height: 1.7; margin: 0 0 16px; }
.welcome { border-left: 4px solid var(--accent); padding: 10px 14px; margin: 0 0 12px; background: var(--bg); border-radius: var(--r-sm); }
.start-here { margin-left: 8px; padding: 2px 8px; border-radius: var(--r-pill); background: var(--accent-fill); color: var(--on-accent); font-size: var(--fs-xs); vertical-align: middle; }
/* N3: toggle buttons (dom.js toggles), at most one selected; a second tap unselects */
.toggles { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
button.toggle { min-height: 44px; padding: 8px 14px; border-radius: var(--r-pill); }
button.toggle[aria-pressed='true'] { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); font-weight: 600; }
button.toggle[aria-pressed='true']::before, button.choice[aria-pressed='true']::before { content: ''; display: inline-block; width: 1em; height: 1em; margin-right: 0.35em; vertical-align: -0.15em; background: currentColor;
  -webkit-mask: var(--mask-check) center / contain no-repeat; mask: var(--mask-check) center / contain no-repeat; }
.own-links { align-items: flex-start; gap: 4px; margin-top: 8px; }
.own-links button.link, .actions.split button.link { min-height: 44px; }
.lao-input { font-size: calc(1.4rem * var(--lao-scale, 1)); line-height: 1.8; }
/* Keyboard (A6 #6, session.js onKey): on a desktop with a mouse, a small number in the corner of each option and
   bank tile (1-9, the keys that pick them) and one muted line of keys under the lesson. Hidden on touch screens
   and phone-sized windows (A7 step 9). */
.kbd-hint { display: none; }
/* Settings "Keyboard shortcuts" off (html.no-keys, settings.js): no key line and no key numbers */
@media (hover: hover) and (pointer: fine) and (min-width: 561px) {
  .lesson-frame .kbd-hint { display: block; flex: none; margin: 6px 0 0; font-size: var(--fs-xs); text-align: center; }
  .lesson-frame .mc-options, .lesson-frame .bs-bank { counter-reset: key; }
  .lesson-frame .bs-bank > button { position: relative; }
  .lesson-frame .bs-bank > * { counter-increment: key; } /* ghosts keep their number: keys follow the slot */
  .lesson-frame .mc-option:not(:disabled) { counter-increment: key; }
  .lesson-frame .mc-option:not(:disabled)::before, .lesson-frame .bs-bank > button::before {
    content: counter(key); position: absolute; top: 3px; left: 6px;
    font-size: var(--fs-xs); line-height: 1; color: var(--muted); font-weight: 400;
  }
  .lesson-frame .bs-bank > button:nth-child(n + 10)::before { content: none; }
  .no-keys .lesson-frame .kbd-hint { display: none; }
  .no-keys .lesson-frame .mc-option:not(:disabled)::before, .no-keys .lesson-frame .bs-bank > button::before { content: none; }
}

/* A7 step 1: the settings page (settings.js) and the sound-spelling example on lesson 1's intro card */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.settings-page h3 { margin: 20px 0 4px; }
.settings-page h1 + h3 { margin-top: 8px; }
/* The sound spelling card (lesson 2): the two k letters, each written in both styles; the chosen row is marked. */
/* A16: lesson 2's style table is the control: a head row (ກ ຂ), then one button per style with the same columns */
.style-table { display: grid; gap: var(--sp-2); margin: 8px 0 12px; }
.style-head, .style-row { display: grid; grid-template-columns: minmax(7.5rem, 1.2fr) repeat(var(--cols, 2), minmax(0, 1fr)); align-items: center; column-gap: var(--sp-2); text-align: center; }
.style-head { padding: 0 var(--sp-3); }
.style-head > .lao { font-size: calc(2.6rem * var(--lao-scale, 1)); }
.style-row { width: 100%; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--control-border); border-radius: var(--radius); background: var(--card); color: var(--fg); }
.style-name { display: flex; align-items: center; gap: var(--sp-1); text-align: left; font-weight: 600; }
.style-check { display: inline-flex; width: 18px; visibility: hidden; color: var(--accent); }
.style-hint { grid-column: 1 / -1; text-align: left; font-size: var(--fs-sm); color: var(--muted); line-height: 1.4; margin-top: 2px; }
.style-row.chosen { border: 2px solid var(--accent); padding: calc(var(--sp-2) - 1px) calc(var(--sp-3) - 1px); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.style-row.chosen .style-name, .style-row.chosen .cell-big { color: var(--accent); }
.style-row.chosen .style-check { visibility: visible; }

/* A7 step 2: the slim learner header (app.js; one line, hidden in lessons) and the lesson chrome (session.js):
   close icon (44px), progress bar, "12 / 40" */
.topbar.slim { flex-wrap: nowrap; }
/* the brand gives way first; the links never clip (they wrap onto two lines only at very narrow widths) */
.topbar.slim strong { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-links { display: inline-flex; flex: none; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0 4px; max-width: 75%; }
.topbar-links > * { white-space: nowrap; }
.lesson-close {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px;
  margin: -8px 0 -8px -10px; padding: 0; border: 0; border-radius: var(--r-circle); background: none; color: var(--muted);
  line-height: 1; text-decoration: none;
}
.lesson-close:hover { color: var(--fg); background: var(--bg); }
.lesson-close:active { background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.lesson-head .session-progress { flex: 1; }
.session-counter { flex: none; min-width: 3.5em; text-align: right; font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* A20: the retries of missed questions, after the bar is full: their own line under the bar */
.lesson-head .session-counter.retry { order: 10; flex-basis: 100%; text-align: left; color: var(--fg); font-weight: 600; }
h1[tabindex='-1']:focus { outline: none; } /* a heading focused by code on a new screen (settings.js) */

/* A7 step 3: home (home.js): the Continue card, the compact lesson path, the folded rest */
.home-greeting { margin: 0 0 var(--sp-2); }
/* the Continue card: text on the left, the button on the right (thumb side); the summary only where there is room */
.continue-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 12px;
  border: 2px solid var(--accent); border-radius: var(--radius); background: var(--bg);
}
.continue-text { flex: 1; min-width: 0; }
.continue-card h2 { margin: 0; font-size: var(--fs-md); line-height: 1.35; }
.continue-card .btn { flex: none; padding-inline: 18px; }
.continue-summary { margin: 4px 0 0; }
/* L6: the lesson's payoff in one line, phones included */
/* wraps: never cut off with an ellipsis */
.continue-summary, .path-summary { overflow-wrap: anywhere; }
.path-summary { display: block; font-size: var(--fs-sm); font-weight: 400; }
.continue-label { margin: 0 0 2px; font-size: var(--fs-sm); font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
a.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 22px;
  border-radius: var(--r-sm); border: 1px solid var(--control-border); background: var(--card); color: inherit; text-decoration: none; font-weight: 600; }
a.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
/* The Lessons page (lessons.js): an accordion of chapter panes, like a book's table of contents. Each chapter is one
   pane: a title header (the only control; one chapter open at most) and, when open, its lessons as a step list hung
   under the header's badge, indented so the header reads as their title. States: done (green check), in progress
   (the chapter number in an accent badge, a progress bar), locked (dashed pane, muted text, a lock, and the line
   naming the chapter that unlocks it). The lesson to pick up is the one boxed row, with a visible Start / Continue. */
.chapters { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); margin-top: var(--sp-3); }
.chapter {
  --badge: 32px; --mark: 24px; --gutter: var(--sp-4); /* the badge and the marks share one centre line */
  scroll-margin-top: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden;
}
.chapter.is-open { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 6px 16px rgb(0 0 0 / 0.06); }
.chapter-h { margin: 0; font-size: var(--fs-md); font-weight: 400; }
.chapter-head {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 72px; margin: 0;
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--gutter); text-align: left;
  font: inherit; color: inherit; border: 0; border-radius: 0; background: var(--bg);
}
button.chapter-head { cursor: pointer; }
button.chapter-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: var(--radius); }
@media (hover: hover) { button.chapter-head:hover { background: color-mix(in srgb, var(--accent) 7%, var(--bg)); } }
button.chapter-head:not(:disabled):active { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); transform: none; }
.chapter.is-open .chapter-head { border-bottom: 1px solid var(--border); }
.chapter-badge {
  flex: none; display: flex; align-items: center; justify-content: center; width: var(--badge); height: var(--badge);
  border-radius: var(--r-circle); font-weight: 700; font-size: var(--fs-md); font-variant-numeric: tabular-nums;
  background: var(--accent-fill); color: var(--on-accent);
}
.chapter.done .chapter-badge { background: color-mix(in srgb, var(--ok) 16%, var(--card)); color: var(--ok); }
.chapter.locked .chapter-badge { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--control-border); }
.chapter-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.chapter-label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.chapter-title { font-size: var(--fs-lg); font-weight: 700; line-height: 1.25; }
.chapter-meta { font-size: var(--fs-sm); line-height: 1.35; color: var(--muted); }
.chapter.done .chapter-meta { color: var(--ok); font-weight: 600; }
.chapter-bar { display: block; height: 4px; max-width: 220px; margin-top: var(--sp-1); border-radius: var(--r-pill); background: var(--border); overflow: hidden; }
.chapter-bar > span { display: block; height: 100%; min-width: 4px; border-radius: inherit; background: var(--accent); }
/* the chevron in a round well: down while closed, up while open */
.chapter-chev { flex: none; position: relative; width: 36px; height: 36px; border-radius: var(--r-circle); color: var(--accent); }
.chapter-chev::before {
  content: ''; position: absolute; inset: 9px; background: currentColor; transform: rotate(-90deg);
  -webkit-mask: var(--mask-chevron) center / contain no-repeat; mask: var(--mask-chevron) center / contain no-repeat;
}
@media (hover: hover) { button.chapter-head:hover .chapter-chev { background: color-mix(in srgb, var(--accent) 12%, transparent); } }
.chapter-head[aria-expanded='true'] .chapter-chev::before { transform: rotate(90deg); }
.chapter.locked { border-style: dashed; background: transparent; }
.chapter.locked .chapter-head { background: transparent; color: var(--muted); min-height: 64px; }
.chapter.locked .chapter-title { font-size: var(--fs-md); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  button.chapter-head { transition: background-color var(--ease); }
  .chapter-chev::before { transition: transform var(--ease); }
  .chapter-body:not([hidden]) { animation: chapter-in 180ms ease-out; }
}
@keyframes chapter-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* the open chapter's body: the step list, its line through the marks under the header's badge */
.chapter-body { padding: var(--sp-3) var(--sp-3) var(--sp-4) calc(var(--gutter) + (var(--badge) - var(--mark)) / 2); }
.chapter-summary { margin: 0 0 var(--sp-3) calc(var(--mark) + var(--sp-2)); font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.path { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-1); }
.path-row { position: relative; display: flex; align-items: center; gap: var(--sp-2); }
.path-row.current { scroll-margin-bottom: var(--sp-6); } /* brought on screen at load (lessons.js) with room under it */
.path-row::before { /* the step line: from this mark's centre to the next one's */
  content: ''; position: absolute; left: calc(var(--mark) / 2 - 1px); top: 0; bottom: calc(-1 * var(--sp-1)); width: 2px; background: var(--border);
}
.path-row:first-child::before { top: 50%; }
.path-row:last-child::before { bottom: 50%; }
.path-row:only-child::before { display: none; }
.path-mark {
  position: relative; flex: none; display: flex; align-items: center; justify-content: center; width: var(--mark); height: var(--mark);
  border-radius: var(--r-circle); background: var(--card); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent);
}
.path-row.done .path-mark { background: color-mix(in srgb, var(--ok) 16%, var(--card)); color: var(--ok); box-shadow: none; }
.path-row.current .path-mark { background: var(--accent-fill); color: var(--on-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, var(--card)); }
.path-row.locked .path-mark { color: var(--muted); box-shadow: inset 0 0 0 1px var(--control-border); }
.path-link {
  flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); min-height: 48px; padding: var(--sp-1) var(--sp-3);
  color: inherit; text-decoration: none; border: 1px solid transparent; border-radius: var(--r-sm);
}
@media (hover: hover) { a.path-link:hover { background: color-mix(in srgb, var(--accent) 7%, var(--card)); } }
/* number | title on one baseline, the summary under the title; wraps on phones, never clipped. The 8rem basis: with
   large text the Start pill wraps under the title instead of squeezing it. */
.path-name {
  flex: 1 1 8rem; min-width: 0; display: grid; grid-template-columns: minmax(2ch, auto) minmax(0, 1fr); column-gap: var(--sp-2); align-items: baseline;
  padding: var(--sp-1) 0; line-height: 1.35; overflow-wrap: anywhere;
}
.path-name .lesson-num { min-width: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.path-summary { grid-column: 2; margin-top: 2px; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); overflow-wrap: anywhere; }
.path-row.current .path-link { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--card)); padding-block: var(--sp-2); }
.path-row.current .path-name { font-weight: 600; }
.path-row.current .lesson-num { color: var(--accent); }
.path-go {
  flex: none; margin-left: auto; display: inline-flex; align-items: center; min-height: 32px; padding: 0.25em var(--sp-3); border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; background: var(--accent-fill); color: var(--on-accent);
}
.path-row.locked .path-link { color: var(--muted); }
.path-side {
  flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--sp-3); font-size: var(--fs-sm); font-weight: 600;
  color: var(--accent); text-decoration: none; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent;
}
@media (hover: hover) { a.path-side:hover { border-color: var(--control-border); } }
/* the checkpoint: the chapter's last step, lined up with the lesson rows */
.chapter-body .checkpoint-card { margin: var(--sp-3) 0 0 calc(var(--mark) + var(--sp-2)); padding: var(--sp-3); border-width: 1px; border-color: var(--border); }
.chapter-body .checkpoint-card.open { border: 2px solid var(--accent); }
.chapter-body .checkpoint-card h3 { margin: 0; font-size: var(--fs-md); line-height: 1.35; }
.chapter-body .checkpoint-card p { margin-bottom: 0; }
@media (max-width: 420px) {
  .chapter-head { gap: var(--sp-2); padding-right: var(--sp-2); }
  .chapter-body { padding-right: var(--sp-2); }
  .path-link { padding-inline: var(--sp-2); }
  .path-side { padding-inline: var(--sp-2); }
  .chapter-body .checkpoint-card { flex-wrap: wrap; }
  .chapter-body .checkpoint-card .btn { margin-left: auto; }
}

/* A7 step 4: the summary's buttons: Back home, then Next lesson on the right (thumb side) */
.summary-actions { justify-content: center; flex-wrap: wrap; gap: 12px; }
.summary-actions .btn { min-width: 140px; }

/* A7 step 7: the brand dot in the learner header (the palette's warm colour) and the colour-theme swatches in
   Settings (each swatch carries data-palette, so it shows that palette's tokens in the current light or dark) */
.brand-dot { display: inline-block; width: 0.7em; height: 0.7em; margin-right: 0.45em; border-radius: var(--r-circle); background: var(--warm); vertical-align: 0.02em; }
.swatch { display: inline-flex; gap: 3px; margin-left: 8px; padding: 3px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--bg); vertical-align: middle; }
.swatch i { width: 16px; height: 16px; border-radius: var(--r-circle); }
.swatch i:nth-child(1) { background: var(--accent); }
.swatch i:nth-child(2) { background: var(--warm); }

/* A7 step 8: home's section tiles (home.js; navigation model B, no tab bar) and the Lessons page (lessons.js).
   2 columns on a phone, 3 where there is room. Live tiles are links; "Soon" tiles are greyed (muted text, 4.5:1 or
   more, dashed edge, "Soon" written out), not focusable, aria-disabled. */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--sp-2); }
/* Review: a full-width bar under the lesson card, outlined and accent-tinted, shorter than a tile. The grid under it
   holds 4 tiles, so 2 columns everywhere (no orphan cell). */
/* Review: the same card as the lesson card (.continue-card), with a lighter tint and edge instead of the solid outline */
.review-card { border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.review-card.soon { border: 1px dashed var(--border); background: transparent; }
.review-card.soon h2 { color: var(--muted); font-weight: 600; }
.tile {
  display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 64px; padding: 10px 12px;
  color: inherit; text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
a.tile:hover, a.tile:focus-visible { border-color: var(--accent); }
.tile-title { font-weight: 700; color: var(--accent); }
.tile-sub { font-size: var(--fs-sm); line-height: 1.3; color: var(--muted); }
.tile.soon { border-style: dashed; background: transparent; cursor: default; }
.tile.soon .tile-title { color: var(--muted); font-weight: 600; }


/* ---- A9 My words (words.js: #/words, #/words/<id>) ---- */
.words-search {
  width: 100%; min-height: 44px; margin: 4px 0 8px; padding: 10px; font: inherit; color: inherit;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm);
}
.words-filters { gap: 6px; margin-bottom: 4px; }
.words-filters .chip[aria-pressed='true'] { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); font-weight: 600; }
.words-count { margin: 4px 0; font-size: var(--fs-sm); }
.words-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.word-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 12px; color: inherit; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
a.word-row:hover, a.word-row:focus-visible { border-color: var(--accent); }
.word-lao { flex: none; font-family: var(--lao-font, 'Leelawadee UI', 'Noto Sans Lao', sans-serif); font-size: calc(1.6rem * var(--lao-scale, 1)); }
.word-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.word-respell { font-weight: 600; }
.word-gloss { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-tags { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.level-badge { display: inline-block; padding: 1px 8px; font-size: var(--fs-xs); font-weight: 600; border: 1px solid var(--muted); border-radius: var(--r-pill); color: var(--muted); white-space: nowrap; }
.level-badge.level-3, .level-badge.level-4 { border-color: var(--accent); color: var(--accent); }
.word-bonus { font-size: var(--fs-xs); font-weight: 700; color: var(--accent); white-space: nowrap; }
.word-bonus::before { content: '\2605\00a0'; content: '\2605\00a0' / ''; }
.word-stats h2, .word-examples h2 { font-size: var(--fs-md); margin: 16px 0 6px; }
.word-stat-lines { margin: 0; padding-left: 1.2em; line-height: 1.8; }
.word-example { padding: 8px 0; border-top: 1px solid var(--border); }
.word-example p { margin: 0 0 2px; }
.word-example .lao { font-size: calc(1.6rem * var(--lao-scale, 1)); }

/* A8 Letters and sounds (letters.js): #/letters groups of tiles (Lao glyph + its sound), #/letters/<id> the unit's
   card, the known words that contain it (the unit highlighted as on the card's "Hear it in a word"), its lesson. */
.letters-group h2 { font-size: var(--fs-md); margin: 16px 0 6px; }
.letters-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.letters-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 84px; padding: 4px;
  color: inherit; text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.letters-cell:hover, .letters-cell:focus-visible { border-color: var(--accent); }
.letters-cell .lao { font-size: calc(2.2rem * var(--lao-scale, 1)); }
.letters-sound { font-weight: 600; font-size: var(--fs-sm); color: var(--accent); }
.letters-more { margin-top: 16px; }
.letters-examples h2 { font-size: var(--fs-md); margin: 16px 0 6px; }
.letters-words { list-style: none; padding: 0; margin: 0; }
.letters-words li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 48px; padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.letters-words .unit-word-lao { font-size: calc(1.7rem * var(--lao-scale, 1)); }
.letters-words .audio-ctl { margin-left: auto; }
/* A8: a letter's sounds at the start / end of a syllable, above its card(s) */
.letters-roles { list-style: none; padding: 0; margin: 0 0 8px; text-align: center; }
.letters-roles strong { font-size: var(--fs-lg); }
.mc-hint-sound { display: block; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.practice-times { display: grid; gap: 10px; margin: 16px 0; }
.practice-times button { min-height: 52px; font-size: var(--fs-md); }

/* N1/N2 native screens: open questions, word suggestions, confirm */
.respelling { color: var(--muted); font-size: var(--fs-lg); margin: 2px 0 0; }
.q-text { font-size: var(--fs-lg); line-height: 1.5; margin: 8px 0; }
.choices { display: grid; gap: 10px; margin: 12px 0; }
button.choice { display: grid; gap: 2px; text-align: left; min-height: 56px; padding: 12px 16px; font-size: var(--fs-md); border-radius: var(--radius); }
button.choice[aria-pressed='true'] { border: 2px solid var(--accent); font-weight: 600; }
button.choice[aria-pressed='true']::before { color: var(--accent); }
.choice-lo { color: var(--muted); font-weight: 400; }
label.free-text, label.field { display: grid; gap: 4px; margin: 12px 0; font-weight: 600; }
label.free-text textarea, label.field input, label.field textarea { font-weight: 400; }
.actions.split { justify-content: space-between; }
.actions.split > button.primary { margin-left: auto; } /* the primary button stays right when it is alone */
.actions.split button.primary, .actions.vote button.primary { min-height: 48px; min-width: 140px; }
.actions.vote { flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.actions.vote button { min-height: 48px; }
.detail { margin: 6px 0; }
.example { border-top: 1px solid var(--border); margin-top: 8px; }
.my-suggestion { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--border); }
form + h2 { margin-top: 32px; }

/* U1/U2: the settings sheet (chrome.js), the report dialog (report.js) and the report and settings buttons of the header and the lesson chrome */
.chrome-btns { display: inline-flex; align-items: center; flex: none; }
button.chrome-btn { min-width: 44px; text-decoration: none; }
/* every icon-only control: a 44px circle, the icon in the muted text colour (its name is the aria-label) */
button.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px;
  padding: 0; border: 0; border-radius: var(--r-circle); background: none; color: var(--muted); line-height: 1;
}
button.icon-btn:not(:disabled):active { background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.lesson-head .chrome-btns { margin: -8px -10px -8px 0; }
.lesson-head .menu-btn { margin: -8px -10px -8px 0; }
/* U1 step 5: the lesson's ⋯ menu (chrome.js lessonMenu), a small list under the button at the top right */
dialog.menu { position: fixed; inset: calc(env(safe-area-inset-top, 0px) + 52px) max(8px, calc((100vw - var(--content-max)) / 2)) auto auto; margin: 0; padding: 4px; min-width: 13rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--fg); box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); }
dialog.menu::backdrop { background: rgb(0 0 0 / 0.15); }
.menu-list { display: grid; }
button.menu-row { display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--fg); text-align: left; font-size: var(--fs-md); }
button.menu-row .icon { color: var(--muted); }
button.menu-row:not(:disabled):active, button.menu-row:focus-visible { background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
@media (hover: hover) { button.menu-row:hover { background: var(--bg); } }
@media (hover: hover) { button.icon-btn:hover { color: var(--fg); background: var(--bg); } }
dialog.sheet { width: min(560px, calc(100vw - 16px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); padding: 0; overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 0 16px; flex: none; }
.sheet-head h2 { margin: 0; font-size: var(--fs-lg); }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 16px 16px; overscroll-behavior: contain; }
.sheet-head .info-x { margin-left: auto; }
.sheet-head .sheet-back { margin-left: -8px; }
/* U1 step 3: on a phone every sheet (info card, More, settings) is a bottom sheet up to 85% of the screen with its
   own scroll; the head (← title ✕) stays put. It slides up unless the learner asked for reduced motion. */
@media (max-width: 760px) {
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: 100%; max-height: 85vh; max-height: 85dvh; border-width: 1px 0 0; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
}
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: sheet-up 220ms ease-out; }
}
@keyframes sheet-up { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
/* a card's "More" (teach_card.js more): a quiet button in a lesson, the content inline in the info sheet */
.more-row { margin: 8px 0 0; text-align: center; }
button.more-btn { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; }
.more-chev { transform: rotate(180deg); }
.more-body { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); }
dialog.sheet > .actions { flex: none; padding: 8px 16px 12px; margin: 0; }
dialog.report-dialog { width: min(26rem, calc(100vw - 16px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }
.report-context-note { font-size: var(--fs-sm); margin: 4px 0; }

/* A7 rest: the sentence's words inline (teach_card.js inlineSentence). Each word is an underlined button. U1: the
   bubble is a popover (position: fixed; teach_card.js placeBubble sets left / top from the word's rect and flips it
   above the word with .above), so it takes no room; its pointer (--point) lines up with the word. */
.sentence-words { display: block; }
.teach > .sentence-words > .lao { font-size: calc(2.2rem * var(--lao-scale, 1)); font-weight: 600; }
.sentence-words > .center { text-align: center; }
button.word-btn {
  display: inline; min-height: 0; margin: 0; padding: 6px 1px; border: 0; border-radius: var(--r-sm); background: none;
  color: inherit; font: inherit; line-height: inherit; cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.18em; text-decoration-color: var(--accent);
}
button.word-btn[aria-expanded='true'] { background: var(--bg); text-decoration-color: var(--warm); }
button.word-btn.fb-fill.right { color: var(--ok); }
.word-bubble {
  --point: 50%;
  position: fixed; z-index: 45; left: 16px; top: 0; width: max-content; max-width: calc(100vw - 32px);
  display: flex; align-items: center; justify-content: center; gap: 4px 12px; flex-wrap: wrap;
  margin: 0; padding: 8px 12px; border: 1px solid var(--control-border); border-radius: var(--radius);
  background: var(--card); color: var(--fg); font-size: var(--fs-md); line-height: 1.4; font-weight: 400; text-align: center;
  white-space: normal; box-shadow: 0 4px 14px rgb(0 0 0 / 0.18);
}
.word-bubble::before {
  content: ''; position: absolute; top: -7px; left: var(--point); width: 12px; height: 12px; margin-left: -6px;
  background: var(--card); border: 1px solid var(--control-border); border-right: 0; border-bottom: 0; transform: rotate(45deg);
}
.word-bubble.above::before { top: auto; bottom: -7px; transform: rotate(225deg); }
/* U1 interlinear (inlineSentence sub / wordButton sub): each word a tappable column, its Lao underlined and its
   romanization small under it. Build the sentence's answered line and the compare grid's "Right answer" row. */
.ilw-line { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 4px 6px; }
button.word-btn.ilw { display: inline-flex; flex-direction: column; align-items: center; min-height: 44px; min-width: 44px; padding: 2px 6px; text-decoration: none; }
.ilw-lao { font-size: calc(1.8rem * var(--lao-scale, 1));
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.18em; text-decoration-color: var(--accent); }
button.word-btn.ilw[aria-expanded='true'] .ilw-lao { text-decoration-color: var(--warm); }
.ilw-sub { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: var(--fs-sm); font-weight: 400; line-height: 1.2; color: var(--muted); white-space: nowrap; }
.bs-line > .sentence-words { flex: 1 1 100%; }
.cmp-cell button.word-btn.ilw { min-width: 0; padding: 2px 0; color: inherit; }
.cmp-cell .ilw-lao { font-size: calc(1.6rem * var(--lao-scale, 1)); }
/* fill in the blank's answered line: the Lao keeps the line's size (no jump on answer); the filled word green */
.fb-sentence .ilw-lao { font-size: inherit; }
.fb-sentence button.word-btn.fb-fill.right .ilw-sub { color: var(--ok); font-weight: 600; }
.dlg-context .dlg-now .fb-sentence.ilw-line { justify-content: flex-start; }
.bubble-gloss { font-weight: 600; }
.bubble-sound { color: var(--muted); }
button.bubble-more {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: -8px -8px -8px 0; padding: 0; border: 0; border-radius: var(--r-circle); background: none; color: var(--accent);
}

/* A7 rest: the home stats strip (learner_stats) */
.home-stats { display: flex; justify-content: space-around; gap: 8px; margin: 12px 0; padding: 10px 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.home-stats[hidden] { display: none; }
.home-stat { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; flex: 1 1 0; }
.home-stat-num { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.2; color: var(--accent); }

/* A7 rest: the slim top bar wraps (brand on its own line) at narrow widths and large zoom instead of clipping */
@media (max-width: 400px) {
  .topbar.slim { flex-wrap: wrap; row-gap: 0; }
  .topbar-links { max-width: 100%; }
}

/* S7g conversations: the conversation card and the context above a line's fill in the blank. Speaker A sits left,
   B right, each with a letter badge (alignment is never the only cue). Bubbles use the card and border tokens, so
   both themes work without new colours; B gets the accent edge. */
.dlg-title { font-size: var(--fs-md); margin: 4px 0 2px; padding: 0 64px; text-align: center; } /* clear of the New / Review badge */
.dlg-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; }
.dlg-head p { margin: 0; }
.dlg-playall { display: inline-flex; align-items: center; gap: 4px; padding: 0 var(--sp-3); }
.dialogue { list-style: none; margin: 8px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dlg-line { max-width: 75%; }
.dlg-line.dlg-a { align-self: flex-start; }
.dlg-line.dlg-b { align-self: flex-end; }
/* the bubble: the speaker's name on top, then the Lao (with its ▶ right after it) and Reveal on the same row */
.dlg-bubble {
  min-width: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 10px;
}
.dlg-b .dlg-bubble { border-color: var(--accent); }
.dlg-line.dlg-playing .dlg-bubble { box-shadow: 0 0 0 3px var(--accent); background: var(--card); }
.dlg-speaker { min-width: 4.5rem; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.dlg-b .dlg-speaker { color: var(--accent); }
button.dlg-speaker { min-height: 36px; min-width: 0; padding: 0; text-align: left; justify-content: flex-start; text-decoration: underline dotted; background: none; border: 0; }
.dlg-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.dlg-part + .dlg-part { border-top: 1px dashed var(--border); padding-top: 4px; }
.dlg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.dlg-row .sentence-words { flex: 0 1 auto; min-width: 0; }
.dlg-lao { font-size: calc(1.5rem * var(--lao-scale, 1)); font-weight: 600; margin: 0; }
.dlg-sound { margin: 0; font-weight: 600; }
.dlg-reveal { padding: 0 var(--sp-3); }
.dlg-en { margin: 0; color: var(--muted); }
/* above a blank: earlier turns are smaller; the line being completed keeps the full fill-in-the-blank size */
.dlg-context { margin: 0 0 8px; }
.dlg-context .dlg-line:not(.dlg-now) .dlg-lao { font-size: calc(1.3rem * var(--lao-scale, 1)); }
.dlg-context .dlg-line { max-width: 85%; }
.dlg-context .dlg-now { max-width: 100%; align-self: stretch; }
.dlg-context .dlg-now .fb-sentence { margin: 0; text-align: left; font-size: calc(clamp(1.8rem, 8vw, 2.4rem) * var(--lao-scale, 1)); } /* as a revealed line */

/* A7a large screens, height first. The dry-run chip sits in the head row's wrap (under it on phones). */
.lesson-head { flex-wrap: wrap; }
.lesson-head .badge.dry { order: 10; flex-basis: 100%; margin: 0; }
/* Mouse devices: the same fixed frame as a phone (owner 2026-11-20: nothing moves on any screen), centred, 820px
   wide and at most 760px tall: the prompt at the top, the options low in the column, hints and answer cards in the
   room between, and the button always in the frame's bottom right corner (its slot is kept while it is absent).
   Questions are one 640px column. */
@media (hover: hover) and (pointer: fine) {
  body:has(.lesson-frame) #app { justify-content: center; }
  .card.lesson-frame { flex: 0 1 760px; max-width: 820px; margin: 0 auto; }
  .lesson-frame .stage > section.mc { width: 100%; max-width: 640px; margin-inline: auto; }
  .lesson-frame .mc-play .audio-slot { display: none; }
  .lesson-frame .mc-play { margin: 0; }
  .lesson-frame .audio-btn.audio-big, .lesson-frame .audio-big.spent { width: 64px; height: 64px; }
  .lesson-frame .glyph { font-size: calc(4.5rem * var(--lao-scale, 1)); }
  .lesson-frame .mc-option, .lesson-frame .mc-options.wide .mc-option { min-height: 60px; }
  .lesson-frame .mc-options.wide.short { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-frame .mc-options.letters .mc-option .lao { font-size: calc(3rem * var(--lao-scale, 1)); }
}
/* Short windows (laptops, 200% zoom): smaller hero, no key line, the chip beside the bar, no empty button slot */
@media (max-height: 560px) {
  .card.lesson-frame { padding-top: 8px; padding-bottom: 8px; }
  .lesson-frame .lesson-head { margin-bottom: 4px; }
  .lesson-head .badge.dry { order: 0; flex: none; }
  .lesson-frame .kbd-hint { display: none; }
  .lesson-frame .stage:not(:has(> .actions))::after { height: 44px; } /* the button's slot, kept so nothing moves */
  .lesson-frame .stage > .actions { min-height: 40px; margin-top: 4px; }
  .lesson-frame .glyph, .glyph { font-size: calc(2.8rem * var(--lao-scale, 1)); }
  .mc-prompt-en { font-size: var(--fs-lg); padding: 2px 0; }
  .mc-prompt { margin-bottom: 4px; }
  .tool-row { margin: 0 0 4px; }
  .lesson-frame .mc-option, .lesson-frame .mc-options.wide .mc-option { min-height: 44px; }
  .mc-question { margin: 0; }
  .lesson-frame .feedback { margin-top: 6px; gap: 4px; }
  .rc { padding: 2px 10px 4px; }
  .rc button.info-btn, .rc .audio-btn { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
  .lesson-frame .stage > .actions button.primary { min-height: 40px; }
  .lesson-frame section.mc > .mc-options { margin-top: 10px; }
  .lesson-frame .mc-options.letters .mc-option .lao { font-size: calc(2.2rem * var(--lao-scale, 1)); }
  .lesson-frame .mc-option { padding-block: 2px; }
  .lesson-frame .mc-option .lao { font-size: calc(1.7rem * var(--lao-scale, 1)); }
  .answer-sound { font-size: var(--fs-lg); }
  .lesson-frame .audio-btn.audio-big, .lesson-frame .audio-big.spent { width: 48px; height: 48px; }
}
@media (hover: hover) and (pointer: fine) and (max-height: 560px) {
  .lesson-frame .mc-options.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-frame .mc-options.wide .mc-option { font-size: var(--fs-md); }
}
/* short windows: the compare strip and the conversation context take less room */
@media (max-height: 560px) {
  .cmp { margin-bottom: 4px; }
  .cmp-grid { gap: 2px 6px; }
  .cmp-cell { min-height: 36px; }
  .cmp-cell .lao { font-size: calc(1.4rem * var(--lao-scale, 1)); }
  .cmp-note { margin-top: 2px; }
  .dlg-lao { font-size: calc(1.4rem * var(--lao-scale, 1)); }
  .dlg-context .dlg-line:not(.dlg-now) .dlg-lao { font-size: calc(1.15rem * var(--lao-scale, 1)); }
  .dlg-context { margin-bottom: 4px; }
  .dlg-context .dlg-now .fb-sentence { font-size: calc(1.8rem * var(--lao-scale, 1)); }
  .dlg-title { margin: 0; }
}

/* A7b: the desktop navigation rail (rail.js). From 1024px a slim left list under the header on every learner page
   but a lesson; the header's contents line up with the content column. Narrower windows keep the home tiles. */
.rail { display: none; }
@media (min-width: 1024px) {
  .topbar { padding-inline: max(16px, calc((100% - var(--content-max)) / 2)); }
  body.has-rail .topbar { padding-inline-start: calc(184px + max(16px, (100% - 184px - var(--content-max)) / 2)); padding-inline-end: max(16px, calc((100% - 184px - var(--content-max)) / 2)); }
  .rail:not([hidden]) {
    display: flex; flex-direction: column; gap: 2px; position: fixed; left: 0; top: var(--rail-top, 57px); bottom: 0; width: 184px;
    padding: var(--sp-3) var(--sp-2); overflow-y: auto; background: var(--card); border-right: 1px solid var(--border); z-index: 5;
  }
  body.has-rail #app { margin-left: 184px; }
  .rail-item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 44px; padding: 0 var(--sp-3); border-radius: var(--radius); color: var(--fg); text-decoration: none; }
  a.rail-item:hover { background: var(--bg); }
  a.rail-item[aria-current='page'] { color: var(--accent); font-weight: 600; background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
  .rail-item.soon { color: var(--muted); }
  .rail-soon { font-size: var(--fs-xs); }
}

/* A18: a word as the hero (not a single letter): the width of a long word (ພາສາອັງກິດ) never breaks it inside a syllable.
   Last in the file so it beats the .glyph rules of the height queries above. */
.glyph.word, .lesson-frame .glyph.word { font-size: calc(clamp(2.8rem, 15vw, 4.5rem) * var(--lao-scale, 1)); white-space: nowrap; word-break: keep-all; }
@media (max-height: 720px) { .glyph.word, .lesson-frame .glyph.word { font-size: calc(clamp(2.6rem, 13vw, 3.6rem) * var(--lao-scale, 1)); } }
@media (max-height: 560px) { .glyph.word, .lesson-frame .glyph.word { font-size: calc(2.4rem * var(--lao-scale, 1)); } }

/* A21a Full alphabet (alphabet.js): the "All letters" chart of #/letters. */
.letters-count { font-size: var(--fs-sm); font-weight: 400; }
.letters-legend { font-size: var(--fs-sm); margin: 4px 0; }
.letters-grid.chart { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.letters-grid.chart .letters-cell, .vowel-side .letters-cell { min-height: 76px; }
.letters-grid.chart .letters-cell .lao, .vowel-side .letters-cell .lao { font-size: calc(1.8rem * var(--lao-scale, 1)); }
.letters-grid.chart .letters-sound, .vowel-side .letters-sound { font-size: 0.78rem; }
.letters-class { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.vowel-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.vowel-head { font-size: var(--fs-sm); text-align: center; }
.vowel-side { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; align-content: start; }
.vowel-special p { margin: 8px 0 4px; font-size: var(--fs-sm); }

/* A21b: learned tiles ticked, every tile a link; the page of a letter not reached yet. */
.letters-cell { position: relative; }
.letters-cell.learned { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--bg)); }
.letters-check { position: absolute; top: 3px; right: 3px; display: inline-flex; color: var(--accent); }
.letters-hero { text-align: center; }
.letters-hero .glyph { font-size: calc(5rem * var(--lao-scale, 1)); }
/* A10 Notes: rows are buttons, groups are spaced like the summary sections */
.notes-row { width: 100%; text-align: left; font: inherit; cursor: pointer; }
button.word-row:hover, button.word-row:focus-visible { border-color: var(--accent); }
.notes-group h2 { font-size: var(--fs-md); margin: var(--sp-4) 0 var(--sp-2); }
