/* design system: lesson (merged into css/ui-kit.css before release)
   The lesson screens and everything that uses the lesson frame: exercises, the answer sheet, the finish screen,
   review cards, the placement test and the level test. Loaded right after css/ui-kit.css, so equal-specificity rules
   here win over css/style.css. Tokens only (css/ui-kit.css, section 1).
   Looks are wrapped in :where(html:not(.a11y-contrast)) so the high-contrast mode keeps its own colours and borders;
   layout (grids, sizes, the phone answer sheet) applies in every mode. The chalkboard (.cc-*, .bd-*) is not styled here. */

/* =====================================================================
   1. The lesson column and its top bar
   ===================================================================== */
.lesson { max-width: 720px; gap: var(--sp-4); }
html.in-lesson:has(#view > .lesson) { scroll-padding-top: 84px; } /* keyboard focus never lands under the sticky bar */

/* the bar spans the whole window (a hairline under it), its content stays on the lesson column */
:where(html:not(.a11y-contrast)).in-lesson .lesson-top {
  min-height: 64px; gap: var(--sp-3); padding-block: max(10px, env(safe-area-inset-top)) 10px;
  background: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
:where(html:not(.a11y-contrast)).in-lesson .lesson-top::before {
  content: ""; position: absolute; z-index: -1; inset-block: 0; inset-inline: calc(50% - 50vw);
  background: color-mix(in srgb, var(--bg) 90%, transparent); border-bottom: 1px solid var(--hairline);
  backdrop-filter: saturate(1.3) blur(14px); -webkit-backdrop-filter: saturate(1.3) blur(14px);
}
/* close: a drawn cross in a 44px key instead of the "×" character */
.lesson-top .icon-btn { flex: none; width: 44px; height: 44px; padding: 0; font-size: 0; border-radius: var(--r-sm); }
.lesson-top .icon-btn::before {
  content: ""; width: 22px; height: 22px; background: currentColor;
  -webkit-mask: var(--ico-close) center / contain no-repeat; mask: var(--ico-close) center / contain no-repeat;
}
:where(html:not(.a11y-contrast)) .lesson-top .icon-btn { color: var(--ink-2); background: transparent; }
/* Loading placeholder for a lesson step under the real top bar (docs/plan/2026-10-28-skeletons.md): the exercise
   label, the question, the word card, four answers and the button, each where the real one will land */
.ds-skel-lesson { display: grid; gap: var(--sp-4); padding-block: var(--sp-2) var(--sp-5); }
.ds-skel-lesson .sk-kind { --w: 6.5rem; height: 26px; }
.ds-skel-lesson .sk-q { --w: 75%; height: 1.6em; }
.ds-skel-lesson .sk-word { --h: clamp(140px, 36vw, 200px); border-radius: var(--r-lg); }
.ds-skel-lesson .sk-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.ds-skel-lesson .sk-opts > .ds-skel { --h: 56px; border-radius: var(--r); }
.ds-skel-lesson .sk-go { --w: 100%; height: 52px; border-radius: var(--r); }
:where(html:not(.a11y-contrast)) .lesson-top .icon-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
:where(html:not(.a11y-contrast)) .lesson-top .icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
/* the way out reads as a key, not a mark: a visible edge always, and from 600px its own words beside the cross
   (the button's aria-label, already in every language) (docs/plan/2026-11-04-where-to-click.md) */
:where(html:not(.a11y-contrast)) .lesson-top .icon-btn[data-nav] { border: 1.5px solid var(--hairline-strong); background: var(--surface); }
@media (min-width: 600px) {
  .lesson-top .icon-btn[data-nav] { width: auto; max-width: 14rem; gap: 6px; grid-auto-flow: column; padding-inline: 10px 14px; }
  .lesson-top .icon-btn[data-nav]::after { content: attr(aria-label); font: 600 var(--fs-sm)/1.2 var(--font-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
/* progress: a thick rounded bar in the level colour; a dot at the start so 0% already reads as a bar */
.lesson-top .progress { height: 12px; border-radius: var(--r-pill); }
:where(html:not(.a11y-contrast)) .lesson-top .progress { background: color-mix(in srgb, var(--lv, var(--accent)) 15%, var(--surface-2)); box-shadow: inset 0 1px 2px rgb(15 20 40 / .07); }
:where(html:not(.a11y-contrast)) .lesson > .lesson-top .progress > span {
  min-width: 12px; border-radius: inherit; background: var(--lv, var(--accent));
  box-shadow: inset 0 3px 0 -1px rgb(255 255 255 / .3);
}
.lesson-top .ex-count { flex: none; min-width: 3.4em; font: 600 .85rem/1 var(--font-ui); font-variant-numeric: tabular-nums; letter-spacing: .01em; text-align: center; color: var(--muted); }
.lesson-top .lv-chip { flex: none; height: 28px; min-width: 42px; font-size: .8rem; }

/* the lesson title above the exercise: quiet, with a dot in the level colour */
.lesson > .eyebrow {
  display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 calc(-1 * var(--sp-1));
  font: 500 var(--fs-sm)/1.35 var(--font-ui); letter-spacing: 0; text-transform: none; color: var(--muted);
}
.lesson > .eyebrow::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--lv, var(--accent)); }

/* =====================================================================
   2. Exercise header and prompt card
   ===================================================================== */
.lesson .ex-head { gap: var(--sp-2); }
.lesson .ex-head .q, .lesson > .q { margin: 0; font: 600 clamp(1.3rem, 1.15rem + .7vw, 1.6rem)/1.3 var(--font-ui); letter-spacing: -.01em; text-wrap: balance; }
:where(:lang(ru)) .lesson .ex-head .q, :where(:lang(ru)) .lesson > .q { letter-spacing: -.015em; }
.lesson > .q + .muted { margin-top: calc(-1 * var(--sp-2)); font-size: var(--fs-sm); }
.lesson .ex-kind { min-height: 28px; padding: 3px 11px 3px 9px; gap: 6px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .01em; border-radius: var(--r-pill); }
:where(html:not(.a11y-contrast)) .lesson .ex-kind {
  color: color-mix(in srgb, var(--lv, var(--accent)) 62%, var(--ink));
  background: color-mix(in srgb, var(--lv, var(--accent)) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--lv, var(--accent)) 22%, transparent);
}
.lesson .ex-sub { margin-top: calc(-1 * var(--sp-2)); font-size: var(--fs-sm); }

.lesson .prompt { min-height: 128px; padding: var(--sp-6) var(--sp-5); gap: var(--sp-3); border-radius: var(--r-lg); }
:where(html:not(.a11y-contrast)) .lesson .prompt {
  border: 1px solid var(--hairline); box-shadow: var(--e2);
  background: linear-gradient(180deg, color-mix(in srgb, var(--lv, var(--accent)) 5%, var(--surface)), var(--surface) 72%);
}
.lesson .prompt > .tgt { font-size: clamp(1.65rem, 1.35rem + 1.2vw, 2.05rem); font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.lesson .prompt.sentence, .lesson .prompt.sentence > .tgt { font-size: clamp(1.15rem, 1.05rem + .5vw, 1.35rem); line-height: 1.5; }
.lesson .prompt .native, .lesson .prompt.l1 { font: 600 clamp(1.35rem, 1.2rem + .6vw, 1.6rem)/1.3 var(--font-ui); }
.lesson .prompt-img { width: 112px; height: 112px; border-radius: var(--r); object-fit: cover; }
:where(html:not(.a11y-contrast)) .lesson .prompt-img { background: var(--surface-2); box-shadow: var(--e1); }

/* speaker keys: a tinted circle, so "you can hear this" is visible at a glance */
:is(.lesson, .review, .finish) .speak { width: 44px; height: 44px; }
.lesson .prompt .speak { width: 48px; height: 48px; }
:is(.lesson, .review, .finish) .speak svg { width: 20px; height: 20px; }
:where(html:not(.a11y-contrast)) :is(.lesson, .review, .finish) .speak {
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); box-shadow: none;
  transition: background-color var(--dur-1), border-color var(--dur-1);
}
:where(html:not(.a11y-contrast)) :is(.lesson, .review, .finish) .speak:hover { transform: none; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
:where(html:not(.a11y-contrast)) :is(.lesson, .review, .finish) .speak:focus-visible { outline: none; box-shadow: var(--ring); }

/* =====================================================================
   3. Answer options: one tactile card for words, translations, sentences and pictures
   ===================================================================== */
.lesson .options { gap: var(--sp-3); }
.lesson .options .opt {
  position: relative; display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 64px; padding: var(--sp-3) 44px; overflow-wrap: anywhere; font: 600 1.08rem/1.3 var(--font-ui);
}
.lesson .options .opt .tgt { font-size: 1.14rem; }
.lesson .options .opt[lang="en"] { font-family: var(--font-target); }
:where(html:not(.a11y-contrast)) .lesson .options .opt {
  color: var(--ink); background: var(--surface); border: 1.5px solid var(--hairline-strong); border-radius: var(--r);
  box-shadow: 0 2px 0 var(--hairline-strong);
  transition: border-color var(--dur-1), background-color var(--dur-1), box-shadow var(--dur-1), transform var(--dur-1), opacity var(--dur-2);
}
.lesson .options .opt:hover:not(:disabled) { transform: none; } /* no hover lift: touch keeps hover after a tap */
@media (hover: hover) and (pointer: fine) {
  :where(html:not(.a11y-contrast)) .lesson .options .opt:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--lv, var(--accent)) 55%, var(--hairline-strong));
    background: color-mix(in srgb, var(--lv, var(--accent)) 5%, var(--surface));
    box-shadow: 0 2px 0 color-mix(in srgb, var(--lv, var(--accent)) 40%, var(--hairline-strong));
  }
}
:where(html:not(.a11y-contrast)) .lesson .options .opt:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 transparent; }
:where(html:not(.a11y-contrast)) .lesson .options .opt:focus-visible {
  outline: none; border-color: var(--lv, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lv, var(--accent)) 30%, transparent), 0 2px 0 var(--hairline-strong);
}
.lesson .options .opt:disabled { cursor: default; }
:where(html:not(.a11y-contrast)) .lesson .options .opt.right {
  color: var(--ink); border-color: var(--ok); background: var(--ok-soft); opacity: 1;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--ok) 55%, transparent);
}
:where(html:not(.a11y-contrast)) .lesson .options .opt.wrong {
  color: var(--ink); border-color: var(--bad); background: var(--bad-soft);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--bad) 55%, transparent);
}
:where(html:not(.a11y-contrast)) .lesson .options .opt.dim { opacity: .5; box-shadow: none; }
/* the level test reuses the plain options: the same right / wrong badges as the lesson */
.lesson .options:not(.ex-opts) .opt:is(.right, .wrong)::before {
  content: ""; position: absolute; z-index: 1; top: calc(50% - 11px); inset-inline-end: 14px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4L18 8' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.lesson .options:not(.ex-opts) .opt.wrong::before { background-color: var(--bad); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.5 7.5l9 9M16.5 7.5l-9 9' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"); }
/* dark theme: the badges' mark is dark on the lighter green and red, like the answer card's icon (css/style.css .fb-icon) */
:root[data-theme="dark"]:not(.a11y-contrast) .lesson .opt.right::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4L18 8' fill='none' stroke='%230a0e1a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
:root[data-theme="dark"]:not(.a11y-contrast) .lesson .opt.wrong::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.5 7.5l9 9M16.5 7.5l-9 9' fill='none' stroke='%230a0e1a' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(.a11y-contrast) .lesson .opt.right::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4L18 8' fill='none' stroke='%230a0e1a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
  :root:not([data-theme="light"]):not(.a11y-contrast) .lesson .opt.wrong::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.5 7.5l9 9M16.5 7.5l-9 9' fill='none' stroke='%230a0e1a' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"); }
}
/* "I don't know" in the placement test: a quiet dashed card across the row */
.lesson .options .opt.dunno { grid-column: 1 / -1; min-height: 52px; font-weight: 500; }
:where(html:not(.a11y-contrast)) .lesson .options .opt.dunno { color: var(--muted); background: transparent; border-style: dashed; box-shadow: none; }

