/* القيّم: design system */
:root {
  --paper: oklch(97.2% 0.012 85);
  --paper-2: oklch(94.6% 0.018 83);
  --paper-3: oklch(90.5% 0.024 82);
  --ink: oklch(23% 0.03 168);
  --ink-2: oklch(40% 0.025 168);
  --ink-3: oklch(49% 0.02 150);
  --green: oklch(37% 0.068 166);
  --green-2: oklch(46% 0.08 166);
  --green-soft: oklch(92% 0.03 160);
  --gold: oklch(67% 0.11 78);
  --gold-2: oklch(52% 0.105 68);
  --gold-soft: oklch(91% 0.05 85);
  --ayah: oklch(40% 0.09 155);
  --mark: oklch(88% 0.11 92);
  --line: oklch(86% 0.02 82);
  --danger: oklch(52% 0.15 28);
  --shadow: 0 1px 2px oklch(30% 0.03 80 / .08), 0 8px 28px -12px oklch(30% 0.04 80 / .25);
  --radius: 10px;
  --ui: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --read: "Amiri", "Noto Naskh Arabic", serif;
  --naskh: "Noto Naskh Arabic", "Amiri", serif;
  --ruqaa: "Aref Ruqaa", "Amiri", serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --gutter: clamp(16px, 4vw, 48px);
  --logo-cut: var(--paper);
  color-scheme: light;
}
:root[data-theme="night"] {
  --paper: oklch(25% 0.012 70);
  --paper-2: oklch(29% 0.013 72);
  --paper-3: oklch(34% 0.014 72);
  --ink: oklch(93% 0.02 85);
  --ink-2: oklch(82% 0.02 82);
  --ink-3: oklch(69% 0.02 80);
  --green: oklch(78% 0.08 160);
  --green-2: oklch(84% 0.08 160);
  --green-soft: oklch(30% 0.04 165);
  --gold: oklch(78% 0.1 82);
  --gold-2: oklch(80% 0.1 82);
  --gold-soft: oklch(33% 0.04 80);
  --ayah: oklch(82% 0.09 150);
  --mark: oklch(45% 0.09 90);
  --line: oklch(38% 0.014 72);
  --shadow: 0 1px 2px oklch(0% 0 0 / .25), 0 10px 30px -12px oklch(0% 0 0 / .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --paper: oklch(25% 0.012 70); --paper-2: oklch(29% 0.013 72); --paper-3: oklch(34% 0.014 72);
    --ink: oklch(93% 0.02 85); --ink-2: oklch(82% 0.02 82); --ink-3: oklch(69% 0.02 80);
    --green: oklch(78% 0.08 160); --green-2: oklch(84% 0.08 160); --green-soft: oklch(30% 0.04 165);
    --gold: oklch(78% 0.1 82); --gold-2: oklch(80% 0.1 82); --gold-soft: oklch(33% 0.04 80);
    --ayah: oklch(82% 0.09 150); --mark: oklch(45% 0.09 90); --line: oklch(38% 0.014 72);
    --shadow: 0 1px 2px oklch(0% 0 0 / .3), 0 10px 30px -12px oklch(0% 0 0 / .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.75 var(--ui); text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-2); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--green-2); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--gold-soft); color: var(--ink); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 12px; }
.wrap { width: min(1180px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.num { font-variant-numeric: tabular-nums; }
svg.i { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }

/* ── header ── */
.top { position: sticky; top: 0; z-index: 40; background: color-mix(in oklch, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent; transition: border-color .3s; }
.top.scrolled { border-bottom-color: var(--line); }
.top .wrap { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand svg { width: 34px; height: 34px; color: var(--green); }
.brand b { font: 700 30px/1 var(--ruqaa); letter-spacing: 0; transform: translateY(-3px); }
.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav a { color: var(--ink-2); padding: 7px 13px; border-radius: 999px; font-weight: 500; font-size: 15px; transition: background .2s, color .2s; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); background: var(--paper-2); }
.nav a[aria-current="page"] { box-shadow: inset 0 0 0 1px var(--line); }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; border: 0; background: transparent; color: var(--ink-2); transition: background .2s, color .2s; }
.iconbtn:hover { background: var(--paper-2); color: var(--ink); }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .nav { position: fixed; inset: 64px 0 auto 0; flex-direction: column; background: var(--paper); padding: 10px var(--gutter) 18px;
    border-bottom: 1px solid var(--line); transform: translateY(-8px); opacity: 0; pointer-events: none; transition: .25s var(--ease); }
  .nav.open { transform: none; opacity: 1; pointer-events: auto; }
  .nav a { font-size: 17px; padding: 12px 14px; }
  .menu-btn { display: inline-grid; margin-inline-start: auto; }
}

/* ── footer ── */
.foot { margin-top: 96px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 14px; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: center; padding-block: 28px; }
.foot a { color: var(--ink-2); }
.foot .brand b { font-size: 22px; }
.foot .brand svg { width: 24px; height: 24px; }

/* ── buttons, fields ── */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 500; font-size: 15px;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); color: var(--ink); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--paper); }
.btn.primary:hover { background: var(--green-2); border-color: var(--green-2); color: var(--paper); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 500; transition: .2s; white-space: nowrap; }
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip[aria-pressed="true"], .chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip small { opacity: .65; font-size: 12px; }
.field { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 6px 6px 6px 6px; padding-inline-start: 18px; box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s; }
.field:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in oklch, var(--gold) 22%, transparent), var(--shadow); }
.field input, .field textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 18px; padding: 10px 0; resize: none; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; color: var(--ink-2); font-size: 14px; font-weight: 500; transition: .2s; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px oklch(30% 0.03 80 / .18); }
.muted { color: var(--ink-3); }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--gold-2); }
.rule { height: 1px; background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent); opacity: .55; border: 0; margin: 0; }
h1, h2, h3 { font-family: var(--read); font-weight: 700; line-height: 1.35; margin: 0; color: var(--ink); }

