/* reader */
:root[data-theme="sepia"] {
  --paper: oklch(93% 0.035 80); --paper-2: oklch(90% 0.04 78); --paper-3: oklch(86% 0.045 76);
  --ink: oklch(28% 0.04 60); --ink-2: oklch(40% 0.04 60); --ink-3: oklch(46% 0.04 65);
  --line: oklch(82% 0.04 76); --green: oklch(38% 0.07 150); --ayah: oklch(38% 0.08 145);
  --leaf: oklch(95% 0.035 82);
}
.reading { --leaf: color-mix(in oklch, var(--paper) 55%, white); --desk: var(--paper-2); --fs: 21; --lh: 2.05;
  background: var(--desk); height: 100vh; height: 100dvh; overflow: hidden; }
:root[data-theme="night"] .reading, :root[data-theme="night"] body.reading { --leaf: oklch(23% 0.014 168); --desk: oklch(17% 0.012 168); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .reading { --leaf: oklch(23% 0.014 168); --desk: oklch(17% 0.012 168); } }
:root[data-theme="sepia"] .reading { --leaf: oklch(95% 0.035 82); --desk: oklch(88% 0.04 76); }
.reading main { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.rbar { position: relative; z-index: 30; display: flex; align-items: center; gap: 8px; height: 58px; padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  background: color-mix(in oklch, var(--desk) 92%, transparent); border-bottom: 1px solid var(--line); transition: transform .35s var(--ease); }
.rtitle { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.rtitle a { color: var(--ink); }
.rtitle b { font: 700 19px/1.2 var(--read); white-space: nowrap; }
.rtitle span { font: 400 15px/1.3 var(--read); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rtools { display: flex; gap: 2px; }
.rtools .iconbtn[aria-pressed="false"] { color: var(--ink-3); text-decoration: line-through; }
.rtools .iconbtn[aria-pressed="false"] svg { stroke-dasharray: 2 2.2; }
.rtools .iconbtn.on { background: var(--green-soft); color: var(--green); }
@media (max-width: 560px) { .rtitle span { display: none; } .rtools .iconbtn { width: 38px; } }

.stage { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(14px, 2.4vw, 30px) clamp(8px, 4vw, 70px); scroll-behavior: smooth; perspective: 2200px; }
.book { display: flex; flex-direction: row; align-items: stretch; gap: 0; position: relative; transform-style: preserve-3d; will-change: transform, opacity; }
.book::after { content: ""; position: absolute; top: 0; bottom: 0; inset-inline-start: 50%; width: 46px; transform: translateX(50%); pointer-events: none;
  background: linear-gradient(90deg, transparent, oklch(0% 0 0 / .07) 45%, oklch(0% 0 0 / .13) 50%, oklch(0% 0 0 / .07) 55%, transparent); display: none; }
.book.spread::after { display: block; }
.leaf { position: relative; width: min(600px, calc(100vw - 32px)); min-height: calc(100dvh - 58px - 56px - 2 * clamp(14px, 2.4vw, 30px));
  background: var(--leaf); color: var(--ink); padding: clamp(28px, 4.4vw, 54px) clamp(22px, 4vw, 52px) 54px;
  box-shadow: 0 1px 1px oklch(30% 0.03 80 / .06), 0 18px 40px -22px oklch(25% 0.04 70 / .45); border-radius: 3px; display: flex; flex-direction: column; }
.book.spread .leaf { width: min(560px, calc((100vw - 2 * clamp(8px, 4vw, 70px) - 24px) / 2)); }
.book.spread .leaf:first-child { border-radius: 3px 8px 8px 3px; }  /* right page (RTL first) */
.book.spread .leaf:last-child { border-radius: 8px 3px 3px 8px; }
.book.spread .leaf + .leaf { box-shadow: 0 1px 1px oklch(30% 0.03 80 / .06), 0 18px 40px -22px oklch(25% 0.04 70 / .45); }
.leaf.na { --leaf: color-mix(in oklch, var(--paper-2) 60%, var(--paper)); }
.leaf.na::before { content: "من مقدمة التحقيق"; position: absolute; top: 14px; inset-inline-start: 22px; font: 500 12px/1 var(--ui); color: var(--ink-3); }

.txt { font: 400 calc(var(--fs) * 1px)/var(--lh) var(--read); text-align: justify; text-justify: inter-word; hyphens: none; flex: 1;
  font-feature-settings: "kern", "liga", "calt"; word-spacing: .02em; }
.font-naskh .txt, .font-naskh .fns { font-family: var(--naskh); }
.txt p { margin: 0; text-indent: 1.3em; }
.txt p + p { margin-top: .15em; }
.txt .bh { font: 700 1.12em/1.8 var(--read); text-align: center; margin: .7em 0 .35em; color: var(--green); text-indent: 0; }
.txt h2.bh { font-size: 1.32em; }
.txt .orn { text-align: center; color: var(--gold); letter-spacing: .6em; margin: .6em 0; font-size: .8em; }
.txt .verse { display: grid; grid-template-columns: auto 1fr 1fr; gap: 0 1.1em; margin: .3em 0; text-align: center; align-items: baseline; font-size: .93em; line-height: 1.9; }
.txt .verse > span:not(.vn) { text-align-last: justify; text-align: justify; }
.txt .verse .vn { font: 500 .62em/1 var(--ui); color: var(--ink-3); min-width: 2.4em; text-align: start; }
.txt .verse:not(:has(.vn)) { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .txt .verse, .txt .verse:not(:has(.vn)) { grid-template-columns: 1fr; gap: 0; text-align: start; } .txt .verse > span:not(.vn) { text-align-last: auto; } .txt .verse > span:nth-of-type(odd):not(.vn) ~ span { padding-inline-start: 2em; } .txt .verse .vn { display: none; } }
q.ayah { quotes: none; color: var(--ayah); font-family: var(--read); }
q.ayah::before, q.ayah::after { content: none; }
.ref { font-size: .78em; color: var(--ink-3); white-space: nowrap; }
.hon { font-family: var(--naskh); font-size: 1.05em; color: var(--ink-2); }
b.kw { font-weight: 700; color: var(--ink); }
sup.fn:focus-visible { outline: 2px solid var(--gold-2); }
sup.fn { font: 600 .56em/0 var(--ui); color: var(--gold-2); padding: 0 .12em; cursor: pointer; vertical-align: .9em; border-radius: 4px; }
sup.fn:hover, sup.fn.on { background: var(--gold-soft); }
.fns { margin-top: 1.3em; padding-top: .7em; position: relative; font: 400 calc(var(--fs) * .74px)/1.95 var(--read); color: var(--ink-2); }
.fns::before { content: ""; position: absolute; top: 0; inset-inline-start: 0; width: 34%; height: 1px; background: var(--ink-3); opacity: .5; }
.fns ol { list-style: none; margin: 0; padding: 0; }
.fns li { margin: .12em 0; text-align: justify; border-radius: 6px; transition: background .6s; }
.fns li.flash { background: var(--gold-soft); }
.fns .nn { color: var(--gold-2); font-family: var(--ui); font-size: .82em; font-weight: 600; }
.folio { font: 500 .58em/1 var(--ui); color: var(--ink-3); vertical-align: .35em; white-space: nowrap; }
.no-notes .fns, .no-notes sup.fn, .no-notes .folio { display: none; }
@media (hover: none) { .keys { display: none; } }
.pn { text-align: center; font: 500 13px/1 var(--ui); color: var(--ink-3); margin-top: 18px; letter-spacing: .04em; }
.pn::before, .pn::after { content: "·"; margin: 0 .7em; color: var(--gold); }
.txt mark { background: var(--mark); border-radius: 3px; box-shadow: 0 0 0 2px var(--mark); }

.leaf .scan { display: none; }
.view-scan .leaf .txt, .view-scan .leaf .fns { display: none; }
.view-scan .leaf .scan { display: block; }
.leaf .scan img { width: 100%; height: auto; aspect-ratio: 17 / 24; border-radius: 2px; filter: contrast(1.04); background: var(--paper-2); min-height: 300px; }
:root[data-theme="night"] .leaf .scan img { filter: invert(.88) hue-rotate(180deg) contrast(.95); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .leaf .scan img { filter: invert(.88) hue-rotate(180deg) contrast(.95); } }
.leaf .scan .noscan { padding: 60px 0; text-align: center; color: var(--ink-3); font-size: 14px; }
.view-scan .leaf, .view-both .leaf.is-scan { padding: 14px; }

.turn { position: sticky; top: 40%; flex: none; width: 44px; height: 88px; border: 0; border-radius: 22px; background: transparent; color: var(--ink-3); display: grid; place-items: center; transition: .2s; margin: 0 6px; z-index: 5; }
.turn:hover { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.turn:disabled { opacity: .2; pointer-events: none; }
.turn svg { width: 26px; height: 26px; }
@media (max-width: 760px) {
  .turn { display: none; } .stage { padding-inline: 8px; } .book { width: 100%; min-width: 0; }
  .leaf, .book.spread .leaf { width: 100%; min-width: 0; padding-inline: 20px; }
  .book.spread { flex-direction: column; gap: 12px; } .book.spread::after { display: none; }
}
.mturn { display: none; }
@media (max-width: 760px) { .mturn { display: inline-grid; } }

.book.out-next { animation: outNext .2s var(--ease) forwards; }
.book.in-next { animation: inNext .38s var(--ease); }
.book.out-prev { animation: outPrev .2s var(--ease) forwards; }
.book.in-prev { animation: inPrev .38s var(--ease); }
@keyframes outNext { to { opacity: 0; transform: translateX(34px) rotateY(-7deg); } }
@keyframes inNext { from { opacity: 0; transform: translateX(-34px) rotateY(7deg); } }
@keyframes outPrev { to { opacity: 0; transform: translateX(-34px) rotateY(7deg); } }
@keyframes inPrev { from { opacity: 0; transform: translateX(34px) rotateY(-7deg); } }

.rfoot { display: flex; align-items: center; gap: 14px; height: 56px; padding: 0 max(18px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(18px, env(safe-area-inset-left));
  border-top: 1px solid var(--line); background: color-mix(in oklch, var(--desk) 92%, transparent); }
.where { font-size: 14px; color: var(--ink-2); white-space: nowrap; min-width: 84px; }
.scrub { flex: 1; min-width: 0; width: 100%; accent-color: var(--green); height: 24px; cursor: pointer; }
.rfoot > * { flex-shrink: 0; } .rfoot .scrub { flex-shrink: 1; }
@media (max-width: 560px) { .rfoot { gap: 6px; padding-inline: 6px; } .where { min-width: 0; font-size: 13px; } }

/* sheets */
dialog.sheet { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: none; width: min(420px, 100vw); border: 0; padding: 0 20px 24px;
  background: var(--paper); color: var(--ink); box-shadow: -20px 0 50px -20px oklch(20% 0.03 80 / .35); overflow: auto; overscroll-behavior: contain; }
dialog.sheet[open] { animation: sheetIn .32s var(--ease); }
@keyframes sheetIn { from { transform: translateX(40px); opacity: 0; } }
dialog.sheet::backdrop { background: oklch(20% 0.02 80 / .28); backdrop-filter: blur(2px); }
.sheet header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 14px 0 12px; background: var(--paper); }
.sheet h2 { font-size: 22px; }
.sheet .field.slim { box-shadow: none; border-radius: 999px; padding-block: 0; margin-bottom: 8px; }
.sheet .field.slim input { font-size: 16px; padding: 9px 0; }
.sheet .toc li a.cur { background: var(--green-soft); color: var(--green); }
.goto { display: flex; gap: 8px; margin-bottom: 12px; }
.goto input, .goto select { height: 36px; border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; background: var(--paper); min-width: 0; }
.goto input { flex: 1; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.set > span { font-weight: 500; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .iconbtn { border: 1px solid var(--line); font: 700 14px/1 var(--read); }
.stepper .iconbtn.big { font-size: 22px; }
.stepper output { min-width: 2ch; text-align: center; }
.keys { font-size: 13px; margin-top: 18px; }
.fres { list-style: none; padding: 0; margin: 0; }
.fres a { display: block; padding: 12px 10px; margin-inline: -10px; border-radius: 10px; color: var(--ink); }
.fres a:hover { background: var(--paper-2); }
.fres .meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; }
.fres .meta b { color: var(--green); }
.fres .snip { font: 400 16px/1.9 var(--read); }

/* footnote popover + selection bar */
.pop { position: fixed; z-index: 60; max-height: 60vh; overflow: auto; overscroll-behavior: contain; max-width: min(420px, calc(100vw - 24px)); padding: 12px 16px; border-radius: 12px; background: var(--paper); color: var(--ink-2);
  box-shadow: 0 12px 40px -10px oklch(20% 0.03 80 / .45), 0 0 0 1px var(--line); font: 400 16px/1.9 var(--read); }
.selbar { position: fixed; z-index: 60; display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--ink); color: var(--paper); box-shadow: 0 10px 30px -10px oklch(10% 0.02 80 / .6); }
.selbar button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: inherit; padding: 7px 11px; border-radius: 9px; font-size: 13px; font-weight: 500; }
.selbar button:hover { background: oklch(100% 0 0 / .12); }

.reading .toast { bottom: 76px; }
@media print { .rbar, .rfoot, .turn, dialog { display: none !important; } .reading { height: auto; overflow: visible; } .leaf { box-shadow: none; } }

/* marked passages (hadith, athar, qawl) + poetry + ayat, each switchable */
.txt .mk.t-hadith { color: var(--c-hadith); }
.txt .mk.t-athar { color: var(--c-athar); }
.txt .mk.t-qawl { color: var(--c-qawl); }
.txt .verse { color: var(--c-poem); }
.no-hadith .txt .mk.t-hadith, .no-athar .txt .mk.t-athar, .no-qawl .txt .mk.t-qawl, .no-poem .txt .verse, .no-ayah q.ayah { color: inherit; }
.txt .mk.flash, .txt q.ayah.flash, .txt .verse.flash { background: color-mix(in oklch, var(--gold) 26%, transparent); border-radius: 4px; box-shadow: 0 0 0 3px color-mix(in oklch, var(--gold) 26%, transparent); transition: background 1.2s, box-shadow 1.2s; }
.set.col { flex-direction: column; align-items: stretch; }
.marks { display: flex; flex-wrap: wrap; gap: 8px; }
.mchip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink-3); font: 600 15px/1 var(--read); transition: .2s; }
.mchip .ix-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--paper-2); color: var(--ink-3); transition: .2s; }
.mchip .ix-ic svg { width: 17px; height: 17px; }
.mchip[aria-pressed="true"] { color: var(--c); border-color: color-mix(in oklch, var(--c) 50%, var(--line)); background: color-mix(in oklch, var(--c) 7%, var(--paper)); }
.mchip[aria-pressed="true"] .ix-ic { background: var(--c); color: var(--paper); }
dialog.sheet.wide { width: min(560px, 100vw); }
.sheet .ix-tab { min-width: 104px; padding: 10px 12px; }
.sheet .ix-tab .ix-ic { width: 34px; height: 34px; }
.sheet .ix-group { top: 52px; background: linear-gradient(var(--paper) 75%, transparent); }
.sheet .ix-text { font-size: 17px; }

