@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/fonts/nunito-cyrillic-ext.woff2) format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/fonts/nunito-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/fonts/nunito-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/fonts/nunito-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;

  /* Color */
  --ink: #162e48;
  --muted: #4a647e;
  --blue: #155fbb;
  --blue-dark: #104b96;
  --sky: #e8f4ff;
  --line: #cedeed;
  --paper: #fff;
  --page: #f5f9fd;
  --amber: #f5ad22;
  --amber-ink: #8a5200;
  --green: #286746;
  --error: #a62940;

  /* Type */
  --font: "Nunito", "Segoe UI", system-ui, sans-serif;
  --text-xs: .875rem;    /* 14px — smallest size used anywhere */
  --text-sm: .9375rem;   /* 15px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.375rem;   /* 22px */
  --text-2xl: clamp(1.5rem, 3vw, 2rem);
  --text-3xl: clamp(1.875rem, 4.5vw, 2.75rem);
  --text-display: clamp(3rem, 7.5vw, 6rem);
  --weight-regular: 400;
  --weight-medium: 600;
  --weight-bold: 700;
  --weight-heavy: 800;

  /* Space (4px scale) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --gutter: 48px;
  --tap: 44px;

  font: var(--weight-regular) var(--text-base)/1.55 var(--font);
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 290px; min-height: 100dvh; display: flex; flex-direction: column; background: var(--page); }
main { flex: 1; }
button, input, select { font: inherit; }
a { color: var(--blue-dark); text-decoration: none; }
button { cursor: pointer; }
button, a, label { touch-action: manipulation; }
button:disabled { cursor: default; opacity: .55; }
svg { flex: none; vertical-align: middle; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.15; font-weight: var(--weight-heavy); }
h1 { font-size: var(--text-3xl); letter-spacing: -.02em; }
h2 { font-size: var(--text-2xl); letter-spacing: -.01em; }
h3 { font-size: var(--text-xl); }
strong { font-weight: var(--weight-bold); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #ad6500; outline-offset: 4px; }
.wrap, .header-inner, .site-footer { width: min(1112px, calc(100% - var(--gutter))); margin-inline: auto; }
.skip { position: absolute; top: var(--space-2); left: var(--space-2); z-index: 3; transform: translateY(-150%); background: white; padding: var(--space-2) var(--space-3); }
.skip:focus { transform: none; }

/* Header and footer */
.site-header { background: #fcfeff; border-bottom: 1px solid var(--line); }
.header-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.brand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--ink); font-size: var(--text-xl); font-weight: var(--weight-heavy); letter-spacing: -.01em; }
.brand-mark { display: block; width: 40px; height: 40px; border-radius: 23%; }
.header-inner nav { display: flex; align-items: center; gap: var(--space-1); }
.header-inner nav a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--muted); font-weight: var(--weight-bold); padding: 0 var(--space-3); border-radius: var(--radius-sm); }
.header-inner nav a:hover, .header-inner nav [aria-current] { color: var(--blue-dark); background: var(--sky); }
.site-footer { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--text-sm); }
.site-footer a:hover { text-decoration: underline; }

/* Buttons and shared */
.button { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); width: fit-content; min-height: 48px; padding: var(--space-2) var(--space-5); border: 1px solid transparent; border-radius: var(--radius-md); font-weight: var(--weight-bold); line-height: 1.25; text-align: center; }
.button svg { width: 20px; height: 20px; }
.primary { color: #fff; background: var(--blue); }
.primary:hover:not(:disabled) { background: var(--blue-dark); }
.secondary { background: white; color: var(--blue-dark); border-color: var(--line); }
.secondary:hover:not(:disabled), .text-button:hover { background: var(--sky); }
.text-button { appearance: none; min-height: var(--tap); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--blue-dark); font-weight: var(--weight-bold); padding: var(--space-1) var(--space-2); text-align: left; }
.loading, .empty-state { padding: var(--space-8) 0; }
.loading { text-align: center; color: var(--muted); }
.empty-state p, .empty-state a { margin-top: var(--space-5); }
.muted, .status { color: var(--muted); }
.status { font-size: var(--text-sm); margin-top: var(--space-2); }
.status:empty { display: none; }
.error-text { color: var(--error); }