/* keyboard number hints (desktop only): a small key cap at the start, never louder than the answer */
@media (hover: hover) and (pointer: fine) {
  .lesson .opt-k { top: calc(50% - 10px); inset-inline-start: 12px; min-width: 20px; height: 20px; padding: 0 5px; font: 600 .68rem/1 var(--font-ui); border-radius: 6px; opacity: .8; }
  :where(html:not(.a11y-contrast)) .lesson .opt-k { color: var(--muted); background: transparent; border: 1px solid var(--hairline-strong); }
  .lesson .options:not(.ex-opts) .opt::after {
    top: calc(50% - 10px); inset-inline-end: auto; inset-inline-start: 12px; display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
    font: 600 .68rem/1 var(--font-ui); border-radius: 6px; opacity: .8;
  }
  :where(html:not(.a11y-contrast)) .lesson .options:not(.ex-opts) .opt::after { color: var(--muted); border: 1px solid var(--hairline-strong); }
  .lesson .options .opt:hover:not(:disabled) .opt-k, .lesson .options .opt:hover:not(:disabled)::after { opacity: 1; }
  .lesson .options:not(.ex-opts) .opt:disabled::after { opacity: 0; }
}

/* picture answers: the photo is the card; the word appears on the photo once answered */
.lesson .ex-opts.pics .opt { flex-direction: column; justify-content: flex-start; gap: 0; min-height: 0; padding: 6px; }
.lesson .ex-opts.pics .pic-img { width: 100%; aspect-ratio: 1; border-radius: calc(var(--r) - 6px); }
.lesson .ex-opts.pics .opt-k { top: 12px; inset-inline-start: 12px; }
:where(html:not(.a11y-contrast)) .lesson .ex-opts.pics .opt-k { background: color-mix(in srgb, var(--surface) 88%, transparent); }
.lesson .ex-opts.pics .opt:is(.right, .wrong)::before { top: 12px; inset-inline-end: 12px; }
:where(html:not(.a11y-contrast)) .lesson .ex-opts.pics:not(.done) .pic-label { display: none; }
:where(html:not(.a11y-contrast)) .lesson .ex-opts.pics.done .pic-label {
  position: absolute; inset-inline: 12px; bottom: 12px; min-height: 0; padding: 4px 10px; border-radius: var(--r-xs);
  font-size: .95rem; line-height: 1.3; color: var(--ink); background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--e1);
}
.lesson .pic-prompt { padding: var(--sp-3); }
.lesson .pic-big { width: min(240px, 62vw); border-radius: var(--r); }

/* =====================================================================
   4. Listening, fill the gap, story
   ===================================================================== */
.lesson .play-box { gap: var(--sp-3); }
.lesson .big-play { width: 88px; height: 88px; }
.lesson .big-play svg { width: 40px; height: 40px; }
:where(html:not(.a11y-contrast)) .lesson .big-play {
  color: var(--surface); background: color-mix(in srgb, var(--lv, var(--accent)) 84%, var(--ink));
  box-shadow: inset 0 2px 0 rgb(255 255 255 / .22), inset 0 -3px 0 rgb(0 0 0 / .14), 0 14px 28px -14px color-mix(in srgb, var(--lv, var(--accent)) 90%, transparent);
  transition: filter var(--dur-1), transform var(--dur-1);
}
.lesson .big-play:hover { transform: none; }
:where(html:not(.a11y-contrast)) .lesson .big-play:hover { filter: brightness(1.06); }
:where(html:not(.a11y-contrast)) .lesson .big-play:active { transform: scale(.97); }
:where(html:not(.a11y-contrast)) .lesson .big-play:focus-visible { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--lv, var(--accent)) 32%, transparent), inset 0 -3px 0 rgb(0 0 0 / .14); }
:is(.lesson, .review) .slow-play { min-height: 44px; padding-block: 0; padding-inline: 12px 16px; gap: var(--sp-2); font: 600 var(--fs-sm)/1 var(--font-ui); }
:where(html:not(.a11y-contrast)) :is(.lesson, .review) .slow-play { color: var(--ink-2); background: var(--surface); border: 1px solid var(--hairline-strong); box-shadow: var(--e1); }
:where(html:not(.a11y-contrast)) :is(.lesson, .review) .slow-play:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 24%, transparent); }
/* the resting shadow above outranked the focus ring of css/style.css, so a keyboard user lost track of this button */
:where(html:not(.a11y-contrast)) :is(.lesson, .review) .slow-play:focus-visible { outline: none; box-shadow: var(--ring), var(--e1); }
/* the review's say-it-aloud step: "show the text" and "I need another try" were 29 px tall text links */
.review .say-step .linkish { display: inline-flex; align-items: center; min-height: 44px; }

.lesson .prompt.gap-sent { padding: var(--sp-6) var(--sp-5) var(--sp-4); }
.lesson .gap-sent > p[lang] { font: 600 clamp(1.2rem, 1.1rem + .6vw, 1.45rem)/1.75 var(--font-target); }
:where(html:not(.a11y-contrast)) .lesson .gap { border-bottom-color: color-mix(in srgb, var(--lv, var(--accent)) 75%, transparent); }
.lesson .hint-btn:not([hidden]) { display: inline-flex; align-items: center; min-height: 44px; margin-top: var(--sp-2); padding: 0 var(--sp-3); border-radius: var(--r-sm); font: 500 var(--fs-sm)/1.2 var(--font-ui); }
.lesson .story-tools .hint-btn { margin-top: 0; }
.lesson .gap-tr, .lesson .story-tr { color: var(--muted); }
.lesson .prompt.story-box { padding: var(--sp-5) var(--sp-5) var(--sp-4); }
.lesson .sgap { min-height: 1.6em; }

/* =====================================================================
   5. Matching pairs
   ===================================================================== */
.lesson .pairs, .lesson .pair-col { gap: var(--sp-3); }
.lesson .pair { min-height: 56px; padding: var(--sp-2) var(--sp-3); font: 600 1.02rem/1.3 var(--font-ui); border-radius: var(--r); }
.lesson .pair.en { font-family: var(--font-target); font-size: 1.06rem; }
:where(html:not(.a11y-contrast)) .lesson .pair {
  color: var(--ink); background: var(--surface); border: 1.5px solid var(--hairline-strong); box-shadow: 0 2px 0 var(--hairline-strong);
  transition: border-color var(--dur-1), background-color var(--dur-1), box-shadow var(--dur-1), transform var(--dur-1), opacity var(--dur-3);
}
.lesson .pair:hover:not(:disabled) { transform: none; }
@media (hover: hover) and (pointer: fine) {
  :where(html:not(.a11y-contrast)) .lesson .pair:hover:not(:disabled):not(.sel) { border-color: color-mix(in srgb, var(--lv, var(--accent)) 55%, var(--hairline-strong)); background: color-mix(in srgb, var(--lv, var(--accent)) 5%, var(--surface)); }
}
:where(html:not(.a11y-contrast)) .lesson .pair:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 transparent; }
:where(html:not(.a11y-contrast)) .lesson .pair:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--lv, var(--accent)) 30%, transparent), 0 2px 0 var(--hairline-strong); }
:where(html:not(.a11y-contrast)) .lesson .pair.sel {
  border-color: var(--lv, var(--accent)); background: color-mix(in srgb, var(--lv, var(--accent)) 11%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lv, var(--accent)) 24%, transparent), 0 2px 0 color-mix(in srgb, var(--lv, var(--accent)) 50%, transparent);
}
:where(html:not(.a11y-contrast)) .lesson .pair.matched {
  color: color-mix(in srgb, var(--ok) 72%, var(--ink)); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  box-shadow: none; opacity: .72;
}
:where(html:not(.a11y-contrast)) .lesson .pair.miss { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 2px 0 color-mix(in srgb, var(--bad) 50%, transparent); }

/* =====================================================================
   6. Sentence building: word tiles and the answer line
   ===================================================================== */
.lesson .build-line { min-height: 72px; padding: var(--sp-3); gap: var(--sp-2); border-radius: var(--r-lg); }
:where(html:not(.a11y-contrast)) .lesson .build-line { border: 2px dashed var(--hairline-strong); background: color-mix(in srgb, var(--surface) 60%, transparent); }
:where(html:not(.a11y-contrast)) .lesson .build-line.right { border: 2px solid var(--ok); background: var(--ok-soft); }
:where(html:not(.a11y-contrast)) .lesson .build-line.wrong { border: 2px solid var(--bad); background: var(--bad-soft); }
.lesson .bank { gap: var(--sp-2); }
.lesson .tok { min-height: 44px; padding: 0 var(--sp-4); font: 600 1.05rem/1 var(--font-target); border-radius: var(--r-sm); }
:where(html:not(.a11y-contrast)) .lesson .tok {
  color: var(--ink); background: var(--surface); border: 1.5px solid var(--hairline-strong); box-shadow: 0 2px 0 var(--hairline-strong);
  transition: border-color var(--dur-1), background-color var(--dur-1), box-shadow var(--dur-1), transform var(--dur-1);
}
@media (hover: hover) and (pointer: fine) {
  :where(html:not(.a11y-contrast)) .lesson .tok:hover:not(:disabled) { border-color: color-mix(in srgb, var(--lv, var(--accent)) 55%, var(--hairline-strong)); }
}
:where(html:not(.a11y-contrast)) .lesson .tok:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 transparent; }
:where(html:not(.a11y-contrast)) .lesson .build-line .tok { border-color: color-mix(in srgb, var(--lv, var(--accent)) 35%, var(--hairline-strong)); }
/* a word already used leaves an empty slot in the bank */
:where(html:not(.a11y-contrast)) .lesson .bank .tok:disabled { opacity: 1; color: transparent; background: var(--surface-2); border-style: dashed; box-shadow: none; }

/* =====================================================================
   7. Typing and dictation
   ===================================================================== */
.lesson .type-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); }
.lesson .type-form input { min-height: 56px; padding-inline: var(--sp-4); font: 600 1.25rem/1.2 var(--font-target); border-radius: var(--r); }
:where(html:not(.a11y-contrast)) .lesson .type-form input { color: var(--ink); background: var(--surface); border: 1.5px solid var(--hairline-strong); box-shadow: inset 0 1px 2px rgb(15 20 40 / .05); }
:where(html:not(.a11y-contrast)) .lesson .type-form input::placeholder { color: var(--faint); font-weight: 500; }
:where(html:not(.a11y-contrast)) .lesson .type-form input:focus { outline: none; border-color: var(--lv, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lv, var(--accent)) 26%, transparent); }
:where(html:not(.a11y-contrast)) .lesson .type-form input.right { border-color: var(--ok); background: var(--ok-soft); box-shadow: none; }
:where(html:not(.a11y-contrast)) .lesson .type-form input.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: none; }
.lesson .type-form .btn { min-height: 56px; min-width: 104px; }
.lesson .letters { gap: 6px; }
.lesson .letters i { width: 14px; }
/* the on-screen English keyboard under the answer field */
.lesson .writing-keyboard { margin: var(--sp-1) auto 0; }
:where(html:not(.a11y-contrast)) .lesson .writing-key { color: var(--ink); background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: 10px; box-shadow: 0 1px 0 var(--hairline-strong); }
:where(html:not(.a11y-contrast)) .lesson .writing-key[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: transparent; }
@media (hover: hover) { :where(html:not(.a11y-contrast)) .lesson .writing-key:hover { color: var(--ink); background: var(--accent-soft); border-color: var(--accent-line); } }

/* =====================================================================
   8. New words (the first step) and the rule (when the chalkboard is off)
   ===================================================================== */
