/* My First Salat — midnight & gold, with a Soft Blend indigo night (dark) and an
   Orchid Grain dawn (light). Tokens follow the owner's design language. */

:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --page: #050506; --surface-1: #0e0e12; --surface-2: #15151b; --surface-3: #1e1e26; --surface-4: #282832;
  --line-subtle: rgba(255,255,255,.07); --line: rgba(255,255,255,.11); --line-strong: rgba(255,255,255,.19);
  --text: #f3f3f1; --text-2: #cfcfca; --text-muted: #a3a39e; --text-disabled: #5c5c59;
  --gold: #d1ae68; --gold-hover: #ddbd7e; --gold-press: #bf9a52; --gold-soft: rgba(209,174,104,.13); --gold-line: rgba(209,174,104,.4); --on-gold: #17120a;
  --success: #6cc495; --success-soft: rgba(108,196,149,.13); --success-line: rgba(108,196,149,.34);
  --review: #f0954a; --review-soft: rgba(240,149,74,.12); --review-line: rgba(240,149,74,.34);
  --focus: #e9cb85;
  --elev-1: inset 0 1px 0 rgba(255,255,255,.05), 0 0 0 1px var(--line-subtle);
  --elev-2: inset 0 1px 0 rgba(255,255,255,.06), 0 0 0 1px var(--line-subtle), 0 14px 32px -16px rgba(0,0,0,.9);
  --elev-3: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 1px var(--line-strong), 0 28px 60px -20px rgba(0,0,0,.95);
  --glass: rgba(14,14,20,.72);
  /* Soft Blend (pryzm.design) — a calm indigo night with a gold lamp glow. */
  --page-bg:
    radial-gradient(560px 440px at 100% 0%, rgb(80 66 200 / .22), transparent 70%),
    radial-gradient(380px 320px at 0% 0%, rgb(122 106 184 / .12), transparent 70%),
    radial-gradient(640px 520px at 0% 100%, rgb(32 27 69 / .6), transparent 72%),
    radial-gradient(520px 360px at 60% 110%, rgb(209 174 104 / .07), transparent 70%),
    #050506;
  /* Pewter Fade (pryzm.design), warm bloom swapped for gold. */
  --hero-bg:
    radial-gradient(420px 340px at 0% 0%, rgb(106 131 182 / .26), transparent 70%),
    radial-gradient(360px 300px at 100% 100%, rgb(209 174 104 / .2), transparent 70%),
    #0e0e12;
  --stage-bg: radial-gradient(120% 90% at 50% 100%, rgb(209 174 104 / .08), transparent 60%), linear-gradient(180deg, #0b0a1c 0%, #121031 55%, #17143a 100%);
  --ornament: .06;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f6f2e9; --surface-1: #fffdf8; --surface-2: #f1ebdf; --surface-3: #e8dfcd; --surface-4: #ffffff;
  --line-subtle: rgba(28,26,22,.07); --line: rgba(28,26,22,.12); --line-strong: rgba(28,26,22,.2);
  --text: #1c1a16; --text-2: #48433a; --text-muted: #625b4e; --text-disabled: #a39c8e;
  --gold: #735719; --gold-hover: #5f4813; --gold-press: #4e3b10; --gold-soft: rgba(176,138,62,.14); --gold-line: rgba(115,87,25,.4); --on-gold: #fffdf8;
  --success: #256845; --success-soft: rgba(37,104,69,.09); --success-line: rgba(37,104,69,.3);
  --review: #94480b; --review-soft: rgba(148,72,11,.08); --review-line: rgba(148,72,11,.3);
  --focus: #7a5c1a;
  --elev-1: 0 1px 2px rgba(28,26,22,.05), 0 0 0 1px var(--line-subtle);
  --elev-2: 0 1px 2px rgba(28,26,22,.06), 0 0 0 1px var(--line-subtle), 0 12px 28px -16px rgba(28,26,22,.28);
  --elev-3: 0 0 0 1px var(--line), 0 28px 56px -20px rgba(28,26,22,.32);
  --glass: rgba(255,253,248,.8);
  /* Orchid Grain (pryzm.design) — soft Fajr dawn on warm paper. */
  --page-bg:
    radial-gradient(520px 420px at 100% 0%, rgb(217 186 207 / .40), transparent 70%),
    radial-gradient(480px 400px at 0% 100%, rgb(138 127 214 / .14), transparent 70%),
    radial-gradient(600px 300px at 50% 100%, rgb(235 194 154 / .35), transparent 70%),
    #f6f2e9;
  --hero-bg:
    radial-gradient(420px 340px at 0% 0%, rgb(217 186 207 / .45), transparent 70%),
    radial-gradient(360px 300px at 100% 100%, rgb(235 194 154 / .45), transparent 70%),
    #fffdf8;
  --stage-bg: radial-gradient(120% 80% at 50% 0%, rgb(255 255 255 / .55), transparent 60%), linear-gradient(180deg, #e9dcef 0%, #f3dfd2 55%, #f7e7d3 100%);
  --ornament: .09;
}
:root {
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-italic: "Instrument Serif", "Fraunces", Georgia, serif;
  --font-ar: "Amiri", "Noto Naskh Arabic", "Geeza Pro", serif;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 26px; --r-full: 999px;
  --topbar-h: 64px;
  --ease-out: cubic-bezier(.16,1,.3,1); --ease-drawer: cubic-bezier(.32,.72,0,1); --spring-sm: cubic-bezier(.3,1.35,.4,1);
  --t-press: 100ms; --t-hover: 150ms; --t-state: 200ms; --t-panel: 320ms; --t-sheet: 420ms;
  --gutter: max(16px, env(safe-area-inset-left));
  --girih: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cg fill='none' stroke='%23000' stroke-width='.8'%3E%3Crect x='12' y='12' width='24' height='24'/%3E%3Crect x='12' y='12' width='24' height='24' transform='rotate(45 24 24)'/%3E%3Cpath d='M0 24h7M41 24h7M24 0v7M24 41v7'/%3E%3C/g%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--page); -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--page-bg); background-attachment: fixed; color: var(--text);
  font: 400 1rem/1.55 var(--font-ui); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; flex: none; }
