/* موسوعة التجويد — التصميم */
/*
 * css/app.css — All styles. Plain CSS, no preprocessor.
 *  - :root holds design tokens (colours, radius, fonts). Dark mode overrides
 *    them under :root[data-theme="dark"] and under prefers-color-scheme: dark
 *    when the user has not forced light. Use the variables, not raw colours.
 *  - Rule colours are NOT here: ayah.js generates the .g-<group> { --c } rules
 *    from js/data/rules.js. Components use var(--c).
 *  - The page is RTL (dir="rtl" on <html>), so "start" is the right side.
 *  - Sections below follow the page order: layout, components, home, chapter,
 *    ayah, legend, sheet, quiz/practice, glossary/search, settings, diagram.
 */
:root {
  --bg: #f6f1e7;
  --bg-2: #efe7d6;
  --surface: #fffdf8;
  --surface-2: #f8f3e9;
  --line: #e3d9c4;
  --text: #1f2a24;
  --muted: #68726c;
  --primary: #0f6e56;
  --primary-ink: #0a4d3c;
  --primary-soft: #dcefe7;
  --accent: #b8892f;
  --accent-soft: #f6ecd2;
  --danger: #b42318;
  --ok: #15803d;
  --shadow: 0 1px 2px rgba(31,42,36,.06), 0 8px 24px -12px rgba(31,42,36,.18);
  --radius: 16px;
  --radius-sm: 10px;
  --font-ui: 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-head: 'Amiri', 'Noto Naskh Arabic', serif;
  --font-quran: 'Amiri Quran', 'Amiri', 'KFGQPC Uthman Taha Naskh', 'Noto Naskh Arabic', serif;
  --quran-size: 1.9rem;
  --nav-h: 64px;
}
:root[data-theme="dark"] {
  --bg: #0f1613;
  --bg-2: #141d19;
  --surface: #182320;
  --surface-2: #1f2c28;
  --line: #2a3934;
  --text: #e9e6dc;
  --muted: #9aa69f;
  --primary: #3fb58f;
  --primary-ink: #7fdcbb;
  --primary-soft: #1b3a30;
  --accent: #d9b35c;
  --accent-soft: #3a2f16;
  --danger: #f87171;
  --ok: #4ade80;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1613; --bg-2: #141d19; --surface: #182320; --surface-2: #1f2c28; --line: #2a3934;
    --text: #e9e6dc; --muted: #9aa69f; --primary: #3fb58f; --primary-ink: #7fdcbb; --primary-soft: #1b3a30;
    --accent: #d9b35c; --accent-soft: #3a2f16; --danger: #f87171; --ok: #4ade80;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-ui); font-size: 17px; line-height: 1.8;
  direction: rtl; text-align: right; min-height: 100dvh;
  background-image: radial-gradient(1200px 500px at 50% -200px, var(--primary-soft), transparent 70%);
}
a { color: var(--primary); text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; line-height: 1.4; margin: 0; }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.2rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
/* Headings and the sheet receive focus programmatically on navigation; no ring for those. */
[tabindex="-1"]:focus { outline: none; }
.skip-link { position: absolute; top: -60px; inset-inline-start: 12px; z-index: 100; padding: 10px 16px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 600; transition: top .15s; }
.skip-link:focus { top: 10px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 1fr; grid-template-rows: auto 1fr; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  transition: box-shadow .2s;
}
.topbar.scrolled { box-shadow: 0 6px 20px -14px rgba(0,0,0,.35); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; color: var(--text); }
/* Brand mark: the star + mushaf artwork from icons/icon.svg, drawn inline; the tile stays the brand green in both themes. */
.brand .mark { width: 36px; height: 36px; border-radius: 10px; background: #0f6e56; display: grid; place-items: center; box-shadow: var(--shadow); overflow: hidden; }
.brand .mark svg { width: 100%; height: 100%; display: block; }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow);
}
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn.flat { box-shadow: none; background: transparent; border-color: transparent; width: 36px; height: 36px; }

.shell { display: grid; grid-template-columns: 1fr; gap: 0; min-width: 0; }
.sidenav { display: none; }
main { padding: 16px 16px calc(var(--nav-h) + 24px); max-width: 860px; width: 100%; margin: 0 auto; min-width: 0; }