.lesson .word-grid { gap: var(--sp-3); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lesson .word-grid > li { display: flex; min-width: 0; }
.lesson .word-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 6px var(--sp-3); text-align: center; border-radius: var(--r);
}
:where(html:not(.a11y-contrast)) .lesson .word-tile {
  color: var(--ink); background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--e1);
  transition: border-color var(--dur-1), box-shadow var(--dur-2) var(--ease), transform var(--dur-1);
}
@media (hover: hover) and (pointer: fine) {
  :where(html:not(.a11y-contrast)) .lesson .word-tile:hover { border-color: color-mix(in srgb, var(--lv, var(--accent)) 40%, var(--hairline)); box-shadow: var(--e2); }
}
:where(html:not(.a11y-contrast)) .lesson .word-tile:active { transform: translateY(1px); }
:where(html:not(.a11y-contrast)) .lesson .word-tile:focus-visible { outline: none; box-shadow: var(--ring), var(--e1); }
:where(html:not(.a11y-contrast)) .lesson .word-tile.sel { border-color: var(--lv, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lv, var(--accent)) 26%, transparent), var(--e2); }
.lesson .word-tile .tile-img { display: block; width: 100%; aspect-ratio: 4 / 3; margin: 0 0 var(--sp-2); border-radius: calc(var(--r) - 6px); }
.lesson .word-tile > :is(.tgt, .tr) { display: block; max-width: 100%; padding-inline: 6px; text-align: center; overflow-wrap: anywhere; }
.lesson .word-tile > .tgt { font-size: 1.08rem; line-height: 1.3; }
.lesson .word-tile > .tr { font-size: var(--fs-sm); line-height: 1.35; color: var(--muted); }
/* no photo for this word: the word itself fills the picture square */
.lesson .word-tile:not(:has(.tile-img)) > .tgt {
  display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; margin-bottom: var(--sp-2); padding: var(--sp-3);
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.6rem); border-radius: calc(var(--r) - 6px);
}
:where(html:not(.a11y-contrast)) .lesson .word-tile:not(:has(.tile-img)) > .tgt {
  color: color-mix(in srgb, var(--lv, var(--accent)) 58%, var(--ink));
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--lv, var(--accent)) 15%, var(--surface)), color-mix(in srgb, var(--lv, var(--accent)) 6%, var(--surface)));
}
/* "tap to hear": a small speaker badge on the picture's corner */
:where(html:not(.a11y-contrast)) .lesson .word-tile::after,
:where(html:not(.a11y-contrast)) .lesson .word-tile::before { content: ""; position: absolute; top: 12px; inset-inline-end: 12px; width: 30px; height: 30px; pointer-events: none; }
:where(html:not(.a11y-contrast)) .lesson .word-tile::after { z-index: 1; border-radius: 50%; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--e1); }
:where(html:not(.a11y-contrast)) .lesson .word-tile::before {
  z-index: 2; color: var(--accent); background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z' fill='%23000'/%3E%3Cpath d='M16 8.5a5 5 0 0 1 0 7M18.5 6a8.5 8.5 0 0 1 0 12' stroke='%23000' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z' fill='%23000'/%3E%3Cpath d='M16 8.5a5 5 0 0 1 0 7M18.5 6a8.5 8.5 0 0 1 0 12' stroke='%23000' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
:where(html:not(.a11y-contrast)) .lesson .word-tile.sel::before { color: var(--lv, var(--accent)); }
.lesson .wd-panel { margin-top: 0; padding: var(--sp-4) var(--sp-5); }
.lesson .wd-panel > strong { display: block; font-size: 1.08rem; font-weight: 600; }
.lesson .wd-panel > strong .tgt { font-size: 1.14rem; }

/* the rule step without the chalkboard */
.lesson .teach-head { gap: var(--sp-3); }
:where(html:not(.a11y-contrast)) .lesson .note { border-radius: var(--r-lg); border: 1px solid var(--hairline); border-inline-start: 4px solid var(--lv, var(--accent)); box-shadow: var(--e1); }
:where(html:not(.a11y-contrast)) .lesson .examples li { border-radius: var(--r); background: var(--surface); border: 1px solid var(--hairline); }
:where(html:not(.a11y-contrast)) .lesson .lesson-video { border-radius: var(--r-lg); box-shadow: var(--e2); }

/* step buttons (new words, the rule, build, story): forward sits at the end, like "Next" on the answer card */
.lesson > .actions:not(.cc-actions):not([hidden]) { justify-content: flex-end; margin-top: var(--sp-1); }
.lesson > .actions:not(.cc-actions) .btn { min-height: 48px; }
.lesson > .actions:not(.cc-actions) .btn.primary { min-width: 168px; }

/* =====================================================================
   9. The answer card: what was right, how it sounds, an example, a note
   ===================================================================== */
.lesson .feedback.fb2 { gap: 0; padding: 0; overflow: hidden; border-radius: var(--r-lg); }
:where(html:not(.a11y-contrast)) .lesson .feedback.fb2 {
  color: var(--ink); background: var(--surface); border: 1px solid color-mix(in srgb, var(--ok) 32%, var(--hairline)); box-shadow: var(--e3);
}
:where(html:not(.a11y-contrast)) .lesson .feedback.fb2.bad { background: var(--surface); border-color: color-mix(in srgb, var(--bad) 32%, var(--hairline)); }
.lesson .fb2 .fb-head { gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); }
:where(html:not(.a11y-contrast)) .lesson .fb2 .fb-head { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--ok) 16%, transparent); }
:where(html:not(.a11y-contrast)) .lesson .fb2.bad .fb-head { background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border-bottom-color: color-mix(in srgb, var(--bad) 16%, transparent); }
.lesson .fb2 .fb-icon { width: 36px; height: 36px; }
.lesson .fb2 .fb-icon svg { width: 20px; height: 20px; }
:where(html:not(.a11y-contrast)) .lesson .fb2 .fb-icon { color: var(--surface); background: var(--ok); box-shadow: 0 6px 14px -8px var(--ok); }
:where(html:not(.a11y-contrast)) .lesson .fb2 .fb-icon.x { background: var(--bad); box-shadow: 0 6px 14px -8px var(--bad); }
.lesson .fb2 .fb-cat { width: 44px; height: 44px; }
:where(html:not(.a11y-contrast)) .lesson .fb2 .fb-cat { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px color-mix(in srgb, var(--bad) 30%, transparent); }
.lesson .fb2 .fb-title strong { font: 700 1.12rem/1.25 var(--font-ui); }
/* the praise line takes its direction from its own words: an English "Exactly!" on a right-to-left page keeps its "!"
   at the end, and the line still sits on the page's side */
