/* Quran section: builds on styles.css tokens (light + dark). UI font Vazirmatn; text Amiri Quran (OFL, self-hosted);
   mushaf pages use the per-page Madinah mushaf fonts (assets/qp/NNN.woff2, loaded on demand by quran.js). */
@font-face { font-family: "Amiri Quran"; src: url("assets/AmiriQuran-Regular.woff2") format("woff2"); font-display: swap; }

.q-body {
  --q-em: #0f4c3b; --q-em-2: #176450; --q-em-deep: #0a3329;
  --q-gold: #a8823c; --q-gold-2: #d6b873; --q-gold-wash: rgba(184, 146, 74, .11); --q-gold-line: rgba(168, 130, 60, .45);
  --q-paper: #fdf8ea; --q-paper-2: #f3e9cc; --q-ink: #1b1a14; --q-mark: rgba(201, 160, 70, .28); --q-play: rgba(23, 100, 80, .16);
  --q-dir: ltr; background: var(--bg);
}
html[dir="rtl"] .q-body { --q-dir: rtl; }
:root[data-theme="dark"] .q-body {
  --q-em: #12392f; --q-em-2: #1d5546; --q-em-deep: #0b241e;
  --q-gold: #d6b46a; --q-gold-2: #e5cb8c; --q-gold-wash: rgba(214, 180, 106, .10); --q-gold-line: rgba(214, 180, 106, .38);
  --q-paper: #24221b; --q-paper-2: #1b1a15; --q-ink: #efe6cc; --q-mark: rgba(214, 180, 106, .26); --q-play: rgba(95, 191, 152, .18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .q-body {
    --q-em: #12392f; --q-em-2: #1d5546; --q-em-deep: #0b241e;
    --q-gold: #d6b46a; --q-gold-2: #e5cb8c; --q-gold-wash: rgba(214, 180, 106, .10); --q-gold-line: rgba(214, 180, 106, .38);
    --q-paper: #24221b; --q-paper-2: #1b1a15; --q-ink: #efe6cc; --q-mark: rgba(214, 180, 106, .26); --q-play: rgba(95, 191, 152, .18);
  }
}
.quran { --q-fs: 2.15rem; --q-trfs: 1.03rem; }
.qi { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------- layout: content + bookmarks panel on the right ---------- */
.q-shell { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "main side"; direction: ltr; align-items: start; }
.q-shell > * { direction: var(--q-dir); }
.q-shell > main { grid-area: main; min-width: 0; }
.q-shell > .q-side { grid-area: side; }
html.q-side-off .q-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
html.q-side-off .q-shell > .q-side { display: none; }

/* ---------- hero ---------- */
.q-hero { position: relative; color: #f6f1e2; padding: 22px 0 20px; overflow: hidden;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='84' viewBox='0 0 84 84'%3E%3Cg fill='none' stroke='%23d6b873' stroke-opacity='.17' stroke-width='1'%3E%3Crect x='22' y='22' width='40' height='40'/%3E%3Crect x='22' y='22' width='40' height='40' transform='rotate(45 42 42)'/%3E%3Ccircle cx='42' cy='42' r='9'/%3E%3Cpath d='M0 0l22 22M84 0L62 22M0 84l22-22M84 84L62 62'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(120% 140% at 85% 0%, var(--q-em-2) 0%, var(--q-em) 45%, var(--q-em-deep) 100%); }
.q-hero::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--q-gold-2), transparent); opacity: .7; }
.q-hero .crumbs, .q-hero .crumbs a { color: rgba(246, 241, 226, .72); }
.q-hero .crumbs a:hover { color: #fff; }
.q-hero h1 { margin: 4px 0 4px; font-size: clamp(1.45rem, 3.2vw, 2.15rem); font-weight: 800; line-height: 1.35; color: #fff; }
.q-lede { margin: 0 0 14px; color: rgba(246, 241, 226, .82); font-size: .95rem; max-width: 70ch; line-height: 1.9; }
.q-hero-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.q-hero-idx { padding: 26px 0 26px; text-align: center; }
.q-hero-idx .crumbs { text-align: start; }
.q-hero-top { margin: 4px auto 16px; max-width: 760px; }
.q-hero-ar { font-family: "Amiri Quran", serif; font-size: clamp(2.2rem, 6vw, 3.3rem); color: var(--q-gold-2); margin: 0; line-height: 1.8; }
.q-hero-idx h1 { font-size: 1.1rem; font-weight: 700; color: rgba(255, 255, 255, .9); margin: 0 0 6px; }
.q-hero-idx .q-lede { margin-inline: auto; }
.q-hero-idx .q-tabs { margin-top: 16px; }
.q-note { margin: 0 0 10px; padding: 8px 12px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .1); border: 1px solid var(--q-gold-line); font-size: .88rem; }

/* tabs: index / ayah by ayah / mushaf */
.q-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, .18); border: 1px solid rgba(214, 184, 115, .35); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.q-tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 999px; color: rgba(246, 241, 226, .88); text-decoration: none; font-weight: 700; font-size: .88rem; white-space: nowrap; transition: background .2s, color .2s; }
.q-tabs a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.q-tabs a.on { background: linear-gradient(180deg, var(--q-gold-2), var(--q-gold)); color: #1d1608; box-shadow: 0 2px 10px rgba(0, 0, 0, .2); }

/* ---------- buttons ---------- */
.q-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 17px; border-radius: 999px; font: inherit; font-weight: 700; font-size: .88rem; line-height: 1.2;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background .18s, border-color .18s, color .18s, transform .12s, box-shadow .18s; white-space: nowrap; }
.q-btn:active { transform: translateY(1px); }
.q-btn-main { background: linear-gradient(180deg, var(--q-em-2), var(--q-em)); color: #fff; box-shadow: 0 2px 8px rgba(15, 76, 59, .25); }
.q-btn-main .qi { color: var(--q-gold-2); }
.q-btn-main:hover { box-shadow: 0 4px 14px rgba(15, 76, 59, .35); }
.q-btn-soft { background: var(--surface); color: var(--text); border-color: var(--border); }
.q-btn-soft:hover, .q-btn-soft:focus-visible { border-color: var(--q-gold); color: var(--text); }
.q-btn-icon { width: 40px; height: 40px; padding: 0; background: var(--surface); color: var(--text-dim); border-color: var(--border); }
.q-btn-icon:hover { border-color: var(--q-gold); color: var(--text); }
.q-btn-icon[aria-pressed="true"] { background: var(--q-gold-wash); border-color: var(--q-gold); color: var(--q-gold); }
.q-btn-icon[aria-pressed="true"] .qi { fill: currentColor; }
.q-x { background: none; border: 0; color: var(--text-mute); cursor: pointer; padding: 6px; border-radius: 50%; display: inline-grid; place-items: center; }
.q-x:hover { background: var(--q-gold-wash); color: var(--text); }

/* ---------- search ---------- */
.q-search { position: relative; display: flex; gap: 8px; max-width: 720px; margin-inline: auto; }
.q-search input { flex: 1; min-width: 0; padding: 13px 16px; padding-inline-start: 44px; border-radius: 999px; border: 1px solid rgba(214, 184, 115, .5); background: rgba(255, 255, 255, .96); color: #1b1e15; font: inherit; font-size: .95rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); }
.q-search input:focus { outline: 2px solid var(--q-gold-2); outline-offset: 2px; }
.q-search-i { position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%); color: #8a7a52; pointer-events: none; }
.q-search .q-btn { padding-inline: 22px; }
.q-search-sm { margin: 0; max-width: 640px; }
.q-search-sm input { box-shadow: none; border-color: var(--border); background: var(--surface); color: var(--text); padding-block: 10px; }

/* ---------- sections ---------- */
.q-sec { padding-block: 16px; }
.q-h2 { margin: 0 0 14px; font-size: 1.12rem; font-weight: 800; }
.q-h2 small { color: var(--text-mute); font-weight: 600; font-size: .8rem; }
.q-h2-orn { display: flex; align-items: center; gap: 12px; }
.q-h2-orn span { display: inline-flex; align-items: center; gap: 10px; }
.q-h2-orn span::before { content: ""; width: 12px; height: 12px; transform: rotate(45deg); border: 2px solid var(--q-gold); border-radius: 2px; }
.q-h2-orn::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--q-gold-line), transparent); }
html[dir="rtl"] .q-h2-orn::after { background: linear-gradient(270deg, var(--q-gold-line), transparent); }
.q-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; min-width: 0; }

