:root {
  --green: #0B5A43;
  --green-d: #08402F;
  --green-l: #E6F2EC;
  --ink: #10231C;
  --muted: #4E5F58;
  --line: #D5DDD9;
  --line-2: #7E928A;
  --bg: #F4F7F5;
  --card: #FFFFFF;
  --paper: #FFFDF7;
  --gold: #D9BF7A;
  --gold-d: #7A5C14;
  --gold-ring: #B08D3C;
  --band-les: #E1F0E7;
  --band-cur: #F6E8BC;
  --band-hid: #DCE5E0;
  --red: #B42318;
  --red-bg: #FDECEC;
  --amber: #8A4B06;
  --amber-bg: #FDF1E2;
  --blue: #1B4F80;
  --blue-bg: #E5EEF8;
  --radius: 14px;
  --tabh: 64px;
  --ui: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ur: 'Noto Nastaliq Urdu', serif;
  --q-madani: 'Amiri Quran', 'Amiri', serif;
  --q-indopak: 'Noto Naskh Arabic', serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--ui); -webkit-tap-highlight-color: transparent; }
body.ur { font-family: var(--ur); font-size: 15px; line-height: 2.05; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #1F6FD1; outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
#view { padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--tabh) + env(safe-area-inset-bottom) + 28px); outline: none; }
body.no-tabs #view { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }
.boot { padding: 40vh 16px 0; text-align: center; color: var(--muted); font-weight: 600; }

.screen { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 0.87em; }
.note { color: var(--muted); font-size: 0.87em; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.ur-font { font-family: var(--ur); line-height: 2; }
.en-font { font-family: var(--ui); line-height: 1.45; }
body.ur .flip { transform: scaleX(-1); }

/* Header bar */
.bar { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.bar h1 { font-size: 1.15em; font-weight: 700; flex: 1; min-width: 0; }
.bar .sub { display: block; font-size: 0.82em; font-weight: 500; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; margin: 0; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink); }
.icon-btn:active { background: var(--line); }

/* Buttons */
.btn { min-height: 48px; margin: 0; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; border: 1.5px solid var(--green); background: var(--card); color: var(--green); font-weight: 600; text-align: center; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:active { background: var(--green-d); }
.btn.block { width: 100%; }
.btn.quiet { border-color: var(--line); color: var(--ink); }
.btn.link { min-height: 44px; border: 0; background: transparent; padding: 0 6px; text-decoration: underline; text-underline-offset: 3px; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger.armed { background: var(--red); color: #fff; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 0.93em; }
.btn:disabled { opacity: 0.55; cursor: default; }
body.ur .btn { line-height: 1.9; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.tint { background: var(--green-l); border-color: #BFDCCD; }
.card.paper { background: var(--paper); }
.card-h { display: flex; align-items: baseline; gap: 8px; }
.card-h h2 { font-size: 1.08em; font-weight: 700; }
.card-h .muted { font-size: 0.87em; }
.card-list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.item .label { flex: 1; min-width: 0; }
.tick { width: 28px; height: 28px; border-radius: 14px; background: var(--green-l); color: var(--green); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.empty { color: var(--muted); font-size: 0.93em; }

/* Chips and segmented choices */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 12px; font-size: 0.8em; font-weight: 600; background: var(--green-l); color: var(--green-d); }
.badge.gold { background: #F6EAC7; color: var(--gold-d); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
body.ur .badge { line-height: 1.8; }

.options { display: flex; flex-direction: column; gap: 10px; }
.opt { width: 100%; min-height: 58px; margin: 0; padding: 10px 16px; display: flex; align-items: center; gap: 12px; text-align: start; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); }
.opt[aria-pressed="true"] { border-color: var(--green); background: var(--green-l); }
.opt .t { display: block; font-weight: 600; }
.opt .s { display: block; font-size: 0.85em; color: var(--muted); }
.opt .mark { width: 22px; height: 22px; flex: none; border-radius: 11px; border: 2px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.opt[aria-pressed="true"] .mark { border-color: var(--green); background: var(--green); }
.opt .q { font-size: 1.25em; line-height: 1.7; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > .label { font-weight: 600; font-size: 0.93em; }
select.select { min-height: 48px; width: 100%; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); }
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; border-radius: 16px; border: 0; background: #B7C4BE; padding: 0; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; transition: inset-inline-start 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { inset-inline-start: 23px; }

/* Welcome */
.welcome { padding-top: 6vh; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.3em; }
.logo { width: 52px; height: 52px; border-radius: 15px; background: var(--green); color: var(--gold); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.welcome-title { font-size: 1.7em; line-height: 1.25; font-weight: 700; }
body.ur .welcome-title { line-height: 2; font-size: 1.55em; }

/* Steps */
.progress-dots { display: flex; gap: 6px; }
.progress-dots span { height: 6px; flex: 1; border-radius: 3px; background: var(--line); }
.progress-dots span.on { background: var(--green); }
.steps { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.step { min-height: 40px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 600; font-size: 0.88em; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.step[aria-current="step"] { background: var(--green); border-color: var(--green); color: #fff; }
.step.done { color: var(--green); border-color: #BFDCCD; }

/* Quran text */
.ar { direction: rtl; text-align: right; font-size: 27px; line-height: 2.15; color: var(--ink); word-spacing: 0.06em; }
.q-madani { font-family: var(--q-madani); }
.q-indopak { font-family: var(--q-indopak); font-weight: 500; line-height: 2.25; }
.ayah { background: var(--paper); border: 1px solid #E8E1C9; border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; transition: background 0.2s, border-color 0.2s; }
.ayah.cur { background: var(--band-cur); border-color: #E2C56E; }
.ayah .tr { font-size: 0.95em; color: var(--ink); }
.ayah .tr.ur-font { direction: rtl; text-align: right; font-size: 1em; }
.ayah .tr.en-font { direction: ltr; text-align: left; }
.ayah .tr-src { font-size: 0.78em; color: var(--muted); }
.mk { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6em; height: 1.6em; padding: 0 0.18em; margin: 0 0.12em; border-radius: 0.8em; border: 1px solid var(--gold-ring); color: var(--gold-d); background: #FFFDF7; font-size: 0.62em; line-height: 1; vertical-align: 0.25em; font-family: var(--q-indopak); font-weight: 600; }
.q-madani .mk { font-family: var(--q-madani); }
.w { display: inline; }
.wbtn { display: inline; margin: 0; padding: 0 0.08em; border: 0; background: transparent; border-radius: 6px; font: inherit; color: inherit; line-height: inherit; }
.wbtn:active, .wbtn.sel { background: var(--band-les); }
.wbtn.hide { color: transparent; background: var(--band-hid); border-radius: 6px; }
.wbtn.peek { color: var(--ink); background: #F6EAC7; }
.tj-ghunnah { color: #1E7A3C; }
.tj-qalqalah { color: #1F5FAD; }
.tj-madd { color: #B45309; }
.tj-silent { color: #7C878D; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85em; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 5px; margin-inline-end: 6px; background: currentColor; }

.meaning-pop { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; }
.meaning-pop .ar { font-size: 24px; line-height: 1.8; flex: none; }

.counter { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.counter .dots { display: flex; gap: 8px; }
.counter .dots span { width: 14px; height: 14px; border-radius: 7px; border: 2px solid var(--green); }
.counter .dots span.on { background: var(--green); }

.player { display: flex; flex-direction: column; gap: 12px; }
.play-btn { width: 64px; height: 64px; border-radius: 32px; border: 0; background: var(--green); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.play-btn:active { background: var(--green-d); }
.err { background: var(--red-bg); color: var(--red); border-radius: 12px; padding: 10px 12px; font-size: 0.93em; }
.info { background: var(--blue-bg); color: var(--blue); border-radius: 12px; padding: 10px 12px; font-size: 0.93em; }

.test-card { display: flex; flex-direction: column; gap: 10px; }
.veil { position: relative; }
.veil .ar { color: transparent; text-shadow: none; }
.veil .ar .mk { color: var(--gold-d); }
.veil-bar { position: absolute; inset: 10px 0; border-radius: 10px; background: repeating-linear-gradient(90deg, var(--band-hid) 0 46px, transparent 46px 54px); pointer-events: none; }
.result { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.result.ok { color: var(--green); }
.result.bad { color: var(--red); }

.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-item { display: flex; align-items: center; gap: 8px; }
.rec-item audio { flex: 1; min-width: 0; height: 40px; }
.rec-dot { width: 10px; height: 10px; border-radius: 5px; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

.done-hero { align-items: center; text-align: center; padding: 26px 16px; }
.done-hero .big-tick { width: 72px; height: 72px; border-radius: 36px; background: var(--green); color: #fff; display: inline-flex; align-items: center; justify-content: center; }

/* Mushaf page */
.mushaf { direction: rtl; background: var(--paper); border: 1px solid #E8E1C9; border-radius: var(--radius); padding: 14px 12px 12px; --pfs: 20px; }
.mushaf-in { width: 100%; }
.mushaf .sh { margin: 0 auto 6px; padding: 4px 10px; border: 1.5px solid var(--gold-ring); border-radius: 10px; text-align: center; font-size: calc(var(--pfs) * 1.05); line-height: 1.9; color: var(--gold-d); background: linear-gradient(#FFFDF7, #FBF3DE); }
.mushaf .bism { text-align: center; font-size: var(--pfs); line-height: 2.1; }
.pl { display: flex; direction: rtl; justify-content: flex-start; align-items: baseline; white-space: nowrap; font-size: var(--pfs); line-height: 2.15; --g: 0px; }
.q-indopak .pl { line-height: 2.3; }
.tk { padding-inline: calc(var(--g) / 2); padding-block: 0.04em; }
.tk:first-child { padding-inline-start: 0; }
.tk:last-child { padding-inline-end: 0; }
.tk .tx { display: inline-block; }
.tk .tx.mk { margin: 0; vertical-align: 0.15em; }
.tk[data-band="les"] { background: var(--band-les); }
.tk[data-band="cur"] { background: var(--band-cur); }
.tk[data-band="hid"] { background: var(--band-hid); }
.tk[data-band="hid"] .tx:not(.mk) { color: transparent; }
.tk.bs { border-start-start-radius: 0.35em; border-end-start-radius: 0.35em; }
.tk.be { border-start-end-radius: 0.35em; border-end-end-radius: 0.35em; }
.page-foot { display: flex; justify-content: center; margin-top: 4px; font-size: 0.85em; color: var(--gold-d); font-family: var(--q-indopak); }
.tr-row { width: 100%; margin: 0; padding: 10px 12px; display: flex; gap: 10px; text-align: start; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.tr-row[aria-pressed="true"] { border-color: #E2C56E; background: #FFF8E4; }
.tr-row .n { flex: none; min-width: 26px; height: 26px; border-radius: 13px; background: var(--green-l); color: var(--green-d); font-size: 0.8em; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-family: var(--ui); }
.tr-row .txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* Progress */
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .n { font-size: 1.9em; font-weight: 700; line-height: 1.1; font-family: var(--ui); }
.stat .l { color: var(--muted); font-size: 0.88em; }
.days14 { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.days14 span { aspect-ratio: 1; border-radius: 5px; background: var(--line); }
.days14 span.on { background: var(--green); }
.days14 span.today { outline: 2px solid var(--gold-ring); outline-offset: 1px; }
.bar-track { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); border-radius: 4px; }

/* Hadith */
.hadith { gap: 8px; }
.hadith.daif { border: 2px solid var(--red); }
.hadith .sanad { direction: rtl; text-align: right; font-family: var(--q-indopak); font-size: 15px; line-height: 2; color: var(--muted); }
.hadith .matn { direction: rtl; text-align: right; font-family: var(--q-indopak); font-size: 20px; line-height: 2.1; }
.hadith .chain { color: var(--muted); font-size: 0.9em; }
.section-h { font-size: 1em; font-weight: 700; margin-top: 6px; }
.section-h.red { color: var(--red); }

/* Tab bar */
.tabs { position: fixed; inset-inline: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; background: rgba(255,255,255,0.97); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs-in { width: 100%; max-width: 520px; display: flex; }
.tab { flex: 1; min-height: var(--tabh); margin: 0; padding: 6px 4px; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.78em; font-weight: 600; }
.tab[aria-current="page"] { color: var(--green); }
body.ur .tab { font-size: 0.8em; line-height: 1.7; }

/* Toast and banner */
.toast { position: fixed; inset-inline: 16px; bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 14px); z-index: 30; margin: 0 auto; max-width: 488px; padding: 12px 16px; border-radius: 12px; background: #10231C; color: #fff; font-weight: 500; opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
body.no-tabs .toast { bottom: calc(env(safe-area-inset-bottom) + 18px); }
.banner { position: fixed; inset-inline: 0; top: 0; z-index: 40; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: var(--green); color: #fff; }
.banner .grow { font-weight: 600; }
.banner .btn { min-height: 40px; background: #fff; color: var(--green); border-color: #fff; }

@media (min-width: 560px) {
  body { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Mushaf lines that are not text */
.pl.hd { justify-content: center; }
.pl.hd .sh { margin: 0.12em 0; width: 84%; line-height: 1.75; }
.pl.bm { justify-content: center; }
.pl.bm .bism { line-height: inherit; }
.pl.blank { height: calc(var(--pfs) * 2.15); }
.q-indopak .pl.blank { height: calc(var(--pfs) * 2.3); }
.pl.center { justify-content: center; }

/* Tafseer notes */
details.fn { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 0 12px; }
details.fn summary { min-height: 44px; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--green-d); cursor: pointer; list-style: none; }
details.fn summary::-webkit-details-marker { display: none; }
details.fn summary::before { content: '+'; display: inline-flex; width: 22px; height: 22px; border-radius: 11px; align-items: center; justify-content: center; background: var(--green-l); font-family: var(--ui); }
details.fn[open] summary::before { content: '−'; }
details.fn[open] { padding-bottom: 10px; }
details.fn p { margin-top: 6px; white-space: pre-line; }

/* Juz grid */
.juz-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.juz { position: relative; overflow: hidden; aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--card); display: flex; align-items: center; justify-content: center; font: 700 0.9em/1 var(--ui); }
.juz i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--band-les); }
.juz span { position: relative; }
.juz.full { background: var(--green); border-color: var(--green); color: #fff; }
.juz.full i { display: none; }
.known-chips .chip { min-height: 40px; }

/* Surah name and bismillah sharing one line (Indo-Pak 16-line layout) */
.pl.hb { justify-content: space-between; align-items: center; gap: 0.5em; }
.pl.hb .sh { margin: 0.12em 0; width: 48%; line-height: 1.7; font-size: 0.92em; }
.pl.hb .bism { font-size: 0.86em; white-space: nowrap; }
