/* =====================================================================
   «استقالة من نفسك» — the page-flip reader (reader.css)
   Everything is scoped under #reader. Tokens come from site.css when it
   is loaded; the fallbacks below make the module work on its own.
   Geometry (page size, margins, font, line height) is driven by custom
   properties that reader.js sets on #reader — the hidden measuring page
   and the visible pages read the SAME values, so pagination is exact.
   ===================================================================== */

#reader {
  /* shared tokens (fallbacks) */
  --rd-bg: var(--bg, #f4f4f2);
  --rd-surface: var(--surface, #ebebe8);
  --rd-line: var(--line, rgba(17, 20, 23, .10));
  --rd-fg: var(--fg, #121417);
  --rd-dim: var(--dim, #6d7278);
  --rd-soft: var(--soft, #3d4248);
  --rd-accent: var(--accent, #173f37);
  --rd-cover: var(--cover, #173f37);
  --rd-cover-2: var(--cover-2, #0c2722);
  --rd-cover-ink: var(--cover-ink, #f3f2ee);
  --rd-cover-sub: var(--cover-sub, #b6c6bf);
  --rd-paper: var(--paper, #fbfbf9);
  --rd-ink: var(--ink, #16191d);
  --rd-display: var(--display, "Alexandria", "IBM Plex Sans Arabic", "Segoe UI", sans-serif);
  --rd-ui: var(--body, "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif);
  --rd-read: var(--read, "Markazi Text", "Noto Naskh Arabic", serif);
  --rd-hand: var(--hand, "Aref Ruqaa", serif);

  /* reader-only (derived) */
  --rd-desk: #e2e2de;
  --rd-desk-hi: #ebebe8;
  --rd-desk-lo: #cbccc7;
  --rd-chrome: var(--rd-soft);
  --rd-chrome-dim: var(--rd-dim);
  --rd-chrome-bg: rgba(244, 244, 242, .82);
  --rd-chrome-line: rgba(17, 20, 23, .14);
  --rd-card: #f1f3ef;
  --rd-em: #2c3a36;
  --rd-ayah: #173f37;
  --rd-page-shadow: rgba(10, 14, 16, .30);
  --rd-gut-1: rgba(14, 18, 20, .26);
  --rd-gut-2: rgba(14, 18, 20, .08);
  --rd-edge-a: #e9e9e4;
  --rd-edge-b: #cfcfc8;
  --rd-cast: 0, 0, 0;
  --rd-end: #0f2f29;

  /* derived colours: plain fallbacks first, color-mix where the browser has it */
  --mx-accent-14: rgba(23, 63, 55, .14);
  --mx-accent-55: rgba(23, 63, 55, .55);
  --mx-accent-22: rgba(23, 63, 55, .22);
  --mx-accent-28: rgba(23, 63, 55, .28);
  --mx-accent-11: rgba(23, 63, 55, .11);
  --mx-dim-55: rgba(109, 114, 120, .55);
  --mx-dim-60: rgba(109, 114, 120, .6);
  --mx-dim-6: rgba(109, 114, 120, .06);
  --mx-cover-ink-25: rgba(243, 242, 238, .25);
  --mx-paper-90-b9b4a4: #f0f0ec;
  --mx-chrome-45: rgba(61, 66, 72, .45);
  --mx-ink-6: rgba(22, 25, 29, .06);
  --mx-desk-60: rgba(226, 226, 222, .6);

  /* geometry, set by JS (px as plain numbers) */
  --pw: 540;
  --ph: 810;
  --pt: 70;
  --pb: 110;
  --pin: 64;
  --pout: 44;
  --tw: 432;
  --fz: 22;
  --lh: 39;
  --H: 624;

  position: relative;
  display: block;
  width: 100%;
  height: var(--reader-h, 100vh);
  min-height: 420px;
  overflow: hidden;
  background:
    radial-gradient(120% 95% at 50% 46%, var(--rd-desk-hi) 0%, var(--rd-desk) 58%, var(--rd-desk-lo) 100%);
  color: var(--rd-fg);
  font-family: var(--rd-ui);
  direction: rtl;
  text-align: start;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  isolation: isolate;
  contain: layout paint;
}

@supports (height: 100dvh) {
  #reader { height: var(--reader-h, 100dvh); }
}

#reader *,
#reader *::before,
#reader *::after { box-sizing: border-box; }

:where(#reader) button { font: inherit; }

/* ---------- night reading ---------- */
#reader.rd-night {
  --rd-desk: #101214;
  --rd-desk-hi: #171a1c;
  --rd-desk-lo: #08090a;
  --rd-chrome: #c9ccce;
  --rd-chrome-dim: #8c9296;
  --rd-chrome-bg: rgba(20, 23, 25, .82);
  --rd-chrome-line: rgba(255, 255, 255, .14);
  --rd-fg: #e6e4de;
  --rd-paper: #2b2a27;
  --rd-ink: #dedad0;
  --rd-soft: #b8b5ac;
  --rd-dim: #8f8c84;
  --rd-accent: #8bbcae;
  --rd-card: #302f2b;
  --rd-em: #e7e3d7;
  --rd-ayah: #a7d0c3;
  --rd-line: rgba(255, 255, 255, .12);
  --rd-page-shadow: rgba(0, 0, 0, .6);
  --rd-gut-1: rgba(0, 0, 0, .45);
  --rd-gut-2: rgba(0, 0, 0, .16);
  --rd-edge-a: #3a3935;
  --rd-edge-b: #22211f;
  --rd-end: #0a1f1b;
  --mx-accent-14: rgba(139, 188, 174, .16);
  --mx-accent-55: rgba(139, 188, 174, .55);
  --mx-accent-22: rgba(139, 188, 174, .24);
  --mx-accent-28: rgba(139, 188, 174, .3);
  --mx-accent-11: rgba(139, 188, 174, .13);
  --mx-dim-55: rgba(143, 140, 132, .55);
  --mx-dim-60: rgba(143, 140, 132, .6);
  --mx-dim-6: rgba(143, 140, 132, .08);
  --mx-paper-90-b9b4a4: #35332f;
  --mx-chrome-45: rgba(201, 204, 206, .45);
  --mx-ink-6: rgba(222, 218, 208, .07);
  --mx-desk-60: rgba(16, 18, 20, .6);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
  #reader, #reader.rd-night {
    --mx-accent-14: color-mix(in srgb, var(--rd-accent) 14%, transparent);
    --mx-accent-55: color-mix(in srgb, var(--rd-accent) 55%, transparent);
    --mx-accent-22: color-mix(in srgb, var(--rd-accent) 22%, transparent);
    --mx-accent-28: color-mix(in srgb, var(--rd-accent) 28%, transparent);
    --mx-dim-55: color-mix(in srgb, var(--rd-dim) 55%, transparent);
    --mx-dim-60: color-mix(in srgb, var(--rd-dim) 60%, transparent);
    --mx-dim-6: color-mix(in srgb, var(--rd-dim) 6%, transparent);
    --mx-cover-ink-25: color-mix(in srgb, var(--rd-cover-ink) 25%, transparent);
    --mx-paper-90-b9b4a4: color-mix(in srgb, var(--rd-paper) 90%, #b9b4a4);
    --mx-chrome-45: color-mix(in srgb, var(--rd-chrome) 45%, transparent);
    --mx-ink-6: color-mix(in srgb, var(--rd-ink) 6%, transparent);
    --mx-accent-11: color-mix(in srgb, var(--rd-accent) 11%, transparent);
    --mx-desk-60: color-mix(in srgb, var(--rd-desk) 60%, transparent);
  }
}

/* the desk follows the site's --bg: a little darker, like a gallery wall in shade */
@supports (color: color-mix(in srgb, red 50%, blue)) {
  #reader:not(.rd-night) {
    --rd-desk: color-mix(in srgb, var(--rd-bg) 90%, #4a4f55);
    --rd-desk-hi: color-mix(in srgb, var(--rd-bg) 97%, #4a4f55);
    --rd-desk-lo: color-mix(in srgb, var(--rd-bg) 80%, #4a4f55);
    --rd-chrome-bg: color-mix(in srgb, var(--rd-bg) 82%, transparent);
  }
}

/* ---------- layers ---------- */
.rd-stage {
  position: absolute;
  inset: 0;
  touch-action: pan-y pinch-zoom;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
  overflow: hidden;
}

.rd-fit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  transition: opacity .2s ease;
}
.rd-fit.rd-fade { opacity: 0; }

.rd-book {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--pw) * 2px);
  height: calc(var(--ph) * 1px);
  margin-left: calc(var(--pw) * -1px);
  margin-top: calc(var(--ph) * -.5px);
  transform-origin: 50% 50%;
  perspective: calc(var(--pw) * 6.5px);
  perspective-origin: 50% 48%;
}

#reader.rd-single .rd-book {
  width: calc(var(--pw) * 1px);
  margin-left: calc(var(--pw) * -.5px);
}

.rd-ground {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--gl, 0) * 1px);
  right: calc(var(--gr, 0) * 1px);
  border-radius: 2px;
  box-shadow:
    0 calc(var(--ph) * .03px) calc(var(--ph) * .05px) calc(var(--ph) * -.014px) var(--rd-page-shadow),
    0 calc(var(--ph) * .004px) calc(var(--ph) * .012px) rgba(0, 0, 0, .16);
  pointer-events: none;
}

/* stacks of page edges, left (unread) and right (read) */
.rd-ground::after {
  content: "";
  position: absolute;
  left: 1px; right: 1px; top: 100%;
  height: 5px;
  background: repeating-linear-gradient(to bottom, var(--rd-edge-a) 0 1px, var(--rd-edge-b) 1px 2px);
  border-radius: 0 0 2px 2px;
  opacity: .9;
}
.rd-edge {
  position: absolute;
  top: calc(var(--ph) * .006px);
  bottom: calc(var(--ph) * .006px);
  width: calc(var(--ew, 0) * 1px);
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, var(--rd-edge-a) 0 1px, var(--rd-edge-b) 1px 2px);
  opacity: .95;
}
.rd-edge-l { right: calc(100% - var(--gl, 0) * 1px); border-radius: 2px 0 0 2px; }
.rd-edge-r { left: calc(100% - var(--gr, 0) * 1px); border-radius: 0 2px 2px 0; }
#reader.rd-single .rd-edge,
#reader.rd-single .rd-cwr { display: none; }

/* ---------- leaves ---------- */
.rd-leaf,
.rd-turn {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--pw) * 1px);
  height: calc(var(--ph) * 1px);
  transform-origin: 100% 50%;
  transform-style: preserve-3d;
}
#reader.rd-single .rd-leaf,
#reader.rd-single .rd-turn { left: 0; }

.rd-leaf[hidden],
.rd-turn[hidden] { display: none; }
.rd-leaf.rd-off { visibility: hidden; }

.rd-face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.rd-face.rd-bk { transform: rotateY(180deg); }


.rd-cwrap {
  position: absolute;
  top: 0;
  height: 100%;
  width: calc(var(--pw) * 1px);
  overflow: hidden;
  pointer-events: none;
  z-index: 15;
}
.rd-cwl { left: 0; }
.rd-cwr { left: calc(var(--pw) * 1px); }
.rd-cast {
  position: absolute;
  top: 0;
  height: 100%;
  pointer-events: none;
  opacity: 0;
}
.rd-castl { background: linear-gradient(to left, rgba(var(--rd-cast), .42) 0%, rgba(var(--rd-cast), .2) 28%, rgba(var(--rd-cast), .07) 62%, rgba(var(--rd-cast), 0) 100%); }
.rd-castr { background: linear-gradient(to right, rgba(var(--rd-cast), .42) 0%, rgba(var(--rd-cast), .2) 28%, rgba(var(--rd-cast), .07) 62%, rgba(var(--rd-cast), 0) 100%); }
.rd-ss { position: absolute; inset: 0; pointer-events: none; }

@keyframes rd-nudge-a { 35% { transform: translateX(-9px); } }
@keyframes rd-nudge-b { 35% { transform: translateX(9px); } }
.rd-book.rd-nudge-a { animation: rd-nudge-a .32s ease; }
.rd-book.rd-nudge-b { animation: rd-nudge-b .32s ease; }

/* strips of the turning leaf */
.rd-seg {
  position: absolute;
  top: 0;
  height: 100%;
  transform-origin: 100% 50%;
  transform-style: preserve-3d;
}
.rd-slice {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.rd-slice.rd-sb { transform: rotateY(180deg); }
.rd-slice > .rd-page {
  position: absolute;
  top: 0;
  width: calc(var(--pw) * 1px);
}

/* ---------- pages ---------- */
.rd-page {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--pw) * 1px);
  height: calc(var(--ph) * 1px);
  background: var(--rd-paper);
  color: var(--rd-ink);
  overflow: hidden;
  font-family: var(--rd-read);
  font-size: calc(var(--fz) * 1px);
  line-height: calc(var(--lh) * 1px);
  font-weight: 400;
  direction: rtl;
  text-align: start;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  contain: layout style;
}
.rd-page > i { position: absolute; pointer-events: none; display: block; }

/* paper: a faint grain and a cool edge */
.rd-paper-grain {
  inset: 0;
  opacity: .5;
  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='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1  0 0 0 0 .1  0 0 0 0 .1  0 0 0 .045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
#reader.rd-night .rd-paper-grain { opacity: .35; }

/* gutter shadow at the spine, a soft rim at the fore edge */
.rd-gut { top: 0; bottom: 0; width: calc(var(--pw) * .12px); }
.rd-l > .rd-gut { right: 0; background: linear-gradient(to left, var(--rd-gut-1), var(--rd-gut-2) 38%, transparent); }
.rd-r > .rd-gut { left: 0; background: linear-gradient(to right, var(--rd-gut-1), var(--rd-gut-2) 38%, transparent); }
.rd-rim { top: 0; bottom: 0; width: 10px; opacity: .8; }
.rd-l > .rd-rim { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, .075), transparent); }
.rd-r > .rd-rim { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, .075), transparent); }

/* ---------- running head, folio ---------- */
.rd-run,
.rd-folio {
  position: absolute;
  left: 0;
  right: 0;
  font-family: var(--rd-display);
  color: var(--rd-dim);
  white-space: nowrap;
  pointer-events: none;
}
.rd-l > .rd-run, .rd-l > .rd-folio { left: calc(var(--pout) * 1px); right: calc(var(--pin) * 1px); }
.rd-r > .rd-run, .rd-r > .rd-folio { left: calc(var(--pin) * 1px); right: calc(var(--pout) * 1px); }
.rd-run {
  top: calc(var(--pt) * .42px);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: calc(var(--fz) * .5px);
  line-height: 1.4;
  font-weight: 400;
  letter-spacing: .01em;
}
.rd-run span:first-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rd-run span:last-child { flex: none; opacity: .8; }
.rd-folio {
  bottom: calc(var(--pb) * .36px);
  text-align: center;
  font-size: calc(var(--fz) * .56px);
  line-height: 1.2;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* ---------- the text area (the measuring page uses the same rules) ---------- */
.rd-body {
  position: absolute;
  top: calc(var(--pt) * 1px);
  width: calc(var(--tw) * 1px);
  height: calc(var(--H) * 1px);
  direction: rtl;
  text-align: justify;
  text-justify: inter-word;
  word-spacing: 0;
  hyphens: manual;
  overflow: visible;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}
.rd-l > .rd-body { right: calc(var(--pin) * 1px); }
.rd-r > .rd-body { left: calc(var(--pin) * 1px); }

.rd-body p,
.rd-body h2, .rd-body h3, .rd-body h4,
.rd-body ol, .rd-body ul, .rd-body li { margin: 0; padding: 0; }

.rd-body p { text-indent: 1.55em; }
.rd-body p.rd-c,
.rd-body h3 + p, .rd-body h4 + p,
.rd-body .rd-open + p,
.rd-body .rd-box-label + p,
.rd-body .rd-label + p { text-indent: 0; }
.rd-body .rd-m { text-align-last: justify; }

/* inline marks: nothing may change the line box height */
.rd-body strong { font-weight: 700; line-height: 0; }
.rd-body em, .rd-body bdi, .rd-body span, .rd-body sup { line-height: 0; }
.rd-body em { font-style: normal; font-weight: 500; color: var(--rd-em); }
.rd-body em bdi, .rd-body bdi em { font-style: italic; font-weight: 400; color: inherit; }
.rd-body bdi[dir="ltr"] {
  font-family: "IBM Plex Sans Arabic", var(--rd-read);
  font-size: .78em;
  font-weight: 400;
  letter-spacing: .005em;
  unicode-bidi: isolate;
}
.rd-body em bdi[dir="ltr"] { font-style: normal; font-weight: 500; }
.rd-body sup.ref {
  font-family: var(--rd-display);
  font-size: .5em;
  font-weight: 600;
  color: var(--rd-accent);
  vertical-align: baseline;
  position: relative;
  top: -.62em;
  margin-inline: .06em 0;
  padding: .2em .12em;
  cursor: pointer;
  border-radius: 3px;
  pointer-events: auto;
}
.rd-body sup.ref:hover { background: var(--mx-accent-14); }
.rd-body .ayah {
  font-weight: 500;
  color: var(--rd-ayah);
  font-size: 1.04em;
}
.rd-body .nass {
  font-weight: 500;
  color: var(--rd-ayah);
}

/* headings */
.rd-body h3 {
  margin-top: calc(var(--lh) * 1px);
  font-family: var(--rd-display);
  font-weight: 600;
  font-size: calc(var(--fz) * .8px);
  line-height: calc(var(--lh) * 1px);
  color: var(--rd-ink);
  text-align: start;
  text-wrap: balance;
}
.rd-body h3::before {
  content: "";
  display: inline-block;
  width: .95em;
  height: 2px;
  background: var(--rd-accent);
  margin-inline-end: .6em;
  vertical-align: middle;
  transform: translateY(-.1em);
}
.rd-body h4 {
  margin-top: calc(var(--lh) * 1px);
  font-family: var(--rd-display);
  font-weight: 500;
  font-size: calc(var(--fz) * .72px);
  line-height: calc(var(--lh) * 1px);
  color: var(--rd-soft);
  text-align: start;
}
.rd-body > :first-child { margin-top: 0; }
.rd-body .rd-box > h3:first-child, .rd-body .rd-box > h4:first-child { margin-top: 0; }

/* lists */
.rd-body ol, .rd-body ul { padding-inline-start: 2.1em; text-align: justify; }
.rd-body ol { list-style: arabic-indic; }
.rd-body ul { list-style: disc; }
.rd-body li { text-indent: 0; }
.rd-body li::marker { color: var(--rd-accent); font-weight: 600; font-family: var(--rd-display); font-size: .7em; }
.rd-body li.rd-c { list-style: none; }
.rd-body li + li { margin-top: calc(var(--lh) * .12px); }

/* boxes */
.rd-body .rd-label,
.rd-body .rd-box-label {
  font-family: var(--rd-display);
  font-weight: 600;
  font-size: calc(var(--fz) * .56px);
  line-height: calc(var(--lh) * .8px);
  letter-spacing: .02em;
  text-indent: 0;
  text-align: start;
  color: var(--rd-dim);
}
.rd-body .rd-box {
  margin-top: calc(var(--lh) * .75px);
  padding: calc(var(--lh) * .4px) calc(var(--fz) * .78px) calc(var(--lh) * .42px);
  font-size: .86em;
  line-height: calc(var(--lh) * .76px);
  position: relative;
  text-align: justify;
}
.rd-body > .rd-box:first-child { margin-top: 0; }
.rd-body .rd-box > :first-child { margin-top: 0; }
.rd-body .rd-box p { text-indent: 0; }
.rd-body .rd-box p + p, .rd-body .rd-box p + ol, .rd-body .rd-box ol + p, .rd-body .rd-box ul + p, .rd-body .rd-box p + ul { margin-top: calc(var(--lh) * .2px); }
.rd-body .rd-box h3 { line-height: calc(var(--lh) * .9px); margin-top: calc(var(--lh) * .5px); }

/* the tool card: a ruled card you would photograph and keep */
.rd-body .rd-k-tool {
  background: var(--rd-card);
  border: 1px solid var(--mx-accent-55);
  border-top: 3px solid var(--rd-accent);
  outline: 1px solid var(--mx-accent-22);
  outline-offset: 3px;
  margin-inline: 4px;
  margin-bottom: 4px;
}
.rd-body .rd-k-tool > .rd-box-label {
  color: var(--rd-accent);
  display: flex;
  align-items: center;
  gap: .6em;
  padding-bottom: calc(var(--lh) * .12px);
  margin-bottom: calc(var(--lh) * .3px);
  border-bottom: 1px solid var(--mx-accent-28);
}
.rd-body .rd-k-tool > .rd-box-label::before {
  content: "";
  width: .62em;
  height: .62em;
  background: var(--rd-accent);
  flex: none;
}
.rd-body .rd-k-tool > .rd-box-label span { margin-inline-start: auto; font-weight: 400; color: var(--rd-dim); letter-spacing: 0; }
.rd-body .rd-box.rd-tight { line-height: calc(var(--lh) * .71px); }
.rd-body .rd-k-tool.rd-bc { border-top-width: 1px; border-top-style: dashed; margin-top: 0; }
.rd-body .rd-k-tool.rd-bm { border-bottom-style: dashed; }
.rd-body .rd-k-tool p strong:first-child { color: var(--rd-accent); }

/* the guard box: quieter, grey rule */
.rd-body .rd-k-guard,
.rd-body .rd-k-box,
.rd-body .rd-k-quote {
  border-top: 1px solid var(--mx-dim-55);
  border-bottom: 1px solid var(--mx-dim-55);
  border-inline-start: 3px solid var(--mx-dim-60);
  background: var(--mx-dim-6);
  color: var(--rd-soft);
  font-size: .9em;
}
.rd-body .rd-k-guard > .rd-label, .rd-body .rd-k-box > h4 { color: var(--rd-soft); }
.rd-body .rd-k-guard.rd-bc, .rd-body .rd-k-box.rd-bc { border-top-style: dashed; margin-top: 0; }
.rd-body .rd-k-guard.rd-bm, .rd-body .rd-k-box.rd-bm { border-bottom-style: dashed; }

/* phones: a narrow measure reads better ragged than justified */
#reader.rd-fluid .rd-body,
#reader.rd-fluid .rd-body .rd-box,
#reader.rd-fluid .rd-body ol,
#reader.rd-fluid .rd-body ul { text-align: start; }
#reader.rd-fluid .rd-body .rd-m { text-align-last: auto; }

/* ---------- the references page ---------- */
.rd-body .rd-refhead {
  font-family: var(--rd-display);
  font-weight: 600;
  font-size: calc(var(--fz) * .78px);
  line-height: calc(var(--lh) * 1px);
  color: var(--rd-ink);
  margin: 0;
  padding-bottom: calc(var(--lh) * .15px);
  border-bottom: 1px solid var(--rd-line);
  text-align: start;
  margin-bottom: calc(var(--lh) * .3px);
}
.rd-body .rd-refhead small { font-weight: 400; color: var(--rd-dim); font-size: .8em; margin-inline-start: .5em; }
.rd-body .rd-ref {
  display: flex;
  gap: .7em;
  align-items: baseline;
  font-size: calc(var(--fz) * .66px);
  line-height: calc(var(--lh) * .62px);
  color: var(--rd-soft);
  margin-top: calc(var(--lh) * .16px);
  text-align: start;
}
.rd-body .rd-ref b {
  flex: none;
  min-width: 1.5em;
  font-family: var(--rd-display);
  font-weight: 600;
  font-size: .86em;
  color: var(--rd-accent);
  text-align: start;
}
.rd-body .rd-ref > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rd-body .rd-ref > span[dir="ltr"] { text-align: left; font-family: "IBM Plex Sans Arabic", var(--rd-read); font-size: .88em; line-height: inherit; }
.rd-body .rd-ref em { font-style: italic; font-weight: 400; color: inherit; }
.rd-body .rd-ref bdi[dir="ltr"] { font-family: "IBM Plex Sans Arabic", var(--rd-read); font-size: .88em; }

/* ---------- chapter opener ---------- */
.rd-open {
  position: relative;
  text-align: start;
  padding-top: calc(var(--lh) * 2.2px);
}
.rd-ok {
  font-family: var(--rd-display);
  font-weight: 500;
  font-size: calc(var(--fz) * .6px);
  line-height: calc(var(--lh) * .9px);
  letter-spacing: .06em;
  color: var(--rd-accent);
  display: flex;
  align-items: center;
  gap: .9em;
}
.rd-ok::after { content: ""; flex: none; width: 2.6em; height: 1px; background: var(--rd-accent); opacity: .7; }
.rd-ot {
  margin: calc(var(--lh) * .35px) 0 0;
  font-family: var(--rd-display);
  font-weight: 700;
  font-size: calc(var(--fz) * 1.5px);
  line-height: 1.3;
  color: var(--rd-ink);
  text-wrap: balance;
  text-align: start;
}
.rd-os {
  margin: calc(var(--lh) * .5px) 0 0;
  font-family: var(--rd-read);
  font-weight: 400;
  font-size: calc(var(--fz) * 1.06px);
  line-height: calc(var(--lh) * 1px);
  color: var(--rd-soft);
  text-indent: 0 !important;
  text-align: start;
  text-wrap: balance;
}
.rd-os::before { content: "—  "; color: var(--rd-accent); opacity: .8; }

/* ---------- special pages ---------- */
.rd-cover {
  background:
    radial-gradient(130% 80% at 30% 0%, rgba(255, 255, 255, .06), transparent 60%),
    linear-gradient(160deg, var(--rd-cover), var(--rd-cover-2));
  color: var(--rd-cover-ink);
  border-radius: 3px 2px 2px 3px;
}
.rd-cover > .rd-paper-grain { opacity: .9; mix-blend-mode: soft-light; }
.rd-cover .rd-joint {
  top: 0; bottom: 0; right: calc(var(--pw) * .052px); width: 14px;
  background:
    linear-gradient(to left, transparent 0, rgba(0, 0, 0, .34) 5px, rgba(255, 255, 255, .07) 7px, transparent 12px);
}
.rd-cover .rd-edgehi {
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), inset 0 1px 0 rgba(255, 255, 255, .1), inset 8px 0 18px -8px rgba(0, 0, 0, .55);
}
.rd-cover-in {
  position: absolute;
  inset: 0;
  padding: calc(var(--ph) * .13px) calc(var(--pw) * .13px) calc(var(--ph) * .085px) calc(var(--pw) * .11px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: var(--rd-display);
}
.rd-cover-t {
  margin: calc(var(--ph) * .035px) 0 0;
  font-weight: 700;
  font-size: calc(var(--pw) * .118px);
  line-height: 1.14;
  color: var(--rd-cover-ink);
  text-align: start;
  text-wrap: balance;
}
.rd-cover-s {
  margin-top: calc(var(--ph) * .018px);
  font-size: calc(var(--pw) * .033px);
  font-weight: 300;
  color: var(--rd-cover-sub);
  line-height: 1.6;
}
.rd-cover-a {
  font-size: calc(var(--pw) * .031px);
  font-weight: 500;
  color: var(--rd-cover-sub);
  border-top: 1px solid var(--mx-cover-ink-25);
  padding-top: calc(var(--ph) * .014px);
}

.rd-endpaper {
  background:
    radial-gradient(120% 70% at 70% 10%, rgba(255, 255, 255, .045), transparent 60%),
    linear-gradient(200deg, var(--rd-cover-2), var(--rd-end));
}
.rd-endpaper > .rd-paper-grain { opacity: .8; mix-blend-mode: soft-light; }


.rd-title {
  text-align: center;
  font-family: var(--rd-display);
}
.rd-title .rd-tt-in {
  position: absolute;
  left: calc(var(--pin) * 1px); right: calc(var(--pout) * 1px);
  top: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-bottom: calc(var(--ph) * .06px);
}
.rd-r.rd-title .rd-tt-in { left: calc(var(--pin) * 1px); right: calc(var(--pout) * 1px); }
.rd-l.rd-title .rd-tt-in { left: calc(var(--pout) * 1px); right: calc(var(--pin) * 1px); }
.rd-tt-mark { width: 38px; height: 2px; background: var(--rd-accent); margin-bottom: calc(var(--ph) * .035px); }
.rd-tt-t { font-weight: 700; font-size: calc(var(--fz) * 1.75px); line-height: 1.25; color: var(--rd-ink); }
.rd-tt-s { margin-top: calc(var(--ph) * .018px); font-weight: 300; font-size: calc(var(--fz) * .86px); color: var(--rd-soft); }
.rd-tt-a { margin-top: calc(var(--ph) * .08px); font-weight: 500; font-size: calc(var(--fz) * .7px); color: var(--rd-ink); }
.rd-tt-e { margin-top: calc(var(--ph) * .008px); font-weight: 300; font-size: calc(var(--fz) * .56px); color: var(--rd-dim); }

.rd-ded .rd-ded-in {
  position: absolute;
  left: calc(var(--pin) * 1px); right: calc(var(--pout) * 1px);
  top: calc(var(--ph) * .34px);
  text-align: center;
}
.rd-l.rd-ded .rd-ded-in { left: calc(var(--pout) * 1px); right: calc(var(--pin) * 1px); }
.rd-ded .rd-ded-in p {
  margin: 0;
  font-family: var(--rd-read);
  font-weight: 400;
  font-size: calc(var(--fz) * 1.34px);
  line-height: calc(var(--lh) * 1.45px);
  color: var(--rd-soft);
  text-indent: 0;
}
.rd-ded .rd-ded-mark { width: 26px; height: 1px; background: var(--rd-accent); margin: calc(var(--lh) * 1px) auto 0; opacity: .8; }

.rd-part .rd-part-in {
  position: absolute;
  left: calc(var(--pin) * 1px); right: calc(var(--pout) * 1px);
  top: 0; bottom: calc(var(--ph) * .05px);
  display: flex; flex-direction: column; justify-content: center;
}
.rd-l.rd-part .rd-part-in { left: calc(var(--pout) * 1px); right: calc(var(--pin) * 1px); }
.rd-part-k {
  font-family: var(--rd-display);
  font-weight: 500;
  font-size: calc(var(--fz) * .62px);
  letter-spacing: .06em;
  color: var(--rd-accent);
  display: flex; align-items: center; gap: .9em;
}
.rd-part-k::after { content: ""; width: 2.6em; height: 1px; background: var(--rd-accent); opacity: .7; }
.rd-part-t {
  margin: calc(var(--lh) * .5px) 0 0;
  font-family: var(--rd-display);
  font-weight: 700;
  font-size: calc(var(--fz) * 2.05px);
  line-height: 1.22;
  color: var(--rd-ink);
  text-wrap: balance;
}
.rd-part-rule { width: 38px; height: 2px; background: var(--rd-accent); margin: calc(var(--lh) * 1px) 0 calc(var(--lh) * .9px); }
.rd-part-in .rd-pb { font-size: calc(var(--fz) * 1px); line-height: calc(var(--lh) * 1px); color: var(--rd-soft); text-align: start; }
.rd-part-in .rd-pb p { margin: 0; text-indent: 0; }
.rd-part-in .rd-pb em { font-style: normal; font-weight: 400; color: inherit; }
.rd-part-in .rd-pb .rd-box { margin: 0; padding: 0; border: 0; background: none; }

.rd-letter .rd-letter-in {
  position: absolute;
  left: calc(var(--pin) * 1px); right: calc(var(--pout) * 1px);
  top: 0; bottom: calc(var(--ph) * .04px);
  display: flex; align-items: center; justify-content: center;
}
.rd-l.rd-letter .rd-letter-in { left: calc(var(--pout) * 1px); right: calc(var(--pin) * 1px); }
.rd-note {
  position: relative;
  width: 92%;
  padding: calc(var(--lh) * 1.1px) calc(var(--fz) * 1.2px) calc(var(--lh) * 1.2px);
  background: var(--mx-paper-90-b9b4a4);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 6px 14px -8px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .12);
  transform: rotate(-.8deg);
  text-align: center;
}
.rd-note::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, transparent calc(50% - 1px), rgba(0, 0, 0, .05) 50%, rgba(255, 255, 255, .35) calc(50% + 1px), transparent calc(50% + 2px));
}
#reader.rd-night .rd-note { background: #36342f; box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .8); }
.rd-note p {
  margin: 0;
  font-family: var(--rd-hand);
  font-size: calc(var(--fz) * 1.22px);
  line-height: calc(var(--lh) * 1.3px);
  color: var(--rd-ink);
  text-align: center;
  text-indent: 0;
  min-height: calc(var(--lh) * .6px);
}