/* feature cards on the index */
.q-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; padding-top: 22px; }
.q-feat { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); color: inherit; text-decoration: none; position: relative; overflow: hidden; transition: border-color .2s, transform .2s, box-shadow .2s; }
.q-feat:hover { border-color: var(--q-gold); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, .08); }
.q-feat b { display: block; font-size: 1rem; }
.q-feat small { display: block; color: var(--text-dim); font-size: .84rem; line-height: 1.7; margin-top: 2px; }
.q-feat-i { flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(160deg, var(--q-em-2), var(--q-em)); color: var(--q-gold-2); }
.q-feat-i .qi { width: 24px; height: 24px; }
.q-feat-resume { border-color: var(--q-gold); background: linear-gradient(135deg, var(--q-gold-wash), var(--surface) 70%); }

/* eight-pointed star badge (surah numbers, ayah numbers) */
.q-star { position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none; color: var(--text); text-decoration: none; }
.q-star::before, .q-star::after { content: ""; position: absolute; inset: 6px; border: 1.5px solid var(--q-gold); border-radius: 3px; background: var(--q-gold-wash); }
.q-star::after { transform: rotate(45deg); }
.q-star b { position: relative; z-index: 1; font-weight: 800; font-size: .84rem; }
.q-star-lg { width: 62px; height: 62px; }
.q-star-lg::before, .q-star-lg::after { inset: 9px; border-color: var(--q-gold-2); background: rgba(255, 255, 255, .06); }
.q-star-lg b { font-size: 1.1rem; color: #fff; }

/* surah grid */
.q-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.q-card { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: inherit; text-decoration: none; transition: border-color .18s, transform .18s, box-shadow .18s; }
.q-card:hover, .q-card:focus-visible { border-color: var(--q-gold); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, .06); }
.q-card:hover .q-star::before, .q-card:hover .q-star::after { background: var(--q-gold); }
.q-card:hover .q-star b { color: #fff; }
.q-names { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.q-loc { font-weight: 700; font-size: .95rem; }
.q-loc small { display: block; color: var(--text-mute); font-weight: 500; font-size: .76rem; }
.q-meta { color: var(--text-mute); font-size: .76rem; }
.q-ar { font-family: "Amiri Quran", "Vazirmatn", serif; font-size: 1.45rem; font-weight: 400; line-height: 1.6; color: var(--q-gold); }
.q-juz { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.q-juz a { display: flex; flex-direction: column; gap: 1px; padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); text-decoration: none; color: inherit; }
.q-juz a:hover { border-color: var(--q-gold); }
.q-juz b { font-size: .88rem; } .q-juz span { color: var(--text-mute); font-size: .76rem; }

/* ---------- surah page ---------- */
.q-hero-s { padding-bottom: 14px; }
.q-title { display: flex; align-items: center; gap: 14px; }
.q-title h1 { margin: 0; }
.q-sub { margin: 2px 0 0; color: rgba(246, 241, 226, .75); font-size: .86rem; }
.q-sname { margin: 14px auto 2px; max-width: 520px; text-align: center; padding: 6px 30px; border: 1.5px solid var(--q-gold-2); border-radius: 10px; position: relative;
  box-shadow: inset 0 0 0 4px rgba(10, 51, 41, .6), inset 0 0 0 5.5px rgba(214, 184, 115, .6); background: rgba(0, 0, 0, .12); }
.q-sname span { font-family: "Amiri Quran", serif; font-size: clamp(1.5rem, 4vw, 2rem); color: var(--q-gold-2); line-height: 1.9; }
.q-sname::before, .q-sname::after { content: "۞"; position: absolute; top: 50%; transform: translateY(-50%); color: var(--q-gold-2); font-size: 1.1rem; }
.q-sname::before { inset-inline-start: 10px; } .q-sname::after { inset-inline-end: 10px; }

.q-bar { position: sticky; top: var(--q-hdr, 72px); z-index: 25; background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); padding: 9px 0; box-shadow: 0 6px 18px rgba(0, 0, 0, .04); }
.q-bar-in { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }
.q-f { display: flex; flex-direction: column; gap: 3px; font-size: .72rem; color: var(--text-mute); min-width: 0; font-weight: 600; }
.q-f select, .q-f input[type=text] { padding: 8px 11px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .86rem; max-width: 240px; min-height: 38px; }
.q-f select:focus, .q-f input:focus { outline: 2px solid var(--q-gold); outline-offset: 1px; }
.q-goto-in { display: flex; gap: 6px; }
.q-goto input { width: 86px; }
.q-goto .q-btn { padding: 8px 14px; }
.q-acts { flex-direction: row; align-items: center; gap: 8px; margin-inline-start: auto; }
.q-sbox { padding-top: 10px; }

/* settings dropdown */
.q-set { position: relative; }
.q-set > summary { list-style: none; }
.q-set > summary::-webkit-details-marker { display: none; }
.q-set[open] > summary { border-color: var(--q-gold); }
.q-set-p { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: min(320px, 86vw); padding: 14px; display: grid; gap: 12px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: 0 18px 40px rgba(0, 0, 0, .16); }
.q-set-p .q-f select { max-width: none; width: 100%; }
.q-set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-switch { display: inline-flex; align-items: center; gap: 9px; font-size: .86rem; color: var(--text); cursor: pointer; font-weight: 600; }
.q-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.q-switch i { width: 38px; height: 22px; border-radius: 99px; background: var(--border); position: relative; transition: background .2s; }
.q-switch i::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.q-switch input:checked + i { background: var(--q-em-2); }
.q-switch input:checked + i::after { transform: translateX(16px); }
html[dir="rtl"] .q-switch input:checked + i::after { transform: translateX(-16px); }
.q-switch input:focus-visible + i { outline: 2px solid var(--q-gold); outline-offset: 2px; }
.q-fs { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.q-fs button { background: var(--surface); border: 0; padding: 7px 14px; color: var(--text); cursor: pointer; font-weight: 800; font-family: inherit; }
.q-fs button:hover { background: var(--q-gold-wash); }
.q-fs button + button { border-inline-start: 1px solid var(--border); }

/* reading */
.q-read { padding-block: 20px 8px; max-width: 1000px; }
.q-bis { text-align: center; font-family: "Amiri Quran", serif; font-size: calc(var(--q-fs) * var(--q-scale, 1) * 1.08); line-height: 2.2; margin: 4px 0 16px; color: var(--q-gold); }
.q-ay { position: relative; padding: 14px 18px 14px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); scroll-margin-top: calc(var(--q-hdr, 72px) + 84px); transition: border-color .25s, background .25s, box-shadow .25s; }
.q-ay::before { content: ""; position: absolute; inset-block: 14px; inset-inline-start: -1px; width: 3px; border-radius: 3px; background: transparent; transition: background .25s; }
.q-ay:hover { border-color: var(--q-gold-line); }
.q-ay.is-target { border-color: var(--q-gold); box-shadow: 0 0 0 3px var(--q-mark); }
.q-ay.is-playing { background: linear-gradient(0deg, var(--q-play), var(--q-play)), var(--surface); border-color: var(--q-em-2); }
.q-ay.is-playing::before { background: var(--q-em-2); }
.q-ay-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-ay-no b { font-size: .8rem; }
.q-tag { font-size: .72rem; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--q-gold-line); color: var(--text-dim); background: var(--q-gold-wash); font-weight: 600; }
.q-tag-saj { color: var(--q-gold); }
.q-ay-tools { margin-inline-start: auto; display: inline-flex; gap: 4px; }
.q-ay-tools button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--text-mute); cursor: pointer; display: grid; place-items: center; transition: background .15s, color .15s, border-color .15s; }
.q-ay-tools button:hover, .q-ay-tools button:focus-visible { background: var(--q-gold-wash); color: var(--text); border-color: var(--q-gold-line); }
.q-ay-tools button[aria-pressed="true"] { color: var(--q-gold); }
.q-ay-tools button[aria-pressed="true"] .qi { fill: currentColor; }
.q-ay-tools button[data-act="play"] { color: var(--q-em-2); }
:root[data-theme="dark"] .q-ay-tools button[data-act="play"] { color: #7fd0ad; }
.q-ay.is-playing .q-ay-tools button[data-act="play"] { background: var(--q-em-2); color: #fff; }
.q-ar-t { margin: 8px 0 6px; font-family: "Amiri Quran", "Vazirmatn", serif; font-size: calc(var(--q-fs) * var(--q-scale, 1)); line-height: 2.3; text-align: right; color: var(--text); word-spacing: .06em; }
.q-end { color: var(--q-gold); font-size: .92em; white-space: nowrap; }
.q-tr { margin: 6px 0 0; font-size: calc(var(--q-trfs) * var(--q-scale, 1)); line-height: 2; color: var(--text-dim); padding-top: 8px; border-top: 1px solid var(--border-soft); }
.q-tr[dir="ltr"] { text-align: left; line-height: 1.75; }
.q-tr[dir="rtl"] { text-align: right; }
.q-read.no-tr .q-tr { display: none; }
.q-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; max-width: 1000px; }

/* search results */
.q-res-head { display: flex; align-items: center; justify-content: space-between; }
.q-res { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.q-res li { border: 1px solid var(--border-soft); border-radius: var(--r); padding: 11px 14px; background: var(--inset); }
.q-res a.ref { font-weight: 800; color: var(--q-gold); text-decoration: none; font-size: .85rem; }
.q-res .r-ar { font-family: "Amiri Quran", "Vazirmatn", serif; font-size: 1.35rem; line-height: 2; margin: 4px 0 0; direction: rtl; text-align: right; }
.q-res .r-tr { margin: 2px 0 0; color: var(--text-dim); font-size: .93rem; line-height: 1.85; }
.q-res mark { background: var(--q-mark); color: inherit; border-radius: 3px; padding: 0 1px; }

/* sources + faq */
.q-src { border-top: 1px solid var(--border-soft); margin-top: 10px; }
.q-trust { margin: 0; display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--text-dim); line-height: 1.9; }
.q-trust::before { content: ""; flex: none; width: 10px; height: 10px; transform: rotate(45deg); background: var(--q-gold); border-radius: 2px; }
.q-fine { margin: 6px 0 0; font-size: .8rem; color: var(--text-mute); }
.q-lic { margin-top: 8px; font-size: .72rem; color: var(--text-mute); }
.q-lic summary { cursor: pointer; display: inline-block; }
.q-lic p { margin: 6px 0 0; line-height: 1.7; direction: ltr; text-align: left; }
.q-faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 11px 16px; margin-bottom: 8px; }
.q-faq details[open] { border-color: var(--q-gold-line); }
.q-faq summary { cursor: pointer; font-weight: 700; }
.q-faq p { margin: 8px 0 2px; color: var(--text-dim); line-height: 1.95; font-size: .92rem; }

