/* app.css — Maktaba-e-Qamar's own CSS. Linked after qamar-common's tokens.css, fonts.css and qc/components.css, and
   before qc/common.css (shared header + footer). The shared look (base, buttons, pills, chips, callouts, segmented
   switch, page heads, crumbs, section headings, the book shelf card, the search box) comes from qamar-common and is
   never restyled here (vendor/qamar-common/MIGRATION-maktaba.md). What stays here is maktaba-only: the subnav bar,
   home hero + topic tiles, the work title page, search results + book picker, catalogue rows, the reader (scan,
   zoom, contents, loading notice) and the /t/ text pages. Open look questions ship option A (dars) until decided. */

/* ─── Site base ─── */
/* Type sizes are qamar-common's (dars's scale, 1.1.0): <main lang="ur"> = --fs-ur-ui / --lh-ur-ui (shared rule);
   Urdu labels --fs-ur-small, captions --fs-ur-caption, reading text --fs-ur-body; English --fs-small / --fs-caption.
   No literal px text sizes here. The Ask composer and the zoom view sit outside <main>: */
:where(.composer, .zoomview)[lang="ur"] { font-size: var(--fs-ur-ui); line-height: var(--lh-ur-ui); }
.wrap.wide { max-width: 1500px; }
.en, [lang="en"] { line-height: var(--lh-en); }
.en { font-size: var(--fs-small); }
.num { font-family: var(--font-en); font-size: .88em; font-variant-numeric: lining-nums; }
.sep { color: var(--muted); }
.muted { color: var(--muted); }
.t-ar { font-family: var(--font-ar); line-height: var(--lh-ar); }
.t-ur { font-family: var(--font-ur); }
.ico { width: 20px; height: 20px; flex: none; }
.saw { font-family: var(--font-ar); font-size: .85em; font-weight: 400; line-height: 1; }
mark { background: var(--highlight); color: inherit; border-radius: 3px; padding: 0 2px; }
/* maktaba's own form controls (zero specificity: the shared .searchbox / .btn always win) */
:where(button, input, select, textarea) { font: inherit; }
:where(button) { cursor: pointer; }
:where(button):disabled { opacity: .4; cursor: default; }
:where(input[type=number], input[type=text], select) { background: var(--bg-2); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 4px 12px; min-height: 44px; }
input[type=search]::placeholder { color: var(--fg-2); opacity: .75; }

/* a status line's English half on its own line (site content inside the shared .callout) */
.callout .en { display: block; }

/* ─── Maktaba bar (the shared header's {{subnav}}): brand at the right, Catalogue · Topics · Search · Ask, search ─── */
.mk-subnav { background: var(--bg-2); border-bottom: 1px solid var(--border); }
.mk-subnav-in { max-width: 1200px; margin: 0 auto; padding: 2px var(--gutter); display: flex; align-items: center; flex-wrap: wrap;
  gap: 2px var(--space-4); }
.mk-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent-2); text-decoration: none; flex: none; }
.mk-brand-ur { font-family: var(--font-ur); font-size: var(--fs-ur-lead); font-weight: 700; line-height: 2.1; }  /* Nastaliq needs the leading */
.mk-brand-en { font: var(--fs-caption)/1.3 var(--font-en); letter-spacing: .04em; color: var(--fg-2);
  border-inline-start: 1px solid var(--border); padding-inline-start: 10px; white-space: nowrap; }
.mk-sub { display: flex; flex-wrap: wrap; gap: 2px; }
.mk-sub-item { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: var(--radius-pill);
  color: var(--accent-2); border: 1px solid transparent; text-decoration: none; white-space: nowrap; }
.mk-sub-item .ur { font-size: var(--fs-ur-small); line-height: 2; }
.mk-sub-item .en { font: var(--fs-caption) var(--font-en); color: var(--fg-2); }
.mk-sub-item:hover { border-color: var(--accent); }
.mk-sub-item[aria-current="page"] { background: var(--accent); color: var(--on-accent); }
.mk-sub-item[aria-current="page"] .en { color: inherit; opacity: .85; }
.mk-subsearch { flex: 0 1 300px; margin: 0; margin-inline-start: auto; }
@media (max-width: 900px) { .mk-sub-item { padding: 0 8px; } .mk-sub-item .en { display: none; } }
@media (max-width: 720px) {
  .mk-subnav-in { gap: 0; padding: 2px 12px 4px; }
  .mk-subsearch { display: none; }
  .mk-sub { flex-basis: 100%; justify-content: space-between; gap: 4px; }
  .mk-sub-item { flex: 1 1 0; flex-direction: column; gap: 0; padding: 2px 2px 4px; min-height: 50px; border-radius: var(--radius-m); justify-content: center; }
  .mk-sub-item .ur { font-size: var(--fs-ur-caption); line-height: 1.9; }
  .mk-sub-item .en { display: block; font-size: var(--fs-xs); line-height: 1.1; }
}
@media (max-width: 340px) { .mk-brand-en { display: none; } }

/* the library's one-line description at the end of the shared footer ({{footer_extra}}) */

/* ─── Shared bits of maktaba pages ─── */
.shelf-book.quiet .shelf-text { opacity: .75; }  /* not reference books: dimmed, same card */
.back { text-align: center; margin: var(--space-6) 0 0; }
.searchbox .ico { width: 18px; height: 18px; }

