/* ──────────────────────────────────────────────────────────────
   WebApp/style.css
   Arabic.app — web edition. Vanilla CSS, no framework, no build.
   Two themes via [data-theme="dark|light"]. All tokens live at :root.
   ────────────────────────────────────────────────────────────── */

:root {
  /* Brand tokens (consistent across themes) */
  --green:        #005430;
  --green-deep:   #003d22;
  --gold:         #C9A227;
  --gold-light:   #E2BF4A;
  --teal-light:   #0D9488;
  --teal-dark:    #14B8A6;
  --warn:         #F59E0B;
  --bad:          #DC2626;

  /* CTA text */
  --on-gold:      #1E293B;
  --on-green:     #FFFFFF;

  /* Shape */
  --radius-sm:    8px;
  --radius:       14px;
  --radius-lg:    22px;
  --shadow-sm:    0 1px 3px rgba(15,23,42,0.08);
  --shadow:       0 6px 18px rgba(15,23,42,0.12);
  --shadow-lg:    0 16px 42px rgba(15,23,42,0.22);

  /* Type */
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Amiri", "SF Arabic", "Geeza Pro", "Noto Naskh Arabic",
             "Traditional Arabic", "Times New Roman", serif;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Animation */
  --ease: cubic-bezier(.2,.7,.2,1);
}

[data-theme="dark"] {
  --bg:          #0F172A;
  --bg-mid:      #131c30;
  --card:        #1E293B;
  --card-hi:     #334155;
  --line:        rgba(255,255,255,0.10);
  --line-strong: rgba(255,255,255,0.16);
  --ink:         #F8FAFC;
  --ink-2:       #CBD5E1;
  --ink-3:       #64748B;
  --teal:        var(--teal-dark);

  /* iʿrāb colour law — deliberately OUTSIDE the standard tajwīd-muṣḥaf palette
     (so learners coming from coloured tajwīd Qurans don't confuse them).
     Pill-style highlights on the final letter. */
  --iraab-rafa-ink:  #5EEAD4;
  --iraab-rafa-bg:   rgba(94,234,212,0.18);
  --iraab-nasb-ink:  #FBBF24;
  --iraab-nasb-bg:   rgba(251,191,36,0.20);
  --iraab-jarr-ink:  #A78BFA;
  --iraab-jarr-bg:   rgba(167,139,250,0.20);
  --iraab-jazm-ink:  #F472B6;
  --iraab-jazm-bg:   rgba(244,114,182,0.20);
}

[data-theme="light"] {
  --bg:          #F8FAF9;
  --bg-mid:      #F0F7F4;
  --card:        #FFFFFF;
  --card-hi:     #F0F7F4;
  --line:        #D5DEE6;
  --line-strong: #CBD5E1;
  --ink:         #1E293B;
  --ink-2:       #475569;
  --ink-3:       #94A3B8;
  --teal:        var(--teal-light);

  --iraab-rafa-ink:  #0F766E;
  --iraab-rafa-bg:   rgba(15,118,110,0.12);
  --iraab-nasb-ink:  #B45309;
  --iraab-nasb-bg:   rgba(180,83,9,0.12);
  --iraab-jarr-ink:  #6D28D9;
  --iraab-jarr-bg:   rgba(109,40,217,0.12);
  --iraab-jazm-ink:  #BE185D;
  --iraab-jazm-bg:   rgba(190,24,93,0.12);
}

/* ─── Reset / base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; padding: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 16px; line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}

main { flex: 1; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

h1, h2, h3 { line-height: 1.18; letter-spacing: -0.01em; margin: 0 0 8px; }
h1 { font-size: clamp(28px, 4.4vw, 40px); font-weight: 800; }
h2 { font-size: clamp(22px, 3vw, 30px); font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
p  { margin: 0 0 12px; color: var(--ink-2); }

/* RTL — set on <html> when language is Arabic/Urdu */
html[dir="rtl"] body { font-family: var(--font-ar); }
html[dir="rtl"] .back-btn svg { transform: scaleX(-1); }

/* ─── Nav ──────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 800; font-size: 18px;
  color: var(--green); letter-spacing: -0.01em;
}
[data-theme="dark"] .brand { color: var(--teal); }
.brand .dot { color: var(--gold); }
.brand:hover { text-decoration: none; }
.nav-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-2);
  cursor: pointer;
  transition: transform .12s var(--ease), background-color .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { color: var(--ink); background: var(--card-hi); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }

/* Theme-toggle: show sun in dark mode, moon in light mode */
.ico-sun, .ico-moon { display: none; }
[data-theme="dark"]  .ico-sun  { display: block; }
[data-theme="light"] .ico-moon { display: block; }

.store-link {
  padding: 8px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--ink-2); font-weight: 600; font-size: 13px;
}
.store-link:hover { background: var(--card-hi); color: var(--ink); text-decoration: none; }

/* Profile chip in nav */
.profile-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--ink-2); cursor: pointer;
  font-weight: 600; font-size: 13px;
  max-width: 180px;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.profile-chip:hover { background: var(--card-hi); color: var(--ink); }
.profile-chip .emoji {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--card-hi);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
}
.profile-chip .name {
  max-width: 110px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Hide profile-chip text on tight screens */
@media (max-width: 560px) {
  .profile-chip { padding: 5px; }
  .profile-chip .name { display: none; }
}

/* ─── Loader ───────────────────────────────────────────────── */
.loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; min-height: 50dvh;
  color: var(--ink-3);
}
.loader[hidden] { display: none; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Layout helpers ───────────────────────────────────────── */
.wrap { max-width: 920px; margin: 0 auto; padding: 24px 20px 80px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-row { display: flex; align-items: center; gap: 16px; }

/* ─── Progress card (top of menu) ──────────────────────────── */
.progress-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.streak-pill {
  padding: 5px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
  font-weight: 700; font-size: 13px;
}
.bar {
  position: relative; height: 32px; border-radius: 16px;
  background: var(--card-hi);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--green) 0%, var(--gold) 100%);
  border-radius: 16px;
  transition: width .6s var(--ease);
}
.bar-label {
  position: relative; font-weight: 700; font-size: 14px;
  color: var(--on-green); text-shadow: 0 1px 2px rgba(0,0,0,.25);
  z-index: 1;
}
[data-theme="light"] .bar-label { color: var(--ink); text-shadow: none; }
.stats-row {
  margin-top: 18px;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
  text-align: center;
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-val { font-weight: 800; font-size: 22px; color: var(--ink); }
.stat-lbl { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* ─── Continue-learning card ───────────────────────────────── */
.continue-card { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; }
.continue-text small {
  display: block; color: var(--ink-3); font-size: 13px; margin-bottom: 4px;
}
.continue-text h2 { margin: 0 0 6px; font-size: 22px; }
.continue-text .pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 18%, transparent);
  color: var(--teal); font-size: 12px; font-weight: 700;
}
.glyph-bubble {
  width: 78px; height: 78px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--green) 18%, transparent);
  border: 2px solid color-mix(in srgb, var(--green) 35%, transparent);
  font-family: var(--font-ar);
  font-size: 34px;
}

/* ─── Big gold CTA button ──────────────────────────────────── */
.btn-cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px 22px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: var(--on-gold);
  border: 0; border-radius: 999px;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--gold) 35%, transparent);
  transition: transform .12s var(--ease), filter .15s var(--ease);
}
.btn-cta:hover { filter: brightness(1.05); }
.btn-cta:active { transform: scale(.98); }
.btn-cta:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--ink); padding: 12px 18px; border-radius: 999px;
  font-weight: 600; cursor: pointer;
}
.btn-ghost:hover { background: var(--card-hi); }

.btn-danger {
  background: color-mix(in srgb, var(--bad) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
  color: var(--bad); padding: 12px 18px; border-radius: 999px;
  font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 25%, transparent); }

