/* مكتبة أهل البيت — the root app's design (src/styles.css tokens, components and
   screens), in RTL, mobile first, with desktop adaptations at wide widths.
   One stylesheet, no external requests. The site font is the visitor's «الخط» choice, Scheherazade
   New (self-hosted) by default, applied at the root: see «site font» at the end. */

:root {
  /* the device's own stacks: the «خطوط الجهاز» choice, fallbacks of every other choice, and Latin text */
  --system-sans: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Roboto, Arial, sans-serif;
  --system-arabic: "Noto Naskh Arabic", "Amiri", "Scheherazade New", "Traditional Arabic", "Geeza Pro", "Arabic Typesetting", "Times New Roman", serif;
  /* the roles components use; overridden by the site font (end of file) */
  --sans: var(--system-sans);
  --arabic: var(--system-arabic);
  --serif: var(--arabic);

  /* the app's tokens (same values) */
  --green-950: #0f3021;
  --green-900: #143d2b;
  --green: #1b4a35;
  --green-700: #245c42;
  --gold: #c9a24f;
  --gold-deep: #a9832f;
  --gold-soft: #e8d39c;
  --bg: #f7f0e1;
  --paper: #fcf8ef;
  --card: #fffbf3;
  --ink: #1d2721;
  --ink-2: #3b443d;
  --muted: #6f6c60;
  --line: #e8dcc4;
  --line-2: #efe5d2;

  --tag-green-bg: #d9eadb;
  --tag-green-fg: #285a3c;
  --tag-rose-bg: #f5d9d1;
  --tag-rose-fg: #8b3a2b;
  --tag-tan-bg: #f2e2c2;
  --tag-tan-fg: #7a5422;
  --tag-plain-bg: #f8f1e3;
  --tag-plain-fg: #4b4a40;

  --label-general: #ebb64e;
  --label-study: #9fd0ab;
  --label-reflection: #ee9d92;
  --label-action: #a9c9ee;
  --hl-general: rgba(242, 203, 110, 0.5);
  --hl-study: rgba(150, 205, 165, 0.45);
  --hl-reflection: rgba(238, 160, 148, 0.42);
  --hl-action: rgba(160, 196, 238, 0.45);

  /* website additions */
  --link: var(--green-700);
  --danger: #9b2c1f;
  --mark: #f1d98f;           /* search match in the text (distinct from user highlights) */
  --mark-ink: #1d2721;
  --tabbar-h: 64px;
  --rail-w: 232px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 45, 15, 0.06), 0 4px 14px rgba(60, 45, 15, 0.06);
  --read-size: 1.2rem;
  --read-lh: 2.05;
  color-scheme: light;
}