/* ─── Home ─── */
.wrap:has(> .hero) { padding-top: var(--space-5); }
.hero { text-align: center; padding: 0 0 var(--space-3); max-width: 720px; margin: 0 auto; }
.hero h1 { margin: 0; font-weight: 400; }
.hero h1 .ur { display: block; font-size: var(--fs-ur-display); font-weight: 700; color: var(--accent-2); line-height: 2; }
.hero h1 .en { display: block; font-size: var(--fs-small); letter-spacing: .16em; text-transform: uppercase; color: var(--fg-2); margin-top: -4px; }
.lead { margin: var(--space-3) 0 var(--space-5); color: var(--fg-2); }  /* size: main[lang=ur] (17 px / 2) */
.hero-search { max-width: 680px; margin: 0 auto; }
.lead-en { margin: var(--space-3) auto 0; color: var(--fg-2); max-width: 560px; }  /* .en (14 px) */
.hero-cat { margin: var(--space-4) 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); }
/* a one-line link to /connect (book, search and Ask pages: build.ai_line) */
.ai-line { margin: var(--space-3) 0; text-align: center; }
.ai-line a { text-decoration: none; }
.ai-line a:hover { text-decoration: underline; }
@media (max-width: 600px) {
  .hero h1 .ur { font-size: var(--fs-ur-h1); }
  .lead { margin-bottom: var(--space-4); }
  .hero-search .searchbox-go [lang="ur"], .w-search .searchbox-go [lang="ur"] { display: none; }
}
.home-shelf, .topics-sec { margin-top: var(--space-6); }
.home-shelf.own { background: var(--note-bg); border: 1px solid var(--border); border-radius: var(--radius-l); padding: var(--space-3) var(--space-5) var(--space-5); margin-top: var(--space-7); }
@media (max-width: 600px) { .home-shelf.own { padding: var(--space-2) var(--space-3) var(--space-4); margin-inline: calc(-1 * var(--space-2)); } }
.swipe-hint { display: none; }  /* .qc-caption, shown on phones */
/* Phones: the two home shelves scroll sideways (the next card peeks in), so the topics are not 12 cards away. */
@media (max-width: 600px) {
  .home-shelf .shelf { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: var(--space-3); padding: 4px 2px 12px;
    margin-inline: -2px; scrollbar-width: thin; overscroll-behavior-x: contain; }
  .home-shelf .shelf-book { flex: 0 0 86%; scroll-snap-align: start; }
  .swipe-hint { display: block; }
}

/* ─── TOPIC tile: flat, centred, eight-point mark ─── */
.topics { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); }
.topic { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 128px;
  padding: var(--space-3) var(--space-2); background: var(--bg-3); border: 1px solid transparent; border-radius: var(--radius-l); color: var(--fg);
  text-decoration: none; }
.topic:hover { background: var(--bg-2); border-color: var(--accent); }
.t-mark { position: relative; width: 16px; height: 16px; margin-bottom: 2px; }
.t-mark::before, .t-mark::after { content: ""; position: absolute; inset: 2px; border: 1.5px solid var(--accent); }
.t-mark::after { transform: rotate(45deg); }
.topic .t-ur { font-size: var(--fs-ur-small); font-weight: 600; color: var(--accent-2); line-height: 1.9; }
.t-en { margin-top: 2px; }  /* .t-detail, .t-en: .qc-caption (1.4.0) */
.more-quiet { text-align: center; margin: var(--space-5) 0 0; }
.more-quiet .count { font: 500 var(--fs-caption) var(--font-en); }
@media (max-width: 420px) { .topics { grid-template-columns: 1fr 1fr; gap: var(--space-2); } .topic { min-height: 116px; } }

/* Topics accordion (home): tile -> full-row panel of book cards */
.topics-hint { margin: 0; }  /* main[lang=ur] size; the English line is .en */
.topics-hint-en { margin: 0 0 var(--space-4); color: var(--fg-2); }
.t-count { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 0 4px; font-size: var(--fs-ur-caption); color: var(--accent-2);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px 12px; margin-top: 8px; line-height: 1.9; }
.t-count b { font: 700 var(--fs-body) var(--font-en); color: var(--accent-2); }
.t-count-en { font: var(--fs-caption) var(--font-en); color: var(--fg-2); }
.t-chev { display: none; width: 8px; height: 8px; margin-inline-start: 6px; align-self: center; border: solid var(--accent); border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg); transition: transform .28s ease; }
.js-topics .t-chev { display: inline-block; }
.js-topics .topic { cursor: pointer; transition: background .2s, border-color .2s, box-shadow .2s; }
.topic[aria-expanded="true"] { background: var(--bg-2); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.topic[aria-expanded="true"] .t-chev { transform: translateY(2px) rotate(-135deg); }
.topic:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topics .tpanel { grid-column: 1 / -1; position: relative; display: grid; grid-template-rows: 0fr; margin-top: calc(var(--space-3) * -1);
  transition: grid-template-rows .38s cubic-bezier(.3,.7,.2,1), margin .38s; scroll-margin-top: 16px; }
.topics .tpanel.open { grid-template-rows: 1fr; margin-top: 0; }
.tp-clip { overflow: hidden; min-height: 0; }
.tp-in { position: relative; margin-top: 8px; background: var(--bg-2); border: 1.5px solid var(--accent); border-radius: var(--radius-l);
  padding: var(--space-4); opacity: 0; transform: translateY(-6px); transition: opacity .3s ease, transform .38s cubic-bezier(.3,.7,.2,1); }
.tpanel.open .tp-in { opacity: 1; transform: none; }
.tp-in::before { content: ""; position: absolute; top: -8px; left: var(--notch, 50%); width: 14px; height: 14px; margin-left: -7px; background: var(--bg-2);
  border: solid var(--accent); border-width: 1.5px 1.5px 0 0; transform: rotate(-45deg); border-radius: 2px 0 0 0; }
.tp-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); }
.tp-title { margin: 0; flex: 1 1 auto; }  /* .qc-subhead (1.4.0); the count is a .qc-caption */
.tp-full { font-size: var(--fs-ur-caption); color: var(--accent); white-space: nowrap; text-decoration: none; }
.tp-full:hover { text-decoration: underline; }
.tp-close { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-3); color: var(--fg); font-size: var(--fs-h2); line-height: 1; cursor: pointer; }
.tp-close:hover { border-color: var(--accent); }
.tp-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 420px) { .t-count { padding: 2px 8px; } .tp-in { padding: var(--space-3); } }
@media (prefers-reduced-motion: reduce) { .topics .tpanel, .tp-in, .t-chev, .topic { transition: none !important; } }
.topics-sec, .topic { scroll-margin-top: 16px; }
@media (max-width: 520px) { .tp-close { position: absolute; top: 8px; left: 8px; width: 36px; height: 36px; font-size: var(--fs-h3); } .tp-head { padding-left: 44px; min-height: 40px; } .tp-title { flex-basis: 100%; } }

