/* ============================================================================
   AI TAJWEED VOICE EVALUATION — Interactive Prototype
   Design system + components.  Dark, immersive, premium.
   Brand: LearnQuran (navy + teal) · AI premium accent: gold · Quran: gold serif
   Semantics: correct=green · Lahn Jaliy (clear)=red · Lahn Khofiy (subtle)=amber
   ========================================================================== */

/* ---------------------------------------------------------------- tokens -- */
:root {
  /* surfaces — deep navy, harmonised between the iOS app + AI backend */
  --bg-0: #04141d;          /* deepest app background                       */
  --bg-1: #072636;          /* card / surface                               */
  --bg-2: #0c3a52;          /* raised surface / sheet                       */
  --bg-3: #114a68;          /* hover / pressed surface                      */
  --hairline: rgba(255,255,255,.075);
  --border: #103b54;
  --border-strong: #17557a;

  /* brand */
  --teal: #34b3e4;          /* primary action (manual / neutral)            */
  --teal-2: #57c6f0;
  --teal-deep: #18799f;
  --teal-ghost: rgba(52,179,228,.14);

  /* premium AI identity */
  --gold: #e6c074;
  --gold-soft: #f2dca0;
  --gold-deep: #b88e3f;
  --ai-glow: rgba(230,192,116,.45);

  /* quran text */
  --quran: #f4ead2;
  --quran-dim: #d8e6ea;

  /* semantics (matched to AI backend) */
  --correct: #45c98a;
  --correct-bg: rgba(69,201,138,.16);
  --jaliy: #ef6461;         /* clear error (Lahn Jaliy)                     */
  --jaliy-bg: rgba(239,100,97,.20);
  --khofiy: #e6a23c;        /* subtle error (Lahn Khofiy)                   */
  --khofiy-bg: rgba(230,162,60,.16);

  /* text */
  --text: #eef5f8;
  --text-dim: rgba(238,245,248,.66);
  --text-faint: rgba(238,245,248,.56);   /* ≥4.5:1 on --bg-0 for real content text */
  --text-ghost: rgba(238,245,248,.30);   /* decorative only (chevrons/hairlines) */

  /* radii / shadow */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow-1: 0 2px 10px rgba(0,0,0,.25);
  --shadow-2: 0 12px 40px rgba(0,0,0,.45);
  --shadow-sheet: 0 -10px 60px rgba(0,0,0,.55);

  /* type */
  --ui: -apple-system, "SF Pro Text", "SF Pro Display", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --arabic: "Amiri Quran", "Scheherazade New", "Amiri", "Geeza Pro", "Noto Naskh Arabic", serif;

  /* device metrics */
  --device-w: 390px;
  --device-h: 844px;
  --safe-top: 54px;
  --safe-bottom: 34px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ui);
  background:
    radial-gradient(1100px 700px at 18% -8%, #0b3146 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 10%, #0a2f44 0%, transparent 55%),
    #020d14;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: var(--teal-2); text-decoration: none; }
::selection { background: var(--teal); color: #02141d; }

/* ============================================================ prototype lab */
.proto {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}
.rail {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  padding: 22px 20px 40px;
  background: linear-gradient(180deg, #061824, #04121b);
  border-right: 1px solid var(--hairline);
}
.rail::-webkit-scrollbar { width: 8px; }
.rail::-webkit-scrollbar-thumb { background: #14384c; border-radius: 8px; }

.rail h1 {
  font-size: 16px; line-height: 1.3; margin: 0 0 2px;
  letter-spacing: -.01em;
}
.rail .sub { font-size: 12px; color: var(--text-faint); margin-bottom: 18px; }
.rail .brand-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--gold-soft);
  background: rgba(230,192,116,.10); border: 1px solid rgba(230,192,116,.25);
  padding: 4px 9px; border-radius: 999px; margin-bottom: 14px;
}
.rail-group { margin: 18px 0; }
.rail-group > .label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint); margin-bottom: 9px;
}
.flow-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; padding: 10px 12px; border-radius: 12px;
  background: #0a2334; border: 1px solid var(--hairline);
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  margin-bottom: 7px; transition: .18s;
}
.flow-btn:hover { background: #0e2e44; color: var(--text); border-color: var(--border-strong); }
.flow-btn .ico { font-size: 15px; width: 18px; text-align: center; }
.flow-btn .n { margin-left: auto; font-size: 10px; color: var(--text-ghost); }

.seg-rail { display: flex; gap: 6px; background: #07202f; padding: 4px; border-radius: 12px; }
.seg-rail button {
  flex: 1; padding: 8px; border-radius: 9px; font-size: 12px; font-weight: 600;
  color: var(--text-dim); transition: .15s;
}
.seg-rail button.on { background: var(--teal); color: #02141d; box-shadow: var(--shadow-1); }
.seg-rail button.on.gold { background: linear-gradient(135deg,var(--gold-soft),var(--gold)); color:#3a2a06; }

.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lang-grid button {
  display: flex; flex-direction: column; gap: 1px; align-items: flex-start;
  padding: 8px 10px; border-radius: 10px; background: #0a2334;
  border: 1px solid var(--hairline); transition: .15s;
}
.lang-grid button .en { font-size: 12px; font-weight: 600; color: var(--text); }
.lang-grid button .nat { font-size: 11px; color: var(--text-faint); }
.lang-grid button.on { border-color: var(--teal); background: var(--teal-ghost); }

.trial-row { display: flex; gap: 6px; }
.trial-row button {
  flex: 1; padding: 8px 0; border-radius: 9px; background: #0a2334;
  border: 1px solid var(--hairline); font-size: 12px; font-weight: 700; color: var(--text-dim);
}
.trial-row button.on { background: var(--gold); color: #3a2a06; border-color: var(--gold); }

.rail-note { font-size: 11px; color: var(--text-faint); line-height: 1.5; margin-top: 6px; }

/* stage */
.stage {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px; position: relative;
}

/* ============================================================ device frame */
.device {
  position: relative;
  width: var(--device-w); height: var(--device-h);
  border-radius: 56px;
  background: #000;
  padding: 13px;
  box-shadow:
    0 0 0 2px #1c2c34,
    0 0 0 13px #0a1419,
    0 40px 90px rgba(0,0,0,.6);
  flex: none;
}
.screen-wrap {
  position: relative; width: 100%; height: 100%;
  border-radius: 44px; overflow: hidden;
  background: var(--bg-0);
}
/* dynamic island */
.island {
  position: absolute; top: 11px; left: 50%; transform: translateX(-50%);
  width: 122px; height: 35px; background: #000; border-radius: 20px; z-index: 60;
}
/* status bar */
.statusbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--safe-top);
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 26px 11px; font-size: 14px; font-weight: 600; z-index: 55;
  color: var(--text); pointer-events: none;
}
.statusbar .right { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.home-indicator {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 134px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.5); z-index: 55;
}

/* ============================================================ screen system */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden;
  transform: translateX(14px) scale(.995);
  transition: opacity .32s ease, transform .32s cubic-bezier(.2,.9,.25,1), visibility .32s;
  background: var(--bg-0);
}
.screen.active { opacity: 1; visibility: visible; transform: none; z-index: 10; }
.screen.leaving { opacity: 0; transform: translateX(-10px) scale(.995); z-index: 9; }

/* host fills the device and clears the status-bar safe area for every screen */
#screenHost {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  z-index: 10;
}
#screenHost > * { min-height: 0; }
.screen-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen-scroll::-webkit-scrollbar { width: 0; }
.pad { padding: 0 18px; }
.pad-b { padding-bottom: calc(var(--safe-bottom) + 16px); }

/* nav bar */
.nav {
  position: relative; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 10px; min-height: 46px;
  background: linear-gradient(180deg, rgba(4,20,29,.9), rgba(4,20,29,0));
}
.nav.solid { background: var(--bg-0); border-bottom: 1px solid var(--hairline); }
.nav .icon-btn { font-size: 17px; }
.nav .title {
  flex: 1; text-align: center; font-size: 16px; font-weight: 700; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav .title .ar { font-family: var(--arabic); font-size: 19px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.07); color: var(--text); font-size: 16px;
  transition: .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.13); }