/* ─── Section list (lessons grouped) ───────────────────────── */
.section { margin-top: 18px; }
.section-head {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 18px; border: 1px solid var(--line);
  background: var(--card); border-radius: var(--radius);
  cursor: pointer; color: var(--ink);
  transition: background-color .15s var(--ease);
}
.section-head:hover { background: var(--card-hi); }
.section-head .ico {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--green) 18%, transparent);
  color: var(--green);
  font-size: 18px;
}
[data-theme="dark"] .section-head .ico { color: var(--teal); background: color-mix(in srgb, var(--teal) 18%, transparent); }
.section-head .meta { display: flex; flex-direction: column; gap: 2px; flex: 1; text-align: start; }
.section-head .meta strong { font-weight: 700; }
.section-head .meta small { color: var(--ink-3); font-size: 12px; }
.section-head .chev {
  width: 16px; height: 16px; color: var(--ink-3);
  transition: transform .2s var(--ease);
}
.section.open .section-head .chev { transform: rotate(180deg); }
.section-body { display: none; padding: 6px 10px 0; }
.section.open .section-body { display: block; }
.lesson-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 14px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--ink);
  margin-top: 6px;
  transition: background-color .15s var(--ease);
}
.lesson-row:hover:not(:disabled) { background: var(--card-hi); }
.lesson-row:disabled { opacity: .5; cursor: not-allowed; }
.lesson-row .glyph {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--green) 18%, transparent);
  font-family: var(--font-ar); font-size: 18px;
}
.lesson-row.locked .glyph { background: var(--card-hi); }
.lesson-row .titles { flex: 1; display: flex; flex-direction: column; gap: 2px; text-align: start; }
.lesson-row .titles strong { font-weight: 600; }
.lesson-row .titles small { color: var(--ink-3); font-size: 12px; }
.lesson-row .stars { display: inline-flex; gap: 2px; color: var(--gold); }
.lesson-row .stars.empty { color: var(--ink-3); opacity: .5; }

/* ─── Lesson detail view ───────────────────────────────────── */
.lesson-header {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  padding: 22px; border: 1px solid var(--line); background: var(--card);
  border-radius: var(--radius-lg);
}
.lesson-header .pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 18%, transparent);
  color: var(--teal); font-size: 12px; font-weight: 700;
}
.lesson-header .glyph-bubble { width: 64px; height: 64px; font-size: 28px; }
.lesson-header .stats-row { margin-top: 14px; }

.tutorial {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 18px; margin-top: 14px;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
  background: color-mix(in srgb, var(--gold) 8%, transparent);
  border-radius: var(--radius);
}
.tutorial .bulb { color: var(--gold); font-size: 18px; }
.tutorial p { color: var(--ink-2); margin: 0; }

.items-grid {
  margin-top: 18px;
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.item-tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; min-height: 86px;
  text-align: center; color: var(--ink);
  transition: transform .12s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease);
}
.item-tile:hover { transform: translateY(-1px); background: var(--card-hi); border-color: var(--line-strong); }
.item-tile.playing { border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
.item-tile.selected { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, transparent); }
.item-tile .arabic { font-family: var(--font-ar); font-size: 28px; line-height: 1.1; }
.item-tile .sub    { font-size: 12px; color: var(--ink-3); }

/* For long-text lessons (sentences, suras, words) — bigger tiles, full width */
.items-grid.long { grid-template-columns: 1fr; }
.items-grid.long .item-tile {
  flex-direction: row; align-items: center; text-align: start;
  gap: 14px; padding: 14px 18px;
}
.items-grid.long .item-tile .arabic { font-size: 22px; flex: 1; direction: rtl; text-align: right; }
.items-grid.long .item-tile .sub { font-size: 13px; }

/* ─── L14 joined-letters: 4 positional sections ────────────── */
.forms-block { margin-top: 18px; }
.forms-head {
  font-size: 14px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 4px; margin-top: 14px;
}
.forms-block .items-grid:first-of-type { margin-top: 6px; }

/* ─── L18 special cases — sticky explanation panel ─────────── */
.explain-card {
  margin-top: 18px;
  padding: 18px 20px;
  background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  display: flex; gap: 18px; align-items: flex-start;
}
html[dir="rtl"] .explain-card { border-left: none; border-right: 4px solid var(--teal); }
.explain-card .glyph-big {
  flex: 0 0 auto;
  font-family: var(--font-ar); font-size: 42px;
  width: 70px; height: 70px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  color: var(--ink); border-radius: var(--radius-sm);
  direction: rtl;
}
.explain-card .body { flex: 1; }
.explain-card .body h3 { margin: 0 0 4px; font-size: 16px; }
.explain-card .body .translit {
  color: var(--teal); font-size: 13px; font-weight: 600;
  margin-bottom: 8px;
}
.explain-card .body p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; }

/* ─── L19 sun/moon comparison ─────────────────────────────── */
.sunmoon {
  margin-top: 18px;
  display: grid; gap: 14px;
  grid-template-columns: 1fr 1fr;
}
.sunmoon-col {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.sunmoon-col h3 {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px;
  font-size: 15px;
}
.sunmoon-col.sun  h3 { color: var(--warn); }
.sunmoon-col.moon h3 { color: var(--teal); }
.sunmoon-col .items-grid { margin-top: 0; grid-template-columns: 1fr; }
.sunmoon-col .item-tile {
  flex-direction: row; align-items: center; text-align: start;
  gap: 12px; padding: 10px 12px; min-height: 60px;
}
.sunmoon-col .item-tile .arabic { font-size: 22px; direction: rtl; }
.sunmoon-col .item-tile .sub { font-size: 11px; }
@media (max-width: 700px) {
  .sunmoon { grid-template-columns: 1fr; }
}

/* ─── Quiz view ────────────────────────────────────────────── */
.quiz-shell { display: flex; flex-direction: column; gap: 18px; min-height: 60dvh; }
.quiz-progress {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--ink-3); margin-bottom: 6px;
}
.quiz-bar {
  height: 6px; background: var(--card-hi); border-radius: 999px; overflow: hidden;
}
.quiz-bar > div {
  height: 100%; background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width .35s var(--ease);
}
.quiz-prompt {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 28px 22px;
  text-align: center;
}
.quiz-prompt .lead { color: var(--ink-3); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.quiz-prompt .glyph {
  font-family: var(--font-ar); font-size: clamp(64px, 11vw, 96px);
  line-height: 1;
}
.quiz-prompt .audio-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  color: var(--on-green); border: 0;
  cursor: pointer;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--green) 50%, transparent);
}
.quiz-prompt .audio-btn svg { width: 32px; height: 32px; }

.quiz-options {
  display: grid; gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
.quiz-opt {
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 18px 16px;
  cursor: pointer; color: var(--ink);
  text-align: center; min-height: 80px;
  font-family: var(--font-ar); font-size: 28px; line-height: 1.1;
  transition: transform .12s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease);
}
.quiz-opt .sub {
  display: block;
  font-family: var(--font-ui); font-size: 12px; color: var(--ink-3);
  margin-top: 4px;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--line-strong); background: var(--card-hi); }
.quiz-opt.correct {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 18%, transparent);
}
.quiz-opt.wrong {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 18%, transparent);
}
.quiz-opt:disabled { cursor: default; }

/* For lessons with long-text answers (sentences, suras), stack opts */
.quiz-options.long { grid-template-columns: 1fr; }
.quiz-options.long .quiz-opt { font-size: 20px; direction: rtl; }