h1, h2, p { margin: 0; }
a { color: var(--gold); text-underline-offset: .2em; text-decoration-color: var(--gold-line); }
:lang(ar) { font-family: var(--font-ar); }

/* ── Buttons ── */
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); font-size: .9375rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color var(--t-hover), border-color var(--t-hover), color var(--t-hover), scale var(--t-press) var(--ease-out), box-shadow var(--t-hover); touch-action: manipulation; }
button:hover:not(:disabled) { background-color: var(--surface-3); }
button:active:not(:disabled) { scale: .96; }
button:disabled { cursor: not-allowed; color: var(--text-disabled); border-color: var(--line-subtle); background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--gold-soft); color: var(--text); }
.btn-icon { width: 44px; padding: 0; background: transparent; border-color: transparent; color: var(--text-2); }
.btn-icon:hover:not(:disabled) { background: var(--gold-soft); color: var(--text); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .8125rem; }
.btn-sm svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.btn-gold {
  position: relative; display: inline-grid; padding: 0 22px; border-color: transparent; color: var(--on-gold); font-weight: 700;
  background-color: var(--gold);
  background-image: linear-gradient(180deg, rgb(255 255 255 / .18), transparent 55%);
  box-shadow: 0 10px 24px -10px rgb(209 174 104 / .65), inset 0 1px 0 rgb(255 255 255 / .35);
}
.btn-gold:hover:not(:disabled) { background-color: var(--gold-hover); translate: 0 -1px; }
.btn-gold:active:not(:disabled) { background-color: var(--gold-press); translate: 0 1px; box-shadow: 0 4px 12px -8px rgb(209 174 104 / .6); }
.btn-gold:disabled { background-color: var(--surface-2); background-image: none; box-shadow: none; color: var(--text-disabled); border-color: var(--line-subtle); }
.btn-gold .btn-state { grid-area: 1 / 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: opacity 180ms var(--ease-out), translate 180ms var(--ease-out); }
.btn-gold .btn-state[data-for] { opacity: 0; translate: 0 6px; pointer-events: none; }
.btn-gold[data-state="idle"] .btn-state[data-for="idle"], .btn-gold[data-state="busy"] .btn-state[data-for="busy"], .btn-gold[data-state="paused"] .btn-state[data-for="paused"], .btn-gold[data-state="done"] .btn-state[data-for="done"] { opacity: 1; translate: 0 0; }
.btn-big { min-height: 56px; padding: 0 28px; font-size: 1.0625rem; border-radius: var(--r-lg); }
.btn-big svg { width: 22px; height: 22px; }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--gutter) 0;
  background: color-mix(in srgb, var(--page) 78%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line-subtle);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; margin-right: auto; min-width: 0; }