/* the back cover */
.rd-back {
  background:
    radial-gradient(130% 80% at 70% 0%, rgba(255, 255, 255, .05), transparent 60%),
    linear-gradient(200deg, var(--rd-cover), var(--rd-cover-2));
  color: var(--rd-cover-ink);
  border-radius: 2px 3px 3px 2px;
}
.rd-back > .rd-paper-grain { opacity: .9; mix-blend-mode: soft-light; }
.rd-back .rd-joint {
  top: 0; bottom: 0; left: calc(var(--pw) * .052px); width: 14px;
  background: linear-gradient(to right, transparent 0, rgba(0, 0, 0, .34) 5px, rgba(255, 255, 255, .07) 7px, transparent 12px);
}
.rd-back-in {
  position: absolute; inset: 0;
  padding: calc(var(--ph) * .12px) calc(var(--pw) * .13px) calc(var(--ph) * .08px) calc(var(--pw) * .11px);
  display: flex; flex-direction: column; justify-content: space-between;
  font-family: var(--rd-display);
}
.rd-back-h { font-weight: 700; font-size: calc(var(--pw) * .06px); line-height: 1.45; color: var(--rd-cover-ink); text-wrap: balance; }
.rd-back-b p { margin: 0 0 calc(var(--ph) * .018px); font-family: var(--rd-read); font-weight: 400; font-size: calc(var(--pw) * .037px); line-height: 1.75; color: var(--rd-cover-sub); text-align: start; }
.rd-back-b p.rd-back-em { color: var(--rd-cover-ink); font-family: var(--rd-display); font-weight: 400; font-size: calc(var(--pw) * .029px); line-height: 1.8; margin-top: calc(var(--ph) * .03px); }
.rd-back-a { border-top: 1px solid var(--mx-cover-ink-25); padding-top: calc(var(--ph) * .014px); font-weight: 500; font-size: calc(var(--pw) * .031px); line-height: 1.7; color: var(--rd-cover-sub); }