/* ─── Work page: a book title page ─── */
.titlepage { position: relative; text-align: center; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-l);
  padding: var(--space-6) var(--space-5) var(--space-5); box-shadow: var(--shadow); margin-top: var(--space-2); }
.titlepage::before { content: ""; position: absolute; inset: 8px; border: 1px solid var(--rule); border-radius: var(--radius-m); pointer-events: none; }
.titlepage .rule { margin: var(--space-4) 0; }
.w-badge { margin: 0 0 var(--space-2); }
.w-sec { margin-top: var(--space-6); }
/* the contents as plain links to the text pages (build.toc_text: rendered server-side for crawlers; closed by default) */
.toc-text summary { cursor: pointer; color: var(--fg-2); }
.toc-text-vol { margin: var(--space-4) 0 var(--space-2); }
.w-title { margin: 0; font-size: var(--fs-ur-h1); font-weight: 700; line-height: 1.9; color: var(--accent-2); }
.w-title.t-ar { line-height: 1.6; }
.w-roman { margin: 2px 0 0; font-size: var(--fs-body); color: var(--fg-2); font-style: italic; }
.w-author { margin: 0; font-size: var(--fs-ur-small); line-height: 2; }
.w-author .lbl { display: block; font-size: var(--fs-ur-caption); color: var(--fg-2); line-height: 1.6; }
.w-author .en { display: block; font-size: var(--fs-caption); color: var(--fg-2); }
.w-vols { margin: var(--space-3) 0 0; }
.w-search { max-width: 640px; margin: var(--space-5) auto; }
.w-about { margin: var(--space-5) auto 0; }
.about { margin: 0; font-size: var(--fs-ur-body); line-height: var(--lh-ur); }
.about-en { margin: var(--space-2) 0 0; text-align: left; }  /* .qc-caption (1.4.0) */
.hint { margin: 0 0 var(--space-3); }  /* .qc-caption */
/* Read: one tile per volume, a book cover (the real one, else a drawn cover with the volume number) + label + "Read".
   The whole tile is the link; "Text only" sits under it inside the same grid cell (never overlaps the next line). */
.vol-list { --cover-w: 52px; list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); }
.vol-item { display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; }
.vol { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 10px 10px; flex: 1 1 auto;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m); color: var(--fg); text-align: center;
  text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.vol:hover, .vol:focus-visible { border-color: var(--accent); box-shadow: 0 2px 10px rgb(0 0 0 / .08); transform: translateY(-1px); }
.vol-cover { display: block; flex: 0 0 auto; }
.vol-cover img { display: block; width: var(--cover-w); height: auto; max-height: calc(var(--cover-w) * 1.6); object-fit: cover;
  border-radius: 3px; box-shadow: 0 1px 4px rgb(0 0 0 / .18); }
.vol-cover .cover-ph { width: var(--cover-w); }
.vol-cover .cover-ph-mark { font-family: inherit; font-size: calc(var(--cover-w) * 0.24); font-weight: 700; }
.vol-body { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.v-main { font-size: var(--fs-ur-small); font-weight: 600; line-height: 1.9; color: var(--accent-2); }
.v-main[lang="en"] { font-size: var(--fs-small); }
.v-note { padding-bottom: 2px; }  /* .qc-caption */
.v-go { display: inline-flex; align-items: baseline; gap: 6px; padding: 2px 14px; border-radius: 999px; background: var(--accent);
  color: var(--on-accent); line-height: 2; }  /* .qc-caption */
.vol:hover .v-go { background: var(--accent-2); }
.v-text { align-self: center; line-height: 1.8; }  /* .qc-caption */
/* one volume: a horizontal card (cover at the start, label + Read beside it), sized to its content */
.vol-list.single { --cover-w: 96px; grid-template-columns: minmax(min(340px, 100%), max-content); }
.vol-list.single .vol { flex-direction: row; gap: var(--space-4); padding: 14px 18px; text-align: start; }
.vol-list.single .vol-body { align-items: flex-start; gap: 8px; }
.vol-list.single .v-go { padding: 4px 20px; }
.vol-list.single .v-text { align-self: flex-start; }
.missing { margin: var(--space-3) 0 0; color: var(--red); }  /* .qc-caption */
.toc-body { border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--bg-2); max-height: 30rem; overflow: auto; overscroll-behavior: contain; }
/* several volumes (static/work.js): one tile per volume, its contents open below its row, one at a time: the home
   topics accordion (.topics / .topic / .tpanel above) with smaller tiles. The panel title is a .qc-subhead, the rows
   .qc-list-row; layout only here */