/* ── reveal motion ── */
.rv { opacity: 0; transform: translateY(14px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.rv.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .rv { opacity: 1; transform: none; }
}
html:not(.js) .rv { opacity: 1; transform: none; }

/* ── khatam pattern ── */
.pattern { position: absolute; inset: 0; pointer-events: none; color: var(--gold); opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72' fill='none' stroke='%23b48a3c' stroke-width='1'%3E%3Crect x='22' y='22' width='28' height='28'/%3E%3Crect x='22' y='22' width='28' height='28' transform='rotate(45 36 36)'/%3E%3Cpath d='M0 36h16M56 36h16M36 0v16M36 56v16'/%3E%3C/svg%3E");
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 50% 30%, #000 10%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 80% at 50% 30%, #000 10%, transparent 75%); }

/* ── home ── */
.hero { position: relative; padding: clamp(48px, 9vw, 110px) 0 clamp(36px, 6vw, 64px); overflow: hidden; }
.hero .wrap { position: relative; display: grid; gap: 28px; justify-items: center; text-align: center; }
.hero h1 { font: 700 clamp(46px, 8.5vw, 104px)/1.25 var(--ruqaa); color: var(--ink); padding-bottom: .12em; }
.hero h1 span { color: var(--green); }
.hero .lede { font: 400 clamp(17px, 2vw, 21px)/1.8 var(--read); color: var(--ink-2); max-width: 46ch; margin: 0; }
.qbox { width: min(720px, 100%); display: grid; gap: 12px; }
.qbox .field { border-radius: 20px; }
.qbox .field input { font-size: 19px; }
.qbox .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.stats { display: flex; gap: clamp(18px, 4vw, 44px); justify-content: center; color: var(--ink-3); font-size: 14px; }
.stats b { display: block; font: 700 26px/1.2 var(--read); color: var(--ink); font-variant-numeric: tabular-nums; }

.quote { position: relative; margin: 0 auto; width: min(860px, 100%); padding: clamp(28px, 5vw, 52px) clamp(22px, 6vw, 72px);
  text-align: center; }
.quote::before, .quote::after { content: ""; position: absolute; inset-inline: 12%; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .6; }
.quote::before { top: 0; } .quote::after { bottom: 0; }
.quote blockquote { margin: 0; font: 400 clamp(21px, 2.6vw, 28px)/1.95 var(--read); color: var(--ink); text-wrap: balance; }
.quote figcaption { margin-top: 14px; font-size: 14px; color: var(--ink-3); }
.quote figcaption a { color: var(--gold-2); font-weight: 600; }
.orn-star { width: 26px; height: 26px; color: var(--gold); margin: 0 auto 12px; display: block; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: clamp(56px, 8vw, 88px) 0 22px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 36px); }

/* shelf of spines */
.shelf { position: relative; padding: 26px 0 0; }
.shelf-row { display: flex; align-items: flex-end; gap: 5px; overflow-x: auto; padding: 8px 4px 0; scroll-snap-type: x proximity;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.shelf-board { height: 14px; border-radius: 3px; background: linear-gradient(180deg, oklch(56% 0.06 60), oklch(42% 0.05 55)); box-shadow: 0 10px 18px -10px oklch(30% 0.05 60 / .7); }
:root[data-theme="night"] .shelf-board { background: linear-gradient(180deg, oklch(38% 0.04 60), oklch(28% 0.03 55)); }
.spine { --h: 0; position: relative; flex: none; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 14px 0 12px; border-radius: 3px 3px 1px 1px; color: oklch(90% 0.06 85);
  background: linear-gradient(90deg, oklch(0% 0 0 / .22), transparent 18%, oklch(100% 0 0 / .07) 50%, transparent 82%, oklch(0% 0 0 / .25)),
              oklch(var(--l, 34%) 0.07 var(--h));
  box-shadow: inset 0 0 0 1px oklch(0% 0 0 / .12); transition: transform .35s var(--ease), box-shadow .35s; transform-origin: bottom; }
.spine:hover, .spine:focus-visible { transform: translateY(-10px); color: oklch(95% 0.06 85); box-shadow: inset 0 0 0 1px oklch(0% 0 0 / .12), 0 14px 22px -14px oklch(20% 0.04 60 / .8); }
.spine .t { writing-mode: vertical-rl; font: 700 17px/1 var(--read); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: calc(100% - 46px); }
.spine .band { width: 70%; height: 3px; border-block: 1px solid oklch(78% 0.1 82 / .8); }
.spine .v { font: 600 11px/1 var(--ui); opacity: .8; }

/* cover cards */
.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: clamp(18px, 2.5vw, 30px) clamp(14px, 2vw, 24px); }
.cover-link { display: grid; gap: 10px; color: var(--ink); }
.cover { --h: 160; position: relative; aspect-ratio: 2 / 3; border-radius: 4px 8px 8px 4px; overflow: hidden;
  background: radial-gradient(120% 80% at 70% 10%, oklch(100% 0 0 / .08), transparent 60%), oklch(var(--l, 33%) 0.07 var(--h));
  box-shadow: inset -6px 0 10px -6px oklch(0% 0 0 / .45), var(--shadow);
  display: grid; place-items: center; padding: 16%; text-align: center; color: oklch(88% 0.08 85);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease); }
.cover::before { content: ""; position: absolute; inset: 7%; border: 1px solid oklch(78% 0.1 82 / .55); border-radius: 2px; }
.cover::after { content: ""; position: absolute; inset: 9.5%; border: 1px solid oklch(78% 0.1 82 / .25); border-radius: 1px; }
.cover .ct { position: relative; font: 700 clamp(17px, 1.6vw, 21px)/1.5 var(--read); text-wrap: balance; }
.cover .cs { position: absolute; top: 13%; inset-inline: 0; display: grid; place-items: center; }
.cover .cs svg { width: 22px; height: 22px; color: oklch(78% 0.1 82 / .8); }
.cover .ca { position: absolute; bottom: 12%; inset-inline: 0; font: 400 12px/1 var(--read); opacity: .75; }
.cover-link:hover .cover { transform: translateY(-6px) rotate(-.6deg); box-shadow: inset -6px 0 10px -6px oklch(0% 0 0 / .45), 0 22px 34px -18px oklch(20% 0.04 60 / .55); }
.cover-meta b { display: block; font: 700 16px/1.5 var(--read); }
.cover-meta span { font-size: 13px; color: var(--ink-3); }

.cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 26px; }
.lib-head { padding: clamp(40px, 6vw, 72px) 0 10px; }
.lib-head h1 { font-size: clamp(34px, 5vw, 52px); }
.lib-head p { color: var(--ink-2); margin: 8px 0 24px; }
.filter { max-width: 420px; }
.filter .field { box-shadow: none; padding-block: 2px; border-radius: 999px; }
.filter .field input { font-size: 16px; }

/* features strip */
.ways { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-block: 1px solid var(--line); }
.ways a { padding: 28px clamp(16px, 2.5vw, 30px); color: var(--ink); display: grid; gap: 6px; border-inline-start: 1px solid var(--line); transition: background .25s; }
.ways a:first-child { border-inline-start: 0; }
.ways a:hover { background: var(--paper-2); }
.ways b { font: 700 22px/1.4 var(--read); display: flex; align-items: center; gap: 10px; }
.ways b svg { color: var(--gold-2); }
.ways span { color: var(--ink-2); font-size: 15px; }
@media (max-width: 760px) { .ways { grid-template-columns: 1fr; } .ways a { border-inline-start: 0; border-top: 1px solid var(--line); } .ways a:first-child { border-top: 0; } }