/* ─── Result view ──────────────────────────────────────────── */
.result {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 36px 22px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
}
.result.passed .score-ring { background: conic-gradient(var(--green) calc(var(--pct) * 1%), var(--card-hi) 0); }
.result.failed .score-ring { background: conic-gradient(var(--bad) calc(var(--pct) * 1%), var(--card-hi) 0); }
.score-ring {
  width: 160px; height: 160px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  --pct: 0;
}
.score-inner {
  width: 130px; height: 130px; border-radius: 50%;
  background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-inner b { font-size: 38px; font-weight: 800; color: var(--ink); }
.score-inner small { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.result-stars {
  display: inline-flex; gap: 6px; color: var(--gold);
  font-size: 28px;
}
.result-stars .empty { color: var(--ink-3); opacity: .35; }
.result h2 { margin: 0; }
.result-msg { color: var(--ink-2); max-width: 36ch; }
.result-actions { display: flex; gap: 10px; width: 100%; flex-wrap: wrap; }
.result-actions > * { flex: 1; min-width: 140px; }

/* Missed-items review on result screen */
.missed-card {
  margin-top: 18px;
  padding: 22px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.missed-card h3 {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 6px;
  color: var(--bad); font-size: 17px;
}
.missed-card > p { color: var(--ink-3); font-size: 13px; margin: 0 0 14px; }
.missed-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

/* ─── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadein .15s var(--ease);
}
.modal-overlay[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 460px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: pop .18s var(--ease);
}
@keyframes pop {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal h2 { margin: 0 0 6px; }
.modal-sub { color: var(--ink-3); font-size: 14px; margin-bottom: 18px; }
.modal-list { display: flex; flex-direction: column; gap: 8px; max-height: 50dvh; overflow-y: auto; }
.modal-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent; cursor: pointer; color: var(--ink);
  width: 100%; text-align: start;
  transition: background-color .12s var(--ease), border-color .12s var(--ease);
}
.modal-item:hover { background: var(--card-hi); border-color: var(--line-strong); }
.modal-item.active { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 10%, transparent); }
.modal-item .emoji {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card-hi);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
}
.modal-item .name { flex: 1; font-weight: 600; }
.modal-item .check { color: var(--teal); font-size: 18px; opacity: 0; }
.modal-item.active .check { opacity: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions > * { flex: 1; min-width: 120px; }

.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form label { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.modal-form input[type=text] {
  font: inherit; padding: 12px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-mid); color: var(--ink);
}
.modal-form input[type=text]:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: transparent; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-picker button {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid transparent; background: var(--card-hi); cursor: pointer;
  font-size: 22px; line-height: 1;
}
.emoji-picker button.active { border-color: var(--teal); }
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-picker button {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.05);
}
.color-picker button.active { border-color: var(--ink); }

/* ─── Settings view ────────────────────────────────────────── */
.settings-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 18px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer; color: var(--ink);
  text-align: start;
  margin-bottom: 10px;
  transition: background-color .12s var(--ease);
}
.settings-row:hover:not(:disabled) { background: var(--card-hi); }
.settings-row .ico {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  color: var(--teal); font-size: 18px;
}
.settings-row .titles { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.settings-row .titles strong { font-weight: 600; }
.settings-row .titles small { color: var(--ink-3); font-size: 12px; }
.settings-row .val {
  color: var(--ink-3); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}

/* ─── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 80;
  max-width: 90vw;
  display: flex; align-items: center; gap: 10px;
}
.toast .emoji { font-size: 22px; }
.toast strong { color: var(--ink); font-weight: 700; }
.toast small  { color: var(--ink-3); display: block; }
.toast[data-visible="false"] { opacity: 0; transform: translate(-50%, 10px); transition: opacity .25s, transform .25s; pointer-events: none; }
.toast[data-visible="true"]  { opacity: 1; transform: translate(-50%, 0);    transition: opacity .25s, transform .25s; }
.toast[hidden] { display: none; }

/* ─── Back button ──────────────────────────────────────────── */
.back-btn[hidden] { display: none; }

/* ─── Footer ───────────────────────────────────────────────── */
.foot {
  padding: 22px 20px; text-align: center;
  border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 13px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.foot a { color: var(--ink-2); }

/* ═══════════════════════════════════════════════════════════════════
   UNDERSTANDING TRACK (Phase 2 — Quran-native curriculum)
   ═══════════════════════════════════════════════════════════════════ */

/* Track tabs at top of menu */
.track-tabs {
  display: flex; gap: 8px; margin: 0 0 18px;
  padding: 5px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
}
.track-tab {
  flex: 1; padding: 10px 14px; border-radius: 10px;
  border: none; cursor: pointer; font-weight: 600; font-size: 14px;
  background: transparent; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.track-tab:hover { background: var(--card-hi); color: var(--ink); }
.track-tab[data-active="true"] {
  background: var(--green); color: var(--on-green);
}
[data-theme="light"] .track-tab[data-active="true"] { background: var(--green); }

/* ─── Quick Reference (Dictionary + Tables) ────────────────────── */
.ref-wrap {
  max-width: 920px; margin: 0 auto;
  padding: 18px 20px 40px;
  display: flex; flex-direction: column; gap: 18px;
}

.intro-ref-btn {
  margin-top: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.18); color: var(--on-green);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 10px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px; cursor: pointer; font-family: inherit;
  transition: background-color .15s var(--ease);
}
.intro-ref-btn:hover { background: rgba(255,255,255,0.28); }
.intro-ref-btn .ico { font-size: 16px; }

.ref-header {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 22px 26px;
}
.ref-header h2 { margin: 0 0 6px; font-size: 24px; color: var(--ink); letter-spacing: -0.01em; }
.ref-header p  { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; }

.ref-tabs {
  display: flex; gap: 6px; padding: 4px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ref-tab {
  flex: 1; padding: 12px 14px; border-radius: 10px;
  border: none; cursor: pointer; font-weight: 600; font-size: 14.5px;
  background: transparent; color: var(--ink-2); font-family: inherit;
  transition: background-color .15s var(--ease);
}
.ref-tab:hover { background: var(--card-hi); color: var(--ink); }
.ref-tab[data-active="true"] { background: var(--green); color: var(--on-green); }

.ref-body { display: flex; flex-direction: column; gap: 18px; }

.ref-empty {
  text-align: center; color: var(--ink-3); padding: 32px 16px;
  font-style: italic;
}

/* Dictionary list */
.ref-list-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.ref-count {
  font-size: 13px; font-weight: 700; color: var(--ink-3);
  padding: 6px 12px; border-radius: 999px;
  background: var(--card-hi);
}
.ref-search {
  flex: 1; min-width: 200px;
  padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 14px; font-family: inherit;
}
.ref-search:focus { outline: none; border-color: var(--teal); }

.ref-dict {
  display: grid; gap: 8px;
}
.ref-dict-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.2fr) 3fr auto;
  align-items: center; gap: 16px;
  padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.ref-dict-row[data-curated="true"] {
  border-left: 3px solid var(--teal);
}
.ref-dict-row .rd-ar {
  font-family: var(--font-ar); font-size: 26px;
  color: var(--ink); direction: rtl; text-align: right; line-height: 1.4;
}
.ref-dict-row .rd-meta {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.ref-dict-row .rd-gloss {
  font-size: 14.5px; color: var(--ink); font-weight: 500;
}
.ref-dict-row .rd-chips {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.ref-dict-row .rd-chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg-mid); color: var(--ink-3);
}
.ref-dict-row .rd-chip-root {
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  color: var(--teal); font-family: var(--font-ar); font-size: 13px;
  text-transform: none; letter-spacing: 0;
}
.ref-dict-row .rd-derived {
  font-size: 12px; color: var(--ink-3); line-height: 1.5;
  font-style: italic;
}
.ref-dict-row .rd-example {
  font-size: 12.5px; color: var(--ink-2);
  padding-top: 4px; border-top: 1px dashed var(--line);
}
.ref-dict-row .rd-ex-ar {
  font-family: var(--font-ar); font-size: 16px; direction: rtl;
  color: var(--ink);
}
.ref-dict-row .rd-ex-ref { color: var(--ink-3); font-size: 11px; }
.ref-dict-row .rd-from {
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line));
  padding: 6px 10px; border-radius: 999px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  align-self: flex-start;
}
.ref-dict-row .rd-from:hover { background: color-mix(in srgb, var(--teal) 22%, transparent); }

@media (max-width: 600px) {
  .ref-dict-row { grid-template-columns: 1fr; gap: 8px; }
  .ref-dict-row .rd-ar { text-align: right; }
  .ref-dict-row .rd-from { justify-self: start; }
}

/* Tables — categories */
.ref-cat-title {
  margin: 14px 0 8px; font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--ink-3);
}

.ref-table-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 22px 24px;
  margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.ref-table-card[data-locked="true"] { opacity: 0.6; }

.ref-table-card .rt-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.ref-table-card .rt-head h4 {
  margin: 0; font-size: 18px; color: var(--ink); font-weight: 700;
  letter-spacing: -0.01em;
}
.ref-table-card .rt-head p {
  margin: 4px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.5;
}
.ref-table-card .rt-from {
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--ink-2); background: var(--card-hi); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  flex-shrink: 0;
}
.ref-table-card .rt-from:hover { color: var(--ink); border-color: var(--line-strong); }
.ref-table-card .rt-lock {
  font-size: 12px; color: var(--ink-3); white-space: nowrap; flex-shrink: 0;
}
.ref-table-card .rt-note {
  margin: 0; padding-top: 10px;
  font-size: 13px; color: var(--ink-3); font-style: italic;
  border-top: 1px dashed var(--line); line-height: 1.5;
}