/* Reading modes: the app's sepia and dark token sets (applied site-wide here; «تلقائي» follows the system). */
:root[data-theme="sepia"],
:root:not([data-theme]) {
  --bg: #f1e4c8;
  --paper: #f4e8cf;
  --card: #f7ecd5;
  --ink: #3d2f1c;
  --ink-2: #4e3d25;
  --line: #dfcca5;
}
:root[data-theme="dark"] {
  --bg: #121815;
  --paper: #161d19;
  --card: #1b231e;
  --ink: #e7e1d3;
  --ink-2: #cfc8b8;
  --muted: #9a9688;
  --line: #2c3630;
  --line-2: #26302a;
  --hl-general: rgba(214, 170, 70, 0.38);
  --hl-study: rgba(110, 180, 130, 0.35);
  --hl-reflection: rgba(220, 120, 108, 0.35);
  --hl-action: rgba(110, 160, 220, 0.35);
  --link: #9fd0ab;
  --danger: #f0a196;
  --mark: #6b5a1c;
  --mark-ink: #fff6d8;
  --tag-green-bg: #23362b;
  --tag-green-fg: #a9d8b6;
  --tag-tan-bg: #3a3020;
  --tag-tan-fg: #e5cf8f;
  --tag-plain-bg: #1f2722;
  --tag-plain-fg: #cfc8b8;
  color-scheme: dark;
}
/* Before js/boot-theme.js runs (or without scripts): the default «ورقي» (sepia, above). */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-underline-offset: 0.2em; }
h1, h2, h3 { line-height: 1.35; }
ol { list-style-type: arabic-indic; } /* numbered lists in Arabic-Indic digits (js/digits.js draws the text) */
p { margin: 0.45rem 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
h1:focus, main:focus { outline: none; }
mark { background: var(--mark); color: var(--mark-ink); border-radius: 2px; padding: 0 1px; }
.offscreen {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; inset-inline-start: 0.5rem; top: -3rem; background: var(--paper); color: var(--ink); padding: 0.5rem 1rem; z-index: 90; border-radius: 8px; }
.skip:focus { top: 0.5rem; }

/* ---------------------------------------------------------------- shell */
.app { min-height: 100vh; min-height: 100dvh; }
.main { display: block; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
.state { color: var(--ink-2); }
.state.small, .small { font-size: 0.9rem; }
.boot { padding: 3rem 1rem; text-align: center; }
.page { margin: 0 auto; }
.narrow { max-width: 42rem; padding: 1rem; }

/* Tab bar (phones): the app's four tabs */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #6b6f68; font-size: 12.5px; text-decoration: none; min-width: 0;
}
.tab .tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab.on { color: var(--green); font-weight: 650; }
:root[data-theme="dark"] .tab { color: #9aa39d; }
:root[data-theme="dark"] .tab.on { color: var(--gold); }
.tab-search, .rail-brand, .rail-about { display: none; }
/* search lives on Home on phones (as in the app): Home stays lit while searching */
.tabbar[data-active="search"] .tab[data-tab="home"] { color: var(--green); font-weight: 650; }
:root[data-theme="dark"] .tabbar[data-active="search"] .tab[data-tab="home"] { color: var(--gold); }

/* ---------------------------------------------------------------- green headers */
.hero, .green-head {
  position: relative; overflow: hidden; color: #fff;
  background: radial-gradient(120% 90% at 50% 0%, #22583f 0%, var(--green) 55%, var(--green-900) 100%);
}
.motifs { position: absolute; inset: 0; pointer-events: none; color: var(--gold); }
/* The Imam Hussain Foundation mark on both sides, in the same faint gold as the rosettes it replaced:
   the SVG is only an alpha mask, the colour is the theme's --gold. No mask support = no mark. */
/* Same box as those rosettes: 120px, half off the header's edge, and running under the cream sheet. */
.motif { display: none; position: absolute; top: 34px; width: 120px; aspect-ratio: 300 / 294; opacity: 0.3; background: currentColor; }
@supports (mask-image: url("../img/ihf-mark.svg")) or (-webkit-mask-image: url("../img/ihf-mark.svg")) {
  .motif {
    display: block;
    -webkit-mask: url("../img/ihf-mark.svg") center / contain no-repeat;
    mask: url("../img/ihf-mark.svg") center / contain no-repeat;
  }
}
.motif-l { left: -46px; }
.motif-r { right: -46px; }
.hero { text-align: center; padding: 34px 20px 46px; }
.hero-in { position: relative; max-width: 40rem; margin: 0 auto; }
.hero-rosette { color: var(--gold); display: block; margin: 0 auto 8px; }
/* The library logo on the page background (sidebar, Profile's «عن المكتبة»): white linework in the dark theme. */
:root[data-theme="dark"] img.brand-logo:not(.on-dark) { content: url("../img/site-logo-light.svg"); }
.brand-logo { flex: none; object-fit: contain; }
.hero h1 { font-family: var(--serif); font-weight: 700; font-size: 2.1rem; margin: 0; line-height: 1.25; }
.hero-sub { color: #efe7d2; font-family: var(--serif); font-size: 1.05rem; margin: 6px 0 22px; }
.green-head { padding: 26px 16px 40px; }
.gh-row { position: relative; display: flex; align-items: center; gap: 8px; max-width: 72rem; margin: 0 auto; }
.gh-titles { flex: 1; min-width: 0; }
.gh-title { font-family: var(--serif); font-weight: 700; font-size: 1.75rem; margin: 0; line-height: 1.3; }
.gh-sub { color: #efe7d2; font-size: 0.95rem; margin: 4px 0 0; position: relative; }
.green-head > .gh-sub, .green-head > .searchbox, .green-head > .seg { max-width: 72rem; margin-inline: auto; position: relative; }
.green-head > .searchbox { margin-top: 18px; }
.green-head > .seg { margin-top: 14px; }
.gh-actions { display: flex; gap: 4px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 999px; background: none; color: inherit; cursor: pointer; text-decoration: none;
}
.icon-btn.small { width: 36px; height: 36px; }
.icon-btn:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn.on-green { color: #fff; }
.icon-btn[aria-pressed="true"] { color: var(--green); }
:root[data-theme="dark"] .icon-btn[aria-pressed="true"] { color: var(--gold); }

/* The rounded sheet that overlaps the green header */
.sheet-body {
  position: relative; margin-top: -22px; background: var(--bg);
  border-radius: 24px 24px 0 0; padding: 20px 16px 16px;
}

/* ---------------------------------------------------------------- search pill */
.searchbox {
  position: relative; display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 16px; border-radius: 999px;
  /* theme tokens, not fixed colours: paper-coloured in «ورقي», dark in «داكن» (D-027) */
  background: var(--card); color: var(--ink-2); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.searchbox input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 1.05rem; color: var(--ink); height: 100%;
}
.searchbox input::placeholder { color: var(--muted); opacity: 1; }
.searchbox input::-webkit-search-cancel-button { display: none; }
.searchbox:focus-within { box-shadow: 0 0 0 2px var(--gold), 0 2px 6px rgba(0, 0, 0, 0.12); }
.searchbox .sb-ic { flex: none; color: var(--muted); }
.sb-clear { display: grid; place-items: center; width: 32px; height: 32px; border: 0; background: none; color: var(--ink-2); cursor: pointer; border-radius: 50%; }
.sb-go {
  flex: none; border: 0; border-radius: 999px; height: 38px; padding: 0 16px; margin-inline-end: -10px;
  background: var(--green); color: #fff; font-weight: 600; cursor: pointer;
}
.searchbox.small { height: 42px; box-shadow: none; border: 1px solid var(--line); background: var(--paper); }
.hero .searchbox { max-width: 36rem; margin: 0 auto; }

/* ---------------------------------------------------------------- chips, pills, buttons */
.chips { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; margin: 0 -16px; padding-inline: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chips-btn { display: none; } /* home «الأقسام» scroll buttons: desktop only (see >= 1024px) */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; flex: none;
  border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink-2);
  font-size: 0.95rem; white-space: nowrap; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 1px rgba(60, 45, 15, 0.04);
}
.chip:hover { border-color: var(--gold); }
.chip.on, .chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.chip-more { color: var(--green-700); font-weight: 600; }
.chip-x { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: inherit; margin-inline-end: -8px; }
.chip-x:hover { background: rgba(255, 255, 255, 0.2); }
.pill, .badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; white-space: nowrap; background: var(--tag-plain-bg); color: var(--tag-plain-fg);
  border: 1px solid var(--line-2); vertical-align: middle;
}
.pill.ok { background: var(--tag-green-bg); color: var(--tag-green-fg); border-color: transparent; }
.pill.muted { background: var(--tag-tan-bg); color: var(--tag-tan-fg); border-color: transparent; }
.badge.tier { font-weight: 500; color: var(--muted); background: none; border-color: var(--line); border-radius: 4px; }
.badge.tier-phrase { color: var(--tag-green-fg); border-color: #bcd8c0; }
.tag { display: inline-block; font-size: 0.78rem; padding: 0 0.5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 40px; padding: 0.35rem 1rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font-size: 0.95rem; line-height: 1.4; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--green-700); }
.btn.big { font-size: 1.05rem; padding: 0.55rem 1.5rem; min-height: 46px; }
.btn.small { min-height: 34px; padding: 0.2rem 0.8rem; font-size: 0.88rem; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: var(--paper); }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: default; }
.btn[aria-pressed="true"] { border-color: var(--green); color: var(--green); background: var(--tag-green-bg); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.8rem; margin: 1rem 0; }
.more-row { text-align: center; margin: 1rem 0; }
.notice {
  font-size: 0.95rem; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-inline-start: 4px solid var(--gold); padding: 0.7rem 0.9rem; border-radius: 10px;
}
.quiet { color: var(--ink-2); font-size: 0.9rem; }
.hint { color: var(--ink-2); font-size: 0.85rem; flex-basis: 100%; }
.count { color: var(--ink-2); font-size: 0.95rem; min-height: 1.5em; }
.help { color: var(--ink-2); font-size: 0.9rem; }
.contact { padding: 0.75rem 1rem; border: 1px dashed var(--muted); border-radius: 10px; }
.prose p { line-height: 1.9; }
a.unavailable { color: var(--muted); }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0.5rem 0; font-size: 0.95rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }
.lab-general .dot, .dot.lab-general { background: var(--label-general); }
.dot.lab-study { background: var(--label-study); }
.dot.lab-reflection { background: var(--label-reflection); }
.dot.lab-action { background: var(--label-action); }

/* Segmented control (the app's) — buttons or links */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--paper);
  border-radius: 999px; padding: 4px; box-shadow: var(--shadow); gap: 2px;
}
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 10px; border: 0; border-radius: 999px; background: none;
  font-size: 0.95rem; color: var(--ink-2); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.seg-btn.on { background: var(--green); color: #fff; font-weight: 600; }
.seg-btn .count-badge { font-size: 0.78rem; opacity: 0.8; }
.seg.seg-small { box-shadow: none; border: 1px solid var(--line); grid-auto-columns: auto; }
@media (max-width: 40rem) {
  /* never let a segmented control widen the page: labels wrap instead */
  .seg { grid-auto-columns: minmax(0, auto); }
  .seg-btn { white-space: normal; line-height: 1.25; text-align: center; min-width: 0; padding: 4px 8px; }
}
.seg.seg-small .seg-btn { min-height: 32px; font-size: 0.85rem; padding: 0 8px; }
/* radio-based segmented control (reader display mode) */
.seg-control { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin: 0; background: var(--paper); min-width: 0; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 0.2rem 0.85rem; border-radius: 999px; font-size: 0.85rem; color: var(--ink-2); }
.seg-opt input:checked + span { background: var(--green); color: #fff; font-weight: 600; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------------------------------------------------------------- covers & cards */
.cover {
  position: relative; overflow: hidden; border-radius: 4px; background: #ddd2b8; flex: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 4px 10px rgba(50, 35, 10, 0.18);
}
.cover-svg { display: block; width: 100%; height: 100%; }
.cover-title { font-family: var(--arabic); font-weight: 700; direction: rtl; }
.cover-author { font-family: var(--sans); direction: rtl; }
.cover-card { width: 96px; height: 148px; }
.cover-row { width: 76px; height: 110px; }
.cover-mini { width: 40px; height: 60px; }
.cover-hero { width: 132px; height: 200px; }

.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sec-head h2 { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; margin: 0; }
.sec-head h2 { min-width: 0; }
.sec-sub { display: block; font-family: var(--sans); font-size: 0.82rem; font-weight: 400; color: var(--muted); white-space: nowrap; }
.see-all { display: inline-flex; align-items: center; gap: 2px; color: var(--green); font-size: 0.95rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
:root[data-theme="dark"] .see-all, :root[data-theme="dark"] .chip-more { color: var(--gold); }
.home-sec { margin-top: 26px; }
.shelf {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px 8px;
}
.shelf::-webkit-scrollbar { display: none; }
.book-card { flex: 0 0 96px; width: 96px; scroll-snap-align: start; display: flex; flex-direction: column; color: var(--ink); text-decoration: none; }
.book-card:hover .bc-title { color: var(--green-700); }
.bc-title {
  font-family: var(--serif); font-weight: 700; font-size: 0.95rem; line-height: 1.35; margin-top: 9px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bc-author, .bc-sub { font-size: 0.8rem; color: var(--ink-2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-sub { color: var(--muted); }
.book-card.unavailable { opacity: 0.75; }
.book-card .pill { margin-top: 6px; align-self: flex-start; max-width: 100%; overflow: hidden; }
.cont-bar { display: block; height: 4px; border-radius: 4px; background: var(--line); margin-top: 6px; overflow: hidden; }
.cont-bar > span { display: block; height: 100%; width: 0; background: var(--gold); }
.home-more { text-align: center; margin: 28px 0 8px; }

/* ---------------------------------------------------------------- explore */
.ex-sec { margin-top: 22px; }
.ex-sec:first-child { margin-top: 4px; }
.sec-help { color: var(--ink-2); font-size: 0.9rem; margin: -4px 0 12px; }
.cat-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
.cat-card {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px;
  border-radius: 12px; background: var(--card); border: 1px solid var(--line-2); color: var(--ink); text-decoration: none;
}
.cat-card:hover { border-color: var(--gold); }
.cat-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--tag-green-bg); color: var(--green); flex: none; }
.cat-card.unavailable .cat-ic { background: var(--tag-plain-bg); color: var(--muted); }
.cat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cat-name { font-family: var(--serif); font-size: 1.05rem; font-weight: 700; color: var(--green-900); }
:root[data-theme="dark"] .cat-name { color: var(--ink); }
.cat-card.unavailable .cat-name { color: var(--ink-2); font-weight: 600; }
.cat-meta { font-size: 0.85rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; }
.cat-meta .pill { height: 20px; font-size: 0.72rem; }
.cat-go { color: var(--muted); flex: none; }
.src-card, .card {
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 14px; margin-top: 10px;
}
.src-name { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; margin-top: 0; }
.card-h { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 1.25rem; font-weight: 700; margin: 0 0 8px; }
.card-h .icon { color: var(--gold-deep); }
.card h3 { font-size: 1rem; margin: 14px 0 4px; }

/* ---------------------------------------------------------------- category */
.filter.searchbox { margin-bottom: 10px; box-shadow: none; border: 1px solid var(--line); background: var(--paper); height: 46px; }
.aside-link { font-size: 0.95rem; }
.aside-link a { display: inline-flex; align-items: center; gap: 4px; }
.work-list { list-style: none; margin: 0; padding: 0; }
.work-list > li { border-bottom: 1px solid var(--line-2); content-visibility: auto; contain-intrinsic-size: auto 5.5rem; }
.work > a, .work summary { display: flex; align-items: center; gap: 12px; padding: 10px 2px; color: var(--ink); text-decoration: none; cursor: pointer; }
.work summary { list-style: none; }
.work summary::-webkit-details-marker { display: none; }
.work-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.work-title { font-family: var(--serif); font-weight: 700; font-size: 1.02rem; }
.work > a:hover .work-title, .work summary:hover .work-title { color: var(--green-700); }
.work-meta { color: var(--ink-2); font-size: 0.88rem; }
.work-chev { color: var(--muted); transition: transform 0.15s; }
.work details[open] .work-chev { transform: rotate(180deg); }
.work .pill { align-self: flex-start; margin-top: 3px; }
.muted .work-title { color: var(--ink-2); font-weight: 600; }
.volumes { margin: 0 0 12px; padding: 0 52px 0 0; display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.volumes a, .volumes span { display: inline-block; padding: 0.25rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); text-decoration: none; font-size: 0.9rem; }
.volumes span[aria-current] { border-color: var(--green); color: var(--green); }

/* ---------------------------------------------------------------- book */
.book-hero { display: flex; gap: 16px; align-items: flex-start; }
.book-hero-text { min-width: 0; }
.book-hero h1 { font-family: var(--serif); font-size: 1.6rem; margin: 0 0 4px; }
.book-author { font-family: var(--serif); font-size: 1.05rem; color: var(--ink-2); margin: 0 0 4px; }
.mine-actions { margin-top: -0.25rem; }
.book-search { margin: 1rem 0; }
.book-search .searchbox { box-shadow: none; border: 1px solid var(--line); background: var(--paper); height: 46px; }
.book-meta { margin: 1rem 0; border: 1px solid var(--line-2); background: var(--card); border-radius: 12px; padding: 8px 14px; }
.book-meta > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.volumes-nav { margin: 1rem 0; }
.volumes-nav h2, .book-main h2 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 8px; }
.volumes-nav details { margin-top: 0.5rem; }
.volumes-nav summary { cursor: pointer; color: var(--ink-2); }
.volumes-nav .volumes { padding: 8px 0 0; }
.pager { display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.pager a { text-decoration: none; }
.book-main { margin-top: 1rem; }
.toc { list-style: none; padding: 0; margin: 0; }
.toc li { border-bottom: 1px solid var(--line-2); content-visibility: auto; contain-intrinsic-size: auto 3rem; }
.toc a { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1rem; padding: 0.55rem 0.2rem; text-decoration: none; color: var(--ink); }
.toc a:hover .toc-title { color: var(--green-700); text-decoration: underline; }
.toc a[aria-current] { background: var(--tag-green-bg); border-radius: 8px; padding-inline: 0.5rem; }
.toc-title { font-family: var(--serif); }
.toc-where { color: var(--muted); font-size: 0.85rem; }

/* ---------------------------------------------------------------- search */
.search-page .green-head { padding-bottom: 44px; }
.filters { display: grid; gap: 10px; margin-bottom: 8px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.f-label { font-size: 0.85rem; color: var(--muted); }
.chip-select {
  height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper);
  padding: 0 12px; color: var(--ink-2); max-width: 100%; font-size: 0.92rem;
}
.filter-row .seg { flex: 1; min-width: 0; max-width: 32rem; }
.help-box { margin: 6px 0 10px; font-size: 0.9rem; }
/* «ابحث في هذه النتائج» (search within the current results) */
.refine { display: grid; gap: 4px; margin: 6px 0 12px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); }
.refine[hidden] { display: none; }
.refine-row { display: flex; gap: 8px; min-width: 0; }
.refine-row input { flex: 1 1 0; width: 0; min-width: 0; min-height: 40px; padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 1rem; }
.refine-row .btn { flex: none; min-height: 40px; }
.retry-shard { margin-inline-start: 6px; }
.help-box > summary { cursor: pointer; color: var(--green-700); }
:root[data-theme="dark"] .help-box > summary { color: var(--gold); }
.results-count { font-weight: 600; color: var(--ink); }
.notes-list { list-style: none; padding: 0; margin: 0.25rem 0; color: var(--ink-2); font-size: 0.9rem; }
.notes-list:empty { display: none; }
.res-h { font-family: var(--serif); font-size: 1.15rem; margin: 18px 0 6px; }
.r-list { list-style: none; margin: 0; padding: 0; }
.r-row { position: relative; border-bottom: 1px solid var(--line); content-visibility: auto; contain-intrinsic-size: auto 150px; }
.r-link { display: flex; gap: 14px; padding: 14px 0 14px 44px; color: var(--ink); text-decoration: none; }
.r-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.r-title { font-family: var(--serif); font-weight: 700; font-size: 1.08rem; line-height: 1.35; }
.r-link:hover .r-title { color: var(--green-700); }
.r-author { font-family: var(--serif); font-size: 0.95rem; color: var(--ink-2); margin-top: 1px; }
.r-snippet {
  font-family: var(--arabic); font-size: 1.05rem; line-height: 1.85; color: var(--ink); margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; unicode-bidi: plaintext;
}
.r-snippet mark { background: var(--hl-general); color: inherit; font-weight: 700; }
.r-loc { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: 0.82rem; color: var(--gold-deep); font-weight: 600; }
:root[data-theme="dark"] .r-loc { color: var(--gold); }
.r-loc .loc { display: inline-flex; align-items: center; gap: 3px; }
.book-hit .r-link { padding-inline-end: 0; }
.bm-btn { position: absolute; left: -4px; top: 10px; width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; color: var(--ink-2); cursor: pointer; border-radius: 50%; }
.reader-head .bm-btn { position: static; width: 44px; height: 44px; }
.bm-btn[aria-pressed="true"] { color: var(--green); }
:root[data-theme="dark"] .bm-btn[aria-pressed="true"] { color: var(--gold); }
.dups { padding: 0 0 10px; font-size: 0.88rem; }
.dups summary { cursor: pointer; color: var(--ink-2); }
.dups ul { margin: 0.3rem 0; padding-inline-start: 1.2rem; }
.end-line { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 10px 0 20px; }
.empty-state { padding: 10px 0; }
.empty-state .chips { flex-wrap: wrap; margin: 0; padding: 0; }
.sentinel { height: 1px; }

/* ---------------------------------------------------------------- reader */
.reader { min-height: 100vh; }
.reader-head {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 2px;
  padding: 6px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.rh-titles { flex: 1; min-width: 0; text-align: center; }
.rh-title { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rh-sub { display: flex; justify-content: safe center; gap: 0 10px; font-size: 0.82rem; color: var(--ink-2); margin: 0; white-space: nowrap; overflow: hidden; }
.rh-sub .loc-pos { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rh-actions { display: flex; }
.reader-grid { display: block; }
.reader-main { min-width: 0; }
.reader-body { max-width: 44rem; margin: 0 auto; padding: 22px 20px calc(130px + var(--safe-b)); }
.eyebrow { text-align: center; font-family: var(--serif); font-size: 1rem; color: var(--ink-2); margin: 0; }
.chapter-title { text-align: center; font-family: var(--serif); font-weight: 700; font-size: 1.7rem; margin: 4px 0 0; text-wrap: balance; }
.chapter-title a { color: inherit; text-decoration: none; }
.reader-mode-row { display: flex; justify-content: center; margin-top: 10px; }
.divider { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--gold); margin: 14px auto 16px; max-width: 240px; }
.divider span { flex: 1; height: 1.5px; background: var(--gold); opacity: 0.8; }
.attribution { text-align: center; font-size: 0.82rem; color: var(--muted); margin: 18px 0 8px; }
.reader[data-style="excerpt"] .loc-label { color: var(--gold-deep); }
.reader-content { margin: 0.5rem 0; }
.unit { padding: 0.25rem 0 1rem; scroll-margin-top: 80px; }
.flow .unit + .unit { border-top: 1px solid var(--line-2); padding-top: 0.9rem; }
.unit-marker { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; color: var(--gold-deep); margin: 0 0 6px; }
.unit-marker a { color: inherit; text-decoration: none; }
.text {
  font-family: var(--arabic); font-size: var(--read-size); line-height: var(--read-lh);
  white-space: pre-wrap; unicode-bidi: plaintext; text-align: right; color: var(--ink);
}
/* First-line indent of a prose paragraph (js/paragraphs.js): an empty marker at the paragraph's first
   character, 1em on the line's start (right) side; wrapped lines keep the normal margin. It has no text,
   so selection, copy, highlights and every offset are those of the source text. */
.para-in { display: inline-block; width: 1em; height: 1px; user-select: none; -webkit-user-select: none; pointer-events: none; }
/* the source's commentary («الشرح») and footnotes («الهامش»), in full under the text: one ruled heading each */
.src-notes { margin-top: 1.4rem; border-top: 1px solid var(--gold); padding-top: 0.55rem; }
.src-notes + .src-notes { margin-top: 1.1rem; }
.src-notes-head { margin: 0 0 0.35rem; font-size: 0.95rem; font-weight: 700; color: var(--gold-deep); font-family: var(--ui, inherit); }
.src-notes-list { list-style: none; margin: 0; padding: 0; }
.src-notes-page { margin: 0.6rem 0 0.1rem; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.src-notes-page:first-of-type { margin-top: 0.1rem; }
.src-notes-page a { color: inherit; }
.note + .note { border-top: 1px dashed var(--line); padding-top: 0.4rem; margin-top: 0.4rem; }
.hd-notes { margin-top: 0.4rem; }
.note .text { font-size: calc(var(--read-size) * 0.88); line-height: calc(var(--read-lh) * 0.92); }
.edge { text-align: center; color: var(--muted); font-size: 0.9rem; }
.unit-pager { margin: 1.4rem 0 0.5rem; }
.pg-btn {
  flex: 1; display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 14px; max-width: 48%;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); text-decoration: none;
}
.pg-btn.next { justify-content: flex-end; text-align: end; }
.pg-btn:hover { border-color: var(--gold); }
.pg-btn > span { display: flex; flex-direction: column; min-width: 0; }
.pg-k { font-size: 0.78rem; color: var(--muted); }
.pg-l { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-btn.disabled { color: var(--muted); justify-content: center; font-size: 0.9rem; background: none; border-style: dashed; }
.goto-box { margin-top: 1rem; border-top: 1px solid var(--line-2); padding-top: 0.5rem; font-size: 0.92rem; }
.goto-box > summary { cursor: pointer; color: var(--ink-2); }
.goto { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin: 0.6rem 0; }
.goto input { width: 7rem; padding: 0.3rem 0.6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
.goto-msg { font-size: 0.9rem; min-height: 1.2em; }

/* the app's floating reading controls */
.reader-controls {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 25;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  width: calc(100% - 32px); max-width: 448px; height: 54px;
  display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); color: var(--ink);
}
.rc-btn { flex: 1 1 0; min-width: 0; height: 100%; display: grid; place-items: center; border: 0; background: none; cursor: pointer; color: inherit; font-size: 1.1rem; }
.rc-btn:disabled { opacity: 0.35; cursor: default; }
.rc-btn[aria-pressed="true"] { color: var(--gold-deep); }
:root[data-theme="dark"] .rc-btn[aria-pressed="true"] { color: var(--gold); }
.rc-a { font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
.rc-a.small { font-size: 0.9rem; }
.rc-sep { flex: none; width: 1px; height: 26px; background: var(--line); }
/* focus mode (js/views/reader.js FOCUS_CLASS): the toggle on every width; «إظهار اللوحات» only while focused */
.rc-restore { display: none; }
.rc-restore {
  flex: none; align-items: center; gap: 6px; height: 40px; margin-inline: 6px; padding: 0 14px; white-space: nowrap;
  border: 1px solid var(--gold); border-radius: 12px; background: var(--paper); color: var(--ink); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
.rc-restore:hover { background: var(--line-2); }

/* side panel: contents + «ملاحظاتي» (drawer on phones, column on wide screens) */
.reader-panel {
  display: none; position: fixed; z-index: 45; inset: 0 0 0 auto; width: min(24rem, 100%);
  background: var(--paper); border-inline-end: 1px solid var(--line); overflow: auto;
  padding: 10px 14px calc(var(--tabbar-h) + var(--safe-b) + 16px); box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
}
.reader.panel-open .reader-panel { display: block; }
.panel-head { position: sticky; top: -10px; z-index: 1; display: flex; align-items: center; gap: 8px; background: var(--paper); padding: 6px 0 10px; }
.panel-head .seg { flex: 1; box-shadow: none; border: 1px solid var(--line); }
.panel-list { list-style: none; margin: 0; padding: 0; }
.pl-item { border-bottom: 1px solid var(--line-2); border-inline-start: 4px solid var(--label-general); padding-inline-start: 8px; margin-bottom: 6px; }
.pl-item.lab-study { border-inline-start-color: var(--label-study); }
.pl-item.lab-reflection { border-inline-start-color: var(--label-reflection); }
.pl-item.lab-action { border-inline-start-color: var(--label-action); }
.pl-item a { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; color: var(--ink); text-decoration: none; }
.pl-kind { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--gold-deep); font-weight: 600; }
.pl-body { white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pl-quote { font-family: var(--arabic); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* user highlights in the colour of their label; notes underlined */
.hl { border-radius: 2px; padding: 0.04em 0; cursor: pointer; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hl-mark { background: var(--hl-general); }
.hl-general { background: var(--hl-general); }
.hl-study { background: var(--hl-study); }
.hl-reflection { background: var(--hl-reflection); }
.hl-action { background: var(--hl-action); }
.hl-note { text-decoration: underline dotted var(--gold-deep); text-decoration-thickness: 2px; text-underline-offset: 0.35em; }
.hl mark { background: var(--mark); }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 50% { outline: 3px solid var(--gold); outline-offset: 2px; } }

.my-notes { margin-top: 0.75rem; border: 1px solid var(--line); border-inline-start: 4px solid var(--gold); border-radius: 12px; padding: 0.55rem 0.9rem; background: var(--card); font-size: 0.95rem; }
.my-note + .my-note, .my-note + .my-hls { border-top: 1px dashed var(--line); margin-top: 0.5rem; padding-top: 0.5rem; }
.mine-badge { display: inline-block; font-size: 0.76rem; font-weight: 700; color: #fff; background: var(--green); border-radius: 999px; padding: 0 0.6rem; }
.my-note-head { margin: 0 0 0.25rem; }
.my-note-body { white-space: pre-wrap; margin: 0.25rem 0; unicode-bidi: plaintext; }
.my-hls summary { cursor: pointer; color: var(--ink-2); }
.my-hls ul { list-style: none; padding: 0; margin: 0.25rem 0; }
.my-hls li { padding: 0.35rem 0; border-top: 1px dashed var(--line); }
.quote-text { font-family: var(--arabic); line-height: 1.9; margin: 0.25rem 0; padding-inline-start: 0.75rem; border-inline-start: 3px solid var(--gold); unicode-bidi: plaintext; white-space: pre-wrap; }
span.quote-text { display: block; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.35rem 0 0; }
.flag { font-size: 0.88rem; color: var(--ink); background: var(--bg); border: 1px dashed var(--muted); border-radius: 8px; padding: 0.35rem 0.6rem; margin: 0.35rem 0; }
.muted-flag { color: var(--ink-2); }
.relink-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 10px 16px 0; }
.reader-status { min-height: 0; }

/* the app's dark-green selection pill */
.sel-toolbar {
  position: fixed; z-index: 40; left: var(--tb-x, 50%); top: var(--tb-y, auto);
  transform: translate(-50%, -100%);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; width: max-content; max-width: calc(100vw - 24px);
  background: var(--green-900); color: #fff; border-radius: 999px; padding: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); font-size: 0.95rem;
}
.sel-toolbar.below { transform: translate(-50%, 0); }
/* Docked (touch selections, js/personal/reader-ui.js placeTb): never beside the selected words, where the
   phone's own Copy / Select all menu opens; just above the reading controls and the safe-area inset, or
   below the reader's header (.dock-top) when the selection reaches down into that band. --dock-b follows
   focus mode, where the controls sit lower. */
.sel-toolbar.docked { top: auto; bottom: var(--dock-b, calc(var(--tabbar-h) + var(--safe-b) + 76px)); transform: translateX(-50%); left: 50%; }
.sel-toolbar.docked.dock-top { top: var(--dock-t, calc(env(safe-area-inset-top, 0px) + 64px)); bottom: auto; }
.sel-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 13px; border: 0; background: none; color: #fff; cursor: pointer; white-space: nowrap; }
@media (max-width: 400px) { .sel-btn { padding: 0 9px; gap: 4px; font-size: 0.9rem; } }
.sel-btn + .sel-btn { border-inline-start: 1px solid rgba(255, 255, 255, 0.25); }
.sel-btn:focus-visible { outline-color: var(--gold-soft); }
.sel-toolbar .tb-msg { font-size: 0.88rem; padding: 4px 12px; max-width: 22rem; white-space: normal; border-radius: 16px; }
.sel-toolbar .tb-msg:empty { display: none; }

/* ---------------------------------------------------------------- dialogs & bottom sheets */
.pdialog {
  border: 1px solid var(--line); border-radius: 18px; background: var(--paper); color: var(--ink);
  padding: 0; width: min(36rem, calc(100% - 2rem)); max-height: calc(100% - 2rem);
}
.pdialog::backdrop { background: rgba(15, 25, 20, 0.38); }
.pdialog.sheet {
  margin: auto auto 0; width: 100%; max-width: 480px; max-height: 86vh; border-radius: 20px 20px 0 0; border-bottom: 0;
  animation: up 0.16s ease-out;
}
@keyframes up { from { transform: translateY(24px); } }
.pdialog-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.pdialog .sheet-body { margin: 0; max-width: none; border-radius: 0; padding: 8px 18px calc(18px + var(--safe-b)); background: transparent; display: flex; flex-direction: column; gap: 8px; }
.sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 6px; }
.sheet-title, .pdialog-body h2 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 4px; }
.sheet-list { list-style: none; margin: 0; padding: 0; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 4px;
  border: 0; border-bottom: 1px solid var(--line-2); background: none; font-size: 1rem; text-align: start; cursor: pointer; color: var(--ink);
}
.sheet-item.current { color: var(--green); font-weight: 700; }
:root[data-theme="dark"] .sheet-item.current { color: var(--gold); }
.sheet-item.danger { color: var(--danger); }
.sheet-item .icon { color: var(--gold-deep); }
.sheet-cancel { margin-top: 6px; }
.pdialog-body textarea, .pdialog input[type="text"] {
  width: 100%; line-height: 1.8; padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); resize: vertical;
}
.pdialog select, .my select { padding: 0.25rem 0.4rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); max-width: 100%; }
.pdialog-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.quote { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: center; }
.save-state { min-height: 1.2em; font-size: 0.92rem; color: var(--green-700); margin: 0.25rem 0; }
:root[data-theme="dark"] .save-state { color: var(--gold); }

.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -20px);
  background: var(--green-950); color: #fff; font-size: 0.92rem; padding: 9px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; z-index: 95; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

/* ---------------------------------------------------------------- my library */
.library .green-head { padding-bottom: 46px; }
.lib-tabs { max-width: 36rem; }
.lib-tabs .seg-btn { font-size: 0.9rem; }
.privacy-note { font-size: 0.9rem; color: var(--ink-2); margin-bottom: 10px; }
.privacy-note > summary { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; color: var(--green-700); }
:root[data-theme="dark"] .privacy-note > summary { color: var(--gold); }
.side-h { font-size: 0.85rem; color: var(--muted); font-weight: 600; margin: 10px 0 6px; }
.label-chips { flex-wrap: wrap; margin: 0; padding: 0; }
.label-chips .chip { height: 34px; padding: 0 12px; }
.label-chips .chip.on { background: #f6ead0; color: var(--ink); border-color: var(--gold); }
:root[data-theme="dark"] .label-chips .chip.on { background: #3a3020; color: var(--ink); }
.folders-box { margin-top: 14px; }
.folders-box .sec-head { margin-bottom: 4px; }
.folders-box h2 { font-size: 1.1rem; }
.folder-list { list-style: none; padding: 0; margin: 0; }
.folder-list li { display: flex; align-items: center; border-bottom: 1px solid var(--line-2); }
.folder-chip { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 6px; border: 0; background: none; cursor: pointer; color: var(--ink); text-align: start; border-radius: 10px; }
.folder-chip .icon { color: var(--gold); }
.folder-chip.on { background: #f6ead0; }
:root[data-theme="dark"] .folder-chip.on { background: #3a3020; }
.fc-name { flex: 1; font-family: var(--serif); font-weight: 700; }
.fc-n { font-size: 0.85rem; color: var(--muted); }
.lib-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.lib-tools .searchbox { flex: 1 1 14rem; }
.filter-book { max-width: 100%; overflow: hidden; }
.filter-book.on { background: var(--tag-green-bg); color: var(--tag-green-fg); border-color: transparent; }
.li-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.li-card {
  position: relative; display: flex; align-items: flex-start; gap: 10px; background: var(--card);
  border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 12px 12px 4px; box-shadow: 0 1px 2px rgba(60, 45, 15, 0.04);
}
.li-bar { flex: 0 0 7px; align-self: stretch; border-radius: 4px; background: var(--label-general); }
.li-card.lab-study .li-bar { background: var(--label-study); }
.li-card.lab-reflection .li-bar { background: var(--label-reflection); }
.li-card.lab-action .li-bar { background: var(--label-action); }
.li-body { flex: 1; min-width: 0; }
.li-link { display: flex; gap: 10px; color: var(--ink); text-decoration: none; }
.li-link .quote-text { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
a.li-link { flex-direction: column; }
a.li-link.bm-link, .prog-item .li-link { flex-direction: row; align-items: center; }
.li-text { display: flex; flex-direction: column; min-width: 0; }
.li-title { font-family: var(--serif); font-weight: 700; font-size: 1.02rem; }
.li-loc { font-size: 0.82rem; color: var(--gold-deep); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
:root[data-theme="dark"] .li-loc { color: var(--gold); }
.li-loc a { color: inherit; }
.li-note { font-size: 0.85rem; color: var(--green-700); display: flex; align-items: center; gap: 4px; }
.li-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--ink-2); margin: 6px 0 0; }
.lab-chip { display: inline-flex; align-items: center; gap: 5px; }
.folder-tag { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); }
.li-more { color: var(--ink-2); }
.lib-progress { margin-bottom: 18px; }
.lib-progress h2 { font-size: 1.1rem; }
.prog-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.prog-item { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line-2); padding: 4px 0; }
.prog-item .li-link { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- profile */
.pref-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; min-height: 48px; }
.pref-label { font-weight: 600; }
.pref-row .seg { box-shadow: none; border: 1px solid var(--line); }
.pref-sample { font-family: var(--arabic); font-size: var(--read-size); line-height: var(--read-lh); background: var(--paper); border-radius: 10px; padding: 8px 12px; border: 1px solid var(--line-2); }
.stepper { display: flex; align-items: center; gap: 10px; }
.step-btn { width: 44px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); cursor: pointer; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; }
.step-btn:disabled { opacity: 0.4; cursor: default; }
.step-val { min-width: 3.5rem; text-align: center; color: var(--ink-2); }
.data-counts { font-weight: 600; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.danger-zone { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 6px; }
.danger-zone h3 { color: var(--danger); }
.app-import ul { margin: 0.3rem 0 0; padding-inline-start: 1.2rem; }
.preview-table { border-collapse: collapse; margin: 0.75rem 0; font-size: 0.92rem; width: 100%; }
.preview-table caption { text-align: start; font-weight: 600; margin-bottom: 0.3rem; }
.preview-table th, .preview-table td { border: 1px solid var(--line); padding: 0.25rem 0.4rem; text-align: start; overflow-wrap: normal; }
.choice { border: 1px solid var(--line); border-radius: 10px; margin: 0.5rem 0; display: flex; flex-direction: column; gap: 0.2rem; }
.radio { display: inline-flex; gap: 0.3rem; align-items: center; }
.about-brand { display: flex; align-items: center; gap: 10px; color: var(--gold); }
.about-logo { display: block; }
.about-name { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; color: var(--ink); }


/* ---------------------------------------------------------------- reference material (/ref) */
.ref-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 10px 0 0; }
.ref-links > a { display: inline-flex; align-items: center; min-height: 40px; }
.lang-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.lang-links .chip { height: 40px; }
.tree-card { align-items: flex-start; }
.tree-card .cat-name { text-decoration: none; display: inline-flex; align-items: center; min-height: 40px; }
.src-card .searchbox.small { margin: 10px 0 4px; }
.ref-list { list-style: none; margin: 0; padding: 0; }
.ref-list > li { border-bottom: 1px solid var(--line-2); }
.ref-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; min-height: 48px; padding: 10px 2px; color: var(--ink); text-decoration: none; }
.ref-row:hover .ref-row-t { color: var(--green-700); text-decoration: underline; }
.ref-row-t { font-family: var(--serif); font-size: 1.05rem; flex: 1 1 14rem; min-width: 0; unicode-bidi: isolate; }
.ref-row-m { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 0.85rem; }
.q-text[lang="en"] { text-align: left; }
.q-texts { display: grid; gap: 10px; margin: 4px 0 8px; }
.q-texts .q-text { margin: 0; padding: 10px 14px; background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; line-height: 1.9; font-family: var(--serif); }
.q-texts .q-ar { font-size: 1.15rem; }
.ref-pager { margin: 18px 0 6px; }
.ref-pager .btn { min-height: 40px; }

.cite-list { list-style: none; margin: 0; padding: 0; }
.cite-row { border: 1px solid var(--line-2); background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.cite-row.cite-unresolved { border-style: dashed; }
.cite-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.cite-book { font-family: var(--serif); font-weight: 700; font-size: 1.02rem; min-width: 0; }
.cite-where { color: var(--gold-deep); font-size: 0.88rem; font-weight: 600; }
:root[data-theme="dark"] .cite-where { color: var(--gold); }
.cite-reason { color: var(--ink-2); font-size: 0.9rem; margin: 6px 0 0; }
.cite-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cite-actions .btn.small, .ex-res .btn.small { min-height: 40px; }
.orig { margin-top: 6px; font-size: 0.85rem; }
.orig > summary { cursor: pointer; color: var(--ink-2); padding-block: 8px; }
.orig-dl { font-size: 0.85rem; margin: 4px 0 0; }
.orig-dl dd { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.tree-box { margin-top: 6px; }
.tree { list-style: none; margin: 0; padding-inline-start: 18px; }
.tree-root { padding-inline-start: 0; }
.tree li { margin: 2px 0; }
.tree summary { cursor: pointer; display: list-item; padding: 8px 0; font-weight: 600; }
.tree summary > .tree-target, .tree summary > .tree-raw { margin-inline-start: 8px; }
.tree summary::marker { color: var(--gold-deep); }
.tree details[open] > summary { color: var(--green-900); }
:root[data-theme="dark"] .tree details[open] > summary { color: var(--ink); }
.tree-leaf { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 40px; padding: 2px 0; }
.tree-link { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 40px; text-decoration: none; }
.tree-link:hover .tree-text { text-decoration: underline; }
.tree-text { unicode-bidi: isolate; }
.tree-plain .tree-text { color: var(--ink-2); }
.tree-target { font-size: 0.78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; white-space: nowrap; }
.tree-raw { font-size: 0.75rem; color: var(--muted); background: var(--tag-plain-bg); border-radius: 4px; padding: 0 4px; unicode-bidi: isolate; overflow-wrap: anywhere; }

.surah-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 8px; }
.surah-card { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; min-height: 56px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); color: var(--ink); text-decoration: none; }
.surah-card:hover { border-color: var(--gold); }
.surah-n { grid-row: span 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--tag-green-bg); color: var(--green); font-size: 0.85rem; font-weight: 700; }
.surah-name { font-family: var(--serif); font-weight: 700; }
.surah-meta { font-size: 0.8rem; color: var(--muted); }
.verse-list { list-style: none; margin: 0; padding: 0; }
.verse { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.verse-n { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--gold); color: var(--gold-deep); font-size: 0.8rem; font-weight: 700; }
.verse-text { margin: 0; font-family: var(--arabic); font-size: 1.3rem; line-height: 2.1; }
.verse-go, .verse > .quiet { grid-column: 2; display: inline-flex; align-items: center; gap: 4px; min-height: 40px; font-size: 0.88rem; width: fit-content; }

.pack-counts { list-style: none; margin: 4px 0 8px; padding: 0; }
.pack-counts li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.pc-n { font-variant-numeric: tabular-nums; }

/* thematic excerpts: the verbatim source and its resolution */
.ex-src { margin-top: 0.75rem; padding: 8px 12px; border: 1px solid var(--line); border-inline-start: 4px solid var(--gold); border-radius: 10px; background: var(--card); font-size: 0.92rem; }
.ex-src-label { margin: 0; }
.ex-k { color: var(--muted); }
.ex-src-label bdi { font-family: var(--serif); }
.ex-src-res { margin: 6px 0 0; }
.ex-res { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ex-list { list-style: none; margin: 0; padding: 0; }
.ex-item { padding: 8px 0; border-bottom: 1px solid var(--line-2); content-visibility: auto; contain-intrinsic-size: auto 7rem; }
.ex-item .ex-src-label { font-size: 0.95rem; }
.ex-n { display: inline-flex; align-items: center; min-height: 40px; font-weight: 600; }
.ex-sources { margin-bottom: 1.2rem; }
.ex-sources h2 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 4px; }

/* reader: the cited source range (r=), distinct from search marks and personal highlights */
.cite-mark {
  background: color-mix(in srgb, var(--green-700) 13%, transparent);
  box-shadow: inset 0 -2px 0 var(--green-700);
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
:root[data-theme="dark"] .cite-mark { background: color-mix(in srgb, var(--gold) 16%, transparent); box-shadow: inset 0 -2px 0 var(--gold); }
.cite-point { display: inline-block; width: 0; height: 1.2em; vertical-align: middle; border-inline-start: 3px solid var(--green-700); margin-inline: 2px; }
:root[data-theme="dark"] .cite-point { border-color: var(--gold); }
.cite-note { margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--line); border-inline-start: 4px solid var(--green-700); border-radius: 10px; background: var(--card); font-size: 0.9rem; }
.cite-note p { margin: 4px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.cite-note .btn.small { min-height: 40px; }
.cite-note-k { font-weight: 600; color: var(--green-900); }
:root[data-theme="dark"] .cite-note-k { color: var(--gold); }
.quiet-link { color: var(--ink-2); display: inline-flex; align-items: center; min-height: 40px; }
.rail-ref { display: none; }

/* touch screens and phones: tap targets of at least 40px */
@media (pointer: coarse), (max-width: 40rem) {
  .btn.small, .seg.seg-small .seg-btn { min-height: 40px; }
  .goto-box > summary, .book-meta > summary, .volumes-nav summary, .help-box > summary, .dups summary { padding-block: 8px; }
  .sb-clear { width: 40px; height: 40px; }
  .sb-go { height: 40px; }
}

/* ---------------------------------------------------------------- tablet+ */
@media (min-width: 40rem) {
  .cat-grid { grid-template-columns: 1fr 1fr; }
  .green-head { padding: 30px 24px 44px; }
  .sheet-body { padding: 24px 24px 20px; }
  .chips, .shelf { margin: 0 -24px; padding-inline: 24px; }
  .hero h1 { font-size: 2.6rem; }
  .cover-row { width: 90px; height: 128px; }
  .book-hero h1 { font-size: 1.9rem; }
  .cover-hero { width: 150px; height: 228px; }
  .reader-body { padding-inline: 28px; }
  .chapter-title { font-size: 1.9rem; }
}

/* ---------------------------------------------------------------- desktop: side navigation rail */
@media (min-width: 1024px) {
  .tabbar {
    inset: 0 0 0 auto; width: var(--rail-w); height: auto; padding: 18px 12px;
    display: flex; flex-direction: column; gap: 4px;
    border-top: 0; border-inline-end: 1px solid var(--line);
  }
  .rail-brand {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 8px 18px; margin-bottom: 8px;
    border-bottom: 1px solid var(--line); color: var(--green); text-decoration: none; text-align: center;
  }
  .rail-brand .rail-rosette { color: var(--gold); }
  .rail-name { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--ink); }
  .tab, .tab-search {
    display: flex; flex-direction: row; justify-content: flex-start; gap: 12px; height: 48px; padding: 0 14px;
    border-radius: 12px; font-size: 1rem;
  }
  .tab:hover { background: var(--line-2); }
  .tab.on { background: var(--tag-green-bg); }
  .tabbar[data-active="search"] .tab[data-tab="home"] { color: #6b6f68; font-weight: 400; }
  :root[data-theme="dark"] .tabbar[data-active="search"] .tab[data-tab="home"] { color: #9aa39d; }
  .rail-about { display: block; margin-top: auto; padding: 10px 14px; font-size: 0.9rem; color: var(--ink-2); }
  .rail-ref { display: flex; align-items: center; height: 44px; padding: 0 14px; margin-top: 8px; border-top: 1px solid var(--line); font-size: 0.95rem; color: var(--ink-2); text-decoration: none; border-radius: 12px; }
  .rail-ref:hover { background: var(--line-2); }
  .rail-ref.on { color: var(--green); font-weight: 650; background: var(--tag-green-bg); }
  :root[data-theme="dark"] .rail-ref.on { color: var(--gold); background: var(--line-2); }
  .main { margin-inline-start: var(--rail-w); padding-bottom: 32px; }
  .toast { left: calc((100% - var(--rail-w)) / 2); }

  .green-head { padding: 34px 40px 52px; }
  .hero { padding: 54px 40px 66px; }
  .sheet-body { max-width: 76rem; margin-inline: auto; padding: 28px 40px 24px; }
  .chips, .shelf { margin: 0; padding-inline: 0; }
  .chips:not(.home-chips) { flex-wrap: wrap; overflow: visible; }
  /* Home «الأقسام»: one RTL row that scrolls inside the page (views/home.js chipsRow) */
  .chips-row { position: relative; min-width: 0; }
  .home-chips {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scroll-padding-inline: 48px;
    scrollbar-width: thin; scrollbar-color: var(--line) transparent; padding: 2px 2px 10px;
  }
  .home-chips::-webkit-scrollbar { display: block; height: 6px; }
  .home-chips::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
  .chips-row.more-start .home-chips { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 56px); mask-image: linear-gradient(to left, transparent 0, #000 56px); }
  .chips-row.more-end .home-chips { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 56px); mask-image: linear-gradient(to right, transparent 0, #000 56px); }
  .chips-row.more-start.more-end .home-chips {
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 56px, #000 calc(100% - 56px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 56px, #000 calc(100% - 56px), transparent 100%);
  }
  .chips-btn {
    position: absolute; top: 2px; z-index: 2; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
    border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--ink-2); cursor: pointer;
    box-shadow: 0 1px 4px rgba(60, 45, 15, 0.12);
  }
  .chips-btn:hover { border-color: var(--gold); color: var(--ink); }
  .chips-btn[hidden] { display: none; }
  .chips-btn-start { right: 0; }
  .chips-btn-end { left: 0; }
  /* multi-column shelves */
  .shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 22px 18px; overflow: visible; }
  .book-card { width: auto; }
  .book-card .cover-card { width: 100%; height: auto; aspect-ratio: 96 / 148; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .work-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; }

  .book-grid { display: grid; grid-template-columns: minmax(0, 26rem) minmax(0, 1fr); gap: 40px; align-items: start; }
  .book-side { position: sticky; top: 16px; }
  .book-main { margin-top: 0; }

  .search-page .sheet-body { max-width: 60rem; }
  .lib-grid { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 32px; align-items: start; }
  .lib-side { position: sticky; top: 16px; }
  .profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
  .profile-grid .about-card { grid-column: 1 / -1; }
  .pdialog.sheet { margin: auto; border-radius: 20px; border-bottom: 1px solid var(--line); }

  .reader-controls { bottom: 18px; left: calc((100% - var(--rail-w)) / 2); }
  .sel-toolbar.docked { bottom: var(--dock-b, 90px); }
  .reader-body { padding-bottom: 110px; }
}

/* reader: desktop columns — see «reader layout and scoped search» below */

/* ================================================================ reader layout and scoped search
   Reader (js/views/reader.js, readerbook.js): physical order from the LEFT viewport edge on desktop
   (>= 1280px = scope.js READER_DESKTOP_MIN): book panel | contents/notes panel | text | rail (right).
   Below that both panels are drawers. Main search: book picker and specialized indexes (bookpicker.js). */
.reader { --rb-w: 17rem; --rp-w: 19rem; }
.reader-book {
  display: none; position: fixed; z-index: 45; inset: 0 auto 0 0; width: min(22rem, 92%);
  background: var(--paper); border-inline-start: 1px solid var(--line); overflow: auto; overscroll-behavior: contain;
  padding: 10px 16px calc(var(--tabbar-h) + var(--safe-b) + 16px); box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
}
.reader.info-open .reader-book { display: block; }
.reader-panel { overscroll-behavior: contain; }
.reader-scrim { display: none; }
.reader.panel-open .reader-scrim, .reader.info-open .reader-scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(0, 0, 0, 0.35); }
.bp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bp-kicker { margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--gold-deep); }
.bp-title { font-family: var(--serif); font-size: 1.3rem; line-height: 1.4; margin: 4px 0 6px; }
.bp-title a { color: var(--ink); text-decoration: none; }
.bp-title a:hover { color: var(--green-700); }
.bp-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 8px; font-size: 0.9rem; }
.bp-meta dt { color: var(--muted); }
.bp-meta dd { margin: 0; color: var(--ink-2); }
.bp-sec { border-top: 1px solid var(--line-2); padding: 10px 0 4px; }
.bp-h { display: block; font-size: 0.85rem; font-weight: 700; color: var(--ink-2); margin: 0 0 6px; }
.bp-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.bp-nav.two { grid-template-columns: 1fr 1fr; }
.bp-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-height: 40px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); text-decoration: none; font-size: 0.85rem; text-align: center;
}
.bp-btn:hover { border-color: var(--gold); }
.bp-btn.disabled { color: var(--muted); border-style: dashed; background: none; }
.bp-sub { font-size: 0.75rem; color: var(--muted); }
.bp-vols { margin-top: 8px; font-size: 0.9rem; }
.bp-vols > summary { cursor: pointer; color: var(--ink-2); min-height: 32px; }
.bp-vol-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px; max-height: 14rem; overflow: auto; }
/* The search form must fit the panel's content box at every width, font and zoom: a grid track
   sized by its content would grow to the <input>'s intrinsic (size=20) width plus the button and
   push «بحث» past the panel's padding — clipped at the panel edge, focus ring cut off (WebKit
   draws it outside the panel). minmax(0, 1fr) and a zero flex basis let the input absorb it. */