/* continue reading */
.continue { display: none; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper-2); color: var(--ink); width: min(720px, 100%); }
.continue.show { display: flex; }
.continue .mini { width: 34px; aspect-ratio: 2/3; border-radius: 2px 4px 4px 2px; background: oklch(33% 0.07 var(--h, 160)); flex: none; }
.continue small { color: var(--ink-3); display: block; font-size: 13px; }

/* ── book page ── */
.bk { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: clamp(28px, 5vw, 64px); padding-top: clamp(32px, 5vw, 64px); align-items: start; }
.bk .cover { position: sticky; top: 88px; }
.bk h1 { font-size: clamp(30px, 4.4vw, 48px); line-height: 1.3; margin: 8px 0 12px; text-wrap: balance; }
.bk .desc { font: 400 20px/1.9 var(--read); color: var(--ink-2); margin: 0 0 22px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 0 0 26px; padding: 0; list-style: none; color: var(--ink-2); font-size: 15px; }
.facts b { color: var(--ink); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 34px; }
.panel { border-top: 1px solid var(--line); padding: 24px 0; }
.panel h2 { font-size: 24px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.edition { font-size: 15px; color: var(--ink-2); white-space: pre-line; line-height: 1.95; }
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.dl a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); transition: .2s; }
.dl a:hover { border-color: var(--green); background: var(--green-soft); }
.dl small { color: var(--ink-3); font-size: 12px; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li a { display: flex; justify-content: space-between; gap: 16px; padding: 7px 10px; border-radius: 8px; color: var(--ink); font: 400 17px/1.6 var(--read); }
.toc li a:hover { background: var(--paper-2); }
.toc li a .pg { font: 400 13px/1.9 var(--ui); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.toc li.l1 > a { font-weight: 700; }
.toc li.l2 a { padding-inline-start: 26px; }
.toc li.l3 a { padding-inline-start: 42px; font-size: 16px; color: var(--ink-2); }
.toc li.l4 a, .toc li.l5 a { padding-inline-start: 58px; font-size: 15px; color: var(--ink-2); }
.toc li.na a { color: var(--ink-3); }
.toc-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.toc-tools .field { flex: 1; box-shadow: none; border-radius: 999px; padding-block: 0; }
.toc-tools .field input { font-size: 15px; }
.toc-list { max-height: 70vh; overflow: auto; overscroll-behavior: contain; }
@media (max-width: 760px) { .bk { grid-template-columns: 1fr; } .bk .cover { position: relative; top: 0; width: 56%; margin-inline: auto; } }

/* ── search ── */
.s-head { padding: clamp(32px, 5vw, 56px) 0 14px; display: grid; gap: 14px; }
.s-head h1 { font-size: clamp(30px, 4vw, 44px); }
.s-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.facets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.results { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 4px; }
.res a { display: grid; gap: 6px; padding: 18px 18px; margin-inline: -18px; border-radius: 14px; color: var(--ink); transition: background .2s; }
.res a:hover { background: var(--paper-2); }
.res .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); }
.res .meta b { color: var(--green); font-weight: 600; }
.res .snip { font: 400 19px/2 var(--read); color: var(--ink); }
.res .head { font: 700 15px/1.5 var(--read); color: var(--ink-2); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.empty { padding: 48px 0; text-align: center; color: var(--ink-3); }
.empty b { display: block; font: 700 22px/1.6 var(--read); color: var(--ink); margin-bottom: 6px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.count { font-size: 14px; color: var(--ink-3); }
.skeleton { height: 92px; border-radius: 14px; background: linear-gradient(90deg, var(--paper-2), var(--paper-3), var(--paper-2)); background-size: 200% 100%; animation: shim 1.3s infinite linear; margin-block: 8px; }
@keyframes shim { to { background-position: -200% 0; } }

/* ── ask ── */
.ask { width: min(860px, 100%); margin-inline: auto; }
.ask .field { align-items: flex-end; border-radius: 20px; }
.ask textarea { min-height: 56px; max-height: 220px; line-height: 1.7; }
.answer { margin-top: 30px; font: 400 20px/2 var(--read); }
.answer h2, .answer h3 { font-size: 23px; margin: 24px 0 8px; }
.answer p { margin: 0 0 14px; }
.answer ul, .answer ol { margin: 0 0 14px; padding-inline-start: 26px; }
.answer li { margin-bottom: 6px; }
.answer .cite { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; margin-inline: 2px; border-radius: 6px; background: var(--green-soft); color: var(--green); font: 600 12px/1 var(--ui); vertical-align: 3px; border: 0; }
.answer .cite:hover { background: var(--green); color: var(--paper); }
.answer .caret { display: inline-block; width: 8px; height: 1.1em; background: var(--gold); vertical-align: -3px; animation: blink 1s steps(2) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.srcs { margin-top: 28px; display: grid; gap: 10px; counter-reset: s; }
.src { border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; background: var(--paper); transition: border-color .3s, box-shadow .3s; }
.src.flash { border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in oklch, var(--gold) 20%, transparent); }
.src header { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--ink-3); }
.src header .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--green-soft); color: var(--green); font-weight: 600; font-size: 13px; }
.src header a { color: var(--green); font-weight: 600; }
.src p { margin: 8px 0 0; font: 400 17px/1.95 var(--read); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.src.open p { -webkit-line-clamp: unset; }
.src .more { border: 0; background: none; color: var(--ink-3); font-size: 13px; padding: 4px 0 0; }
.ans-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.ans-tools .chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); }
.ask-ex { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 26px; }
.ask-ex button { text-align: start; border: 1px solid var(--line); background: transparent; padding: 14px 16px; border-radius: 14px; font: 400 17px/1.7 var(--read); color: var(--ink); transition: .2s; }
.ask-ex button:hover { border-color: var(--gold); background: var(--paper-2); }
.note { font-size: 13px; color: var(--ink-3); margin-top: 10px; }

/* ── prose (about) ── */
.prose { width: min(760px, 100%); margin-inline: auto; font: 400 20px/2 var(--read); }
.prose h1 { font-size: clamp(34px, 5vw, 52px); margin: clamp(36px, 6vw, 72px) 0 18px; }
.prose h2 { font-size: 27px; margin: 40px 0 10px; }
.prose p { margin: 0 0 16px; color: var(--ink-2); }
.prose table { width: 100%; border-collapse: collapse; font: 400 15px/1.7 var(--ui); }
.prose td, .prose th { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--ink-3); font-weight: 500; font-size: 13px; }