/* ---------- bookmarks panel (right side) ---------- */
.q-side { position: sticky; top: var(--q-hdr, 72px); height: calc(100vh - var(--q-hdr, 72px)); overflow-y: auto; border-left: 1px solid var(--border); background: var(--surface); padding: 14px 14px 24px; z-index: 30; }
.q-side-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.q-side-h b { display: inline-flex; align-items: center; gap: 8px; font-size: 1rem; }
.q-side-h b .qi { color: var(--q-gold); fill: var(--q-gold-wash); }
.q-side-last { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 14px; border-radius: var(--r); text-decoration: none; color: inherit;
  background: linear-gradient(140deg, var(--q-em-2), var(--q-em)); color: #fff; box-shadow: 0 6px 18px rgba(15, 76, 59, .25); }
.q-side-last .q-feat-i { width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, .12); }
.q-side-last small { display: block; font-size: .74rem; opacity: .8; }
.q-side-last b { display: block; font-size: .92rem; }
.q-side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.q-side-list li { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); overflow: hidden; transition: border-color .15s; }
.q-side-list li:hover { border-color: var(--q-gold); }
.q-side-list li.cur { border-color: var(--q-gold); background: var(--q-gold-wash); }
.q-side-list a { flex: 1; min-width: 0; display: block; padding: 9px 12px; text-decoration: none; color: var(--text); }
.q-side-list a b { display: flex; align-items: center; gap: 6px; font-size: .86rem; }
.q-side-list a b i { font-style: normal; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--q-gold-wash); color: var(--q-gold); border: 1px solid var(--q-gold-line); }
.q-side-list a span { display: block; font-family: "Amiri Quran", serif; font-size: 1.02rem; color: var(--text-dim); line-height: 1.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: right; }
.q-side-list button { border: 0; border-inline-start: 1px solid var(--border); background: none; color: var(--text-mute); padding: 0 10px; cursor: pointer; }
.q-side-list button:hover { color: #b3261e; background: rgba(179, 38, 30, .06); }
.q-side-empty { font-size: .84rem; color: var(--text-mute); line-height: 1.9; margin: 6px 2px; }
.q-side-btn { position: fixed; z-index: 45; bottom: 22px; right: 18px; width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--q-gold-line); cursor: pointer;
  background: linear-gradient(160deg, var(--q-em-2), var(--q-em)); color: var(--q-gold-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .22); display: none; place-items: center; }