/* Home */
.hero { min-height: 480px; display: grid; grid-template-columns: minmax(265px, .9fr) minmax(0, 1.1fr); align-items: center; gap: clamp(var(--space-5), 5vw, var(--space-8)); padding: var(--space-7) 0; }
.hero h1 { font-size: var(--text-display); line-height: 1.04; letter-spacing: -.03em; }
.grade { margin: 0 0 var(--space-3); font-size: var(--text-sm); font-weight: var(--weight-heavy); letter-spacing: .04em; text-transform: uppercase; color: var(--blue-dark); }
.hero-description { max-width: 380px; font-size: var(--text-lg); color: var(--muted); margin: var(--space-5) 0; }
.hero-figure { position: relative; margin: 0; align-self: center; justify-self: stretch; }
.hero-mascot { position: absolute; z-index: 1; left: -10%; bottom: 6px; width: 30%; pointer-events: none; filter: drop-shadow(0 8px 0 #24415b1f); }
.hero-mascot img { display: block; width: 100%; height: auto; }
.empty-mascot { display: block; width: 140px; height: auto; margin-bottom: var(--space-5); }
.paper-preview { display: block; position: relative; aspect-ratio: 1.47; overflow: hidden; background: #fff; border: 8px solid #dcebf7; border-radius: var(--radius-xl); box-shadow: 0 8px 0 #d0e1ef; }
.hint-box { position: absolute; border: 2px solid var(--amber); border-radius: var(--radius-sm); background: #ffc34326; }
.hint-sound { position: absolute; transform: translate(-50%, -55%); display: grid; place-items: center; width: 24px; height: 24px; color: var(--ink); background: #ffdf84; border-radius: 50%; }
.hint-sound svg { width: 16px; height: 16px; }
.hero-figure figcaption { display: flex; align-items: center; gap: var(--space-2); justify-content: center; color: var(--muted); font-size: var(--text-sm); margin-top: var(--space-4); }
.hero-figure figcaption svg { width: 18px; height: 18px; }
.home-lessons { padding: var(--space-6) 0 var(--space-8); border-top: 1px solid var(--line); }
.home-lessons h2 { margin-bottom: var(--space-5); }
.lesson-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.lesson-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-4); background: white; border: 1px solid var(--line); border-radius: var(--radius-lg); color: var(--ink); padding: var(--space-4); min-height: 88px; }
.lesson-card:hover { border-color: #77ace0; background: #fafdff; }
.lesson-number { display: grid; place-items: center; border-radius: var(--radius-md); background: var(--lesson-tint, var(--card-tint, var(--sky))); color: var(--lesson-ink, var(--card-ink, var(--blue-dark))); font-size: var(--text-xl); font-weight: var(--weight-heavy); width: 48px; height: 48px; }
.lesson-number svg { width: 22px; height: 22px; }
.lesson-card:nth-child(3n+2) { --card-tint: #e2f4e7; --card-ink: var(--green); }
.lesson-card:nth-child(3n+3) { --card-tint: #fff2cb; --card-ink: #815000; }
[data-mascot="3"] { --lesson-tint: var(--sky); --lesson-ink: var(--blue-dark); }
[data-mascot="4"] { --lesson-tint: #e2f4e7; --lesson-ink: var(--green); }
[data-mascot="5"] { --lesson-tint: #fff2cb; --lesson-ink: #815000; }
[data-mascot="6"] { --lesson-tint: #eaf5fc; --lesson-ink: #175b9e; }
[data-mascot="7"] { --lesson-tint: #ebf7ef; --lesson-ink: #236d4d; }
[data-mascot="8"] { --lesson-tint: #fff3e6; --lesson-ink: #9c5425; }
[data-mascot="9"] { --lesson-tint: #f4eefc; --lesson-ink: #634993; }
[data-mascot="10"] { --lesson-tint: #fbeef4; --lesson-ink: #86516a; }
.lesson-card strong, .lesson-card small { display: block; }
.lesson-card strong { font-size: var(--text-lg); }
.lesson-card small { color: var(--muted); font-size: var(--text-xs); }
.lesson-card > svg { color: var(--blue); width: 22px; }

/* Lesson progress: best practice stars and how much has been listened to */
.lessons-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.lessons-heading h2 { margin: 0; }
.star-total { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 6px 12px; border-radius: 999px; color: var(--amber-ink); background: #fff0cc; font-weight: var(--weight-heavy); }
.star-total svg { width: 18px; height: 18px; fill: #ffc83d; stroke: #e0a21a; }
.lesson-info { min-width: 0; }
.lesson-progress { display: flex; align-items: center; gap: var(--space-2); margin-top: 6px; }
.star-row { display: inline-flex; flex: none; gap: 2px; }
.star-row svg { display: block; width: 18px; height: 18px; fill: #e6edf5; stroke: #cdd8e4; }
.star-row .earned svg { fill: #ffc83d; stroke: #e0a21a; }
.lesson-meter { flex: 1; min-width: 24px; height: 6px; border-radius: 6px; background: #e6edf5; overflow: hidden; }
.lesson-meter i { display: block; height: 100%; border-radius: inherit; background: var(--lesson-ink, var(--card-ink, var(--blue))); }
.lesson-card.complete { border-color: #f1c453; box-shadow: 0 0 0 2px #ffe08a inset; background: #fffdf5; }
.reading-pose { object-fit: contain; }
.lesson-pose { display: block; width: 68px; height: 68px; border-radius: 23%; }

/* Reader: the page is a full-screen canvas; bar and dock float above it */
body.immersive { height: 100dvh; overflow: hidden; }
body.immersive .site-header, body.immersive .site-footer { display: none; }
.reader { position: fixed; inset: 0; background: #e3edf6; }
.viewport { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom; cursor: grab;
  padding: calc(var(--bar, 64px) + var(--space-4)) var(--space-5) calc(var(--dock, 140px) + var(--space-4)); }
.viewport:focus-visible { outline-offset: -4px; }
.viewport.dragging, .viewport.dragging .hotspot { cursor: grabbing; }
.canvas-content { display: flex; flex-direction: column; align-items: center; gap: var(--space-5); min-width: min-content; }
.reading-paper { position: relative; flex: none; background: #fff; border-radius: 6px; box-shadow: 0 2px 4px #24415b14, 0 12px 32px #24415b1f; user-select: none; overflow: hidden; }

.glass { background: #ffffffd9; -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4); }
.reader-bar { position: absolute; inset: 0 0 auto; z-index: 3; display: flex; align-items: center; gap: var(--space-3); padding: calc(env(safe-area-inset-top) + var(--space-2)) max(var(--space-4), env(safe-area-inset-right)) var(--space-2) max(var(--space-4), env(safe-area-inset-left)); border-bottom: 1px solid #cedeed99; }
.reader-bar h1 { flex: 1; min-width: 0; font-size: var(--text-xl); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-activity { display: grid; flex: none; place-items: center; width: var(--tap); height: var(--tap); border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--blue-dark); }
.reader-activity:hover { background: var(--sky); }
.reader-activity svg { width: 22px; height: 22px; }
.bar-home { display: block; flex: none; width: var(--tap); height: var(--tap); border-radius: 23%; overflow: hidden; transition: transform .15s; }
.bar-home:hover { transform: scale(1.06); }
.bar-home img { display: block; width: 100%; height: 100%; }
.bar-home .reading-pose, .now-playing .reading-pose { padding: 0; }
.page-switch { display: flex; gap: var(--space-1); overflow-x: auto; scrollbar-width: none; }
.page-switch a { display: grid; place-items: center; flex: none; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: var(--tap); height: var(--tap); color: var(--blue-dark); font-weight: var(--weight-heavy); padding: 0 var(--space-2); }
.page-switch a:hover { border-color: var(--blue); }
.page-switch a[aria-current] { background: var(--blue); color: #fff; border-color: var(--blue); }
/* A gold dot marks a practised page; a ringed dot marks all three stars. */
.page-switch a { position: relative; }
.page-switch a[data-stars]:not([data-stars="0"])::after { content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: #ffc83d; }
.page-switch a[data-stars="3"]::after { box-shadow: 0 0 0 2px #fff, 0 0 0 3px #e0a21a; }

.reader-dock { position: absolute; inset: auto 0 0; z-index: 3; width: min(720px, calc(100% - var(--space-5))); margin: 0 auto calc(env(safe-area-inset-bottom) + var(--space-3)); border: 1px solid #cedeedcc; border-radius: var(--radius-xl); box-shadow: 0 10px 30px #24415b2b; overflow: hidden; }
.reader-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-1) var(--space-2) var(--space-2); }
.toolbar-start, .segmented, .zoom-buttons { display: flex; align-items: center; min-width: 0; gap: var(--space-1); }
.toolbar-start { gap: var(--space-2); }
.segmented { padding: 3px; background: #e9f1f8; border-radius: var(--radius-md); }
.segmented button, .zoom-buttons button, .reveal-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; color: var(--blue-dark); background: transparent; min-height: var(--tap); min-width: var(--tap); border-radius: var(--radius-sm); font-weight: var(--weight-bold); font-size: var(--text-sm); }
.segmented button { min-height: 38px; padding: 0 var(--space-3); }
.segmented button[aria-pressed="true"] { background: white; box-shadow: 0 1px 3px #24415b26; }
.reveal-toggle { padding: 0 var(--space-3); }
.reveal-toggle[aria-pressed="true"] { background: #fff2cb; color: var(--amber-ink); }
.zoom-buttons button:hover, .reveal-toggle:hover, .segmented button:hover { background: var(--sky); }
.segmented button[aria-pressed="true"]:hover { background: white; }
.zoom-buttons svg, .reveal-toggle svg { width: 20px; height: 20px; }

.marking-paper img { display: block; width: 100%; height: auto; pointer-events: none; }

/* Text page: the worksheet redrawn as live text at the photo's coordinates */
.text-page { position: relative; width: 100%; container-type: inline-size; background: #fff; color: var(--ink); font-family: var(--font); font-weight: var(--weight-heavy); line-height: 1; }
.page-text { position: absolute; inset: 0; }
.page-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.text-page .word { position: absolute; display: flex; align-items: center; justify-content: center; white-space: nowrap; font-size: calc(var(--size) * var(--fit, 1)); }
.text-page .page-title { position: absolute; display: flex; align-items: center; justify-content: center; color: #1f7fc4; font-weight: var(--weight-heavy); letter-spacing: -.01em; }
.text-page .v { color: #cf3a3a; }
.text-page .v-group { color: #246c46; }
.text-page .c { color: #1f5fae; }
.page-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--space-5); color: var(--muted); font-size: var(--text-base); font-weight: var(--weight-bold); text-align: center; }
.hotspots, .marks { position: absolute; inset: 0; pointer-events: none; }
.hotspot, .marks span { position: absolute; border: 2px solid transparent; border-radius: clamp(4px, 1vw, 12px); padding: 0; background: transparent; pointer-events: auto; touch-action: inherit; }
.hotspot.active, .marks span { border-color: #ae6d06; background: #fbc55047; }
.hotspot.active.playing { animation: pulse 1s ease-in-out infinite; }
.hotspots.reveal .hotspot:not(.active) { border: 2px dashed #d08a1c; background: #ffd56a1f; }
.hotspots.hinting .hotspot:not(.active) { animation: hint 1.4s ease-in-out 2; }
@media (hover: hover) { .hotspot:hover { border-color: #936820; background: #fbc55027; } }
.hotspot:focus-visible { outline-offset: 0; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 #f5ad2299; }
  50% { box-shadow: 0 0 0 8px #f5ad2200; }
}
@keyframes hint {
  0%, 100% { border-color: transparent; background: transparent; }
  45%, 55% { border-color: #d08a1c; background: #ffd56a40; }
}

.now-playing { display: flex; align-items: center; gap: var(--space-3); min-height: 60px; padding: var(--space-2) var(--space-2) var(--space-1) var(--space-4); }
.now-playing .guide { flex: none; width: 40px; height: 40px; border-radius: 23%; }
.now-playing[data-state="loading"] .guide, .now-playing[data-state="playing"] .guide { display: none; }
.now-playing .bars { display: flex; align-items: flex-end; gap: 3px; height: 18px; color: var(--amber); }
.now-playing .bars i { display: block; width: 4px; height: 6px; border-radius: 2px; background: currentColor; }
.now-playing[data-state="playing"] .bars i { animation: bar .8s ease-in-out infinite; }
.now-playing[data-state="playing"] .bars i:nth-child(2) { animation-delay: -.25s; }
.now-playing[data-state="playing"] .bars i:nth-child(3) { animation-delay: -.5s; }
.now-playing[data-state="loading"] .bars i { animation: wait 1s ease-in-out infinite; }
.now-playing[data-state="loading"] .bars i:nth-child(2) { animation-delay: .15s; }
.now-playing[data-state="loading"] .bars i:nth-child(3) { animation-delay: .3s; }
.now-playing[data-state="idle"] .bars { display: none; }
.now-playing[data-state="prompt"] .bars { display: none; }
.now-playing[data-state="prompt"] .now-playing-text { font-size: var(--text-base); font-weight: var(--weight-bold); color: var(--muted); }
.now-playing[data-state="error"] .bars { display: none; }
.now-playing-text { flex: 1; min-width: 0; font-size: var(--text-xl); font-weight: var(--weight-heavy); line-height: 1.25; overflow-wrap: anywhere; }
.now-playing[data-state="error"] .now-playing-text { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--error); }
.replay { display: grid; place-items: center; flex: none; width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; color: #fff; background: var(--blue); }
.replay:hover { background: var(--blue-dark); }
.replay svg { width: 22px; height: 22px; }

.practice-launch.button { flex: none; min-height: var(--tap); padding-inline: var(--space-3); color: var(--amber-ink); background: #fff0cc; }
.practice-launch:hover { background: #ffe3a4; }
.practice-launch svg { width: 18px; height: 18px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.practice-panel { display: none; }
.reader[data-practicing] :is(.now-playing, .toolbar-start, .page-switch, .reader-pager, .reading-note) { display: none; }
.reader[data-practicing] .practice-panel { display: block; padding: var(--space-3) var(--space-3) var(--space-1); outline: none; }

/* Progress: one dot per question, a star for a first-try answer */
.practice-meter { display: flex; align-items: center; gap: var(--space-3); }
.practice-dots { display: flex; flex: 1; gap: 6px; margin: 0; padding: 0; list-style: none; }
.practice-dots li { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #e3ecf6; transition: transform .2s, background .2s; }
.practice-dots li.current { background: #fff; box-shadow: inset 0 0 0 3px var(--blue); transform: scale(1.1); }
.practice-dots li.first { background: #ffc83d; }
.practice-dots li.retry { background: #8fd6a8; }
.practice-dots li.skipped { background: #cfd8e3; }
.practice-dots svg { width: 16px; height: 16px; fill: #fff; stroke: #fff; }
.practice-score { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; color: var(--amber-ink); background: #fff0cc; font-weight: var(--weight-heavy); white-space: nowrap; }
.practice-score svg { width: 16px; height: 16px; fill: #ffc83d; stroke: #e0a21a; }
.practice-exit { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; }
.practice-exit:hover { color: var(--ink); background: var(--sky); }
.practice-exit svg { width: 20px; height: 20px; }

/* Prompt: one big listen button the child can always press */
.practice-prompt { display: flex; align-items: center; gap: var(--space-3); min-height: 76px; }
.practice-listen { position: relative; display: grid; place-items: center; flex: none; width: 64px; height: 64px; border: 0; border-radius: 50%; color: #fff; background: var(--blue); box-shadow: 0 5px 0 var(--blue-dark); transition: transform .1s, box-shadow .1s; }
.practice-listen:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--blue-dark); }
.practice-listen svg { width: 30px; height: 30px; }
.practice-listen:disabled { opacity: 1; cursor: default; }
.practice-panel[data-listening] .practice-listen::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid #155fbb66; animation: listen-ring 1s ease-out infinite; }
@keyframes listen-ring { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.practice-status { flex: 1; min-width: 0; font-size: var(--text-lg); font-weight: var(--weight-heavy); line-height: 1.25; }
.practice-panel[data-correct] .practice-status { color: var(--green); }
.practice-skip { flex: none; color: var(--muted); font-size: var(--text-sm); }

/* While practising, only the answer choices stay bright */
.reader[data-practicing]:not([data-practicing="sentence"]) .text-page .word { transition: opacity .25s; }
.reader[data-practicing]:not([data-practicing="sentence"]) .text-page .word:not(.practice-choice) { opacity: .22; }
.reader[data-practicing] .hotspots .hotspot { border-color: #4f83ba59; }
.reader[data-practicing] .hotspots .hotspot.practice-right { border-color: #28744d; background: #63c18a55; animation: pop .35s ease-out; }
.reader[data-practicing] .hotspots .hotspot.practice-try { border-color: #c0392b; background: #ff8a7a40; animation: shake .4s ease-in-out; }
.reader[data-practicing] .hotspots .hotspot.practice-hint { border-color: #e0a21a; background: #ffd56a40; animation: hint-glow 1.1s ease-in-out infinite; }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes hint-glow { 50% { box-shadow: 0 0 0 6px #ffc83d66; } }

/* Correct answer: a big cheer over the page, then the game moves on */
.practice-burst { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: var(--space-5); pointer-events: none; }
.practice-burst[hidden] { display: none; }
.practice-burst-card { pointer-events: auto; display: grid; justify-items: center; gap: var(--space-1); padding: var(--space-4) var(--space-6) var(--space-5); border: 0; border-radius: 28px; color: var(--green); background: #fff; box-shadow: 0 18px 50px #24415b40, 0 0 0 6px #ffc83d; animation: burst-in .45s cubic-bezier(.2, 1.4, .4, 1); }
.practice-burst-art img { display: block; width: 132px; height: 132px; }
.practice-burst-card strong { font-size: 2.5rem; font-weight: var(--weight-heavy); line-height: 1; }
.practice-burst-points { color: var(--amber-ink); font-size: var(--text-xl); font-weight: var(--weight-heavy); }
@keyframes burst-in { from { transform: scale(.4) rotate(-6deg); opacity: 0; } }
.confetti { position: absolute; inset: 0; overflow: hidden; }
.confetti i { position: absolute; top: 42%; left: 50%; width: 10px; height: 14px; border-radius: 3px; opacity: 0; animation: confetti 1.1s ease-out forwards; }
.confetti i:nth-child(4n+1) { background: #ffc83d; }
.confetti i:nth-child(4n+2) { background: #ff6f86; }
.confetti i:nth-child(4n+3) { background: #3d8bff; }
.confetti i:nth-child(4n+4) { background: #22b865; }
.confetti i:nth-child(1) { --x: -150px; --y: -170px; --r: 200deg; animation-delay: 0s; }
.confetti i:nth-child(2) { --x: 140px; --y: -190px; --r: -160deg; animation-delay: 0.03s; }
.confetti i:nth-child(3) { --x: -90px; --y: -230px; --r: 120deg; animation-delay: 0.05s; }
.confetti i:nth-child(4) { --x: 110px; --y: -120px; --r: 240deg; animation-delay: 0.02s; }
.confetti i:nth-child(5) { --x: -180px; --y: -60px; --r: -200deg; animation-delay: 0.06s; }
.confetti i:nth-child(6) { --x: 170px; --y: -50px; --r: 180deg; animation-delay: 0.04s; }
.confetti i:nth-child(7) { --x: -40px; --y: -250px; --r: 300deg; animation-delay: 0.01s; }
.confetti i:nth-child(8) { --x: 60px; --y: -240px; --r: -260deg; animation-delay: 0.07s; }
.confetti i:nth-child(9) { --x: -130px; --y: 40px; --r: 160deg; animation-delay: 0.05s; }
.confetti i:nth-child(10) { --x: 150px; --y: 60px; --r: -140deg; animation-delay: 0.03s; }
.confetti i:nth-child(11) { --x: -200px; --y: -140px; --r: 260deg; animation-delay: 0.08s; }
.confetti i:nth-child(12) { --x: 210px; --y: -150px; --r: -220deg; animation-delay: 0.02s; }
.confetti i:nth-child(13) { --x: 20px; --y: -200px; --r: 180deg; animation-delay: 0.06s; }
.confetti i:nth-child(14) { --x: -60px; --y: -140px; --r: -180deg; animation-delay: 0.04s; }
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 260px)) rotate(var(--r)); }
}

.practice-dialog { position: fixed; width: min(416px, calc(100% - var(--space-5))); max-height: calc(100dvh - var(--space-5)); padding: var(--space-5); color: var(--ink); background: var(--paper); border: 0; border-radius: 28px; box-shadow: 0 24px 60px #24415b40; }
.practice-dialog::backdrop { background: #162e4870; }
.practice-dialog h2 { margin-bottom: var(--space-2); }
.practice-setup { text-align: center; }
.practice-setup-mascot { display: block; width: 88px; height: 88px; margin: 0 auto var(--space-3); border-radius: 23%; }
.practice-setup p, .practice-result-count { color: var(--muted); font-weight: var(--weight-bold); }
.practice-close { position: absolute; top: var(--space-2); right: var(--space-2); width: var(--tap); height: var(--tap); display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--blue-dark); background: var(--sky); }
.practice-close svg { width: 20px; height: 20px; }
.practice-types { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-4); }
.practice-types .button { display: grid; gap: 2px; width: 100%; min-height: 72px; padding: var(--space-2); border-width: 2px; border-radius: 18px; font-size: var(--text-lg); box-shadow: 0 4px 0 var(--line); }
.practice-types .button:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--line); }
.practice-types .button small { color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.practice-types .button:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
.practice-results { text-align: center; }
.practice-celebration img { display: block; width: min(100%, 220px); height: auto; margin: 0 auto var(--space-2); border-radius: var(--radius-lg); }
.practice-stars { display: flex; justify-content: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.practice-stars svg { width: 44px; height: 44px; fill: #e3ecf6; stroke: #cfd8e3; }
.practice-stars svg:nth-child(2) { transform: translateY(-8px) scale(1.15); }
.practice-stars svg.earned { fill: #ffc83d; stroke: #e0a21a; animation: star-in .5s cubic-bezier(.2, 1.4, .4, 1) backwards; }
.practice-stars svg.earned:nth-child(2) { animation-delay: .15s; }
.practice-stars svg.earned:nth-child(3) { animation-delay: .3s; }
@keyframes star-in { from { transform: scale(0) rotate(-40deg); } }
.practice-record { display: inline-flex; align-items: center; gap: 6px; margin: var(--space-1) 0; padding: 4px 12px; border-radius: 999px; color: var(--amber-ink); background: #fff0cc; font-weight: var(--weight-heavy); }
.practice-record[hidden] { display: none; }
.practice-record svg { width: 16px; height: 16px; fill: #ffc83d; stroke: #e0a21a; }
.practice-total { color: var(--blue-dark); font-size: var(--text-3xl); font-weight: var(--weight-heavy); line-height: 1.2; margin: var(--space-2) 0; }
.practice-result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-4); }
.practice-result-actions .button { padding-inline: var(--space-4); }
@media (prefers-reduced-motion: reduce) {
  .practice-burst-card, .confetti i, .practice-stars svg.earned, .hotspot.practice-try, .hotspot.practice-right, .hotspot.practice-hint, .practice-panel[data-listening] .practice-listen::after { animation: none !important; }
  .confetti { display: none; }
}

@keyframes bar {
  0%, 100% { height: 5px; }
  50% { height: 18px; }
}
@keyframes wait {
  0%, 100% { opacity: .3; }
  50% { opacity: 1; }
}

.reading-note { width: min(790px, calc(100% - 2 * var(--space-4))); color: var(--muted); font-size: var(--text-base); line-height: 1.5; }
.reading-note span { display: block; }
.reader-pager { display: flex; justify-content: space-between; gap: var(--space-3); width: 100%; max-width: 790px; }
.reader-pager .button { min-height: 52px; font-size: var(--text-lg); }
.reader-pager .next { margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  .hotspot.active.playing, .hotspots.hinting .hotspot, .now-playing .bars i { animation: none !important; }
  .hotspots.hinting .hotspot:not(.active) { border-color: #d08a1c; background: #ffd56a40; }
}

/* Weekly activity */
.activity { padding-block: var(--space-7) var(--space-8); }
.activity-heading { margin-bottom: var(--space-5); }
.activity-heading h1 { font-size: clamp(2.25rem, 6vw, 3.5rem); }
.activity-heading p, .activity-note { color: var(--muted); }
.activity-heading p { margin-top: var(--space-2); }
.activity-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.activity-tabs button { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: var(--space-2) var(--space-4); background: var(--paper); color: var(--blue-dark); border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: var(--weight-bold); }
.activity-tabs button:hover { background: var(--sky); }
.activity-tabs button[aria-selected="true"] { background: var(--blue-dark); color: #fff; border-color: var(--blue-dark); }
.activity-tabs svg { width: 18px; height: 18px; }
.activity-week { padding: var(--space-5); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-xl); }
.activity-week-header, .activity-scope, .activity-week-nav { display: flex; align-items: center; gap: var(--space-3); }
.activity-week-header, .activity-scope { justify-content: space-between; }
.activity-week-header h2, .activity-scope h3 { font-size: var(--text-xl); }
.activity-week-nav { gap: var(--space-2); font-weight: var(--weight-bold); }
.activity-week-nav button { display: grid; place-items: center; flex: none; width: var(--tap); height: var(--tap); background: #fff; color: var(--blue-dark); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.activity-week-nav button:hover:not(:disabled) { background: var(--sky); }
.activity-week-nav button svg { width: 18px; height: 18px; }
.activity-calendar { display: grid; grid-template-columns: repeat(7, minmax(44px, 1fr)); gap: var(--space-2); margin: var(--space-4) 0; overflow-x: auto; padding: var(--space-1); }
.activity-calendar button { display: grid; justify-items: center; align-content: center; min-height: 94px; gap: var(--space-1); padding: var(--space-2) 0; color: var(--ink); background: var(--page); border: 1px solid var(--line); border-radius: var(--radius-md); font-size: var(--text-xs); line-height: 1.2; }
.activity-calendar:not(.activity-month) button:hover:not(:disabled), .activity-calendar:not(.activity-month) button[aria-pressed="true"] { background: var(--sky); border-color: var(--blue); }
.activity-calendar button[aria-pressed="true"] { box-shadow: inset 0 -3px 0 var(--blue); }
.activity-calendar button:focus-visible { outline-offset: -3px; }
.activity-calendar button[aria-current="date"] time { background: var(--blue); color: #fff; }
.activity-calendar time { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: var(--text-lg); font-weight: var(--weight-heavy); }
.activity-day-points { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1); color: var(--amber-ink); font-weight: var(--weight-bold); }
.activity-day-points svg { width: 13px; height: 13px; fill: #ffdd84; }
.activity [data-activity-level="0"] { --activity-fill: #fff; }
.activity [data-activity-level="1"] { --activity-fill: #e7f7e9; }
.activity [data-activity-level="2"] { --activity-fill: #bde9c5; }
.activity [data-activity-level="3"] { --activity-fill: #79cc95; }
.activity [data-activity-level="4"] { --activity-fill: #256e4a; --activity-text: #fff; }
.activity-month { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-1); margin-bottom: var(--space-3); }
.activity-weekday { text-align: center; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.activity-month button { grid-template-rows: 1fr auto; justify-items: start; min-height: clamp(54px, 7vw, 70px); padding: var(--space-2); background: var(--activity-fill); color: var(--activity-text, var(--ink)); }
.activity-month button:hover:not(:disabled), .activity-month button[aria-pressed="true"] { border-color: var(--blue); }
.activity-month button:disabled { color: var(--muted); opacity: 1; }
.activity-month button .activity-day-points { justify-self: end; color: inherit; }
.activity-legend { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-5); color: var(--muted); font-size: var(--text-xs); }
.activity-legend ul { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); list-style: none; margin: 0; padding: 0; }
.activity-legend li { display: inline-flex; align-items: center; gap: var(--space-1); }
.activity-legend i { width: 16px; height: 16px; background: var(--activity-fill); border: 1px solid var(--line); border-radius: 4px; }
.activity-scope { padding-bottom: var(--space-2); border-bottom: 1px solid var(--line); }
.activity-scope .text-button { text-align: right; }
.activity-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, .9fr); gap: var(--space-3); margin: var(--space-3) 0 0; }
.activity-totals > div { padding: var(--space-3); }
.activity-totals > div:last-child { background: #fff2cb; color: var(--amber-ink); border-radius: var(--radius-md); }
.activity-totals dt { font-weight: var(--weight-bold); font-size: var(--text-sm); line-height: 1.25; }
.activity-totals dd { margin: var(--space-1) 0 0; font-size: var(--text-2xl); font-weight: var(--weight-heavy); line-height: 1.15; font-variant-numeric: tabular-nums; }
.activity-totals .activity-metric-note { color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-regular); }
.activity-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--space-6); margin-top: var(--space-6); }
.activity-detail h2 { margin-bottom: var(--space-3); }
.activity-by-type table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.activity-by-type th, .activity-by-type td { border-bottom: 1px solid var(--line); padding: var(--space-2); text-align: right; }
.activity-by-type th:first-child { text-align: left; }
.activity-by-type thead th { color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.activity-lesson-group + .activity-lesson-group { margin-top: var(--space-5); }
.activity-lesson-group h3 { color: var(--muted); font-size: var(--text-base); }
.activity-lesson-group ul { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.activity-lesson-group li { border-bottom: 1px solid var(--line); padding: var(--space-2) 0 var(--space-3); overflow-wrap: anywhere; }
.activity-lesson-group a, .activity-lesson-group strong { display: flex; align-items: center; width: fit-content; min-height: var(--tap); font-weight: var(--weight-heavy); }
.activity-lesson-group a:hover { text-decoration: underline; }
.activity-lesson-group li span { display: block; color: var(--muted); font-size: var(--text-xs); }
.activity-empty { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); padding: var(--space-1) 0; }
.activity-note { margin-top: var(--space-5); font-size: var(--text-xs); }

/* One-time donation invitation */
.donate-toast { position: fixed; z-index: 10; right: max(var(--space-5), env(safe-area-inset-right)); bottom: calc(env(safe-area-inset-bottom) + var(--space-5)); display: flex; align-items: flex-start; gap: var(--space-3); width: min(380px, calc(100% - var(--space-6))); padding: var(--space-4); background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 14px 40px #24415b33; animation: toast-in .35s cubic-bezier(.2, .8, .2, 1); }
.donate-toast.leaving { animation: toast-out .25s ease-in forwards; }
body.immersive .donate-toast { top: calc(env(safe-area-inset-top) + 72px); bottom: auto; }
.donate-toast-icon { flex: none; width: 48px; height: 48px; border-radius: 23%; }
.donate-toast-body { flex: 1; min-width: 0; }
.donate-toast-body strong { display: block; font-size: var(--text-lg); line-height: 1.3; padding-right: var(--space-5); }
.donate-toast-body p { margin-top: var(--space-1); color: var(--muted); font-size: var(--text-sm); line-height: 1.45; }
.donate-toast-actions { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); }
.donate-toast-actions .button { min-height: var(--tap); padding-inline: var(--space-4); }
.donate-toast-actions .button svg { width: 18px; height: 18px; }
.donate-toast-close { position: absolute; top: var(--space-2); right: var(--space-2); display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); color: var(--muted); background: transparent; }
.donate-toast-close:hover { background: var(--sky); color: var(--ink); }
.donate-toast-close svg { width: 18px; height: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(16px); } }
body.immersive .donate-toast { animation-name: toast-in-top; }
body.immersive .donate-toast.leaving { animation-name: toast-out-top; }
@keyframes toast-in-top { from { opacity: 0; transform: translateY(-16px); } }
@keyframes toast-out-top { to { opacity: 0; transform: translateY(-16px); } }
@media (max-width: 545px) {
  .donate-toast { left: var(--space-3); right: var(--space-3); width: auto; bottom: calc(env(safe-area-inset-bottom) + var(--space-3)); }
}
@media (prefers-reduced-motion: reduce) {
  .donate-toast, .donate-toast.leaving { animation-duration: .01s; }
}

/* Donate */
.donate-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); gap: clamp(var(--space-5), 7vw, 96px); align-items: start; padding-top: clamp(var(--space-6), 7vw, 80px); padding-bottom: var(--space-8); }
.donate-mascot { display: block; width: clamp(120px, 16vw, 170px); height: auto; margin-bottom: var(--space-4); }
.donate-copy p { margin-top: var(--space-4); max-width: 440px; color: var(--muted); font-size: var(--text-lg); }
.checkout, .panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(var(--space-4), 3vw, 28px); }
.checkout form { display: grid; gap: var(--space-3); }
.checkout h2 { font-size: var(--text-xl); margin-bottom: var(--space-1); }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.amounts button { min-height: var(--tap); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--blue-dark); font-weight: var(--weight-bold); background: #fff; }
.amounts button[aria-pressed="true"] { border-color: var(--blue); background: var(--sky); }
label { color: var(--ink); font-weight: var(--weight-bold); }
input:not([type="checkbox"]), select { display: block; width: 100%; max-width: 100%; height: var(--tap); border-radius: var(--radius-sm); border: 1px solid #bbcee0; background: #fcfeff; color: var(--ink); font-weight: var(--weight-regular); padding: var(--space-2) var(--space-3); }
input[type="file"] { line-height: 1.85; font-size: var(--text-sm); }
label > input:not([type="checkbox"]), label > select { margin-top: var(--space-1); }
.checkout form .primary { width: 100%; margin-top: var(--space-1); }
.checkout .qr { width: min(250px, 100%); height: auto; display: block; margin: var(--space-3) auto; }
.bank-links, .checkout-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-4); }
.bank-links a { padding: var(--space-1) var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.payment-complete { text-align: center; padding: var(--space-4); }
.payment-complete > svg { color: var(--green); width: 44px; height: 44px; margin-bottom: var(--space-3); }

/* Admin */
.admin-login { padding: var(--space-8) 0; }
.admin-login .panel { max-width: 430px; margin-top: var(--space-5); display: grid; gap: var(--space-3); }
.admin-layout { padding: var(--space-6) 0 var(--space-7); }
.admin-heading { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.admin-heading p { margin-top: var(--space-2); color: var(--muted); }
.admin-workspace { display: grid; grid-template-columns: minmax(175px, 240px) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.admin-side { display: grid; gap: var(--space-3); padding: var(--space-4); }
.admin-side h2 { font-size: var(--text-xl); }
#admin-readings { display: grid; gap: var(--space-1); }
#admin-readings button, .item-list button { display: flex; align-items: center; justify-content: space-between; gap: var(--space-1); text-align: left; width: 100%; min-height: var(--tap); padding: var(--space-1) var(--space-2); color: var(--ink); background: #fff; border: 1px solid transparent; border-radius: var(--radius-sm); overflow: hidden; }
#admin-readings button:hover, #admin-readings button[aria-pressed=true], .item-list button:hover, .item-list button[aria-pressed=true] { background: var(--sky); border-color: var(--line); }
#admin-readings small { display: block; color: var(--muted); font-size: var(--text-xs); }
.pill { padding: 2px 6px; border-radius: 6px; color: #6a3f22; background: #f8eadd; font-size: var(--text-xs); font-weight: var(--weight-bold); }
.pill.on { color: var(--green); background: #e0f3e7; }
.lesson-settings { padding: var(--space-4); margin-bottom: var(--space-3); }
.lesson-settings form { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
.lesson-settings form > label:first-child { flex: 1 1 180px; }
.checkbox { display: flex; align-items: center; align-self: end; gap: var(--space-1); min-height: var(--tap); }
.checkbox input { accent-color: var(--blue); width: 16px; height: 16px; }
.item-workspace { padding: var(--space-4); }
.item-head, .detail-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.item-head h2 { font-size: var(--text-xl); }
.filters { display: grid; grid-template-columns: minmax(80px, .6fr) 1fr; gap: var(--space-3); margin: var(--space-4) 0 var(--space-3); }
.item-grid { display: grid; grid-template-columns: minmax(122px, .66fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.item-list { display: grid; align-content: start; gap: 2px; max-height: 450px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-1); }
.item-list button > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.item-list small { flex: none; color: var(--muted); font-size: var(--text-xs); }
.item-list svg { width: 16px; height: 16px; }
.item-detail { display: grid; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm); background: var(--page); min-width: 0; }
.item-detail h3 { overflow-wrap: anywhere; }
.detail-heading small { color: var(--muted); font-size: var(--text-xs); }
.clip-info, .edit-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.clip-info span { font-size: var(--text-xs); color: var(--muted); }
.generation-form, .upload-form, .new-reading { display: grid; gap: var(--space-2); }
.upload-form { border-top: 1px solid var(--line); padding-top: var(--space-3); margin-top: var(--space-1); }
.new-reading { max-width: 540px; }
.marking-paper { position: relative; max-width: 100%; cursor: crosshair; touch-action: none; }
.marks span { pointer-events: none; }

@media (max-width: 750px) {
  .hero { min-height: auto; gap: var(--space-5); }
  .lesson-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-workspace { grid-template-columns: 1fr; }
  #admin-readings { grid-template-columns: repeat(auto-fit, minmax(123px, 1fr)); }
  .activity-detail { grid-template-columns: 1fr; gap: var(--space-5); }
  .activity-totals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 545px) {
  :root { --gutter: 32px; }
  .header-inner { min-height: 64px; }
  .brand { gap: var(--space-2); font-size: var(--text-lg); }
  .brand-mark { width: 36px; height: 36px; }
  .header-inner nav { gap: 0; }
  .header-inner nav a { padding: 0 var(--space-2); font-size: var(--text-sm); }
  .hero, .donate-layout { grid-template-columns: 1fr; }
  .hero { padding: var(--space-6) 0 var(--space-5); }
  .hero h1 { font-size: clamp(3rem, 13vw, 4.25rem); }
  .hero-description { margin-top: var(--space-4); }
  .lesson-grid { grid-template-columns: 1fr; }
  .hero-mascot { left: -2%; width: 28%; }
  .hero-figure figcaption { padding-left: 24%; }
  .home-lessons { padding-bottom: var(--space-6); }
  .reader, .viewport { background: #fff; }
  .viewport { padding-inline: 0; }
  .reading-paper { border-radius: 0; box-shadow: none; }
  .reader-pager { padding-inline: var(--space-4); }
  .reader-pager .button { flex: 1; padding-inline: var(--space-3); font-size: var(--text-base); }
  .reader-bar { gap: var(--space-2); padding-inline: max(var(--space-3), env(safe-area-inset-left)) max(var(--space-3), env(safe-area-inset-right)); }
  .reader-bar h1 { font-size: var(--text-lg); }
  .bar-home { width: 40px; height: 40px; }
  .page-switch a { min-width: 40px; height: 40px; }
  .reader[data-layout="numbers"] .reader-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
  .reader[data-layout="numbers"] .page-switch { grid-column: 1 / -1; }
  .reader[data-layout="numbers"] .page-switch a { flex: 1 0 auto; font-size: var(--text-sm); }
  .reader-dock { width: calc(100% - var(--space-4)); margin-bottom: calc(env(safe-area-inset-bottom) + var(--space-2)); border-radius: 20px; }
  .reader-toolbar { padding-inline: var(--space-1); }
  .toolbar-start { gap: var(--space-1); }
  .segmented button { padding: 0 10px; }
  .zoom-buttons { gap: 0; }
  .zoom-buttons button { min-width: 36px; }
  .reveal-toggle span { display: none; }
  .reveal-toggle { padding: 0; min-width: 40px; }
  .now-playing { min-height: 56px; padding-left: var(--space-3); }
  .practice-launch.button { padding-inline: var(--space-2); font-size: var(--text-sm); }
  .practice-meter, .practice-prompt { gap: var(--space-2); }
  .practice-dots { gap: 4px; }
  .practice-dots li { width: 22px; height: 22px; }
  .practice-listen { width: 56px; height: 56px; }
  .practice-status { font-size: var(--text-base); }
  .donate-layout { padding-bottom: var(--space-7); }
  .item-grid { grid-template-columns: 1fr; }
  .item-list { max-height: 190px; }
  .activity { padding-block: var(--space-6) var(--space-7); }
  .activity-week { padding: var(--space-3); }
  .activity-calendar { gap: 3px; padding-inline: 2px; }
  .activity-week-header { flex-wrap: wrap; gap: var(--space-2); }
  .activity-week-nav { margin-left: auto; }
  .activity-month button { justify-items: center; padding: var(--space-1) 0; }
  .activity-month button .activity-day-points { justify-self: center; gap: 2px; }
  .activity-month .activity-day-points svg { width: 10px; height: 10px; }
  .activity-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .activity-totals > div { padding: var(--space-2); }
  .activity-totals > div:last-child { grid-column: 1 / -1; }
}
@media (max-width: 430px) {
  .header-inner { flex-wrap: wrap; gap: 0; padding-top: var(--space-2); }
  .header-inner nav { width: 100%; justify-content: space-between; }
  .reader-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
  .reader-bar .page-switch { grid-column: 1 / -1; }
}
@media (max-width: 360px) {
  .activity-month .activity-day-points svg { display: none; }
}

/* Цагаан толгой: vowels red, consonants blue, signs purple, as in the school primer */
.alphabet-page, .letter-panel { --vowel: #c8334f; --vowel-soft: #ffeef1; --consonant: var(--blue); --consonant-soft: var(--sky); --sign: #6a4fb3; --sign-soft: #f1edfb; }
.alphabet-page { padding: var(--space-6) 0 var(--space-8); }
body.letter-open .alphabet-page { padding-bottom: 340px; }
.alphabet-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.alphabet-lead { max-width: 34rem; margin: var(--space-2) 0 0; color: var(--muted); }
.alphabet-legend { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; font-size: var(--text-sm); font-weight: var(--weight-bold); }
.alphabet-legend li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 8px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.alphabet-legend i { width: 12px; height: 12px; border-radius: 50%; background: var(--consonant); }
.alphabet-legend .vowel i { background: var(--vowel); }
.alphabet-legend .sign i { background: var(--sign); }

.alphabet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.letter-card { --tone: var(--consonant); --soft: var(--consonant-soft); position: relative; display: grid; justify-items: center; width: 100%; height: 100%; padding: var(--space-2) var(--space-2) var(--space-3); border: 2px solid var(--line); border-radius: 20px; color: var(--ink); background: #fff; box-shadow: 0 4px 0 var(--line); font: inherit; text-align: center; cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; }
.letter-card.vowel, .letter-panel.vowel { --tone: var(--vowel); --soft: var(--vowel-soft); }
.letter-card.sign, .letter-panel.sign { --tone: var(--sign); --soft: var(--sign-soft); }
.letter-panel.consonant { --tone: var(--consonant); --soft: var(--consonant-soft); }
.letter-card:hover { border-color: var(--tone); }
.letter-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.letter-card[aria-pressed="true"] { border-color: var(--tone); background: var(--soft); box-shadow: 0 4px 0 var(--tone); }
.letter-glyph { justify-self: start; color: var(--tone); font-size: 2rem; font-weight: var(--weight-heavy); line-height: 1; }
.letter-glyph small, .letter-hero-glyph small { margin-left: 2px; font-size: .62em; }
.letter-card img { display: block; width: 70%; height: auto; aspect-ratio: 1; margin: -2px 0 var(--space-2); object-fit: contain; }
.letter-word { font-size: var(--text-base); font-weight: var(--weight-heavy); line-height: 1.2; overflow-wrap: anywhere; }
.letter-card mark, .letter-panel mark { color: var(--tone); background: none; }

.letter-panel { --tone: var(--consonant); --soft: var(--consonant-soft); position: fixed; inset: auto 0 0; z-index: 20; padding: var(--space-3) 0 calc(var(--space-3) + env(safe-area-inset-bottom)); background: #fff; border-top: 3px solid var(--tone); border-radius: 24px 24px 0 0; box-shadow: 0 -12px 40px #24415b2e; animation: panel-up .28s cubic-bezier(.2, .9, .3, 1); }
.letter-panel[hidden] { display: none; }
@keyframes panel-up { from { transform: translateY(100%); } }
.letter-panel-inner { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--space-5); width: min(1112px, calc(100% - var(--gutter))); margin-inline: auto; }
.letter-hero { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; gap: 0 var(--space-2); padding: var(--space-3); border: 0; border-radius: 20px; color: var(--ink); background: var(--soft); font: inherit; text-align: left; cursor: pointer; }
.letter-hero-glyph { color: var(--tone); font-size: 3rem; font-weight: var(--weight-heavy); line-height: 1; }
.letter-hero img { grid-row: span 2; justify-self: end; width: 96px; height: 96px; }
.letter-hero-word { grid-column: 1; font-size: var(--text-lg); font-weight: var(--weight-heavy); line-height: 1.2; }
.letter-hero.playing img, .syllable.playing { animation: pop .35s ease-out; }
.letter-hero.playing { box-shadow: inset 0 0 0 3px var(--tone); }
.letter-panel-top { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.letter-panel-title { flex: 1; min-width: 0; margin: 0; font-size: var(--text-lg); font-weight: var(--weight-heavy); }
.letter-kind { display: inline-block; margin-right: 4px; padding: 2px 10px; border-radius: 999px; color: #fff; background: var(--tone); font-size: var(--text-xs); vertical-align: 2px; }
.letter-play-all { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 var(--space-3); border: 0; border-radius: 999px; color: #fff; background: var(--tone); font: inherit; font-weight: var(--weight-heavy); white-space: nowrap; cursor: pointer; }
.letter-play-all svg { width: 18px; height: 18px; }
.letter-play-all[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--soft), 0 0 0 5px var(--tone); }
.letter-close { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; color: var(--muted); background: var(--page); cursor: pointer; }
.letter-close svg { width: 20px; height: 20px; }
.syllable-list { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.syllable { width: 100%; min-height: 56px; padding: 0 var(--space-2); border: 2px solid var(--line); border-radius: 16px; color: var(--ink); background: #fff; box-shadow: 0 3px 0 var(--line); font: inherit; font-size: 1.5rem; font-weight: var(--weight-heavy); line-height: 1; cursor: pointer; }
.syllable-list.wide { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.syllable:hover { border-color: var(--tone); }
.syllable.playing { border-color: var(--tone); background: var(--soft); box-shadow: 0 3px 0 var(--tone); }
.letter-steps { display: flex; justify-content: space-between; margin-top: var(--space-2); }
.letter-steps .text-button { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-lg); }
.letter-steps svg { width: 18px; height: 18px; }

.alphabet-banner { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); border: 2px solid var(--line); border-radius: 24px; color: var(--ink); background: linear-gradient(100deg, #fff 40%, #fff4dc); box-shadow: 0 4px 0 var(--line); }
.alphabet-banner:hover { border-color: var(--blue); }
.alphabet-banner-letters { display: flex; flex: none; }
.alphabet-banner-letters img { width: 56px; height: 56px; margin-right: -14px; padding: 4px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px var(--line); }
.alphabet-banner-copy { display: grid; flex: 1; min-width: 0; margin-left: var(--space-4); }
.alphabet-banner-copy strong { font-size: var(--text-xl); font-weight: var(--weight-heavy); }
.alphabet-banner-copy small { color: var(--muted); font-size: var(--text-sm); font-weight: var(--weight-bold); }
.alphabet-banner > svg { flex: none; width: 28px; height: 28px; color: var(--blue); }

@media (min-width: 600px) { .alphabet-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 960px) { .alphabet-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-4); } }
@media (max-width: 700px) {
  .alphabet-page { padding-top: var(--space-5); }
  body.letter-open .alphabet-page { padding-bottom: 300px; }
  .letter-panel { padding-top: var(--space-2); }
  .letter-panel-inner { grid-template-columns: 1fr; gap: var(--space-2); width: calc(100% - 2 * var(--space-4)); }
  .letter-hero { grid-template-columns: auto auto 1fr; grid-template-rows: auto; padding: var(--space-1) var(--space-3); }
  .letter-hero > * { grid-row: 1; }
  .letter-hero img { grid-column: 1; width: 52px; height: 52px; }
  .letter-hero-glyph { grid-column: 2; font-size: 2.25rem; }
  .letter-hero-word { grid-column: 3; }
  .letter-panel-top { margin-bottom: var(--space-2); }
  .letter-panel-title { font-size: var(--text-base); }
  .letter-kind { display: none; }
  .letter-hero-word { padding-left: var(--space-2); }
  .syllable-list { gap: 6px; }
  .syllable { min-height: 48px; padding: 0; border-radius: 12px; font-size: 1.25rem; }
  .letter-steps { margin-top: var(--space-1); }
  .letter-steps .text-button { min-height: 36px; font-size: var(--text-base); }
  .letter-play-all { min-height: 36px; padding: 0 var(--space-3); }
  .letter-close { width: 36px; height: 36px; }
}
@media (max-width: 545px) {
  .letter-glyph { font-size: 1.625rem; }
  .letter-word { font-size: var(--text-sm); }
  .alphabet-banner { gap: var(--space-2); padding: var(--space-3) var(--space-4); }
  .alphabet-banner-letters img { width: 44px; height: 44px; margin-right: -16px; }
  .alphabet-banner-letters img:nth-child(n+4) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .letter-panel, .letter-hero.playing img, .syllable.playing { animation: none; }
}