/* ---------- the hidden measuring page ---------- */
.rd-measure {
  position: absolute;
  left: -20000px;
  top: 0;
  width: calc(var(--pw) * 1px);
  height: calc(var(--ph) * 1px);
  visibility: hidden;
  pointer-events: none;
  contain: layout style;
}
.rd-measure .rd-page { overflow: visible; }

/* ---------- chrome ---------- */
.rd-chrome { transition: opacity .35s ease, transform .35s ease; }
#reader.rd-idle .rd-chrome { opacity: 0; pointer-events: none; }
#reader.rd-idle .rd-bar { transform: translateY(-6px); }

.rd-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.rd-bar > * { pointer-events: auto; }
.rd-group { display: flex; align-items: center; gap: 6px; }
.rd-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  min-width: 38px;
  padding: 0 14px;
  border: 1px solid var(--rd-chrome-line);
  border-radius: 999px;
  background: var(--rd-chrome-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--rd-chrome);
  font-family: var(--rd-ui);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, border-color .2s, color .2s, transform .2s;
}
.rd-btn svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.rd-btn:hover { border-color: var(--mx-chrome-45); color: var(--rd-fg); }
.rd-btn:active { transform: scale(.97); }
.rd-btn:focus-visible { outline: 2px solid var(--rd-accent); outline-offset: 2px; }
.rd-btn[aria-pressed="true"] { background: var(--rd-fg); color: var(--rd-desk); border-color: var(--rd-fg); }
.rd-btn[disabled] { opacity: .38; cursor: default; }
.rd-btn.rd-aa { min-width: 40px; padding: 0 11px; font-family: var(--rd-display); font-weight: 600; font-size: 16px; letter-spacing: 0; direction: ltr; gap: 1px; }
.rd-btn.rd-aa small { font-size: 13px; font-weight: 600; margin-inline-start: 1px; transform: translateY(-1px); }