/* Reference table cells — slimmer than the lesson stepper's */
.ref-table.step-table .step-table-row .cell {
  padding: 10px 8px; min-height: 56px;
}
.ref-table.step-table .step-table-row .cell .word {
  font-size: 22px;
}
.ref-table.step-table .step-table-row .cell .label {
  font-family: var(--font-display);
  font-size: 14px; color: var(--ink); font-weight: 600;
  text-align: center; line-height: 1.3;
}

@media (max-width: 600px) {
  .ref-wrap { padding: 12px 14px 32px; }
  .ref-table-card { padding: 18px 16px; }
  .ref-dict-row { grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; }
  .ref-dict-row .rd-gloss { grid-column: 1 / -1; font-size: 13px; }
  .ref-dict-row .rd-ar { font-size: 22px; }
  .ref-table.step-table .step-table-row .cell .word { font-size: 18px; }
  .ref-table.step-table .step-table-row .cell .label { font-size: 12px; }
}

@media (min-width: 900px) {
  .ref-table.step-table .step-table-row .cell { padding: 14px 10px; min-height: 64px; }
  .ref-table.step-table .step-table-row .cell .word { font-size: 26px; }
  .ref-table.step-table .step-table-row .cell .label { font-size: 15px; }
}

/* ─── Quran-readable progress meter ────────────────────────────── */
.quran-meter {
  background: linear-gradient(135deg, var(--green) 0%, var(--teal-light) 100%);
  color: var(--on-green);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin: 0 0 18px;
  box-shadow: var(--shadow);
}
.quran-meter .qm-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
}
.quran-meter .qm-label {
  font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; opacity: 0.85;
}
.quran-meter .qm-pct {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.quran-meter .qm-bar {
  height: 8px; border-radius: 999px;
  background: rgba(255,255,255,0.18);
  overflow: hidden;
}
.quran-meter .qm-fill {
  height: 100%; background: var(--gold);
  border-radius: 999px;
  transition: width 0.6s var(--ease);
  min-width: 4px;
}
.quran-meter .qm-detail {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; opacity: 0.85; flex-wrap: wrap;
}
.quran-meter .qm-detail .qm-dot { opacity: 0.5; }
.quran-meter .qm-hint {
  margin-top: 8px; font-size: 12px; opacity: 0.75; font-style: italic;
}

.preview-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; margin: 0 0 18px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--gold) 14%, var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 50%, var(--line));
  border-left: 4px solid var(--gold);
}
.preview-banner .pb-icon { font-size: 18px; }
.preview-banner .pb-label {
  flex: 1; font-size: 14px; color: var(--ink); font-weight: 600;
}
.preview-banner .pb-toggle {
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--ink-2); padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.preview-banner .pb-toggle:hover { border-color: var(--gold); color: var(--ink); }

/* Understanding menu structure */
.understanding-intro {
  background: linear-gradient(135deg, var(--green) 0%, color-mix(in srgb, var(--green) 55%, var(--teal)) 100%);
  color: #FFFFFF; border-radius: var(--radius-lg);
  padding: 22px 24px; margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.understanding-intro h2 {
  margin: 0 0 8px; font-size: 22px;
  color: #FFFFFF;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.understanding-intro p {
  margin: 0; line-height: 1.6;
  color: rgba(255,255,255,0.96);
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.phase-block { margin-bottom: 30px; }
.phase-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 0 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.phase-head h3 { margin: 0; font-size: 18px; color: var(--ink); font-weight: 700; }
.phase-head .phase-meta { font-size: 13px; color: var(--ink-3); }

.stage-block { margin-bottom: 22px; }
.stage-head {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 10px;
}
.stage-head .stage-num {
  width: 30px; height: 30px; border-radius: 8px;
  background: color-mix(in srgb, var(--teal) 18%, transparent);
  color: var(--teal); display: grid; place-items: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.stage-head h4 { margin: 0; font-size: 16px; color: var(--ink); font-weight: 700; }
.stage-head .stage-cap { font-size: 13px; color: var(--ink-3); margin-left: auto; }

.node-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* Node card */
.node-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  cursor: pointer; display: flex; flex-direction: column; gap: 8px;
  transition: transform .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
  text-align: left;
}
.node-card:not([data-locked="true"]):hover {
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: var(--shadow);
}
.node-card[data-locked="true"] {
  opacity: 0.55; cursor: not-allowed;
}
.node-card[data-status="passed"] {
  border-color: color-mix(in srgb, var(--green) 50%, var(--line));
  background: color-mix(in srgb, var(--green) 6%, var(--card));
}
.node-card .node-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.node-card .node-id {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--ink-3); letter-spacing: 0.5px;
}
.node-card .node-title { font-weight: 700; font-size: 15px; color: var(--ink); line-height: 1.35; }
.node-card .node-concept { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.node-card .node-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  flex-shrink: 0; white-space: nowrap;
}
.node-card .node-status[data-kind="passed"]      { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.node-card .node-status[data-kind="ready"]       { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--teal); }
.node-card .node-status[data-kind="in-dev"]      { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.node-card .node-status[data-kind="locked"]      { background: var(--card-hi); color: var(--ink-3); }
[data-theme="light"] .node-card .node-status[data-kind="passed"] { color: var(--green-deep); }
[data-theme="light"] .node-card .node-status[data-kind="in-dev"] { color: #92400E; }

/* Combined-test row */
.combined-test-card {
  margin-top: 12px; padding: 14px 16px;
  background: color-mix(in srgb, var(--gold) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line));
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: transform .15s var(--ease);
}
.combined-test-card:hover { transform: translateY(-1px); }
.combined-test-card[data-celebratory="true"] {
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 22%, var(--card)) 0%, color-mix(in srgb, var(--teal) 14%, var(--card)) 100%);
}
.combined-test-card .ct-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--gold); color: var(--on-gold);
  display: grid; place-items: center; font-weight: 800;
  flex-shrink: 0;
}
.combined-test-card .ct-text { flex: 1; }
.combined-test-card .ct-title { font-weight: 700; color: var(--ink); font-size: 14px; }
.combined-test-card .ct-meta  { font-size: 12px; color: var(--ink-2); }
.combined-test-card[data-locked="true"] { opacity: 0.55; cursor: not-allowed; }
.combined-test-card[data-passed="true"] { border-color: var(--green); }

/* ─── Node lesson view ─────────────────────────────────────── */
.node-view { display: flex; flex-direction: column; gap: 18px; }
.node-view .node-hero {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 22px 24px;
}
.node-view .node-hero .stage-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  color: var(--teal); font-size: 12px; font-weight: 700;
  margin-bottom: 8px;
}
.node-view .node-hero h2 { margin: 0 0 6px; font-size: 26px; color: var(--ink); }
.node-view .node-hero .node-concept-line {
  margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.55;
}
.node-view .node-hero .node-meta {
  display: flex; gap: 14px; margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--line); flex-wrap: wrap;
  font-size: 13px; color: var(--ink-3);
}
.node-view .node-hero .node-meta strong { color: var(--ink-2); font-weight: 700; }