.brand-mark { width: 30px; height: 30px; color: var(--gold); }
.brand-name { font: 500 1.28rem/1 var(--font-display); font-variation-settings: "opsz" 48; letter-spacing: -.01em; white-space: nowrap; }
.brand-name em { font: italic 400 1.18em/1 var(--font-italic); color: var(--gold); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.stars { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px 0 10px; border-radius: var(--r-full); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold-line); color: var(--gold); font: 700 .9375rem/1 var(--font-ui); font-variant-numeric: tabular-nums; }
.stars svg { width: 18px; height: 18px; }
.stars.bump svg { animation: star-pop 520ms var(--spring-sm); }
@keyframes star-pop { 0% { scale: 1; } 40% { scale: 1.45; rotate: 18deg; } 100% { scale: 1; rotate: 0deg; } }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; overflow: hidden; }
.progress i { display: block; height: 100%; width: 100%; transform-origin: 0 50%; scale: 0 1; background: linear-gradient(90deg, var(--gold-press), var(--gold), var(--gold-hover)); box-shadow: 0 0 12px rgb(209 174 104 / .6); transition: scale 500ms var(--ease-out); }

/* Segmented controls with a gliding pill. */
.seg { position: relative; display: inline-flex; align-items: center; gap: 2px; padding: 4px; border-radius: var(--r-full); background: var(--surface-1); box-shadow: var(--elev-1); }
.seg button { position: relative; z-index: 1; min-height: 34px; padding: 0 14px; border: 0; background: transparent; border-radius: var(--r-full); color: var(--text-2); font-weight: 650; font-size: .875rem; }
.seg button:hover:not(:disabled) { background: transparent; color: var(--text); }
.seg button[aria-checked="true"] { color: var(--text); }
.seg-label { padding: 0 6px 0 10px; font-size: .6875rem; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.seg-pill { position: absolute; top: 4px; left: 0; height: calc(100% - 8px); width: 0; border-radius: var(--r-full); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--gold-line); opacity: 0; pointer-events: none; }
.seg-pill.is-set { opacity: 1; }
.seg-pill.glide { transition: translate 300ms var(--ease-out), width 300ms var(--ease-out), opacity var(--t-state); }
.rakat-seg button { min-width: 40px; padding: 0; font: 600 1rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.rakat-seg button[aria-checked="true"] { color: var(--gold); }

/* ── App layout ── */
.app { display: grid; grid-template-columns: minmax(0, 7fr) minmax(360px, 5fr); gap: 20px; padding: 20px var(--gutter) 20px; height: calc(100svh - var(--topbar-h) - env(safe-area-inset-top)); min-height: 520px; }

.stage { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-radius: var(--r-xl); background: var(--surface-1); box-shadow: var(--elev-2); isolation: isolate; }
/* Labels sit in a strip above the 3D view so nothing ever covers the child. */
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 12px; }
.stage-view { position: relative; flex: 1; min-height: 0; margin: 0 6px 6px; overflow: hidden; border-radius: calc(var(--r-xl) - 6px); background: var(--stage-bg); }
.stage-view::before, .stage-view::after { content: ""; position: absolute; z-index: 2; width: 22px; height: 22px; border: 1.5px solid var(--gold-line); pointer-events: none; }
.stage-view::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.stage-view::after { right: 10px; bottom: 10px; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }
.stage-chip { display: inline-flex; align-items: baseline; gap: 10px; min-width: 0; white-space: nowrap; }
.stage-chip span { font-size: .6875rem; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.stage-chip span { flex: none; }
.stage-chip b { font: 500 1.0625rem/1.2 var(--font-display); overflow: hidden; text-overflow: ellipsis; }
.view-seg { flex: none; }
.view-seg button { min-height: 32px; padding: 0 12px; font-size: .8125rem; }
.view-seg svg { width: 16px; height: 16px; }
.loading { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: var(--stage-bg); transition: opacity 400ms var(--ease-out); }
.loading.gone { opacity: 0; pointer-events: none; }
.loader-dots { display: inline-flex; gap: 8px; }
.loader-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); opacity: .3; animation: dot 1.2s var(--ease-out) infinite; }
.loader-dots i:nth-child(2) { animation-delay: .15s; } .loader-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { opacity: 1; translate: 0 -5px; } }