.rd-nav {
  position: absolute;
  top: 50%;
  z-index: 15;
  width: 46px; height: 46px;
  margin-top: -23px;
  padding: 0;
  border-radius: 50%;
}
.rd-nav svg { width: 20px; height: 20px; }
.rd-nav-next { left: 14px; }
.rd-nav-prev { right: 14px; }

.rd-foot {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 14px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.rd-foot > * { pointer-events: auto; }
.rd-pg {
  font-family: var(--rd-ui);
  font-size: 13px;
  font-weight: 400;
  color: var(--rd-chrome);
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rd-pg small { color: var(--rd-chrome-dim); font-size: 12px; margin-inline-start: .5em; }
.rd-scrubwrap { position: relative; width: min(520px, 76vw); }
.rd-ticks { position: absolute; left: 0; right: 0; top: 50%; height: 0; pointer-events: none; }
.rd-tick { position: absolute; top: -4px; width: 1px; height: 8px; background: var(--rd-chrome-dim); opacity: .6; }
.rd-scrub {
  --p: 0%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  direction: rtl;
  cursor: pointer;
}
.rd-scrub:focus-visible { outline: 2px solid var(--rd-accent); outline-offset: 4px; border-radius: 4px; }
.rd-scrub::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(to left, var(--rd-chrome) 0, var(--rd-chrome) var(--p), var(--rd-chrome-line) var(--p));
}
.rd-scrub::-moz-range-track { height: 2px; border-radius: 2px; background: var(--rd-chrome-line); }
.rd-scrub::-moz-range-progress { height: 2px; background: var(--rd-chrome); }
.rd-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--rd-chrome);
  border: 2px solid var(--rd-desk);
  box-shadow: 0 0 0 1px var(--rd-chrome-line);
}
.rd-scrub::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--rd-chrome); border: 2px solid var(--rd-desk); }

