/* Learner portal design system. Mobile-first.
   Palette: warm paper for long reading, midnight indigo for focus, marigold for reward. */
:root {
  --ink: #171a3f;
  --ink-2: #252a6b;
  --brand: #4250e0;
  --brand-dark: #2f3bc0;
  --brand-soft: #eceefd;
  --accent: #ffb020;
  --accent-deep: #e58a00;
  --accent-soft: #fff3d9;
  --ok: #0f8f62;
  --ok-bg: #e2f6ec;
  --warn: #c93b37;
  --warn-bg: #fdebe9;
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1c1f37;
  --muted: #666b86;
  --line: #e7e3da;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(23, 26, 63, .05), 0 2px 8px rgba(23, 26, 63, .04);
  --shadow-md: 0 10px 30px rgba(23, 26, 63, .09), 0 2px 8px rgba(23, 26, 63, .05);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --pop: cubic-bezier(.34, 1.56, .64, 1);
  --nav-h: 62px;
  --top-h: 60px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Plus Jakarta Sans", "Tiro Devanagari Marathi", system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #efece4; padding: 0 4px; border-radius: 4px; }
:focus-visible { outline: 3px solid rgba(66, 80, 224, .45); outline-offset: 2px; border-radius: 6px; }

/* ----- shell ----- */
.app-shell { min-height: 100vh; }
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}
/* The blur lives on a pseudo-element: a backdrop-filter on .top-bar itself would trap the
   fixed-position mobile tab bar (a descendant) inside the header. */
.top-bar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(18px) saturate(170%); -webkit-backdrop-filter: blur(18px) saturate(170%);
  border-bottom: 1px solid rgba(23, 26, 63, .07);
}
.top-bar-inner {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  height: var(--top-h); padding: 0 16px; max-width: 1080px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; padding: 3px; border-radius: 11px; background: var(--accent-soft); }
.brand-name { font-size: 1.05rem; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 700; font-size: .9rem;
}
.icon-button {
  display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: #efece4; color: var(--ink); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button[aria-pressed="false"] .sound-waves { display: none; }
.icon-button[aria-pressed="false"] { opacity: .55; }
.logout-form { margin: 0; }
.top-bar .link-button { color: var(--muted); font-weight: 600; }

.main-nav {
  position: fixed; z-index: 30; display: flex; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(23, 26, 63, .08);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .7rem; font-weight: 600;
  transition: color .15s ease, transform .12s var(--ease);
}
.nav-item:hover { text-decoration: none; color: var(--ink); }
.nav-item:active { transform: scale(.94); }
.nav-item.active { color: var(--brand); }
.nav-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.main {
  max-width: 760px; margin: 0 auto;
  padding: calc(var(--top-h) + env(safe-area-inset-top, 0px) + 20px) 16px
           calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 28px);
}
.main:has(.home-hero) { max-width: 900px; }