/* ── Lesson panel ── */
.panel { position: relative; display: flex; flex-direction: column; min-height: 0; border-radius: var(--r-xl); background: var(--surface-1); box-shadow: var(--elev-2); overflow: hidden; }
.panel::after { content: ""; position: absolute; top: -80px; right: -80px; width: 260px; height: 260px; pointer-events: none; opacity: var(--ornament); background: var(--gold); -webkit-mask: var(--girih) center / 48px 48px, radial-gradient(closest-side, #000, transparent); -webkit-mask-composite: source-in; mask: var(--girih) center / 48px 48px, radial-gradient(closest-side, #000, transparent); mask-composite: intersect; }
.panel-scroll { position: relative; z-index: 1; flex: 1; min-height: 0; overflow-y: auto; padding: 26px 26px 20px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
.eyebrow { margin: 0 0 10px; font-size: .75rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-variant-numeric: tabular-nums; }
.step-title { font: 450 clamp(1.9rem, 3vw, 2.6rem)/1.08 var(--font-display); font-variation-settings: "opsz" 144; letter-spacing: -.02em; }
.step-title em { display: block; margin-top: 4px; font: italic 400 .62em/1.15 var(--font-italic); letter-spacing: 0; color: var(--gold); }
.do-card { display: flex; gap: 14px; align-items: flex-start; margin: 18px 0 0; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--elev-1); }
.do-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--gold-soft); color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-line); }
.do-icon svg { width: 22px; height: 22px; }
.do-card p { font-size: 1.0625rem; line-height: 1.5; color: var(--text); padding-top: 1px; }

.show-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 14px; }
.toggle { min-height: 38px; padding: 0 14px 0 6px; border-radius: var(--r-full); background: transparent; border-color: var(--line); color: var(--text-muted); font-size: .875rem; }
.toggle .t-glyph { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border-radius: var(--r-full); background: var(--surface-3); font: 700 .75rem/1 var(--font-ui); color: var(--text-muted); }
.toggle .t-glyph[lang="ar"] { font: 700 1.05rem/1 var(--font-ar); padding-bottom: 3px; }
.toggle[aria-pressed="true"] { color: var(--text); border-color: var(--gold-line); background: var(--gold-soft); }
.toggle[aria-pressed="true"] .t-glyph { background: var(--gold); color: var(--on-gold); }
.toggle:hover:not(:disabled) { background-color: var(--gold-soft); }