.toc-vols { grid-template-columns: repeat(auto-fill, minmax(min(136px, 100%), 1fr)); }
.toc-vols .topic { width: 100%; min-height: 0; padding: var(--space-2); font: inherit; cursor: pointer; transition: background .2s, border-color .2s, box-shadow .2s; }
.toc-vols .t-count { margin-top: 4px; }
.toc-vols .t-chev { display: inline-block; }
.toc-vols .tp-head { margin-bottom: var(--space-3); }
@media (max-width: 520px) { .toc-vols { grid-template-columns: repeat(auto-fill, minmax(min(96px, 100%), 1fr)); gap: var(--space-2); }
  .toc-vols .topic { padding: var(--space-2) 4px; } .toc-vols .t-count { padding: 0 6px; max-width: 100%; } .toc-vols .t-chev { display: none; } .toc-vols .t-count-en { display: none; } }
.toc-list { border-top: 0; }
.toc-list .qc-list-row { padding: 4px 14px; min-height: 44px; border-bottom-color: var(--rule); }
.toc-list .unv .qc-list-title { color: var(--fg-2); }
.toc-more { display: block; width: 100%; min-height: 44px; border: 0; border-radius: 0; background: var(--bg-3); color: var(--accent); font-size: var(--fs-ur-caption); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: var(--space-2) var(--space-5); margin: 0; }
.facts div { border-bottom: 1px solid var(--rule); padding-bottom: 2px; }
/* dt = qamar-common .qc-caption (Urdu 15 / English 12, 1.4.0); dd inherits main[lang=ur] (17 px / 2); English values are .en */
.facts dd { margin: 0; }
.facts dd [lang="en"] { line-height: 1.7; display: inline-block; padding: 4px 0; }
.tags { list-style: none; padding: 0; margin: var(--space-4) 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: var(--fs-ur-caption); line-height: 1.9; color: var(--fg-2); background: var(--bg-3); border-radius: var(--radius-s); padding: 0 10px; }
@media (max-width: 600px) {
  .titlepage { padding: var(--space-5) var(--space-4) var(--space-4); }
  .w-title { font-size: var(--fs-ur-h2); }
}

/* ─── Search: filters, book picker, results grouped by book ─── */
.sform { margin: 0 0 var(--space-2); }
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: var(--space-3); }
.modes { display: flex; flex-wrap: wrap; gap: 6px; }
.modes label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--bg-2); cursor: pointer; line-height: 1.9; }
.modes label:has(input:checked) { border-color: var(--accent); background: var(--note-bg); color: var(--accent-2); }
.modes input { accent-color: var(--accent); margin: 0; }
.modes small { color: var(--muted); font-family: var(--font-en); font-size: var(--fs-caption); }
.sel { display: inline-flex; align-items: center; gap: 6px; }
.sel .qc-select { max-width: 210px; }
.scope { background: var(--note-bg); border-radius: var(--radius-s); padding: 2px 12px; margin: var(--space-2) 0 0; }
.scope a { margin-inline-start: 8px; }
.tip { margin: var(--space-2) 0 0; }  /* .qc-caption */
#s-status { margin-top: var(--space-3); }
.wmatch { margin-top: var(--space-5); }
.alt { margin: var(--space-3) 0; }  /* .qc-caption (its Arabic: the shared 19 px Amiri) */
.rgroup { position: relative; margin: var(--space-4) 0; border: 1px solid var(--border); border-radius: var(--radius-m); border-start-start-radius: 3px; border-end-start-radius: 3px;
  background: var(--bg-2); box-shadow: var(--shadow); overflow: hidden; border-inline-start: 6px solid var(--accent); }
/* group header = qamar-common .qc-meta-row (a.qc-meta-title + author .qc-caption, 1.4.0); the box lines stay here */
.rgroup > header { padding: 6px var(--space-4); border-bottom: 1px solid var(--rule); }
.hit-link { display: block; padding: 8px var(--space-4) 10px; border-top: 1px solid var(--rule); color: var(--fg); text-decoration: none; }
.rgroup > header + .hit-link { border-top: 0; }
.hit-link:hover { background: var(--bg-3); }
/* the hit's page reference is a qamar-common .qc-meta-ref pill (.sub = the PDF page) */
.hit-link .excerpt { max-width: 40em; }  /* qamar-common .excerpt (R11): Urdu 17 px, Arabic 19 px */
.pager { display: flex; justify-content: space-between; gap: 8px; margin: var(--space-5) 0; align-items: center; }
.empty { text-align: center; padding: var(--space-6) 0; color: var(--fg-2); }
.empty .en { display: block; }
@media (max-width: 600px) {
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .modes { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .modes label { justify-content: center; padding: 0 6px; }
  .modes small { display: none; }
  .sel { min-width: 0; }
  .sel .qc-select { flex: 1; min-width: 0; max-width: none; }
}
/* book picker (type, pick several; picked books are qamar-common .chip.on) */
.bookpick { position: relative; margin-top: var(--space-3); display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.bookpick > label small { color: var(--fg-2); }
.bp-box { flex: 1 1 320px; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 46px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--bg-2); }
/* the typing field is a qamar-common .qc-input (R11) set into the chip box: layout reset only, no sizes */
.bp-box .qc-input { flex: 1 1 160px; width: 0; min-width: 120px; min-height: 0; border: 0; background: transparent; padding: 6px 4px; outline: none; }
.bp-box:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.bp-chips { display: contents; }
.bp-chips .chip { align-items: center; padding-inline-end: 4px; }
.bp-x { min-height: 0; border: 0; background: transparent; color: inherit; font-size: var(--fs-lead); cursor: pointer; line-height: 1; padding: 0 4px; }
.bp-sugg { position: absolute; z-index: 30; top: 100%; inset-inline: 0; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m); box-shadow: var(--shadow); max-height: 340px; overflow: auto; }
.bp-item { display: grid; grid-template-columns: 2.6em 1fr; gap: 0 8px; padding: 6px 8px; border-radius: var(--radius-s); cursor: pointer; }
.bp-item small { grid-column: 2; direction: ltr; text-align: right; }
.bp-item:hover, .bp-item.on { background: var(--bg-3); }
.bp-no { align-self: center; }
.bp-none { padding: 8px; color: var(--fg-2); }