.bp-search { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.bp-q { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.bp-q > .btn { flex: none; white-space: nowrap; min-height: 40px; padding-inline: 1rem; }
.bp-input { flex: 1 1 0; width: 0; min-width: 0; min-height: 40px; padding: 0.3rem 0.7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font-size: 1rem; }
.bp-scope { border: 0; margin: 0; padding: 0; min-inline-size: 0; display: grid; gap: 2px; font-size: 0.9rem; }
.bp-scope legend { font-size: 0.8rem; color: var(--muted); padding: 0; }
.bp-radio { display: flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; }
.bp-results { list-style: none; margin: 4px 0 0; padding: 0; }
.bp-hit { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; border-bottom: 1px solid var(--line-2); color: var(--ink); text-decoration: none; }
.bp-hit:hover .bp-hit-sn { color: var(--green-700); }
.bp-hit-loc { font-size: 0.78rem; color: var(--gold-deep); font-weight: 600; }
.bp-hit-sn { font-family: var(--arabic); font-size: 0.95rem; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Focus mode below the desktop layout (phones, tablets, the 1024px rail): the navigation (bottom tab bar
   or rail), the reader's header with its panel buttons and the drawers are display:none, so the text
   gets the whole screen. The floating bar moves down to the safe-area inset and swaps the focus toggle
   for the obvious «إظهار اللوحات» button, which is always on screen. The page pager stays in the text,
   so pages can be turned while focused. Touch selection keeps working: the selection dock follows the bar. */
@media (max-width: 1279.98px) {
  body.reader-focus[data-shell="reader"] .tabbar,
  body.reader-focus[data-shell="reader"] .reader-head,
  body.reader-focus[data-shell="reader"] .reader-book,
  body.reader-focus[data-shell="reader"] .reader-panel,
  body.reader-focus[data-shell="reader"] .reader-scrim,
  body.reader-focus[data-shell="reader"] .books-side,
  body.reader-focus[data-shell="reader"] .rc-focus,
  body.reader-focus[data-shell="reader"] .rc-focus-sep { display: none; }
  body.reader-focus[data-shell="reader"] .main { margin-inline-start: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: calc(var(--safe-b) + 12px); }
  body.reader-focus[data-shell="reader"] .reader-controls { left: 50%; bottom: calc(var(--safe-b) + 12px); }
  body.reader-focus[data-shell="reader"] .reader-controls { width: max-content; max-width: calc(100vw - 32px); }
  body.reader-focus[data-shell="reader"] .rc-btn { flex: 0 0 auto; width: 56px; }
  body.reader-focus[data-shell="reader"] .rc-restore { display: inline-flex; }
  body.reader-focus[data-shell="reader"] .toast { left: 50%; }
  body.reader-focus[data-shell="reader"] { --dock-b: calc(var(--safe-b) + 76px); }
}
/* Narrow phones: the bar's buttons keep their touch size; «إظهار اللوحات» sits just above the bar's
   start edge instead of squeezing them, and the selection dock goes above it. */
@media (max-width: 599.98px) {
  body.reader-focus[data-shell="reader"] .rc-restore {
    position: absolute; bottom: calc(100% + 8px); inset-inline-start: 0; margin: 0; box-shadow: var(--shadow);
  }
  body.reader-focus[data-shell="reader"] .reader-controls { width: calc(100% - 32px); max-width: 448px; }
  body.reader-focus[data-shell="reader"] .rc-btn { flex: 1 1 0; width: auto; }
  body.reader-focus[data-shell="reader"] { --dock-b: calc(var(--safe-b) + 124px); }
}

@media (min-width: 1280px) {
  /* both panels: fixed full-height columns against the left edge, each with its own scroll */
  .reader { padding-left: calc(var(--rb-w) + var(--rp-w)); }
  .reader-book, .reader-panel {
    display: block; position: fixed; top: 0; bottom: 0; z-index: 30; overflow: auto; box-shadow: none; border-radius: 0; margin: 0; max-height: none;
    padding: 14px 16px 24px; border: 0; border-right: 1px solid var(--line);
  }
  .reader-book { left: 0; right: auto; width: var(--rb-w); background: var(--paper); }
  .reader-panel { left: var(--rb-w); right: auto; width: var(--rp-w); background: var(--card); border-right: 2px solid var(--line); }
  .panel-head { background: var(--card); top: -14px; }
  .reader-scrim, .reader.panel-open .reader-scrim, .reader.info-open .reader-scrim { display: none; }
  .panel-close, .contents-btn, .info-btn { display: none; }
  .reader-grid { display: block; }
  .reader-controls { left: calc(var(--rb-w) + var(--rp-w) + (100% - var(--rail-w) - var(--rb-w) - var(--rp-w)) / 2); max-width: 512px; }

  /* focus mode (js/views/reader.js FOCUS_CLASS): the navigation rail, the contents/notes panel and the
     book panel are display:none (out of the tab order too), the text is centred in the whole width at
     its usual measure, the controls bar is centred and shows «إظهار اللوحات». Only in the reading layout
     (body[data-shell="reader"]: the book reader and the Qur'an reading views, router.js readingShell). */
  body.reader-focus[data-shell="reader"] .tabbar,
  body.reader-focus[data-shell="reader"] .reader-book,
  body.reader-focus[data-shell="reader"] .reader-panel { display: none; }
  body.reader-focus[data-shell="reader"] .main { margin-inline-start: 0; }
  body.reader-focus[data-shell="reader"] .reader { padding-left: 0; }
  body.reader-focus[data-shell="reader"] .reader-controls { left: 50%; width: max-content; max-width: calc(100vw - 32px); }
  body.reader-focus[data-shell="reader"] .rc-btn { flex: 0 0 auto; width: 64px; } /* a width, not only a flex basis: WebKit sizes max-content from widths */
  body.reader-focus[data-shell="reader"] .rc-restore { display: inline-flex; }
  body.reader-focus[data-shell="reader"] .toast { left: 50%; }
}

/* main search: book picker (removable chips, title / author finder) */
.picker { margin: 4px 0 10px; }
.pick-sel { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.pick-h { margin: 0; font-size: inherit; }
.pick-sel-h { margin: 0; color: var(--ink-2); font-size: 0.9rem; }
.pick-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pick-chips:empty { display: none; }
.pick-chip { gap: 4px; max-width: 100%; }
.pick-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 20rem; }
.pick-chip .chip-x { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.pick-find { margin-top: 8px; }
.pick-find > summary { cursor: pointer; color: var(--green-700); font-weight: 600; min-height: 36px; }
.pick-q { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0 4px; }
.pick-input { flex: 1 1 14rem; min-width: 0; min-height: 40px; padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 1rem; }
.pick-results { list-style: none; margin: 0; padding: 0; max-height: 26rem; overflow: auto; }
.pick-results.nested { max-height: none; padding-inline-start: 12px; }
.pick-work, .pick-author { border-bottom: 1px solid var(--line-2); padding: 6px 0; }
.pick-work { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; }
.pick-w-t { font-family: var(--serif); font-weight: 700; min-width: 0; }
.pick-w-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pick-vols > summary { cursor: pointer; font-size: 0.85rem; color: var(--ink-2); }
.pick-vol-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; max-height: 10rem; overflow: auto; }
.pick-add { min-height: 32px; font-size: 0.85rem; }
.pick-a-h { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.pick-a-name { font-weight: 700; }
.idx-tabs { margin: 6px 0; }
.idx-out .ref-list { margin-top: 4px; }
@media print { .reader-book, .reader-scrim { display: none !important; } .reader { padding: 0 !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media print {
  .tabbar, .reader-head, .reader-controls, .reader-panel, .unit-pager, .goto-box, .sel-toolbar, .relink-bar, .toast, .bm-btn { display: none !important; }
  .main { margin: 0; padding: 0; }
  .hero, .green-head { background: none; color: #000; }
  body { background: #fff; color: #000; }
}


/* ===================================================================== site font
   Preference `readingFont` (js/prefs.js → <html data-read-font>, set before first paint by
   js/boot-theme.js, which also preloads the chosen face). The choice is the font of the WHOLE
   site — navigation, headings, cards, buttons, form fields, dialogs, covers, reader text,
   footnotes, commentary and notes — through the --sans / --arabic / --serif roles at the root.
   "Never chosen" (no attribute, first visit, after «إعادة ضبط التفضيلات») = Scheherazade New;
   `default` is the explicit «خطوط الجهاز» choice (the device stacks above).
   Amiri and Scheherazade New are served from this site (fonts/, SIL OFL 1.1, see fonts/OFL-*.txt)
   under their own family names. Arabic Typesetting is a Windows system font that cannot be
   redistributed: local() only; when it is missing Scheherazade New is used. */
@font-face { font-family: "SL Amiri"; font-style: normal; font-weight: 400; font-display: swap; src: local("Amiri"), local("Amiri-Regular"), url("../fonts/amiri-arabic-400.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "SL Amiri"; font-style: normal; font-weight: 400; font-display: swap; src: local("Amiri"), local("Amiri-Regular"), url("../fonts/amiri-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "SL Amiri"; font-style: normal; font-weight: 700; font-display: swap; src: local("Amiri Bold"), local("Amiri-Bold"), url("../fonts/amiri-arabic-700.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "SL Amiri"; font-style: normal; font-weight: 700; font-display: swap; src: local("Amiri Bold"), local("Amiri-Bold"), url("../fonts/amiri-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "SL Scheherazade New"; font-style: normal; font-weight: 400; font-display: swap; src: local("Scheherazade New"), local("ScheherazadeNew-Regular"), url("../fonts/scheherazade-new-arabic-400.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "SL Scheherazade New"; font-style: normal; font-weight: 400; font-display: swap; src: local("Scheherazade New"), local("ScheherazadeNew-Regular"), url("../fonts/scheherazade-new-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "SL Scheherazade New"; font-style: normal; font-weight: 700; font-display: swap; src: local("Scheherazade New Bold"), local("ScheherazadeNew-Bold"), url("../fonts/scheherazade-new-arabic-700.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "SL Scheherazade New"; font-style: normal; font-weight: 700; font-display: swap; src: local("Scheherazade New Bold"), local("ScheherazadeNew-Bold"), url("../fonts/scheherazade-new-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "SL Arabic Typesetting"; font-style: normal; font-weight: 400; src: local("Arabic Typesetting"), local("ArabicTypesetting"); size-adjust: 125%; }
@font-face { font-family: "SL Arabic Typesetting"; font-style: normal; font-weight: 700; src: local("Arabic Typesetting"), local("ArabicTypesetting"); size-adjust: 125%; }
:root:not([data-read-font]), :root[data-read-font="scheherazade"] { --site-font: "SL Scheherazade New", var(--system-arabic); }
:root[data-read-font="amiri"] { --site-font: "SL Amiri", var(--system-arabic); }
:root[data-read-font="typesetting"] { --site-font: "SL Arabic Typesetting", "SL Scheherazade New", var(--system-arabic); }
:root:not([data-read-font="default"]) { --sans: var(--site-font); --arabic: var(--site-font); }
:root { --read-font: var(--arabic); }
/* per-book override (book page «خط هذا الكتاب», preference `bookFonts`): that book's reader text,
   titles and notes draw in it; the interface keeps the site font */
.reader[data-book-font="scheherazade"] { --book-font: "SL Scheherazade New", var(--system-arabic); }
.reader[data-book-font="amiri"] { --book-font: "SL Amiri", var(--system-arabic); }
.reader[data-book-font="typesetting"] { --book-font: "SL Arabic Typesetting", "SL Scheherazade New", var(--system-arabic); }
.reader[data-book-font="default"] { --book-font: var(--system-arabic); }
.reader[data-book-font] { --arabic: var(--book-font); --serif: var(--book-font); --read-font: var(--book-font); }
/* reader text: body, footnotes, commentary and thematic excerpts all render as .text */
.text, .pref-sample { font-family: var(--read-font); }
/* Latin-script passages (English translations in /ref) keep the device's Latin face */
[lang="en"] { font-family: var(--system-sans); }
.font-choice { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.font-choice legend { padding: 0; margin-bottom: 6px; font-weight: 600; }
.font-opt { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 2px 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; }
.font-opt:has(input:checked) { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.font-opt input { margin-top: 0.35rem; accent-color: var(--green-700); }
.font-opt-name { font-weight: 600; }
.font-opt-sample { grid-column: 2; font-size: 1.35rem; line-height: 1.9; color: var(--ink); }
.font-opt-sample[data-font="default"] { font-family: var(--system-arabic); }
.font-opt-sample[data-font="typesetting"] { font-family: "SL Arabic Typesetting", var(--system-arabic); }
.font-opt-sample[data-font="scheherazade"] { font-family: "SL Scheherazade New", var(--system-arabic); }
.font-opt-sample[data-font="amiri"] { font-family: "SL Amiri", var(--system-arabic); }
.font-opt-status { grid-column: 2; font-size: 0.82rem; color: var(--muted); }
.font-opt-status:empty { display: none; }
/* book page «خط هذا الكتاب»: samples of the book's own title and first line */
.bf-sample { display: flex; flex-direction: column; font-size: 1.25rem; line-height: 1.9; }
.bf-s-title { font-weight: 700; }
.bf-s-line { font-size: 1.1rem; color: var(--ink-2); }
.bf-status { margin: 6px 0; font-size: 0.9rem; }
.bf-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.font-opt-status.missing { color: var(--danger); }

/* ===================================================================== help guide (/guide) */
.guide .card-body p { margin: 0.4rem 0; }
.guide-steps { margin: 0.4rem 0; padding-inline-start: 1.4rem; }
.guide-steps li { margin: 0.25rem 0; }
.guide-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0.6rem 0 0.2rem; padding: 0; list-style: none; }
.guide-links a { min-height: 40px; }
.guide-toc { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 0 0 4px; list-style: none; }
.guide-toc a { display: inline-flex; align-items: center; min-height: 40px; color: var(--link); }
.guide-ui { font-weight: 600; color: var(--ink); }
.rail-guide { display: none; }
@media (min-width: 1024px) {
  .rail-guide { display: block; margin-top: auto; padding: 10px 14px 0; font-size: 0.9rem; color: var(--ink-2); }
  .rail-guide.on { color: var(--green); font-weight: 650; }
  .rail-guide + .rail-about { margin-top: 0; }
}
.profile-guide { grid-column: 1 / -1; margin: 0; }

/* ===================================================================== books sidebar and book details menu */
/* «كتبي» (js/sidebar.js): docked against the LEFT edge at ≥1280px on every page except the
   reader (whose own two panels use that edge); elsewhere a drawer from the left, opened by the
   «كتبي» button of the navigation (5th phone tab / rail entry). Physical `left` as in the reader. */
:root { --bs-w: 16rem; }
.tabbar { grid-template-columns: repeat(5, 1fr); }
button.tab { border: 0; background: none; font: inherit; font-size: 12.5px; cursor: pointer; padding: 0; }
button.tab.on { color: var(--green); font-weight: 650; }
:root[data-theme="dark"] button.tab.on { color: var(--gold); }

.books-side {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(var(--bs-w), 86vw); z-index: 48;
  display: flex; flex-direction: column; background: var(--paper); border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.books-side[hidden] { display: none; }
.books-side.drawer { bottom: calc(var(--tabbar-h) + var(--safe-b)); width: min(20rem, 88vw); }
.bs-scrim { position: fixed; inset: 0; z-index: 47; background: rgba(0, 0, 0, 0.32); }
.bs-scrim[hidden] { display: none; }
.bs-head { display: flex; align-items: center; gap: 2px; padding: 12px 10px 8px 12px; border-bottom: 1px solid var(--line-2); }
.bs-heading { flex: 1; display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--serif); font-size: 1.12rem; color: var(--ink); }
.bs-heading .icon { color: var(--gold); }
.bs-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 8px 16px; }
.bs-search { padding: 4px 4px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.bs-input { width: 100%; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: inherit; }
.bs-input:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.bs-note { margin: 6px 4px; font-size: 0.85rem; }
.bs-sec { margin-top: 10px; }
.bs-sec-h { margin: 4px 6px 4px; font-size: 0.8rem; font-weight: 650; color: var(--muted); }
.bs-list { list-style: none; margin: 0; padding: 0; }
.bs-row { display: flex; align-items: center; gap: 2px; border-radius: 10px; }
.bs-row:hover, .bs-row:focus-within { background: var(--line-2); }
.bs-row.current { background: var(--tag-green-bg); }
.bs-link { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 7px 8px; color: var(--ink); text-decoration: none; border-radius: 10px; }
.bs-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-sub { font-size: 0.8rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-row .icon-btn { flex: 0 0 auto; color: var(--ink-2); }
.bs-row .bk-pin[aria-pressed="true"] { color: var(--green); }
:root[data-theme="dark"] .bs-row .bk-pin[aria-pressed="true"] { color: var(--gold); }
.bs-row:not(:hover):not(:focus-within):not(.current) .bk-pin[aria-pressed="false"] { opacity: 0.45; }
.bs-empty { margin: 14px 8px; font-size: 0.9rem; line-height: 1.7; }
.bs-collapse[hidden], .bs-close[hidden] { display: none; }

@media (min-width: 1024px) {
  .tabbar .tab-books { display: flex; flex-direction: row; justify-content: flex-start; gap: 12px; height: 48px; padding: 0 14px; border-radius: 12px; font-size: 1rem; color: #6b6f68; width: 100%; }
  :root[data-theme="dark"] .tabbar .tab-books { color: #9aa39d; }
  .tabbar .tab-books:hover { background: var(--line-2); }
  .tabbar .tab-books.on { background: var(--tag-green-bg); color: var(--green); }
  .books-side.drawer { bottom: 0; }
}
@media (min-width: 1280px) {
  body.bs-docked .books-side { z-index: 20; box-shadow: none; }
  body.bs-docked .main { margin-left: var(--bs-w); }
  body.bs-docked .toast { left: calc(var(--bs-w) + (100% - var(--rail-w) - var(--bs-w)) / 2); }
}

/* Per-book details menu (js/views/bookmenu.js): the button sits beside the row's link; the panel is one
   fixed element on <body> (rows use content-visibility and would clip it). */
.book-card { position: relative; }
.bc-link { display: flex; flex-direction: column; color: inherit; text-decoration: none; min-width: 0; }
.book-card:hover .bc-title { color: var(--green-700); }
/* the details button sits beside the card's last text line (author / volumes), never over the cover art */
.bc-more { position: absolute; bottom: -6px; left: -8px; width: 32px; height: 32px; min-width: 32px; color: var(--ink-2); }
.bc-link > span:last-child { padding-inline-end: 24px; }
.work { position: relative; display: flex; align-items: center; }
.work > a, .work > details { flex: 1; min-width: 0; }
.work.multi { align-items: flex-start; }
.work-more { flex: 0 0 auto; margin-top: 12px; color: var(--ink-2); }
.work.multi .work-more { margin-top: 18px; }
.book-hit .r-link { padding-inline-end: 44px; }
.bk-pop {
  position: fixed; z-index: 60; max-height: min(70vh, 32rem); overflow-y: auto;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 14px 14px;
}
.bk-pop.sheet { left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 18px 18px 0 0; padding-bottom: calc(14px + var(--safe-b)); max-height: 80vh; }
.bk-head { display: flex; align-items: flex-start; gap: 6px; }
.bk-title { flex: 1; margin: 6px 0 4px; font-family: var(--serif); font-size: 1.08rem; line-height: 1.5; }
.bk-title:focus { outline: none; }
.bk-meta { margin: 6px 0 8px; font-size: 0.9rem; }
.bk-status { margin: 4px 0 8px; }
.bk-note { font-size: 0.85rem; }
.bk-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.bk-actions .bk-pin { display: inline-flex; align-items: center; gap: 6px; }
.bk-actions .bk-pin[aria-pressed="true"] { border-color: var(--green); color: var(--green); }
:root[data-theme="dark"] .bk-actions .bk-pin[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }

@media print { .books-side, .bs-scrim, .bk-pop, .bk-more, .tab-books { display: none !important; } body.bs-docked .main { margin: 0 !important; } }

/* ================================================================ reader line menu (personal/reader-ui.js)
   A small «⋮» button in the margin at the start (right) of the source line under the pointer, tapped or
   reached with the keyboard; it opens the selection toolbar (.sel-toolbar) for that line. */
.reader-body { position: relative; }
@media (max-width: 39.99rem) { .reader-body { padding-inline-start: 26px; } }
.line-btn {
  position: absolute; z-index: 5; left: var(--lb-x, 0); top: var(--lb-y, 0);
  width: 24px; height: 32px; padding: 0; border: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--muted); cursor: pointer; opacity: 0.85;
}
.line-btn:hover, .line-btn[aria-expanded="true"] { color: var(--green-700); background: color-mix(in srgb, var(--green-700) 10%, transparent); opacity: 1; }
.line-btn:focus-visible { opacity: 1; outline-offset: 1px; }
@media print { .line-btn { display: none !important; } }

/* reader floating bar, continuous mode: «صفحة بصفحة» at the page being read (views/reader.js unitModeBtn) */
.rc-unitmode {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 40px; margin-inline: 6px 2px; padding: 0 11px; white-space: nowrap;
  border: 1px solid var(--gold); border-radius: 12px; background: var(--paper); color: var(--ink); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.rc-unitmode[hidden] { display: none; }
.rc-unitmode:hover { background: var(--line-2); }
@media (max-width: 400px) { .rc-unitmode { padding: 0 8px; font-size: 0.82rem; } .rc-unitmode svg { display: none; } }
@media print { .rc-unitmode { display: none !important; } }


/* ================================================================ «حديثًا حديثًا» (views/reader.js, D-024)
   Chapter context, one narration clearly separated as a card, and a compact source reference. */
.reader-mode-row { flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.reader-mode-row .seg-control { max-width: 100%; }
.hd-coverage { margin: 8px auto 0; max-width: 36rem; text-align: center; font-size: 0.85rem; color: var(--ink-2); }
.hd-coverage[data-kind="partial"], .hd-coverage[data-kind="in-progress"] {
  padding: 6px 12px; border: 1px solid var(--gold-soft, var(--line)); border-radius: 10px; background: var(--tag-tan-bg); color: var(--tag-tan-fg);
}
.hd-context { margin: 0.25rem 0 0.75rem; }
.hd-context ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; }
.hd-context li { font-family: var(--serif); font-weight: 700; color: var(--gold-deep); font-size: 1.02rem; text-align: center; }
.hd-context li + li::before { content: '›'; margin-inline-end: 8px; color: var(--muted); font-weight: 400; }
.hadith {
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 0.9rem 1.1rem 0.6rem;
  box-shadow: 0 1px 2px rgba(60, 45, 15, 0.05); scroll-margin-top: 80px;
}
.hd-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 0.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--line-2); }
.hd-num { display: inline-flex; align-items: center; height: 26px; padding: 0 12px; border-radius: 999px; background: var(--tag-green-bg); color: var(--tag-green-fg); font-weight: 700; font-size: 0.9rem; }
.hd-pos { font-size: 0.82rem; color: var(--muted); }
.hd-tag { font-size: 0.76rem; color: var(--gold-deep); border: 1px solid var(--line); border-radius: 999px; padding: 0 0.55rem; }
.hd-text { margin: 0.25rem 0 0.5rem; }
.hd-split .hd-isnad { color: var(--ink-2); font-size: 0.94em; }
.hd-split .hd-matn { color: var(--ink); }
.hd-foot { border-top: 1px dashed var(--line); padding-top: 0.45rem; }
.hd-source { margin: 0; font-size: 0.86rem; color: var(--ink-2); }
.hd-source-k { font-weight: 700; color: var(--ink-2); }
.hd-page { font-weight: 600; }
.hd-where { color: var(--gold-deep); }
.hd-missing { margin: 0.5rem 0; }
.quran-reader-link { white-space: nowrap; }
@media print { .hadith { box-shadow: none; } }

/* ================================================================ Qur'an reader (views/quran.js, D-024) */
.quran-reader { min-height: 100vh; }
.qr-body { max-width: 46rem; }
.qr-title { margin-bottom: 0.15rem; }
.qr-meta { text-align: center; color: var(--muted); font-size: 0.88rem; margin: 0 0 0.75rem; }
.qr-controls { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0 0 6px; }
.qr-surah-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; width: 100%; }
.qr-select {
  height: 38px; min-width: 0; max-width: 15rem; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 0.98rem;
}
.qr-nav { display: inline-flex; align-items: center; gap: 4px; }
.qr-nav.disabled { opacity: 0.45; pointer-events: none; }
.qr-nav-k { font-size: 0.8rem; color: var(--muted); }
.qr-nav-l { font-weight: 650; }
.qr-view-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 14px; }
.qr-jump { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.qr-jump-input { width: 4.5rem; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; text-align: center; }
.qr-jump .hint { color: var(--muted); font-size: 0.8rem; }
/* continuous: flowing text with small inline ayah markers */
.qr-flow { text-align: justify; text-align-last: right; line-height: calc(var(--read-lh) * 1.12); white-space: normal; }
.qr-v { scroll-margin-top: 90px; }
.qr-mark {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.6em; height: 1.6em; padding: 0 0.25em; margin: 0 0.1em;
  border: 1px solid var(--gold); border-radius: 999px; color: var(--gold-deep); font-family: var(--sans); font-size: 0.62em;
  line-height: 1; text-decoration: none; vertical-align: 0.25em;
}
.qr-mark:hover { background: var(--line-2); }
/* ayah by ayah */
.qr-list { list-style: none; margin: 0; padding: 0; }
.qr-ayah { display: flex; gap: 12px; align-items: flex-start; padding: 0.8rem 0.5rem; border-bottom: 1px solid var(--line-2); scroll-margin-top: 90px; border-radius: 10px; }
.qr-ayah[aria-current="location"] { background: color-mix(in srgb, var(--gold) 14%, transparent); box-shadow: inset -3px 0 0 var(--gold); }
.qr-num {
  flex: none; margin-top: 0.35em; display: inline-flex; align-items: center; justify-content: center; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  border: 1.5px solid var(--gold); color: var(--gold-deep); font-weight: 700; font-size: 0.9rem; text-decoration: none;
}
.qr-ayah[aria-current="location"] .qr-num { background: var(--gold); color: #fff; }
.qr-ayah-main { flex: 1; min-width: 0; }
.qr-ayah-text { margin: 0; white-space: normal; }
.qr-ayah-acts { display: flex; justify-content: flex-end; gap: 2px; margin-top: 2px; opacity: 0.7; }
.qr-ayah:hover .qr-ayah-acts, .qr-ayah:focus-within .qr-ayah-acts, .qr-ayah[aria-current="location"] .qr-ayah-acts { opacity: 1; }
.qr-ayah-acts .icon-btn { width: 30px; height: 30px; color: var(--muted); }
.qr-pager { margin-top: 1.5rem; }
.qr-notfound-links { display: flex; flex-wrap: wrap; gap: 8px; }
@media print { .qr-controls, .qr-pager, .qr-ayah-acts { display: none !important; } }
.qr-jump label, .qr-jump .btn, .qr-jump .hint { white-space: nowrap; }
.qr-jump label { font-weight: 650; }
.qr-jump-row { display: flex; align-items: flex-start; justify-content: center; flex-wrap: wrap; gap: 10px 22px; width: 100%; }
.qr-surah-jump { flex-wrap: wrap; justify-content: center; }
.qr-surah-input { width: 11rem; font-family: inherit; font-size: 0.95rem; }
.qr-surah-jump .hint { flex-basis: 100%; text-align: center; }
.qr-surah-list { columns: 2 16rem; column-gap: 1.5rem; }
.qr-surah-list li { break-inside: avoid; }
.qr-saved { margin-top: 0.5rem; }
.qr-saved .pl-item[aria-current="true"] { box-shadow: inset -3px 0 0 var(--gold); padding-inline-start: 8px; }
@media (max-width: 640px) {
  .qr-surah-jump { width: 100%; }
  .qr-surah-input { flex: 1 1 9rem; width: auto; min-width: 0; }
  .qr-surah-jump .qr-select { flex: 1 1 100%; max-width: none; }
}
.qr-controls .goto-msg:empty { display: none; }
/* Qur'an reading views in the reader's layout (D-027): the surahs panel heading sits where the book
   reader's contents tabs are; everything else is the reader's own .reader / .reader-book / .reader-panel. */
.qr-panel-h { flex: 1; margin: 0; }
.qr-panel-search .searchbox { height: 42px; gap: 6px; padding: 0 10px; box-shadow: none; border: 1px solid var(--line); background: var(--paper); }
.qr-panel-search .sb-go { margin-inline-end: -4px; height: 32px; padding: 0 12px; }