.recite-list { display: grid; gap: 12px; }
.recite { position: relative; padding: 16px 18px 18px; border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--elev-1); transition: box-shadow var(--t-state); }
.recite.is-cue { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); padding: 10px 14px 10px 16px; }
.recite.is-cue .recite-head { grid-column: 1 / -1; margin-bottom: 4px; }
.recite.is-cue .ar { grid-column: 2; grid-row: 2; font-size: 1.6rem; line-height: 1.5; }
.recite.is-cue .tr { grid-column: 1; grid-row: 2; margin: 0; }
.recite.is-cue .en { grid-column: 1 / -1; margin-top: 2px; font-size: .875rem; }
.recite.is-playing { box-shadow: var(--elev-1), 0 0 0 1.5px var(--gold), 0 12px 30px -16px rgb(209 174 104 / .55); }
.recite-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.recite-name { font-size: .75rem; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.recite-tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-full); background: var(--surface-3); font-size: .75rem; font-weight: 600; color: var(--text-2); }
.times { display: inline-flex; gap: 5px; margin-left: 2px; }
.times i { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-4); box-shadow: inset 0 0 0 1px var(--line-strong); transition: background-color var(--t-state), box-shadow var(--t-state), scale var(--t-state) var(--spring-sm); }
.times i.on { background: var(--gold); box-shadow: none; scale: 1.15; }
.recite-play { margin-left: auto; width: 40px; min-height: 40px; padding: 0; border-radius: 50%; background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }
.recite-play:hover:not(:disabled) { background: var(--gold); color: var(--on-gold); }
.recite-play svg { width: 18px; height: 18px; }
.recite.is-playing .recite-play { background: var(--gold); color: var(--on-gold); }
/* Per-recitation play/pause + replay */
.recite-btns { display: inline-flex; gap: 6px; margin-left: auto; }
.recite-btn { position: relative; width: 40px; min-height: 40px; padding: 0; border-radius: 50%; background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }
.recite-btn:hover:not(:disabled) { background: var(--gold); color: var(--on-gold); }
.recite-btn:active:not(:disabled) { scale: .94; }
.recite-btn svg { width: 18px; height: 18px; }
.recite-replay { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.recite-replay svg { width: 17px; height: 17px; }
.recite-toggle .i-on-pause { display: none; }
.recite[data-state="playing"] .recite-toggle { background: var(--gold); color: var(--on-gold); }
.recite[data-state="playing"] .recite-toggle .i-on-play { display: none; }
.recite[data-state="playing"] .recite-toggle .i-on-pause { display: block; }
.recite[data-state="paused"] { box-shadow: var(--elev-1), 0 0 0 1.5px var(--gold-line); }
.recite[data-state="paused"] .recite-toggle { box-shadow: 0 0 0 3px var(--gold-soft); }
.recite[data-state="paused"] .recite-tag::after { content: "Paused"; margin-left: 4px; padding-left: 8px; border-left: 1px solid var(--line-strong); color: var(--gold); }
.recite.is-cue .recite-btn { width: 40px; min-height: 40px; }
/* Skip to Qa‘dah */
.skip-btn { width: 100%; justify-content: flex-start; gap: 10px; margin-top: 10px; min-height: 46px; padding: 0 16px 0 12px; border-radius: var(--r-lg); background: transparent; border-color: var(--gold-line); color: var(--text); font-size: .9375rem; }
.skip-btn svg { flex: none; width: 20px; height: 20px; color: var(--gold); }
.skip-btn small { margin-left: auto; overflow: hidden; text-overflow: ellipsis; font-size: .8125rem; font-weight: 500; color: var(--text-muted); }
.skip-btn:hover:not(:disabled) { background: var(--gold-soft); }
.skip-btn:active:not(:disabled) { scale: .98; }
.skip-btn[hidden] { display: none; }
.ar { direction: rtl; text-align: right; font: 400 clamp(1.6rem, 2.4vw, 2rem)/2 var(--font-ar); color: var(--text); unicode-bidi: plaintext; }
.ar .ph, .tr .ph { border-radius: 6px; transition: color var(--t-state), background-color var(--t-state); }
.ar .ph { padding: 0 2px; }
.ph.on { color: var(--gold); background: linear-gradient(transparent 62%, var(--gold-soft) 62%); }
.tr { margin-top: 6px; font: 600 1.125rem/1.55 var(--font-ui); color: var(--text); letter-spacing: .005em; }
.en { margin-top: 8px; font-size: .9875rem; line-height: 1.55; color: var(--text-muted); }
.after-line { display: flex; align-items: baseline; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.after-line .ar { font-size: 1.5rem; line-height: 1.4; }
.after-line .tr { margin: 0; }
.after-line .en { margin: 0; font-size: .875rem; }
.recite-list[data-hide-ar] .ar, .recite-list[data-hide-tr] .tr, .recite-list[data-hide-en] .en { display: none; }
.no-words { padding: 22px 18px; border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--elev-1); color: var(--text-2); font-size: .9875rem; text-align: center; }
.no-words b { display: block; margin-bottom: 4px; font: italic 400 1.4rem/1.2 var(--font-italic); color: var(--gold); }

/* Controls */
.controls { position: relative; z-index: 2; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-subtle); background: color-mix(in srgb, var(--surface-1) 94%, transparent); }
.ctl-side { min-height: 52px; padding: 0 16px; border-radius: var(--r-lg); }
.ctl-side svg { width: 22px; height: 22px; }
.ctl-mid { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ctl-play { min-height: 56px; min-width: 170px; border-radius: var(--r-lg); font-size: 1.0625rem; }
.ctl-play svg { width: 22px; height: 22px; }
.steps-btn { position: absolute; left: 50%; top: -18px; translate: -50% 0; min-height: 32px; padding: 0 12px; border-radius: var(--r-full); font-size: .8125rem; font-variant-numeric: tabular-nums; color: var(--text-2); background: var(--surface-2); box-shadow: var(--elev-2); }
.steps-btn svg { width: 16px; height: 16px; }
.auto { display: inline-flex; align-items: center; gap: 8px; font-size: .8125rem; font-weight: 600; color: var(--text-muted); cursor: pointer; user-select: none; }
.auto input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; width: 34px; height: 20px; border-radius: var(--r-full); background: var(--surface-4); box-shadow: inset 0 0 0 1px var(--line-strong); transition: background-color var(--t-state); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: translate var(--t-state) var(--ease-out), background-color var(--t-state); }
.auto input:checked + .switch { background: var(--gold); box-shadow: none; }
.auto input:checked + .switch::after { translate: 14px 0; background: var(--on-gold); }
.auto input:focus-visible + .switch { outline: 2px solid var(--focus); outline-offset: 2px; }
.auto:has(input:checked) { color: var(--gold); }