/* ─── Catalogue (فہرستِ کتب): one row per work; the number is qamar-common .list-no (decision 01) ─── */
.c-tools { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin: var(--space-3) 0 var(--space-5); }
.c-tools .searchbox { flex: 1 1 280px; margin: 0; min-width: 0; }
/* text size 1.6.1: an input's intrinsic width grows with its font (step 3 at 320 px pushed the page sideways) */
.searchbox input { min-width: 0; }
.c-sec { margin-bottom: var(--space-6); }
/* rows: qamar-common .qc-list > li > a.qc-list-row (.list-no, .qc-list-main: -title, -roman, -sub; .qc-list-meta), 1.4.0 */
.c-empty { color: var(--fg-2); text-align: center; }
/* section jump row (UX review 1 #14) and the «↑ اوپر» link at each section head */
.c-jump { margin: 0 0 var(--space-5); }
.c-count .en { display: block; }
.sec-h:has(.c-top) .en { margin-inline-start: auto; }
.sec-h .c-top { text-decoration: none; color: var(--fg-2); white-space: nowrap; }
.sec-h .c-top:hover { color: var(--accent); }
@media print { .c-jump, .c-top, .c-tools { display: none; } }

/* ─── Reader: scan + OCR text side by side ─── */
.rbar { position: sticky; top: var(--header-offset, 0px); transition: top 200ms; z-index: 15; background: var(--glass); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); padding: 6px 0; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.rwork { font-weight: 700; color: var(--accent-2); flex: 1 1 240px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.rwork:hover { text-decoration: underline; }
.rpos { color: var(--fg-2); }
.rpos bdi { font-family: var(--font-en); }
/* reader bar controls: qamar-common .btn.quiet / .qc-input (R11, 40 -> 44 px); layout only here */
.rnav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rgo { display: flex; gap: 4px; align-items: center; }
.rgo .qc-input { width: 80px; text-align: center; }
.rsearch { display: inline-flex; gap: 4px; }
.rsearch .qc-input { width: 12em; }
.rsearch .btn.quiet { padding: 0 12px; }
.rpos .rpos-file { margin-inline-start: 8px; }
.rvol { display: inline-flex; gap: 4px; align-items: center; }
.rvol .qc-select { max-width: 14em; }
.rfile { display: inline-block; }
.rfile summary { cursor: pointer; color: var(--fg-2); list-style: none; padding: 0 4px; }
.rfile summary::-webkit-details-marker { display: none; }
.rfile summary span { border-bottom: 1px dotted currentColor; }
.rfile[open] { display: inline-flex; gap: 6px; align-items: center; }
.rprint { display: inline-flex; gap: 4px; }
.rfrom { flex-basis: 100%; display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin: 0; }
.rfrom .btn.quiet { min-height: 32px; padding: 0 10px; }
/* the page-turn row under the text (phones: the reader no longer scrolls back up to turn the page) */
.rbottom { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin: var(--space-5) 0 var(--space-3);
  padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.rbottom .rpos { text-align: center; }
.rbottom .rpos .rpos-file { display: block; margin: 0; white-space: nowrap; }
.rbottom .btn { min-width: 7em; }
/* print-only citation line (a printed sheet says which book, volume and page it is) */
.r-cite { display: none; }
#r-status { margin: var(--space-3) 0; }
.rgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; padding-top: var(--space-4); }
/* text size (qamar-common 1.6.1, <html data-qc-text>): every --fs-* token scales by itself (Nastaliq x --text-scale-ur,
   Latin / Amiri x --text-scale), so site rules use the token as is (a token times a factor would scale twice) and only
   literal px on content take a factor; chrome is marked class="qc-fixed-size" in build.py. The scan column grows by
   the Nastaliq factor of each step (fr cannot go inside calc()); one column on phones and in print, so nothing there */
html[data-qc-text="-1"] .rgrid { grid-template-columns: minmax(0, 1fr) minmax(0, .92fr); }
html[data-qc-text="1"] .rgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
html[data-qc-text="2"] .rgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
html[data-qc-text="3"] .rgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.32fr); }
.textcol { min-width: 0; }  /* reading text: qamar-common .qc-prose lang=ur (21 px, 19 px on phones) */
.scancol { position: sticky; top: calc(var(--header-offset, 0px) + 64px); transition: top 200ms; max-height: calc(100vh - 80px - var(--header-offset, 0px)); overflow: auto; scrollbar-gutter: stable; }
.scanwrap { position: relative; overflow: hidden; min-height: 240px; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-s); box-shadow: var(--shadow); direction: ltr; }
.scanwrap img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.box { position: absolute; border: 2px solid var(--red); background: rgba(169, 53, 39, .14); border-radius: 3px; pointer-events: none; transition: all var(--dur); }
.blk { margin: 0 0 var(--space-3); padding: 2px 10px; border-inline-start: 3px solid transparent; border-radius: var(--radius-s); scroll-margin-top: 110px; cursor: default; overflow-wrap: anywhere; }
.blk:hover, .blk.on { background: var(--bg-3); border-inline-start-color: var(--accent); }
/* the search hit's passage: a locator only (side rule), the strong highlight is on the matched words (<mark>) */
.blk.hit { border-inline-start-color: var(--red); }
.blk.hit:hover, .blk.hit.on { border-inline-start-color: var(--red); }
.box.loc { background: rgba(169, 53, 39, .07); border-width: 2px; border-style: dashed; }
/* topic words (shared concept groups) of a meaning hit / Ask citation: a lighter mark with a dotted rule;
   the closest sentence of a meaning hit or of an Ask quote: a soft tint with a thin rule under it */