/* toast */
.toast { position: fixed; inset-inline: 0; bottom: 24px; margin-inline: auto; width: max-content; max-width: calc(100% - 32px); background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 90; opacity: 0; transform: translateY(10px); transition: .3s var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: none; }

/* 404 */
.nf { text-align: center; padding: 120px 0; }
.nf h1 { font: 700 72px/1 var(--ruqaa); color: var(--gold-2); }

/* ── type colors (ayat, hadith, athar, aqwal, poetry) ── */
:root { --c-ayah: oklch(40% 0.09 155); --c-hadith: oklch(44% 0.13 28); --c-athar: oklch(42% 0.1 262); --c-qawl: oklch(45% 0.09 62); --c-poem: oklch(43% 0.11 330); }
:root[data-theme="night"] { --c-ayah: oklch(82% 0.09 150); --c-hadith: oklch(78% 0.1 32); --c-athar: oklch(79% 0.08 262); --c-qawl: oklch(82% 0.08 75); --c-poem: oklch(80% 0.08 330); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) { --c-ayah: oklch(82% 0.09 150); --c-hadith: oklch(78% 0.1 32); --c-athar: oklch(79% 0.08 262); --c-qawl: oklch(82% 0.08 75); --c-poem: oklch(80% 0.08 330); } }
.t-ayah { --c: var(--c-ayah); } .t-hadith { --c: var(--c-hadith); } .t-athar { --c: var(--c-athar); } .t-qawl { --c: var(--c-qawl); } .t-poem { --c: var(--c-poem); }

/* ── index component ── */
.ix-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; scroll-snap-type: x proximity; }
.ix-tabs::-webkit-scrollbar { display: none; }
.ix-tab { flex: 1 0 auto; min-width: 118px; scroll-snap-align: start; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  text-align: start; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); transition: border-color .2s, background .2s, box-shadow .2s, transform .15s var(--ease); }
.ix-tab:hover { border-color: color-mix(in oklch, var(--c) 45%, var(--line)); }
.ix-tab:active { transform: scale(.98); }
.ix-tab .ix-ic { grid-row: span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--c); background: color-mix(in oklch, var(--c) 11%, transparent); }
.ix-tab .ix-ic svg { width: 22px; height: 22px; }
.ix-name { font: 700 17px/1.3 var(--read); }
.ix-n { font-size: 13px; color: var(--ink-3); }
.ix-tab[aria-selected="true"] { border-color: var(--c); background: color-mix(in oklch, var(--c) 7%, var(--paper)); box-shadow: 0 0 0 1px var(--c) inset; }
.ix-tab[aria-selected="true"] .ix-ic { background: var(--c); color: var(--paper); }
.ix-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0 8px; }
.ix-tools .field { flex: 1 1 240px; box-shadow: none; border-radius: 999px; padding-block: 0; }
.ix-tools .field input { font-size: 16px; padding: 9px 0; }
.ix-tools select.chip { padding-inline: 12px; max-width: 220px; }
.ix-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.ix-item a { display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 14px 12px; margin-inline: -12px; border-radius: 14px; color: var(--ink); transition: background .2s; }
.ix-item a:hover, .ix-item a:focus-visible { background: var(--paper-2); }
.ix-item .ix-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--c); background: color-mix(in oklch, var(--c) 10%, transparent); margin-top: 4px; }
.ix-item .ix-ic svg { width: 19px; height: 19px; }
.ix-body { display: grid; gap: 6px; min-width: 0; }
.ix-text { font: 400 19px/1.95 var(--read); color: var(--ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.t-ayah .ix-text { color: var(--c-ayah); }
.ix-text.poem { text-align: center; }
.ix-gap { display: inline-block; width: 2.2em; }
.ix-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px; color: var(--ink-3); }
.ix-by { color: var(--c); font-weight: 600; }
.ix-chip { padding: 1px 10px; border-radius: 999px; background: color-mix(in oklch, var(--c-ayah) 10%, transparent); color: var(--c-ayah); font-weight: 600; }
.ix-where b { color: var(--ink-2); font-weight: 600; }
.ix-group { position: sticky; top: 64px; z-index: 2; padding: 10px 0 6px; margin-top: 10px; font: 700 18px/1.4 var(--read); color: var(--c-ayah);
  background: linear-gradient(var(--paper) 75%, transparent); }
.ix-more { text-align: center; margin: 18px 0; }
.bk-ix { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.bk-ix a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); transition: .2s; }
.bk-ix a:hover { border-color: var(--c); background: color-mix(in oklch, var(--c) 6%, var(--paper)); }
.bk-ix .ix-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--c); background: color-mix(in oklch, var(--c) 11%, transparent); }
.bk-ix b { display: block; font: 700 16px/1.3 var(--read); }
.bk-ix small { color: var(--ink-3); font-size: 13px; }