/* ── Quiz ── */
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quiz-head .eyebrow { margin: 0; }
.quiz .step-title { margin-top: 12px; }
.quiz-ask { margin-top: 12px; font-size: 1.0625rem; color: var(--text-2); }
.quiz-dots { display: flex; gap: 6px; margin: 16px 0 18px; }
.quiz-dots i { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-3); transition: background-color var(--t-state); }
.quiz-dots i.on { background: var(--gold); } .quiz-dots i.cur { background: var(--gold-line); }
.quiz-options { display: grid; gap: 10px; }
.opt { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 14px 14px 14px 18px; border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--elev-1); text-align: left; cursor: pointer; transition: box-shadow var(--t-state), background-color var(--t-state), translate var(--t-press); }
.opt:hover { background: var(--surface-3); }
.opt:active { translate: 0 1px; }
.opt .tr { margin: 0; font-size: 1.0625rem; }
.opt .en { margin-top: 2px; font-size: .875rem; }
.opt.right { box-shadow: 0 0 0 2px var(--success), var(--elev-1); background: var(--success-soft); }
.opt.wrong { box-shadow: 0 0 0 1.5px var(--review-line); animation: nudge 360ms var(--ease-out); }
@keyframes nudge { 25% { translate: -6px 0; } 60% { translate: 5px 0; } }
.opt .recite-play { margin: 0; }
.quiz-feedback { min-height: 1.6em; margin-top: 14px; font: italic 400 1.5rem/1.3 var(--font-italic); color: var(--gold); text-align: center; }
.quiz-controls { grid-template-columns: 1fr; justify-items: center; }