/* ───────── book look: paper, spine, page edges ───────── */
.reading { --desk: oklch(90.5% 0.022 78); --leaf: oklch(97.6% 0.014 86); --edge: oklch(88% 0.02 80); }
:root[data-theme="night"] .reading, :root[data-theme="night"] body.reading { --desk: oklch(23% 0.012 70); --leaf: oklch(29% 0.013 75); --edge: oklch(35% 0.012 75); }
:root[data-theme="sepia"] .reading { --desk: oklch(85% 0.045 72); --leaf: oklch(94.5% 0.04 84); --edge: oklch(84% 0.04 76); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .reading { --desk: oklch(23% 0.012 70); --leaf: oklch(29% 0.013 75); --edge: oklch(35% 0.012 75); } }
.reading { background: radial-gradient(120% 90% at 50% 0%, color-mix(in oklch, var(--desk) 70%, white) 0%, var(--desk) 55%, color-mix(in oklch, var(--desk) 88%, black) 100%) fixed; }
.leaf {
  background-color: var(--leaf);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .25 0 0 0 .055 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  border-radius: 6px;
  box-shadow: 0 1px 0 var(--edge), 0 2px 0 color-mix(in oklch, var(--edge) 85%, black 4%), 0 3px 0 var(--edge),
              0 30px 50px -28px oklch(25% 0.04 60 / .5), 0 6px 14px -8px oklch(25% 0.04 60 / .25);
}
.book.spread .leaf.side-r { border-radius: 2px 7px 7px 2px; box-shadow: inset 34px 0 34px -30px oklch(20% 0.03 60 / .22), 2px 1px 0 var(--edge), 3px 2px 0 var(--edge), 4px 3px 0 color-mix(in oklch, var(--edge) 90%, black 6%), 0 30px 50px -28px oklch(25% 0.04 60 / .5); }
.book.spread .leaf.side-l { border-radius: 7px 2px 2px 7px; box-shadow: inset -34px 0 34px -30px oklch(20% 0.03 60 / .22), -2px 1px 0 var(--edge), -3px 2px 0 var(--edge), -4px 3px 0 color-mix(in oklch, var(--edge) 90%, black 6%), 0 30px 50px -28px oklch(25% 0.04 60 / .5); }
.book::after { display: none !important; }
.book.spread { filter: drop-shadow(0 1px 0 color-mix(in oklch, var(--edge) 60%, transparent)); }
.leaf.na::before { content: none; }
.rh { display: flex; justify-content: center; margin: -10px 0 22px; padding-bottom: 10px; position: relative; }
.rh span { font: 400 14px/1.4 var(--read); color: var(--ink-3); max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rh::after { content: ""; position: absolute; bottom: 0; left: 18%; right: 18%; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in oklch, var(--gold) 70%, transparent), transparent); }
.pn { margin-top: 26px; font: 600 13px/1 var(--ui); color: var(--ink-3); display: flex; align-items: center; justify-content: center; gap: 12px; }
.pn::before, .pn::after { content: ""; width: 34px; height: 1px; margin: 0; background: linear-gradient(90deg, transparent, var(--gold)); }
.pn::after { background: linear-gradient(90deg, var(--gold), transparent); }
.turn { width: 52px; height: 52px; border-radius: 999px; background: color-mix(in oklch, var(--leaf) 70%, transparent); box-shadow: 0 2px 10px -4px oklch(25% 0.04 60 / .3); color: var(--ink-2); }
.turn:hover { background: var(--leaf); color: var(--green); transform: scale(1.06); }
.turn:focus-visible { outline: 2px solid var(--green-2); outline-offset: 3px; }