/* ═════════ Mamluk manuscript palette: vellum, iron-gall ink, lapis, gold, carmine rubric ═════════ */
:root {
  --paper: oklch(93.2% 0.03 82);
  --paper-2: oklch(90% 0.034 80);
  --paper-3: oklch(86% 0.038 78);
  --line: oklch(81% 0.035 78);
  --ink: oklch(23% 0.035 262);
  --ink-2: oklch(36% 0.035 258);
  --ink-3: oklch(46% 0.03 250);
  --green: oklch(36% 0.095 258);          /* lapis: primary */
  --green-2: oklch(44% 0.11 258);
  --green-soft: oklch(89% 0.035 250);
  --lapis: oklch(30% 0.085 260);
  --lapis-2: oklch(24% 0.07 262);
  --vellum: oklch(93.5% 0.03 82);
  --gold: oklch(72% 0.12 80);
  --gold-2: oklch(50% 0.1 68);
  --gold-soft: oklch(88% 0.06 85);
  --rubric: oklch(45% 0.15 28);
  --ayah: oklch(38% 0.09 165);
  --c-ayah: oklch(38% 0.09 165);
  --mark: oklch(86% 0.1 88);
  --logo-cut: var(--paper);
  --shadow: 0 1px 2px oklch(30% 0.04 70 / .1), 0 10px 30px -14px oklch(25% 0.05 70 / .35);
}
:root[data-theme="night"] { --rubric: oklch(76% 0.12 35); --lapis: oklch(27% 0.03 250); --lapis-2: oklch(22% 0.02 250); --vellum: oklch(92% 0.025 82); --gold: oklch(78% 0.11 82); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) { --rubric: oklch(76% 0.12 35); --lapis: oklch(27% 0.03 250); --lapis-2: oklch(22% 0.02 250); } }
body { background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .32 0 0 0 0 .2 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.top { background: color-mix(in oklch, var(--paper) 90%, transparent); }
.brand svg { color: var(--lapis); }
.brand b { color: var(--ink); }

/* frontispiece hero */
.hero { background:
  radial-gradient(90% 120% at 50% 0%, oklch(40% 0.1 258) 0%, var(--lapis) 45%, var(--lapis-2) 100%); color: var(--vellum);
  margin: 0 clamp(8px, 2vw, 24px); border-radius: 0 0 28px 28px; box-shadow: inset 0 0 0 1px oklch(72% 0.12 80 / .35), inset 0 0 0 7px var(--lapis-2), inset 0 0 0 8px oklch(72% 0.12 80 / .55); }
.hero .pattern { opacity: .32; -webkit-mask-image: radial-gradient(ellipse 80% 90% at 50% 40%, #000 15%, transparent 80%); mask-image: radial-gradient(ellipse 80% 90% at 50% 40%, #000 15%, transparent 80%);
  background-image: 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-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%3Ccircle cx='42' cy='42' r='6'/%3E%3Cpath d='M0 42h18M66 42h18M42 0v18M42 66v18M0 0l14 14M84 0L70 14M0 84l14-14M84 84L70 70'/%3E%3C/svg%3E"); }
.hero h1 { color: var(--vellum); text-shadow: 0 2px 24px oklch(15% 0.05 260 / .5); }
.hero h1 span { color: var(--gold); }
.hero .lede { color: oklch(86% 0.03 82); }
.hero .stats { color: oklch(80% 0.04 82); }
.hero .stats b { color: var(--vellum); }
.hero .seg { background: oklch(100% 0 0 / .08); border-color: oklch(72% 0.12 80 / .35); }
.hero .seg button { color: oklch(85% 0.03 82); }
.hero .seg button[aria-pressed="true"] { background: var(--gold); color: var(--lapis-2); }
.hero .field { background: var(--vellum); border-color: oklch(72% 0.12 80 / .6); }
.hero .continue { background: oklch(100% 0 0 / .08); border-color: oklch(72% 0.12 80 / .35); color: var(--vellum); }
.hero .continue small { color: oklch(80% 0.04 82); }
.btn.primary { background: var(--lapis); border-color: var(--lapis); color: var(--vellum); }
.btn.primary:hover { background: var(--green-2); border-color: var(--green-2); color: var(--vellum); }
.hero .btn.primary { background: var(--gold); border-color: var(--gold); color: var(--lapis-2); }
.hero .btn.primary:hover { background: oklch(78% 0.12 82); border-color: oklch(78% 0.12 82); }

/* rubrics and ornaments */
.section-head h2, .lib-head h1, .s-head h1, .bk h1, .prose h1 { color: var(--ink); }
.section-head h2::after, .lib-head h1::after, .s-head h1::after { content: ""; display: block; width: 64px; height: 2px; margin-top: 10px; background: linear-gradient(90deg, var(--gold), transparent); }
.panel h2, .prose h2 { color: var(--rubric); }
.toc li.l1 > a { color: var(--rubric); }
.quote blockquote { color: var(--ink); }
.orn-star { color: var(--gold-2); }

/* footer as the back board of the binding */
.foot { background: var(--lapis-2); color: oklch(80% 0.03 82); border-top: 3px double oklch(72% 0.12 80 / .6); }
.foot a, .foot .brand b { color: var(--vellum); }
.foot .brand svg { color: var(--gold); }
:root { --c-hadith: oklch(39% 0.1 40); --c-athar: oklch(38% 0.09 262); --c-qawl: oklch(42% 0.08 70); }
:root[data-theme="night"] { --c-hadith: oklch(80% 0.09 45); }

/* ═════════ calm heritage tuning ═════════ */
:root { --lapis: oklch(33% 0.062 252); --lapis-2: oklch(27% 0.05 254); --green: oklch(37% 0.07 252); --green-2: oklch(44% 0.08 252); }
.hero { background: radial-gradient(90% 120% at 50% 0%, oklch(41% 0.07 250) 0%, var(--lapis) 50%, var(--lapis-2) 100%); }
.rv { transition-duration: 1.1s; }
* { scroll-behavior: smooth; }

/* title-page covers: the real first leaf of each edition */
.cover.photo { padding: 0; background: var(--vellum); border-radius: 3px 6px 6px 3px; display: block; position: relative; overflow: hidden;
  box-shadow: inset 5px 0 8px -5px oklch(25% 0.04 60 / .35), 1px 1px 0 var(--line), 2px 2px 0 oklch(84% 0.035 78), 3px 3px 0 var(--line), 0 18px 30px -18px oklch(25% 0.05 60 / .55); }
.cover.photo::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; border: 0;
  background: linear-gradient(90deg, oklch(0% 0 0 / .06), transparent 7%, transparent 93%, oklch(0% 0 0 / .04)); }
.cover.photo::after { content: none; }
.cover.photo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cover-link:hover .cover.photo { transform: translateY(-6px); }

/* the book on its page: turn it over */
.bk-side { position: sticky; top: 88px; display: grid; gap: 14px; justify-items: center; }
.book3d-wrap { width: 100%; display: grid; gap: 14px; justify-items: center; perspective: 1800px; }
.book3d { all: unset; cursor: pointer; display: block; width: 100%; position: relative; }
.book3d:focus-visible { outline: 2.5px solid var(--green-2); outline-offset: 6px; border-radius: 6px; }
.b3-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 1.1s cubic-bezier(.45,.05,.25,1); }
.book3d.flipped .b3-inner { transform: rotateY(180deg); }
.b3-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 3px 7px 7px 3px; overflow: hidden; background: var(--vellum);
  box-shadow: inset 6px 0 10px -6px oklch(25% 0.04 60 / .35), 1px 1px 0 var(--line), 2px 2px 0 oklch(84% 0.035 78), 3px 3px 0 var(--line), 4px 4px 0 oklch(84% 0.035 78), 0 30px 44px -24px oklch(25% 0.05 60 / .6); }
.b3-back { transform: rotateY(180deg); border-radius: 7px 3px 3px 7px; }
.b3-face img { width: 100%; height: 100%; object-fit: contain; display: block; }
.b3-ctrl { justify-self: center; }
@media (max-width: 760px) { .bk-side { position: relative; top: 0; width: 70%; margin-inline: auto; } }
@media (prefers-reduced-motion: reduce) { .b3-inner { transition: none; } }