.lesson-section {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
}
.lesson-section[data-kind="english_contrast"] {
  background: color-mix(in srgb, var(--gold) 8%, var(--card));
  border-color: color-mix(in srgb, var(--gold) 30%, var(--line));
}
.lesson-section[data-kind="concept"] {
  background: color-mix(in srgb, var(--teal) 10%, var(--card));
  border-color: color-mix(in srgb, var(--teal) 35%, var(--line));
}
.lesson-section h3 { margin: 0 0 10px; font-size: 16px; color: var(--ink); font-weight: 700; }
.lesson-section h3 .kind-pill {
  font-size: 10px; font-weight: 800; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--ink-3);
  margin-left: 8px;
}
.lesson-section p { margin: 0 0 10px; color: var(--ink-2); line-height: 1.62; white-space: pre-wrap; }
.lesson-section p:last-child { margin-bottom: 0; }
.lesson-section .arabic-inline {
  font-family: var(--font-ar); font-size: 19px; color: var(--ink);
  white-space: nowrap;
}

/* Example block with parse table */
.example-block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.example-block .ex-arabic {
  font-family: var(--font-ar); font-size: 28px; line-height: 1.7;
  text-align: center; color: var(--ink); padding: 8px 0;
  direction: rtl;
}
.example-block .ex-english {
  color: var(--ink-2); font-style: italic; font-size: 14px; text-align: center;
}
.example-block .ex-ref {
  color: var(--ink-3); font-size: 12px; text-align: center;
}
.example-block .ex-note {
  font-size: 13px; color: var(--ink-3); line-height: 1.5;
  padding-top: 8px; border-top: 1px dashed var(--line);
}

/* Parse table — word-by-word breakdown */
.parse-table {
  display: grid; gap: 6px; padding: 10px 0;
  border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line);
  direction: rtl;
}
.parse-row {
  display: grid; grid-template-columns: minmax(80px, 1fr) auto auto;
  align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: 8px; background: var(--bg-mid);
}
.parse-row .pr-word {
  font-family: var(--font-ar); font-size: 22px; color: var(--ink); text-align: center;
}
.parse-row .pr-role {
  font-size: 12px; color: var(--ink-2); direction: ltr; text-align: left;
}
.parse-row .pr-state {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  font-weight: 700; direction: ltr; text-align: center;
}
.parse-row .pr-state[data-state="rafʿ"] { background: var(--iraab-rafa-bg); color: var(--iraab-rafa-ink); }
.parse-row .pr-state[data-state="naṣb"] { background: var(--iraab-nasb-bg); color: var(--iraab-nasb-ink); }
.parse-row .pr-state[data-state="jarr"] { background: var(--iraab-jarr-bg); color: var(--iraab-jarr-ink); }
.parse-row .pr-state[data-state="jazm"] { background: var(--iraab-jazm-bg); color: var(--iraab-jazm-ink); }

/* Vocab list */
.vocab-list { display: grid; gap: 8px; }
.vocab-row {
  display: grid; grid-template-columns: minmax(80px, 1fr) minmax(80px, 1fr) 2fr;
  align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); direction: rtl;
}
.vocab-row .v-arabic { font-family: var(--font-ar); font-size: 22px; color: var(--ink); text-align: center; }
.vocab-row .v-plural { font-family: var(--font-ar); font-size: 18px; color: var(--ink-2); text-align: center; }
.vocab-row .v-gloss  { font-size: 14px; color: var(--ink-2); direction: ltr; text-align: left; }

/* Practice items */
.practice-list { display: grid; gap: 10px; }
.practice-row {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: grid; gap: 4px;
}
.practice-row .p-prompt {
  font-family: var(--font-ar); font-size: 22px; color: var(--ink);
  direction: rtl; text-align: right;
}
.practice-row .p-prompt-en {
  font-family: var(--font-ui); font-size: 15px; color: var(--ink); direction: ltr;
}
.practice-row .p-meta { font-size: 12px; color: var(--ink-3); }
.practice-row .p-answer {
  font-size: 14px; color: var(--ink-2); padding-top: 6px;
  border-top: 1px dashed var(--line); margin-top: 4px;
  display: none;
}
.practice-row[data-revealed="true"] .p-answer { display: block; }
.practice-row .reveal-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--teal); font-size: 13px; font-weight: 600;
  margin-top: 4px; text-align: left;
}
.practice-row .p-answer .ans-ar {
  font-family: var(--font-ar); font-size: 20px; color: var(--ink); direction: rtl;
}

/* "In development" notice for unfilled nodes */
.in-development {
  background: color-mix(in srgb, var(--warn) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line));
  border-radius: var(--radius); padding: 22px;
  text-align: center;
}
.in-development .icon { font-size: 32px; margin-bottom: 8px; }
.in-development h3 { margin: 0 0 6px; color: var(--ink); font-size: 18px; }
.in-development p { margin: 0; color: var(--ink-2); line-height: 1.55; }

/* Start-test CTA */
.start-test-cta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 18px 22px;
  background: linear-gradient(135deg, var(--green) 0%, var(--teal-light) 100%);
  color: var(--on-green); border-radius: var(--radius);
  cursor: pointer; border: none; width: 100%;
  font-family: inherit; font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow);
  transition: transform .15s var(--ease);
}
.start-test-cta:hover { transform: translateY(-2px); }
.start-test-cta .cta-meta { font-size: 12px; opacity: 0.85; font-weight: 500; }
.start-test-cta:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ─── Understanding test runner ─────────────────────────────── */
.utest-shell { display: flex; flex-direction: column; gap: 18px; }
.utest-progress {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.utest-progress .upc-text { font-size: 13px; color: var(--ink-2); }
.utest-progress .upc-bar {
  flex: 1; height: 8px; background: var(--bg-mid);
  border-radius: 999px; overflow: hidden;
}
.utest-progress .upc-fill {
  height: 100%; background: linear-gradient(90deg, var(--teal), var(--green));
  border-radius: 999px;
  transition: width .3s var(--ease);
}

.utest-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px;
}
.utest-card .uq-prompt {
  font-size: 17px; color: var(--ink); line-height: 1.55;
  margin: 0 0 18px; font-weight: 600;
}
.utest-card .uq-prompt .arabic {
  font-family: var(--font-ar); font-size: 26px; direction: rtl;
}

.utest-options { display: grid; gap: 10px; }
.utest-option {
  background: var(--card-hi); border: 2px solid transparent;
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; text-align: left;
  color: var(--ink); font-family: inherit; font-size: 15px; line-height: 1.45;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.utest-option:hover { border-color: var(--line-strong); }
.utest-option .arabic { font-family: var(--font-ar); font-size: 20px; }
.utest-option[data-state="selected"] {
  border-color: var(--teal); background: color-mix(in srgb, var(--teal) 14%, var(--card));
}
.utest-option[data-state="correct"] {
  border-color: var(--green); background: color-mix(in srgb, var(--green) 14%, var(--card));
}
.utest-option[data-state="wrong"] {
  border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--card));
}
.utest-option:disabled { cursor: default; }

.utest-explanation {
  margin-top: 14px; padding: 12px 14px;
  border-radius: var(--radius-sm); font-size: 14px; line-height: 1.55;
}
.utest-explanation[data-kind="correct"] {
  background: color-mix(in srgb, var(--green) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
  color: var(--ink);
}
.utest-explanation[data-kind="wrong"] {
  background: color-mix(in srgb, var(--bad) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line));
  color: var(--ink);
}
.utest-explanation strong { display: block; margin-bottom: 4px; color: var(--ink); }

.utest-next-btn {
  background: var(--green); color: var(--on-green); border: none;
  padding: 12px 22px; border-radius: var(--radius-sm);
  font-weight: 700; cursor: pointer; font-size: 14px;
  margin-top: 14px; font-family: inherit;
}
.utest-next-btn:hover { background: var(--green-deep); }