.textcol mark { box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.textcol mark.hc { background: rgba(255, 244, 194, .45); background: color-mix(in srgb, var(--highlight) 45%, transparent); border-bottom: 2px dotted var(--accent); border-radius: 0; padding: 0; }
.hl-sent { background: rgba(31, 92, 74, .09); background: color-mix(in srgb, var(--accent) 9%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  box-decoration-break: clone; -webkit-box-decoration-break: clone; }
@media print {   /* backgrounds do not print: words underlined (search words heavier), the hit passage keeps its rule */
  .textcol mark { background: none; text-decoration: underline 2px; text-underline-offset: .35em; }
  .textcol mark.hc { text-decoration: none; border-bottom: 1px dotted currentColor; }
  .hl-sent { background: none; border-bottom: 1px solid currentColor; }
  .blk.hit { border-inline-start: 3px solid currentColor; }
}
.blk.script-ar, .blk.script-fa { font-family: var(--font-ar); font-size: var(--fs-arabic); line-height: var(--lh-ar); }
.blk.script-en { font-family: var(--font-en); font-size: var(--fs-lead); line-height: var(--lh-en); direction: ltr; text-align: left; }
.blk.heading { font-size: var(--fs-ur-h3); font-weight: 700; color: var(--accent-2); margin-top: var(--space-4); }
.blk.script-ar.heading { font-size: calc(24px * var(--text-scale)); }   /* Amiri: the Latin factor (--fs-ur-h3 scales by the Nastaliq one) */
.blk.quote { background: var(--quote-bg); border-inline-start: 3px solid var(--border); }
.blk.poetry { text-align: center; white-space: pre-line; background: var(--quote-bg); padding: var(--space-3); }
.blk.footnote { font-size: var(--fs-ur-small); color: var(--fg-2); border-top: 1px solid var(--rule); padding-top: 6px; }
.blk.footnote.script-ar { font-size: calc(17px * var(--text-scale)); }   /* Amiri: the Latin factor */
.blk.margin_note { font-size: var(--fs-ur-small); background: var(--note-bg); border: 1px dashed var(--border); color: var(--fg-2); margin-inline-start: var(--space-5); }
.blk .tag { display: inline-block; font-family: var(--font-ur); font-size: var(--fs-ur-caption); color: var(--muted); background: var(--bg-3); border-radius: var(--radius-s); padding: 0 6px; margin-inline-end: 6px; line-height: 1.6; }
.blk.page_number, .blk.page_header, .blk.catchword { font-size: var(--fs-ur-caption); color: var(--muted); text-align: center; }
.blk.non_book_overlay { display: none; opacity: .7; font-size: var(--fs-ur-caption); color: var(--muted); border: 1px dotted var(--border); }
.show-overlay .blk.non_book_overlay { display: block; }
/* OCR inline tags (functions/_lib/render/rich.js TAGS), the same in the reader (.blk) and the /t/ text pages (.tp-text) */
:is(.blk, .tp-text) .t-quran { font-family: var(--font-ar); background: var(--quran-bg); color: var(--quran-fg); border-radius: var(--radius-s); padding: 0 6px; font-size: 1.08em; line-height: var(--lh-ar); }
:is(.blk, .tp-text) .t-quran .ref { font-family: var(--font-en); font-size: var(--fs-xs); opacity: .75; margin-inline-start: 4px; direction: ltr; unicode-bidi: isolate; }
:is(.blk, .tp-text) .t-hadith { font-family: var(--font-ar); background: var(--hadith-bg); color: var(--hadith-fg); border-radius: var(--radius-s); padding: 0 6px; line-height: var(--lh-ar); }
:is(.blk, .tp-text) .t-arabic, :is(.blk, .tp-text) .t-persian { font-family: var(--font-ar); line-height: var(--lh-ar); }
:is(.blk, .tp-text) .t-persian { font-size: .95em; }
:is(.blk, .tp-text) .t-urdu { font-family: var(--font-ur); line-height: var(--lh-ur); }
:is(.blk, .tp-text) .t-english { font-family: var(--font-en); direction: ltr; unicode-bidi: isolate; font-size: .9em; }
:is(.blk, .tp-text) .t-poetry { display: block; text-align: center; white-space: pre-line; }
:is(.blk, .tp-text) .t-u { text-decoration: underline; text-underline-offset: .35em; }
:is(.blk, .tp-text) .t-o { text-decoration: overline; }
/* Text | Scan switch (qamar-common .mode-switch, decision 03 option A): only when the window is too narrow for both panes */
.r-viewbar { display: none; }
@media (max-width: 900px) {
  .rgrid, html[data-qc-text] .rgrid { grid-template-columns: 1fr; gap: var(--space-3); }
  .scancol { position: static; max-height: none; order: -1; }
  .rgrid.v-text .scancol, .rgrid.v-scan .textcol { display: none; }
  .rwork { flex-basis: 100%; }
  .rbar { position: static; }  /* phones: the Text | Scan switch is the one sticky bar */
  .r-viewbar { display: block; position: sticky; top: var(--header-offset, 0px); transition: top 200ms; z-index: 16; text-align: center; padding: 6px 0; background: var(--glass);
    backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); }
}
/* print: one column, the citation line on top, the text OR the scan of the page (the Text | Scan choice, or the
   print buttons), black on white (UX review 1 #3) */
@media print {
  .mk-subnav, .rbar, .r-viewbar, .rbottom, #r-status, .zoombtn, .imgwait, .box, .zoomview { display: none !important; }
  .reader-page .qc-footer { display: none !important; }   /* #r-cite is the citation (qamar-common 1.6.0 prints one too) */
  .reader-page .wrap { max-width: none; padding: 0; }
  .r-cite { display: block !important; font-family: var(--font-ur); line-height: 2; color: #000;
    border-bottom: 1px solid #000; padding-bottom: 4pt; margin: 0 0 10pt; }
  .rgrid { display: block !important; padding: 0; }
  .scancol { position: static !important; max-height: none !important; overflow: visible !important; }
  .scanwrap { border: 0; box-shadow: none; background: none; }
  .scanwrap img { width: auto; max-width: 100%; max-height: 24cm; margin: 0 auto; }
  .rgrid.v-text .scancol, .rgrid.v-scan .textcol { display: none !important; }
  .rgrid .textcol, .rgrid .scancol { display: block; }
  body.print-text .rgrid .scancol { display: none !important; }
  body.print-text .rgrid .textcol { display: block !important; }
  body.print-scan .rgrid .textcol { display: none !important; }
  body.print-scan .rgrid .scancol { display: block !important; }
  .blk { color: #000; background: none !important; border-color: transparent; break-inside: avoid; }
  .blk.page_number, .blk.page_header, .blk.catchword, .blk .tag { color: #444; }
  :is(.blk, .tp-text) .t-quran, :is(.blk, .tp-text) .t-hadith { background: none; color: #000; padding: 0; }
  :is(.blk, .tp-text) .t-quran .ref { opacity: 1; }
}
/* "loading scan" notice instead of a broken-image icon; Retry after the automatic retries fail */
.imgwait { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m); color: var(--fg-2); text-align: center; }
.imgwait .qc-caption { color: inherit; padding: 0; }
.imgwait .dots i { font-style: normal; animation: imgdots 1.2s infinite both; }
.imgwait .dots i:nth-child(2) { animation-delay: .2s; } .imgwait .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes imgdots { 0%, 80%, 100% { opacity: .15; } 40% { opacity: 1; } }
.imgwait.failed { color: var(--red); }
.imgretry { margin-top: 6px; }
#r-img.loading { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .imgwait .dots i { animation: none; opacity: .6; } }
/* zoom / pan view */
.zoombtn, .zclose, .zctl button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border);
  background: var(--glass); color: var(--fg); cursor: pointer; }
.zoombtn { position: absolute; top: 8px; left: 8px; width: 36px; height: 36px; padding: 0; border-radius: var(--radius-pill); font-size: var(--fs-lead); line-height: 1; }
.zoomview { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92); direction: ltr; }
.zstage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.zstage img { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; background: var(--paper); }
.zclose { position: absolute; top: 10px; right: 12px; z-index: 2; width: 44px; height: 44px; font-size: var(--fs-h2); padding: 0; border-radius: var(--radius-pill); }
.zctl { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 2; display: flex; gap: 8px; }
.zctl button { min-width: 44px; min-height: 44px; padding: 2px 12px; border-radius: var(--radius-s); }

/* ─── /t/<doc>/<page> text pages (server-rendered for search engines) ─── */
.textpage .tp-where, .textpage .tp-author { color: var(--fg-2); margin: 0; }
.tp-nav { display: flex; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-4) 0; }
/* reading text: qamar-common .qc-prose lang=ur (R11); headings and footnotes keep their block-type sizes (allowlisted) */
.tp-text h2 { font-size: var(--fs-ur-h3); color: var(--accent-2); margin: var(--space-4) 0 var(--space-2); }
.tp-text .fn { font-size: var(--fs-ur-small); color: var(--fg-2); border-top: 1px solid var(--border); padding-top: 4px; }
/* printed text page: title, author and «جلد …، صفحہ …» stay on top as the reference; the shared footer's print line
   (qamar-common 1.6.0: «مکتبۂ قمر» · tab title — maktaba.muftiqamar.com/t/…) carries the address */