/* ---------- contents panel ---------- */
.rd-scrim {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(8, 10, 12, .34);
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.rd-toc-open .rd-scrim { opacity: 1; pointer-events: auto; }
.rd-toc {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  z-index: 40;
  width: min(400px, 92vw);
  display: flex; flex-direction: column;
  background: var(--rd-paper);
  color: var(--rd-ink);
  box-shadow: -24px 0 50px -20px rgba(0, 0, 0, .35);
  transform: translateX(104%);
  transition: transform .42s cubic-bezier(.2, .8, .2, 1), visibility 0s .42s;
  visibility: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.rd-toc-open .rd-toc { transform: none; visibility: visible; transition: transform .42s cubic-bezier(.2, .8, .2, 1); }
.rd-toc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--rd-line);
}
.rd-toc-head h2 { margin: 0; font-family: var(--rd-display); font-weight: 600; font-size: 18px; color: var(--rd-ink); }
.rd-toc-head .rd-btn { background: transparent; height: 34px; min-width: 34px; padding: 0 10px; color: var(--rd-soft); border-color: var(--rd-line); }
.rd-toc-list { flex: 1; overflow-y: auto; padding: 8px 10px 28px; overscroll-behavior: contain; direction: rtl; }
.rd-toc-grp { margin: 14px 0 2px; padding: 0 12px; font-family: var(--rd-display); font-size: 12px; font-weight: 500; color: var(--rd-accent); letter-spacing: .04em; }
.rd-toc-item {
  appearance: none; -webkit-appearance: none;
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 12px;
  width: 100%;
  text-align: start;
  padding: 11px 12px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--rd-ink);
  cursor: pointer;
  font-family: var(--rd-ui);
}
.rd-toc-item:hover { background: var(--mx-ink-6); }
.rd-toc-item:focus-visible { outline: 2px solid var(--rd-accent); outline-offset: -2px; }
.rd-toc-item[aria-current="true"] { background: var(--mx-accent-11); }
.rd-toc-item .k { display: block; font-size: 11.5px; color: var(--rd-dim); margin-bottom: 2px; }
.rd-toc-item .t { display: block; font-family: var(--rd-display); font-weight: 500; font-size: 15px; line-height: 1.45; }
.rd-toc-item .n { font-size: 12px; color: var(--rd-dim); font-variant-numeric: tabular-nums; }
.rd-toc-item.rd-top .t { font-weight: 600; }
.rd-toc-item.rd-top .k { color: var(--rd-accent); font-weight: 500; }
.rd-toc-grp { height: 1px; margin: 10px 12px 4px; background: var(--rd-line); padding: 0; font-size: 0; }
.rd-toc-item.rd-ch { padding-inline-start: 22px; }