.lesson .fb2 .fb-title strong { unicode-bidi: plaintext; text-align: match-parent; }
:where(html:not(.a11y-contrast)) .lesson .fb2 .fb-title strong { color: color-mix(in srgb, var(--ok) 82%, var(--ink)); }
:where(html:not(.a11y-contrast)) .lesson .fb2.bad .fb-title strong { color: color-mix(in srgb, var(--bad) 86%, var(--ink)); }
.lesson .fb2 .fb-title .small { font-size: var(--fs-sm); }
.lesson .fb2 .fb-body { gap: var(--sp-3); padding: var(--sp-4) var(--sp-5) 0; }
.lesson .fb2 .fb-label { margin: 0 0 calc(-1 * var(--sp-1)); font: 600 var(--fs-xs)/1.3 var(--font-ui); letter-spacing: .02em; color: var(--muted); }
.lesson .fb2 :is(.fb-row, .wd-ex) { gap: var(--sp-3); padding: 10px var(--sp-3); border-radius: var(--r); }
:where(html:not(.a11y-contrast)) .lesson .fb2 :is(.fb-row, .wd-ex) { background: var(--surface-2); border: 1px solid transparent; }
.lesson .fb2 .fb-img { width: 48px; height: 48px; border-radius: var(--r-xs); }
.lesson .fb2 .fb-main .tgt, .lesson .fb2 .wd-ex .tgt { font-size: 1.12rem; }
.lesson .fb2 .wd-ex > span { gap: 2px; }
.lesson .fb2 .wd-x { font-size: .95rem; line-height: 1.6; }
:where(html:not(.a11y-contrast)) .lesson .fb2 .wd-x { color: var(--ink-2); }
.lesson .fb2 .fb-typed { font-size: .92rem; }
.lesson .fb2 .fb-line { color: var(--ink-2); }
.lesson .fb2 .fb-foot { padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.lesson .fb2 .fb-next { min-height: 48px; min-width: 176px; }
/* "note" label before an explanation: a small chip, the same everywhere */
:is(.lesson, .review) .wd-x .tag { display: inline-flex; align-items: center; margin-inline-end: 6px; padding: 1px 8px; border-radius: var(--r-pill); font: 700 .7rem/1.6 var(--font-ui); letter-spacing: .04em; vertical-align: 1px; }
:where(html:not(.a11y-contrast)) :is(.lesson, .review) .wd-x .tag { color: var(--accent); background: var(--accent-soft); }
:where(html:not(.a11y-contrast)) :is(.lesson, .review) .word-detail .wd-ex { border-radius: var(--r); background: var(--surface-2); }

/* the level test's answer card: the same card from flat markup. Its first line becomes the head (round icon, verdict,
   the right answer under it); the explanation and "Next" follow, like the lesson's card */
.lesson #test-fb > .feedback { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; justify-items: stretch; gap: var(--sp-4); padding: 0 0 var(--sp-5); overflow: hidden; border-radius: var(--r-lg); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback { color: var(--ink); background: var(--surface); border: 1px solid color-mix(in srgb, var(--ok) 32%, var(--hairline)); box-shadow: var(--e3); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback.bad { border-color: color-mix(in srgb, var(--bad) 32%, var(--hairline)); }
.lesson #test-fb > .feedback > * { margin: 0 var(--sp-5); }
.lesson #test-fb > .feedback > p:first-child {
  position: relative; display: block; margin: 0; padding-block: var(--sp-5); padding-inline: 68px var(--sp-5);
  font-size: 1.02rem; line-height: 1.5;
}
.lesson #test-fb > .feedback > p:first-child::before,
.lesson #test-fb > .feedback > p:first-child::after { content: ""; position: absolute; inset-inline-start: var(--sp-5); top: calc(50% - 18px); width: 36px; height: 36px; }
.lesson #test-fb > .feedback > p:first-child::before { border-radius: 50%; background: var(--ok); }
.lesson #test-fb > .feedback.bad > p:first-child::before { background: var(--bad); }
/* the mark is cut out of the circle colour (white, dark on the dark theme), like the lesson card's icon */
.lesson #test-fb > .feedback > p:first-child::after {
  background: var(--surface);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4L18 8' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 22px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4L18 8' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 22px no-repeat;
}
.lesson #test-fb > .feedback.bad > p:first-child::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.5 7.5l9 9M16.5 7.5l-9 9' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.5 7.5l9 9M16.5 7.5l-9 9' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
}
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback > p:first-child { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--ok) 16%, transparent); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback.bad > p:first-child { background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border-bottom-color: color-mix(in srgb, var(--bad) 16%, transparent); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback > p:first-child::before { box-shadow: 0 6px 14px -8px var(--ok); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback.bad > p:first-child::before { box-shadow: 0 6px 14px -8px var(--bad); }
.lesson #test-fb > .feedback > p:first-child strong { display: block; font: 700 1.12rem/1.25 var(--font-ui); }
.lesson #test-fb > .feedback > p:first-child [lang] { font: 600 1.08rem/1.4 var(--font-target); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback > p:first-child { color: var(--ink-2); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback > p:first-child strong { color: color-mix(in srgb, var(--ok) 82%, var(--ink)); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback.bad > p:first-child strong { color: color-mix(in srgb, var(--bad) 86%, var(--ink)); }
:where(html:not(.a11y-contrast)) .lesson #test-fb > .feedback > p:first-child [lang] { color: var(--ink); }
.lesson #test-fb > .feedback .word-detail { margin-block: 0; }
.lesson #test-fb > .feedback #fb-next { justify-self: end; min-height: 48px; min-width: 176px; }

/* =====================================================================
   10. Phones: the answer card is a sheet at the bottom of the screen, "Next" under the thumb
   ===================================================================== */
@media (max-width: 640px) {
  .lesson { gap: 14px; }
  .lesson .prompt { min-height: 112px; padding: var(--sp-5) var(--sp-4); }
  .lesson .options .opt { min-height: 60px; padding-inline: 14px; }
  .lesson .options .opt:is(.right, .wrong)::before, .lesson .ex-opts .opt:is(.right, .wrong)::before { top: 8px; inset-inline-end: 8px; width: 20px; height: 20px; background-size: 14px; }
  .lesson .ex-opts.pics { gap: 10px; }
  .lesson .ex-opts.pics .opt:is(.right, .wrong)::before { top: 12px; inset-inline-end: 12px; }
  .lesson .pairs, .lesson .pair-col { gap: 10px; }
  .lesson .word-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lesson .word-tile .tile-img, .lesson .word-tile:not(:has(.tile-img)) > .tgt { aspect-ratio: 1; }
  .lesson > .actions:not(.cc-actions):not([hidden]) { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .lesson > .actions:not(.cc-actions):has(> .btn.ghost):not([hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson > .actions:not(.cc-actions) :is(.btn, .btn.primary) { width: 100%; min-width: 0; white-space: normal; overflow-wrap: anywhere; } /* beats the desktop 168px minimum */

  /* the sheet: glued to the bottom edge, full width; when the lesson is short it still waits at the bottom */
  .lesson:has(> #feedback.fb2), .lesson:has(> #test-fb > .feedback) { min-height: 100vh; min-height: 100svh; }
  html.in-lesson:has(.lesson > #feedback.fb2, .lesson > #test-fb > .feedback) :is(#shell, #view) { padding-bottom: 0; }
  html.in-lesson:has(.lesson > #feedback.fb2, .lesson > #test-fb > .feedback) body { padding-bottom: 0; }
  .lesson > #feedback.feedback.fb2, .lesson > #test-fb:has(> .feedback) { position: sticky; bottom: 0; z-index: 20; margin-block: auto 0; margin-inline: calc(50% - 50vw); }
  .lesson > #feedback.feedback.fb2 { max-height: calc(100svh - 96px); overflow-y: auto; overscroll-behavior: contain; }
  /* the sheet lies over the page, so under the glass it needs a solid base: in the dark look --surface is see-through, and the writing keyboard
     and the lesson's own text showed through the answer card (390 px, dictation and typed steps) */
  :where(html:not(.a11y-contrast)) .lesson > #feedback.feedback.fb2,
  :where(html:not(.a11y-contrast)) .lesson > #test-fb > .feedback { background: linear-gradient(var(--surface), var(--surface)), var(--bg); }
  .lesson > #feedback.feedback.fb2, .lesson > #test-fb > .feedback { border-radius: var(--r-xl) var(--r-xl) 0 0; }
  :where(html:not(.a11y-contrast)) .lesson > #feedback.feedback.fb2,
  :where(html:not(.a11y-contrast)) .lesson > #test-fb > .feedback {
    border-width: 1px 0 0; box-shadow: 0 -16px 36px -20px rgb(15 20 40 / .38);
    animation: ds-sheet-up var(--dur-3) var(--ease);
  }
  .lesson > #feedback.fb2 .fb-head { padding: var(--sp-4) var(--sp-4) var(--sp-3); }
  .lesson > #feedback.fb2 .fb-body { padding: var(--sp-3) var(--sp-4) 0; gap: 10px; }
  .lesson > #feedback.fb2 .fb-foot { position: sticky; bottom: 0; padding: var(--sp-3) var(--sp-4) calc(14px + env(safe-area-inset-bottom)); background: inherit; }
  .lesson > #feedback.fb2 .fb-next { width: 100%; min-width: 0; }
  .lesson > #test-fb > .feedback { position: static; gap: var(--sp-3); padding: 0 0 calc(14px + env(safe-area-inset-bottom)); }
  .lesson > #test-fb > .feedback > * { margin-inline: var(--sp-4); }
  .lesson > #test-fb > .feedback > p:first-child { margin-inline: 0; padding-block: var(--sp-4); padding-inline: 64px var(--sp-4); }
  .lesson > #test-fb > .feedback > p:first-child::before, .lesson > #test-fb > .feedback > p:first-child::after { inset-inline-start: var(--sp-4); }
  .lesson > #test-fb > .feedback #fb-next { justify-self: stretch; width: auto; min-width: 0; }
  /* room under the last key of a step, away from the screen's bottom edge */
  html.in-lesson .lesson:not(:has(> #feedback.fb2, > #test-fb > .feedback)) { padding-bottom: var(--sp-6); }

  /* Polly stands under the bar beside the lesson title, never over the question or the answers */
  .lesson > .buddy:not(.float) { --b: 64px; }
  .lesson:has(> .buddy:not(.off)) > :is(.eyebrow, .q) { padding-inline-end: 76px; }
  /* the flash cards' top row ("Card 1 of 8 … Word list") comes right under the title when the course has no learning-help
     row (only English has one), level with Polly's paws: it starts below her (ending before her squeezed the dots away) */
  .lesson:has(> .buddy:not(.off):not(.float)):not(:has(> .lh-row)) .pg-deck-top { margin-block-start: 36px; }
  /* while the sheet is open she does not walk in along the bottom: the sheet is there */
  .lesson:has(> #feedback.fb2, > #test-fb > .feedback) > .buddy.float { visibility: hidden; }
}
/* Polly's flying hearts, notes and sleepy z are drawn from data-ch (js/pet/buddy.js), not written into the page */
.buddy .bf::before { content: attr(data-ch); }
/* Phones and tablets: the accessibility key (css/a11y.css floats it at the bottom corner) sits at the end of the lesson bar,
   so it never covers an answer, the on-screen keyboard or the sheet's "Next"; its menu opens under the bar */
@media (max-width: 1179.98px) {
  html.in-lesson:has(#view > .lesson > .lesson-top) .a11y-btn {
    top: max(10px, env(safe-area-inset-top)); bottom: auto; inset-inline: auto 12px; width: 44px; height: 44px; opacity: 1;
  }
  html.in-lesson:has(#view > .lesson > .lesson-top) .a11y-btn svg { width: 24px; height: 24px; }
  :where(html:not(.a11y-contrast)).in-lesson:has(#view > .lesson > .lesson-top) .a11y-btn {
    color: var(--ink-2); background: transparent; border-color: transparent; border-radius: var(--r-sm); box-shadow: none;
  }
  :where(html:not(.a11y-contrast)).in-lesson:has(#view > .lesson > .lesson-top) .a11y-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
  :where(html:not(.a11y-contrast)).in-lesson:has(#view > .lesson > .lesson-top) .a11y-btn[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
  html.in-lesson:has(#view > .lesson > .lesson-top) .a11y-menu {
    top: calc(max(10px, env(safe-area-inset-top)) + 54px); bottom: auto; inset-inline: auto 12px; max-height: calc(100svh - 80px);
  }
  /* the bar's own keys end before it (when the window leaves no room beside the lesson column) */
  html:has(> body > .a11y-btn) .lesson > .lesson-top { padding-inline-end: max(16px, calc(80px - (100vw - 100%) / 2)); }
  /* high contrast: the bar stays on top too, so the key never floats over the lesson */
  html.a11y-contrast.in-lesson .lesson > .lesson-top { position: sticky; top: 0; z-index: 30; margin-inline: -16px; padding-block: max(10px, env(safe-area-inset-top)) 10px; padding-inline-start: 16px; background: var(--bg); }
}
/* Polly just under the 64px bar: css/ui-kit.css puts her at 74px; this is the same spot plus the phone app's status bar */
@media (max-width: 1179.98px) {
  html.in-lesson .lesson.buddy-host > .buddy:not(.float):not(.inrow) { top: calc(max(10px, env(safe-area-inset-top)) + 64px); }
}
@media (max-width: 1179.98px) {
  /* her speech bubble ("Let's start!") opens beside her head, level with the lesson title, on one line: beside her middle
     it covered the next row, where the "Word list" link and the learning-help key sit (the help key is not there in every
     course, so that row can be right beside her). The title is text only, and the bubble fades after two seconds. */
  .lesson > .buddy:not(.float):not(.inrow) .buddy-say { top: 2px; transform: scale(.6); transform-origin: center right; max-width: calc(100vw - var(--b) - 48px); font-size: .8rem; white-space: nowrap; }
  [dir="rtl"] .lesson > .buddy:not(.float):not(.inrow) .buddy-say { transform-origin: center left; }
  .lesson > .buddy:not(.float):not(.inrow) .buddy-say::after { top: 13px; margin-top: -6px; }
  .lesson > .buddy:not(.float):not(.inrow) .buddy-say.on { animation-name: bd-say-down; }
}
@media (min-width: 641px) and (max-width: 1179.98px) {
  .lesson > .buddy:not(.float) { --b: 72px; }
  .lesson:has(> .buddy:not(.off)) > :is(.eyebrow, .q) { padding-inline-end: 84px; }
  .lesson:has(> .buddy:not(.off):not(.float)):not(:has(> .lh-row)) .pg-deck-top { margin-block-start: 40px; }
}
@media (max-width: 380px) {
  .lesson-top { gap: var(--sp-2); }
  .lesson-top .ex-count { min-width: 2.8em; font-size: .8rem; }
  .lesson .ex-opts.two .opt, .lesson .pair { font-size: 1rem; }
  .lesson .type-form .btn { min-width: 88px; padding-inline: .9em; }
  .lesson .word-tile > .tgt { font-size: 1rem; }
}
@keyframes ds-sheet-up { from { transform: translateY(24px); opacity: .4; } }

/* =====================================================================
   11. The finish screen: a celebration card
   ===================================================================== */
.lesson.finish {
  position: relative; max-width: 600px; margin: var(--sp-6) auto var(--sp-4); padding: var(--sp-8) var(--sp-6) var(--sp-6);
  gap: var(--sp-3); align-items: center; text-align: center;
}
:where(html:not(.a11y-contrast)) .lesson.finish {
  border: 1px solid var(--hairline); border-radius: var(--r-xl); box-shadow: var(--e3);
  background: radial-gradient(130% 55% at 50% 0%, color-mix(in srgb, var(--lv, var(--accent)) 15%, transparent), transparent 72%), var(--surface);
}
.lesson.finish .mascot-img { width: 136px; height: 136px; margin: 0; }
:where(html:not(.a11y-contrast)) .lesson.finish .mascot-img { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px color-mix(in srgb, var(--lv, var(--accent)) 55%, transparent), var(--e3); }
.lesson.finish .lv-chip.big { position: relative; margin-top: calc(-1 * var(--sp-6)); }
:where(html:not(.a11y-contrast)) .lesson.finish .lv-chip.big { box-shadow: 0 0 0 3px var(--surface), var(--e2); }
.lesson.finish h1 { margin: var(--sp-1) 0 0; font-size: var(--fs-h1); text-wrap: balance; }
.lesson.finish > p.muted:not(.small) { margin-top: calc(-1 * var(--sp-2)); font-size: var(--fs-lg); }
.lesson.finish .stat-grid.wide { width: 100%; max-width: none; margin-block: var(--sp-3) var(--sp-1); gap: var(--sp-3); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lesson.finish .stat-grid.wide > div {
  --c: var(--ok); --c-ink: color-mix(in srgb, var(--ok) 80%, var(--ink));
  display: flex; flex-direction: column-reverse; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0;
  padding: var(--sp-4) var(--sp-2) var(--sp-3); border-radius: var(--r);
}
.lesson.finish .stat-grid.wide > div:nth-child(2) { --c: var(--accent); --c-ink: var(--accent); }
.lesson.finish .stat-grid.wide > div:nth-child(3) { --c: var(--warn); --c-ink: color-mix(in srgb, var(--warn) 82%, var(--ink)); }
:where(html:not(.a11y-contrast)) .lesson.finish .stat-grid.wide > div { background: color-mix(in srgb, var(--c) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 22%, transparent); box-shadow: none; }
.lesson.finish .stat-grid dd { margin: 0; font: 700 clamp(1.5rem, 1.25rem + 1vw, 1.9rem)/1.1 var(--font-target); letter-spacing: -.01em; }
:where(html:not(.a11y-contrast)) .lesson.finish .stat-grid dd { color: var(--c-ink); }
.lesson.finish .stat-grid dt { font: 500 var(--fs-xs)/1.3 var(--font-ui); color: var(--muted); }
.lesson.finish > p:not(.muted) { max-width: 46ch; color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.55; }
/* blocks from plugins (Polly's cheer, a level certificate) sit as quiet panels inside the one card */
.lesson.finish .pet-cheer { width: 100%; margin: 0; padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); border-radius: var(--r); }
:where(html:not(.a11y-contrast)) .lesson.finish .pet-cheer { background: var(--surface-2); }
.lesson.finish .pet-cheer .pc-art svg { width: 112px; }
.lesson.finish .cert-won { width: 100%; max-width: none; margin: 0; border-radius: var(--r); }
.lesson.finish .btn.small { min-height: 44px; }
/* rewards that come with the lesson end, as quiet rows in the card (markup suggested for js/app.js: ul.fin-notes > li) */
.lesson.finish .fin-notes { display: grid; gap: var(--sp-2); width: 100%; margin: 0; padding: 0; list-style: none; }
.lesson.finish .fin-notes > li { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: 40px; padding: 8px 14px; border-radius: var(--r); font: 500 var(--fs-sm)/1.4 var(--font-ui); }
:where(html:not(.a11y-contrast)) .lesson.finish .fin-notes > li { color: var(--ink-2); background: var(--surface-2); }
/* the small notes under the card (progress saved on this phone, the daily-cycle step) stay small: the subtitle rule above
   once made them as large as the lesson name. The rewards read as quiet rows, not three lines of bold text. */
.lesson.finish > p.muted.small { max-width: 46ch; margin-block: 0; font-size: var(--fs-sm); line-height: 1.55; }
.lesson.finish > .gl-end { justify-content: center; text-align: center; }
.lesson.finish .finish-rewards { gap: var(--sp-2); width: 100%; margin: 0; }
.lesson.finish .finish-rewards > li { padding: 8px 14px; border-radius: var(--r); font: 600 var(--fs-sm)/1.4 var(--font-ui); text-wrap: balance; }
:where(html:not(.a11y-contrast)) .lesson.finish .finish-rewards > li { color: var(--ink); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); }
.lesson.finish > [role="status"]:has(> .finish-rewards) { width: 100%; }
/* blocks other rooms add to the finish card, fitted to its narrow column (wave 8 polish): the exam card puts its button
   under the text, the video list gives titles the full width, and the unit games sit as equal tiles */
.lesson.finish .vl-deeper { padding: var(--sp-4); }
.lesson.finish .vl-deeper > :is(h2, p) { text-align: center; }
.lesson.finish .ax-unit-games { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.lesson.finish .ax-unit-go { justify-content: center; }
@media (max-width: 520px) {
  .lesson.finish { padding-inline: var(--sp-4); }
  .lesson.finish .vc-item { grid-template-columns: auto minmax(0, 1fr); padding-inline: 10px; }
  .lesson.finish .vc-item > .vc-num { grid-row: span 2; }
  .lesson.finish .vc-item > .lv-chip { grid-column: 2; justify-self: start; margin-top: -4px; }
}
.lesson.finish > .actions:not(.cc-actions):not([hidden]) { justify-content: center; width: 100%; margin-top: var(--sp-3); gap: var(--sp-3); }
.lesson.finish .actions .btn { min-height: 52px; min-width: 168px; }
/* one main key: "next lesson" stays primary and comes last in the row; "review now" and the certificate's key look like
   ordinary keys beside it */
.lesson.finish .actions .btn.primary { order: 2; }
.lesson.finish .actions .btn.primary ~ .btn.primary { order: 1; }
/* three keys: "next lesson" across the card, the other two side by side under it */
.lesson.finish > .actions:not(.cc-actions):has(> .btn:nth-child(3)):not([hidden]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lesson.finish > .actions:has(> .btn:nth-child(3)) > .btn { min-width: 0; }
.lesson.finish > .actions:has(> .btn:nth-child(3)) > .btn.primary { grid-column: 1 / -1; order: -2; }
.lesson.finish > .actions:has(> .btn:nth-child(3)) > .btn.primary ~ .btn.primary { grid-column: auto; order: -1; }
:where(html:not(.a11y-contrast)) .lesson.finish :is(.actions .btn.primary ~ .btn.primary, .cert-won .btn.primary) {
  color: var(--ink); text-shadow: none; border-color: var(--hairline-strong); background: var(--surface); filter: none;
  box-shadow: var(--e1), inset 0 -2px 0 rgb(15 20 40 / .05);
}
:where(html:not(.a11y-contrast)) .lesson.finish :is(.actions .btn.primary ~ .btn.primary, .cert-won .btn.primary):hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--ink) 22%, transparent); background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); filter: none;
  box-shadow: var(--e2), inset 0 -2px 0 rgb(15 20 40 / .05);
}
:where(html:not(.a11y-contrast)) .lesson.finish :is(.actions .btn.primary ~ .btn.primary, .cert-won .btn.primary):focus-visible { box-shadow: var(--ring), var(--e1); }
/* one celebration: rewards that still arrive as toasts or a medal card come without motion; on phones and tablets they
   wait at the top, over the menu bar, not over the card (folding them into the card needs js/app.js, see .fin-notes) */
html:has(#view > .lesson.finish) :is(.toast, .medal-pop) { animation: none; }
@media (max-width: 1179.98px) {
  html:has(#view > .lesson.finish) #toasts { top: max(12px, env(safe-area-inset-top)); bottom: auto; }
  html:has(#view > .lesson.finish):has(> body > .medal-pop) #toasts { top: calc(max(12px, env(safe-area-inset-top)) + 96px); }
}
@media (max-width: 640px) {
  .lesson.finish { margin-top: var(--sp-4); padding: var(--sp-6) var(--sp-4) var(--sp-5); }
  .lesson.finish .mascot-img { width: 116px; height: 116px; }
  .lesson.finish .stat-grid.wide { gap: var(--sp-2); }
  .lesson.finish .stat-grid.wide > div { padding: var(--sp-3) var(--sp-1); }
  /* Polly's cheer as one compact row: picture, words (they wrap), key */
  .lesson.finish .pet-cheer { padding: var(--sp-2) var(--sp-3); gap: 10px; }
  .lesson.finish .pet-cheer .pc-art svg { width: 72px; }
  .lesson.finish .pet-cheer > p { flex: 1 1 7em; min-width: 0; margin: 0; font-size: .95rem; line-height: 1.35; text-align: start; }
  /* two keys side by side, the same width; three keys (next lesson, review, back) one under the other */
  .lesson.finish > .actions:not(.cc-actions):has(> .btn):not([hidden]) { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .lesson.finish > .actions:not(.cc-actions):has(> .btn:nth-child(3)):not([hidden]) { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); }
  .lesson.finish > .actions:not(.cc-actions) .btn { width: 100%; min-width: 0; }
  .lesson.finish .actions .btn.primary { order: -2; }
  .lesson.finish .actions .btn.primary ~ .btn.primary { order: -1; }
}

/* =====================================================================
   12. Review cards
   ===================================================================== */
.review { max-width: 640px; gap: var(--sp-4); }
.review .review-head { align-items: center; }
.review .review-head h1 { font-size: var(--fs-h1); }
.review .review-head .muted { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 320 px phones (design backlog D28): the title, Polly and "left: N" did not fit one line in Russian and pushed the whole
   review card 26 px past the screen edge; the counter now drops under the title instead */
.review .review-head { flex-wrap: wrap; row-gap: 2px; }
.review .review-head h1 { min-width: 0; overflow-wrap: break-word; }
.review .ladder { gap: 6px; margin-block: var(--sp-1) var(--sp-2); }
.review .ladder li { height: 28px; border-radius: var(--r-xs); font: 600 .75rem/1 var(--font-ui); }
/* The ladder belongs to the rating step (app.js shows it after the answer): its display: flex had overruled [hidden], so
   it stood above every card as a row of bare numbers. When it shows, its own name says what the numbers are (the
   aria-label, already in every language: "the review ladder: 1, 3, 7… days") (QA click audit, 4 Nov 2026). */
.review .ladder[hidden] { display: none; }
.review .ladder { flex-wrap: wrap; }
.review .ladder::before { content: attr(aria-label); flex: 0 0 100%; margin-bottom: 2px; text-align: center; font: 500 var(--fs-sm)/1.35 var(--font-ui); color: var(--muted); unicode-bidi: plaintext; }
/* The answer box keeps to the card: the form lays it out in a row, where the input's own size (about 370px at this
   font) pushed it off a phone screen (-24px in Hebrew, to 414px in Russian at 390px wide). */
.review .recall { min-width: 0; max-width: 100%; }
.review .recall input { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
:where(html:not(.a11y-contrast)) .review .ladder li { color: var(--muted); background: var(--surface-2); }
:where(html:not(.a11y-contrast)) .review .ladder li.past { color: color-mix(in srgb, var(--ok) 72%, var(--ink)); background: color-mix(in srgb, var(--ok) 16%, var(--surface)); }
:where(html:not(.a11y-contrast)) .review .ladder li.here { color: var(--surface); background: color-mix(in srgb, var(--lv, var(--accent)) 70%, var(--ink)); }
.review .flash { min-height: 260px; padding: var(--sp-10) var(--sp-6) var(--sp-8); gap: var(--sp-4); border-radius: var(--r-xl); }
:where(html:not(.a11y-contrast)) .review .flash {
  border: 1px solid var(--hairline); box-shadow: var(--e3);
  background: radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--lv, var(--accent)) 12%, transparent), transparent 70%), var(--surface);
}
.review .flash .lv-chip { top: 16px; inset-inline-end: 16px; height: 28px; font-size: .8rem; }
.review .flash-front { font-size: clamp(1.9rem, 1.5rem + 1.8vw, 2.6rem); font-weight: 600; line-height: 1.2; }
.review .flash-front .native { font-weight: 600; }
.review .flash-back:not([hidden]) {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto minmax(0, 1fr); grid-template-areas: ". word say ." "detail detail detail detail";
  align-items: center; gap: var(--sp-3); width: 100%; padding-top: var(--sp-5); font-size: 1.5rem;
}
.review .flash-back:has(> .flash-img):not([hidden]) { grid-template-areas: "img img img img" ". word say ." "detail detail detail detail"; }
:where(html:not(.a11y-contrast)) .review .flash-back { border-top: 1px solid var(--hairline); }
.review .flash-back > .flash-img { grid-area: img; justify-self: center; width: 132px; height: 132px; border-radius: var(--r); object-fit: cover; }
.review .flash-back > :is(.native, .tgt) { grid-area: word; font-weight: 600; }
.review .flash-back > .speak { grid-area: say; }
.review .flash-back > .word-detail { grid-area: detail; margin-top: var(--sp-1); font-size: .95rem; }
.review .flash-back .wd-ex { padding: 10px var(--sp-3); gap: var(--sp-3); align-items: center; }
.review #flash-actions { gap: var(--sp-3); margin-top: var(--sp-1); }
.review #flash-actions #show { min-height: 52px; min-width: 220px; }
.review #flash-actions:has(.rate) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.review .btn.rate { min-width: 0; min-height: 64px; flex-direction: column; gap: 2px; padding: var(--sp-2); border-radius: var(--r); }
.review .btn.rate span { font-size: 1rem; font-weight: 700; }
.review .btn.rate small { font: 500 var(--fs-xs)/1.2 var(--font-ui); opacity: 1; color: var(--muted); }
:where(html:not(.a11y-contrast)) .review .btn.rate {
  --c: var(--accent); color: color-mix(in srgb, var(--c) 80%, var(--ink));
  background: color-mix(in srgb, var(--c) 8%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--c) 30%, transparent);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 30%, transparent);
}
:where(html:not(.a11y-contrast)) .review .btn.rate-0 { --c: var(--bad); }
:where(html:not(.a11y-contrast)) .review .btn.rate-2 { --c: var(--ok); }
:where(html:not(.a11y-contrast)) .review .btn.rate:hover:not(:disabled) { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-color: color-mix(in srgb, var(--c) 50%, transparent); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 40%, transparent); }
:where(html:not(.a11y-contrast)) .review .btn.rate:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 transparent; }
:where(html:not(.a11y-contrast)) .review .btn.rate:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 32%, transparent); }
/* phones: when the keys get focus they scroll clear of the tab bar, not half under it */
@media (max-width: 760px) {
  .review #flash-actions .btn { scroll-margin-bottom: calc(var(--dock-h) + 24px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .review .flash { min-height: 220px; padding: var(--sp-8) var(--sp-4) var(--sp-6); }
  .review .flash-back > .flash-img { width: 112px; height: 112px; }
  .review #flash-actions #show { width: 100%; }
  .review #flash-actions:has(.rate) { gap: var(--sp-2); }
}

/* =====================================================================
   13. Placement test and level test: start, result
   ===================================================================== */
.place-intro { max-width: 560px; margin: var(--sp-8) auto; padding: var(--sp-8) var(--sp-6); gap: var(--sp-2); }
:where(html:not(.a11y-contrast)) .place-intro {
  border: 1px solid var(--hairline); border-radius: var(--r-xl); box-shadow: var(--e3);
  background: radial-gradient(130% 60% at 50% 0%, color-mix(in srgb, var(--lv, var(--accent)) 12%, transparent), transparent 72%), var(--surface);
}
.place-intro .lead { max-width: 44ch; }
.place-intro .actions { margin-top: var(--sp-4); gap: var(--sp-3); }
.place-intro .actions .btn { min-height: 52px; min-width: 160px; }
/* Czech placement test: the grid centres each item at its own width, so a 220 px answer box plus Check pushed out of a
   340 px card on a phone. The "marks missing" note is a quiet panel that waits for Continue (2026-11-04-wrong-answer-stays). */
.cs-place > .type-form, .cs-place > .options, .cs-place > .actions, .cs-place > #csp-fb { justify-self: stretch; min-width: 0; }
.cs-place > .actions .btn { min-width: 0; flex: 1 1 160px; }
.cs-place #csp-fb:not(:empty) { margin-top: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--hairline); color: var(--ink); line-height: 1.6; }
.cs-place #csp-fb p { margin: 0; }
.cs-place #csp-fb .actions { margin-top: var(--sp-3); }
:where(html:not(.a11y-contrast)) .place-intro .place-icon { display: grid; place-items: center; width: 88px; height: 88px; border-radius: var(--r-lg); background: var(--surface-2); }
.place-intro .place-icon svg { width: 60px; height: 60px; }
.test-result { gap: var(--sp-6); padding: var(--sp-6) var(--sp-8); }
:where(html:not(.a11y-contrast)) .test-result { border-radius: var(--r-xl); box-shadow: var(--e3); }
:where(html:not(.a11y-contrast)) .test-result.pass { background: radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 70%), var(--surface); }
:where(html:not(.a11y-contrast)) .test-result img { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px color-mix(in srgb, var(--lv, var(--accent)) 50%, transparent), var(--e2); }
.test-result .test-score { font-weight: 700; letter-spacing: -.02em; }
.test-result .actions .btn { min-height: 48px; }
@media (max-width: 640px) {
  .place-intro { margin-block: var(--sp-4); padding: var(--sp-6) var(--sp-4); }
  .place-intro .actions { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr); }
  .place-intro .actions .btn { width: 100%; }
  .test-result { padding: var(--sp-6) var(--sp-4); }
}

/* =====================================================================
   14. Calm, easy learning and reduced motion: nothing moves, nothing lifts
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  :is(.lesson, .review) :is(.opt, .pair, .tok, .word-tile, .big-play, .btn.rate):is(:hover, :active) { transform: none !important; }
  .lesson > #feedback.fb2, .lesson > #test-fb > .feedback { animation: none !important; }
}
html:is(.pref-calm, .pref-easy) :is(.lesson, .review) :is(.opt, .pair, .tok, .word-tile, .big-play, .btn.rate):is(:hover, :active) { transform: none !important; }
html:is(.pref-calm, .pref-easy) .lesson > :is(#feedback, #test-fb > .feedback) { animation: none !important; }
/* a combo compliment (the praise line from js/app.js) never blocks the close key under it; easy learning keeps only the
   spoken line, so the answer card stays the one place to look */
html.in-lesson:has(#view > .lesson:not(.finish)) .praise { pointer-events: none; }
html.pref-easy.in-lesson:has(#view > .lesson:not(.finish)) .praise { display: none; }
/* easy learning on wider screens: the level test's card waits at the bottom too, like the lesson's (css/ui-kit.css) */
@media (min-width: 641px) { html.pref-easy .lesson > #test-fb:has(> .feedback) { position: sticky; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 6; } }
/* easy learning: the finish card without the glow */
:where(html:not(.a11y-contrast)).pref-easy .lesson.finish { background: var(--surface); }

/* =====================================================================
   Quiet mode (N3, S.prefs.quiet in the personal area): no points, streak or league anywhere on screen.
   The finish card keeps only the accuracy (js/app.js finishStats); rewards stay unlisted.
   ===================================================================== */
html.pref-quiet :is([data-nav="league"], #ar-mini, .tc-streak) { display: none !important; }
html.pref-quiet .finish .stat-grid { max-width: 220px; margin-inline: auto; }

/* =====================================================================
   Report a mistake (N14): a flag key in the lesson bar, a link under the finish card, and the short form
   ===================================================================== */
.lesson-top .flag-btn::before { content: none; }
.lesson-top .flag-btn svg { width: 20px; height: 20px; }
:where(html:not(.a11y-contrast)) .lesson-top .flag-btn { color: var(--muted); }
.finish .finish-report { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 var(--sp-5); margin: var(--sp-4) 0 0; }
.finish .finish-report :is(a, .link-btn) { display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; }
:where(html:not(.a11y-contrast)) .finish .finish-report :is(a, .link-btn) { color: var(--muted); }
.report-dlg { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: auto; text-align: start; }
:where(html:not(.a11y-contrast)) .report-dlg { border: 1px solid var(--hairline); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--e4); }
html.a11y-contrast .report-dlg { border: 2px solid var(--ink); background: var(--bg); color: var(--ink); }
.report-dlg .rp-form { display: grid; gap: var(--sp-2); padding: var(--sp-6); }
.report-dlg h2 { margin: 0; font-size: var(--fs-h3); }
.report-dlg p { margin: 0; }
.report-dlg .rp-where { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); overflow-wrap: anywhere; }
:where(html:not(.a11y-contrast)) .report-dlg .rp-where { background: var(--surface-2); }
.report-dlg label { margin-top: var(--sp-2); font-weight: 600; font-size: var(--fs-sm); }
.report-dlg :is(textarea, input) { width: 100%; padding: 10px 12px; font: inherit; border-radius: var(--r-sm); }
:where(html:not(.a11y-contrast)) .report-dlg :is(textarea, input) { border: 1px solid var(--hairline-strong); background: var(--bg); color: var(--ink); }
:where(html:not(.a11y-contrast)) .report-dlg :is(textarea, input):focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.report-dlg textarea { min-height: 110px; resize: vertical; }
.report-dlg .rp-status:empty { display: none; }
.report-dlg .rp-status { font-weight: 600; }
.report-dlg .actions { justify-content: flex-end; margin-top: var(--sp-2); }
/* On a phone the two buttons stack full width, so they never hang on the far side of right-to-left text */
@media (max-width: 480px) { .report-dlg .actions { display: grid; justify-content: stretch; } .report-dlg .actions .btn { width: 100%; } }

/* =====================================================================
   Placement result as a range (N21): "between A2 and B1", an estimate, and what the learner can already do
   ===================================================================== */
.place-result .place-est { max-width: 52ch; margin-inline: auto; font-size: var(--fs-sm); }
.place-result .can-already { max-width: 560px; margin: var(--sp-4) auto 0; padding: var(--sp-4) var(--sp-5); text-align: start; }
:where(html:not(.a11y-contrast)) .place-result .can-already { border-radius: var(--r); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 24%, transparent); }
html.a11y-contrast .place-result .can-already { border: 2px solid var(--ink); border-radius: var(--r); }
.place-result .can-already h2 { margin: 0 0 var(--sp-1); font-size: 1rem; }
.place-result .can-already p { margin: 0; line-height: 1.6; }
.place-result .lv-chip.huge bdi { white-space: nowrap; }

/* The lesson's goal on its first screen (app.js intro step, R1 gap 7): one calm card with a target icon. */
.lesson .ls-goal { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--sp-3); align-items: start; padding: var(--sp-3) var(--sp-4); }
:where(html:not(.a11y-contrast)) .lesson .ls-goal { border-radius: var(--r-lg); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 26%, transparent); }
html.a11y-contrast .lesson .ls-goal { border: 2px solid var(--ink); }
.lesson .ls-goal strong { display: block; font-size: var(--fs-sm); }
.lesson .ls-goal p { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--ink-2); text-wrap: pretty; }
.lesson .lg-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.lesson .lg-ic::before { content: ""; width: 22px; height: 22px; background: var(--ok);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Ccircle cx='12' cy='12' r='4.5'/%3E%3Ccircle cx='12' cy='12' r='.8' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Ccircle cx='12' cy='12' r='4.5'/%3E%3Ccircle cx='12' cy='12' r='.8' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat; }
html.a11y-contrast .lesson .lg-ic::before { background: var(--ink); }
/* Polly stands at the top corner of a lesson (css/pet.css .buddy, 84px): the goal card makes room beside her */
.lesson.buddy-host:has(> .buddy:not(.off)) > .ls-goal { margin-inline-end: 80px; }

/* Less text while practising (docs/plan/2026-10-04-less-text-in-practice.md): the goal and the explanation fold behind a tap,
   the AI-voice note sits behind a small "i" next to the heading. The text stays in the page, so kids mode still filters it. */
.lesson .lg-more summary, .lesson .wd-more summary, .lesson .info-tip summary { cursor: pointer; list-style: none; }
.lesson .lg-more summary::-webkit-details-marker, .lesson .wd-more summary::-webkit-details-marker, .lesson .info-tip summary::-webkit-details-marker { display: none; }
.lesson .lg-more summary { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 40px; }
.lesson .lg-more summary::after, .lesson .wd-more summary::after { content: ""; flex: none; width: 8px; height: 8px; margin-inline: 4px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; }
.lesson .lg-more[open] summary::after, .lesson .wd-more[open] summary::after { transform: rotate(-135deg); }
.lesson .wd-more summary { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 44px; }
.lesson .wd-more[open] > .wd-x { margin-top: var(--sp-1); }
.lesson .q-row { position: relative; display: flex; align-items: center; gap: var(--sp-2); }
.lesson .q-row .q { margin: 0; }
.lesson .info-tip { flex: none; }
.lesson .info-tip summary { display: grid; place-items: center; width: 44px; height: 44px; margin: -10px; font: italic 700 .95rem/1 var(--font-ui); color: var(--muted); }
.lesson .info-tip summary span { display: grid; place-items: center; width: 24px; height: 24px; border: 1.5px solid currentColor; border-radius: 50%; }
.lesson .info-tip[open] > p { position: absolute; z-index: 2; inset-inline: 0; top: 100%; margin: var(--sp-2) 0 0; padding: var(--sp-3); border: 1px solid var(--hairline); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.lesson .lg-more summary:focus-visible, .lesson .wd-more summary:focus-visible, .lesson .info-tip summary:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
.review .rev-more summary { cursor: pointer; list-style: none; min-height: 44px; display: flex; align-items: center; }
.review .rev-more summary::-webkit-details-marker { display: none; }
.review .rev-more summary::after { content: "?"; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-inline-start: var(--sp-2); border: 1.5px solid currentColor; border-radius: 50%; font-size: .75rem; font-weight: 700; }
.review .rev-more summary:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* =====================================================================
   Learner round 2, findings 19 and 22 (low vision, stray details). Same look; only clashes and contrast gaps fixed.
   ===================================================================== */
/* Key-number hints sit inside the answer's padding, so a long or wrapped answer never runs under them ("3hank you"). */
@media (hover: hover) and (pointer: fine) {
  .lesson .ex-opts:not(.pics) .opt:has(> .opt-k) { padding-inline: 40px; }
}
/* A narrow window (QA W7-F8, 320 px): the key hint needs room on its own side only, a single word stays whole
   ("estuve", not "estu / ve"), and the Enter hint on "Next" is dropped */
@media (max-width: 400px) {
  .lesson .ex-opts:not(.pics) .opt:has(> .opt-k) { padding-inline: 36px 12px; }
  .lesson .options .opt { overflow-wrap: break-word; }
  .lesson .options .opt .tgt { font-size: 1.05rem; }
  .lesson .fb-next kbd { display: none; }
}
/* The answer-streak flame sits under Polly instead of on her. */
.lesson .buddy:not(.float) .buddy-streak { bottom: auto; top: calc(100% + 2px); white-space: nowrap; }
/* Polly's hide/show button looks the same, but a finger gets 44 px around it. */
.buddy.off .buddy-x { position: relative; }
.buddy-x::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
/* High contrast: no photo behind the page, and matched pairs keep full contrast with a tick instead of a faint tint. */
html.a11y-contrast :is(.scene-box, .scene-sky, .scene-land, .scene-veil) { display: none !important; }
html.a11y-contrast .lesson .pair.matched { opacity: 1; color: var(--ink); background: var(--bg); border: 2px dashed var(--ink); box-shadow: none; }
html.a11y-contrast .lesson .pair.matched::before { content: '✓ ' / ''; font-weight: 800; }

/* ---------- Redesign phase 2: the lesson intro (docs/plan/2026-10-04-redesign-bento.md §5.3) ----------
   The same parts as before in the rounded "bento" shapes of the new home: the goal sits on a soft tint, the word cards get the
   larger radius, and "Next" stays in reach at the bottom of the screen while the learner looks through the words. */
:where(html:not(.a11y-contrast)) .lesson .ls-goal { background: var(--tint-1, var(--surface-2)); border: 0; border-radius: var(--r-lg); box-shadow: none; }
:where(html:not(.a11y-contrast)) .lesson .word-tile { border-radius: var(--r-lg); }
.lesson .word-tile .tile-img { border-radius: calc(var(--r-lg) - 8px); }
.lesson .wd-panel { border-radius: var(--r-lg); }
/* the bar is sticky only on the intro (the one step with a word grid), so a long list never hides the way on */
.lesson .word-grid ~ .actions { position: sticky; bottom: 0; z-index: 2; margin-block-end: calc(-1 * var(--sp-2)); padding-block: var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom)); }
:where(html:not(.a11y-contrast)) .lesson .word-grid ~ .actions { background: linear-gradient(to bottom, transparent, var(--bg) 28%); }
html.a11y-contrast .lesson .word-grid ~ .actions { background: var(--bg); border-top: 2px solid var(--ink); }

/* ---------- Wave 4: the lesson goal before and after (W04-T014) ----------
   Before: the folded goal card shows the goal itself in one line under its heading, so the learner sees it without a tap;
   opening the card shows the whole sentence instead. After: the same goal on the finish card, with a tick when it was met
   or an open circle and "Again" when it was not. */
.lesson .lg-more summary { flex-wrap: wrap; row-gap: 0; }
.lesson .lg-more .lg-sum { order: 3; flex: 1 0 100%; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--fs-sm); color: var(--ink-2); }
.lesson .lg-more[open] .lg-sum { display: none; }
.lesson.finish .ls-goal-end { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--sp-3); align-items: start; width: 100%; padding: var(--sp-3) var(--sp-4); text-align: start; }
:where(html:not(.a11y-contrast)) .lesson.finish .ls-goal-end { border-radius: var(--r-lg); background: var(--tint-1, var(--surface-2)); }
:where(html:not(.a11y-contrast)) .lesson.finish .ls-goal-end.is-near { background: var(--surface-2); }
html.a11y-contrast .lesson.finish .ls-goal-end { border: 2px solid var(--ink); }
.lesson.finish .ls-goal-end h2 { margin: 0; font-size: 1rem; }
.lesson.finish .ls-goal-end p { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--ink-2); text-wrap: pretty; }
.lesson.finish .ls-goal-end .btn { margin-top: var(--sp-2); }
.lesson.finish .lge-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 800; font-size: 1.25rem; }
.lesson.finish .is-ok .lge-ic { color: var(--surface); background: var(--ok); }
.lesson.finish .is-near .lge-ic { border: 2px dashed var(--ink-2); }
html.a11y-contrast .lesson.finish .is-ok .lge-ic { color: var(--bg); background: var(--ink); }
html.a11y-contrast .lesson.finish .is-near .lge-ic { border: 2px solid var(--ink); }