/* the turning page */
.turn-layer { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
.turn-layer .face { position: absolute; overflow: hidden; border-radius: 6px; background: var(--leaf); }
.turn-layer .face > .leaf { min-height: 0; box-shadow: none; border-radius: 0; }
.turn-layer .flipper { position: absolute; transform-style: preserve-3d; will-change: transform; }
.turn-layer .flipper .face { inset: 0; left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 20px 60px -20px oklch(20% 0.04 60 / .55); }
.turn-layer .flipper .face.back { transform: rotateY(180deg); }
.turn-layer .shade { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: linear-gradient(90deg, oklch(15% 0.03 60 / .55), oklch(15% 0.03 60 / .08) 45%, oklch(100% 0 0 / .18) 70%, oklch(15% 0.03 60 / .3)); }

/* ═════════ reader as an open manuscript on a lapis binding ═════════ */
.reading { --desk: var(--lapis); --leaf: oklch(93.6% 0.034 83); --edge: oklch(84% 0.04 78); --chrome: var(--lapis-2); --chrome-ink: oklch(88% 0.03 82); }
:root[data-theme="night"] .reading, :root[data-theme="night"] body.reading { --desk: oklch(23% 0.012 70); --leaf: oklch(29% 0.013 75); --edge: oklch(35% 0.012 75); --chrome: oklch(21% 0.012 70); --chrome-ink: var(--ink-2); }
:root[data-theme="sepia"] .reading { --desk: oklch(42% 0.05 55); --leaf: oklch(91.5% 0.045 80); --edge: oklch(80% 0.05 74); --chrome: oklch(32% 0.04 55); --chrome-ink: oklch(90% 0.03 82); }
:root[data-theme="light"] .reading { --leaf: oklch(96% 0.022 85); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .reading { --desk: oklch(23% 0.012 70); --leaf: oklch(29% 0.013 75); --chrome: oklch(21% 0.012 70); --chrome-ink: var(--ink-2); } }
body.reading { background:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='84' viewBox='0 0 84 84' fill='none' stroke='%23d9b25f' stroke-opacity='.10' stroke-width='1'%3E%3Crect x='26' y='26' width='32' height='32'/%3E%3Crect x='26' y='26' width='32' height='32' transform='rotate(45 42 42)'/%3E%3Cpath d='M0 42h18M66 42h18M42 0v18M42 66v18'/%3E%3C/svg%3E"),
  radial-gradient(110% 80% at 50% 10%, color-mix(in oklch, var(--desk) 82%, white) 0%, var(--desk) 55%, color-mix(in oklch, var(--desk) 75%, black) 100%) fixed; }
.rbar, .rfoot { background: var(--chrome); border-color: oklch(72% 0.12 80 / .35); color: var(--chrome-ink); }
.rbar .iconbtn, .rfoot .iconbtn { color: var(--chrome-ink); }
.rbar .iconbtn:hover, .rfoot .iconbtn:hover { background: oklch(100% 0 0 / .1); color: var(--gold); }
.rtools .iconbtn.on { background: var(--gold); color: var(--chrome); }
.rtitle a, .rtitle b { color: oklch(95% 0.02 85); }
.rtitle span { color: oklch(78% 0.04 82); }
.rfoot .where { color: var(--chrome-ink); }
.rfoot .muted { color: oklch(74% 0.04 82); }
.scrub { accent-color: var(--gold); }
.turn { background: oklch(100% 0 0 / .08); color: oklch(88% 0.03 82); box-shadow: inset 0 0 0 1px oklch(72% 0.12 80 / .35); }
.turn:hover { background: var(--gold); color: var(--lapis-2); }
/* the page: vellum, aged edges, gold-ruled frame like an illuminated manuscript */
.leaf { background-image:
  radial-gradient(130% 110% at 50% 45%, transparent 62%, oklch(60% 0.06 70 / .16) 100%),
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .36 0 0 0 0 .22 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.leaf::after { content: ""; position: absolute; inset: 14px; pointer-events: none; border: 1px solid oklch(66% 0.11 78 / .55); border-radius: 2px;
  box-shadow: inset 0 0 0 3px transparent, inset 0 0 0 4px oklch(66% 0.11 78 / .3); }
:root[data-theme="night"] .leaf::after { border-color: oklch(70% 0.09 80 / .3); box-shadow: inset 0 0 0 4px oklch(70% 0.09 80 / .15); }
.leaf { padding-top: clamp(40px, 5vw, 62px); padding-bottom: 62px; padding-inline: clamp(30px, 4.6vw, 60px); }
.txt .bh { color: var(--rubric); }
.txt .orn { color: var(--gold-2); }
.rh span { color: var(--gold-2); font-weight: 700; }
.pn { color: var(--gold-2); }
@media (max-width: 760px) { .leaf, .book.spread .leaf { padding-inline: 26px; } .leaf::after { inset: 8px; } }
/* calmer in-text marking: tinted ink, not loud colour */
.txt .mk.t-hadith { color: color-mix(in oklch, var(--c-hadith) 72%, var(--ink)); }
.txt .mk.t-athar { color: color-mix(in oklch, var(--c-athar) 70%, var(--ink)); }
.txt .mk.t-qawl { color: color-mix(in oklch, var(--c-qawl) 70%, var(--ink)); }
.reading { --desk: oklch(31% 0.055 252); }
.reading { --desk: oklch(30% 0.045 42); }
.turn-layer .face { background: transparent; }
.turn-layer .face > .leaf { position: absolute; }
.turn-layer .flipper .face { box-shadow: none; }
.turn-layer .flipper .face > .leaf { box-shadow: 0 20px 60px -20px oklch(20% 0.04 60 / .55); }
.sheet .toc .tt { font-size: 16.5px; }
.sheet .toc li.l1 > a .tt { font-size: 17.5px; }

/* ── phone reading: floating bars that slide away ── */
.rbar, .rfoot { transition: transform .4s var(--ease); }
[data-where] { cursor: pointer; border-radius: 8px; padding: 4px 6px; }
[data-where]:hover { background: oklch(100% 0 0 / .08); }
@media (max-width: 760px) {
  body.reading { height: 100dvh; }
  .rbar { position: fixed; top: 0; inset-inline: 0; z-index: 30; }
  .rfoot { position: fixed; bottom: 0; inset-inline: 0; z-index: 30; height: calc(56px + env(safe-area-inset-bottom)); }
  .stage { padding-top: calc(58px + 10px); padding-bottom: calc(56px + 18px + env(safe-area-inset-bottom)); height: 100dvh; flex: none; }
  .standalone .stage { padding-top: calc(58px + 10px + env(safe-area-inset-top)); }
  .immersive .rbar { transform: translateY(-110%); }
  .immersive .rfoot { transform: translateY(110%); }
  .leaf { min-height: calc(100dvh - 58px - 56px - 30px); }
  .rtools .iconbtn { width: 42px; height: 42px; }
  .rfoot .iconbtn { width: 46px; height: 46px; }
}
/* measuring for fit: pages at their natural height */
.book.measuring .leaf { min-height: 0 !important; }
.fit-chip[aria-pressed="true"] { background: var(--lapis); color: var(--vellum); border-color: var(--lapis); }
.stepper output { min-width: 4ch; font-size: 14px; }
@media (max-width: 760px) { .fit-chip { display: none; } }
/* fit mode: compact page furniture, wider pages */
.fit .stage { padding-top: 12px; padding-bottom: 12px; }
.fit .leaf { padding: 30px clamp(24px, 3vw, 44px) 24px; }
.fit .leaf::after { inset: 9px; }
.fit .rh { margin: -6px 0 12px; padding-bottom: 7px; }
.fit .rh span { font-size: 13px; }
.fit .pn { margin-top: 12px; font-size: 12px; }
.fit .fns { margin-top: .8em; padding-top: .5em; line-height: 1.75; }
.fit .txt .bh { margin: .4em 0 .2em; }
.fit .book.spread .leaf { width: min(640px, calc((100vw - 2 * 64px - 24px) / 2)); }
.fit .leaf { min-height: calc(100dvh - 58px - 56px - 24px); }