/* Test result page */
.utest-result {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 32px 28px;
  text-align: center;
}
.utest-result.passed {
  background: linear-gradient(135deg, color-mix(in srgb, var(--green) 22%, var(--card)) 0%, color-mix(in srgb, var(--teal) 14%, var(--card)) 100%);
  border-color: color-mix(in srgb, var(--green) 40%, var(--line));
}
.utest-result.failed {
  background: color-mix(in srgb, var(--warn) 8%, var(--card));
  border-color: color-mix(in srgb, var(--warn) 30%, var(--line));
}
.utest-result h2 { margin: 0 0 8px; font-size: 26px; color: var(--ink); }
.utest-result .score-big {
  font-size: 64px; font-weight: 800; margin: 14px 0;
  color: var(--ink);
}
.utest-result .score-big.passed-tone { color: var(--green); }
.utest-result .score-big.failed-tone { color: var(--warn); }
.utest-result p { color: var(--ink-2); line-height: 1.55; margin: 0 0 6px; }
.utest-result .result-actions {
  display: flex; gap: 10px; margin-top: 20px; justify-content: center; flex-wrap: wrap;
}
.utest-result .result-actions button {
  background: var(--teal); color: var(--on-green); border: none;
  padding: 12px 22px; border-radius: var(--radius-sm);
  font-weight: 700; cursor: pointer; font-family: inherit;
}
.utest-result .result-actions button.secondary {
  background: transparent; color: var(--ink-2); border: 1px solid var(--line);
}
.utest-result .celebratory {
  background: linear-gradient(135deg, var(--gold) 0%, var(--teal-light) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; font-weight: 800;
}

/* ─── Stepper (e-learning, one idea per screen) ────────────────── */
.step-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100dvh - 140px);
}

.step-node-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 4px 2px; flex-wrap: wrap;
}
.step-node-title { font-weight: 700; font-size: 17px; color: var(--ink); letter-spacing: -0.01em; flex: 1; min-width: 0; }
.step-node-meta  { font-size: 12px; color: var(--ink-3); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.step-ref-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card-hi); border: 1px solid var(--line);
  color: var(--ink); padding: 7px 14px; border-radius: 999px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.step-ref-btn:hover { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, var(--card-hi)); }
.step-ref-btn span:first-child { font-size: 15px; }

.step-progress {
  display: flex; gap: 6px; padding: 4px 0;
}
.step-progress .dot {
  flex: 1; height: 6px; border-radius: 999px;
  background: var(--line);
  transition: background-color .25s var(--ease);
}
.step-progress .dot.done    { background: var(--green); }
.step-progress .dot.current { background: var(--teal); }

.step-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.step-card {
  display: flex; flex-direction: column;
  justify-content: flex-start; gap: 22px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  animation: stepIn .35s var(--ease);
  box-shadow: var(--shadow-sm);
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-headline {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700;
  text-align: center; color: var(--ink);
  line-height: 1.25; letter-spacing: -0.015em;
  max-width: 28ch; margin-inline: auto;
}
.step-subhead {
  margin: 0;
  font-size: 17px; color: var(--ink-2);
  text-align: center; line-height: 1.6;
}
/* Prose body — supports paragraphs, bold, numbered lists, line breaks */
.step-body {
  margin: 0;
  font-size: 17px; color: var(--ink);
  line-height: 1.65;
  max-width: 64ch;
  margin-inline: auto;
}
.step-body p { margin: 0 0 14px; }
.step-body p:last-child { margin-bottom: 0; }
.step-body strong { color: var(--ink); font-weight: 700; }
.step-body .prose-list {
  list-style: none;
  margin: 6px 0 14px;
  padding: 0;
  counter-reset: prose-item;
  display: grid; gap: 10px;
}
.step-body .prose-list li {
  counter-increment: prose-item;
  position: relative;
  padding: 12px 14px 12px 48px;
  background: color-mix(in srgb, var(--green) 5%, var(--card));
  border: 1px solid color-mix(in srgb, var(--green) 18%, var(--line));
  border-radius: 12px;
  line-height: 1.5;
}
.step-body .prose-list li::before {
  content: counter(prose-item);
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green); color: #fff;
  border-radius: 50%;
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.step-body .prose-list li strong { color: var(--green-li, var(--green)); }
.step-body .prose-bullets {
  list-style: none;
  margin: 6px 0 14px;
  padding: 0;
  display: grid; gap: 8px;
}
.step-body .prose-bullets li {
  position: relative;
  padding: 8px 10px 8px 26px;
  line-height: 1.55;
}
.step-body .prose-bullets li::before {
  content: "•";
  position: absolute;
  left: 8px; top: 8px;
  color: var(--gold);
  font-weight: 700;
}
/* Box body variant — same rules, scoped to step-box */
.step-box-body { margin: 0; }
.step-box-body p { margin: 0 0 12px; }
.step-box-body p:last-child { margin-bottom: 0; }
.step-box-body .prose-list {
  list-style: none; margin: 6px 0 0; padding: 0;
  counter-reset: prose-item; display: grid; gap: 8px;
}
.step-box-body .prose-list li {
  counter-increment: prose-item;
  position: relative; padding-left: 28px;
}
.step-box-body .prose-list li::before {
  content: counter(prose-item) ".";
  position: absolute; left: 0; top: 0;
  font-weight: 700; color: var(--green);
}
.step-arabic-big {
  font-family: var(--font-ar);
  font-size: 72px; line-height: 1.35;
  text-align: center; direction: rtl;
  color: var(--ink); padding: 8px 0;
  font-weight: 400;
}

.step-examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.step-ex-card {
  background: var(--bg-mid); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 14px;
  text-align: center;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.step-ex-card .ar {
  font-family: var(--font-ar);
  font-size: 32px; color: var(--ink);
  direction: rtl; line-height: 1.4;
}
.step-ex-card .en {
  font-size: 13px; color: var(--ink-3);
}
.step-ex-card[data-state="rafʿ"] { border-color: var(--iraab-rafa-ink); }
.step-ex-card[data-state="naṣb"] { border-color: var(--iraab-nasb-ink); }
.step-ex-card[data-state="jarr"] { border-color: var(--iraab-jarr-ink); }

.step-compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.step-compare .col {
  background: var(--bg-mid); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.step-compare .col .lang-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  color: var(--ink-3); text-transform: uppercase; margin-bottom: 6px;
}
.step-compare .col .content {
  font-size: 15px; color: var(--ink); line-height: 1.5; white-space: pre-line;
}
.step-compare .col.ar .content {
  font-family: var(--font-ar);
  font-size: 22px; direction: rtl; text-align: right;
}

/* Verse preview — verb greyed-out, "you'll unlock in Phase B" */
.step-arabic-big.preview-verse {
  display: flex; flex-wrap: wrap-reverse; justify-content: center; gap: 0.3em;
  direction: rtl;
}
.step-arabic-big.preview-verse .pv-word {
  display: inline-block;
}
.step-arabic-big.preview-verse .pv-word.locked {
  color: var(--ink-3);
  background: var(--bg-mid);
  padding: 0 6px;
  border-radius: 6px;
  border: 1px dashed var(--line-strong);
  opacity: 0.65;
  position: relative;
}
.step-preview-tag {
  display: inline-flex; align-self: center; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 14%, var(--card));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line));
  font-size: 13px; color: var(--ink-2);
  margin: 0 auto;
}
.step-preview-tag .lock-icon { font-size: 14px; }