/* Wave 5 (T051): the word panel waits empty under the words (the one hint above says what a tap does) */
.lesson .wd-panel:empty { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; }

/* =====================================================================
   Word cards: the new words one card at a time (docs/plan/2026-10-12-app-look-word-cards.md). Looks only; the card
   cycle (which card, "I know it" / "Not yet", the return of "not yet" words) is js/wordcards.js
   (docs/plan/2026-10-12-card-cycle-learning-style.md). Markup this styles:
     .pg-deck > .pg-deck-top (.pg-count, .pg-dots > span[.done|.again|.on], .pg-skip)
              > .pg-stack > .pg-card[.is-revealed|.is-out-know|.is-out-again]
                  > img.pg-card-img (optional)
                  > .pg-card-body > .pg-card-head (.pg-card-word, .speak) + .pg-show + .pg-card-back (.pg-card-tr, .pg-card-ex)
              > .pg-acts (.pg-again, .pg-know)
   Layout applies in every mode; colours sit in :where(html:not(.a11y-contrast)), and high contrast gets plain borders.
   ===================================================================== */
.lesson .pg-deck { display: grid; gap: var(--sp-4); width: 100%; max-width: 560px; margin-inline: auto; }
.lesson .pg-deck-top { display: flex; align-items: center; gap: var(--sp-3); min-height: 32px; }
.lesson .pg-count { flex: none; font: 600 var(--fs-sm)/1 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--muted); }
.lesson .pg-dots { flex: 1; display: flex; gap: 4px; min-width: 0; }
.lesson .pg-dots > span { flex: 1; height: 6px; border-radius: var(--r-pill); background: var(--surface-3, var(--rule)); }
.lesson .pg-dots > span.done { background: var(--ok); }
.lesson .pg-dots > span.again { background: var(--warn); }
.lesson .pg-dots > span.on { background: var(--lv, var(--accent)); }
.lesson .pg-skip { flex: none; min-height: 44px; padding: 0 var(--sp-2); border: 0; background: none; font: 500 var(--fs-sm)/1.2 var(--font-ui); color: var(--muted); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.lesson .pg-skip:hover { color: var(--ink); }

/* the stack: the live card in front, two quiet edges behind it say "more cards to come" */
.lesson .pg-stack { position: relative; display: grid; padding-block-end: 14px; }
.lesson .pg-stack::before, .lesson .pg-stack::after { content: ""; position: absolute; z-index: 0; border-radius: var(--r-xl); pointer-events: none; }
.lesson .pg-stack::before { inset: 14px 18px 0; }
.lesson .pg-stack::after { inset: 7px 9px 7px; }
:where(html:not(.a11y-contrast)) .lesson .pg-stack::before { background: color-mix(in srgb, var(--surface) 55%, transparent); border: 1px solid var(--hairline); }
:where(html:not(.a11y-contrast)) .lesson .pg-stack::after { background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--hairline); }
.lesson .pg-stack.is-last::before, .lesson .pg-stack.is-last::after { display: none; }

