/* Lingo Lizard: mobile-first, light/dark from the system. No amber or yellow anywhere. */

:root {
  --bg: #f3f7f4;
  --surface: #ffffff;
  --surface-2: #e7f0eb;
  --text: #13221b;
  --muted: #5a6c63;
  --border: #d3e1d9;
  --primary: #1f8a5b;
  --primary-press: #17704a;
  --primary-ink: #ffffff;
  --accent: #7a4fb5;
  --good: #1b7d52;
  --good-bg: #dcf3e6;
  --bad: #c3324a;
  --bad-bg: #fbe3e7;
  --almost: #2f63c4;
  --almost-bg: #e1e9fb;
  --shadow: 0 1px 2px rgb(16 40 28 / 6%), 0 4px 14px rgb(16 40 28 / 6%);
  --radius: 16px;
  --tap: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1613;
    --surface: #16211c;
    --surface-2: #1e2c25;
    --text: #e5efe9;
    --muted: #9cb0a5;
    --border: #2a3b33;
    --primary: #3cc283;
    --primary-press: #31a36e;
    --primary-ink: #04120b;
    --accent: #b48ce8;
    --good: #4fd394;
    --good-bg: #12301f;
    --bad: #ff7186;
    --bad-bg: #3a1820;
    --almost: #86a9ff;
    --almost-bg: #1a2442;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.in-lesson { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
[hidden] { display: none !important; }
mark { background: var(--almost-bg); color: var(--almost); border-radius: 3px; padding: 0 1px; font-weight: 700; }

#app { max-width: 640px; margin: 0 auto; }

.screen {
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.center-screen { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin: 0 0 14px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 10px 18px;
  border-radius: 14px; border: 2px solid transparent;
  font-weight: 700; text-decoration: none; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: transform .06s ease, background .15s ease;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:active { background: var(--primary-press); }
.btn.secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn.big { width: 100%; min-height: 60px; font-size: 1.1rem; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .95rem; }
.btn small { font-weight: 500; font-size: .85rem; opacity: .85; }
.btn[aria-disabled="true"] { opacity: .55; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row .btn { flex: 1 1 140px; }
.link-btn { background: none; border: 0; color: var(--primary); padding: 8px 0; cursor: pointer; text-decoration: underline; min-height: 40px; }
.danger-text { color: var(--bad); }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border-radius: 12px; border: 0; background: transparent; color: var(--muted);
  font-size: 1.4rem; text-decoration: none; cursor: pointer;
}
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn:active { background: var(--surface-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: .9rem; }

/* ---------- forms ---------- */
.form h2 { margin-bottom: 10px; }
.field { display: block; margin: 0 0 14px; border: 0; padding: 0; }
.field > span, .field > legend { display: block; font-weight: 600; margin-bottom: 6px; padding: 0; }
.field input, .field select {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--bg);
}
.field-help { display: block; margin-top: 6px; font-size: 0.85rem; line-height: 1.35; }
.field input:focus, .field select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--primary); }

/* ---------- mascot ---------- */
.mascot { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; transform-origin: 50% 100%; }
.mascot.hop { animation: liz-hop .5s ease-out; }
.mascot.droop { animation: liz-droop .5s ease-in-out; }
@keyframes liz-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10%) scaleY(1.03); } 70% { transform: translateY(0) scaleY(.97); } }
@keyframes liz-droop { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 50% { transform: rotate(4deg); } 75% { transform: rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { .mascot.hop, .mascot.droop { animation: none; } }

/* ---------- setup & profiles ---------- */
.setup-liz { width: 150px; height: 160px; margin: 12px auto 4px; }
.swatch span { height: 96px; }
.profile-btn .mascot { width: 100px; height: 110px; }
.setup h1 { text-align: center; }
.color-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 2px solid var(--border); border-radius: 14px; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { width: 100%; }
.swatch b { font-size: .95rem; }
.swatch small { color: var(--muted); font-size: .72rem; text-align: center; line-height: 1.2; }
.mascot-says { margin: 0 0 4px; color: var(--muted); }
.mascot-says b { color: var(--text); }
.notes summary { display: flex; align-items: center; gap: 10px; }
.notes-liz { width: 40px; height: 44px; flex: none; }
.swatch:has(input:checked) { border-color: var(--primary); background: var(--good-bg); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--primary); }
.profile-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 20px 0; }
.profile-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 10px; border-radius: var(--radius); border: 1.5px solid var(--border); background: var(--surface); font-weight: 700; font-size: 1.1rem; cursor: pointer; }
.start-choice { display: grid; gap: 10px; }
.tip { border-color: var(--almost); background: var(--almost-bg); }
.tip p { margin: 0 0 4px; }