.bottomnav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 20; height: var(--nav-h);
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav { box-shadow: 0 -6px 20px -16px rgba(0,0,0,.35); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .78rem; color: var(--muted); min-width: 0; }
.bottomnav a svg { padding: 3px 14px; width: 52px !important; height: 30px !important; border-radius: 99px; box-sizing: border-box; transition: background .15s; }
.bottomnav a.active { font-weight: 700; }
.bottomnav a.active svg { background: var(--primary-soft); }
.bottomnav a svg, .sidenav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav a.active, .sidenav a.active { color: var(--primary); }
.sidenav a.active { background: var(--primary-soft); }

@media (min-width: 900px) {
  .shell { grid-template-columns: 250px 1fr; }
  .sidenav { display: block; position: sticky; top: 61px; height: calc(100dvh - 61px); overflow: auto; padding: 16px 12px; border-left: 1px solid var(--line); }
  .sidenav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--text); font-weight: 600; margin-bottom: 4px; }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav .group { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin: 14px 12px 6px; padding-top: 12px; border-top: 1px solid var(--line); letter-spacing: .02em; }
  .sidenav .chap { font-weight: 500; font-size: .95rem; padding: 7px 12px; }
  .sidenav .chap .n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: .72rem; flex: none; }
  .sidenav .chap.done .n { background: var(--primary); color: #fff; border-color: var(--primary); }
  .sidenav .chap.active .n { border-color: var(--primary); color: var(--primary); }
  .sidenav a.active { box-shadow: inset -3px 0 0 var(--primary); }
  .bottomnav { display: none; }
  main { padding: 28px 32px 48px; }
  :root { --nav-h: 0px; }
}

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; transition: transform .08s, background .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-ink); }
:root[data-theme="dark"] .btn.primary, :root:not([data-theme="light"]) .btn.primary { color: #06201a; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .btn.primary { color: #fff; } }
:root[data-theme="light"] .btn.primary { color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.small { padding: 6px 12px; font-size: .9rem; border-radius: 10px; min-height: 38px; }
.btn { min-height: 44px; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.ok { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill-letters { font-family: var(--font-quran); font-size: 1.25rem; letter-spacing: .25em; color: var(--primary-ink); }
.eyebrow { font-size: .8rem; color: var(--muted); letter-spacing: .02em; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.toast { position: fixed; bottom: calc(var(--nav-h) + 16px); inset-inline: 16px; margin: auto; max-width: 420px; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; z-index: 50; box-shadow: var(--shadow); text-align: center; animation: pop .2s ease-out; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* progress ring */
.ring { width: 76px; height: 76px; position: relative; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: var(--primary); stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: .95rem; }
.bar-track { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar-track > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s ease; }

/* ---------- Home ---------- */
.hero { display: grid; gap: 14px; padding: 26px 22px; border-radius: 22px; background: linear-gradient(135deg, #13785e 0%, #0a4d3c 100%); color: #fff; /* fixed brand green in both themes so white text keeps contrast */ box-shadow: var(--shadow); position: relative; overflow: hidden; }
/* Watermark: the eight-point star from the app icon. */
.hero::after { content: ''; position: absolute; left: -40px; bottom: -60px; width: 240px; height: 240px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cg fill='none' stroke='%23fff' stroke-width='16' stroke-linejoin='round'%3E%3Crect x='120' y='120' width='272' height='272' rx='14'/%3E%3Crect x='120' y='120' width='272' height='272' rx='14' transform='rotate(45 256 256)'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat; opacity: .1; pointer-events: none; }
.hero h1 { color: #fff; font-size: 2.1rem; }
.hero .eyebrow { color: rgba(255,255,255,.78); }
.hero-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.hero .ring .track { stroke: rgba(255,255,255,.22); }
.hero .ring .bar { stroke: #fff; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 600px) {
  .hero { padding: 20px 18px; gap: 12px; }
  .hero h1 { font-size: 1.6rem; }
  .hero p { font-size: .95rem; line-height: 1.75; }
  .hero .ring { width: 62px; height: 62px; }
  .hero .ring .val { font-size: .85rem; }
  .hero-actions .btn { flex: 1 1 auto; }
  .hero::after { width: 170px; height: 170px; bottom: -40px; }
}
.hero p { color: rgba(255,255,255,.85); max-width: 46ch; margin: 0; }
.hero .btn { background: #fff; color: #0a4d3c; border-color: #fff; }
.hero .btn.ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.3); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; font-family: var(--font-head); color: var(--primary); }
.stat b small { font-size: .9rem; color: var(--muted); }
.stat span { font-size: .8rem; color: var(--muted); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 12px; }
.section-title h2 { font-size: 1.35rem; }

/* learning path */
.path { position: relative; display: grid; gap: 10px; padding-right: 22px; }
.path::before { content: ''; position: absolute; right: 9px; top: 18px; bottom: 18px; width: 2px; background: var(--line); }
.path-item { position: relative; display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--text); transition: transform .12s, border-color .12s; }
.path-item:hover { transform: translateX(-2px); border-color: var(--primary); }
.path-item::before { content: ''; position: absolute; right: -19px; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--line); border: 2px solid var(--bg); transform: translateY(-50%); }
.path-item.done::before { background: var(--primary); }
.path-item.current::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.path-item .icon { width: 48px; height: 48px; border-radius: 14px; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-family: var(--font-quran); font-size: 1.6rem; }
.path-item.done .icon { background: var(--primary); color: #fff; }
.path-item .t { font-weight: 700; font-family: var(--font-head); font-size: 1.1rem; }
.path-item .s { font-size: .85rem; color: var(--muted); }
.path-item .meta { display: grid; justify-items: end; gap: 4px; font-size: .78rem; color: var(--muted); }
.path-item.locked { opacity: .75; }

/* ---------- Chapter ---------- */
.chapter-head { padding: 22px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.chapter-head .icon { width: 64px; height: 64px; border-radius: 18px; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-family: var(--font-quran); font-size: 2.2rem; }
.chapter-head h1 { font-size: 1.7rem; }
.chapter-intro { margin-top: 14px; padding: 16px 18px; border-radius: var(--radius); background: var(--accent-soft); border-right: 4px solid var(--accent); }
.section { margin-top: 20px; }
.section h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 1.35rem; }
.section h2::before { content: ''; width: 6px; height: 26px; border-radius: 3px; background: var(--accent); }
.rule-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.rule-tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .85rem; cursor: pointer; }
.rule-tag.active, .section.active { outline: 2px solid var(--accent); outline-offset: 2px; }
.rule-tag i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.body { font-size: 1.02rem; }
.body b { color: var(--primary-ink); }
.tips { margin-top: 10px; padding: 12px 16px; border-radius: 12px; background: var(--primary-soft); font-size: .95rem; }
.tips li { margin: 4px 0; }
.tips ul { margin: 0; padding-right: 18px; }
table.marks { border-collapse: collapse; width: 100%; margin-top: 8px; }
table.marks td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.marks td:first-child { font-family: var(--font-quran); font-size: 1.5rem; color: var(--primary-ink); width: 70px; text-align: center; }
.summary { margin-top: 24px; }
.summary ol { padding-right: 20px; margin: 8px 0 0; }
.summary li { margin: 6px 0; }
.chapter-actions { display: grid; gap: 10px; margin-top: 22px; }
@media (min-width: 600px) { .chapter-actions { grid-template-columns: 1fr 1fr; } }
.chapter-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }

/* ---------- Ayah ---------- */
.ayah { margin: 12px 0; padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.ayah .q { font-family: var(--font-quran); font-size: var(--quran-size); line-height: 2.3; text-align: right; word-spacing: .12em; }
.ayah .q .end { font-size: .7em; color: var(--accent); }
.ayah .ref { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.ayah .note { margin-top: 8px; font-size: .92rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }
.tj { color: var(--c); text-decoration: underline dotted; text-decoration-color: var(--c); text-underline-offset: .22em; text-decoration-thickness: 2px; cursor: pointer; border-radius: 4px; transition: background .15s; }
.tj:hover, .tj:focus-visible { background: color-mix(in srgb, var(--c) 14%, transparent); }
.tj.active { background: color-mix(in srgb, var(--c) 22%, transparent); }
.ayah.plain .tj { color: inherit; text-decoration: none; cursor: default; }
.ayah.plain .tj.target { background: var(--accent-soft); color: var(--accent); text-decoration: underline dotted; }

.audio { display: inline-flex; align-items: center; gap: 8px; }
.audio button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: .85rem; }
.audio button svg { width: 16px; height: 16px; fill: currentColor; }
.audio button.playing { background: var(--primary); color: #fff; border-color: var(--primary); }
.audio .err { color: var(--danger); font-size: .8rem; }

/* ---------- Legend ---------- */
.legend { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.legend-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: .92rem; }
.legend-item i { width: 14px; height: 14px; border-radius: 4px; background: var(--c); flex: none; }
.legend-sample { font-family: var(--font-quran); font-size: 1.4rem; color: var(--c); }

/* ---------- Sheet (tap to explain) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; display: none; }
.sheet-backdrop.open { display: block; }
.sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 61; background: var(--surface); border-radius: 22px 22px 0 0; padding: 14px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 86dvh; overflow: auto; overscroll-behavior: contain; transform: translateY(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1), translate .25s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
.sheet.open { transform: none; visibility: visible; }
.sheet:not(.open) { visibility: hidden; transition: transform .25s cubic-bezier(.2,.8,.2,1), translate .25s cubic-bezier(.2,.8,.2,1), visibility 0s .25s; }
/* While open, the page behind must not scroll or trigger pull-to-refresh. */
.sheet-backdrop { touch-action: none; overscroll-behavior: contain; }
.sheet .grip { touch-action: none; cursor: grab; }
.sheet .grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet .rule-name { display: flex; align-items: center; gap: 10px; }
.sheet .rule-name i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.sheet .sample { font-family: var(--font-quran); font-size: 2rem; color: var(--c); margin: 6px 0; }
.sheet .why { padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); border-right: 4px solid var(--accent); margin: 10px 0; }
.sheet .how { padding: 10px 14px; border-radius: 12px; background: var(--primary-soft); margin: 10px 0; }
.sheet .how b, .sheet .why b { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
@media (min-width: 900px) { .sheet { inset-inline: auto; left: 50%; transform: translate(-50%, 105%); width: 560px; border-radius: 22px; bottom: 24px; } .sheet.open { transform: translate(-50%, 0); } }

/* ---------- Quiz / practice ---------- */
.quiz-progress { display: flex; gap: 4px; margin: 10px 0 16px; }
.quiz-progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.quiz-progress i.ok { background: var(--ok); } .quiz-progress i.bad { background: var(--danger); } .quiz-progress i.cur { background: var(--accent); }
.question { font-size: 1.15rem; font-weight: 600; margin-bottom: 14px; }
.question .q-ayah { font-family: var(--font-quran); font-size: 1.8rem; font-weight: 400; display: block; margin-top: 8px; line-height: 2.2; }
.options { display: grid; gap: 8px; }
.option { text-align: right; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; display: flex; gap: 10px; align-items: center; transition: border-color .12s, background .12s; }
.option:hover:not(:disabled) { border-color: var(--primary); }
.option .k { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: .8rem; flex: none; }
.option.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.option.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.option:disabled { cursor: default; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border-right: 4px solid var(--accent); }
.feedback.ok { border-color: var(--ok); } .feedback.bad { border-color: var(--danger); }
.result { text-align: center; padding: 26px 18px; }
.result .score { font-family: var(--font-head); font-size: 3rem; color: var(--primary); line-height: 1.1; }
.result .badge { font-size: 3rem; }

/* ---------- Glossary / search ---------- */
.search-box { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.search-box input { flex: 1; min-width: 0; width: 0; border: 0; background: transparent; font: inherit; font-size: 1.05rem; color: inherit; outline: none; }
.result-item { display: block; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--text); margin-top: 8px; }
.result-item .k { font-size: .78rem; color: var(--muted); }
.result-item b { font-family: var(--font-head); font-size: 1.05rem; }
.result-item mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.term { padding: 12px 0; border-bottom: 1px solid var(--line); }
.term b { font-family: var(--font-head); font-size: 1.1rem; color: var(--primary-ink); }

/* ---------- Settings ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.setting:last-child { border-bottom: 0; }
.setting select, .setting input[type=range] { font: inherit; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: inherit; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 6px 12px; border: 0; background: var(--surface); cursor: pointer; }
.seg button.on { background: var(--primary); color: #fff; }

/* ---------- Makharij diagram ---------- */
.diagram { margin: 12px 0 4px; }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram .zone { cursor: pointer; transition: opacity .15s; }
.diagram .zone circle { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 2; }
.diagram .zone text { font-family: var(--font-quran); font-size: 15px; fill: var(--primary-ink); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.diagram .zone:hover circle, .diagram .zone.on circle { fill: var(--accent-soft); stroke: var(--accent); }
.diagram .outline { fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.diagram .tongue { fill: color-mix(in srgb, var(--accent) 25%, var(--surface)); stroke: var(--accent); stroke-width: 2; }
.diagram-info { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); min-height: 60px; }
.diagram-info .letters { font-family: var(--font-quran); font-size: 1.7rem; color: var(--primary-ink); letter-spacing: .2em; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.fade-in { animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .topbar, .bottomnav, .sidenav, .audio, .chapter-actions { display: none !important; } main { padding: 0; } }

/* ---------- المصحف ---------- */
.mushaf-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.mushaf-bar .spacer { flex: 1; }
.mushaf-bar .btn.on-color { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.mushaf-title { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.mushaf-title .num { width: 54px; height: 54px; border-radius: 16px; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-family: var(--font-quran); font-size: 1.5rem; flex: none; }
.mushaf-title h1 { font-size: 1.7rem; }
.mushaf-title > .row { margin-inline-start: auto; }
.mushaf-tabs { margin-top: 2px; }
.surah-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
.surah-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); transition: border-color .12s, transform .12s; }
.surah-item:hover { border-color: var(--primary); transform: translateX(-2px); }
.surah-item .num { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--font-quran); font-size: 1.1rem; flex: none; color: var(--primary-ink); }
.surah-item .nm { display: grid; line-height: 1.5; min-width: 0; }
.surah-item .nm b { font-family: var(--font-head); font-size: 1.15rem; }
.surah-item .nm .muted { font-size: .82rem; }
.surah-item .rm { margin-inline-start: auto; width: 32px; height: 32px; font-size: .8rem; }
.mushaf-legend { margin: 0 0 14px; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.mushaf-legend summary { cursor: pointer; font-weight: 600; color: var(--primary-ink); }
.mushaf-legend .legend { margin-top: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.mushaf-legend .legend-item { padding: 6px 10px; font-size: .85rem; background: var(--surface-2); }
.mushaf .q { font-family: var(--font-quran); font-size: var(--quran-size); line-height: 2.4; text-align: right; word-spacing: .12em; }
/* Isti'adha header: smaller, muted and in the heading font so it reads as distinct from the basmalah and the ayat. */
.mushaf .istiadha { width: fit-content; max-width: 100%; margin: 4px auto 10px; padding: 4px 18px; border-block: 1px solid var(--line); text-align: center; font-family: var(--font-head); font-size: calc(var(--quran-size) * .72); line-height: 2; color: var(--muted); }
.mushaf .basmalah { text-align: center; margin: 6px 0 14px; color: var(--primary-ink); }
.mushaf .flow { padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: justify; text-align-last: center; }
.mushaf .ay { transition: background .2s; border-radius: 6px; scroll-margin-top: 90px; }
.mushaf .ay.focus { background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); }
.mushaf .ay.playing { background: var(--primary-soft); box-shadow: 0 0 0 4px var(--primary-soft); }
.mushaf .istiadha.playing, .mushaf .basmalah.playing { background: var(--primary-soft); border-radius: 10px; }
.mushaf.list .ayah.ay.playing { border-color: var(--primary); }
.mushaf.list .ayah .q { line-height: 2.3; }
.mushaf.list .ayah .ref .row { gap: 4px; }
.mushaf.list .bm svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linejoin: round; }
.mushaf.list .bm.on svg { fill: var(--accent); stroke: var(--accent); }
.aya-num { display: inline-grid; place-items: center; min-width: 1.45em; height: 1.45em; padding: 0 .25em; margin: 0 .15em; border-radius: 50%; border: 1.5px solid var(--accent); color: var(--accent); font-size: .62em; line-height: 1; vertical-align: middle; cursor: pointer; font-family: var(--font-ui); font-weight: 600; user-select: none; }
.aya-num:hover, .aya-num:focus-visible { background: var(--accent-soft); }
.mushaf.nocolor .tj { color: inherit; text-decoration: none; cursor: text; pointer-events: none; }
.mushaf .tj { text-decoration-thickness: 1.5px; }
.waqf { color: var(--muted); pointer-events: none; }
.mushaf.nocolor .waqf { color: var(--muted); }
.player[hidden] { display: none; }
.player { position: fixed; bottom: calc(var(--nav-h) + 10px); inset-inline: 12px; margin: auto; max-width: 560px; z-index: 55; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: pop .2s ease-out; }
.player .info { display: grid; line-height: 1.4; min-width: 0; flex: 1; }
.player .info b { font-family: var(--font-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .info .muted { font-size: .8rem; }
.player .ctl { display: flex; align-items: center; gap: 4px; }
.player .icon-btn.big { width: 44px; height: 44px; background: var(--primary); color: #fff; border-color: var(--primary); }
.player .icon-btn.big svg { fill: currentColor; stroke: currentColor; }
.player .icon-btn[disabled] { opacity: .4; pointer-events: none; }
.mushaf-cta { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); background: linear-gradient(135deg, var(--surface), var(--surface-2)); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow); }
.mushaf-cta .mark { font-family: var(--font-quran); font-size: 2.2rem; color: var(--primary); line-height: 1; }
.mushaf-cta b { font-family: var(--font-head); font-size: 1.15rem; display: block; }
.mushaf-cta .muted { font-size: .88rem; }
.mushaf-cta svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; color: var(--primary); }
@media (max-width: 600px) { .mushaf .flow { padding: 14px 12px; } .mushaf-title h1 { font-size: 1.45rem; } .mushaf-cta { grid-template-columns: auto 1fr; } .mushaf-cta svg { display: none; } }

/* ---------- UX additions: onboarding, chapter contents, reading progress, "More" hub ---------- */
.onboard { margin-top: 14px; border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.onboard h2 { font-size: 1.3rem; }
.onboard .steps { list-style: none; margin: 8px 0 14px; padding: 0; display: grid; gap: 12px; }
@media (min-width: 760px) { .onboard .steps { grid-template-columns: repeat(3, 1fr); } }
.onboard .steps li { display: flex; gap: 12px; align-items: flex-start; }
.onboard .steps .ic { flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.onboard .steps svg, .menu-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.onboard .steps b { display: block; font-family: var(--font-head); font-size: 1.05rem; }
.onboard .steps .muted { font-size: .9rem; line-height: 1.7; display: block; }
.icon-btn.flat svg { width: 18px; height: 18px; }

.read-progress { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 30; pointer-events: none; }
.read-progress span { display: block; height: 100%; width: 0; background: var(--accent); margin-inline-start: 0; border-radius: 0 3px 3px 0; }

.toc { margin-top: 14px; padding: 14px 18px; }
.toc b { font-family: var(--font-head); font-size: 1.1rem; }
.toc ol { list-style: arabic-indic; margin: 6px 0 0; padding-inline-start: 22px; columns: 2 220px; column-gap: 24px; }
.toc li { margin: 4px 0; break-inside: avoid; }
.toc a { color: var(--text); border-bottom: 1px dashed transparent; }
.toc a:hover { color: var(--primary); border-bottom-color: currentColor; }
.toc li::marker { color: var(--accent); font-weight: 700; }
.section, .summary { scroll-margin-top: 76px; }

.menu-list { display: grid; gap: 10px; margin-top: 14px; }
.menu-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow); }
.menu-item:hover { border-color: var(--primary); }
.menu-item .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.menu-item b { display: block; font-family: var(--font-head); font-size: 1.1rem; }
.menu-item .muted { font-size: .88rem; }
.menu-item > svg { color: var(--muted); }

/* Larger touch targets for small interactive chips. */
.rule-tag { min-height: 34px; padding-block: 4px; }
.audio button { min-height: 36px; }
.seg button { min-height: 36px; }

/* Mushaf toolbar: one tidy row on phones (label of the index link hidden, icon kept). */
@media (max-width: 600px) {
  .mushaf-bar { gap: 6px; }
  .mushaf-bar .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .mushaf-bar .btn.small, .mushaf-bar .seg button { padding-inline: 10px; }
}