.lesson .pg-card { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: min(62vh, 520px); overflow: hidden; border-radius: var(--r-xl); }
:where(html:not(.a11y-contrast)) .lesson .pg-card {
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--lv, var(--accent)) 30%, var(--hairline));
  box-shadow: 0 24px 50px -26px rgb(15 20 40 / .45), 0 2px 6px rgb(15 20 40 / .06);
}
html.a11y-contrast .lesson .pg-card { background: var(--bg); border: 2px solid var(--ink); }
.lesson .pg-card-img { display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 42vh; object-fit: cover; }
.lesson .pg-card-body { flex: 1; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-6); }
.lesson .pg-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.lesson .pg-card-word { min-width: 0; overflow-wrap: anywhere; }
.lesson .pg-card-word .tgt, .lesson .pg-card-word.tgt { font: 700 clamp(2rem, 1.6rem + 2vw, 2.6rem)/1.1 var(--font-target); letter-spacing: -.02em; }
.lesson .pg-card-head .speak { flex: none; width: 56px; height: 56px; }
.lesson .pg-card-head .speak svg { width: 24px; height: 24px; }
/* "show the meaning": a wide quiet key where the meaning will appear, so a first tap lands in the right place */
.lesson .pg-show { min-height: 56px; border-radius: var(--r-lg); font: 600 var(--fs-lg)/1.2 var(--font-ui); cursor: pointer; }
:where(html:not(.a11y-contrast)) .lesson .pg-show { color: var(--ink-2); background: var(--surface-2); border: 1px dashed var(--hairline-strong); }
:where(html:not(.a11y-contrast)) .lesson .pg-show:hover { color: var(--ink); border-style: solid; }
html.a11y-contrast .lesson .pg-show { color: var(--ink); background: var(--bg); border: 2px solid var(--ink); }
.lesson .pg-card-back { display: grid; gap: var(--sp-3); }
.lesson .pg-card-back[hidden], .lesson .pg-show[hidden] { display: none; }
.lesson .pg-card-tr { margin: 0; font: 600 1.25rem/1.35 var(--font-ui); color: var(--ink-2); }
.lesson .pg-card-ex { margin: 0; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); font-size: var(--fs-lg); line-height: 1.45; }
.lesson .pg-card-ex .tr { display: block; margin-top: 2px; font-size: var(--fs-sm); color: var(--muted); }
:where(html:not(.a11y-contrast)) .lesson .pg-card-ex { background: var(--surface-2); border: 1px solid var(--hairline); }
html.a11y-contrast .lesson .pg-card-ex { border: 2px solid var(--ink); }