.icon-btn.plain { background: none; }

.h-large { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 4px; }
.sub-lead { font-size: 14px; color: var(--text-dim); line-height: 1.45; }

/* ============================================================== components */
/* list rows (lesson / section) */
.section-label {
  font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-faint); padding: 18px 4px 8px;
}
.card {
  background: var(--bg-1); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); overflow: hidden;
}
.card.glow-ai { border-color: rgba(230,192,116,.30); box-shadow: 0 0 0 1px rgba(230,192,116,.06), 0 10px 30px rgba(0,0,0,.3); }
.row {
  display: flex; align-items: center; gap: 13px;
  padding: 15px 16px; cursor: pointer; transition: background .15s;
}
.row + .row { border-top: 1px solid var(--hairline); }
.row:active { background: rgba(255,255,255,.04); }
.row . ricon, .row .ic {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
}
.ic.book { background: rgba(230,192,116,.16); color: var(--gold-soft); }
.ic.pencil { background: rgba(52,179,228,.16); color: var(--teal-2); }
.ic.num { background: rgba(255,255,255,.06); color: var(--text-dim); font-weight: 700; font-size: 14px; }
.ic.mic { background: linear-gradient(135deg,var(--gold-soft),var(--gold)); color:#3a2a06; }
.row .body { flex: 1; min-width: 0; }
.row .body .t { font-size: 15px; font-weight: 600; line-height: 1.3; }
.row .body .d { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.row .chev { color: var(--text-ghost); font-size: 15px; }
.row .ar-inline { font-family: var(--arabic); font-size: 17px; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  padding: 3px 7px; border-radius: 999px; vertical-align: middle;
}
.badge.ai { background: linear-gradient(135deg,var(--gold-soft),var(--gold)); color: #3a2a06; box-shadow: 0 0 12px var(--ai-glow); }
.badge.new { background: var(--teal); color: #02141d; }
.badge.soft-ai { background: rgba(230,192,116,.14); color: var(--gold-soft); border: 1px solid rgba(230,192,116,.3); }
.badge.ghost { background: rgba(255,255,255,.08); color: var(--text-dim); }
.sparkle { font-size: 10px; }

/* pills / chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: rgba(255,255,255,.06); color: var(--text-dim);
}
.chip.gold { background: rgba(230,192,116,.14); color: var(--gold-soft); border: 1px solid rgba(230,192,116,.28); }
.chip.teal { background: var(--teal-ghost); color: var(--teal-2); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border-radius: var(--r-md);
  font-size: 15.5px; font-weight: 700; letter-spacing: -.01em;
  transition: transform .12s ease, filter .15s, background .15s; user-select: none;
}
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--teal); color: #02141d; box-shadow: 0 8px 24px rgba(52,179,228,.28); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ai {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #3a2406; box-shadow: 0 10px 30px var(--ai-glow);
}
.btn-ghost { background: rgba(255,255,255,.07); color: var(--text); }
.btn-outline { background: transparent; border: 1.5px solid var(--border-strong); color: var(--text); }
.btn-danger-ghost { background: rgba(239,100,97,.10); color: var(--jaliy); }
.btn-lg { padding: 17px; font-size: 16.5px; }
.btn-sm { width: auto; padding: 10px 16px; font-size: 13.5px; border-radius: 11px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-stack { display: flex; flex-direction: column; gap: 10px; }

/* segmented control (Manual / AI) */
.segmented {
  display: flex; gap: 4px; padding: 4px; border-radius: 13px;
  background: rgba(255,255,255,.06); position: relative;
}
.segmented button {
  flex: 1; padding: 9px 10px; border-radius: 10px; font-size: 13.5px; font-weight: 700;
  color: var(--text-dim); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: .18s; position: relative; z-index: 2;
}
.segmented button.on { color: #02141d; background: var(--teal); }
.segmented button.on.ai { color: #3a2406; background: linear-gradient(135deg,var(--gold-soft),var(--gold)); box-shadow: 0 0 16px var(--ai-glow); }
.segmented .lock { font-size: 11px; opacity: .8; }

/* ===================================================== immersive recite UI */
.recite {
  flex: 1; display: flex; flex-direction: column;
  background:
    radial-gradient(120% 60% at 50% 0%, #0a2f44 0%, transparent 60%),
    var(--bg-0);
}
.recite-top { padding: 4px 14px 0; }
.recite-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 22px; text-align: center; gap: 22px;
}
.ayah {
  font-family: var(--arabic); color: var(--quran);
  font-size: 40px; line-height: 2.15; direction: rtl; font-weight: 400;
  text-shadow: 0 2px 18px rgba(0,0,0,.4);
}
.ayah.lg { font-size: 46px; }
.ayah .w { display: inline-block; padding: 0 .12em; border-radius: 10px; transition: .2s; cursor: pointer; }
.ayah .w.correct { color: var(--quran); }
/* mistakes carry a non-colour shape cue too (WCAG 1.4.1): solid underline = clear, dotted = subtle */
.ayah .w.jaliy { background: var(--jaliy-bg); box-shadow: inset 0 0 0 1.5px var(--jaliy); color: #ffe9e8;
  text-decoration: underline solid var(--jaliy); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.ayah .w.khofiy { background: var(--khofiy-bg); box-shadow: inset 0 0 0 1.4px var(--khofiy); color: #ffeccd;
  text-decoration: underline dotted var(--khofiy); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.ayah .w.active { outline: 2px solid var(--gold); outline-offset: 1px; }
.translit { font-size: 14px; color: var(--text-faint); letter-spacing: .02em; }
.translit .hl { color: var(--gold-soft); }

.page-dots { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--text-faint); }
.page-dots .pill { background: var(--teal-ghost); color: var(--teal-2); font-weight: 700; padding: 3px 12px; border-radius: 999px; }

/* recite control bar */
.recite-bar {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 12px 18px calc(var(--safe-bottom) + 6px);
}
.rbtn {
  width: 52px; height: 52px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 21px;
  background: rgba(255,255,255,.08); color: var(--text); transition: .15s;
}
.rbtn:hover { background: rgba(255,255,255,.14); }
.rbtn.teal { background: var(--teal); color: #02141d; }
.rbtn.sm { width: 44px; height: 44px; font-size: 17px; }
.rbtn.muted { color: var(--text-faint); }

/* thumbs (recitation test manual mode) */
.thumbs { display: flex; align-items: center; justify-content: center; gap: 26px; }
.thumb {
  width: 66px; height: 66px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 27px;
  transition: transform .12s, background .15s;
}
.thumb:active { transform: scale(.9); }
.thumb.up { background: var(--correct-bg); color: var(--correct); border: 1.5px solid rgba(69,201,138,.4); }
.thumb.down { background: var(--jaliy-bg); color: var(--jaliy); border: 1.5px solid rgba(239,100,97,.4); }
.thumb.sel.up { background: var(--correct); color: #03281a; }
.thumb.sel.down { background: var(--jaliy); color: #2a0c0c; }

/* ================================================== big mic / record button */
.mic-zone { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mic-hint { font-size: 13px; color: var(--text-faint); }
.mic-btn {
  position: relative; width: 84px; height: 84px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 32px;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold)); color: #3a2406;
  box-shadow: 0 12px 34px var(--ai-glow); transition: transform .14s;
}
.mic-btn.manual { background: var(--teal); color: #02141d; box-shadow: 0 12px 34px rgba(52,179,228,.32); }
.mic-btn:active { transform: scale(.94); }
.mic-btn .ring-pulse {
  position: absolute; inset: -6px; border-radius: 999px; border: 2px solid var(--gold);
  opacity: 0; animation: micpulse 2s ease-out infinite;
}
@keyframes micpulse { 0% { transform: scale(.85); opacity: .6;} 100% { transform: scale(1.5); opacity: 0; } }

/* recording state */
.recording {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: calc(var(--safe-bottom) + 14px); gap: 18px;
}
.rec-timer {
  font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: 9px; color: var(--text);
}
.rec-timer .dot { width: 9px; height: 9px; border-radius: 999px; background: var(--jaliy); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-timer .max { color: var(--text-faint); font-weight: 600; }
.rec-progress { width: 220px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.rec-progress > i { display: block; height: 100%; background: var(--jaliy); width: 0%; transition: width .25s linear; }

/* live waveform */
.wave { display: flex; align-items: center; justify-content: center; gap: 4px; height: 56px; }
.wave i {
  width: 4px; border-radius: 4px;
  background: linear-gradient(180deg, var(--teal-2), var(--teal-deep));
  box-shadow: 0 0 10px rgba(52,179,228,.5);
  animation: wv 1s ease-in-out infinite;
}
@keyframes wv { 0%,100% { height: 14%; } 50% { height: 100%; } }
.wave.gold i { background: linear-gradient(180deg, var(--gold-soft), var(--gold-deep)); box-shadow: 0 0 10px var(--ai-glow); }

.rec-stop {
  width: 76px; height: 76px; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--jaliy); color: #fff; box-shadow: 0 10px 30px rgba(239,100,97,.4);
  transition: transform .12s;
}
.rec-stop:active { transform: scale(.93); }
.rec-stop .sq { width: 26px; height: 26px; border-radius: 7px; background: #fff; }

/* ============================================================== bottom sheet */
.scrim {
  position: absolute; inset: 0; background: rgba(2,8,12,.55);
  backdrop-filter: blur(2px); opacity: 0; visibility: hidden; transition: .28s; z-index: 70;
}
.scrim.show { opacity: 1; visibility: visible; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 75;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--hairline);
  box-shadow: var(--shadow-sheet);
  transform: translateY(102%); transition: transform .36s cubic-bezier(.2,.9,.25,1);
  padding: 10px 18px calc(var(--safe-bottom) + 16px);
  max-height: 88%; overflow-y: auto;
}
.sheet.show { transform: none; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.22); margin: 4px auto 14px; }
.sheet h3 { font-size: 19px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.01em; }
.sheet .sheet-sub { font-size: 13.5px; color: var(--text-dim); line-height: 1.5; margin-bottom: 16px; }

/* audio player (review before submit / history) */
.player {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.05); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 12px 14px;
}
.player .play {
  width: 44px; height: 44px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
  background: var(--teal); color: #02141d;
}
.player .track { flex: 1; height: 5px; border-radius: 5px; background: rgba(255,255,255,.14); position: relative; overflow: hidden; }
.player .track > i { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: var(--teal-2); }
.player .time { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.cost-line {
  display: flex; align-items: center; gap: 10px;
  background: rgba(230,192,116,.10); border: 1px solid rgba(230,192,116,.26);
  border-radius: var(--r-md); padding: 13px 14px; margin: 14px 0;
}
.cost-line .ic { font-size: 18px; }
.cost-line .txt { flex: 1; font-size: 13px; line-height: 1.4; }
.cost-line .txt b { color: var(--gold-soft); }

/* ====================================================== loading / scoring */
.scoring { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; flex: 1; padding: 30px; text-align: center; }
.scoring .orb {
  width: 120px; height: 120px; border-radius: 999px; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(230,192,116,.22), transparent 70%);
}
.scoring .orb::before, .scoring .orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 999px;
  border: 2px solid transparent; border-top-color: var(--gold); animation: spin 1.4s linear infinite;
}
.scoring .orb::after { inset: 16px; border-top-color: var(--teal-2); animation-duration: 1.9s; animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.scoring .orb .glyph { font-size: 34px; filter: drop-shadow(0 0 10px var(--ai-glow)); }
.scoring .stage-txt { font-size: 15px; font-weight: 700; color: var(--gold-soft); min-height: 20px; }
.scoring .sub-txt { font-size: 12.5px; color: var(--text-faint); max-width: 250px; line-height: 1.5; }
.scoring .wave { margin-top: 4px; }
.leave-ok {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-dim); background: rgba(255,255,255,.05);
  border: 1px solid var(--hairline); padding: 9px 14px; border-radius: 999px;
}

/* ===================================================== result presentation */
.verdict-hero { padding: 18px 18px 6px; text-align: center; }
.score-ring { position: relative; width: 168px; height: 168px; margin: 6px auto 10px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .num b { font-size: 46px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.score-ring .num span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); margin-top: 4px; }
.verdict-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 800;
  padding: 7px 16px; border-radius: 999px; margin-bottom: 6px;
}
.verdict-pill.excellent, .verdict-pill.good { background: var(--correct-bg); color: var(--correct); }
.verdict-pill.needs_work { background: var(--khofiy-bg); color: var(--khofiy); }
.verdict-pill.incorrect { background: var(--jaliy-bg); color: var(--jaliy); }
.verdict-summary { font-size: 14.5px; color: var(--text-dim); line-height: 1.5; max-width: 320px; margin: 6px auto 0; }

.subscores { display: flex; gap: 10px; padding: 14px 18px; }
.subscore { flex: 1; background: var(--bg-1); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 13px 12px; text-align: center; }
.subscore b { font-size: 24px; font-weight: 800; }
.subscore .lab { font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); margin-top: 3px; }
.subscore .lab small { display: block; text-transform: none; letter-spacing: 0; font-size: 10px; color: var(--text-ghost); }
.sc-hi { color: var(--correct); } .sc-mid { color: var(--khofiy); } .sc-lo { color: var(--jaliy); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; padding: 4px 18px 10px; font-size: 11.5px; color: var(--text-dim); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend i.c { background: var(--correct); } .legend i.j { background: var(--jaliy); } .legend i.k { background: var(--khofiy); }

.review-block { padding: 0 18px; }
.review-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; letter-spacing: .02em; margin: 18px 0 9px; }
.review-title .tag { font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 7px; }
.review-title .tag.j { background: var(--jaliy); color: #2a0c0c; }
.review-title .tag.k { background: var(--khofiy); color: #2e1f06; }
.mistake {
  background: var(--bg-1); border: 1px solid var(--hairline); border-left: 3px solid var(--border);
  border-radius: var(--r-md); padding: 13px 14px; margin-bottom: 9px;
}
.mistake.j { border-left-color: var(--jaliy); }
.mistake.k { border-left-color: var(--khofiy); }
.mistake .head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mistake .word { font-family: var(--arabic); font-size: 22px; color: var(--quran); }
.mistake .rule { font-size: 12.5px; font-weight: 700; color: var(--khofiy); }
.mistake .exph { font-size: 12px; color: var(--text-dim); }
.mistake .exph b { color: var(--text); }
.mistake .note { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-top: 7px; }
.mistake .ex-pair { display: inline-flex; gap: 6px; align-items: center; font-family: var(--arabic); font-size: 17px; }
.mistake .ex-pair .exp { color: var(--correct); } .mistake .ex-pair .heard { color: var(--jaliy); }

.allgood {
  display: flex; align-items: center; gap: 10px; padding: 14px; margin: 6px 18px 0;
  background: var(--correct-bg); border: 1px solid rgba(69,201,138,.3); border-radius: var(--r-md);
  color: var(--correct); font-size: 14px; font-weight: 600;
}

/* AI disclaimer + Learn with teacher bridge */
.disclaimer {
  margin: 20px 18px 0; padding: 14px 15px; border-radius: var(--r-md);
  background: rgba(255,255,255,.04); border: 1px solid var(--hairline);
  font-size: 12.5px; color: var(--text-dim); line-height: 1.55; display: flex; gap: 10px;
}
.disclaimer .ic { font-size: 15px; flex: none; }
.disclaimer a { font-weight: 700; color: var(--gold-soft); text-decoration: underline; text-underline-offset: 2px; }
.teacher-bridge {
  margin: 12px 18px 0; padding: 16px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(52,179,228,.14), rgba(230,192,116,.10));
  border: 1px solid rgba(52,179,228,.28);
}
.teacher-bridge .tb-top { display: flex; align-items: center; gap: 11px; margin-bottom: 4px; }
.teacher-bridge .tb-ava { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.1); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.teacher-bridge h4 { margin: 0; font-size: 15px; font-weight: 800; }
.teacher-bridge p { margin: 2px 0 12px; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }

/* meta footer */
.result-meta { padding: 16px 18px; font-size: 11px; color: var(--text-ghost); text-align: center; line-height: 1.6; }
.result-meta code { background: rgba(0,0,0,.3); padding: 2px 6px; border-radius: 5px; color: var(--text-faint); }

/* ================================================================ history */
.summary-hero {
  margin: 6px 0 4px; padding: 18px; border-radius: var(--r-lg);
  background: var(--bg-1); border: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 16px;
}
.mini-ring { position: relative; width: 86px; height: 86px; flex: none; }
.mini-ring .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.mini-ring .num b { font-size: 19px; font-weight: 800; line-height: 1; }
.mini-ring .num span { font-size: 8.5px; color: var(--text-faint); }
.stat-col { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: rgba(255,255,255,.04); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 10px 12px; }
.stat b { font-size: 20px; font-weight: 800; }
.stat span { display: block; font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }

.hist-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; }
.hist-item .sc {
  width: 46px; height: 46px; border-radius: 12px; flex: none; font-weight: 800; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.hist-item .sc.hi { background: var(--correct-bg); color: var(--correct); }
.hist-item .sc.mid { background: var(--khofiy-bg); color: var(--khofiy); }
.hist-item .sc.lo { background: var(--jaliy-bg); color: var(--jaliy); }
.hist-item .sc.pending { background: rgba(230,192,116,.14); color: var(--gold-soft); font-size: 18px; }
.hist-item .meta { flex: 1; min-width: 0; }
.hist-item .meta .t { font-size: 14px; font-weight: 700; }
.hist-item .meta .d { font-size: 12px; color: var(--text-faint); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.hist-item .ar-mini { font-family: var(--arabic); font-size: 16px; color: var(--quran-dim); }

/* attempts table (existing style, modernised) */
.attempt-table { width: 100%; border-collapse: collapse; background: var(--bg-1); border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--hairline); }
.attempt-table th { background: var(--teal); color: #02141d; font-size: 12px; font-weight: 700; padding: 9px; }
.attempt-table td { text-align: center; padding: 11px; font-size: 14px; border-top: 1px solid var(--hairline); }
.attempt-table td.label { text-align: left; font-weight: 600; }

/* ================================================================ paywall */
.paywall { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* pinned footer so CTAs clear the home indicator and the legal/reassurance text is always visible */
.paywall-foot {
  flex: none; padding: 12px 18px calc(var(--safe-bottom) + 10px);
  background: linear-gradient(0deg, var(--bg-0) 72%, transparent);
  border-top: 1px solid var(--hairline);
}
.linkish { display: inline; font-size: inherit; color: var(--teal-2); padding: 0; }
.linkish:hover { text-decoration: underline; }
.paywall-hero { padding: 30px 22px 10px; text-align: center; }
.paywall-hero .crest {
  width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 14px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 36px;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold)); color: #3a2406;
  box-shadow: 0 14px 40px var(--ai-glow);
}
.paywall-hero h2 { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.paywall-hero p { font-size: 14px; color: var(--text-dim); line-height: 1.5; max-width: 300px; margin: 0 auto; }
.benefit { display: flex; gap: 12px; padding: 11px 4px; align-items: flex-start; }
.benefit .bi { width: 30px; height: 30px; border-radius: 9px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--teal-ghost); color: var(--teal-2); font-size: 15px; }
.benefit .bt { font-size: 14px; font-weight: 700; }
.benefit .bd { font-size: 12.5px; color: var(--text-faint); margin-top: 1px; line-height: 1.4; }
.plan {
  border: 1.5px solid var(--border); border-radius: var(--r-lg); padding: 15px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px; transition: .15s;
}
.plan.sel { border-color: var(--gold); background: rgba(230,192,116,.08); }
.plan .radio { width: 22px; height: 22px; border-radius: 999px; border: 2px solid var(--border-strong); flex: none; }
.plan.sel .radio { border-color: var(--gold); background: var(--gold); box-shadow: inset 0 0 0 4px var(--bg-1); }
.plan .pinfo { flex: 1; } .plan .pinfo .pt { font-size: 14.5px; font-weight: 700; } .plan .pinfo .pd { font-size: 12px; color: var(--text-faint); }
.plan .pprice { text-align: right; } .plan .pprice b { font-size: 16px; font-weight: 800; } .plan .pprice span { display: block; font-size: 10.5px; color: var(--text-faint); }
.plan .save { font-size: 10px; font-weight: 800; color: #02141d; background: var(--teal-2); padding: 2px 7px; border-radius: 6px; }

/* ============================================================ onboarding */
.onb { flex: 1; display: flex; flex-direction: column; }
.onb-art {
  flex: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.onb-illus {
  width: 230px; height: 230px; border-radius: 40px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 92px; position: relative;
  background: radial-gradient(circle at 50% 35%, rgba(230,192,116,.18), transparent 65%);
}
.onb-illus .halo { position: absolute; inset: 0; border-radius: 40px; box-shadow: 0 0 80px var(--ai-glow); }
.onb-copy { padding: 6px 28px 0; text-align: center; }
.onb-copy h2 { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 8px; }
.onb-copy p { font-size: 15px; color: var(--text-dim); line-height: 1.55; }
.onb-dots { display: flex; gap: 7px; justify-content: center; padding: 22px 0 14px; }
.onb-dots i { width: 7px; height: 7px; border-radius: 999px; background: rgba(255,255,255,.2); transition: .2s; }
.onb-dots i.on { width: 22px; background: var(--gold); }
.onb-foot { padding: 0 24px calc(var(--safe-bottom) + 10px); }

/* ============================================================== coachmark */
.coach-scrim { position: absolute; inset: 0; background: rgba(2,8,12,.72); z-index: 80; opacity: 0; visibility: hidden; transition: .25s; }
.coach-scrim.show { opacity: 1; visibility: visible; }
.coach {
  position: absolute; z-index: 82; max-width: 250px; padding: 14px 15px;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold)); color: #3a2406;
  border-radius: var(--r-md); box-shadow: 0 16px 40px rgba(0,0,0,.5);
  opacity: 0; visibility: hidden; transition: .25s; transform: translateY(6px);
}
.coach.show { opacity: 1; visibility: visible; transform: none; }
.coach h5 { margin: 0 0 4px; font-size: 14px; font-weight: 800; }
.coach p { margin: 0 0 11px; font-size: 12.5px; line-height: 1.45; font-weight: 500; }
.coach .arrow { position: absolute; width: 14px; height: 14px; background: var(--gold); transform: rotate(45deg); }
.coach .coach-actions { display: flex; align-items: center; justify-content: space-between; }
.coach .coach-actions .step { font-size: 11px; font-weight: 700; opacity: .7; }
.coach .coach-actions button { font-size: 13px; font-weight: 800; background: #3a2406; color: var(--gold-soft); padding: 6px 13px; border-radius: 9px; }

/* tooltip helper inline */
.helper-tip {
  display: flex; gap: 9px; align-items: flex-start; padding: 11px 13px; border-radius: var(--r-md);
  background: rgba(52,179,228,.10); border: 1px solid rgba(52,179,228,.26); margin: 0 0 4px;
}
.helper-tip .ic { color: var(--teal-2); font-size: 15px; }
.helper-tip .tx { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.helper-tip .x { color: var(--text-faint); font-size: 13px; }

/* ============================================================ toast/banner */
.toast {
  position: absolute; left: 12px; right: 12px; top: calc(var(--safe-top) + 4px); z-index: 90;
  display: flex; align-items: center; gap: 11px; padding: 12px 14px;
  background: linear-gradient(135deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); transform: translateY(calc(-100% - 72px)); transition: transform .4s cubic-bezier(.2,.9,.25,1);
}
.toast.show { transform: none; }
.toast .ico { width: 36px; height: 36px; border-radius: 10px; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; background: linear-gradient(135deg,var(--gold-soft),var(--gold)); color: #3a2406; }
.toast .tx { flex: 1; } .toast .tx b { font-size: 13.5px; font-weight: 700; display: block; } .toast .tx span { font-size: 12px; color: var(--text-dim); }
.toast .go { font-size: 12.5px; font-weight: 800; color: var(--teal-2); }

/* trial counter chip in nav */
.trial-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  padding: 5px 10px; border-radius: 999px; background: rgba(230,192,116,.14);
  color: var(--gold-soft); border: 1px solid rgba(230,192,116,.28);
}
.trial-chip.empty { background: rgba(239,100,97,.14); color: var(--jaliy); border-color: rgba(239,100,97,.3); }

/* generic helpers */
.center { text-align: center; }
.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mt20{margin-top:20px}.mt24{margin-top:24px}
.muted { color: var(--text-faint); }
.divider { height: 1px; background: var(--hairline); margin: 16px 0; }
.spacer { flex: 1; }
.fade-up { animation: fadeUp .5s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px);} to { opacity:1; transform:none; } }
.pop { animation: pop .4s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { transform: scale(.8); opacity: 0;} to { transform: scale(1); opacity: 1; } }

/* ====================================================================== RTL */
[dir="rtl"] .nav .title { text-align: center; }
[dir="rtl"] .row .chev { transform: scaleX(-1); }
[dir="rtl"] .mistake { border-left: 1px solid var(--hairline); border-right: 3px solid var(--border); }
[dir="rtl"] .mistake.j { border-right-color: var(--jaliy); }
[dir="rtl"] .mistake.k { border-right-color: var(--khofiy); }
[dir="rtl"] .toast .go, [dir="rtl"] .row .body { direction: rtl; }
[dir="rtl"] .back-chev { transform: scaleX(-1); display: inline-block; }
/* numeric / code runs stay LTR so digits + separators don't bidi-reorder in RTL */
.player .time, .rec-timer, .page-dots .pill, .result-meta code, .score-ring .num b, .subscore b, .hist-item .sc, .mini-ring .num, .stat b { direction: ltr; unicode-bidi: isolate; }