/* Verse step */
.step-verse-en {
  margin: 0; text-align: center;
  font-style: italic; color: var(--ink-2);
}
.step-verse-ref {
  margin: 0; text-align: center;
  font-size: 12px; color: var(--ink-3);
}
.step-parse {
  display: grid; gap: 6px; padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.step-parse-row {
  display: grid; grid-template-columns: 1fr 1.5fr auto;
  gap: 10px; align-items: center;
  padding: 8px 10px; background: var(--bg-mid);
  border-radius: var(--radius-sm);
}
.step-parse-row .pp-word {
  font-family: var(--font-ar); font-size: 22px;
  direction: rtl; text-align: center; color: var(--ink);
}
.step-parse-row .pp-meta {
  font-size: 12px; color: var(--ink-2);
}
.step-parse-row .pp-gloss {
  color: var(--ink); font-size: 14px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.step-parse-row .pp-state {
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  border: 1.5px solid currentColor; background: transparent;
}
.step-parse-row .pp-state[data-state="rafʿ"] { color: var(--iraab-rafa-ink); }
.step-parse-row .pp-state[data-state="naṣb"] { color: var(--iraab-nasb-ink); }
.step-parse-row .pp-state[data-state="jarr"] { color: var(--iraab-jarr-ink); }
.step-parse-row .pp-state[data-state="jazm"] { color: var(--iraab-jazm-ink); }

/* Tap check */
.step-tap-options {
  display: grid; gap: 12px;
}
.step-tap-btn {
  padding: 20px 22px;
  background: var(--card-hi); border: 2px solid transparent;
  border-radius: var(--radius);
  font-size: 17px; font-weight: 600;
  color: var(--ink); font-family: inherit;
  text-align: center; cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease), transform .1s var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
}
.step-tap-btn:hover:not(:disabled) { border-color: var(--line-strong); transform: translateY(-1px); }
.step-tap-btn .tap-ar {
  font-family: var(--font-ar); font-size: 28px; direction: rtl; font-weight: 400;
}
.step-tap-btn .tap-gloss {
  color: var(--ink-3); font-size: 14px; font-weight: 500;
}
.step-tap-btn[data-state="correct"] {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, var(--card));
}
.step-tap-btn[data-state="wrong"] {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, var(--card));
}
.step-tap-btn:disabled { cursor: default; opacity: 1; }

.step-feedback {
  padding: 16px 18px; border-radius: var(--radius);
  font-size: 16px; line-height: 1.6; color: var(--ink);
}
.step-feedback[data-kind="correct"] {
  background: color-mix(in srgb, var(--green) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
}
.step-feedback[data-kind="wrong"] {
  background: color-mix(in srgb, var(--bad) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line));
}
.step-feedback strong { display: block; margin-bottom: 2px; }

.step-actions {
  display: flex; gap: 10px; padding-top: 4px;
}
.step-continue-btn {
  flex: 1;
  padding: 18px 26px;
  background: var(--green); color: var(--on-green);
  border: none; border-radius: var(--radius);
  font-weight: 700; font-size: 16px; letter-spacing: 0.01em;
  cursor: pointer; font-family: inherit;
  transition: background-color .15s var(--ease), transform .1s var(--ease);
}
.step-continue-btn:hover  { background: var(--green-deep); }
.step-continue-btn:active { transform: translateY(1px); }
.step-continue-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.step-back-btn {
  flex: 0 0 auto;
  padding: 18px 22px;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-weight: 600; font-size: 15px;
  cursor: pointer; font-family: inherit;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.step-back-btn:hover { background: var(--card-2, color-mix(in srgb, var(--ink) 4%, var(--card))); border-color: var(--ink-3); color: var(--ink); }
.step-back-btn:active { transform: translateY(1px); }

.step-complete-mark {
  font-size: 64px; text-align: center; color: var(--green);
  font-weight: 800; line-height: 1;
}

/* ─── Themed boxes for richer step kinds ───────────────────────── */
.step-box {
  border-radius: var(--radius-lg); padding: 26px 28px;
  border: 1px solid var(--line);
  display: flex; gap: 20px; align-items: flex-start;
  background: var(--bg-mid);
}
.step-box .step-box-icon {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 800;
  font-family: var(--font-display);
}
.step-box .step-box-content { flex: 1; min-width: 0; }
.step-box .step-box-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0.8px;
  text-transform: uppercase; margin-bottom: 6px;
  display: inline-block;
}
.step-box .step-box-headline {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; color: var(--ink);
  margin: 0 0 10px; line-height: 1.3; letter-spacing: -0.01em;
}
.step-box .step-box-body {
  font-size: 17px; color: var(--ink); line-height: 1.7;
  margin: 0; white-space: pre-line;
}
.step-box .step-box-body strong { color: var(--ink); font-weight: 700; }

/* Cheat sheet — end-of-lesson recap before the test */
.step-cheat-sheet {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--gold) 18%, var(--card)) 0%,
    color-mix(in srgb, var(--teal) 14%, var(--card)) 100%);
  border: 2px solid color-mix(in srgb, var(--gold) 55%, var(--line));
  border-radius: var(--radius-lg); padding: 28px 32px;
}
.step-cheat-sheet .cs-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
}
.step-cheat-sheet .cs-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--gold); color: var(--on-gold);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800; font-family: var(--font-display);
  flex-shrink: 0;
}
.step-cheat-sheet .cs-title {
  margin: 0; font-size: 22px; font-weight: 800;
  letter-spacing: -0.01em; color: var(--ink);
  font-family: var(--font-display);
}
.step-cheat-sheet .cs-rules {
  display: grid; gap: 12px;
}
.step-cheat-sheet .cs-rule {
  display: grid; grid-template-columns: auto 1fr; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px;
  align-items: start;
}
.step-cheat-sheet .cs-num {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--gold); color: var(--on-gold);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  flex-shrink: 0;
}
.step-cheat-sheet .cs-rule-text {
  font-size: 15.5px; line-height: 1.6; color: var(--ink);
}
.step-cheat-sheet .cs-rule-text strong { color: var(--ink); font-weight: 700; }
.step-cheat-sheet .cs-rule-text .ar {
  font-family: var(--font-ar); font-size: 19px; direction: rtl;
  unicode-bidi: isolate;
}
.step-cheat-sheet .cs-foot {
  margin-top: 14px; font-size: 13px; color: var(--ink-2);
  font-style: italic; text-align: center;
}

/* RTL list of Arabic examples (e.g. numbers 1-9 should flow right-to-left) */
.step-rtl-grid {
  direction: rtl;
}
.step-rtl-grid .step-ex-card {
  /* the cards themselves are LTR text inside, but flow RTL */
}

/* Key rule — green/gold accent */
.step-box[data-kind="key_rule"] {
  background: color-mix(in srgb, var(--gold) 8%, var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line));
  border-left: 4px solid var(--gold);
}
.step-box[data-kind="key_rule"] .step-box-icon {
  background: var(--gold); color: var(--on-gold);
}
.step-box[data-kind="key_rule"] .step-box-badge { color: var(--gold); }
[data-theme="light"] .step-box[data-kind="key_rule"] .step-box-badge { color: #92400E; }

/* English aside — teal accent */
.step-box[data-kind="english_aside"] {
  background: color-mix(in srgb, var(--teal) 8%, var(--card));
  border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--line));
  border-left: 4px solid var(--teal);
}
.step-box[data-kind="english_aside"] .step-box-icon {
  background: var(--teal); color: var(--on-green);
}
.step-box[data-kind="english_aside"] .step-box-badge { color: var(--teal); }

/* Pitfall / watch-out — bad/red accent */
.step-box[data-kind="pitfall"] {
  background: color-mix(in srgb, var(--bad) 6%, var(--card));
  border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line));
  border-left: 4px solid var(--bad);
}
.step-box[data-kind="pitfall"] .step-box-icon {
  background: var(--bad); color: #fff;
}
.step-box[data-kind="pitfall"] .step-box-badge { color: var(--bad); }