/* ---------- resume toast, reference popover ---------- */
.rd-toast {
  position: absolute;
  left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px));    /* under the book, over the progress line: it never covers the cover */
  z-index: 35;
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center;
  width: max-content;
  max-width: min(560px, calc(100% - 24px));
  padding: 11px 14px 11px 12px;
  border: 1px solid var(--rd-chrome-line);
  border-radius: 14px;
  background: var(--rd-chrome-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .4);
  color: var(--rd-fg);
  font-size: 14px;
  transition: opacity .4s ease, transform .5s cubic-bezier(.2, .8, .2, 1);
}
.rd-toast.rd-show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.rd-toast p { margin: 0; line-height: 1.5; padding-inline: 4px; }
.rd-toast p b { font-weight: 600; font-family: var(--rd-display); }
.rd-toast .rd-btn { height: 34px; font-size: 13.5px; padding: 0 14px; }
.rd-toast .rd-btn.rd-primary { background: var(--rd-fg); color: var(--rd-desk); border-color: var(--rd-fg); }
.rd-toast .rd-btn.rd-primary:hover { opacity: .9; }

.rd-pop {
  position: absolute;
  z-index: 50;
  width: min(340px, calc(100vw - 24px));
  padding: 12px 14px 13px;
  border: 1px solid var(--rd-chrome-line);
  border-radius: 10px;
  background: var(--rd-paper);
  color: var(--rd-ink);
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .45);
  font-size: 13px;
  line-height: 1.6;
  opacity: 0; visibility: hidden;
  transform: translateY(6px);
  transition: opacity .2s, transform .2s, visibility 0s .2s;
}
.rd-pop.rd-show { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .2s; }
.rd-pop b { display: block; font-family: var(--rd-display); font-size: 11.5px; font-weight: 600; color: var(--rd-accent); margin-bottom: 4px; }
.rd-pop div[dir="ltr"] { text-align: left; font-family: "IBM Plex Sans Arabic", var(--rd-read); }
.rd-pop em { font-style: italic; }