@media print {
  .textpage .tp-nav, .textpage .crumbs { display: none; }
  .tp-text { color: #000; }
}

/* ─── Privacy ─── */
.en-block { text-align: left; }
.privacy-page main { overflow-wrap: anywhere; }   /* the address wraps at big text sizes on phones */

/* ─── /connect: English mode (default) | Urdu mode, one URL (build.build_connect). <html data-cx-lang> is set in the
   head before the first paint; without JS the English section shows and #ur (:target) brings the Urdu one. ─── */
.cx-mode[data-l="ur"] { display: none; }
html:not([data-cx-lang]) .cx-main:has(#ur:target) #en { display: none; }
html:not([data-cx-lang]) #ur:target { display: block; }
html[data-cx-lang="ur"] #en { display: none; }
html[data-cx-lang="ur"] #ur { display: block; }
.cx-mode[lang="ur"] { font-size: var(--fs-ur-ui); line-height: var(--lh-ur-ui); }
.cx-mode { overflow-wrap: anywhere; }   /* long addresses (the citation example) wrap on phones */
.cx-switch { display: flex; width: max-content; margin: 0 auto var(--space-5); }
.cx-h1 { color: var(--accent-2); font-weight: 600; line-height: 1.25; }
.cx-mode h2 { color: var(--accent-2); margin: var(--space-6) 0 var(--space-3); }
.cx-mode ol { padding-inline-start: 1.6em; }
.cx-mode[lang="ur"] ol { list-style-type: urdu; }   /* ۱، ۲ … (Urdu digits, as the section numbers); "1." reads ".1" in RTL */
.cx-mode li { margin-bottom: var(--space-2); }
.cx-note { color: var(--fg-2); }
.cx-copybox { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-3) 0 var(--space-4); }
.cx-copybox code.cx-src { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--bg-2); overflow-wrap: anywhere; }
.cx-block { flex-direction: column; align-items: stretch; }
.cx-block .cx-copy { align-self: flex-end; }
.cx-prompt { white-space: pre-line; padding: var(--space-3) var(--space-4); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent); border-radius: var(--radius-s); background: var(--bg-2); overflow-wrap: anywhere; }
.cx-ask .cx-block { flex-direction: row; align-items: flex-start; flex-wrap: nowrap; margin: 0; }
.cx-ask .cx-prompt { flex: 1 1 auto; min-width: 0; }
.cx-ask .cx-block .cx-copy { align-self: center; }
/* who it is for (dl), the major works (ul per subject), questions and answers (h3 + p) */
.cx-mode h3 { color: var(--accent-2); margin: var(--space-5) 0 var(--space-2); }
.cx-who dt { font-weight: 600; color: var(--accent-2); margin-top: var(--space-4); }
.cx-mode[lang="ur"] .cx-who dt { font-weight: 400; }   /* Nastaliq: no synthetic bold */
.cx-who dd { margin: var(--space-1) 0 0; }
.cx-who dd ul, .cx-works { padding-inline-start: 1.4em; margin: var(--space-2) 0; }
.cx-who dd p { margin: var(--space-1) 0; }
.cx-works li { margin-bottom: var(--space-2); }
.cx-faq h3 { margin-top: var(--space-5); }
.cx-jump a { white-space: nowrap; }
@media print {
  .cx-switch, .cx-copy { display: none !important; }
  .cx-prompt, .cx-copybox code.cx-src { background: none; border-color: #000; color: #000; }
}

/* ─── Arabic (Amiri) is never bold (as muftiqamar.com, dars 2026-12-02): titles and headings in Arabic use the regular
   face; size and colour carry the emphasis. The bold Amiri files (~118 KB) are then never downloaded. Amiri is used by
   .t-ar (Arabic / Persian titles), [lang=ar] and the reader's / text pages' Arabic blocks and spans. !important: the
   shared components set 600/700 on title elements with more specific selectors (.shelf-text h3 .ur,
   .qc-meta-row a.qc-meta-title), and this rule must win wherever Amiri is the face. ─── */
.t-ar, [lang="ar"], .blk.script-ar, .blk.script-fa, .blk .t-quran, .blk .t-hadith, .blk .t-arabic, .blk .t-persian,
.tp-text .t-quran, .tp-text .t-hadith, .tp-text .t-arabic, .tp-text .t-persian { font-weight: 400 !important; }

/* ─── Long pages: content-visibility: auto skips style, layout and paint of blocks far off screen (the catalogue's
   sections, search result groups, the volume tiles, contents rows). contain-intrinsic-block-size is a block's height
   until it is first rendered (measured averages: catalogue row ~100 px desktop / ~165 px phone, contents row 46 / 93
   px, volume tile 177 px); `auto` then keeps its real height. Paint containment clips a block's contents to its box,
   so focus rings of the rows inside are drawn inset. ─── */
.c-sec { --row-h: 100px; content-visibility: auto; contain-intrinsic-block-size: auto calc(var(--rows, 10) * var(--row-h) + 64px); }
/* containment stops the heading's top margin collapsing through the section: the section carries it instead (same gaps) */
.c-sec { margin-top: var(--space-7); }
.c-sec > .sec-h:first-child { margin-top: 0; }
.rgroup { content-visibility: auto; contain-intrinsic-block-size: auto 500px; }
.vol-list:not(.single) .vol { content-visibility: auto; contain-intrinsic-block-size: auto 177px; }
.toc-list > li { --row-h: 46px; content-visibility: auto; contain-intrinsic-block-size: auto var(--row-h); }
.c-sec a.qc-list-row:focus-visible, .toc-list a.qc-list-row:focus-visible { outline-offset: -2px; }
@media (max-width: 600px) { .c-sec { --row-h: 165px; } .toc-list > li { --row-h: 93px; } }
@media (prefers-reduced-motion: reduce) { .rbar, .r-viewbar, .scancol { transition: none !important; } }