/* ---------- home ---------- */
.home-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.home-liz { width: 72px; height: 84px; flex: none; }
.home-hello { flex: 1; min-width: 0; }
.home-hello h1 { font-size: 1.45rem; margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; }
.meter { display: inline-block; flex: 1; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 50px; }
.meter i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.meter.wide { display: block; width: 100%; margin: 8px 0 10px; }
.week-head { display: flex; justify-content: space-between; font-weight: 600; }
.week-days { display: flex; justify-content: space-between; gap: 4px; }
.day { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 700; }
.day.on { background: var(--primary); color: var(--primary-ink); }
.day.today { box-shadow: 0 0 0 2px var(--accent); }
.week p { margin: 8px 0 0; }
.actions { display: grid; gap: 10px; margin-bottom: 18px; }
.units-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 8px; }
.units-head h2 { margin: 0; }
.units { display: grid; gap: 10px; }
.unit-row {
  display: grid; grid-template-columns: 44px 1fr auto; grid-template-rows: auto 6px; column-gap: 12px; row-gap: 8px; align-items: center;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.unit-row:active { background: var(--surface-2); }
.unit-num { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; grid-row: span 2; }
.unit-row.done .unit-num { background: var(--primary); color: var(--primary-ink); }
.unit-text { display: flex; flex-direction: column; min-width: 0; }
.unit-text small { color: var(--muted); }
.unit-count { font-size: .85rem; color: var(--muted); font-weight: 600; }
.unit-badge svg, .unit-lock svg { width: 22px; height: 22px; }
.unit-badge { color: var(--primary); }
.unit-lock { color: var(--muted); }
.unit-bar { grid-column: 2 / 4; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.unit-bar i { display: block; height: 100%; background: var(--primary); }
.unit-row.locked { opacity: .6; box-shadow: none; }
.level-head { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 2px 0; font-size: 1rem; color: var(--accent); }
.level-head:first-child { margin-top: 0; }
.level-head small { color: var(--muted); font-weight: 500; font-size: .85rem; }

/* ---------- unit page ---------- */
.sub-top { display: flex; align-items: center; gap: 8px; margin: 0 0 8px -8px; }
.sub-top h1 { margin: 0; }
.notes summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.notes ul { margin: 10px 0 0; padding-left: 20px; }
.notes li { margin-bottom: 6px; }
.lessons { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.lesson-row {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.lesson-row.next { border: 2px solid var(--primary); }
.lesson-row.disabled { opacity: .55; }
.lesson-num { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; flex: none; }
.lesson-row.done .lesson-num { background: var(--primary); color: var(--primary-ink); }
.lesson-text { display: flex; flex-direction: column; }
.lesson-text small { color: var(--muted); }
.locked-card p { margin-top: 0; }
.section-head { margin: 20px 0 10px; }
.pron-link { margin-top: 16px; }
.practice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: -6px 0 18px; }
.practice-row .btn { padding: 8px 10px; }
.practice-row .btn:only-child { grid-column: span 2; }

/* ---------- lesson ---------- */
.lesson {
  position: fixed; left: 0; right: 0; top: var(--vvtop, 0px);
  height: var(--vvh, 100dvh);
  display: flex; flex-direction: column;
  max-width: 640px; margin: 0 auto;
  background: var(--bg);
}
.lesson-top { display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 12px 6px; }
.progress { flex: 1; height: 14px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .3s ease; }
.liz-mini { width: 52px; height: 56px; flex: none; }
.lesson-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 16px; }
.lesson-foot { padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border); }
.foot-row { display: flex; gap: 10px; }
.foot-row .check { flex: 1; min-height: 56px; font-size: 1.1rem; }
.foot-row .skip { flex: 0 1 auto; font-size: .9rem; }

.accent-bar { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.accent-key { min-width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); font-size: 1.15rem; cursor: pointer; touch-action: manipulation; }
.accent-key:active { background: var(--surface-2); }

.feedback { border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; max-height: 40vh; overflow-y: auto; }
.feedback p { margin: 0 0 4px; }
.feedback.good { background: var(--good-bg); color: var(--good); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback.almost { background: var(--almost-bg); color: var(--almost); }
.feedback.neutral { background: var(--surface-2); color: var(--muted); }
.fb-title { font-weight: 800; font-size: 1.15rem; }
.fb-answer { color: var(--text); font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.fb-label { color: inherit; font-weight: 500; opacity: .85; }
.feedback .fb-answer .fb-label { color: var(--muted); }
.fb-meaning { color: var(--muted); }
.fb-note { color: var(--text); font-size: .92rem; opacity: .9; }
.fb-small { font-size: .85rem; opacity: .85; }
.feedback .speak-btn { width: 36px; height: 36px; }

.ex-label { font-weight: 700; font-size: 1.15rem; margin: 6px 0 14px; }
.tag-new { display: inline-block; background: var(--accent); color: #fff; font-size: .75rem; padding: 2px 8px; border-radius: 99px; vertical-align: 2px; margin-right: 4px; }
.prompt-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.prompt { font-size: 1.25rem; font-weight: 600; }
.prompt.big { font-size: 1.7rem; }
.hint { color: var(--muted); font-size: .95rem; }
.meaning { color: var(--muted); margin: -8px 0 16px; }

.speak-btn {
  width: 48px; height: 48px; flex: none; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  border: 0; background: var(--primary); color: var(--primary-ink);
}
.speak-btn svg { width: 26px; height: 26px; }
.speak-btn.slow { background: var(--surface-2); color: var(--text); }
.speak-btn.big { width: 96px; height: 96px; }
.speak-btn.big svg { width: 48px; height: 48px; }
.speak-btn.pulse { animation: pulse .35s ease; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.listen-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0 24px; }

.options { display: grid; gap: 10px; }
.opt {
  min-height: var(--tap); padding: 12px 14px; text-align: left;
  border-radius: 14px; border: 2px solid var(--border); background: var(--surface);
  font-size: 1.05rem; cursor: pointer; touch-action: manipulation;
}
.opt.selected { border-color: var(--primary); background: var(--good-bg); }
.opt.correct { border-color: var(--good); background: var(--good-bg); color: var(--good); font-weight: 700; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.locked .opt { cursor: default; }

/* word bank */
.wb-answer {
  min-height: 112px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px;
  padding: 10px 0; margin-bottom: 18px;
  background-image: linear-gradient(var(--border) 2px, transparent 2px);
  background-size: 100% 56px; background-position: 0 52px;
}
.wb-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.wb-slot { display: inline-block; border-radius: 12px; background: var(--surface-2); }
.tile {
  min-height: 46px; padding: 8px 14px; border-radius: 12px;
  border: 2px solid var(--border); border-bottom-width: 4px; background: var(--surface);
  font-size: 1.05rem; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.tile.used { visibility: hidden; }
.tile.dragging { opacity: .3; }
.tile.tile-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; box-shadow: 0 8px 24px rgb(0 0 0 / 20%); cursor: grabbing; }
.locked .tile { cursor: default; }

/* typing */
.answer-input {
  width: 100%; min-height: 96px; padding: 12px 14px; resize: none;
  border: 2px solid var(--border); border-radius: 14px; background: var(--surface);
  font-size: 1.15rem;
}

/* speaking */
.speak-area { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 12px; }
.mic-btn {
  width: 132px; height: 132px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--primary); color: var(--primary-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-weight: 700; font-size: .9rem;
}
.mic-btn svg { width: 46px; height: 46px; }
.mic-btn.listening { background: var(--bad); color: #fff; animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); } }
.speak-status { text-align: center; color: var(--muted); margin: 4px 0; min-height: 1.4em; }
.speak-note { text-align: center; color: var(--muted); font-size: .92rem; margin: 0 0 6px; }
.heard { font-size: 1.15rem; text-align: center; }
.heard .ok { color: var(--good); font-weight: 700; }
.heard .miss { color: var(--bad); text-decoration: underline wavy; }
.rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.rate-row .btn { padding: 8px 6px; }
.compare-row { display: flex; align-items: center; gap: 12px; }
.compare-row .btn { flex-direction: row; gap: 6px; }
.compare-row .btn svg { width: 20px; height: 20px; }

/* matching */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: grid; gap: 10px; align-content: start; }
.match-col .opt { text-align: center; padding: 10px 8px; }
.opt.matched { opacity: .35; border-color: var(--good); background: var(--good-bg); }
.opt.shake { animation: shake .35s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* reading */
.passage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 6px; }
.passage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.passage-head h3 { margin: 0; }
.passage p { margin: 0 0 4px; }
.sent { background: none; border: 0; padding: 6px 0; text-align: left; font-size: 1.08rem; cursor: pointer; line-height: 1.4; }
.sent:active { color: var(--primary); }
.gloss { margin: 10px 0 0; padding-top: 8px; border-top: 1px dashed var(--border); font-size: .9rem; }
.gloss div { display: flex; gap: 8px; }
.gloss dt { font-weight: 700; }
.gloss dd { margin: 0; color: var(--muted); }
.tap-hint { font-size: .85rem; color: var(--muted); margin: 0 0 14px; }
.question { border: 0; padding: 0; margin: 0 0 18px; }
.question legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.q-en { display: block; font-weight: 400; color: var(--muted); font-size: .92rem; }

/* ---------- stories ---------- */
.story-title { margin: 4px 0 12px; }
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.bubble { max-width: 86%; display: flex; flex-direction: column; gap: 2px; }
.bubble.left { align-self: flex-start; }
.bubble.right { align-self: flex-end; align-items: flex-end; }
.bubble.narration { align-self: stretch; max-width: 100%; }
.bubble .who { font-size: .78rem; font-weight: 700; color: var(--accent); padding: 0 8px; }
.bubble .line {
  text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 14px; border-radius: 16px; font-size: 1.05rem; line-height: 1.4; cursor: pointer;
}
.bubble.left .line { border-bottom-left-radius: 4px; }
.bubble.right .line { border-bottom-right-radius: 4px; background: var(--good-bg); }
.bubble.narration .line { background: transparent; border-style: dashed; font-style: italic; }
.hidden-line { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.hidden-line svg { width: 18px; height: 18px; }
.story-card { margin-top: 12px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.story-q.locked .opt { cursor: default; }
.listen-row.small { margin: 0 0 12px; justify-content: flex-start; gap: 10px; }

/* ---------- pronunciation drill ---------- */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; margin: 6px 0 2px; }
.gauge { width: 100%; max-width: 300px; height: auto; overflow: visible; }
.gauge .needle { transform-box: view-box; transform-origin: 110px 110px; transition: transform .9s cubic-bezier(.34, 1.56, .64, 1); }
.gauge-label { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.gauge-score { font-weight: 800; font-size: 1.1rem; margin: 4px 0 0; min-height: 1.4em; }
.gauge-score.good { color: var(--good); }
.gauge-score.almost { color: var(--almost); }
.gauge-score.bad { color: var(--bad); }
.ex-pron .heard { text-align: center; min-height: 1.4em; }
.pron-actions { display: flex; justify-content: center; margin-top: 6px; }
.mic-btn.small-mic { width: 112px; height: 112px; }
@media (prefers-reduced-motion: reduce) { .gauge .needle { transition: none; } }

/* ---------- summary ---------- */
.summary { display: flex; flex-direction: column; min-height: 100dvh; }
.summary-liz { width: 170px; height: 190px; margin: 16px auto 4px; }
.summary h1 { text-align: center; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.badge-line { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; margin: 0 0 14px; }
.badge-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; }
.review-list ul { list-style: none; margin: 0; padding: 0; }
.review-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.review-list li:last-child { border-bottom: 0; }
.summary-foot { margin-top: auto; padding-top: 16px; }

/* ---------- update banner ---------- */
.update-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: 616px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px 10px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 24px rgb(0 0 0 / 18%);
}
body.in-lesson .update-banner { display: none; }

/* =====================================================================
   Learning path, accounts, tips and fluency (v0.6)
   ===================================================================== */
:root {
  --lock-bg: #e3e9e5; --lock-ink: #a7b3ac; --lock-shadow: #c6d0ca;
  --tip-bg: #e9f2fd; --tip-ink: #2f63c4; --ring-bg: #e3e9e5;
}
@media (prefers-color-scheme: dark) {
  :root { --lock-bg: #26332d; --lock-ink: #5f7068; --lock-shadow: #1a2420; --tip-bg: #172238; --tip-ink: #86a9ff; --ring-bg: #26332d; }
}
.s1 { --sec: #1f9d63; --sec-dark: #157148; }
.s2 { --sec: #2f7fd8; --sec-dark: #1f5ca3; }
.s3 { --sec: #8a5bd0; --sec-dark: #6741a3; }
.s4 { --sec: #cf4677; --sec-dark: #9e3058; }

#app.wide { max-width: 1240px; }
.tw { font-weight: 700; text-decoration: underline dotted; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 4px; text-decoration-thickness: 2px; }
.tip-tag { display: inline-block; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--tip-ink); }

/* ---- home layout ---- */
.path-home { padding: max(16px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom)); }
.rail { display: none; }
@media (min-width: 1000px) {
  .path-home { display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
  .rail { display: block; position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; scrollbar-width: thin; padding-bottom: 8px; }
  .path-home .home-top .icon-btn[href="#/players"] { display: none; }
  .friends-strip { display: none !important; }
}
.path-col { min-width: 0; }
.rail-head { font-size: .95rem; color: var(--muted); margin: 18px 4px 8px; }
.me-card { padding: 14px; }
.me-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.me-top b { display: block; }
.me-liz { width: 48px; height: 54px; flex: none; }

.section-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px; border-radius: var(--radius);
  background: var(--sec); color: #fff; text-decoration: none; box-shadow: 0 4px 0 var(--sec-dark); }
.section-card.locked { filter: grayscale(.85); opacity: .7; }
.sec-art { width: 62px; height: 70px; flex: none; }
.sec-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.sec-text small { opacity: .9; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.sec-text b { font-size: 1.1rem; }
.section-card .meter { height: 8px; background: rgb(255 255 255 / 30%); }
.me-card .meter { height: 8px; background: var(--surface-2); width: 100%; }
.section-card .meter i { background: #fff; }
.sec-count { text-transform: none !important; letter-spacing: 0 !important; }

.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip-stat { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--border); font-size: .9rem; }
.week-chip .meter, .cefr-chip .meter { width: 70px; flex: none; height: 8px; }
.days-chip { gap: 3px; padding: 4px 8px; }
.dd { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: .7rem; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.dd.on { background: var(--primary); color: var(--primary-ink); }
.dd.today { outline: 2px solid var(--primary); outline-offset: 1px; }
.path-home .practice-row { grid-template-columns: 1fr 1fr; margin: 0 0 16px; }
.path-home .practice-row .continue { grid-column: 1 / -1; }
.friends-strip a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text); text-decoration: none; font-size: .92rem; }
.friend-face { width: 32px; height: 34px; flex: none; display: inline-block; border-radius: 50%; background: var(--surface); border: 2px solid #fff; overflow: hidden; margin-left: -8px; }
.friend-face:first-child { margin-left: 0; }

/* ---- unit banner and trail ---- */
.unit-block { margin-bottom: 26px; }
.unit-banner { position: sticky; top: max(8px, env(safe-area-inset-top)); z-index: 6; display: flex; align-items: center; gap: 10px;
  padding: 12px 6px 12px 16px; border-radius: var(--radius); background: var(--sec); color: #fff; box-shadow: 0 4px 0 var(--sec-dark); }
.unit-banner.locked { background: var(--lock-bg); color: var(--muted); box-shadow: 0 4px 0 var(--lock-shadow); }
.ub-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ub-text small { font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.ub-text b { font-size: 1.2rem; line-height: 1.25; }
.ub-text span { font-size: .9rem; opacity: .9; }
.ub-friends { display: flex; }
.ub-friends .friend-face { width: 30px; height: 32px; }
.ub-guide { width: 48px; height: 48px; display: grid; place-items: center; color: inherit; border-left: 2px solid rgb(255 255 255 / 30%); flex: none; }
.unit-banner.locked .ub-guide { border-color: var(--border); }
.ub-guide svg { width: 26px; height: 26px; }

.trail { --amp: 58px; position: relative; display: flex; flex-direction: column; align-items: center; padding: 34px 0 6px; }
@media (min-width: 560px) { .trail { --amp: 78px; } }
.trail-row { position: relative; height: 94px; display: flex; justify-content: center; transform: translateX(calc(var(--o) * var(--amp))); }
.trail-row:has(.node-pop) { z-index: 10; }
.node { position: relative; width: 74px; height: 68px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--sec); color: #fff; box-shadow: 0 7px 0 var(--sec-dark); transition: transform .08s, box-shadow .08s; -webkit-tap-highlight-color: transparent; }
.node:active, .node.open { transform: translateY(4px); box-shadow: 0 3px 0 var(--sec-dark); }
.node-face { display: grid; place-items: center; width: 100%; height: 100%; }
.node svg { width: 34px; height: 34px; }
.node.k-trophy svg { width: 38px; height: 38px; }
.node.st-locked { background: var(--lock-bg); color: var(--lock-ink); box-shadow: 0 7px 0 var(--lock-shadow); }
.node.st-locked:active, .node.st-locked.open { box-shadow: 0 3px 0 var(--lock-shadow); }
.node.st-done.k-trophy { background: var(--accent); box-shadow: 0 7px 0 color-mix(in srgb, var(--accent) 70%, #000); }
.node-check { position: absolute; right: -4px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--sec); border: 2px solid var(--sec); }
.node-check svg { width: 16px; height: 16px; }
.node-ring { position: absolute; inset: -11px -11px -15px; border-radius: 50%; border: 7px solid var(--ring-bg); border-top-color: var(--sec); border-right-color: var(--sec);
  pointer-events: none; transform: rotate(-20deg); }
.start-bubble { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 12px; white-space: nowrap;
  background: var(--surface); border: 2px solid var(--border); color: var(--sec); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: .9rem;
  animation: bob 1.6s ease-in-out infinite; pointer-events: none; z-index: 2; }
.start-bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px; background: var(--surface);
  border-right: 2px solid var(--border); border-bottom: 2px solid var(--border); transform: translateX(-50%) rotate(45deg); }
@keyframes bob { 50% { transform: translate(-50%, -5px); } }
@media (prefers-reduced-motion: reduce) { .start-bubble { animation: none; } }
.trail-deco { position: absolute; width: 96px; height: 110px; pointer-events: none; }
.trail-deco.left { left: calc(50% - 175px); }
.trail-deco.right { right: calc(50% - 175px); }
@media (min-width: 560px) { .trail-deco { width: 130px; height: 145px; } .trail-deco.left { left: calc(50% - 250px); } .trail-deco.right { right: calc(50% - 250px); } }
.unit-block.locked .trail-deco { filter: grayscale(1); opacity: .45; }

.node-pop { position: absolute; top: 88px; left: calc(50% - var(--o) * var(--amp)); transform: translateX(-50%); width: min(310px, calc(100vw - 32px)); z-index: 20;
  padding: 14px; border-radius: var(--radius); background: var(--sec); color: #fff; box-shadow: 0 10px 30px rgb(0 0 0 / 22%); text-align: left; }
.node-pop::before { content: ""; position: absolute; top: -7px; left: calc(50% + var(--o) * var(--amp)); width: 14px; height: 14px; background: inherit; transform: translateX(-50%) rotate(45deg); }
.node-pop.locked { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.node-pop > b { display: block; font-size: 1.15rem; margin: 2px 0 4px; }
.pop-kind { font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.pop-blurb { margin: 0 0 10px; font-size: .92rem; opacity: .95; }
.pop-tip { background: rgb(255 255 255 / 15%); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; font-size: .9rem; }
.pop-tip .tip-tag { color: inherit; opacity: .85; }
.pop-tip p { margin: 2px 0 0; }
.node-pop.locked .pop-tip { background: var(--tip-bg); }
.node-pop.locked .pop-tip .tip-tag { color: var(--tip-ink); }
.pop-best { font-size: .88rem; margin: 0 0 10px; opacity: .9; }
.pop-note { font-size: .85rem; margin: 8px 0 0; color: var(--muted); }
.node-pop .btn { width: 100%; }
.node-pop .btn.primary { background: #fff; color: var(--sec-dark); box-shadow: 0 4px 0 rgb(0 0 0 / 15%); }
.node-pop .btn small { font-weight: 700; opacity: .8; }

/* ---- right rail ---- */
.tip-rail { background: var(--tip-bg); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.tip-rail h3 { font-size: 1.25rem; margin: 4px 0 10px; }
.rail-tip { margin-bottom: 14px; }
.rail-tip > p { margin: 0 0 8px; }
.tip-example { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.tip-example > span { display: flex; flex-direction: column; }
.tip-example small { color: var(--muted); }
.tip-example .speak-btn { flex: none; }
.players-card { padding: 14px; }
.pc-head { display: flex; align-items: center; justify-content: space-between; }
.pc-head h3 { margin: 0; font-size: 1.05rem; }
.pc-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--text); text-decoration: none; border-top: 1px solid var(--border); }
.pc-row:first-child { border-top: 0; }
.pc-liz { width: 40px; height: 44px; flex: none; }
.pc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pc-text small { color: var(--muted); font-size: .8rem; }
.pc-xp { display: flex; flex-direction: column; align-items: flex-end; }
.pc-xp small { color: var(--muted); font-size: .72rem; }

/* ---- lesson: tips, silent reading mode, fluency ---- */
.tip-btn { color: var(--muted); }
.tip-btn svg { width: 24px; height: 24px; }
.tip-btn.on { color: var(--tip-ink); background: var(--tip-bg); }
.tip-card { background: var(--tip-bg); border-radius: 14px; padding: 10px 14px 12px; margin: 4px 0 14px; }
.tip-head { display: flex; align-items: center; justify-content: space-between; }
.tip-head .link-btn { min-height: 32px; padding: 0 4px; text-decoration: none; color: var(--muted); }
.tip-help { margin: 2px 0 8px; color: var(--muted); font-size: .9rem; }
.tip-note, .tip-concept { margin: 0 0 8px; }
.lesson.silent .speak-btn, .lesson.silent .play-all, .lesson.silent .tap-hint { display: none !important; }
.ex-speak.locked .mic-btn, .ex-speak.locked .self-rate { display: none; }

.fluency-card { --fl: var(--good); display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; margin-top: 6px;
  border-radius: var(--radius); background: var(--surface); border: 1.5px solid var(--border); text-align: left; }
.fluency-card.almost { --fl: var(--almost); }
.fluency-card.bad { --fl: var(--bad); }
.fl-ring { width: 84px; height: 84px; flex: none; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--fl) var(--deg), var(--surface-2) 0); }
.fl-ring > span { width: 66px; height: 66px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.fl-ring b { font-size: 1.5rem; color: var(--fl); }
.fl-ring small { font-size: .65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }
.fl-body { flex: 1; min-width: 0; }
.fl-label { font-weight: 800; margin: 0 0 6px; color: var(--fl); }
.fl-part { display: grid; grid-template-columns: 96px 1fr 28px; align-items: center; gap: 8px; font-size: .82rem; margin-bottom: 3px; }
.fl-part b { text-align: right; }
.fl-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: block; flex: 1; }
.fl-bar i { display: block; height: 100%; background: var(--fl, var(--primary)); border-radius: inherit; }
.fl-tip, .fl-note { font-size: .85rem; margin: 6px 0 0; color: var(--muted); }
.fl-pill { display: inline-block; min-width: 38px; text-align: center; padding: 2px 8px; border-radius: 99px; font-weight: 800; font-size: .9rem; }
.fl-pill.good { background: var(--good-bg); color: var(--good); }
.fl-pill.almost { background: var(--almost-bg); color: var(--almost); }
.fl-pill.bad { background: var(--bad-bg); color: var(--bad); }
.fluency-list ul { list-style: none; padding: 0; margin: 0; }
.fluency-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); }
.fluency-list li:first-child { border-top: 0; }
.story-mode { font-size: .9rem; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 8px 12px; margin: 0 0 12px; }

/* ---- guidebook ---- */
.guide-intro { display: flex; align-items: center; gap: 10px; margin: 10px 0 12px; }
.guide-intro p { margin: 0; }
.tip-block { background: var(--tip-bg); border-left: 5px solid var(--sec); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.tip-text { margin: 4px 0 8px; font-size: 1.02rem; }
.tip-example.big { background: var(--surface); border-radius: 12px; padding: 8px 10px; margin: 0; }
.kind-ico svg { width: 22px; height: 22px; }
.lesson-row.k-speak .kind-ico { color: #2f7fd8; }
.lesson-row.k-read .kind-ico { color: #8a5bd0; }
.lesson-row.k-listen .kind-ico { color: #cf4677; }
.lesson-row.k-lesson .kind-ico, .lesson-row.k-review .kind-ico { color: var(--primary); }
.row-check { margin-left: auto; color: var(--primary); }
.row-check svg { width: 22px; height: 22px; }

/* ---- players ---- */
.players { max-width: 860px; margin: 0 auto; }
.signin-pitch { padding: 18px; }
.week-board { padding: 14px; }
.wb-row { display: grid; grid-template-columns: 38px minmax(70px, 120px) 1fr auto; align-items: center; gap: 10px; padding: 6px 0; }
.wb-row.me .wb-name { font-weight: 800; }
.wb-liz { width: 38px; height: 42px; }
.wb-bar { height: 12px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.wb-bar i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.player-cards { display: grid; gap: 12px; margin: 12px 0; }
@media (min-width: 760px) { .player-cards { grid-template-columns: 1fr 1fr; } }
.player-card { padding: 14px; }
.player-card.me { border-color: var(--primary); }
.pl-head { display: flex; align-items: center; gap: 12px; }
.pl-head h2 { margin: 0; }
.pl-head p { margin: 0; }
.pl-head > div { flex: 1; min-width: 0; }
.pl-liz { width: 56px; height: 62px; flex: none; }
.pl-level { padding: 4px 10px; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 800; font-size: .85rem; }
.pl-unit { margin: 12px 0 10px; display: flex; flex-direction: column; }
.pl-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
@media (max-width: 420px) { .pl-stats { grid-template-columns: 1fr 1fr; } }
.pl-stats div { background: var(--surface-2); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; }
.pl-stats b { font-size: 1.2rem; }
.pl-stats span { font-size: .75rem; color: var(--muted); }
.pl-skills { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; margin-bottom: 10px; }
.pl-fluency { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.pl-fluency .fl-bar i { background: var(--primary); }
.pl-langs { list-style: none; padding: 0; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 12px; }
.pl-langs li { display: grid; grid-template-columns: 1.6em minmax(0, 1fr) auto; grid-template-areas: "flag name level" "flag bar words"; align-items: center; gap: 2px 8px; padding: 8px 10px; }
.pl-langs li + li { border-top: 1px solid var(--border); }
.plg-flag { grid-area: flag; font-size: 1.3rem; }
.plg-name { grid-area: name; overflow-wrap: anywhere; }
.plg-level { grid-area: level; font-weight: 700; font-size: .88rem; text-align: right; }
.plg-bar { grid-area: bar; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.plg-bar i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.plg-words { grid-area: words; text-align: right; }
.pl-share { margin-top: 12px; }

/* ---- share sheet ---- */
.share-sheet { width: min(520px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.share-sheet::backdrop { background: rgb(0 0 0 / 45%); }
.share-sheet h2 { margin: 0 0 4px; }
.share-text { width: 100%; box-sizing: border-box; margin: 8px 0 12px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; font-size: .95rem; line-height: 1.4; resize: vertical; }
.share-sheet .btn-row { flex-wrap: wrap; }

/* ---- sign in ---- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 12px 0; border-radius: 14px; background: var(--surface-2); }
.seg-btn { min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.form-msg { min-height: 1.3em; font-size: .92rem; color: var(--muted); }
.form-msg.bad { color: var(--bad); }
.toggle.bring { margin-bottom: 6px; }
.pw-change { margin-top: 10px; }
.pw-change summary { cursor: pointer; color: var(--primary); margin-bottom: 8px; }

/* =====================================================================
   Hangul writing pad and romanization (v0.7)
   ===================================================================== */
.rom { display: block; flex-basis: 100%; color: var(--muted); font-size: .92rem; font-style: italic; margin-top: -4px; }
.prompt.letter { font-size: 3rem; line-height: 1; }
.trace-info { margin: -6px 0 12px; color: var(--muted); }
.trace-info b { color: var(--text); }
.trace-chips { display: flex; justify-content: center; gap: 8px; margin: 0 0 10px; }
.tchip { min-width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; font-size: 1.4rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 2px solid transparent; }
.tchip.on { border-color: var(--primary); color: var(--text); background: var(--surface); }
.tchip.done { background: var(--good-bg); color: var(--good); }
.trace-pad { width: min(320px, 82vw, 46dvh); aspect-ratio: 1; margin: 0 auto; }
.trace-pad svg { width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.trace-pad.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.tp-frame { fill: var(--surface); stroke: var(--border); stroke-width: 1; }
.tp-grid { fill: none; stroke: var(--border); stroke-width: .6; stroke-dasharray: 2 2; }
.tp-ghost path, .tp-hint .tp-next, .tp-ink path, .tp-demo path, .tp-user { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tp-ghost path { stroke: var(--surface-2); stroke-width: 8; }
.tp-hint .tp-next { stroke: color-mix(in srgb, var(--primary) 30%, var(--surface-2)); stroke-width: 8; }
.tp-arrow { fill: none; stroke: var(--primary); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tp-dot { fill: var(--primary); stroke: var(--surface); stroke-width: 1; }
.tp-num { font-size: 6px; font-weight: 800; fill: var(--primary); font-family: var(--font); }
.tp-ink path { stroke: var(--text); stroke-width: 7; }
.tp-ink path.helped { stroke: var(--almost); }
.tp-demo-stroke { stroke: var(--accent); stroke-width: 7; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .45s ease-in-out; }
.tp-demo-stroke.go { stroke-dashoffset: 0; }
/* Chinese characters: real brush outlines for the ghost and your finished strokes, thinner guide lines */
.trace-pad .tp-ghost .tp-outline { fill: var(--surface-2); stroke: none; }
.trace-pad .tp-ink .tp-outline { fill: var(--text); stroke: none; }
.trace-pad .tp-ink .tp-outline.helped { fill: var(--almost); }
.trace-pad.hanzi .tp-hint .tp-next { stroke-width: 5; }
.trace-pad.hanzi .tp-demo-stroke { stroke-width: 5; }
.trace-pad.hanzi .tp-user { stroke-width: 5; }
.tp-user { stroke: var(--primary); stroke-width: 6; opacity: .85; }
.tp-user.bad { stroke: var(--bad); }
.tp-user.fade { opacity: 0; transition: opacity .5s; }
.trace-msg { text-align: center; min-height: 1.5em; margin: 8px 0 4px; color: var(--muted); font-size: .95rem; }
.trace-msg.bad { color: var(--bad); }
.trace-msg.good { color: var(--good); font-weight: 700; }
.trace-msg.almost { color: var(--almost); }
.trace-tools { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.ex-trace.locked .trace-tools { visibility: hidden; }
.lesson-row.k-write .kind-ico { color: #1f9d63; }

/* =====================================================================
   Version 1.0: navigation bar, streak, today's goals, friends and pokes, motion
   ===================================================================== */
:root { --flame: #e0457b; --flame-bg: #fde6ee; --flame-core: #fff; --nav-h: 62px; --nav-top: 0px; }
@media (prefers-color-scheme: dark) {
  :root { --flame: #ff7aa5; --flame-bg: #3a1826; --flame-core: #3a1826; }
}

/* ---- navigation bar: bottom on phones, top on wide screens ---- */
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); }
body.in-lesson #nav { display: none; }
.nav-inner { max-width: 640px; margin: 0 auto; display: flex; }
.nav-brand, .nav-streak { display: none; }
.nav-tabs { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); }
.nav-tab { position: relative; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 700; -webkit-tap-highlight-color: transparent; }
.nav-ico { position: relative; width: 30px; height: 30px; display: grid; place-items: center; transition: transform .15s ease; }
.nav-ico svg { width: 26px; height: 26px; }
.nav-tab:active .nav-ico { transform: scale(.88); }
.nav-tab.on { color: var(--primary); }
.nav-tab.on::before { content: ""; position: absolute; top: -1px; left: 50%; width: 40px; height: 3px; margin-left: -20px; border-radius: 0 0 4px 4px; background: var(--primary); animation: nav-bar .25s ease-out; }
.nav-tab.on .nav-ico { animation: nav-pop .4s cubic-bezier(.34, 1.56, .64, 1); }
.nav-tab[data-tab="today"].lit .nav-ico { color: var(--flame); }
.nav-count { position: absolute; right: -13px; top: -5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); border: 2px solid var(--surface); font-size: .68rem; font-weight: 800; line-height: 1; }
.nav-count.lit { background: var(--flame); color: #fff; }
.nav-tab.risk .nav-count { background: var(--bad); color: #fff; animation: dot-pulse 1.8s ease-in-out infinite; }
.nav-tab.has-dot .nav-ico::after { content: ""; position: absolute; right: -4px; top: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); animation: dot-pulse 1.8s ease-in-out infinite; }
@keyframes nav-pop { 0% { transform: scale(.7) translateY(3px); } 100% { transform: none; } }
@keyframes nav-bar { from { transform: scaleX(0); } }
@keyframes dot-pulse { 50% { transform: scale(1.18); } }

body.has-nav #app { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
body.has-nav .update-banner { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); }
.unit-banner { top: calc(max(8px, env(safe-area-inset-top)) + var(--nav-top)); }

@media (min-width: 1000px) {
  body.has-nav { --nav-top: 60px; }
  #nav { top: 0; bottom: auto; padding-bottom: 0; border-top: 0; border-bottom: 1px solid var(--border); }
  .nav-inner { max-width: 1240px; height: 60px; padding: 0 16px; align-items: center; gap: 20px; }
  .nav-brand { display: flex; align-items: center; gap: 10px; flex: 0 0 250px; color: var(--text); text-decoration: none; font-size: 1.1rem; }
  .nav-brand img { border-radius: 9px; }
  .nav-tabs { display: flex; justify-content: center; gap: 6px; }
  .nav-tab { flex-direction: row; gap: 8px; height: 44px; padding: 0 16px; border-radius: 12px; font-size: .95rem; }
  .nav-tab:hover { background: var(--surface-2); }
  .nav-tab.on { background: var(--good-bg); }
  .nav-tab.on::before, .nav-count { display: none; }
  .nav-streak { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex: 0 0 250px; color: var(--muted); text-decoration: none; font-weight: 800; }
  .nav-streak .flame { width: 26px; height: 26px; }
  .nav-streak b { font-size: 1.15rem; color: var(--text); }
  .nav-streak small { font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); margin-left: 6px; }
  body.has-nav #app { padding-bottom: 0; padding-top: 60px; }
  body.has-nav .update-banner { bottom: calc(12px + env(safe-area-inset-bottom)); }
  .rail { top: calc(var(--nav-top) + 16px); max-height: calc(100dvh - 32px - var(--nav-top)); }
}

.tab-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.tab-top h1 { margin: 0; }
.today { max-width: 640px; margin: 0 auto; }

/* ---- the flame ---- */
.flame { display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none; color: var(--lock-ink); }
.flame svg { width: 100%; height: 100%; transform-origin: 50% 90%; }
.lit .flame, .flame.lit { color: var(--flame); }
.lit .flame svg, .flame.lit svg { animation: flicker 1.9s ease-in-out infinite; }
.risk .flame svg { animation: ember 2.2s ease-in-out infinite; }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1.5deg); }
  25% { transform: scale(1.05, .96) rotate(1.5deg); }
  50% { transform: scale(.97, 1.06) rotate(-1deg); }
  75% { transform: scale(1.04, .98) rotate(2deg); }
}
@keyframes ember { 50% { opacity: .45; transform: scale(.94); } }
.flame.ignite svg { animation: ignite .7s cubic-bezier(.34, 1.56, .64, 1) both, flicker 1.9s ease-in-out .7s infinite; }
@keyframes ignite { 0% { transform: scale(0) rotate(-25deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1); } }

/* ---- home: streak pill, goals chip, risk banner ---- */
.home-liz { border: 0; background: none; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.streak-pill { display: inline-flex; align-items: center; gap: 4px; height: 44px; padding: 0 14px 0 10px; border-radius: 99px; flex: none;
  background: var(--surface); border: 1.5px solid var(--border); color: var(--muted); text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.streak-pill.lit { background: var(--flame-bg); border-color: transparent; color: var(--flame); }
.streak-pill.risk { border-color: var(--bad); color: var(--bad); }
.streak-pill:active { transform: scale(.96); }
@media (min-width: 1000px) { .path-home .streak-pill { display: none; } }
a.chip-stat { color: var(--text); text-decoration: none; }
.goals-chip { gap: 4px; }
.goals-chip span { margin-left: 4px; }
.gdot { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-2); border: 1.5px solid var(--border); }
.gdot.on { background: var(--primary); border-color: var(--primary); }
.goals-chip.done { background: var(--good-bg); border-color: transparent; color: var(--good); }
.risk-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 0 0 14px; border-radius: var(--radius);
  background: var(--bad-bg); color: var(--bad); text-decoration: none; font-size: .92rem; animation: rise .35s ease-out both; }
.risk-banner .flame { width: 30px; height: 30px; color: var(--bad); }
.risk-banner span:last-child { color: var(--text); }
.risk-banner b { color: var(--bad); }
.pc-streak { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; color: var(--muted); }
.pc-streak.lit { color: var(--flame); }
.pc-streak .flame { width: 20px; height: 20px; }

/* ---- Today: streak card ---- */
.streak-card { padding: 18px 16px 14px; overflow: hidden; position: relative; }
.streak-card.lit { background: linear-gradient(160deg, var(--flame-bg), var(--surface) 70%); border-color: color-mix(in srgb, var(--flame) 35%, var(--border)); }
.streak-card.risk { border-color: var(--bad); }
:root { --ice: #3d9bdc; }
.streak-card.frozen { border-color: var(--ice); }
.streak-card.frozen .streak-flame, .streak-card.frozen .streak-num b { color: var(--ice); }
.streak-pill.frozen { border-color: var(--ice); color: var(--ice); }
.risk-banner.frozen { border-color: var(--ice); }
.risk-banner.frozen .flame, .risk-banner.frozen b { color: var(--ice); }
.streak-main { display: flex; align-items: center; gap: 12px; }
.streak-flame { width: 76px; height: 76px; }
.streak-num { flex: 1; display: flex; flex-direction: column; line-height: 1; }
.streak-num b { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.streak-card.lit .streak-num b { color: var(--flame); }
.streak-num span { font-weight: 700; color: var(--muted); margin-top: 4px; }
.streak-liz { width: 92px; height: 104px; flex: none; }
.streak-line { margin: 12px 0; font-weight: 600; }
.streak-card.risk .streak-line { color: var(--bad); }
.streak-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 0 0 10px; }
.sw-day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sw-day i { width: 100%; max-width: 40px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: #fff; border: 2px solid transparent; }
.sw-day i svg { width: 60%; height: 60%; }
.sw-day.on i { background: var(--flame); animation: pop-in .4s cubic-bezier(.34, 1.56, .64, 1) both; }
.sw-day.frozen i { background: var(--ice); }
.sw-day.today i { border-color: var(--flame); }
.sw-day.today:not(.on) i { border-style: dashed; background: transparent; }
.sw-day.future { opacity: .5; }
.sw-day small { font-size: .72rem; font-weight: 800; color: var(--muted); }
.sw-day.today small { color: var(--text); }
.streak-foot { margin: 0; }

/* ---- today's goals ---- */
.goals-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.goals-head h2 { margin: 0; }
.goals-count { font-weight: 800; padding: 3px 12px; border-radius: 99px; background: var(--surface-2); font-size: .9rem; }
.goals-card.swept .goals-count { background: var(--primary); color: var(--primary-ink); }
.goals { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.goal { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--bg); border: 1.5px solid var(--border); }
.goal-ico { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); --node-ink: var(--surface-2); }
.goal-ico svg { width: 22px; height: 22px; }
.goal-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.goal-body b { font-size: .97rem; line-height: 1.25; }
.goal-bar { display: flex; align-items: center; gap: 10px; }
.goal-bar .meter { height: 8px; }
.goal-bar small { font-weight: 700; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.goal.done { background: var(--good-bg); border-color: transparent; }
.goal.done .goal-ico { background: var(--primary); color: var(--primary-ink); }
.goal.done b { color: var(--good); }
.goal.fresh { animation: goal-flash 1s ease-out both; }
.goal.fresh .goal-ico { animation: pop-in .5s cubic-bezier(.34, 1.56, .64, 1) .25s both; }
@keyframes goal-flash { 0% { transform: scale(.96); box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 50%, transparent); } 40% { transform: scale(1.02); } 100% { transform: none; box-shadow: 0 0 0 14px transparent; } }
.goals-swept { margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--good-bg); color: var(--good); font-weight: 600; }
.goals-note { margin: 10px 0 0; }
.goals-card.compact .goals { margin-bottom: 0; }
.goals-card.compact .goals-swept { margin: 10px 0 0; }
.week-card .meter.wide { height: 12px; }
.week-card p { margin: 0; }
.cefr-card p { margin: 0; }
.cefr-track { display: flex; gap: 6px; margin: 8px 0 10px; }
.cefr-seg { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cefr-seg .meter { display: block; flex: none; width: 100%; height: 12px; min-width: 0; }
.cefr-seg small { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area-list { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; gap: 10px; }
.area-row { display: grid; gap: 4px; }
.area-top { display: flex; justify-content: space-between; gap: 10px; font-size: .85rem; }
.area-top b { font-weight: 600; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.area-top small { color: var(--muted); flex: none; }
.area-row.cur .area-top b, .area-row.done .area-top b { color: var(--text); }
.area-row.cur .area-top b { font-weight: 800; }
.area-row .meter { display: block; width: 100%; height: 10px; min-width: 0; }
.cefr-seg.cur small b, .cefr-seg.done small b { color: var(--text); }
.cefr-chip { text-decoration: none; color: inherit; }
.me-card .me-cefr { display: block; }

/* ---- milestones ---- */
.miles { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.mile { display: flex; gap: 12px; align-items: flex-start; }
.mile-ico { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--lock-ink); --node-ink: var(--surface-2); }
.mile-ico svg { width: 24px; height: 24px; }
.mile.has .mile-ico { background: var(--accent); color: #fff; --node-ink: var(--accent); }
.mile-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.mile-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mile-top small { color: var(--muted); font-variant-numeric: tabular-nums; }
.mile .meter { height: 8px; }
.mile .meter i { background: var(--accent); }
.mile-tiers { display: flex; flex-wrap: wrap; gap: 5px; }
.mile-tiers i { font-style: normal; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--lock-ink); }
.mile-tiers i.on { background: var(--accent); color: #fff; }

/* ---- friends ---- */
.today-board { padding: 14px; }
.tb-faces { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 0 2px; }
.tb-face { flex: 1 0 72px; max-width: 110px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 14px; background: var(--bg); text-align: center; position: relative; }
.tb-face.lit { background: var(--flame-bg); }
.tb-liz { width: 52px; height: 58px; position: relative; }
.tb-face.cold .tb-liz { filter: grayscale(.8); opacity: .7; }
.tb-face b { font-size: .85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-face small { display: inline-flex; align-items: center; gap: 1px; font-weight: 800; color: var(--muted); }
.tb-face.lit small { color: var(--flame); }
.tb-face .flame { width: 16px; height: 16px; }
.alerts-pitch { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.alerts-pitch > div { flex: 1; min-width: 0; }
.alerts-pitch p { margin: 2px 0 0; }
.ap-ico { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--tip-bg); color: var(--tip-ink); }
.ap-ico svg { width: 22px; height: 22px; animation: bell 3.2s ease-in-out infinite; transform-origin: 50% 10%; }
@keyframes bell { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(14deg); } 90% { transform: rotate(-12deg); } 95% { transform: rotate(6deg); } }
.pl-streak { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; font-size: 1.3rem; color: var(--muted); }
.pl-streak.lit { color: var(--flame); }
.pl-streak .flame { width: 30px; height: 30px; }
.pl-today { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; margin: 12px 0 0; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--bg); font-size: .92rem; }
.pl-today.lit { background: var(--good-bg); color: var(--good); }
.pl-today.risk { background: var(--bad-bg); }
.pl-today.risk b { color: var(--bad); }
.poke-btn { flex-direction: row; gap: 6px; background: var(--accent); color: #fff; flex: none; }
.poke-btn .poke-ico { width: 20px; height: 20px; display: grid; transform: rotate(90deg); }
.poke-btn svg { width: 20px; height: 20px; }
.poke-btn:not(:disabled):hover .poke-ico, .poke-btn:not(:disabled):focus-visible .poke-ico { animation: jab .5s ease-in-out infinite; }
.poke-btn.go .poke-ico { animation: jab .35s ease-in-out 3; }
.poke-btn.sent { background: var(--surface-2); color: var(--muted); opacity: 1; }
@keyframes jab { 50% { transform: rotate(90deg) translateY(-4px); } }
.poke-done { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: .85rem; flex: none; }
.poke-done svg { width: 18px; height: 18px; }

/* ---- toasts ---- */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 45; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
body.has-nav .toasts { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); }
body.in-lesson .toasts { display: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; width: min(100%, 460px); padding: 10px 16px 10px 10px; border-radius: 18px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--accent); color: var(--text); text-decoration: none; box-shadow: 0 8px 28px rgb(0 0 0 / 22%);
  animation: toast-in .4s cubic-bezier(.34, 1.56, .64, 1) both; }
.toast.out { animation: toast-out .25s ease-in both; }
.toast-liz { width: 52px; height: 58px; flex: none; }
.toast-liz .mascot { animation: liz-wobble .6s ease-in-out 3; }
.toast-text { display: flex; flex-direction: column; min-width: 0; }
.toast-text span { color: var(--muted); font-size: .9rem; }
@keyframes toast-in { from { transform: translateY(30px) scale(.9); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(20px); opacity: 0; } }

/* ---- effects ---- */
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
.fx-spark { position: fixed; z-index: 55; width: 8px; height: 8px; margin: -4px; border-radius: 2px; pointer-events: none; animation: spark .6s ease-out both; }
@keyframes spark { from { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) rotate(160deg) scale(.2); opacity: 0; } }
@keyframes pop-in { from { transform: scale(0); opacity: 0; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
@keyframes grow-x { from { transform: scaleX(0); } }

/* ---- the lizards come alive ---- */
.mascot.idle, .liz-mini .mascot:not(.hop):not(.droop), .trail-deco .mascot, .sec-art .mascot { animation: liz-breathe 3.4s ease-in-out infinite; }
.mascot.idle[data-pose="wave"] { animation: liz-wave 4.2s ease-in-out infinite; }
.mascot.idle[data-pose="cheer"] { animation: liz-cheer 2.6s ease-in-out infinite; }
.mascot.idle[data-pose="oops"] { animation: liz-wobble 2.8s ease-in-out infinite; }
.mascot[data-pose="sleep"] { animation: liz-sleep 4.6s ease-in-out infinite !important; }
.trail-deco.right .mascot { animation-delay: -1.7s; }
.unit-block.locked .trail-deco .mascot { animation-duration: 5.5s; }
.mascot.bounce-in { animation: liz-in .65s cubic-bezier(.34, 1.56, .64, 1) both, liz-cheer 2.6s ease-in-out .8s infinite; }
.section-card:hover .mascot { animation: liz-wobble .6s ease-in-out; }
@keyframes liz-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(.985, 1.025); } }
@keyframes liz-sleep { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.02, .97); } }
@keyframes liz-wave { 0%, 55%, 100% { transform: rotate(0) scale(1, 1); } 25% { transform: rotate(0) scale(.985, 1.025); } 65% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } 85% { transform: rotate(-3deg); } 93% { transform: rotate(2deg); } }
@keyframes liz-cheer { 0%, 30%, 100% { transform: translateY(0) scale(1, 1); } 10% { transform: translateY(0) scale(1.04, .95); } 18% { transform: translateY(-9%) scale(.97, 1.04); } 26% { transform: translateY(0) scale(1.03, .97); } }
@keyframes liz-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 50% { transform: rotate(4deg); } 75% { transform: rotate(-2deg); } }
@keyframes liz-in { from { transform: translateY(40%) scale(.3); opacity: 0; } }
/* sleeping lizards snore a little "z" */
.trail-deco:has(img[data-pose="sleep"])::after, .home-liz:has(img[data-pose="sleep"])::after, .tb-liz:has(img[data-pose="sleep"])::after, .pl-liz:has(img[data-pose="sleep"])::after {
  content: "z"; position: absolute; right: 6%; top: 0; font-weight: 800; font-size: 1rem; color: var(--muted); animation: zzz 2.8s ease-in-out infinite; pointer-events: none; }
.home-liz, .pl-liz { position: relative; }
@keyframes zzz { 0% { transform: translate(0, 8px) scale(.6); opacity: 0; } 30% { opacity: .9; } 100% { transform: translate(10px, -14px) scale(1.2); opacity: 0; } }

/* ---- screens, lessons and the summary move ---- */
#app > section { animation: screen-in .24s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }
#app > section.lesson { animation: none; }
.ex-wrap > * { animation: ex-in .28s ease-out; }
@keyframes ex-in { from { opacity: 0; transform: translateX(18px); } }
.feedback:not([hidden]) { animation: fb-up .22s ease-out; }
@keyframes fb-up { from { transform: translateY(14px); opacity: 0; } }
.opt, .tile, .accent-key { transition: transform .08s ease, border-color .15s ease, background .15s ease; }
.opt:active, .tile:active { transform: scale(.97); }
.opt.correct { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.04); } }
.progress { position: relative; }
.progress .bar { position: relative; overflow: hidden; transition: width .45s cubic-bezier(.34, 1.3, .64, 1); }
.progress .bar::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 45%) 50%, transparent 70%); transform: translateX(-100%); }
.progress.glow .bar::after { animation: shine .7s ease-out; }
.progress.glow { animation: glow .7s ease-out; }
@keyframes shine { to { transform: translateX(100%); } }
@keyframes glow { 30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 30%, transparent); } }
.liz-mini { position: relative; }
.combo { position: absolute; right: -2px; bottom: -12px; white-space: nowrap; padding: 2px 8px; border-radius: 99px; background: var(--flame); color: #fff; font-size: .68rem; font-weight: 800; z-index: 2; }
.combo.pop { animation: pop-in .35s cubic-bezier(.34, 1.56, .64, 1); }
.meter i, .wb-bar i, .fl-bar i, .unit-bar i { transform-origin: 0 50%; animation: grow-x .7s cubic-bezier(.22, 1, .36, 1) both; }
.node.st-current { animation: node-beat 2.2s ease-in-out infinite; }
.node.st-current:active, .node.st-current.open { animation: none; }
@keyframes node-beat { 50% { transform: scale(1.05); } }
.node-ring { animation: ring-spin 9s linear infinite; }
@keyframes ring-spin { to { transform: rotate(340deg); } }
.node-check { animation: pop-in .4s cubic-bezier(.34, 1.56, .64, 1) both; }
.btn.primary.continue { box-shadow: 0 4px 0 var(--primary-press); }
.btn.primary.continue:active { box-shadow: 0 1px 0 var(--primary-press); transform: translateY(3px); }
.summary .stat { animation: pop-in .45s cubic-bezier(.34, 1.56, .64, 1) both; }
.summary .stat:nth-child(2) { animation-delay: .1s; }
.summary .stat:nth-child(3) { animation-delay: .2s; }
.summary .card { animation: rise .4s ease-out .25s both; }
.streak-up { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: linear-gradient(160deg, var(--flame-bg), var(--surface) 80%); border-color: color-mix(in srgb, var(--flame) 35%, var(--border)); }
.streak-up .streak-flame { width: 58px; height: 58px; }
.streak-up b { font-size: 1.3rem; color: var(--flame); }
.streak-up p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.streak-count { display: inline-block; font-variant-numeric: tabular-nums; }
.streak-count.tick { animation: tick .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes tick { 0% { transform: translateY(-70%) scale(1.6); opacity: 0; } }
.badge-dot { animation: pop-in .5s cubic-bezier(.34, 1.56, .64, 1) .3s both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .trail-deco::after, .home-liz::after, .tb-liz::after, .pl-liz::after { display: none; }
}

/* fix your answer: a retry keeps the words you got right */
.fix-area { margin-bottom: 8px; }
.fix-line {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 6px;
  padding: 14px; border: 2px solid var(--border); border-radius: 14px; background: var(--surface);
  font-size: 1.2rem; line-height: 1.6;
}
.fix-word { color: var(--good); font-weight: 600; }
.fix-extra { color: var(--muted); }
.fix-slot {
  font: inherit; color: var(--text); min-width: 3ch; max-width: 100%;
  padding: 2px 6px; border: 0; border-bottom: 3px solid var(--bad);
  border-radius: 6px 6px 0 0; background: var(--bad-bg);
}
.fix-slot.empty { border-bottom-style: dashed; }
.fix-slot:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.fix-slot:read-only { background: transparent; }
.fix-help { color: var(--muted); font-size: .92rem; margin: 6px 0 12px; }
.fix-help .link-btn { min-height: 32px; padding: 0; }
.tile.flagged { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.fb-mine { color: var(--text); }
.feedback .fb-mine .fb-label { color: var(--muted); }
.diff-bad { color: var(--bad); font-weight: 700; text-decoration: underline wavy; text-underline-offset: 3px; }
.diff-extra { opacity: .7; }
.diff-gap { color: var(--bad); font-weight: 700; }

/* ---------- situation games ---------- */
.lesson-row.k-situation .kind-ico { color: #d0573a; }
.node.k-situation:not(.st-locked) { background: #d0573a; box-shadow: 0 7px 0 #9e3c24; }
.node.k-situation:not(.st-locked):active, .node.k-situation.open:not(.st-locked) { box-shadow: 0 3px 0 #9e3c24; }
.node.k-situation .node-check { color: #d0573a; border-color: #d0573a; }
.sit-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.sit-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
.sit-card:active { transform: translateY(1px); }
.sit-ico { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--surface-2); font-size: 1.5rem; }
.sit-ico.big { width: 56px; height: 56px; font-size: 1.9rem; }
.sit-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sit-text small { color: var(--muted); }
.sit-stars { color: #d0573a; letter-spacing: 1px; white-space: nowrap; }
.sit-stars i { font-style: normal; color: var(--border); }
.sit-new { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #d0573a; }
.sit-head { display: flex; align-items: center; gap: 12px; }
.sit-head .story-title { margin: 0; }
.sit-en { margin: 0; }
.sit-scene { margin: 12px 0 8px; font-style: italic; }
.sit-cast { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 4px; }
.cast-one { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 64px; text-align: center; }
.cast-one img { width: 48px; height: 52px; object-fit: contain; }
.cast-one small { font-size: .74rem; color: var(--muted); line-height: 1.15; }
.npc-face { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); font-size: 1.6rem; }
.npc-face.sm { width: 20px; height: 20px; font-size: .85rem; background: none; display: inline-grid; margin-right: 4px; vertical-align: -3px; }
.sit-intro.started .sit-cast, .sit-intro.started .sit-scene { display: none; }
.sit-mission { position: sticky; top: -1px; z-index: 3; margin: 10px 0 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface);
  border: 1.5px solid color-mix(in srgb, #d0573a 45%, var(--border)); font-size: .9rem; }
.sit-mission > b { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #d0573a; }
.sit-mission ol { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.sit-mission li { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.sit-mission .tick { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800;
  border: 1.5px solid var(--border); color: var(--muted); }
.sit-mission li.done { color: var(--text); }
.sit-mission li.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.sit-ears { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; color: var(--muted); margin: 0 0 12px; cursor: pointer; }
.sit-ears input { margin-top: 3px; }
.sit-b .who { display: flex; align-items: center; gap: 4px; }
.who-face { width: 22px; height: 24px; object-fit: contain; }
.b-tools { display: flex; gap: 6px; padding: 2px 6px 0; }
.b-tool { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 10px; padding: 2px 8px; font-size: .75rem; font-weight: 700;
  min-height: 26px; display: inline-flex; align-items: center; cursor: pointer; }
.b-tool svg { width: 16px; height: 16px; }
.b-en { font-size: .88rem; color: var(--muted); padding: 2px 8px 0; max-width: 100%; }
.bubble.you .line { background: color-mix(in srgb, #d0573a 14%, var(--surface)); border-color: color-mix(in srgb, #d0573a 35%, var(--border)); }
.bubble.pop { animation: pop-in .35s cubic-bezier(.34, 1.56, .64, 1) both; }
.sit-goal { display: inline-block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: #d0573a;
  border-radius: 8px; padding: 2px 7px; margin-right: 6px; vertical-align: 1px; }
.sit-choose .opt[disabled] { opacity: .55; cursor: default; }
.sit-hint { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; }
.hint-face { width: 24px; height: 26px; object-fit: contain; vertical-align: middle; }
.sit-hint-text { margin: 10px 0 0; padding: 8px 12px; border-radius: 12px; background: var(--tip-bg, var(--surface-2)); font-size: .92rem; }
.sit-goal.call { background: #2f7d6d; }
.sit-adv { color: #2f7d6d !important; font-weight: 700; }
.sit-advnote { margin: 10px 0 0; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); font-size: .9rem; }
.sit-ico.art { object-fit: cover; padding: 0; }
.sit-banner { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 240px; object-fit: cover; border-radius: var(--radius); margin: 12px 0 4px; }
.sit-intro.started .sit-banner, .sit-intro.started .sit-advnote { display: none; }
.npc-face.pic { object-fit: cover; }
.cast-one img.npc-face.pic { width: 48px; height: 48px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.pick-grid.plain { grid-template-columns: 1fr; }
.pick-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 96px; padding: 12px 10px;
  border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: center; cursor: pointer;
  transition: transform .08s ease, border-color .15s ease, background .15s ease; }
.pick-grid.plain .pick-tile { min-height: 52px; align-items: flex-start; text-align: left; }
.pick-tile:active { transform: scale(.97); }
.pick-tile.selected { border-color: #2f7d6d; background: color-mix(in srgb, #2f7d6d 12%, var(--surface)); }
.pick-tile b { line-height: 1.2; }
.pick-tile small { color: var(--muted); font-size: .8rem; line-height: 1.2; }
.pick-ico { font-size: 2rem; line-height: 1; }
img.pick-ico { width: 56px; height: 56px; object-fit: contain; }
.pick-seen { position: absolute; top: 5px; right: 7px; font-style: normal; font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pick-free { margin: 10px 0 0; font-size: .86rem; color: var(--muted); }
.bubble.sit-custom { align-self: stretch; max-width: 100%; align-items: stretch; }
.bubble.sit-custom .line { background: color-mix(in srgb, #2f7d6d 10%, var(--surface)); border: 1px dashed color-mix(in srgb, #2f7d6d 55%, var(--border)); border-radius: 14px;
  padding: 10px 14px; font-size: .95rem; text-align: left; cursor: default; }
.cu-head { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #2f7d6d; padding: 0 6px 3px; }
.sit-slip ul { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.sit-slip li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); font-weight: 700; }
.sit-slip li > span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.sit-slip li small { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.sit-again { font-size: .88rem; margin: 0 0 12px; }
.sit-customs { margin-bottom: 12px; }
.sit-speak .ex-speak { margin: 0; }
.sit-speak .ex-speak > .ex-label { display: none; }
.sit-end h3 { margin: 0 0 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sit-end h3 .sit-stars { font-size: 1.3rem; }
.sit-phrases { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sit-phrases li { display: flex; align-items: center; gap: 10px; }
.sit-phrases li > span { display: flex; flex-direction: column; }
.sit-phrases small { color: var(--muted); }
.sit-tips ul { margin: 4px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: .94rem; }
.sit-tips .ex-label { display: flex; align-items: center; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .bubble.pop { animation: none; } }

/* A regional tip (e.g. what to say in Québec instead) under a reading */
.region-note { margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2, rgba(127,127,127,0.1)); font-size: 0.9rem; line-height: 1.4; }

/* ---------- dress up (avatar maker) ---------- */
.mascot.liz-pending { opacity: 0; }
.mascot { transition: opacity .15s ease-out; }
.du-layout { display: grid; gap: 14px; }
@media (min-width: 860px) {
  .du-layout { grid-template-columns: minmax(280px, 360px) 1fr; align-items: start; }
  .du-stage { position: sticky; top: 16px; }
}
.du-stage { text-align: center; }
.du-preview { display: block; width: 220px; height: 240px; margin: 4px auto 8px; padding: 0; background: none; border: 0; cursor: pointer; }
.du-stage .btn-row { margin-top: 10px; }
.du-options { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.du-group h2 { margin: 0 0 8px; font-size: 1.05rem; }
.du-group > p { margin: -4px 0 10px; }
.du-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.du-colors { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
.du-lizards { grid-template-columns: repeat(3, 1fr); }
.du-pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 6px; min-height: var(--tap);
  background: var(--surface-2); border: 2px solid transparent; border-radius: 14px; color: var(--text); cursor: pointer; font: inherit; }
.du-pick small { font-size: .74rem; line-height: 1.15; text-align: center; color: var(--muted); }
.du-pick.on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.du-pick.on small { color: var(--text); font-weight: 700; }
.du-pick:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.du-pick.locked { opacity: .55; cursor: not-allowed; }
.du-lock { position: absolute; top: 4px; right: 4px; font-size: .65rem; font-weight: 800; padding: 1px 6px; border-radius: 99px; background: var(--accent); color: #fff; }
.du-face { width: 72px; height: 80px; }
.du-thumb { display: grid; place-items: center; width: 60px; height: 44px; }
.du-thumb img { display: block; width: 60px; height: 44px; object-fit: contain; }
.du-none { font-size: 1.2rem; color: var(--muted); }
.du-swatch { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgb(0 0 0 / 15%); }
.lizard-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); text-decoration: none; background: var(--surface-2); }
.lizard-row > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lizard-row-liz { width: 56px; height: 62px; flex: none; }
.me-top .link-btn.small { display: block; min-height: 0; padding: 2px 0 0; font-size: .82rem; }
.path-chip { display: inline-block; margin: 2px 0 4px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: inherit; text-decoration: none; font-weight: 600; }
/* Started scene: the mission is one compact row (ticks + the next goal) so it never covers the chat. */
.situation.started .sit-mission { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.situation.started .sit-mission ol { margin: 0; flex-wrap: nowrap; gap: 6px; min-width: 0; flex: 1; }
.situation.started .sit-mission li > span:last-child { display: none; }
.situation.started .sit-mission li.next { min-width: 0; flex: 1; }
.situation.started .sit-mission li.next > span:last-child { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.du-pick .rom { margin-top: 0; font-size: .68rem; text-align: center; }

/* ---------- Placement results and unit checkpoints ---------- */
.level-strip { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0 8px; }
.ls-cell { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--border); flex: none; }
.ls-cell.ok { background: var(--good); }
.ls-cell.mid { background: var(--almost); }
.ls-cell.no { background: var(--bad); }
.ls-cell.here { outline: 2px solid var(--accent); outline-offset: 1px; }
.ls-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.ls-key .ls-cell { width: 11px; height: 11px; margin-left: 6px; }
.ls-key .ls-cell:first-child { margin-left: 0; }
.checkpoint-offer { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; margin: 12px 0; border: 2px solid var(--primary); }
.checkpoint-offer small { display: block; margin-top: 2px; }
.co-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--good-bg); color: var(--good); flex: none; }
.co-ico svg { width: 20px; height: 20px; }
.summary-foot .btn + .btn { margin-top: 10px; }

/* ---- math problems (exercises/problem.js) ---- */
.prob-q { font-size: 1.12rem; line-height: 1.55; margin: 0 0 18px; }
.prob-q .katex, .prob-options .katex, .step-tile .katex { font-size: 1.08em; }
.math-display { display: block; overflow-x: auto; overflow-y: hidden; margin: 8px 0; }
.katex-display { margin: 0; }
code.tex { font-size: .92em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.prob-steps-show { margin: 0 0 14px; padding-left: 1.4em; line-height: 1.6; }
.prob-steps-show li { margin-bottom: 6px; }
.prob-answer { font-size: 1.1rem; margin: 0 0 10px; }
.prob-note { color: var(--muted); font-size: .95rem; }
.got-it { margin-top: 8px; width: 100%; }

.num-entry { display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px; }
.num-display {
  flex: 1; min-height: 56px; display: flex; align-items: center; padding: 8px 14px;
  border: 2px solid var(--primary); border-radius: 14px; background: var(--surface);
  font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-x: auto; white-space: nowrap;
}
.num-display .ph { font-size: 1rem; font-weight: 500; color: var(--muted); }
.num-display sup { font-size: .6em; }
.num-unit { font-size: 1.15rem; color: var(--muted); font-weight: 600; }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 420px; margin: 0 auto; }
.key {
  min-height: 52px; border-radius: 12px; border: 2px solid var(--border); border-bottom-width: 4px;
  background: var(--surface); color: var(--text); font-size: 1.3rem; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.key:active { transform: translateY(2px); border-bottom-width: 2px; }
.key.k-zero { grid-column: span 2; }
.key.k-back, .key.k-neg, .key.k-exp, .key.k-clear { background: var(--surface-2); font-size: 1.1rem; }
.locked .key { opacity: .5; cursor: default; }

.prob-options .opt { font-size: 1.1rem; }
.steps-chosen { min-height: 60px; margin: 0 0 14px; padding-left: 1.6em; display: grid; gap: 8px; }
.steps-chosen li::marker { color: var(--muted); font-weight: 700; }
.steps-empty { list-style: none; margin-left: -1.6em; color: var(--muted); border: 2px dashed var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.steps-pool { display: grid; gap: 8px; padding-top: 12px; border-top: 2px solid var(--border); }
.step-tile {
  width: 100%; min-height: 48px; padding: 8px 12px; text-align: left; border-radius: 12px;
  border: 2px solid var(--border); border-bottom-width: 4px; background: var(--surface); color: var(--text);
  font-size: 1rem; cursor: pointer; touch-action: manipulation;
}
.step-tile.correct { border-color: var(--good); background: var(--good-bg); }
.step-tile.wrong { border-color: var(--bad); background: var(--bad-bg); }
.ex-problem .match-col .opt { text-align: center; }

.prob-why { color: var(--text); font-weight: 600; }
.prob-sol { color: var(--text); margin: 6px 0 4px; }
.prob-sol summary { cursor: pointer; font-weight: 700; color: inherit; }
.prob-sol ol, .steps-right { margin: 6px 0 0; padding-left: 1.4em; line-height: 1.55; }
.prob-ref { color: var(--muted); font-size: .88rem; }
.fb-answer .steps-right { flex-basis: 100%; font-weight: 500; }

/* ---- mock exam (screens/exam.js) ---- */
.exam-formats { display: grid; gap: 10px; margin: 14px 0; }
.exam-format { display: grid; gap: 2px; text-decoration: none; color: var(--text); }
.exam-format b { font-size: 1.1rem; }
.exam-format.disabled { opacity: .5; pointer-events: none; }
.exam-past ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.exam-past li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; }
.exam-past li small { grid-column: 1 / -1; }
.exam-past .good, .exam-areas .good { color: var(--good); }
.exam-areas .bad { color: var(--bad); }

.exam {
  position: fixed; left: 0; right: 0; top: var(--vvtop, 0px); height: var(--vvh, 100dvh);
  display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--bg);
}
.exam-top { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--border); }
.exam-count { flex: 1; font-weight: 700; white-space: nowrap; }
.exam-foot .btn { white-space: nowrap; }
.exam-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.1rem; padding: 4px 10px; border-radius: 10px; background: var(--surface-2); }
.exam-timer.warn { background: var(--bad-bg); color: var(--bad); }
.exam-flag { min-height: 40px; padding: 6px 12px; }
.exam-flag.on { color: var(--accent); border-color: var(--accent); font-weight: 800; }
.exam-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.exam-grid { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--bg); max-height: 55vh; overflow-y: auto; }
.exam-grid-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-bottom: 10px; }
.exam-grid .cell {
  min-height: 44px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 700; cursor: pointer; position: relative;
}
.exam-grid .cell.done { background: var(--good-bg); border-color: var(--good); }
.exam-grid .cell.flag::after { content: '⚑'; position: absolute; top: -2px; right: 3px; font-size: .75rem; color: var(--accent); }
.exam-grid .cell.cur { outline: 3px solid var(--primary); outline-offset: 1px; }
.exam-grid .hand-in { width: 100%; }
.exam-foot { display: flex; gap: 8px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg); }
.exam-foot .btn { flex: 1; }
.exam-foot .grid-btn { flex: 1.2; }

.exam-areas table { width: 100%; border-collapse: collapse; }
.exam-areas th { text-align: left; font-weight: 600; padding: 6px 8px 6px 0; }
.exam-areas td { padding: 6px 4px; white-space: nowrap; }
.exam-areas td:nth-child(3) { width: 30%; }
.exam-review { padding-left: 1.6em; display: grid; gap: 8px; }
.exam-review details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.exam-review summary { cursor: pointer; font-weight: 700; }
.exam-review .mark { display: inline-block; width: 1.2em; }
.exam-review li.right .mark { color: var(--good); }
.exam-review li.wrong .mark { color: var(--bad); }
.exam-review .prob-q { margin: 8px 0; font-size: 1rem; }
.prob-sol-list { padding-left: 1.4em; line-height: 1.55; }

/* Arabic: right-to-left, and larger so the vowel marks are readable */
[lang="ar"] { unicode-bidi: plaintext; }
.prompt[lang="ar"], .tile[lang="ar"], .opt[lang="ar"], .passage[lang="ar"] .sent, .line[lang="ar"], .tip-example [lang="ar"] { font-size: 1.4rem; line-height: 1.8; }
.prompt.big[lang="ar"] { font-size: 2.1rem; }
.opt[lang="ar"] { text-align: right; }
.match-col .opt[lang="ar"] { text-align: center; }
.passage[lang="ar"] p, .passage[lang="ar"] .rom { text-align: right; }
.wb-answer[dir="rtl"], .wb-bank[dir="rtl"] { direction: rtl; }