/* the two answers: "Not yet" quiet and amber, "I know it" solid green; side by side, thumb-sized */
.lesson .pg-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); position: sticky; bottom: 0; z-index: 2; padding-block: var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom)); }
:where(html:not(.a11y-contrast)) .lesson .pg-acts { background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
html.a11y-contrast .lesson .pg-acts { background: var(--bg); }
.lesson .pg-acts :is(.pg-again, .pg-know) { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: 60px; padding: 0 var(--sp-4); border-radius: var(--r-pill); font: 700 1.05rem/1.2 var(--font-ui); cursor: pointer; }
:where(html:not(.a11y-contrast)) .lesson .pg-again { color: var(--warn); background: var(--warn-soft); border: 2px solid color-mix(in srgb, var(--warn) 70%, transparent); }
:where(html:not(.a11y-contrast)) .lesson .pg-know { color: var(--on-cta); background: var(--cta, var(--ok)); border: 0; box-shadow: 0 10px 22px -12px var(--ok); }
html.a11y-contrast .lesson .pg-acts :is(.pg-again, .pg-know) { color: var(--ink); background: var(--bg); border: 2px solid var(--ink); }
.lesson .pg-acts :is(.pg-again, .pg-know):focus-visible { outline: none; box-shadow: var(--ring); }
.lesson .pg-acts :is(.pg-again, .pg-know) svg { width: 20px; height: 20px; flex: none; }

/* night look: the card is glass (over a solid base, so the cards behind it don't show through) with an aurora in the level colour behind the word, and the answers glow */
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-card {
  background:
    radial-gradient(120% 70% at 50% 100%, color-mix(in srgb, var(--lv, var(--accent)) 16%, transparent), transparent 70%),
    linear-gradient(160deg, rgb(255 255 255 / .09), rgb(255 255 255 / .02) 60%), linear-gradient(var(--surface), var(--surface)), var(--bg);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .1), 0 28px 60px -28px rgb(0 0 0 / .95), 0 0 52px -24px var(--lv, var(--accent));
}
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-card-word .tgt { text-shadow: 0 0 26px color-mix(in srgb, var(--lv, var(--accent)) 45%, transparent); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-know { box-shadow: 0 0 26px -8px var(--ok); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-again { background: rgb(242 176 67 / .1); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-dots > span.on { box-shadow: 0 0 10px var(--lv, var(--accent)); }

/* the card leaves to the side its answer names, and the meaning fades in; only where motion is welcome, never in calm mode.
   js/wordcards.js adds .is-out-know / .is-out-again and moves on at animationend (or at once when there is no animation). */
@keyframes pg-out-end { to { opacity: 0; translate: 40% 0; rotate: 6deg; } }
@keyframes pg-out-start { to { opacity: 0; translate: -40% 0; rotate: -6deg; } }
@keyframes pg-in { from { opacity: 0; translate: 0 16px; scale: .97; } }
@keyframes pg-reveal { from { opacity: 0; translate: 0 6px; } }
@media (prefers-reduced-motion: no-preference) {
  html:not(.pref-calm) .lesson .pg-card { animation: pg-in .34s var(--ease) both; }
  html:not(.pref-calm) .lesson .pg-card.is-out-know { animation: pg-out-end .28s ease-in both; }
  html:not(.pref-calm) .lesson .pg-card.is-out-again { animation: pg-out-start .28s ease-in both; }
  html:not(.pref-calm)[dir="rtl"] .lesson .pg-card.is-out-know { animation-name: pg-out-start; }
  html:not(.pref-calm)[dir="rtl"] .lesson .pg-card.is-out-again { animation-name: pg-out-end; }
  html:not(.pref-calm) .lesson .pg-card-back:not([hidden]) { animation: pg-reveal .26s var(--ease) both; }
  html:not(.pref-calm) .lesson .pg-acts :is(.pg-again, .pg-know) { transition: transform var(--dur-1) var(--ease), filter var(--dur-1); }
  html:not(.pref-calm) .lesson .pg-acts :is(.pg-again, .pg-know):active { transform: scale(.97); }
}
/* phones: the card takes the screen, the image a little less */
@media (max-width: 520px) {
  .lesson .pg-card { min-height: min(58vh, 480px); }
  .lesson .pg-card-img { max-height: 34vh; }
  .lesson .pg-card-body { padding: var(--sp-4) var(--sp-4) var(--sp-5); }
}

/* Space cats, part 4 (docs/plan/2026-10-12-space-holo.md): in the night theme the word card is a hologram in the colours
   of the crew intro: a rim that runs cyan to pink to lime, faint scan lines (--hud-scan from css/ds/cosmos.css, which lite
   and kids mode turn off), cyan edges on the cards behind, and the word in a cyan-to-pink light. The level chip in the
   lesson's top bar becomes a small planet, like the badges on home. No new motion. */
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-card {
  border: 1.5px solid transparent;
  background:
    var(--hud-scan, none) padding-box,
    radial-gradient(120% 70% at 50% 100%, color-mix(in srgb, var(--lv, var(--accent)) 16%, transparent), transparent 70%) padding-box,
    radial-gradient(80% 60% at 100% 0%, rgb(232 121 249 / .14), transparent 70%) padding-box,
    linear-gradient(160deg, rgb(125 249 255 / .1), rgb(255 255 255 / .02) 60%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(var(--bg), var(--bg)) padding-box,
    linear-gradient(140deg, rgb(125 249 255), rgb(232 121 249) 55%, rgb(163 230 53)) border-box;
  box-shadow: inset 0 0 40px rgb(34 211 238 / .08), 0 28px 60px -28px rgb(0 0 0 / .95), 0 0 56px -22px rgb(232 121 249 / .7), 0 0 40px -20px rgb(34 211 238 / .8);
}
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-stack::before { border-color: rgb(125 249 255 / .16); background: rgb(125 249 255 / .03); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-stack::after { border-color: rgb(125 249 255 / .24); background: rgb(125 249 255 / .05); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-card-word .tgt {
  background: linear-gradient(100deg, white 18%, rgb(125 249 255) 46%, rgb(240 171 252) 78%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none; filter: drop-shadow(0 0 16px rgb(125 249 255 / .45));
}
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-card-head .speak { box-shadow: 0 0 24px -2px rgb(34 211 238 / .75); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-card-ex { background: rgb(125 249 255 / .07); border-color: rgb(125 249 255 / .25); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson-top .lv-chip {
  width: 34px; height: 34px; min-width: 0; padding: 0; border-radius: 50%; color: var(--bg);
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--lv, var(--accent)) 50%, white), var(--lv, var(--accent)) 38%, var(--lv, var(--accent)) 62%, color-mix(in srgb, var(--lv, var(--accent)) 50%, black) 96%);
  box-shadow: inset -4px -5px 8px rgb(0 0 0 / .35), 0 0 16px -3px var(--lv, var(--accent));
}
/* the answer keys' backdrop fades into the sky instead of a black band (it only has to hide the card scrolling under it) */
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-acts { background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg) 72%, transparent) 45%); }
/* Kids look, part 2 (docs/plan/2026-10-20-kids-look.md): for children the night card keeps its colours but drops the strong
   glows, so the screen stays calm: a softer rim, a plain shadow, a quieter halo on the word and the sound button. The
   answer sheet keeps its gold and amber, without the bright glow above it. html.kids outranks the :where() rules above. */
html.kids:not(.a11y-contrast):root[data-theme="dark"] .lesson .pg-card {
  border-radius: var(--r-2xl);
  background:
    radial-gradient(120% 70% at 50% 100%, color-mix(in srgb, var(--lv, var(--accent)) 12%, transparent), transparent 70%) padding-box,
    radial-gradient(80% 60% at 100% 0%, rgb(232 121 249 / .1), transparent 70%) padding-box,
    linear-gradient(160deg, rgb(125 249 255 / .08), rgb(255 255 255 / .02) 60%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(var(--bg), var(--bg)) padding-box,
    linear-gradient(140deg, rgb(125 249 255 / .6), rgb(232 121 249 / .55) 55%, rgb(163 230 53 / .55)) border-box;
  box-shadow: 0 22px 48px -26px rgb(0 0 0 / .9);
}
html.kids:not(.a11y-contrast):root[data-theme="dark"] .lesson .pg-card-word .tgt { filter: drop-shadow(0 0 8px rgb(125 249 255 / .25)); }
html.kids:not(.a11y-contrast):root[data-theme="dark"] .lesson .pg-card-head .speak { box-shadow: 0 0 12px -4px rgb(34 211 238 / .5); }
html.kids:not(.a11y-contrast):root[data-theme="dark"] .lesson > #feedback.feedback.fb2 { box-shadow: 0 -10px 30px -20px rgb(0 0 0 / .8); }

/* =====================================================================
   Letter cards (space cats, part 5; docs/plan/2026-10-12-space-letter.md). The alphabet lessons of the foundation stage
   show one letter at a time with a finger trace pad; the logic is js/letter-card.js (learning-style room,
   docs/plan/2026-10-12-letter-card-trace-pad.md). Markup this styles:
     .pg-letter > .pg-deck-top (.pg-count, .pg-skip) + .pg-letter-big + .pg-letter-name + button.speak
                + .pg-letter-word (img.pg-letter-img, p.pg-letter-ex with .tgt + .tr)
                + .trace-pad[hidden] (canvas.trace-canvas, button.trace-clear)
                + .pg-letter-acts (button.pg-trace-open, button.pg-know)
   The pad draws in the canvas's CSS colour and takes its box size, so both are set here.
   ===================================================================== */
.lesson .pg-letter { display: grid; justify-items: center; gap: var(--sp-4); width: 100%; max-width: 560px; margin-inline: auto; text-align: center; }
.lesson .pg-letter > .pg-deck-top { justify-self: stretch; justify-content: space-between; }
.lesson .pg-letter-big {
  display: grid; place-items: center; width: 100%; min-height: min(34vh, 260px); padding: var(--sp-5); border-radius: var(--r-xl);
  font: 700 clamp(5rem, 3.6rem + 7vw, 8rem)/1 var(--font-target); letter-spacing: .04em; overflow-wrap: anywhere;
}
:where(html:not(.a11y-contrast)) .lesson .pg-letter-big { color: var(--ink); background: var(--surface); border: 1px solid color-mix(in srgb, var(--lv, var(--accent)) 30%, var(--hairline)); box-shadow: var(--e2); }
html.a11y-contrast .lesson .pg-letter-big { color: var(--ink); background: var(--bg); border: 2px solid var(--ink); }
.lesson .pg-letter-name { margin: calc(-1 * var(--sp-2)) 0 0; font: 600 var(--fs-lg)/1.3 var(--font-ui); color: var(--ink-2); }
.lesson .pg-letter > .speak { width: 64px; height: 64px; }
.lesson .pg-letter > .speak svg { width: 28px; height: 28px; }
.lesson .pg-letter-word { display: grid; justify-items: center; gap: var(--sp-3); width: 100%; }
.lesson .pg-letter-word:empty { display: none; }
.lesson .pg-letter-img { display: block; width: min(220px, 62vw); aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-lg); }
.lesson .pg-letter-ex { margin: 0; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); font-size: var(--fs-lg); line-height: 1.45; }
.lesson .pg-letter-ex .tr { display: block; margin-top: 2px; font-size: var(--fs-sm); color: var(--muted); }
:where(html:not(.a11y-contrast)) .lesson .pg-letter-ex { background: var(--surface-2); border: 1px solid var(--hairline); }
html.a11y-contrast .lesson .pg-letter-ex { border: 2px solid var(--ink); }
/* the trace pad: a square frame with a faint writing line; the stroke takes the canvas's colour */
.lesson .trace-pad { position: relative; width: min(100%, 320px); aspect-ratio: 1; border-radius: var(--r-xl); overflow: hidden; }
.lesson .trace-pad[hidden], .lesson .pg-trace-open[hidden] { display: none; }
:where(html:not(.a11y-contrast)) .lesson .trace-pad {
  background: linear-gradient(transparent calc(66% - 1px), var(--hairline-strong) calc(66% - 1px) 66%, transparent 66%), var(--surface);
  border: 2px dashed color-mix(in srgb, var(--lv, var(--accent)) 50%, var(--hairline));
}
html.a11y-contrast .lesson .trace-pad { background: var(--bg); border: 2px solid var(--ink); }
.lesson .trace-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; color: var(--ink); }
:where(html:not(.a11y-contrast)) .lesson .trace-canvas { color: color-mix(in srgb, var(--lv, var(--accent)) 80%, var(--ink)); }
.lesson .trace-clear { position: absolute; top: var(--sp-2); inset-inline-end: var(--sp-2); min-height: 44px; padding: 0 var(--sp-3); border-radius: var(--r-pill); font: 600 var(--fs-sm)/1 var(--font-ui); cursor: pointer; }
:where(html:not(.a11y-contrast)) .lesson .trace-clear { color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--hairline-strong); }
html.a11y-contrast .lesson .trace-clear { color: var(--ink); background: var(--bg); border: 2px solid var(--ink); }
.lesson .pg-letter-acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--sp-3); justify-self: stretch; position: sticky; bottom: 0; z-index: 2; padding-block: var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom)); }
:where(html:not(.a11y-contrast)) .lesson .pg-letter-acts { background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
html.a11y-contrast .lesson .pg-letter-acts { background: var(--bg); }
.lesson .pg-letter-acts .btn { min-height: 56px; width: 100%; min-width: 0; }

/* night look: the letter stands in a HUD frame (corner brackets as background layers, faint scan lines that lite and kids
   mode drop) and glows cyan and pink, like the crew intro's lettering; the trace pad is a cyan grid and draws in cyan */
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-letter-big {
  --b: rgb(125 249 255 / .8);
  border-color: rgb(125 249 255 / .5);
  background:
    linear-gradient(var(--b), var(--b)) left 14px top 14px / 22px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) left 14px top 14px / 2px 22px no-repeat,
    linear-gradient(var(--b), var(--b)) right 14px top 14px / 22px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) right 14px top 14px / 2px 22px no-repeat,
    linear-gradient(var(--b), var(--b)) left 14px bottom 14px / 22px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) left 14px bottom 14px / 2px 22px no-repeat,
    linear-gradient(var(--b), var(--b)) right 14px bottom 14px / 22px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) right 14px bottom 14px / 2px 22px no-repeat,
    var(--hud-scan, none),
    radial-gradient(120% 80% at 50% 110%, rgb(34 211 238 / .3), transparent 70%),
    radial-gradient(90% 70% at 100% 0%, rgb(232 121 249 / .2), transparent 70%),
    linear-gradient(var(--surface), var(--surface)), var(--bg);
  box-shadow: 0 0 50px -16px rgb(34 211 238 / .8), inset 0 0 30px rgb(34 211 238 / .12);
  color: rgb(224 253 255); text-shadow: 0 0 28px rgb(125 249 255 / .85), 0 0 60px rgb(232 121 249 / .55);
}
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-letter-name { color: rgb(189 239 252); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-letter > .speak { box-shadow: 0 0 26px -2px rgb(34 211 238 / .8); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-letter-img { border: 1px solid rgb(125 249 255 / .45); box-shadow: 0 0 24px -10px rgb(34 211 238 / .8); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-letter-ex { background: rgb(125 249 255 / .07); border-color: rgb(125 249 255 / .25); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .trace-pad {
  border: 1.5px solid rgb(125 249 255 / .5);
  background:
    linear-gradient(transparent calc(66% - 1px), rgb(232 121 249 / .45) calc(66% - 1px) 66%, transparent 66%),
    repeating-linear-gradient(0deg, rgb(125 249 255 / .07) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, rgb(125 249 255 / .07) 0 1px, transparent 1px 32px),
    linear-gradient(rgb(6 14 36 / .9), rgb(6 14 36 / .9)), var(--bg);
  box-shadow: inset 0 0 30px rgb(34 211 238 / .12), 0 0 36px -16px rgb(34 211 238 / .8);
}
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .trace-canvas { color: rgb(125 249 255); }
:where(html:not(.a11y-contrast)):root[data-theme="dark"] .lesson .pg-letter-acts { background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg) 72%, transparent) 45%); }
