/* Surah Al-Kahf — Madinah mushaf pages (King Fahd Complex QCF V2 glyphs) */
@font-face { font-family: "Amiri Quran"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/amiri-quran-arabic.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Amiri Quran"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/amiri-quran-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "qcf-hdr"; font-display: block; src: url(https://static-cdn.tarteel.ai/qul/fonts/surah-names/surah-header/QCF_SurahHeader_COLOR-Regular.woff2) format("woff2"); }
/* King Fahd Complex Hafs font (v3.0), served unchanged as its licence requires: quoted ayahs in the tafsir */
@font-face { font-family: "KFGQPC Hafs"; font-display: swap; src: url(../assets/qurancomplex/kfgqpc_hafs_v30.ttf) format("truetype"); }

:root {
  --paper: #f4eedf; --page: #fffdf7; --ink: #1b1b17; --gold: #9c7a2c; --gold-2: #c9a24f; --gold-3: #e6cf91; --line: #e6dabb; --muted: #7b6c4f;
  --hl: rgba(201, 162, 79, .30); --sel: rgba(18, 90, 72, .12); --hadith: #155c48; --frame-1: #b48a35; --frame-2: #0f5a47;
  --ui: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif; --q: "Amiri Quran", "Amiri", serif;
  --fs: 20px; --lh: 40px; --pw: 680px; --lw: 600px; --pnum: #ad8b52; --rule: #dfcca3;
  color-scheme: light;
}
body.sepia { --paper: #e9dcbd; --page: #f6ead0; --ink: #2f2412; --line: #d9c496; --hl: rgba(176, 128, 40, .30); --hadith: #6b4510; --pnum: #94703a; --rule: #d2b883; }
body.night { --paper: #0c1411; --page: #121d19; --ink: #ece4cc; --gold: #d0ab5c; --gold-2: #b8954b; --gold-3: #6f5b2f; --line: #2a3832; --muted: #a99a77; --pnum: #a08c62; --rule: #34453d;
  --hl: rgba(224, 189, 106, .22); --sel: rgba(140, 220, 190, .12); --hadith: #93d6bb; --frame-1: #a78339; --frame-2: #3f8f76; color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: radial-gradient(1200px 600px at 50% -10%, rgba(201, 162, 79, .16), transparent 70%), var(--paper); color: var(--ink); font-family: var(--ui); line-height: 1.7;
  padding-top: calc(var(--bar) + env(safe-area-inset-top)); padding-bottom: 130px; transition: background-color .3s ease, color .3s ease; }
:root { --bar: 50px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* calm reading: the page is the surah itself, under a thin bar that stays (listen · the surah's name · tools).
   «الأدوات» or a tap beside the text shows the tools and the resume chips (body.ui) for a few seconds; scrolling hides
   them again. The resume chips also show for a few seconds after opening (body.hello). */
.top { position: fixed; inset: 0 0 auto 0; z-index: 45; height: calc(var(--bar) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(8px, calc(50vw - 460px)) 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: var(--paper); border-bottom: 1px solid var(--line); }
.topTitle { font-family: "KFGQPC Hafs", var(--q); font-weight: normal; font-size: 1.6rem; line-height: 1; color: var(--ink); white-space: nowrap; }
.topBtn { justify-self: start; display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--gold); font: inherit; font-weight: 600; font-size: .9rem;
  padding: 6px 8px; border-radius: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.topBtn.end { justify-self: end; }
.topBtn:hover, .topBtn:focus-visible, .topBtn[aria-expanded="true"] { background: var(--sel); outline: none; }
.topBtn svg { width: 17px; height: 17px; fill: currentColor; stroke: currentColor; stroke-width: 0; }
#topTools svg { fill: none; stroke-width: 2; stroke-linecap: round; }
.progress { position: fixed; left: 0; right: 0; top: calc(var(--bar) + env(safe-area-inset-top) - 2px); height: 2px; z-index: 46; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .15s linear; }
.offline { font-size: .78rem; color: #1b7a43; font-weight: 600; }
body.night .offline { color: #7fd3a5; }
/* «تصميم KulliQ», at the very end: back to the site */
.madeBy { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 12px; margin: 22px auto 0; font-size: .92rem; }
.madeBy a { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; font-weight: 600; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--page); }
.madeBy a:hover, .madeBy a:focus-visible { border-color: var(--gold-2); color: var(--ink); outline: none; }
.madeBy svg { width: 22px; height: 22px; }
.madeBy .wm { direction: ltr; color: var(--ink); font-weight: 700; }
.madeBy .wm b { color: #1D9E75; }
body.night .madeBy .wm b { color: #5DCAA5; }
/* a tapped ayah stands out and the rest of the text dims */
:root { --dim: rgba(27, 27, 23, .28); }
body.sepia { --dim: rgba(47, 36, 18, .28); }
body.night { --dim: rgba(236, 228, 204, .26); }

.wrap { max-width: 1000px; margin: 0 auto; padding: 14px 12px 0; }

/* intro (hadith and details): printed on the first PDF sheet; on screen the hadith is at the end, after the surah */
.intro { display: none; width: min(var(--pw), 100%); margin: 14px auto 18px; text-align: center; }
.hadith { position: relative; margin: 0; padding: 22px 22px 16px; border-radius: 18px; background: var(--page);
  box-shadow: inset 0 0 0 1px var(--gold-3), inset 0 0 0 5px var(--page), inset 0 0 0 6px var(--line); }
.hadith .orn { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--paper); color: var(--gold); padding: 0 10px; font-size: 1rem; line-height: 22px; }
.hadith blockquote { margin: 0; font-family: var(--q); font-size: clamp(1.18rem, 3.6vw, 1.45rem); line-height: 2; color: var(--hadith); }
.hadith figcaption { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.meta { margin: 12px 0 0; color: var(--muted); font-size: .86rem; }
.resumeRow { position: fixed; left: 50%; z-index: 43; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 76px); display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  width: max-content; max-width: calc(100vw - 20px); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .25s ease, transform .25s ease, bottom .25s ease; }
body.ui .resumeRow, body.hello .resumeRow { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
body.hello:not(.ui) .resumeRow { bottom: max(18px, env(safe-area-inset-bottom)); }
body.playing .resumeRow { display: none; }
.resumeRow .chip, .resumeRow .chipGroup { box-shadow: 0 8px 22px rgba(60, 45, 15, .18); }
.chip { border: 1px solid var(--gold-2); background: var(--page); color: var(--gold); border-radius: 99px; padding: .35rem 1rem; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; }
.chip:hover { background: var(--hl); }
/* bookmark chip with its ✕ (clear) as one pill */
.chipGroup { display: inline-flex; align-items: stretch; border: 1px solid var(--gold-2); border-radius: 99px; overflow: hidden; background: var(--page); }
.chipGroup .chip { border: 0; border-radius: 0; }
.chipX { border: 0; border-inline-start: 1px solid var(--gold-2); background: transparent; color: var(--gold); padding: 0 .8rem; font: inherit; font-size: .85rem; cursor: pointer; }
.chipX:hover, .chipX:focus-visible { background: var(--hl); }

/* mushaf pages */
.mushaf { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; justify-items: center; }
.mpage { position: relative; width: min(var(--pw), 100%); background: var(--page); padding: 10px 14px 8px; border-radius: 6px;
  box-shadow: 0 1px 2px rgba(60, 45, 15, .06), 0 18px 44px rgba(60, 45, 15, .10); }
/* the ornamental frame (assets/ornament, one per colour theme), like a printed mushaf */
.frame { position: relative; --fb: 30px; border: var(--fb) solid #1c5878; border-image: url(../assets/ornament/frame-light.svg) 48 round; padding: 4px 6px; background: var(--page); }
body.sepia .frame { border-image-source: url(../assets/ornament/frame-sepia.svg); }
body.night .frame { border-image-source: url(../assets/ornament/frame-night.svg); }
.phead { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 6px; font-family: var(--q); font-size: 1rem; color: var(--gold); }
.lines { position: relative; padding: 2px 8px; }
.hizb { display: none; }
@media (min-width: 761px) {
  .mpage { padding-inline: 58px; }
  .hizb { position: absolute; right: calc(-1 * var(--fb) - 52px); top: calc(6px + var(--lh) * (var(--row) + .5)); transform: translateY(-50%); width: 46px; padding: 6px 2px;
    display: grid; justify-items: center; text-align: center; line-height: 1.25; border-radius: 40% / 22%; color: var(--gold);
    background: radial-gradient(circle at 50% 35%, var(--page), rgba(201, 162, 79, .12)); box-shadow: inset 0 0 0 1px var(--gold-2), inset 0 0 0 3px var(--page), inset 0 0 0 4px var(--gold-3); }
  .hizb b { font-size: .7rem; } .hizb small { font-size: .62rem; }
}
.mpage:not(.ready) .lines { visibility: hidden; }
.mpage:not(.ready)::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 6px; background: linear-gradient(100deg, transparent 30%, rgba(201, 162, 79, .08) 50%, transparent 70%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.ln { display: flex; justify-content: space-between; align-items: center; height: var(--lh); font-size: var(--fs); line-height: 1; white-space: nowrap; color: var(--ink); min-width: 0; }
.lines { min-width: 0; overflow-x: clip; overflow-y: visible; }
.w { cursor: pointer; border-radius: .2em; padding: .08em .015em; transition: background-color .25s ease, color .25s ease; -webkit-tap-highlight-color: transparent; }
.w.e { color: var(--ink); }
.ln.hdr { justify-content: center; font-family: "qcf-hdr"; font-size: calc(var(--lw) / 3.32); line-height: 1; overflow: visible;
  background: linear-gradient(180deg, #8a6420 0%, #d9b766 38%, #a77d2a 62%, #6f5016 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
body.night .ln.hdr { background-image: linear-gradient(180deg, #e9cf86, #b8913f 60%, #e2c676); }
.ln.bsml { justify-content: center; }
.ln.bsml i { display: block; width: calc(var(--lh) * 4.3); height: calc(var(--lh) * .88); background: var(--ink);
  -webkit-mask: url(basmala.svg) center / contain no-repeat; mask: url(basmala.svg) center / contain no-repeat; }
.pfoot { display: flex; justify-content: center; padding: 8px 0 2px; }
.pfoot span { min-width: 2.6em; padding: 0 .7em; height: 1.7em; display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--gold);
  border: 1px solid var(--gold-3); border-radius: 99px; background: var(--page); }

/* ayah actions */
.pop { position: absolute; z-index: 45; background: var(--page); border: 1px solid var(--line); border-radius: 16px; padding: 8px; box-shadow: 0 16px 40px rgba(0, 0, 0, .22); width: max-content; max-width: calc(100vw - 16px); }
.popTitle { display: block; text-align: center; font-size: .78rem; color: var(--muted); margin: 0 0 4px; }
.popBtns { display: flex; gap: 2px; }
.popBtns button { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 1rem; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 8px; border-radius: 10px; cursor: pointer; min-width: 52px; }
.popBtns button span { font-size: .72rem; font-weight: 600; }
.popBtns button:hover { background: var(--sel); }

/* finished card */
.done { width: min(var(--pw), 100%); margin: 26px auto 0; text-align: center; background: var(--page); border-radius: 18px; padding: 22px 18px;
  box-shadow: inset 0 0 0 1px var(--gold-3), 0 12px 30px rgba(60, 45, 15, .08); }
.done h2 { margin: 0; font-family: var(--q); font-weight: 400; font-size: 1.6rem; color: var(--hadith); }
.doneSub { margin: 2px 0 12px; color: var(--muted); font-size: .9rem; }
.readBtn { border: 0; border-radius: 14px; padding: .7rem 1.4rem; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; color: #fff; background: linear-gradient(135deg, #0f5a47, #1d7a60); box-shadow: 0 10px 22px rgba(15, 90, 71, .25); }
.readBtn.ok { background: transparent; color: var(--hadith); box-shadow: inset 0 0 0 1.5px var(--hadith); cursor: default; }
.streak { margin: 10px 0 0; color: var(--gold); font-weight: 700; font-size: .95rem; min-height: 1.2em; }
.doneActions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.pill { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 99px; padding: .5rem 1rem; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; }
.pill:hover { background: var(--sel); }
.done .hadith { margin: 22px 0 4px; box-shadow: inset 0 0 0 1px var(--gold-3); }
.done .hadith .orn { background: var(--page); }
.done .meta { margin-top: 16px; }
.credit { width: min(var(--pw), 100%); margin: 18px auto 0; text-align: center; color: var(--muted); font-size: .72rem; line-height: 1.9; }
.credit a { color: inherit; }

/* toolbar */
.tools { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translate(-50%, 150%); opacity: 0; pointer-events: none; z-index: 40;
  display: flex; gap: 1px; background: rgba(18, 58, 48, .95); backdrop-filter: blur(6px); border-radius: 18px; padding: 5px; box-shadow: 0 12px 34px rgba(0, 0, 0, .28);
  transition: transform .25s ease, opacity .25s ease; }
body.ui .tools { transform: translateX(-50%); opacity: 1; pointer-events: auto; }
.tools button { border: 0; background: transparent; color: #f3ead2; font: inherit; font-size: .7rem; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; border-radius: 12px; cursor: pointer; min-width: 48px; }
.tools button:hover { background: rgba(255, 255, 255, .1); }
.tools svg { width: 20px; height: 20px; fill: currentColor; }
.tools b { font-size: 1rem; line-height: 20px; font-family: var(--q); }
.tools #tListen { color: #FAC775; }

/* player */
.player { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transition: bottom .25s ease; transform: translateX(-50%); z-index: 41; width: min(540px, calc(100vw - 20px));
  display: flex; align-items: center; gap: 8px; background: var(--page); border: 1px solid var(--line); border-radius: 16px; padding: 8px 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .18); }
body.ui .player { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 70px); }
/* on touch screens a long press opens the ayah menu, so the mushaf glyphs are not selected as text */
@media (pointer: coarse) { .mushaf { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; } }
.pBtn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: #123a30; color: #FAC775; font-size: 1rem; cursor: pointer; }
.pBtn.ghost { background: transparent; color: var(--muted); width: 34px; height: 34px; }
#pFollow[aria-pressed="true"] { color: var(--gold); }
.pMid { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; }
.pMid b { grid-column: 1 / -1; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pMid input { width: 100%; accent-color: var(--gold); }
.pMid small { color: var(--muted); font-size: .75rem; direction: ltr; }

/* dialogs */
.sheetDlg { border: 0; border-radius: 20px; padding: 18px; width: min(460px, calc(100vw - 20px)); max-height: 86vh; background: var(--page); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.sheetDlg::backdrop { background: rgba(10, 20, 16, .45); }
.sheetDlg h2 { margin: 0 0 8px; font-size: 1.08rem; }
.recList { display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; }
.rec { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px 4px 10px; }
.rec.on { border-color: var(--gold-2); background: var(--hl); }
.rec button { border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; }
.rec .play { flex: 1; text-align: start; padding: 8px 6px; font-weight: 600; }
.rec .save { width: 38px; height: 38px; border-radius: 10px; color: var(--gold); font-size: 1.05rem; }
.rec .save.done { color: #1b7a43; }
.dlNote { color: var(--muted); font-size: .8rem; margin: 6px 0 10px; }
.dlgClose { margin-top: 12px; width: 100%; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 12px; padding: .55rem; font: inherit; font-weight: 600; cursor: pointer; }
.dlgRow { display: flex; gap: 8px; margin-top: 10px; }
.dlgRow .dlgBtn { flex: 1; }
.dlgCol { display: grid; gap: 8px; }
.dlgBtn { display: block; text-align: center; text-decoration: none; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 12px; padding: .55rem; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; }
.dlgBtn.big { padding: .75rem; }
.dlgBtn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.tafAyah { text-align: center; font-size: 22px; line-height: 2.1; padding: 8px 6px; border-radius: 12px; background: var(--sel); direction: rtl; }
.tafAyah span { padding: 0 .06em; }
.tafText { font-size: 1rem; line-height: 2; margin: 12px 0 4px; }
.tafSrc { color: var(--muted); font-size: .74rem; margin: 0; }
/* word meanings: in the tap menu, and listed with the tafsir */
.w.gw { color: var(--gold); }
.popMean { max-width: min(330px, calc(100vw - 40px)); margin: 0 auto 6px; padding: 4px 12px 8px; border-radius: 12px; background: var(--sel); text-align: center; line-height: 1.75; }
.popMean .pm { display: block; font-size: 26px; line-height: 1.9; font-weight: normal; color: var(--gold); }
.popMean > span { display: block; font-size: .93rem; }
.tafWords h3, .tafHead { margin: 14px 0 4px; font-size: .92rem; color: var(--gold); }
.tafWords ul { list-style: none; margin: 0; padding: 0; }
.tafWords li { display: flex; align-items: center; gap: 10px; padding: 3px 0 5px; border-bottom: 1px dashed var(--line); line-height: 1.8; }
.tafWords li:last-child { border-bottom: 0; }
.tafWords .pm { flex: none; max-width: 48%; font-size: 23px; font-weight: normal; color: var(--gold); line-height: 1.7; }
.tafWords li > span { font-size: .95rem; }
.qv { font-family: "KFGQPC Hafs", "Amiri Quran", serif; font-size: 1.18em; font-weight: normal; }
.msgBox { white-space: pre-wrap; font: inherit; font-size: .92rem; line-height: 1.9; background: var(--sel); border-radius: 12px; padding: 12px; margin: 0 0 12px; }

.toast { position: fixed; left: 50%; top: calc(var(--bar) + env(safe-area-inset-top) + 10px); transform: translateX(-50%) translateY(-20px); opacity: 0; z-index: 60; background: #123a30; color: #fff; border-radius: 99px; padding: .5rem 1.1rem; font-size: .9rem; transition: opacity .25s ease, transform .25s ease; pointer-events: none; max-width: calc(100vw - 24px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .wrap { padding: 0 6px; }
  .mpage { padding: 8px 6px 6px; }
  .frame { --fb: 16px; padding: 2px 3px; }
  .lines { padding: 0 4px; }
  .phead { padding: 0 4px 4px; font-size: .86rem; }
  .tools button { min-width: 42px; padding: 6px 4px; }
  .popBtns button { min-width: 46px; padding: 6px 4px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }

/* print / save as PDF: A4, one mushaf page per sheet, no browser header or footer (zero page margin) */
@media print {
  @page { size: A4; margin: 0; }
  html, body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; padding: 0; }
  body.night, body.sepia { --page: #fff; --ink: #111; --paper: #fff; --hadith: #155c48; --gold: #9c7a2c; --gold-2: #c9a24f; --gold-3: #e6cf91; }
  body.night .frame, body.sepia .frame { border-image-source: url(../assets/ornament/frame-light.svg); }
  .progress, .rp, .top, .tools, .player, .toast, .resumeRow, .sheetDlg, .pop, .done, .credit, .madeBy, .pbreak { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .intro { display: block; width: 182mm; margin: 0 auto; padding-top: 10mm; }
  .hadith { padding: 5mm 6mm 4mm; }
  .hadith blockquote { font-size: 15pt; }
  .meta { font-size: 9pt; margin-top: 3mm; }
  .printCredit { display: block !important; text-align: center; color: #7b6c4f; font-size: 8pt; margin: 2mm 0 0; }
  .mushaf { display: block; --fs: var(--fsp); --lh: 15.4mm; --lw: 139mm; }
  .mpage { width: 210mm; height: 297mm; margin: 0; padding: 10mm 0 0; background: none; box-shadow: none; border-radius: 0;
    display: flex; flex-direction: column; align-items: center; break-after: page; break-inside: avoid; }
  .mpage:first-child { height: auto; padding-top: 4mm; }
  .mpage:last-child { break-after: auto; }
  .phead { width: 165mm; font-size: 12pt; padding: 0 2mm 2mm; }
  .frame { --fb: 8mm; width: 165mm; padding: 1.5mm 3mm; }
  .lines { padding: 0; }
  .pfoot span { font-size: 10pt; }
  .hizb { display: grid; position: absolute; right: -21mm; top: calc(1.5mm + var(--lh) * (var(--row) + .5)); transform: translateY(-50%); width: 13mm; padding: 1.5mm .5mm;
    justify-items: center; text-align: center; line-height: 1.2; border-radius: 40% / 22%; color: #9c7a2c; box-shadow: inset 0 0 0 .3mm #c9a24f, inset 0 0 0 .8mm #fff, inset 0 0 0 1.1mm #e6cf91; }
  .hizb b { font-size: 7pt; } .hizb small { font-size: 6pt; }
  .band, .w.e.bm::after { display: none !important; }
}
.printCredit { display: none; }
.meta i, .phead i { font-style: normal; color: var(--gold-2); font-size: .6em; margin: 0 .35em; vertical-align: .15em; }
.popBtns svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; margin-bottom: 2px; }
.popBtns button[data-act="play"] svg, .popBtns button[data-act="mark"] svg { fill: currentColor; stroke: none; }
.popBtns button[data-act="mark"] { color: var(--gold); }
.tafAyah { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .2em .32em; max-height: 34vh; overflow-y: auto; }
.nw { white-space: nowrap; }
.chip .ic { width: 14px; height: 14px; fill: currentColor; vertical-align: -2px; }
.pill { display: inline-flex; align-items: center; gap: 6px; }
.pill svg { width: 18px; height: 18px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.msgBox { unicode-bidi: plaintext; text-align: start; }
/* bookmark: the whole ayah tinted, a ribbon hanging on its number (the tools' «العلامة» button goes to it) */
.w.e.bm { position: relative; color: var(--gold); }
.w.e.bm::after { content: ""; position: absolute; left: 50%; top: -.42em; width: .36em; height: .62em; transform: translateX(-50%);
  background: linear-gradient(#d9b766, #a77d2a); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.tools button { position: relative; }
.tools .badge { position: absolute; top: 2px; left: 6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: #FAC775; color: #123a30; font-style: normal; font-size: .66rem; font-weight: 800; line-height: 18px; text-align: center; }
/* highlight bands: one continuous band per line behind the ayah (selected, being recited, bookmarked) */
.ln[data-l] { position: relative; }
.ln[data-l] .w { position: relative; z-index: 1; }
.w:hover { color: var(--gold); }
.band { position: absolute; top: 9%; bottom: 9%; z-index: 0; border-radius: .38em; pointer-events: none; animation: bandIn .2s ease; }
@keyframes bandIn { from { opacity: 0; } }
.band.bmk { background: rgba(201, 162, 79, .16); box-shadow: inset 0 -2px 0 rgba(176, 132, 44, .55); }
.band.sel { background: linear-gradient(180deg, rgba(236, 200, 112, .36), rgba(201, 162, 79, .24)); box-shadow: inset 0 0 0 1px rgba(176, 132, 44, .3); }
.band.on { background: rgba(201, 162, 79, .36); box-shadow: inset 0 0 0 1px rgba(176, 132, 44, .35); }
body.night .band.bmk { background: rgba(224, 189, 106, .12); box-shadow: inset 0 -2px 0 rgba(224, 189, 106, .5); }
body.night .band.sel { background: rgba(224, 189, 106, .2); box-shadow: inset 0 0 0 1px rgba(224, 189, 106, .32); }
body.night .band.on { background: rgba(224, 189, 106, .28); }
/* one page on screen: the whole surah in a single frame, no breaks between mushaf pages (print keeps a sheet per page) */
@media screen {
  .mushaf { gap: 0; width: min(var(--pw), 100%); margin: 0 auto; background: var(--page); border-radius: 6px; padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(60, 45, 15, .06), 0 18px 44px rgba(60, 45, 15, .10); }
  .mpage { width: 100%; padding: 0; background: none; box-shadow: none; border-radius: 0; }
  .mpage .frame { border-top-width: 0; border-bottom-width: 0; padding-block: 0; }
  .mpage .lines { padding-block: 0; }
  .mpage:first-child .frame { border-top-width: var(--fb); padding-top: 6px; }
  .mpage:last-child .frame { border-bottom-width: var(--fb); padding-bottom: 6px; }
  .mpage .hizb { top: calc(var(--lh) * (var(--row) + .5)); }
  .mpage:first-child .hizb { top: calc(6px + var(--lh) * (var(--row) + .5)); }
  .mpage .phead, .mpage .pfoot { display: none; }
  .mpage:first-child .phead { display: flex; }
}
@media screen and (min-width: 761px) { .mushaf { padding-inline: 58px; } .mpage { padding-inline: 0; } }
@media screen and (max-width: 560px) { .mushaf { padding: 8px 6px; border-radius: 0; } }

/* the ayah's card: under the tapped ayah, the width of the page */
.pop { width: min(560px, calc(100vw - 16px)); max-width: none; padding: 8px 12px 6px; max-height: 62vh; overflow-y: auto; }
.cardHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cardHead .popTitle { margin: 0; text-align: start; font-size: .82rem; }
.cardX { flex: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .95rem; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.cardX:hover, .cardX:focus-visible { background: var(--sel); outline: none; }
.pop .popMean { display: flex; align-items: center; gap: 10px; max-width: none; margin: 4px 0 6px; padding: 6px 10px; text-align: start; }
.pop .popMean .pm { flex: none; font-size: 24px; line-height: 1.7; }
.cardTaf { margin: 2px 0 6px; font-size: .98rem; line-height: 1.95; }
.pop .popBtns { justify-content: space-around; border-top: 1px solid var(--line); padding-top: 4px; }

/* where one mushaf page ends and the next begins: «صفحة ٢٩٣» between two hairlines, then a breath of space (the
   continuous frame on wide screens; the PDF keeps its own page numbers) */
.pbreak { display: flex; align-items: center; gap: 14px; margin: 10px 0 0; padding-bottom: 14px; color: var(--pnum); font-size: .8rem; font-weight: 600; line-height: 1;
  -webkit-user-select: none; user-select: none; }
.pbreak::before, .pbreak::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.mpage:last-child .pbreak { padding-bottom: 4px; }

/* phones: no frame and no card, one calm cream surface from the bar down (as in a printed page), so the text uses
   the width and comes out larger; the pages are told apart by the divider (the frame stays on wider screens and in
   the PDF) */
@media screen and (max-width: 560px) {
  :root { --paper: #faf3e6; --page: #faf3e6; }
  body { background: var(--page); }
  .top { background: var(--page); }
  .wrap { padding: 6px 0 0; }
  .mushaf { padding: 6px 14px 0; background: transparent; box-shadow: none; border-radius: 0; }
  .mpage { padding: 0; background: transparent; box-shadow: none; border-radius: 0; }
  .frame { border: 0; border-image: none; padding: 0; background: transparent; }
  .mpage .frame { padding-block: 0; }
  .lines { padding: 0; }
  .phead { padding: 0 0 4px; font-size: .86rem; }
  .pbreak { margin: 16px -14px 0; padding: 0 14px 34px; }
  .mpage:last-child .pbreak { padding-bottom: 8px; }
  .done { width: auto; margin: 22px 14px 0; }
  .credit, .madeBy { padding-inline: 14px; }
  .topTitle { font-size: 1.45rem; }
}

/* a tapped ayah: the small bar at the bottom (bookmark · «المزيد»), above the player when a recitation plays */
.ayBar { position: fixed; z-index: 50; left: 50%; bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px; max-width: calc(100vw - 20px); font-family: var(--ui);
  background: var(--page); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 14px 36px rgba(0, 0, 0, .2); animation: ayIn .2s ease; }
body.playing .ayBar { bottom: calc(max(16px, calc(env(safe-area-inset-bottom) + 8px)) + 78px); }
.ayNum { padding-inline: 10px 4px; font-size: .86rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.ayBar button { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: .6rem 1.05rem; font: inherit; font-size: .95rem; font-weight: 700;
  white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .1s ease; }
.ayBar button:active { transform: scale(.96); }
.ayBar svg { width: 17px; height: 17px; flex: none; }
.ayMark { background: #123a30; color: #f6e7bf; }
.ayMark svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.ayMark.on { background: #a07c2e; color: #fff; }
.ayMark.on svg { fill: currentColor; }
.ayMore { background: var(--sel); color: var(--ink); }
.ayMore svg { fill: currentColor; }
.ayBar button:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
body.night .ayMark { background: #e0bd6a; color: #121d19; }
@keyframes ayIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* «المزيد»: a short list, one tap each */
.moreDlg .popMean { display: flex; align-items: center; gap: 10px; max-width: none; margin: 2px 0 10px; padding: 6px 12px; text-align: start; }
.moreDlg .popMean .pm { flex: none; font-size: 24px; line-height: 1.7; }
.moreList { display: grid; gap: 6px; }
.moreList button { display: flex; align-items: center; gap: 12px; width: 100%; border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 14px; padding: .8rem 1rem; font: inherit; font-size: 1rem; font-weight: 600; text-align: start; cursor: pointer; }
.moreList button:hover, .moreList button:focus-visible { background: var(--sel); outline: none; }
.moreList svg { width: 21px; height: 21px; flex: none; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.moreList button[data-act="play"] svg { fill: var(--gold); stroke: none; }
@media print { .ayBar { display: none !important; } }


/* reading progress in green: a ring (default) or a bar; a tap changes it, the third hides it */
.rp { --rp: #1D9E75; --rpT: rgba(29, 158, 117, .16); position: fixed; z-index: 39; left: max(12px, env(safe-area-inset-left));
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 6px)); border: 0; padding: 0; margin: 0; font: inherit; cursor: pointer;
  background: var(--page); color: var(--ink); box-shadow: 0 2px 10px rgba(0, 0, 0, .12), 0 0 0 1px var(--line);
  transition: bottom .25s ease, opacity .2s ease; -webkit-tap-highlight-color: transparent; }
body.night .rp { --rp: #5DCAA5; --rpT: rgba(93, 202, 165, .18); }
.rp[hidden] { display: none; }
.rp.ring { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; }
.rp.bar { width: 34px; height: min(210px, 32vh); border-radius: 17px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 7px; }
.rpRing { display: none; }
.rp.ring .rpRing { display: block; position: absolute; inset: 4px; width: 48px; height: 48px; transform: rotate(-90deg); }
.rpT, .rpF { fill: none; stroke-width: 4.5; }
.rpT { stroke: var(--rpT); }
.rpF { stroke: var(--rp); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .2s linear; }
.rpBar { display: none; }
.rp.bar .rpBar { display: block; position: relative; flex: 1; width: 10px; border-radius: 99px; background: var(--rpT); overflow: hidden; }
.rpBar i { position: absolute; inset: 0 0 auto 0; height: 0; background: var(--rp); border-radius: 99px; transition: height .2s linear; }
.rpN { position: relative; font-size: .82rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.rp.bar .rpN { font-size: .66rem; letter-spacing: -.02em; }
/* out of the way of the tools, the player and the ayah bar */
body.ui .rp, body.playing .rp, body:has(#ayBar:not([hidden])) .rp { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 74px); }