.q-side-btn .qi { width: 24px; height: 24px; }
.q-side-cnt { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--q-gold-2); color: #1d1608; font-size: .72rem; font-weight: 800; display: grid; place-items: center; }
html.q-side-off .q-side-btn { display: grid; }

/* ---------- play choice popover + mini player ---------- */
.q-pop { position: absolute; z-index: 60; width: min(300px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--q-gold-line); border-radius: var(--r-lg); box-shadow: 0 20px 44px rgba(0, 0, 0, .2); padding: 12px; animation: qpop .16s ease-out; }
@keyframes qpop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.q-pop h3 { margin: 0 0 8px; font-size: .9rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.q-pop-b { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; text-align: start; margin-top: 6px; }
.q-pop-b:hover, .q-pop-b:focus-visible { border-color: var(--q-gold); background: var(--q-gold-wash); }
.q-pop-b .qi { color: var(--q-em-2); width: 20px; height: 20px; }
:root[data-theme="dark"] .q-pop-b .qi { color: #7fd0ad; }
.q-pop-b.on .qi { fill: currentColor; color: var(--q-gold); }
.q-pop-tr { margin: 10px 2px 2px; font-size: .9rem; line-height: 2; color: var(--text-dim); max-height: 40vh; overflow: auto; border-top: 1px solid var(--border-soft); padding-top: 8px; }
.q-player { position: fixed; z-index: 55; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 7px 10px; width: max-content; max-width: calc(100vw - 24px);
  border-radius: 999px; background: rgba(10, 51, 41, .94); color: #f6f1e2; box-shadow: 0 14px 36px rgba(0, 0, 0, .3); border: 1px solid rgba(214, 184, 115, .35); backdrop-filter: blur(8px); animation: qpop .2s ease-out; }
.q-pl-b { width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; }
.q-pl-b:hover { background: rgba(255, 255, 255, .1); }
.q-pl-main { background: var(--q-gold-2); color: #1d1608; width: 42px; height: 42px; }
.q-pl-main:hover { background: #ecd59c; }
.q-pl-t { font-size: .84rem; font-weight: 700; padding-inline: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.q-seg { display: inline-flex; border: 1px solid rgba(214, 184, 115, .4); border-radius: 999px; overflow: hidden; }
.q-seg button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: rgba(246, 241, 226, .75); font: inherit; font-size: .76rem; font-weight: 700; padding: 6px 11px; cursor: pointer; }
.q-seg button.on { background: rgba(214, 184, 115, .25); color: #fff; }
.q-seg .qi { width: 15px; height: 15px; }
.q-toast { position: fixed; inset-inline: 0; bottom: 84px; margin-inline: auto; width: max-content; max-width: 88vw; padding: 9px 18px; border-radius: 99px; background: var(--text); color: var(--bg); font-size: .88rem; z-index: 70; box-shadow: var(--shadow); }

/* ---------- mushaf: a paper Quran page (always light, like a printed mushaf) ---------- */
.q-hero-m { padding-bottom: 14px; }
.q-hero-m .q-lede { margin-top: 8px; font-size: .88rem; }
.q-stage { --pw: 560px; position: relative; display: flex; flex-direction: column; align-items: center; padding: 22px 12px 26px; overflow-x: clip;
  user-select: none; -webkit-user-select: none; background: #f1eee2; color: #2b2a22; }
.q-mhead { width: var(--pw); max-width: 100%; display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 8px; font-family: "Amiri Quran", serif; font-size: 1.05rem; color: #3d4b34; line-height: 1.6; }
.q-book-wrap { position: relative; width: var(--pw); max-width: 100%; }
.q-book { width: calc(var(--pw) * 1.9) !important; height: calc(var(--pw) * 1.58) !important; min-height: 0 !important; max-width: none !important; min-width: 0 !important; margin: 0 calc(var(--pw) * -0.45); filter: drop-shadow(0 10px 22px rgba(60, 50, 20, .18)); }
.q-turn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 52px; height: 52px; border-radius: 50%; border: 1px solid #cdbf93; background: #fffdf4; color: #6b5a2a;
  cursor: pointer; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(60, 50, 20, .16); transition: background .15s, transform .15s; }
.q-turn:hover { background: #f6efd8; transform: translateY(-50%) scale(1.06); }
.q-turn .qi { width: 26px; height: 26px; stroke-width: 2.2; }
.q-turn-l { left: -76px; } .q-turn-r { right: -76px; }
.q-mnav { position: sticky; bottom: 0; z-index: 20; width: calc(var(--pw) + 24px); max-width: calc(100% + 12px); display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 10px 12px; background: rgba(241, 238, 226, .95); backdrop-filter: blur(8px); border-radius: 16px 16px 0 0; }
.q-mnav-b { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid #cdbf93; background: #fffdf4; color: #3a3420;
  font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer; transition: background .15s, box-shadow .15s; -webkit-tap-highlight-color: transparent; }
.q-mnav-b:hover { background: #f6efd8; box-shadow: 0 4px 12px rgba(60, 50, 20, .12); }
.q-mnav-b:active { transform: translateY(1px); }
.q-mnav-b:disabled { opacity: .4; cursor: default; }
.q-mnav-b .qi { width: 20px; height: 20px; stroke-width: 2.2; }
.q-mnav-next { background: linear-gradient(180deg, #1d6a52, #0f4c3b); color: #fff; border-color: transparent; }
.q-mnav-next:hover { background: linear-gradient(180deg, #227a5f, #125643); }
.q-mnav-n { font-weight: 700; color: #4a4530; font-size: 1rem; white-space: nowrap; direction: ltr; }
.q-stage:fullscreen { justify-content: center; padding: 10px; }
/* sizes here must apply at once: the site-wide reduced-motion rule (* transition-duration .01ms) otherwise
   animates the --pw width change, the flip library measures the old 560px book and draws the page off-centre */
.q-stage, .q-mhead, .q-book-wrap, .q-book, .q-book .stf__wrapper, .q-book .stf__block, .q-pg, .q-pg-in, .q-mnav { transition-property: none !important; }

/* page-flip library (structure only) */
.q-book .stf__wrapper { padding-bottom: 0 !important; height: calc(var(--pw) * 1.58); }
.stf__parent { position: relative; display: block; box-sizing: border-box; transform: translateZ(0); touch-action: pan-y; }
.stf__wrapper { position: relative; width: 100%; box-sizing: border-box; }
.stf__parent canvas { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
.stf__block { position: absolute; width: 100%; height: 100%; box-sizing: border-box; perspective: 2000px; }
.stf__item { display: none; position: absolute; transform-style: preserve-3d; }
.stf__outerShadow, .stf__innerShadow, .stf__hardShadow, .stf__hardInnerShadow { position: absolute; left: 0; top: 0; }

.q-pg { background: #fffdf3; color: #111; overflow: hidden; user-select: none; -webkit-user-select: none; }
.q-pg-in { position: absolute; inset: 0; padding: 10% 10.5% 8.5%; display: flex; flex-direction: column; direction: rtl; }
/* ornamental border: two thin rules with a patterned band between them, well clear of the text */
.q-pg-in::after { content: ""; position: absolute; inset: 2.2%; border: 1.5px solid #a08a4c; border-radius: 3px; pointer-events: none;
  background: repeating-linear-gradient(45deg, rgba(160, 138, 76, .16) 0 3px, rgba(160, 138, 76, 0) 3px 7px), repeating-linear-gradient(-45deg, rgba(76, 110, 80, .12) 0 3px, rgba(76, 110, 80, 0) 3px 7px); }
.q-pg-in::before { content: ""; position: absolute; inset: 4.4%; z-index: 1; border: 1.5px solid #a08a4c; border-radius: 2px; background: #fffdf3; pointer-events: none; }
.q-lines, .q-pg-num, .q-pg-load { position: relative; z-index: 2; }
.q-lines { flex: 1; display: grid; grid-template-rows: repeat(15, 1fr); align-items: center; min-height: 0; }
.q-lines > .q-ln { height: 100%; }
.q-ln { display: flex; justify-content: space-between; align-items: center; white-space: nowrap; direction: rtl; line-height: 1; font-size: var(--fs, 20px); }
.q-ln.c { justify-content: center; gap: .16em; }
.q-ln .w { cursor: pointer; border-radius: .2em; transition: background .15s, color .15s; }
.q-ln .w.hl { background: rgba(214, 180, 90, .3); }
.q-ln .w.pl { background: rgba(120, 190, 120, .3); }
@media (hover: hover) { .q-ln .w:hover { background: rgba(214, 180, 90, .2); } }
.q-ln-h { justify-content: center; }
.q-ln-h span { display: grid; place-items: center; width: 78%; height: 82%; font-family: "Amiri Quran", serif; color: #1f3a2c; font-size: calc(var(--fs, 20px) * .78); line-height: 1;
  border: 1.5px solid #7d9466; border-radius: 999px; background: linear-gradient(180deg, #f4f7e6, #e7eed2); box-shadow: inset 0 0 0 3px #fffdf3, inset 0 0 0 4px #c2ad6f; position: relative; }
.q-ln-h span::before, .q-ln-h span::after { content: "۞"; position: absolute; top: 50%; transform: translateY(-50%); color: #a08a4c; font-size: .8em; }
.q-ln-h span::before { right: -1.2em; } .q-ln-h span::after { left: -1.2em; }
.q-ln-b { justify-content: center; font-family: "Amiri Quran", serif; font-size: calc(var(--fs, 20px) * .82); color: #111; }
.q-pg-num { text-align: center; font-family: "Amiri Quran", serif; color: #6b5a2a; font-size: var(--hfs, 14px); margin-top: 1%; }
.q-pg.open .q-pg-in { padding: 18% 16% 16%; }
.q-pg.open .q-pg-in::before { inset: 7%; border-radius: 50% 50% 6px 6px / 14% 14% 6px 6px; box-shadow: inset 0 0 0 4px #fffdf3, inset 0 0 0 5.5px #c2ad6f; }
.q-pg.open .q-lines { grid-template-rows: repeat(8, 1fr); flex: none; height: 60%; margin-block: auto; }
.q-pg-load { position: absolute; inset: 0; display: grid; place-items: center; color: #a08a4c; font-size: .85rem; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .q-shell { display: block; }
  .q-shell > .q-side { position: fixed; top: 0; bottom: 0; right: 0; height: auto; width: min(88vw, 330px); transform: translateX(105%); transition: transform .28s ease; box-shadow: -18px 0 40px rgba(0, 0, 0, .18); z-index: 80; display: block; }
  html.q-side-off .q-shell > .q-side { display: block; }
  html.q-side-open .q-shell > .q-side { transform: none; }
  .q-side-btn { display: grid; }
  html.q-side-open .q-side-btn { display: none; }
}
@media (max-width: 720px) {
  .quran { --q-fs: 1.8rem; --q-trfs: .97rem; }
  .q-grid { grid-template-columns: 1fr; }
  .q-bar { position: static; }
  .q-f { flex: 1 1 140px; }
  .q-f select { max-width: 100%; }
  .q-acts { flex-basis: 100%; margin-inline-start: 0; }
  .q-acts .q-btn-main { flex: 1; }
  .q-ay { padding: 12px 12px 10px; scroll-margin-top: calc(var(--q-hdr, 64px) + 10px); }
  .q-hero-row .q-tabs { width: 100%; justify-content: center; }
  .q-tabs a { padding: 8px 12px; font-size: .82rem; }
  .q-stage { padding: 12px 6px 0; }
  .q-turn { display: none; }
  .q-mnav { position: sticky; bottom: 0; z-index: 20; width: calc(100% + 12px); max-width: none; margin: 10px -6px 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(241, 238, 226, .96); backdrop-filter: blur(8px); border-top: 1px solid #ddd3b3; }
  .q-mnav-b { min-height: 48px; padding: 0 12px; flex: 1; justify-content: center; white-space: nowrap; font-size: .88rem; }
  .q-mnav-n { font-size: .85rem; }
  .q-hero-m { padding: 12px 0 10px; }
  .q-hero-m .q-lede, .q-hero-m .crumbs { display: none; }
  .q-hero-m h1 { font-size: 1.25rem; }
  .q-body-m .q-bar-in { gap: 6px 8px; }
  .q-body-m .q-f > span:first-child { display: none; }
  .q-body-m .q-goto-in { width: 100%; }
  .q-body-m .q-goto { flex: 1 1 100%; }
  .q-body-m .q-goto input { flex: 1; width: auto; min-width: 0; }
  .q-side-btn { width: 46px; height: 46px; bottom: 16px; right: 12px; }
  .q-player { bottom: 10px; gap: 2px; padding: 6px 8px; }
  .q-seg span, .q-pl-t { display: none; }
  .q-search .q-btn { padding-inline: 14px; }
}
@media (prefers-reduced-motion: reduce) { .q-card, .q-feat, .q-pop, .q-player { transition: none; animation: none; } }
