/* Layout: phone-first single column (max 640px) with a floating pill tab bar. Visual identity: "highlighter on a study desk" —
   cobalt ink for actions, a yellow marker for words you learn, and one colour per activity (lesson cobalt, review coral, reading mint, voice violet).
   Players (lesson, review, copy, shadow) are full-screen with a fixed action bar; the reader uses a serif text face and a bottom sheet. */
:root {
  --bg: #F2F4F9;
  --bg-glow: #E3E9FF;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --ink: #0E1530;
  --muted: #5A6382;
  --line: #DCE1EE;
  --soft: #ECEFF7;
  --accent: #2F55E4;
  --accent-2: #1A36B0;
  --accent-ink: #FFFFFF;
  --accent-soft: #E4EAFF;
  --hero-1: #3358F0;
  --hero-2: #1B2F9E;
  --mark: #FFD84D;
  --coral: #F2603F;
  --coral-soft: #FFE7E0;
  --mint: #0F9C70;
  --mint-soft: #DCF4EB;
  --violet: #6E4CF5;
  --violet-soft: #ECE6FF;
  --good: #0F9C70;
  --good-soft: #DCF4EB;
  --bad: #DC3B42;
  --bad-soft: #FDE3E3;
  --shadow: 0 1px 2px rgba(14, 21, 48, .05), 0 6px 22px rgba(14, 21, 48, .06);
  --shadow-lg: 0 10px 34px rgba(27, 47, 158, .28);
  --font-display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --font-body: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Literata", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090D19; --bg-glow: #141C3A; --surface: #121931; --surface-2: #161E39; --ink: #E9EDF8; --muted: #96A1BF; --line: #232C4A; --soft: #1A2242;
    --accent: #7D98FF; --accent-2: #5674FF; --accent-ink: #0A0F22; --accent-soft: #1D2754; --hero-1: #3554E8; --hero-2: #1A2A86;
    --mark: rgba(255, 216, 77, .34); --coral: #FF8A6C; --coral-soft: #3A221F; --mint: #3DD6A3; --mint-soft: #11302A; --violet: #A68FFF; --violet-soft: #251F48;
    --good: #3DD6A3; --good-soft: #11302A; --bad: #FF6D70; --bad-soft: #3B1D25;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22); --shadow-lg: 0 12px 34px rgba(10, 20, 80, .55); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #090D19; --bg-glow: #141C3A; --surface: #121931; --surface-2: #161E39; --ink: #E9EDF8; --muted: #96A1BF; --line: #232C4A; --soft: #1A2242;
  --accent: #7D98FF; --accent-2: #5674FF; --accent-ink: #0A0F22; --accent-soft: #1D2754; --hero-1: #3554E8; --hero-2: #1A2A86;
  --mark: rgba(255, 216, 77, .34); --coral: #FF8A6C; --coral-soft: #3A221F; --mint: #3DD6A3; --mint-soft: #11302A; --violet: #A68FFF; --violet-soft: #251F48;
  --good: #3DD6A3; --good-soft: #11302A; --bad: #FF6D70; --bad-soft: #3B1D25;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22); --shadow-lg: 0 12px 34px rgba(10, 20, 80, .55); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 520px at 50% -180px, var(--bg-glow), transparent 70%) no-repeat, var(--bg);
  background-color: var(--bg);
  color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; min-height: 100vh;
}
.app {
  max-width: 640px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1, h2 { text-wrap: balance; }
em { font-style: italic; color: var(--muted); }
[hidden] { display: none !important; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.logo { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(140deg, var(--hero-1), var(--hero-2)); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 17px; box-shadow: var(--shadow-lg); flex: none; }
.hello { display: grid; line-height: 1.2; min-width: 0; }
.hello b { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.hello span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.streak { display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; text-decoration: none; box-shadow: var(--shadow); }
.streak svg { width: 18px; height: 18px; color: var(--muted); }
.streak.on svg { color: var(--coral); }
.theme-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink); box-shadow: var(--shadow); }
.theme-btn svg { width: 18px; height: 18px; }

/* building blocks */
.stack { display: grid; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 12px; min-width: 0; box-shadow: var(--shadow); }
.panel.link { text-decoration: none; color: inherit; transition: transform .15s ease; }
.panel.link:active { transform: scale(.985); }
.label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lead { color: var(--muted); }
.small { font-size: 14px; }
.h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(25px, 7vw, 32px); line-height: 1.15; letter-spacing: -.015em; }
.h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.h3 { font-weight: 600; font-size: 18px; }
.page-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 2px 2px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .btn { flex: 1 1 auto; }
.between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 18px; border-radius: 15px; border: 1px solid transparent; background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent)); color: var(--accent-ink); font-weight: 600; text-decoration: none; text-align: center; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 28%, transparent); transition: transform .12s ease, filter .12s ease; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: none; }
.btn.soft { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn.big { min-height: 58px; font-size: 18px; width: 100%; }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: 14px; border-radius: 11px; }
.btn.white { background: #fff; color: #1A2A86; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; box-shadow: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); flex: none; text-decoration: none; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.meter { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), color-mix(in srgb, var(--mint) 70%, var(--accent))); border-radius: 4px; transition: width .4s ease; }
.meter.thin { height: 6px; }
.meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.points { display: flex; flex-wrap: wrap; gap: 6px; }
.points span { font-size: 14px; padding: 5px 11px; border-radius: 999px; background: var(--soft); }
.pill { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.accent { background: var(--accent); color: var(--accent-ink); }
.pill.coral { background: var(--coral-soft); color: var(--coral); }
details > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; color: var(--muted); font-family: var(--font-mono); }
details[open] > summary::after { content: "−"; }
.how { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; color: var(--muted); }
.how b { color: var(--ink); font-weight: 600; }
mark, .hl strong { background: linear-gradient(transparent 55%, var(--mark) 55%); color: inherit; font-weight: inherit; padding: 0 1px; border-radius: 2px; }

/* home hero */
.hero { position: relative; overflow: hidden; border-radius: 26px; padding: 22px; color: #fff; background: linear-gradient(150deg, var(--hero-1), var(--hero-2)); box-shadow: var(--shadow-lg); display: grid; gap: 16px; }
.hero::before { content: ""; position: absolute; right: -60px; top: -70px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 70%); }
.hero > * { position: relative; z-index: 1; }
.hero .label { color: rgba(255, 255, 255, .78); }
.hero .h1 { color: #fff; }
.hero .sub { color: rgba(255, 255, 255, .82); font-size: 15px; }
.hero-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.ring { width: 76px; height: 76px; flex: none; position: relative; }
.ring svg { width: 76px; height: 76px; transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 17px; }
.ring small { position: absolute; left: 0; right: 0; bottom: -18px; text-align: center; font-size: 11px; color: rgba(255, 255, 255, .75); }

/* activity tiles (one colour per activity) */
.ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.ic svg { width: 22px; height: 22px; }
.ic.c-lesson { background: var(--accent-soft); color: var(--accent); }
.ic.c-review { background: var(--coral-soft); color: var(--coral); }
.ic.c-read { background: var(--mint-soft); color: var(--mint); }
.ic.c-voice { background: var(--violet-soft); color: var(--violet); }
.tasks { display: grid; gap: 10px; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s ease; }
.task:active { transform: scale(.985); }
.task .t { min-width: 0; }
.task .t b { display: block; font-weight: 600; }
.task .t span { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.done { background: var(--surface-2); }
.task.done .t b { color: var(--muted); }
.tick { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; }
.tick svg { width: 15px; height: 15px; }
.task.done .tick { background: var(--good); border-color: var(--good); color: #fff; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats.four, .stats.two { grid-template-columns: repeat(2, 1fr); }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: grid; gap: 3px; min-width: 0; }
.stat b { font-family: var(--font-display); font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat b small { font-size: 13px; color: var(--muted); font-family: var(--font-body); font-weight: 500; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.c-lesson b { color: var(--accent); } .stat.c-review b { color: var(--coral); } .stat.c-read b { color: var(--mint); } .stat.c-voice b { color: var(--violet); }
.list { display: grid; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; width: 100%; color: inherit; text-decoration: none; }
.item:first-child { border-top: 0; }
.item .num { font-family: var(--font-mono); font-size: 13px; color: var(--muted); min-width: 3ch; }
.item .t { min-width: 0; }
.item .t div:last-child:not(:first-child) { font-size: 13px; color: var(--muted); }
.item.dim { opacity: .6; }
.check { width: 30px; height: 30px; border-radius: 10px; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 600; color: var(--muted); }
.check.on { background: var(--good); border-color: var(--good); color: #fff; }
.check svg { width: 15px; height: 15px; }
.pitfall { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: 15px; display: grid; gap: 2px; }
.pitfall s { color: var(--bad); }
.pitfall b { color: var(--good); font-weight: 600; }
.pitfall small { color: var(--muted); font-size: 13px; }
.feedback { border-radius: 18px; padding: 16px; background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 6px; font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.feedback.teacher { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, var(--line)); }
.empty { text-align: center; padding: 32px 12px; display: grid; gap: 10px; justify-items: center; }
.skeleton { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, var(--soft), var(--surface-2), var(--soft)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 11px; font-size: 14px; color: var(--muted); border-radius: 9px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
input[type="text"], input[type="password"], input[type="search"], textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); padding: 13px 15px; font-size: 17px; line-height: 1.5; resize: vertical; transition: border-color .15s ease, box-shadow .15s ease; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
textarea { min-height: 84px; }

/* player */
.player { display: grid; gap: 18px; }
.ptop { display: flex; align-items: center; gap: 12px; }
.ptop .meter { flex: 1; height: 10px; border-radius: 5px; }
.ptop .meter i { background: linear-gradient(90deg, var(--accent), var(--violet)); }
.pcount { font-family: var(--font-mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pbody { display: grid; gap: 16px; min-width: 0; }
.pbody > .label:first-child { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); }
.pbody > .label:first-child::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pbody[data-kind="drill"] > .label:first-child, .pbody[data-kind="type"] > .label:first-child, .pbody[data-kind="create"] > .label:first-child { color: var(--violet); }
.pbody[data-kind="dictation"] > .label:first-child, .pbody[data-kind="listen"] > .label:first-child { color: var(--mint); }
.pbody[data-kind="shadow"] > .label:first-child, .pbody[data-kind="answer"] > .label:first-child, .pbody[data-kind="speak"] > .label:first-child { color: var(--coral); }
.pfoot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-top: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.pfoot-in { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; }
.pfoot-in .btn { flex: 1; min-height: 56px; font-size: 17px; }
.pfoot-in .icon-btn { height: 56px; width: 56px; }
.btn.no { background: var(--bad); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--bad) 30%, transparent); }
.btn.ok { background: var(--good); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--good) 30%, transparent); }
.phrase-big { font-size: clamp(23px, 6.4vw, 29px); font-weight: 600; line-height: 1.3; letter-spacing: -.005em; }
.ru-big { font-size: 20px; font-weight: 500; }
.ru { color: var(--muted); font-size: 16px; }
.tip { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--mark); border-radius: 16px; padding: 14px 16px; font-size: 16px; display: block; box-shadow: var(--shadow); }
.tip > * + * { margin-top: 8px; }
.tip > .between, .tip > .audio-row { display: flex; }
.tip > textarea { display: block; }
.tip > .verdict { display: grid; }
.tip strong { font-weight: 600; }
.audio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.audio-row .btn { flex: 0 1 auto; min-height: 42px; padding: 8px 14px; }
.lines { display: grid; gap: 8px; }
.line { display: grid; gap: 2px; text-align: left; padding: 11px 15px; border-radius: 18px 18px 18px 6px; border: 1px solid var(--line); background: var(--surface); width: 88%; justify-self: start; box-shadow: var(--shadow); }
.line .who { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.line.me { justify-self: end; border-radius: 18px 18px 6px 18px; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.line.playing { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.line .en.blur { filter: blur(6px); user-select: none; }
.line .ru { font-size: 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; padding: 15px 16px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); font-size: 17px; box-shadow: var(--shadow); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.verdict { border-radius: 18px; padding: 14px 16px; display: grid; gap: 8px; border: 1px solid transparent; animation: pop .22s ease-out; }
.verdict.ok { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.verdict.no { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.verdict.info { background: var(--surface-2); border-color: var(--line); }
.verdict .v { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.verdict.ok .v { color: var(--good); }
.verdict.no .v { color: var(--bad); }
.verdict.ok .v::before { content: "✓"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--good); color: #fff; font-size: 13px; }
.verdict.no .v::before { content: "!"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--bad); color: #fff; font-size: 13px; }
@keyframes pop { from { transform: scale(.97); opacity: .4; } to { transform: none; opacity: 1; } }
.diff { font-size: 18px; line-height: 1.9; }
.diff .miss { background: var(--mark); border-radius: 4px; padding: 1px 4px; }
.diff .extra { color: var(--bad); text-decoration: line-through; padding: 0 2px; }
.diff .bad { color: var(--bad); text-decoration: underline wavy; }
.diff .good { color: var(--good); }
.dots { display: flex; gap: 8px; flex-wrap: wrap; }
.dots i { width: 26px; height: 8px; border-radius: 4px; background: var(--line); }
.dots i.on { background: var(--good); }
.dots i.off { background: var(--bad); }
.dots i.re { width: 14px; }
.hidden-text { letter-spacing: .2em; color: var(--muted); }
.big-score { font-family: var(--font-display); font-weight: 700; font-size: 56px; line-height: 1; font-variant-numeric: tabular-nums; background: linear-gradient(135deg, var(--accent), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rec { width: 92px; height: 92px; border-radius: 50%; border: 0; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--coral) 75%, #fff), var(--coral)); color: #fff; display: grid; place-items: center; justify-self: center; box-shadow: 0 10px 28px color-mix(in srgb, var(--coral) 40%, transparent); }
.rec svg { width: 36px; height: 36px; }
.rec.on { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); box-shadow: 0 0 0 14px color-mix(in srgb, var(--coral) 18%, transparent); } }
.celebrate { position: relative; display: grid; place-items: center; height: 120px; }
.celebrate .medal { width: 96px; height: 96px; border-radius: 30px; display: grid; place-items: center; background: linear-gradient(140deg, var(--hero-1), var(--violet)); color: #fff; box-shadow: var(--shadow-lg); transform: rotate(-6deg); }
.celebrate .medal svg { width: 48px; height: 48px; }
.celebrate.still i { display: none; }
.celebrate.still .medal { animation: none; }
.celebrate i { position: absolute; width: 10px; height: 10px; border-radius: 3px; animation: burst 1s ease-out forwards; opacity: 0; }
@keyframes burst { 0% { transform: translate(0, 0) scale(.6); opacity: 1; } 100% { transform: translate(var(--x), var(--y)) rotate(200deg); opacity: 0; } }

/* course */
.units { display: grid; gap: 14px; position: relative; }
.unit { display: grid; gap: 12px; }
.unit-head { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.unit-n { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 18px; background: var(--soft); color: var(--muted); }
.unit.done .unit-n { background: var(--good); color: #fff; }
.unit.current { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent), var(--shadow); }
.unit.current .unit-n { background: linear-gradient(140deg, var(--hero-1), var(--hero-2)); color: #fff; }
.unit.later { opacity: .75; }

/* library */
.shelf { display: grid; gap: 12px; }
.shelf.row-scroll { grid-auto-flow: column; grid-auto-columns: 140px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.book { display: grid; grid-template-columns: 76px 1fr; gap: 14px; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow); transition: transform .15s ease; }
.book:active { transform: scale(.985); }
.cover { position: relative; width: 76px; height: 104px; border-radius: 10px 14px 14px 10px; overflow: hidden; display: flex; align-items: flex-end; padding: 8px; font-family: var(--font-display); font-weight: 700; font-size: 11px; line-height: 1.12; color: #fff; box-shadow: inset 4px 0 0 rgba(0, 0, 0, .18), 0 6px 14px rgba(0, 0, 0, .18); }
.cover::before { content: ""; position: absolute; inset: 0; background: var(--pattern); opacity: .9; }
.cover span { position: relative; text-shadow: 0 1px 6px rgba(0, 0, 0, .35); }
.cover.big { width: 104px; height: 144px; font-size: 14px; padding: 12px; }
.book .t { display: grid; gap: 4px; min-width: 0; align-content: start; }
.book-head { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: end; }

/* reader */
.reader { font-family: var(--font-read); font-size: var(--read-size, 20px); line-height: 1.75; display: grid; gap: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 20px; box-shadow: var(--shadow); }
.reader h2 { font-family: var(--font-display); font-size: 22px; line-height: 1.25; }
.para { position: relative; display: grid; gap: 6px; scroll-margin-top: 20px; }
.para .tr { font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--muted); border-left: 3px solid var(--mark); padding-left: 10px; }
.para-tools { display: flex; gap: 6px; opacity: .8; }
.para-tools button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 3px 10px; font-family: var(--font-body); font-size: 13px; color: var(--muted); }
.w { cursor: pointer; border-radius: 4px; transition: background .15s ease; }
.w.saved { background: linear-gradient(transparent 62%, color-mix(in srgb, var(--mark) 70%, transparent) 62%); }
.w.sel { background: var(--mark); }
.s.reading { background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 4px; }
.reader-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.reader-bar-in { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.reader-bar .meter { flex: 1; }

/* bottom sheet */
.sheet-back { position: fixed; inset: 0; background: rgba(5, 8, 20, .42); z-index: 40; backdrop-filter: blur(2px); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 26px 26px 0 0; border-top: 1px solid var(--line); padding: 10px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); max-height: 78vh; overflow: auto; box-shadow: 0 -16px 40px rgba(0, 0, 0, .2); }
.sheet::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-in { max-width: 640px; margin: 0 auto; display: grid; gap: 12px; }
.sheet .word { font-family: var(--font-display); font-size: 26px; font-weight: 700; }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font-mono); }

/* floating tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 0 max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.tabs-in { pointer-events: auto; max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 6px; border-radius: 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .14); }
.tab { border: 0; padding: 7px 2px 8px; display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); position: relative; text-decoration: none; border-radius: 18px; transition: background .2s ease, color .2s ease; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.tab .badge { position: absolute; top: 2px; left: calc(50% + 7px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--coral); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom, 0px)); z-index: 50; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 500; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }

/* login */
.login { min-height: 72vh; display: grid; align-content: center; gap: 18px; }
.login .logo { width: 64px; height: 64px; border-radius: 20px; font-size: 28px; }

@media (prefers-reduced-motion: no-preference) {
  .pbody, .sheet { animation: rise .22s ease-out; }
  @keyframes rise { from { transform: translateY(10px); opacity: .4; } to { transform: none; opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* podcast transcript inside the reader */
.para.pod { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px 18px 18px 6px; padding: 10px 14px; width: 92%; justify-self: start; }
.para.pod.me { justify-self: end; border-radius: 18px 18px 6px 18px; background: var(--accent-soft); }
.para .who { font-family: var(--font-body); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.reader.blind .en-text { filter: blur(7px); user-select: none; transition: filter .2s ease; }
.reader.blind .para:active .en-text, .reader.blind .para:hover .en-text { filter: none; }

/* Colour theme "green" (default): forest/emerald accents; reading switches to teal so it stays distinct from the accent. */
:root[data-accent="green"] {
  --bg: #F1F6F3; --bg-glow: #DCF1E5; --surface: #FFFFFF; --surface-2: #F6FAF8; --ink: #0C1F17; --muted: #557064; --line: #D5E4DB; --soft: #E7F0EB;
  --accent: #128A5E; --accent-2: #0B6446; --accent-ink: #FFFFFF; --accent-soft: #DCF3E8; --hero-1: #16A06C; --hero-2: #0A5A40;
  --mint: #0E86A8; --mint-soft: #DDF1F7; --shadow-lg: 0 10px 34px rgba(10, 90, 64, .28);
}
@media (prefers-color-scheme: dark) {
  :root[data-accent="green"]:not([data-theme="light"]) {
    --bg: #07110D; --bg-glow: #0F2A1F; --surface: #0E1B16; --surface-2: #12221C; --ink: #E6F2EC; --muted: #8FAA9D; --line: #1E3229; --soft: #15261F;
    --accent: #4FD69C; --accent-2: #2FB57D; --accent-ink: #052016; --accent-soft: #143628; --hero-1: #169466; --hero-2: #0A4733;
    --mint: #4CC3E6; --mint-soft: #0F2B33; --shadow-lg: 0 12px 34px rgba(0, 40, 25, .6);
  }
}
:root[data-accent="green"][data-theme="dark"] {
  --bg: #07110D; --bg-glow: #0F2A1F; --surface: #0E1B16; --surface-2: #12221C; --ink: #E6F2EC; --muted: #8FAA9D; --line: #1E3229; --soft: #15261F;
  --accent: #4FD69C; --accent-2: #2FB57D; --accent-ink: #052016; --accent-soft: #143628; --hero-1: #169466; --hero-2: #0A4733;
  --mint: #4CC3E6; --mint-soft: #0F2B33; --shadow-lg: 0 12px 34px rgba(0, 40, 25, .6);
}
:root[data-accent="green"] .btn.white { color: #0A5A40; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; }
.swatch i { width: 28px; height: 28px; border-radius: 9px; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

/* learning-flow notices: comeback after a break, low accuracy, resume */
.notice { background: var(--coral-soft); color: var(--ink); border-radius: 16px; padding: 14px 16px; font-size: 15px; line-height: 1.45; }
.notice b { color: var(--coral); }
.resume-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: var(--accent-soft); border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.resume-bar .btn { flex: none; }