/* ── Overlays ── */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) var(--gutter) max(16px, env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--page) 55%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow-y: auto; }
.overlay.leaving { animation: fade-out 260ms var(--ease-out) forwards; }
@keyframes fade-out { to { opacity: 0; } }
.hero-card { position: relative; width: min(560px, 100%); padding: 38px 36px 30px; border-radius: var(--r-xl); background: var(--hero-bg); box-shadow: var(--elev-3); overflow: hidden; text-align: center; }
.hero-ornament { position: absolute; top: -90px; right: -90px; width: 300px; height: 300px; color: var(--gold); opacity: .035; }
.hero-card .eyebrow { margin-bottom: 12px; }
.hero-card h1 { font: 400 clamp(2.2rem, 6vw, 3.2rem)/1.04 var(--font-display); font-variation-settings: "opsz" 144; letter-spacing: -.025em; }
.hero-card h1 em { font: italic 400 1.12em/1 var(--font-italic); letter-spacing: 0; color: var(--gold); }
.hero-sub { max-width: 40ch; margin: 14px auto 0; color: var(--text-2); font-size: 1.0625rem; }
.steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 22px 0 0; padding: 0; list-style: none; }
.steps li { display: inline-flex; align-items: center; gap: 9px; padding: 7px 14px 7px 7px; border-radius: var(--r-full); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: .875rem; color: var(--text-2); }
.steps b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font-size: .75rem; }
.hero-q { margin: 26px 0 10px; font-size: .75rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); }
.prayer-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.prayer-pick button { display: grid; justify-items: center; gap: 2px; min-height: 96px; padding: 12px 8px; border-radius: var(--r-lg); background: var(--surface-2); border-color: var(--line); white-space: normal; }
.prayer-pick b { font: 500 2rem/1 var(--font-display); color: var(--text); }
.prayer-pick span { font-size: .8125rem; color: var(--text-2); }
.prayer-pick small { font-size: .75rem; color: var(--text-muted); line-height: 1.3; }
.prayer-pick button[aria-checked="true"] { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 1px var(--gold) inset; }
.prayer-pick button[aria-checked="true"] b { color: var(--gold); }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.hero-actions .btn-gold { min-width: 200px; }
.credit { margin-top: 20px; font-size: .75rem; color: var(--text-muted); }
.credit a, .link-btn { color: inherit; }
.link-btn { padding: 0; border: 0; background: none; font: inherit; text-decoration: underline; cursor: pointer; }
.credits ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.credits li { font-size: .9375rem; line-height: 1.5; color: var(--text-muted); }
.credits li a { color: var(--text); font-weight: 600; text-decoration-color: var(--gold-line); text-underline-offset: 3px; }
.done-card h1 { font-size: clamp(3rem, 9vw, 4.4rem); }
.done-stars { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; padding: 8px 18px; border-radius: var(--r-full); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold-line); color: var(--gold); font-weight: 700; font-size: 1.125rem; }
.done-stars svg { width: 24px; height: 24px; }
.burst { position: absolute; left: 50%; top: 38%; width: 0; height: 0; }
.burst i { position: absolute; width: 14px; height: 14px; margin: -7px; background: var(--gold); -webkit-mask: radial-gradient(circle, #000 0 0) ; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); opacity: 0; }
.overlay:not([hidden]) .burst i { animation: burst 1100ms var(--ease-out) backwards; animation-delay: calc(var(--i) * 40ms + 150ms); }
.burst i:nth-child(1) { --i: 0; --a: 0deg; } .burst i:nth-child(2) { --i: 1; --a: 45deg; } .burst i:nth-child(3) { --i: 2; --a: 90deg; } .burst i:nth-child(4) { --i: 3; --a: 135deg; }
.burst i:nth-child(5) { --i: 4; --a: 180deg; } .burst i:nth-child(6) { --i: 5; --a: 225deg; } .burst i:nth-child(7) { --i: 6; --a: 270deg; } .burst i:nth-child(8) { --i: 7; --a: 315deg; }
@keyframes burst { 0% { opacity: 0; transform: rotate(var(--a)) translateY(0) scale(.3); } 25% { opacity: 1; } 100% { opacity: 0; transform: rotate(var(--a)) translateY(-150px) scale(1.1); } }

/* ── Steps sheet ── */
.sheet { width: min(720px, calc(100vw - 32px)); max-height: min(80svh, 760px); padding: 0; border: 0; border-radius: var(--r-xl); background: var(--surface-1); color: var(--text); box-shadow: var(--elev-3); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; }
.sheet::backdrop { background: rgb(0 0 0 / .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet-grab { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px 24px; }
.sheet-head h2 { font: 500 1.5rem/1.2 var(--font-display); }
.sheet-body { overflow-y: auto; padding: 0 24px 24px; overscroll-behavior: contain; }
.sheet-group { margin-top: 16px; }
.sheet-group h3 { margin: 0 0 10px; font-size: .75rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px 0 6px; border-radius: var(--r-full); background: var(--surface-2); border-color: var(--line); font-size: .875rem; font-weight: 600; color: var(--text-2); }
.chip b { display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: var(--r-full); background: var(--surface-3); font-size: .75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chip.done b { background: var(--gold-soft); color: var(--gold); }
.chip.done b::before { content: "★"; font-size: .8rem; }
.chip.done b span { display: none; }
.chip[aria-current="step"] { border-color: var(--gold); color: var(--text); background: var(--gold-soft); }
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: sheet-in var(--t-sheet) var(--ease-drawer) backwards; }
  @keyframes sheet-in { from { translate: 0 24px; opacity: 0; } }
  .hero-card { animation: rise 600ms var(--ease-out) backwards; }
  @keyframes rise { from { translate: 0 18px; opacity: 0; scale: .98; } }
  .panel-scroll > * { animation: enter 420ms var(--ease-out) backwards; }
  .fresh .panel-scroll > :nth-child(2) { animation-delay: 30ms; } .fresh .panel-scroll > :nth-child(3) { animation-delay: 60ms; } .fresh .panel-scroll > :nth-child(5) { animation-delay: 100ms; }
}
@keyframes enter { from { opacity: 0; translate: 0 8px; } }

/* ── Tablet portrait and narrow windows: stack ── */
@media (max-width: 900px), (orientation: portrait) and (max-width: 1100px) {
  .app { --stage-h: 46svh; grid-template-columns: minmax(0, 1fr); grid-template-rows: max(260px, var(--stage-h)) auto; height: auto; min-height: 0; padding-bottom: 0; }
  /* Keep the child in view while the words scroll underneath. */
  .stage { position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top) + 10px); z-index: 6; box-shadow: var(--elev-2), 0 -14px 0 4px var(--page); }
  .recite { scroll-margin-top: calc(var(--topbar-h) + max(260px, var(--stage-h)) + 30px); scroll-margin-bottom: 140px; }
  .panel { overflow: visible; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .panel-scroll { overflow: visible; padding-bottom: 130px; }
  .controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding-left: var(--gutter); padding-right: var(--gutter); background: var(--surface-1); box-shadow: 0 -12px 30px -18px rgb(0 0 0 / .6); }
  .panel::after { display: none; }
}
/* ── Phones ── */
@media (max-width: 640px) {
  :root { --topbar-h: 56px; }
  .brand-name { font-size: 1.12rem; }
  .brand-mark { width: 26px; height: 26px; }
  .topbar { gap: 8px; }
  .topbar .rakat-seg { display: none; }
  .quiz-btn span { display: none; }
  .quiz-btn { width: 44px; padding: 0; }
  .app { --stage-h: 46svh; gap: 12px; padding: 12px var(--gutter) 0; }
  .stage { border-radius: var(--r-lg); }
  .panel { border-radius: var(--r-lg) var(--r-lg) 0 0; margin: 0 calc(-1 * var(--gutter)); }
  .panel-scroll { padding: 22px var(--gutter) 140px; }
  .stage-bar { padding: 6px 6px 6px 12px; }
  .stage-chip { gap: 8px; }
  .stage-chip b { font-size: .9375rem; }
  .view-seg button { padding: 0 9px; }
  .view-seg button span { display: none; }
  .controls { gap: 8px; padding-top: 22px; }
  .ctl-side { width: 56px; padding: 0; }
  .ctl-side span { display: none; }
  .ctl-play { min-width: 0; width: 100%; max-width: 220px; }
  .do-card p { font-size: 1rem; }
  .recite-head { flex-wrap: wrap; row-gap: 6px; }
  .hero-card { padding: 30px 20px 24px; }
  .prayer-pick { gap: 8px; }
  .prayer-pick button { min-height: 88px; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 86svh; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet-grab { display: block; width: 40px; height: 5px; margin: 10px auto 0; border-radius: 3px; background: var(--line-strong); }
  .sheet-head { padding: 8px 12px 6px 20px; }
  .sheet-body { padding: 0 20px 20px; }
}
@media (max-width: 360px) {
  .brand-name { display: none; }
  .prayer-pick small { display: none; }
}
/* ── Short landscape (phones on their side) ── */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --topbar-h: 48px; }
  .topbar .rakat-seg .seg-label { display: none; }
  .app { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: none; height: calc(100svh - var(--topbar-h)); min-height: 0; gap: 10px; padding: 8px var(--gutter) 8px; }
  .panel { overflow: hidden; border-radius: var(--r-lg); margin: 0; }
  .panel-scroll { overflow-y: auto; padding: 14px 16px 12px; }
  .controls { position: relative; padding: 10px 12px; box-shadow: none; }
  .ctl-play { min-height: 46px; min-width: 0; }
  .ctl-side { min-height: 46px; width: 50px; padding: 0; }
  .ctl-side span, .auto span:last-child { display: none; }
  .steps-btn { top: -14px; }
  .step-title { font-size: 1.6rem; }
  .stage { border-radius: var(--r-lg); }
  .hero-card { padding: 20px; }
  .hero-card .steps, .hero-sub { display: none; }
}
@media (min-width: 901px) and (max-height: 700px) {
  .app { padding-top: 14px; padding-bottom: 14px; gap: 14px; }
  .panel-scroll { padding: 20px 22px 16px; }
  .step-title { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: 1ms !important; }
  .burst { display: none; }
  .loader-dots i { opacity: 1; }
}
@media (forced-colors: active) {
  .ph.on { outline: 2px solid Highlight; }
  .recite.is-playing, .recite[data-state] { outline: 2px solid Highlight; }
}