/* ═════════ leather & gold: replaces the blue ═════════ */
:root { --lapis: oklch(32% 0.055 40); --lapis-2: oklch(25.5% 0.045 40); --green: oklch(36% 0.07 35); --green-2: oklch(43% 0.08 35); --green-soft: oklch(90% 0.03 60); }
:root[data-theme="night"] { --lapis: oklch(27% 0.025 50); --lapis-2: oklch(22% 0.02 50); --green: oklch(80% 0.07 60); --green-2: oklch(86% 0.07 60); --green-soft: oklch(33% 0.03 55); }
.hero { background: radial-gradient(90% 120% at 50% 0%, oklch(41% 0.065 45) 0%, var(--lapis) 50%, var(--lapis-2) 100%); }
.leather { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* ── the binding (front / back), every size in units of its own width ── */
.cover-bind { container-type: inline-size; }
.bind { --c: oklch(33% 0.065 var(--h)); container-type: inline-size; position: relative; aspect-ratio: 720 / 1016; width: 100%;
  border-radius: 1.2cqw 2.4cqw 2.4cqw 1.2cqw; overflow: hidden; color: oklch(80% 0.11 82);
  background:
    radial-gradient(120% 90% at 30% 15%, oklch(100% 0 0 / .09), transparent 55%),
    radial-gradient(130% 120% at 50% 50%, transparent 55%, oklch(0% 0 0 / .32) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .25 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    var(--c);
  box-shadow: inset 3cqw 0 3cqw -2cqw oklch(0% 0 0 / .45), inset -1px 0 0 oklch(100% 0 0 / .08), 0 4cqw 7cqw -4cqw oklch(20% 0.04 50 / .7);
  display: flex; flex-direction: column; align-items: center; text-align: center; padding: 15cqw 12cqw 12cqw; }
.bind-back { border-radius: 2.4cqw 1.2cqw 1.2cqw 2.4cqw; box-shadow: inset -3cqw 0 3cqw -2cqw oklch(0% 0 0 / .45), 0 4cqw 7cqw -4cqw oklch(20% 0.04 50 / .7); justify-content: center; }
.bind-frame { position: absolute; inset: 5.5cqw; border: .45cqw solid oklch(76% 0.11 82 / .85); border-radius: .6cqw; pointer-events: none; }
.bind-frame::before { content: ""; position: absolute; inset: 1.6cqw; border: .25cqw solid oklch(76% 0.11 82 / .5); }
.bind-frame::after { content: ""; position: absolute; inset: -.2cqw; pointer-events: none;
  background:
    radial-gradient(circle at 0 0, oklch(78% 0.11 82 / .9) 0 2.2cqw, transparent 2.4cqw),
    radial-gradient(circle at 100% 0, oklch(78% 0.11 82 / .9) 0 2.2cqw, transparent 2.4cqw),
    radial-gradient(circle at 0 100%, oklch(78% 0.11 82 / .9) 0 2.2cqw, transparent 2.4cqw),
    radial-gradient(circle at 100% 100%, oklch(78% 0.11 82 / .9) 0 2.2cqw, transparent 2.4cqw); }
.bind-series { font: 400 4.4cqw/1.4 var(--read); opacity: .85; letter-spacing: 0; }
.bind-orn { margin: 4cqw 0 0; width: 9cqw; height: 9cqw; color: oklch(80% 0.11 82); }
.bind-orn svg { width: 100%; height: 100%; }
.bind-title { width: 100%; max-height: 42cqw; object-fit: contain; margin: auto 0; filter: drop-shadow(0 .3cqw 0 oklch(0% 0 0 / .35)); }
.bind-title-txt { margin: auto 0; font: 700 12cqw/1.3 var(--read); }
.bind-author { font: 400 4.6cqw/1.4 var(--read); opacity: .9; margin-bottom: 4cqw; }
.bind-pub { font: 400 3.6cqw/1.4 var(--read); opacity: .7; }
.bind-medal { width: 54cqw; height: 54cqw; color: oklch(78% 0.11 82 / .85); }
.bind-medal svg { width: 100%; height: 100%; }
.bind-desc { margin: 7cqw 0 9cqw; font: 400 5.2cqw/1.7 var(--read); color: oklch(84% 0.08 82); max-width: 62cqw; }
.cover-link .bind { transition: transform .6s var(--ease), box-shadow .6s var(--ease); }
.cover-link:hover .bind { transform: translateY(-6px) rotate(-.6deg); }

/* ── book page: cover opens on its spine (right edge) to the title page; turn over for the back ── */
.bk-side { position: sticky; top: 88px; display: grid; gap: 16px; justify-items: center; }
.book3d-wrap { width: 100%; display: grid; gap: 16px; justify-items: center; perspective: 2000px; }
.book3d { position: relative; width: 100%; aspect-ratio: 720 / 1016; cursor: pointer; }
.b3-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 1.2s cubic-bezier(.45,.05,.25,1); }
.book3d[data-state="back"] .b3-inner { transform: rotateY(180deg); }
.b3-back { position: absolute; inset: 0; transform: rotateY(180deg); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.b3-page { position: absolute; inset: 1.5% 0 1.5% 3%; background: var(--vellum); border-radius: 2px 5px 5px 2px; overflow: hidden; transform: translateZ(-1px);
  box-shadow: inset 8px 0 14px -8px oklch(25% 0.04 60 / .35), 2px 2px 0 var(--line), 4px 4px 0 oklch(84% 0.035 78), 0 20px 34px -20px oklch(25% 0.05 60 / .5); }
.b3-page img { width: 100%; height: 100%; object-fit: contain; display: block; }
.b3-cover { position: absolute; inset: 0; transform-origin: right center; transform-style: preserve-3d; transition: transform 1.3s cubic-bezier(.45,.05,.25,1); }
.book3d[data-state="open"] .b3-cover { transform: rotateY(155deg); }
.b3-cover-front, .b3-cover-in { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.b3-cover-in { transform: rotateY(180deg); border-radius: 2.4% 1.2% 1.2% 2.4% / 1.7% .85% .85% 1.7%;
  background: oklch(80% 0.06 75) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40' fill='none' stroke='%23a07a3c' stroke-opacity='.35' stroke-width='1'%3E%3Crect x='12' y='12' width='16' height='16'/%3E%3Crect x='12' y='12' width='16' height='16' transform='rotate(45 20 20)'/%3E%3C/svg%3E"); }
.book3d[data-state="back"] .b3-cover, .book3d[data-state="back"] .b3-page { visibility: hidden; transition: visibility 0s .6s; }
.b3-ctrl { justify-self: center; }
.book3d[data-state="open"] { margin-inline-start: 0; }
@media (max-width: 760px) { .bk-side { position: relative; top: 0; width: 64%; margin-inline: auto; } }
@media (prefers-reduced-motion: reduce) { .b3-inner, .b3-cover { transition: none; } }

/* ── shelf: leather spines with raised bands and gold tooling ── */
.shelf-row { gap: 3px; padding-top: 14px; }
.spine { --c: oklch(var(--l, 32%) 0.065 var(--h)); border-radius: 4px 4px 2px 2px; padding: 0; justify-content: flex-start; gap: 0; color: oklch(80% 0.11 82);
  background:
    linear-gradient(90deg, oklch(0% 0 0 / .38), oklch(0% 0 0 / .05) 14%, oklch(100% 0 0 / .13) 42%, oklch(100% 0 0 / .05) 58%, oklch(0% 0 0 / .1) 84%, oklch(0% 0 0 / .42)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .25 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    var(--c);
  box-shadow: inset 0 0 0 1px oklch(0% 0 0 / .2), 0 6px 10px -6px oklch(20% 0.04 50 / .6); }
.spine .band { width: 100%; height: 9px; margin-top: 16px; border: 0; flex: none;
  background: linear-gradient(180deg, transparent 0 1px, oklch(78% 0.11 82 / .9) 1px 2px, oklch(0% 0 0 / .25) 2px 3px, oklch(100% 0 0 / .12) 3px 6px, oklch(0% 0 0 / .25) 6px 7px, oklch(78% 0.11 82 / .9) 7px 8px, transparent 8px); }
.spine .band.b2 { margin-top: auto; margin-bottom: 0; }
.spine .t { font: 700 16px/1 var(--read); margin: 14px 0; max-height: calc(100% - 110px); color: oklch(84% 0.11 84); text-shadow: 0 1px 0 oklch(0% 0 0 / .4); }
.spine .sorn { width: 14px; height: 14px; margin-top: 10px; color: oklch(78% 0.11 82); flex: none; }
.spine .v { display: grid; place-items: center; width: 20px; height: 20px; margin: 6px 0 4px; border-radius: 999px; border: 1px solid oklch(78% 0.11 82 / .7); font: 600 11px/1 var(--ui); color: oklch(84% 0.11 84); flex: none; }
.spine .v:empty { border: 0; height: 6px; }
.spine .band.b3 { margin-top: 0; margin-bottom: 12px; }
.b3-cover-front, .b3-back, .cover-bind { container-type: inline-size; }
.b3-cover-front .bind, .b3-back .bind { height: 100%; }
.b3-cover { transition: transform 1.3s cubic-bezier(.45,.05,.25,1), opacity .5s ease .75s; }
.book3d[data-state="open"] .b3-cover { transform: rotateY(150deg); opacity: 0; }
.b3-ctrl { position: relative; z-index: 2; }

/* ═════════ table of contents: a printed index ═════════ */
.toc { list-style: none; margin: 0; padding: 0; }
.toc li a { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; transition: background .2s; }
.toc li a:hover { background: color-mix(in oklch, var(--gold) 12%, transparent); }
.toc .tt { font: 400 17px/1.75 var(--read); text-wrap: pretty; min-width: 0; }
.toc .ld { flex: 1; min-width: 18px; border-bottom: 1.5px dotted color-mix(in oklch, var(--ink-3) 55%, transparent); transform: translateY(-5px); }
.toc .pg { flex: none; min-width: 3.2ch; text-align: end; font: 600 13px/1 var(--ui); color: var(--ink-3); white-space: nowrap; }
.toc li.l1 { margin-top: 14px; }
.toc li.l1:first-child { margin-top: 0; }
.toc li.l1 > a .tt { font: 700 18.5px/1.7 var(--read); color: var(--rubric); }
.toc li.l1 > a .tt::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-inline-end: 10px; transform: rotate(45deg) translateY(-3px); background: var(--gold); }
.toc li.l2 > a { padding-inline-start: 30px; }
.toc li.l3 > a { padding-inline-start: 48px; }
.toc li.l4 > a { padding-inline-start: 64px; }
.toc li.l2, .toc li.l3, .toc li.l4 { position: relative; }
.toc li.l2::before, .toc li.l3::before, .toc li.l4::before { content: ""; position: absolute; top: 0; bottom: 0; inset-inline-start: 16px; width: 1px; background: color-mix(in oklch, var(--gold) 45%, transparent); }
.toc li.l3 .tt, .toc li.l4 .tt { font-size: 15.5px; color: var(--ink-2); }
.toc li.na .tt { color: var(--ink-3); }
.toc li.na.l1 > a .tt { color: var(--ink-3); }
.toc .tvol { margin: 22px 0 6px; padding: 8px 10px; display: flex; align-items: center; gap: 12px; font: 700 15px/1 var(--ui); color: var(--gold-2); }
.toc .tvol::before, .toc .tvol::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in oklch, var(--gold) 60%, transparent)); }
.toc .tvol::after { background: linear-gradient(90deg, color-mix(in oklch, var(--gold) 60%, transparent), transparent); }
.toc .tvol:first-child { margin-top: 0; }
.toc li a.cur { background: color-mix(in oklch, var(--gold) 18%, transparent); }
.toc li a.cur .tt { font-weight: 700; }

/* ═════════ spacing & sizes ═════════ */
.bk { grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); gap: clamp(32px, 6vw, 80px); padding-top: clamp(28px, 4vw, 56px); }
.bk h1 { font-size: clamp(28px, 3.6vw, 44px); margin: 6px 0 10px; }
.bk .desc { font-size: clamp(17px, 1.6vw, 20px); margin: 0 0 18px; }
.facts { gap: 6px 22px; margin-bottom: 22px; }
.actions { gap: 10px; margin-bottom: 28px; }
.panel { padding: 26px 0 28px; }
.panel h2 { margin-bottom: 16px; }
.b3-ctrl button { white-space: nowrap; padding: 6px 12px; font-size: 13.5px; }
.covers { grid-template-columns: repeat(auto-fill, minmax(min(168px, 42vw), 1fr)); gap: clamp(22px, 3vw, 36px) clamp(14px, 2.4vw, 28px); }
.cover-meta { display: grid; gap: 2px; }
.cover-meta b { font-size: 16.5px; line-height: 1.45; }
.lib-head { padding: clamp(32px, 5vw, 64px) 0 8px; }
.lib-head p { margin: 4px 0 20px; }
.cats { gap: 8px; margin-bottom: 30px; }
@media (max-width: 860px) { .bk { grid-template-columns: 1fr; } .bk-side { position: relative; top: 0; width: min(260px, 62%); margin-inline: auto; } }
@media (max-width: 560px) {
  .covers { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; }
  .cats { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scrollbar-width: none; }
  .cats::-webkit-scrollbar { display: none; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .toc .tt { font-size: 16px; }
  .toc li.l2 > a { padding-inline-start: 24px; } .toc li.l3 > a { padding-inline-start: 36px; } .toc li.l4 > a { padding-inline-start: 46px; }
  .toc li.l2::before, .toc li.l3::before, .toc li.l4::before { inset-inline-start: 12px; }
}

/* ═════════ share sheet ═════════ */
dialog.share-sheet { border: 0; padding: 0 20px 22px; width: min(460px, 100vw); max-height: 92dvh; overflow: auto; border-radius: 22px; background: var(--paper); color: var(--ink);
  box-shadow: 0 30px 80px -20px oklch(20% 0.04 50 / .6); }
dialog.share-sheet::backdrop { background: oklch(18% 0.03 50 / .45); backdrop-filter: blur(3px); }
dialog.share-sheet[open] { animation: shIn .38s var(--ease); }
@keyframes shIn { from { opacity: 0; transform: translateY(24px) scale(.98); } }
.share-sheet header { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 10px; }
.share-sheet h2 { font-size: 22px; }
.sh-grip { display: none; }
.sh-card { margin: 0 auto 16px; width: min(300px, 70%); aspect-ratio: 1080 / 1350; border-radius: 10px; overflow: hidden; background: var(--paper-3); box-shadow: 0 16px 34px -18px oklch(20% 0.04 50 / .6); }
.sh-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.sh-card img.loading { opacity: 0; }
.sh-card:has(img.loading) { background: linear-gradient(90deg, var(--paper-2), var(--paper-3), var(--paper-2)); background-size: 200% 100%; animation: shim 1.2s infinite linear; }
.sh-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 6px; }
.sh-grid button { display: grid; justify-items: center; gap: 6px; border: 0; background: none; padding: 6px 2px; border-radius: 14px; color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.sh-grid button:hover { background: var(--paper-2); }
.sh-grid .i { width: 52px; height: 52px; padding: 13px; border-radius: 999px; background: var(--paper-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.sh-grid .b-wa .i { background: oklch(64% 0.15 150); color: white; box-shadow: none; }
.sh-grid .b-tg .i { background: oklch(64% 0.12 235); color: white; box-shadow: none; }
.sh-grid .b-x .i { background: oklch(22% 0.01 250); color: white; box-shadow: none; }
@media (max-width: 560px) {
  dialog.share-sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  dialog.share-sheet[open] { animation: shUp .42s var(--ease); }
  @keyframes shUp { from { transform: translateY(100%); } }
  .sh-grip { display: block; width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 10px auto 2px; }
}

/* ═════════ inner page header: leather band ═════════ */
.page-hero { position: relative; overflow: hidden; margin: 0 clamp(8px, 2vw, 24px) clamp(26px, 4vw, 44px); border-radius: 0 0 26px 26px; color: var(--vellum);
  background: radial-gradient(90% 140% at 50% 0%, oklch(41% 0.065 45) 0%, var(--lapis) 55%, var(--lapis-2) 100%);
  box-shadow: inset 0 0 0 1px oklch(72% 0.12 80 / .35), inset 0 0 0 6px var(--lapis-2), inset 0 0 0 7px oklch(72% 0.12 80 / .5); }
.page-hero .pattern { opacity: .22; }
.page-hero .wrap { position: relative; padding: clamp(34px, 5vw, 60px) 0 clamp(26px, 4vw, 40px); display: grid; gap: 12px; }
.page-hero.slim .wrap { padding-bottom: clamp(24px, 3.5vw, 34px); }
.page-hero h1 { font: 700 clamp(40px, 6vw, 64px)/1.2 var(--ruqaa); color: var(--gold); text-shadow: 0 2px 18px oklch(15% 0.04 40 / .45); }
.page-hero h1::after { content: none !important; }
.page-hero p { margin: -4px 0 6px; font: 400 clamp(16px, 1.7vw, 19px)/1.7 var(--read); color: oklch(86% 0.035 80); }
.page-hero .field { background: var(--vellum); border-color: oklch(72% 0.12 80 / .55); }
.page-hero .field input, .page-hero .field textarea { color: var(--ink); }
.page-hero .s-tools { margin-top: 2px; }
.page-hero .seg { background: oklch(100% 0 0 / .08); border-color: oklch(72% 0.12 80 / .35); }
.page-hero .seg button { color: oklch(86% 0.03 82); }
.page-hero .seg button[aria-pressed="true"] { background: var(--gold); color: var(--lapis-2); }
.page-hero select.chip { background: oklch(100% 0 0 / .08); color: var(--vellum); border-color: oklch(72% 0.12 80 / .4); }
.page-hero select.chip option { color: var(--ink); background: var(--paper); }
.page-hero .count { color: oklch(84% 0.04 82); }
.page-hero .btn.primary { background: var(--gold); border-color: var(--gold); color: var(--lapis-2); }
.page-hero .filter .field { box-shadow: none; }
.page-hero .field svg.i { color: var(--ink-3); }

/* ask */
.ask-ex { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; margin-top: 4px; }
.ex-h { grid-column: 1 / -1; font: 700 22px/1.4 var(--read); color: var(--rubric); margin: 0 0 4px; }
.ask-ex button { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; text-align: start; padding: 16px 18px; border-radius: 16px;
  border: 1px solid var(--line); background: color-mix(in oklch, var(--paper) 70%, white); color: var(--ink); transition: transform .25s var(--ease), box-shadow .25s, border-color .25s; }
.ask-ex button:hover { transform: translateY(-2px); border-color: color-mix(in oklch, var(--gold) 60%, var(--line)); box-shadow: 0 14px 28px -20px oklch(25% 0.05 50 / .55); }
.ex-k { font: 700 12.5px/1 var(--ui); color: var(--gold-2); padding: 7px 10px; border-radius: 999px; background: color-mix(in oklch, var(--gold) 14%, transparent); white-space: nowrap; }
.ex-q { font: 400 18.5px/1.6 var(--read); }
.ex-go { width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 1.8; }
.ans-q { font: 700 clamp(22px, 2.6vw, 28px)/1.5 var(--read); color: var(--rubric); margin: 6px 0 14px; text-wrap: balance; }
.answer.on { position: relative; margin-top: 0; padding: clamp(24px, 4vw, 44px) clamp(20px, 4vw, 48px); border-radius: 10px;
  background: color-mix(in oklch, var(--paper) 55%, white); box-shadow: 0 18px 40px -26px oklch(25% 0.05 50 / .45), 0 1px 0 var(--line); }
.answer.on::before { content: ""; position: absolute; inset: 10px; border: 1px solid oklch(66% 0.11 78 / .45); border-radius: 4px; pointer-events: none; box-shadow: inset 0 0 0 3px transparent, inset 0 0 0 4px oklch(66% 0.11 78 / .22); }
.answer h3 { color: var(--rubric); }
.src header .n { background: oklch(33% 0.065 var(--h)); color: oklch(84% 0.11 84); }
.src { background: color-mix(in oklch, var(--paper) 60%, white); }
.ask { width: min(900px, 100% - 2 * var(--gutter)); }
.page-hero .wrap.ask { width: min(900px, 100% - 2 * var(--gutter)); }