/* ---------- loading, errors ---------- */
.rd-veil {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: var(--mx-desk-60);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.rd-veil.rd-show { opacity: 1; pointer-events: auto; transition-delay: .4s; }
.rd-veil span {
  padding: 9px 16px;
  border: 1px solid var(--rd-chrome-line);
  border-radius: 999px;
  background: var(--rd-chrome-bg);
  font-size: 13.5px; color: var(--rd-chrome);
}
.rd-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; font-size: 16px; line-height: 1.8; color: var(--rd-soft); }

.rd-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- phones: compact chrome ---------- */
@media (max-width: 640px) {
  .rd-bar { padding-inline: 10px; }
  .rd-btn { height: 36px; padding: 0 12px; font-size: 13px; }
  .rd-btn .rd-lbl { display: none; }
  .rd-btn.rd-toc-btn .rd-lbl { display: inline; }
  .rd-nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rd-chrome, .rd-toc, .rd-scrim, .rd-toast, .rd-pop, .rd-veil { transition-duration: .01s !important; }
}

/* Integration polish: a tone-on-tone deboss on the cover title, a quiet inner frame clear of the spine joint,
   and a phone-sized hit area for the progress scrubber. */
.rd-cover-t { text-shadow: 0 1px 0 rgba(255, 255, 255, .07), 0 -1px 1px rgba(0, 0, 0, .5); }
.rd-cover-in::after { content: ""; position: absolute; pointer-events: none; border: 1px solid rgba(243, 242, 238, .1);
  inset: calc(var(--ph) * .035px) calc(var(--pw) * .09px) calc(var(--ph) * .035px) calc(var(--pw) * .055px); }