@media (min-width: 860px) {
  .main-nav {
    position: static; height: auto; padding: 0; background: none; border: 0; gap: 4px;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .nav-item { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 8px 14px; border-radius: 99px; font-size: .9rem; }
  .nav-item:hover { background: #efece4; }
  .nav-item.active { background: var(--brand-soft); }
  .nav-icon { width: 19px; height: 19px; }
  .main { padding-bottom: 56px; }
}
@media (max-width: 420px) { .brand-name { display: none; } }

/* public (logged-out) pages */
.is-public {
  background:
    radial-gradient(ellipse 70% 50% at 15% 0%, rgba(255, 176, 32, .16), transparent),
    radial-gradient(ellipse 70% 55% at 90% 10%, rgba(66, 80, 224, .16), transparent), var(--bg);
  background-attachment: fixed;
}
.public-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 40px; color: var(--ink); font-weight: 800; }
.public-brand-mark { width: 64px; height: 64px; padding: 6px; border-radius: 20px; background: #fff; box-shadow: var(--shadow-md); }
.public-brand .brand-name { display: block; font-size: 1.3rem; letter-spacing: -0.02em; }
.main-public { padding-top: 12px; padding-bottom: 40px; }
.auth-card { max-width: 430px; margin: 16px auto; padding: 28px 24px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border-color: transparent; }
.auth-title { text-align: center; margin: 0 0 6px; font-size: 1.5rem; }
.auth-card > .muted { text-align: center; margin: 0 0 16px; }
.g_id_signin { display: flex; justify-content: center; }

/* ----- components ----- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.card-title { margin: 0 0 8px; font-size: 1.08rem; }
.page-title { font-size: 1.7rem; margin: 4px 0 12px; }
.section-title { font-size: 1.15rem; margin: 24px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .74rem; }
.center { text-align: center; }
.center-card { text-align: center; padding: 40px 22px; border-radius: var(--radius-lg); }
.plain-list { margin: 0; padding-left: 20px; }
.plain-list li { margin-bottom: 6px; }
.breadcrumb { font-size: .82rem; color: var(--muted); margin: 0 0 10px; }
.breadcrumb a { color: var(--muted); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.kicker, .world-kicker, .resume-kicker {
  margin: 0 0 4px; color: var(--brand); font-size: .72rem; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase;
}
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 1.4rem; }

.flash { border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; font-size: .95rem; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--warn-bg); color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; cursor: pointer; font-family: inherit;
  padding: 13px 22px; font-size: 1rem; font-weight: 700; text-align: center;
  background: #ece9e1; color: var(--text);
  transition: transform .12s var(--ease), box-shadow .2s var(--ease), background .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(2px) scale(.98); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 0 var(--brand-dark); }
.btn-primary:hover { background: #4b59ea; color: #fff; }
.btn-primary:active { box-shadow: 0 1px 0 var(--brand-dark); transform: translateY(3px); }
.btn-accent { background: var(--accent); color: #2a1d00; box-shadow: 0 4px 0 var(--accent-deep); }
.btn-accent:hover { background: #ffba3d; }
.btn-accent:active { box-shadow: 0 1px 0 var(--accent-deep); transform: translateY(3px); }
.btn-secondary { background: #ece9e1; color: var(--text); }
.btn-secondary:hover { background: #e4e0d6; }
.btn-lg { padding: 16px 28px; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; margin-top: 16px; }
.btn-audio { background: var(--brand-soft); color: var(--brand); }
.link-button { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font-size: .9rem; font-family: inherit; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; font-weight: 600; }
.field input, .field textarea, .field select {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px; font-size: 1rem;
  font-family: inherit; font-weight: 400; background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(66, 80, 224, .14); }
.field input.is-invalid, .field textarea.is-invalid { border-color: #d64545; background: #fff7f7; }
.field input.is-invalid:focus, .field textarea.is-invalid:focus { box-shadow: 0 0 0 4px rgba(214, 69, 69, .14); }
.field-error { color: #c43636; font-weight: 500; font-size: .84rem; margin-top: 2px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: #eef0f6; color: #444a66; }
.badge-ok { background: #e2f6ec; color: #0f8f62; }
.invite-link { display: inline-block; font-size: .82rem; word-break: break-all; background: #f6f7fb; padding: 3px 7px; border-radius: 7px; }

/* progress */
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-track { flex: 1; height: 10px; background: #e9e5dc; border-radius: 99px; overflow: hidden; }
.progress-track.slim { height: 6px; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #ffcf5c); transition: width .6s var(--ease); }
.progress-number { font-weight: 700; }

/* chapter grid + lesson rows */
.chapter-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .chapter-grid { grid-template-columns: 1fr 1fr; } }
.chapter-card, .lesson-card { color: var(--text); transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .15s ease; }
.chapter-card { display: flex; flex-direction: column; gap: 6px; }
a.chapter-card:hover, .lesson-card:hover { text-decoration: none; border-color: #c9cdf5; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.chapter-card.locked { opacity: .6; }
.chapter-seq { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: .9rem; }
.status-completed .chapter-seq { background: var(--ok-bg); color: var(--ok); }
.chapter-title { font-weight: 700; font-size: 1.05rem; }
.chapter-desc { font-size: .86rem; color: var(--muted); }
.chapter-status { font-size: .78rem; color: var(--muted); text-transform: capitalize; }
.lesson-card { display: flex; gap: 14px; align-items: center; }
.lesson-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lesson-title { font-weight: 700; }
.lesson-side { width: 92px; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }

/* vocabulary + reading blocks */
.vocab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .vocab-grid { grid-template-columns: 1fr 1fr 1fr; } }
.vocab-chip { border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; display: flex; flex-direction: column; gap: 2px; }
.vocab-word { font-weight: 700; }
.audio-chip, .tts-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); cursor: pointer; vertical-align: middle; flex: 0 0 auto;
  font-family: inherit; transition: transform .12s var(--ease), background .15s ease, color .15s ease;
}
.audio-chip:hover, .tts-btn:hover { background: #dfe2fb; transform: scale(1.06); }
.audio-chip .icon, .tts-btn .icon { width: 19px; height: 19px; }
.audio-chip.is-playing, .tts-btn.is-playing { background: var(--brand); color: #fff; animation: chip-pulse 1s ease-in-out infinite; }
.teaching-note, .dialogue-context, .reading-context { margin: 1rem 0; padding: 14px 16px; border-radius: 14px; background: #f7f5ef; }
.teaching-note { background: var(--accent-soft); border-left: 4px solid var(--accent); line-height: 1.55; }
.lesson-goal { margin: 12px 0; padding: 12px 14px; border-left: 4px solid var(--brand); border-radius: 10px; background: var(--brand-soft); line-height: 1.55; }
.lesson-illustration { margin: 16px auto; max-width: 760px; }
.lesson-illustration img { display: block; width: 100%; max-height: 360px; object-fit: cover; border-radius: 16px; }
.dialogue-context h2, .reading-context h2 { margin: 0 0 .35rem; font-size: 1.05rem; }
.transcript.dialogue-transcript { font-style: normal; }
.dialogue-transcript p { margin: .45rem 0; }
.dialogue-line { margin: 8px 0 14px; }
.reading-context p, .vocab-example { line-height: 1.6; }

/* ----- activity player ----- */
.question-card { padding: 24px 22px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border-color: transparent; }
.activity-title { font-size: .78rem; margin: 0 0 4px; color: var(--brand); text-transform: uppercase; letter-spacing: .1em; font-weight: 800; }
.instruction { color: var(--muted); margin: 0 0 14px; }
.prompt { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.35; margin: 16px 0; }
.media-block { margin: 14px 0; }
.question-image { max-width: 100%; border-radius: 16px; }
.transcript { margin: 8px 0 0; font-style: italic; }
.model-line { background: var(--brand-soft); border-radius: 12px; padding: 11px 14px; }

.options { display: flex; flex-direction: column; gap: 10px; counter-reset: opt; }
.option {
  position: relative; display: flex; align-items: center; gap: 12px; counter-increment: opt;
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 16px;
  padding: 14px 16px; cursor: pointer; font-size: 1.05rem; font-weight: 500; background: #fff;
  transition: transform .12s var(--ease), border-color .15s ease, background .15s ease;
}
.option:hover { border-color: #c5c9f3; }
.option:active { transform: translateY(2px); }
.options .option input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.options .option::before {
  content: counter(opt, upper-alpha); flex: 0 0 auto; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line);
  color: var(--muted); font-size: .82rem; font-weight: 800; transition: all .15s ease;
}
.option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.options .option:has(input:checked)::before { background: var(--brand); border-color: var(--brand); color: #fff; transform: scale(1.08); }
.option:has(input:focus-visible) { outline: 3px solid rgba(66, 80, 224, .45); outline-offset: 2px; }
.option-copy, .rubric-copy { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.option-copy .translation, .rubric-copy .translation { margin-bottom: 0; font-size: .88rem; }
.lang-option input { width: 18px; height: 18px; accent-color: var(--brand); }

.feedback { position: relative; border-radius: 16px; padding: 14px 16px; margin: 16px 0 4px; font-size: 1rem; font-weight: 600; animation: rise .45s var(--ease) both; }
.feedback-correct, .feedback-done { background: var(--ok-bg); color: var(--ok); }
.feedback-retry { background: var(--warn-bg); color: var(--warn); }
.question-card.is-shaking { animation: shake .45s ease; }

/* mascot reactions */
.cheer { display: flex; align-items: flex-end; gap: 10px; margin: 18px 0 -6px; animation: rise .5s var(--ease) both; }
.cheer-mascot { width: 62px; height: 62px; flex: 0 0 auto; transform-origin: 50% 90%; }
.cheer-happy .cheer-mascot { animation: dance .7s var(--pop) 2; }
.cheer-retry .cheer-mascot { animation: wobble .7s ease 1; }
.cheer-bubble {
  position: relative; margin-bottom: 18px; padding: 9px 14px; border-radius: 16px 16px 16px 4px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: .95rem;
  animation: pop-in .4s var(--pop) .15s both;
}
.cheer-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin: 0 0 18px auto; }
.fun-chip { padding: 6px 12px; border-radius: 99px; font-size: .82rem; font-weight: 800; white-space: nowrap; animation: pop-in .45s var(--pop) .3s both; }
.fun-chip-xp { background: var(--accent-soft); color: #9a5b00; }
.fun-chip-combo { background: #ffe5df; color: #c2410c; }
.confetti-canvas { position: fixed; inset: 0; z-index: 90; pointer-events: none; }

/* word order */
.word-order { margin: 12px 0; }
.wo-answer {
  min-height: 60px; border: 2px dashed #d8d3c7; border-radius: 16px; padding: 9px;
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; background: #fbfaf7;
}
.wo-bank { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.wo-chip {
  border: 2px solid var(--line); border-bottom-width: 4px; background: #fff; border-radius: 12px; cursor: pointer;
  padding: 9px 14px; font-size: 1.05rem; font-family: inherit; font-weight: 600; color: var(--text);
  transition: transform .12s var(--ease), border-color .15s ease;
}
.wo-chip:hover { border-color: #c5c9f3; }
.wo-chip:active { transform: translateY(2px); }
.wo-chip.is-popping { animation: pop-in .3s var(--pop); }
.wo-answer .wo-chip { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

/* rubric */
.rubric { margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.rubric-line { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.rubric-line input { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); }
.done-line { margin-top: 8px; font-weight: 700; }

.option .audio-chip, .option .tts-btn { margin-left: auto; }
.translation { margin: 2px 0 10px; font-size: .95rem; font-weight: 400; color: #474c6b; }
.translation.pending { font-size: .78rem; color: var(--muted); font-style: italic; }
.translation[lang="ur"], .translation[lang="sd"], .translation[lang="ks"] { direction: rtl; text-align: right; }

/* chapter page + flashcards */
.step-badge { display: inline-block; background: var(--ink); color: #fff; border-radius: 99px; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 4px 11px; margin-right: 8px; vertical-align: middle; }
.vocab-first { border-left: 5px solid var(--accent); }
.vocab-finished { max-width: 560px; margin: 12px auto; padding: clamp(22px, 5vw, 36px); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border-color: transparent; }
.vocab-finished { text-align: center; }
.vocab-finished .btn { margin: 8px 4px 0; }
.practice-partner-note { margin-bottom: 10px; }

/* language settings */
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .lang-grid { grid-template-columns: 1fr 1fr 1fr; } }
.lang-option { padding: 11px 13px; font-size: .95rem; border-bottom-width: 2px; }

/* ----- home ----- */
.home-hero { display: grid; gap: 18px; margin: 6px 0 20px; }
.home-hero h1 { margin: 0; font-size: clamp(1.7rem, 5vw, 2.5rem); letter-spacing: -0.03em; line-height: 1.12; max-width: 520px; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat {
  display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 84px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.stat strong { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat strong small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.stat span { font-size: .72rem; color: var(--muted); font-weight: 600; }
.stat-ring { position: relative; align-items: center; padding: 8px; }
.stat-ring svg { width: 66px; height: 66px; transform: rotate(-90deg); }
.stat-ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.ring-track { stroke: #ebe7de; }
.ring-fill { stroke: var(--accent); transition: stroke-dashoffset 1.2s var(--ease); }
.stat-ring strong { position: absolute; font-size: .95rem; }
@media (max-width: 560px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 860px) { .home-hero { grid-template-columns: 1fr minmax(380px, 460px); align-items: end; } }

.next-step {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px;
  padding: 22px 24px; margin-bottom: 16px; border-radius: var(--radius-lg); background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow-md);
}
.next-step-copy { flex: 1; min-width: min(100%, 260px); }
.next-step h2 { margin: 0; font-size: 1.4rem; }
.next-step-copy > p:last-child { margin: 4px 0 0; color: var(--muted); }
.memory-boost {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  padding: 14px 20px; margin-bottom: 16px; border-radius: var(--radius); background: var(--ok-bg);
}
.memory-boost .kicker { color: var(--ok); }
.memory-boost p { margin: 0; }
.memory-boost .btn { background: #fff; }

/* the trail: a night-sky map the mascot walks through */
.trail-scene {
  position: relative; overflow: hidden; margin: 26px 0; padding: 24px 0 28px; color: #fff;
  border-radius: 28px;
  background:
    radial-gradient(ellipse 60% 22% at 80% 0%, rgba(120, 130, 255, .38), transparent),
    radial-gradient(ellipse 70% 20% at 10% 100%, rgba(255, 176, 32, .22), transparent),
    linear-gradient(180deg, #121433 0%, #1a1e52 45%, #262b78 100%);
  box-shadow: 0 24px 60px rgba(23, 26, 63, .28);
}
.trail-scene::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .9;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 8%, #fff, transparent), radial-gradient(1px 1px at 28% 22%, #cdd3ff, transparent),
    radial-gradient(1.5px 1.5px at 44% 5%, #fff, transparent), radial-gradient(1px 1px at 61% 17%, #fff, transparent),
    radial-gradient(2px 2px at 77% 9%, #ffe7a8, transparent), radial-gradient(1px 1px at 91% 26%, #fff, transparent),
    radial-gradient(1px 1px at 8% 41%, #fff, transparent), radial-gradient(1.5px 1.5px at 52% 37%, #cdd3ff, transparent),
    radial-gradient(1px 1px at 84% 47%, #fff, transparent), radial-gradient(1.5px 1.5px at 20% 63%, #ffe7a8, transparent),
    radial-gradient(1px 1px at 66% 69%, #fff, transparent), radial-gradient(1px 1px at 38% 82%, #cdd3ff, transparent),
    radial-gradient(1.5px 1.5px at 93% 77%, #fff, transparent), radial-gradient(1px 1px at 6% 91%, #fff, transparent);
  background-size: 100% 620px; animation: twinkle 5s ease-in-out infinite alternate;
}
.trail-scene-head { position: relative; display: flex; align-items: end; justify-content: space-between; gap: 12px; padding: 0 22px 6px; }
.trail-scene-head .kicker { color: var(--accent); }
.trail-scene-head h2 { margin: 0; font-size: 1.6rem; }
.scene-pill { padding: 6px 13px; border-radius: 99px; background: rgba(255, 255, 255, .12); font-size: .78rem; font-weight: 700; white-space: nowrap; }

.trail-map { position: relative; list-style: none; margin: 0; padding: 8px 18px 0; }
.trail-stop { margin: 12px 0; }
.trail-link { display: flex; align-items: center; gap: 14px; color: #fff; }
.trail-link:hover { text-decoration: none; }
.trail-node {
  position: relative; flex: 0 0 auto; display: grid; place-items: center; width: 66px; height: 66px; border-radius: 50%;
  background: #2a2f7a; border: 2px solid rgba(255, 255, 255, .22);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .25);
  transition: transform .2s var(--pop), box-shadow .2s ease;
}
.trail-node-icon { font-size: 1.65rem; line-height: 1; }
.trail-node-check {
  position: absolute; right: -4px; bottom: -4px; display: grid; place-items: center; width: 24px; height: 24px;
  border-radius: 50%; background: #16a36e; color: #fff; font-size: .78rem; font-weight: 800; border: 2px solid #1a1e52;
}
.trail-label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.trail-label-kicker { font-size: .64rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: rgba(255, 255, 255, .55); }
.trail-label-title { font-size: 1rem; line-height: 1.25; }
.trail-label-state { font-size: .76rem; color: rgba(255, 255, 255, .62); }
a.trail-link:hover .trail-node { transform: translateY(-3px) scale(1.06); }
a.trail-link:active .trail-node { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }

.state-completed .trail-node { background: linear-gradient(160deg, #ffd66b, #ffab1a); border-color: #ffe9b0; box-shadow: 0 6px 0 #b86e00, 0 0 26px rgba(255, 176, 32, .45); }
.state-in_progress .trail-node, .state-available .trail-node { background: #fff; border-color: #fff; box-shadow: 0 6px 0 #b9bfef; }
.trail-stop.is-current .trail-node { animation: beacon 2.2s ease-out infinite; }
.trail-stop.is-current .trail-label-state { color: var(--accent); font-weight: 700; }
.state-locked .trail-link { color: rgba(255, 255, 255, .5); }
.state-locked .trail-node-icon { font-size: 1.2rem; opacity: .7; }
.trail-stop.is-popping .trail-node { animation: node-pop .7s var(--pop); }

.trail-start, .trail-summit, .trail-avatar, .trail-svg { display: none; }

/* live mode: JS lays the stops out along a winding SVG path */
.trail-live .trail-map { padding: 0; margin: 0 14px; }
.trail-live .trail-svg { display: block; position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.trail-path-base { fill: none; stroke: rgba(255, 255, 255, .22); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 1 19; }
.trail-path-fill { fill: none; stroke: url(#trail-gold); stroke-width: 9; stroke-linecap: round; filter: drop-shadow(0 0 8px rgba(255, 176, 32, .7)); }
.trail-live .trail-stop { position: absolute; margin: 0; width: 0; height: 0; }
.trail-live .trail-node { position: absolute; left: -33px; top: -33px; }
.trail-live .trail-label { position: absolute; top: 0; width: var(--label-w, 180px); transform: translateY(-50%); }
.trail-live .side-left .trail-label { left: 48px; }
.trail-live .side-right .trail-label { right: 48px; text-align: right; align-items: flex-end; }
.trail-live .trail-start, .trail-live .trail-summit { display: flex; position: absolute; transform: translate(-50%, -50%); flex-direction: column; align-items: center; gap: 4px; }
.trail-start span { padding: 4px 12px; border-radius: 99px; background: #2f347f; font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.trail-summit-badge { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; font-size: 2.3rem; background: #2f347f; border: 2px dashed rgba(255, 255, 255, .35); }
.trail-summit.is-reached .trail-summit-badge { background: linear-gradient(160deg, #ffd66b, #ffab1a); border: 2px solid #ffe9b0; box-shadow: 0 0 40px rgba(255, 176, 32, .7); }
.trail-summit-label { font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: rgba(255, 255, 255, .7); }
.trail-live .trail-avatar { display: block; position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 5; pointer-events: none; will-change: transform; }
.trail-avatar-body { position: absolute; left: -29px; top: -60px; width: 58px; height: 58px; transform-origin: 50% 100%; animation: bob 1.8s ease-in-out infinite; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); }
.trail-avatar-body svg { width: 100%; height: 100%; display: block; transition: transform .2s ease; }
.trail-avatar.faces-left .trail-avatar-body svg { transform: scaleX(-1); }
.trail-avatar.is-moving .trail-avatar-body { animation: hop .34s ease-in-out infinite; }
.trail-avatar-shadow { position: absolute; left: -16px; top: -5px; width: 32px; height: 9px; border-radius: 50%; background: rgba(0, 0, 0, .35); filter: blur(2px); }
.trail-toast {
  position: absolute; z-index: 6; left: 50%; top: 0; transform: translate(-50%, -50%); padding: 10px 18px; border-radius: 99px;
  background: var(--accent); color: #2a1d00; font-weight: 800; white-space: nowrap; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  animation: toast 2.8s var(--ease) both; pointer-events: none;
}

.future-worlds { margin-top: 30px; }
.future-world-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .future-world-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.future-world { display: flex; align-items: flex-start; gap: 14px; padding: 18px; color: #fff; border-radius: 20px; box-shadow: var(--shadow-md); }
.future-world-code { flex: 0 0 auto; display: grid; place-items: center; min-width: 50px; height: 50px; border-radius: 14px; background: rgba(255, 255, 255, .18); font-weight: 800; }
.future-world-status { margin: 2px 0; font-size: .62rem; letter-spacing: .12em; font-weight: 800; opacity: .8; text-transform: uppercase; }
.future-world h3 { margin: 0 0 4px; font-size: 1.08rem; }
.future-world p:last-child { margin: 0; font-size: .84rem; opacity: .9; }
.world-violet { background: linear-gradient(135deg, #5b3fb0, #8d63d8); }
.world-amber { background: linear-gradient(135deg, #b2621b, #e09a3b); }
.world-deep { background: linear-gradient(135deg, #17485f, #2a7d92); }

.replay-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: rgba(18, 20, 51, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .25s ease both; }
.replay-dialog { width: min(100%, 500px); padding: 26px; border-radius: var(--radius-lg); background: #fff; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); animation: pop-in .4s var(--pop) both; }
.replay-dialog h2 { margin: 5px 0 8px; }
.replay-dialog > p:not(.kicker) { color: var(--muted); }
.replay-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@media (max-width: 420px) { .replay-actions { flex-direction: column-reverse; } .replay-actions .btn, .next-step .btn { width: 100%; } }

/* ----- chapter test ----- */
.test-result { max-width: 640px; margin: 5vh auto 0; padding: clamp(24px, 5vw, 42px); text-align: center; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border-color: transparent; border-top: 6px solid var(--brand); }
.test-result h1 { margin: 4px 0 8px; font-size: clamp(1.8rem, 5vw, 2.4rem); }
.test-result.test-passed { border-top-color: var(--accent); }
.test-result.test-passed .resume-kicker { color: var(--accent-deep); }
.test-result.test-failed { border-top-color: #d88945; }
.test-result.test-failed .resume-kicker { color: #a25b20; }
.test-score { display: flex; align-items: baseline; justify-content: center; gap: 7px; margin: 12px 0; color: var(--muted); }
.test-score strong { color: var(--text); font-size: 3.2rem; line-height: 1; letter-spacing: -0.03em; }
.test-result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 22px 0 12px; }
@media (max-width: 520px) { .test-result-actions { flex-direction: column; } .test-result-actions .btn { width: 100%; } }

/* tables */
.table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.table th, .table td { border-bottom: 1px solid var(--line); text-align: left; padding: 9px 10px; }
.table .num { text-align: right; }
.table-wrap { overflow-x: auto; }
.error-log { color: var(--warn); font-size: .8rem; white-space: pre-wrap; }

/* ----- motion ----- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes flip-in { from { opacity: 0; transform: rotateX(-70deg); } to { opacity: 1; transform: none; } }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes bob-centered { 0%, 100% { transform: translateX(-50%); } 50% { transform: translate(-50%, -4px); } }
@keyframes hop { 0%, 100% { transform: translateY(0) scaleY(.94); } 50% { transform: translateY(-13px) scaleY(1.04); } }
@keyframes dance { 0%, 100% { transform: rotate(0) translateY(0); } 25% { transform: rotate(-12deg) translateY(-8px); } 75% { transform: rotate(12deg) translateY(-8px); } }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes beacon { 0% { box-shadow: 0 6px 0 #b9bfef, 0 0 0 0 rgba(255, 255, 255, .55); } 100% { box-shadow: 0 6px 0 #b9bfef, 0 0 0 22px rgba(255, 255, 255, 0); } }
@keyframes node-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes twinkle { from { opacity: .55; } to { opacity: 1; } }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.7); } 12%, 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -90%) scale(.95); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .top-bar::before, .main-nav { background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

.auth-card > .muted.center { margin: 18px 0 0; }

/* ============================================================
   Learner UI polish v1 — calmer hierarchy, quieter translations,
   tidier cards. Additive & reversible (delete this block to undo).
   ============================================================ */

/* 1. Translations: quiet secondary helper line under the English */
.translation {
  font-size: .82rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.5;
  margin: 3px 0 16px;
}
.translation.pending {
  font-size: .72rem;
  color: #a9a699;
  font-style: normal;
  margin: 2px 0 14px;
}

/* ============================================================
   Practice mode — flashcards, lesson player, chapter test.
   One thing at a time (context → question → feedback), with the
   main action always within thumb reach. Without JavaScript the
   stages simply stack and everything still works.
   ============================================================ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon { width: 1.25em; height: 1.25em; flex: 0 0 auto; vertical-align: -.24em; }

/* Focus mode: the practice screen owns the viewport (no site chrome). */
.is-focus .top-bar, .is-focus .main-nav { display: none; }
.is-focus .main {
  max-width: 620px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 148px);
}
.practice { display: flex; flex-direction: column; gap: 14px; }

/* Slim header: close · progress · count */
.pr-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 8px 0 12px; background: linear-gradient(var(--bg) 80%, rgba(246, 244, 239, 0));
}
.pr-close { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -8px; border-radius: 50%; color: var(--muted); flex: 0 0 auto; transition: background .15s ease, color .15s ease; }
.pr-close:hover { background: #ebe7de; color: var(--ink); text-decoration: none; }
.pr-close .icon { width: 22px; height: 22px; }
.pr-bar { flex: 1; height: 12px; border-radius: 99px; background: #e6e1d6; overflow: hidden; }
.pr-bar span { display: block; height: 100%; min-width: 12px; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #ffcf5c); transition: width .5s var(--ease); }
.pr-segments { flex: 1; display: flex; gap: 5px; }
.pr-seg { flex: 1; height: 12px; border-radius: 99px; background: #e6e1d6; transition: background .2s ease, transform .15s ease; }
.pr-seg:hover { transform: scaleY(1.25); }
.pr-seg.is-done { background: var(--accent); }
.pr-seg.is-current { background: var(--brand); }
.pr-count { min-width: 38px; text-align: right; color: var(--muted); font-size: .82rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Stage 1 — context: listen / read / notice */
.pr-stage { display: flex; flex-direction: column; gap: 14px; animation: rise .45s var(--ease) both; }
.pr-pill {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 5px 12px 5px 9px; border-radius: 99px;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.pr-pill .icon { width: 16px; height: 16px; }
.pr-pill-light { background: var(--brand-soft); color: var(--brand); }

.pr-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 20px 20px; border-radius: 28px; text-align: center; color: #fff;
  background: radial-gradient(ellipse 70% 50% at 88% 0%, rgba(255, 176, 32, .34), transparent 60%), linear-gradient(150deg, var(--ink), var(--ink-2));
  box-shadow: 0 18px 44px rgba(23, 26, 63, .22);
}
.pr-hero-mithu { width: 84px; height: 84px; margin-top: -14px; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .25)); }
.pr-hero-title { margin: 2px 0 0; font-size: 1.5rem; }
.pr-hero-sub { margin: 2px 0 0; max-width: 34ch; color: rgba(255, 255, 255, .84); font-size: .96rem; line-height: 1.5; }
.pr-hero .translation { margin: 0; max-width: 36ch; color: rgba(255, 255, 255, .6); }
.pr-hero-hint { margin: 0; min-height: 1.3em; color: rgba(255, 255, 255, .82); font-size: .86rem; font-weight: 700; }

/* The play button: marigold disc, white progress ring */
.pr-play {
  --p: 0; position: relative; display: grid; place-items: center; width: 84px; height: 84px; margin: 18px 0 12px;
  border: 0; border-radius: 50%; cursor: pointer; background: var(--accent); color: #2a1d00;
  box-shadow: 0 6px 0 var(--accent-deep); transition: transform .12s var(--ease), box-shadow .15s ease;
}
.pr-play:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-deep); }
.pr-play > .icon { grid-area: 1 / 1; width: 38px; height: 38px; }
.pr-play > .pr-i-play { margin-left: 5px; }
.pr-i-pause { display: none; }
.is-playing > .pr-i-play, .is-playing > .pr-ref-icon > .pr-i-play { display: none; }
.is-playing > .pr-i-pause, .is-playing > .pr-ref-icon > .pr-i-pause { display: block; }
.pr-ring { position: absolute; inset: -11px; width: calc(100% + 22px); height: calc(100% + 22px); transform: rotate(-90deg); pointer-events: none; }
.pr-ring circle { fill: none; stroke-width: 4.5; }
.pr-ring-track { stroke: rgba(255, 255, 255, .18); }
.pr-ring-fill { stroke: #fff; stroke-linecap: round; stroke-dasharray: 289.03; stroke-dashoffset: calc(289.03 * (1 - var(--p))); transition: stroke-dashoffset .25s linear; }
.pr-play.is-loading { animation: chip-pulse .9s ease-in-out infinite; }
.pr-play-sm { width: 60px; height: 60px; margin: 12px 0 6px; box-shadow: 0 4px 0 var(--accent-deep); }
.pr-play-sm > .icon { width: 28px; height: 28px; }
.pr-play-sm > .pr-i-play { margin-left: 0; }
.pr-play-sm .pr-ring { inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); }

.pr-paper {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px 20px 20px; border-radius: 24px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-md);
}
.pr-paper-mithu { position: absolute; right: 12px; top: 8px; width: 66px; height: 66px; }
.pr-paper-title { margin: 8px 0 4px; padding-right: 64px; font-size: 1.35rem; }
.pr-passage p { margin: 0 0 8px; font-size: 1.08rem; line-height: 1.55; }
.pr-passage p:last-child { margin-bottom: 0; }
.pr-paper-tip { background: linear-gradient(180deg, #fff8e8, #fff 70%); border-color: #ffe3a3; }
.pr-tip-text { margin: 0; font-size: 1.08rem; font-weight: 500; line-height: 1.6; }
.pr-help { margin-top: 6px; font-size: .86rem; }
.pr-help summary { cursor: pointer; list-style: none; color: var(--brand); font-weight: 700; }
.pr-help summary::-webkit-details-marker { display: none; }
.pr-help .translation { margin: 6px 0 0; }

.pr-lead { padding: 0 4px; }
.pr-lead p { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.5; }
.pr-lead .translation { margin: 2px 0 0; font-size: .86rem; font-weight: 400; }
.pr-lead-inline { padding: 0; margin: 0 0 14px; }
.pr-lead-inline p { color: var(--muted); font-weight: 500; }
.pr-goal { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 16px; background: var(--brand-soft); color: #2a2f6b; font-size: .92rem; line-height: 1.5; }
.pr-goal > .icon { width: 22px; height: 22px; margin-top: 1px; color: var(--brand); }
.pr-goal p { margin: 0; }
.pr-goal strong { display: block; color: var(--brand); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
.pr-goal .translation { margin: 3px 0 0; font-size: .82rem; }
.pr-question .pr-goal { margin-bottom: 14px; }
.pr-goal-test { background: var(--accent-soft); color: #6b4300; }
.pr-goal-test > .icon, .pr-goal-test strong { color: #9a5b00; }

/* Stage 2 — the question */
[data-question]:focus, [data-reveal]:focus { outline: none; }
.pr-question { padding: 20px 18px 22px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow-md); animation: rise .45s var(--ease) both; }
.pr-kicker { margin: 0 0 10px; color: var(--brand); font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.pr-prompt { margin: 4px 0; font-size: clamp(1.32rem, 5.4vw, 1.6rem); line-height: 1.32; letter-spacing: -.015em; }
.pr-prompt + .translation { margin: 3px 0 0; font-size: .88rem; }
.pr-prompt .audio-chip, .pr-prompt .tts-btn { margin-left: 4px; }
.pr-blank { display: inline-block; min-width: 3.2em; margin: 0 .12em; padding: 0 .3em; border-bottom: 3px solid var(--brand); color: var(--brand); text-align: center; line-height: 1.15; }
.pr-blank:empty::before { content: "\00a0"; }
.pr-blank.is-filled { background: var(--brand-soft); border-radius: 8px 8px 0 0; animation: pop-in .25s var(--pop); }
.answer-form { margin-top: 18px; }
.pr-figure { margin: 0 0 12px; }
.pr-note { margin: 14px 0 0; }

/* Helpers beside the question: listen again, re-read, tip */
.pr-refs { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.pr-ref {
  --p: 0; position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 14px 8px 8px; border: 0; border-radius: 16px; cursor: pointer; text-align: left; font-family: inherit;
  background: var(--brand-soft); color: var(--ink); transition: box-shadow .15s ease;
}
.pr-ref::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--p) * 100%); background: var(--brand); transition: width .25s linear; }
.pr-ref.is-playing { box-shadow: inset 0 0 0 2px var(--brand); }
.pr-ref-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; background: var(--brand); color: #fff; }
.pr-ref-icon > .icon { grid-area: 1 / 1; width: 20px; height: 20px; }
.pr-ref-icon > .pr-i-play { margin-left: 2px; }
.pr-ref-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.pr-ref-text strong { font-size: .92rem; }
.pr-ref-text span { overflow: hidden; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.pr-ref-panel { border-radius: 16px; background: #f7f5ef; }
.pr-ref-panel summary { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; list-style: none; color: var(--ink); font-size: .92rem; font-weight: 700; }
.pr-ref-panel summary::-webkit-details-marker { display: none; }
.pr-ref-panel summary > .icon:first-child { color: var(--brand); }
.pr-ref-panel summary > span { flex: 1; }
.pr-chev { color: var(--muted); transition: transform .2s ease; }
.pr-ref-panel[open] .pr-chev { transform: rotate(180deg); }
.pr-ref-body, .pr-passage-compact { padding: 0 14px 12px; }
.pr-ref-body p { margin: 0 0 4px; line-height: 1.55; }
.pr-ref-body .translation { margin: 0 0 8px; }
.pr-passage-compact p { margin-bottom: 5px; font-size: 1rem; }
.pr-transcript, .pr-rubric { margin-top: 14px; }
.pr-transcript .dialogue-line { margin: 0 0 10px; }
.pr-heard { margin-top: 14px; padding: 12px 14px; border-radius: 16px; background: #f7f5ef; }
.pr-heard p { margin: 0; }
.pr-heard .translation { margin: 3px 0 0; }
.pr-label { display: flex; align-items: center; gap: 6px; margin: 0 0 3px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.pr-label .icon { width: 16px; height: 16px; color: var(--brand); }

/* Tap-to-answer pieces */
.pr-bank { display: flex; flex-wrap: wrap; gap: 10px; margin: 2px 0 14px; }
.pr-bank .wo-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand-dark); color: #fff; }
.js .pr-type-has-bank { display: none; }
.wo-clear { display: inline-flex; align-items: center; gap: 6px; }
.wo-clear .icon { width: 16px; height: 16px; }
.pr-model { margin-bottom: 14px; padding: 12px 14px; border-radius: 16px; background: var(--brand-soft); }
.pr-model-text { margin: 0; font-size: 1.08rem; font-weight: 600; line-height: 1.45; }
.pr-model .translation { margin: 3px 0 0; }
.pr-starters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pr-starters .pr-label { flex: 1 1 100%; }
.pr-starter { padding: 8px 12px; border: 1.5px dashed #c5c9f3; border-radius: 12px; background: #fff; color: var(--brand-dark); cursor: pointer; font: inherit; font-size: .95rem; text-align: left; }
.pr-starter:hover { background: var(--brand-soft); }
.rubric-copy > span { display: block; }
.pr-rubric .rubric { padding-top: 2px; }

/* Stage 3 — feedback */
.feedback { display: flex; align-items: flex-start; gap: 10px; }
.feedback-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%; background: var(--ok); color: #fff; }
.feedback-retry .feedback-icon { background: var(--warn); }
.feedback-icon .icon { width: 16px; height: 16px; }
.feedback-body { min-width: 0; }
.feedback-body p { margin: 0; }
.feedback-body .translation { margin: 3px 0 0; color: inherit; opacity: .82; }
.feedback .audio-chip, .feedback .tts-btn { width: 28px; height: 28px; background: rgba(255, 255, 255, .7); color: inherit; }
.mithu-reveal { display: flex; align-items: flex-start; gap: 12px; margin-top: 12px; padding: 14px 16px; border: 1px solid #ffe3a3; border-radius: 16px; background: #fff7e6; }
.mithu-reveal-icon { flex: 0 0 48px; width: 48px; height: 48px; }
.mithu-reveal-label { margin: 0 0 2px; color: #b7791f; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.mithu-reveal-answer { margin: 0; color: var(--ink); font-size: 1.15rem; font-weight: 700; }
.mithu-reveal .translation { margin: 2px 0 0; }

/* The action bar: always at the bottom of the screen */
.pr-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; pointer-events: none;
  padding: 22px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(rgba(246, 244, 239, 0), var(--bg) 30%);
}
.pr-actions-inner { max-width: 588px; margin: 0 auto; pointer-events: auto; }
.pr-actions-set { display: flex; flex-direction: column; gap: 6px; }
.pr-actions .btn { min-height: 54px; margin-top: 0; font-size: 1.05rem; }
.pr-actions .btn .icon { width: 20px; height: 20px; }
.pr-actions .btn[disabled] { background: #dcd8cd; color: #98948a; box-shadow: 0 4px 0 #c9c4b7; cursor: not-allowed; }
.pr-skip { align-self: center; padding: 6px 10px; border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: .86rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.pr-actions-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 2px; color: var(--ok); font-size: .84rem; font-weight: 800; }
.fc-rating { flex-direction: row; gap: 10px; }
.fc-rating .btn { flex: 1; }

/* Which stage is showing (JavaScript only; otherwise everything is visible) */
.js .practice[data-stage="context"] [data-question],
.js .practice[data-stage="context"] [data-actions="question"],
.js .practice[data-stage="question"] [data-gate],
.js .practice[data-stage="question"] [data-actions="context"],
.js .practice[data-stage="front"] [data-reveal],
.js .practice[data-stage="front"] [data-actions="rate"],
.js .practice[data-stage="revealed"] [data-actions="reveal"],
.js .practice[data-stage="revealed"] [data-front-only] { display: none; }
html:not(.js) [data-actions="context"],
html:not(.js) [data-actions="reveal"],
html:not(.js) [data-front-only],
html:not(.js) .pr-refs .pr-ref-primary { display: none; }
html:not(.js) .pr-actions { position: static; padding: 0; background: none; }

/* Flashcards */
.fc { display: flex; flex-direction: column; gap: 12px; }
.fc .pr-kicker { margin: 0 4px; }
.fc-front {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: min(44vh, 360px);
  padding: 22px 18px 24px; border-radius: 28px; text-align: center; color: #fff;
  background: radial-gradient(ellipse at 86% 0%, rgba(255, 176, 32, .34), transparent 55%), linear-gradient(150deg, var(--ink), var(--ink-2));
  box-shadow: 0 18px 44px rgba(23, 26, 63, .22); animation: flip-in .5s var(--ease) both;
}
.fc-image { width: min(100%, 340px); aspect-ratio: 16 / 10; object-fit: cover; border: 2px solid rgba(255, 255, 255, .22); border-radius: 18px; }
.fc-word { margin: 6px 0 0; font-size: clamp(2.3rem, 10vw, 3.3rem); line-height: 1.05; letter-spacing: -.03em; overflow-wrap: anywhere; }
.fc-pos { padding: 3px 12px; border-radius: 99px; background: rgba(255, 255, 255, .14); color: rgba(255, 255, 255, .86); font-size: .78rem; font-weight: 700; }
.fc-front .tts-btn { width: 52px; height: 52px; margin-top: 10px; background: var(--accent); color: #2a1d00; }
.fc-front .tts-btn .icon { width: 26px; height: 26px; }
.fc-prompt { margin: 2px 8px 0; color: var(--muted); font-size: .92rem; text-align: center; }
.fc-back { scroll-margin-bottom: 140px; display: flex; flex-direction: column; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 24px; background: var(--card); box-shadow: var(--shadow-sm); animation: rise .4s var(--ease) both; }
.fc-native { margin: 0; color: var(--brand); font-size: 1.6rem; font-weight: 700; line-height: 1.3; text-align: center; }
.fc-row { display: flex; flex-direction: column; }
.fc-text { margin: 0; font-size: 1.05rem; line-height: 1.5; }
.fc-example { font-weight: 600; }
.fc-row .translation { margin: 3px 0 0; }
.practice[data-stage="revealed"] .fc-front { min-height: 0; padding: 16px 18px 18px; }
.practice[data-stage="revealed"] .fc-image { width: auto; max-width: 100%; max-height: 120px; }
.vocab-finished-mithu, .test-result-mithu { display: block; width: 88px; height: 88px; margin: 0 auto 6px; animation: dance .7s var(--pop) 2; transform-origin: 50% 90%; }
.vocab-finished .btn-block { margin: 10px 0 0; }

/* Trail icons */
.trail-node-icon { display: grid; place-items: center; }
.trail-node-icon .icon { width: 36px; height: 36px; }
.state-locked .trail-node-icon .icon { width: 24px; height: 24px; color: rgba(255, 255, 255, .5); }
.trail-node-check .icon { width: 14px; height: 14px; }
.trail-summit-badge .icon { width: 40px; height: 40px; color: rgba(255, 255, 255, .7); }
.trail-summit.is-reached .trail-summit-badge .icon { color: #7a4a00; }
.fun-chip .icon { width: 15px; height: 15px; vertical-align: -.18em; }
.page-title .icon { width: 1.1em; height: 1.1em; color: var(--brand); }

@keyframes chip-pulse { 50% { transform: scale(1.08); } }

/* ---------- Android app: the card on the trail page and the download page ---------- */
.app-promo {
  position: relative; display: flex; align-items: center; gap: 14px; margin: 0 0 16px;
  padding: 14px 46px 14px 14px; border-radius: var(--radius); color: #fff;
  background: linear-gradient(120deg, var(--ink) 0%, var(--ink-2) 100%); box-shadow: var(--shadow-sm);
}
.app-promo img { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 14px; }
.app-promo-copy { flex: 1; min-width: 0; }
.app-promo-copy strong { display: block; font-size: 1.02rem; }
.app-promo-copy span { display: block; font-size: .88rem; opacity: .85; }
.app-promo .btn { flex: 0 0 auto; padding: 10px 16px; font-size: .92rem; }
.app-promo-close {
  position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: transparent; color: #fff; opacity: .7; font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.app-promo-close:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.app-promo.is-min { padding: 8px 8px 8px 14px; background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.app-promo.is-min img, .app-promo.is-min .app-promo-copy span, .app-promo.is-min .app-promo-close { display: none; }
.app-promo.is-min .app-promo-copy strong { font-size: .92rem; }
.app-promo.is-min .btn { padding: 7px 12px; font-size: .84rem; box-shadow: none; }
@media (max-width: 480px) {
  .app-promo:not(.is-min) { flex-wrap: wrap; }
  .app-promo:not(.is-min) .app-promo-copy { flex: 1 1 60%; }
  .app-promo:not(.is-min) .btn { width: 100%; }
}

.store { max-width: 720px; }
.store-head { display: flex; gap: 18px; align-items: center; margin: 6px 0 18px; }
.store-icon { flex: 0 0 auto; width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow-sm); }
.store-head h1 { margin: 0; font-size: 1.7rem; }
.store-maker { margin: 2px 0 0; color: var(--brand); font-weight: 700; }
.store-tag { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.store-facts { display: flex; margin: 0 0 18px; padding: 0; list-style: none; text-align: center; }
.store-facts li { flex: 1; min-width: 0; padding: 0 6px; border-left: 1px solid var(--line); }
.store-facts li:first-child { border-left: 0; }
.store-facts strong { display: block; font-size: .98rem; }
.store-facts span { font-size: .8rem; color: var(--muted); }
.store-get { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.store-get .btn { width: 100%; padding: 15px 22px; font-size: 1.06rem; }
.store-hint { margin: 0; font-size: .88rem; color: var(--muted); text-align: center; }
.store h2 { font-size: 1.15rem; margin: 0 0 8px; }
.store-list { margin: 0 0 10px; padding-left: 20px; }
.store-list li { margin: 6px 0; }
.store-steps { margin: 0; padding: 0; list-style: none; counter-reset: store-step; }
.store-steps li { position: relative; padding: 4px 0 12px 44px; counter-increment: store-step; }
.store-steps li::before {
  content: counter(store-step); position: absolute; left: 0; top: 2px; width: 30px; height: 30px;
  border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 800;
  display: grid; place-items: center;
}
.store-sha { font-family: ui-monospace, Consolas, monospace; font-size: .78rem; word-break: break-all; color: var(--muted); }
@media (max-width: 480px) {
  .store-icon { width: 76px; height: 76px; border-radius: 18px; }
  .store-head h1 { font-size: 1.45rem; }
  .store-facts strong { font-size: .86rem; }
}

/* ----- right-to-left pages (Arabic, Urdu): login, WhatsApp number, app page, settings ----- */
[dir="rtl"] .table th, [dir="rtl"] .table td { text-align: right; }
[dir="rtl"] .field input[type="tel"], [dir="rtl"] .field input[type="email"], [dir="rtl"] .store-sha { direction: ltr; text-align: left; }
[dir="rtl"] .field input[type="tel"]::placeholder { text-align: left; }