/* Tip / lightbulb — warn/amber accent */
.step-box[data-kind="tip"] {
  background: color-mix(in srgb, var(--warn) 8%, var(--card));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line));
  border-left: 4px solid var(--warn);
}
.step-box[data-kind="tip"] .step-box-icon {
  background: var(--warn); color: #1E293B;
}
.step-box[data-kind="tip"] .step-box-badge { color: var(--warn); }
[data-theme="light"] .step-box[data-kind="tip"] .step-box-badge { color: #92400E; }

/* ─── Table step (Singular / Dual / Plural etc.) ───────────────── */
.step-table {
  display: grid; gap: 8px;
}
.step-table-head, .step-table-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) repeat(var(--cols, 3), 1fr);
  gap: 8px; align-items: stretch;
}
.step-table-head .th {
  font-size: 12px; font-weight: 800; letter-spacing: 0.7px;
  color: var(--ink-3); text-transform: uppercase;
  text-align: center; padding: 6px 8px;
}
.step-table-head .th:first-child { text-align: left; }
.step-table-row .row-label {
  font-size: 14px; color: var(--ink-2); font-weight: 600;
  display: flex; align-items: center;
}
.step-table-row .cell {
  background: var(--bg-mid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 80px; gap: 4px;
}
.step-table-row .cell .word {
  font-family: var(--font-ar);
  font-size: 30px; direction: rtl;
  line-height: 1.3; color: var(--ink);
}
.step-table-row .cell .cell-label {
  /* English-text cells in tables — use UI font, not Arabic */
  font-family: var(--font-display, var(--font-ui, inherit));
  font-size: 15px; line-height: 1.4;
  color: var(--ink); text-align: center;
  direction: ltr;
}
.step-table-row .cell .word .stem  { color: var(--ink); }
.step-table-row .cell .word .iraab {
  font-weight: 700;
}
.step-table-row .cell .word .iraab[data-state="rafʿ"] { color: var(--iraab-rafa-ink); }
.step-table-row .cell .word .iraab[data-state="naṣb"] { color: var(--iraab-nasb-ink); }
.step-table-row .cell .word .iraab[data-state="jarr"] { color: var(--iraab-jarr-ink); }
.step-table-row .cell .word .iraab[data-state="jazm"] { color: var(--iraab-jazm-ink); }
.step-table-row .cell .gloss {
  font-size: 11px; color: var(--ink-3); text-align: center;
}

@media (max-width: 600px) {
  .step-box { padding: 14px 14px; gap: 10px; }
  .step-box .step-box-icon { width: 30px; height: 30px; font-size: 15px; }
  .step-box .step-box-headline { font-size: 16px; }
  .step-box .step-box-body { font-size: 14px; }
  .step-table-head, .step-table-row {
    grid-template-columns: minmax(70px, auto) repeat(var(--cols, 3), 1fr);
    gap: 6px;
  }
  .step-table-row .cell { padding: 8px 4px; min-height: 56px; }
  .step-table-row .cell .word { font-size: 19px; }
  .step-table-row .row-label { font-size: 12px; }
}

@media (max-width: 600px) {
  .step-wrap { padding: 10px 14px 24px; min-height: calc(100dvh - 120px); }
  .step-card { padding: 22px 18px; gap: 14px; border-radius: var(--radius); }
  .step-headline { font-size: 20px; }
  .step-subhead  { font-size: 14px; }
  .step-arabic-big { font-size: 42px; }
  .step-ex-card .ar { font-size: 22px; }
  .step-compare { grid-template-columns: 1fr; }
  .step-parse-row { grid-template-columns: 1fr auto; }
  .step-parse-row .pp-meta { grid-column: 1 / -1; padding-top: 2px; }
  .step-tap-btn { padding: 14px 16px; }
}

@media (min-width: 900px) {
  .step-wrap { max-width: 920px; padding: 24px 24px 48px; }
  .step-card { padding: 44px 56px; gap: 22px; }
  .step-headline { font-size: 28px; }
  .step-subhead  { font-size: 17px; }
  .step-body     { font-size: 17px; }
  .step-arabic-big { font-size: 84px; }
  .step-box { padding: 32px 36px; gap: 24px; }
  .step-box .step-box-icon { width: 60px; height: 60px; font-size: 28px; }
  .step-box .step-box-headline { font-size: 24px; }
  .step-box .step-box-body { font-size: 18px; }
  .step-ex-card { padding: 24px 16px; }
  .step-ex-card .ar { font-size: 36px; }
  .step-ex-card .en { font-size: 14px; }
  .step-tap-btn { padding: 22px 26px; font-size: 18px; }
  .step-tap-btn .tap-ar { font-size: 32px; }
  .step-table-row .cell { padding: 20px 14px; min-height: 90px; }
  .step-table-row .cell .word { font-size: 36px; }
}

/* iʿrāb ending — coloured letters (not a pill highlight) */
.iraab {
  font-family: inherit; font-weight: 700;
}
.iraab[data-state="rafʿ"] { color: var(--iraab-rafa-ink); }
.iraab[data-state="naṣb"] { color: var(--iraab-nasb-ink); }
.iraab[data-state="jarr"] { color: var(--iraab-jarr-ink); }
.iraab[data-state="jazm"] { color: var(--iraab-jazm-ink); }

/* Generic letter highlight (the gold marker for ة, ـُونَ, ـَات, dual ending, etc.)
   Use [[ ... ]] in JSON Arabic strings and the renderer converts to this span.
   Gold reads more clearly than green against the Arabic text. */
.hl {
  color: var(--gold-light, #E2BF4A);
  font-weight: 700;
}
[data-theme="light"] .hl { color: var(--gold); }

/* Legend chips — keep filled so the colour-key is unambiguous */
.iraab-legend {
  display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 0; justify-content: center;
}
.iraab-legend .chip {
  padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 700; border: 1.5px solid currentColor;
  background: transparent;
}
.iraab-legend .chip[data-state="rafʿ"] { color: var(--iraab-rafa-ink); }
.iraab-legend .chip[data-state="naṣb"] { color: var(--iraab-nasb-ink); }
.iraab-legend .chip[data-state="jarr"] { color: var(--iraab-jarr-ink); }
.iraab-legend .chip[data-state="jazm"] { color: var(--iraab-jazm-ink); }

/* ─── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ─── Mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .wrap { padding: 16px 14px 60px; }
  .nav { padding: 10px 14px; }
  .stats-row { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .stat-val { font-size: 20px; }
  .lesson-header { grid-template-columns: 1fr; text-align: center; }
  .lesson-header .glyph-bubble { margin: 0 auto; }
  .items-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  .item-tile { min-height: 70px; padding: 10px 6px; }
  .item-tile .arabic { font-size: 22px; }
  .quiz-options { grid-template-columns: 1fr 1fr; }
  .foot { font-size: 12px; }
  .nav-actions { gap: 6px; }
  .store-link { display: none; }

  /* Understanding-track mobile */
  .node-grid { grid-template-columns: 1fr; }
  .node-view .node-hero { padding: 18px; }
  .node-view .node-hero h2 { font-size: 22px; }
  .lesson-section { padding: 14px 16px; }
  .example-block .ex-arabic { font-size: 24px; }
  .parse-row { grid-template-columns: 1fr; gap: 4px; padding: 8px; }
  .parse-row .pr-role { direction: ltr; text-align: center; }
  .vocab-row { grid-template-columns: 1fr 2fr; gap: 8px; }
  .vocab-row .v-plural { grid-column: 1 / -1; text-align: right; padding-right: 4px; font-size: 16px; }
  .utest-card { padding: 16px; }
  .utest-card .uq-prompt { font-size: 15px; }
  .stage-head { flex-wrap: wrap; }
  .stage-head .stage-cap { margin-left: 0; flex-basis: 100%; }
}


/* ─── Language button (top nav) ─────────────────────────────────────
   Deliberately in the nav rather than only inside Settings: a user who
   lands in a language they can't read cannot be expected to find a
   settings screen labelled in that language. The globe + language code
   is recognisable regardless of what language the UI is currently in. */
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2, rgba(255,255,255,.08));
  border: 1px solid var(--border, rgba(255,255,255,.14));
  color: inherit; border-radius: 999px;
  padding: 6px 10px; cursor: pointer; font: inherit; line-height: 1;
}
.lang-btn:hover { filter: brightness(1.12); }
.lang-btn:focus-visible { outline: 2px solid var(--accent, #C9A227); outline-offset: 2px; }
.lang-btn svg { width: 16px; height: 16px; flex: none; }
.lang-btn .code { font-size: 12px; font-weight: 700; letter-spacing: .04em; }
@media (max-width: 380px) { .lang-btn .code { display: none; } }


/* ─── Understanding: coming-soon panel ──────────────────────────────
   Shown while UNDERSTANDING_LIVE is false. The track keeps its tab so
   the feature is announced, but no lesson data is fetched or shipped. */
.u-soon { text-align: center; padding: 34px 24px; }
.u-soon-badge {
  display: inline-block; margin-bottom: 14px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--gold, #C9A227); color: #1E293B;
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase;
}
.u-soon h2 { margin: 0 0 12px; }
.u-soon-body {
  max-width: 54ch; margin: 0 auto 22px;
  opacity: .85; line-height: 1.65;
}