@media (max-width: 899px) { .rd-scrub { height: 28px; } }

/* ===================================================================================
   Left-to-right editions (data-dir="ltr"): the stage is the Arabic book mirrored (the JS flips .rd-fit), so
   the spine, the turning leaf, the shadows and the page edges mirror together; the text on the pages and the
   chrome are turned back so they read normally.
   =================================================================================== */
#reader.rd-ltr, #reader.rd-ltr .rd-page, #reader.rd-ltr .rd-body, #reader.rd-ltr .rd-scrub, #reader.rd-ltr .rd-toc-list { direction: ltr; }
#reader.rd-ltr { text-align: start; }
#reader.rd-ltr .rd-page > .rd-run,
#reader.rd-ltr .rd-page > .rd-folio,
#reader.rd-ltr .rd-page > .rd-body,
#reader.rd-ltr .rd-page > .rd-tt-in,
#reader.rd-ltr .rd-page > .rd-ded-in,
#reader.rd-ltr .rd-page > .rd-part-in,
#reader.rd-ltr .rd-page > .rd-letter-in,
#reader.rd-ltr .rd-page > .rd-cover-in,
#reader.rd-ltr .rd-page > .rd-back-in { transform: scaleX(-1); }
#reader.rd-ltr .rd-nav-next { left: auto; right: 14px; }
#reader.rd-ltr .rd-nav-prev { right: auto; left: 14px; }
#reader.rd-ltr .rd-scrub::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--rd-chrome) 0, var(--rd-chrome) var(--p), var(--rd-chrome-line) var(--p)); }
#reader.rd-ltr .rd-toc { right: auto; left: 0; transform: translateX(-104%); }
#reader.rd-ltr.rd-toc-open .rd-toc { transform: none; }
#reader.rd-ltr .rd-body .rd-ref > span[dir="ltr"], #reader.rd-ltr .rd-pop div[dir="ltr"] { text-align: left; }
/* Quran verses are Arabic inside a left-to-right page; the meaning follows in the edition's language */
#reader[lang] .rd-body .ayah { font-family: "Amiri", "Noto Naskh Arabic", "Scheherazade New", serif; direction: rtl; unicode-bidi: isolate; }
#reader[lang] .rd-body .ayah-tr { font-size: .96em; }
#reader[lang] .rd-body .note-ar { display: block; font-size: .86em; color: var(--rd-dim); }
/* ragged text for scripts that justify badly */
#reader.rd-nj .rd-body, #reader.rd-nj .rd-body * { text-align: start; text-align-last: auto; }

/* ===== fasfos.ca: a real book on a dark desk (appended to the module's reader.css) ===== */
body #reader:not(.rd-night){
  --rd-desk:#0b1a22;--rd-desk-hi:#1a3844;--rd-desk-lo:#04080b;
  --rd-fg:#e9f1ef;--rd-chrome:#c6d6da;--rd-chrome-dim:#86a0aa;--rd-chrome-bg:rgba(6,13,18,.8);--rd-chrome-line:rgba(233,241,239,.16);
  --rd-paper:#f6f2e9;--rd-ink:#17191b;--rd-card:#efeadd;--rd-edge-a:#ebe4d3;--rd-edge-b:#cdc4ae;
  --rd-page-shadow:rgba(0,0,0,.55);
}
body #reader.rd-night{
  --rd-desk:#070f14;--rd-desk-hi:#0f202a;--rd-desk-lo:#020405;
  --rd-chrome-bg:rgba(4,9,13,.82);
}
/* the real front cover: the final cover art (it already carries the title, subtitle and author) */
body #reader .rd-cover{background:#242b24 url(/books/istiqala/assets/cover.webp) center/100% 100% no-repeat}
body #reader .rd-cover > .rd-paper-grain{opacity:.35}
body #reader .rd-cover-in{opacity:0}
body #reader .rd-cover::after{content:"";position:absolute;inset:0;pointer-events:none;
  background:linear-gradient(to left,rgba(0,0,0,.28),transparent 9%,transparent 94%,rgba(255,255,255,.05))}
/* endpapers take the olive of the blanket on the cover; the back cover is the cover's warm wall, with dark ink */
body #reader{--rd-cover:#2b372d;--rd-cover-2:#1c261e;--rd-end:#141c16}
body #reader .rd-back{--rd-cover-ink:#1b231e;--rd-cover-sub:#454d44;--mx-cover-ink-25:rgba(27,35,30,.28);
  background:radial-gradient(130% 80% at 70% 0%,rgba(255,255,255,.28),transparent 60%),linear-gradient(200deg,#d9ccb5,#c4b59b)}
body #reader .rd-back > .rd-paper-grain{mix-blend-mode:multiply;opacity:.5}
body #reader .rd-back .rd-joint{background:linear-gradient(to right,transparent 0,rgba(0,0,0,.2) 5px,rgba(255,255,255,.18) 7px,transparent 12px)}
body #reader.rd-night .rd-back{--rd-cover-ink:#ddd8cb;--rd-cover-sub:#a8a498;--mx-cover-ink-25:rgba(221,216,203,.25);
  background:linear-gradient(200deg,#3a3a33,#2a2a25)}
body #reader.rd-night .rd-cover::after{background:linear-gradient(to left,rgba(0,0,0,.28),rgba(0,0,0,.18) 9%,rgba(0,0,0,.18) 94%,rgba(0,0,0,.12))}
body #reader{--reader-h:calc(100vh - 46px)}
@supports (height:100dvh){body #reader{--reader-h:calc(100dvh - 46px)}}
/* no selecting, no touch-callout, no image dragging inside the book */
#reader,#reader *{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-user-drag:none}
