/* من الحكم إلى العمل: platform stylesheet. Mobile first.
   The linear design of the sister site (taqrib-al-usul): white paper, black ink, one accent
   (lapis here, rubric red there), rules instead of cards, no shadows, no rounded corners.
   School inks appear only where the three schools are compared. */

@font-face { font-family: "Amiri"; src: url("fonts/Amiri-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Amiri"; src: url("fonts/Amiri-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Noto Naskh Arabic"; src: url("fonts/NotoNaskhArabic-Regular.ttf") format("truetype"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "Noto Naskh Arabic"; src: url("fonts/NotoNaskhArabic-Bold.ttf") format("truetype"); font-weight: 600 700; font-display: swap; }

/* Tokens. Paper and ink; lapis is the single accent and the rubric: numbers of propositions and steps,
   block labels, the line of the books. Each school has an ink, used wherever that school speaks.
   Type: Amiri for display (titles, kitab names, numerals of the matn), Noto Naskh for reading and
   headings, IBM Plex Sans Arabic for the interface. Scale on 1.125 (18px) reading text. */
:root {
  --paper: #fbfaf7;
  --paper-2: #f3f2ee;
  --paper-3: #e5e3dc;
  --ink: #18191b;
  --ink-2: #5a5c61;
  --rule: #d9d7d0;
  --accent: #1d4e89;
  --accent-soft: #e8eef6;
  --on-accent: #ffffff;
  --m-hanafi: #8a3b2a;
  --m-maliki: #2d6a3e;
  --m-shafii: #7a5a0b;
  --font-ui: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-text: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", serif;
  --font-display: "Amiri", "Noto Naskh Arabic", serif;
  --fs-body: 1.125rem;
  --fs-matn: clamp(1.25rem, 1.12rem + .55vw, 1.45rem);
  --measure: 40rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121416; --paper-2: #1a1d20; --paper-3: #2a2e33; --ink: #ebe9e3; --ink-2: #a9a8a2; --rule: #353a3f;
    --accent: #9dbcf0; --accent-soft: #1a2536; --on-accent: #0e1520;
    --m-hanafi: #e8a38f; --m-maliki: #8fd0a3; --m-shafii: #e0bf6a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121416; --paper-2: #1a1d20; --paper-3: #2a2e33; --ink: #ebe9e3; --ink-2: #a9a8a2; --rule: #353a3f;
  --accent: #9dbcf0; --accent-soft: #1a2536; --on-accent: #0e1520;
  --m-hanafi: #e8a38f; --m-maliki: #8fd0a3; --m-shafii: #e0bf6a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-ui); font-size: 1rem; line-height: 1.75; overflow-wrap: break-word; }
html[lang="en"] body { line-height: 1.6; }
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--font-text); line-height: 1.55; margin: 0 0 .5em; font-weight: 700; }
/* page titles in Amiri; section headings in Naskh bold, which holds up at small sizes and on phones */
html[lang="ar"] h1, h1[lang="ar"] { font-family: var(--font-display); line-height: 1.5; }
html[lang="en"] h1, html[lang="en"] h2, html[lang="en"] h3 { font-family: var(--font-ui); font-weight: 600; }
html[lang="en"] h1[lang="ar"] { font-family: var(--font-display); font-weight: 700; }
html[lang="en"] .sharh-body h2, html[lang="en"] .sharh-body h3, html[lang="en"] h2[lang="ar"], html[lang="en"] h3[lang="ar"] { font-family: var(--font-text); font-weight: 700; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.65rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 .9em; }
.muted { color: var(--ink-2); }
button, input, select { font: inherit; color: inherit; }
.skip { position: absolute; inset-inline-start: 1rem; top: -4rem; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 100; }
.skip:focus { top: .5rem; }
main { display: block; outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.aya { font-family: var(--font-display); font-size: 1.08em; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: .2em; cursor: pointer; min-height: 44px; }

/* ---------- school inks: only where the three are compared ---------- */
.m-hanafi, [data-m="hanafi"] { --m: var(--m-hanafi); }
.m-maliki, [data-m="maliki"] { --m: var(--m-maliki); }
.m-shafii, [data-m="shafii"] { --m: var(--m-shafii); }
.m-tag { display: inline-block; font-family: var(--font-ui); font-size: .78rem; font-weight: 600; line-height: 1.5; padding: 0 .45rem; border: 1px solid var(--m, var(--rule)); color: var(--m, var(--ink-2)); white-space: nowrap; }

/* ---------- header ---------- */
/* one row on every width: the name, then the tools; the sections open from «القائمة» below 1120px */
.site-head { background: var(--paper); border-bottom: 1px solid var(--rule); position: relative; z-index: 20; }
.head-in { max-width: 1320px; margin: 0 auto; padding: .2rem 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 .6rem; min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.22rem; min-height: 44px; white-space: nowrap; }
html[lang="en"] .brand { font-family: var(--font-ui); font-weight: 600; font-size: 1rem; }
.brand-mark { width: 40px; height: 12px; flex: none; }
.brand-mark path { stroke: var(--accent); stroke-width: 2; fill: none; }
.brand-mark circle { fill: var(--paper); stroke: var(--accent); stroke-width: 2; }
.brand-mark .bm-end { fill: var(--accent); }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .6rem; color: var(--ink); text-decoration: none; font-weight: 500; }
.site-nav a:hover { color: var(--accent); }
.site-nav a[aria-current="page"], .site-nav a.is-in { box-shadow: inset 0 -2px 0 var(--accent); color: var(--accent); }
.nav-tools { margin: 0; }
.head-tools { display: flex; align-items: center; gap: .25rem; margin-inline-start: auto; }
.lang { display: inline-flex; align-items: center; gap: .25rem; min-height: 44px; padding: 0 .5rem; color: var(--ink-2); text-decoration: none; font-size: .92rem; white-space: nowrap; }
.lang .on { color: var(--ink); font-weight: 600; }
.theme-btn, .menu-btn, .m-switch, .search-btn { min-width: 44px; min-height: 44px; border: 1px solid transparent; background: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; padding: 0; }
.theme-btn:hover, .menu-btn:hover, .m-switch:hover, .search-btn:hover { border-color: var(--rule); }
.theme-btn svg { width: 20px; height: 20px; fill: var(--ink); }
.search-btn svg, .menu-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: square; }
.m-switch { padding: 0 .55rem; gap: .3rem; font-size: .92rem; white-space: nowrap; border-color: var(--rule); }
.m-switch[data-m] { border-color: var(--m); }
.m-switch .ms-l { color: var(--ink-2); }
.m-switch .ms-v { color: var(--m, var(--ink)); font-weight: 600; }
.menu-btn { display: none; gap: .35rem; padding: 0 .4rem; }
.mb-t { font-size: .92rem; }
.js .menu-btn { display: inline-flex; }
.js .site-nav { order: 4; flex-basis: 100%; display: none; }
.js .site-nav.open { display: block; padding: .2rem 0 .7rem; border-top: 1px solid var(--rule); }
.js .site-nav.open ul { flex-direction: column; }
.js .site-nav.open a { font-size: 1.05rem; min-height: 48px; }
.site-nav .nav-tools { padding: .3rem .6rem 0; }
.nav-theme { display: none; }
.nav-theme span { margin-inline-start: .5rem; font-size: .95rem; }
@media (max-width: 559px) { .m-switch .ms-l, .mb-t { display: none; } .brand-mark { display: none; } .brand { font-size: 1.12rem; } html[lang="en"] .brand { font-size: .95rem; } }
/* on a phone the theme switch moves into the menu, so the header stays one row */
@media (max-width: 479px) {
  .head-tools .theme-btn { display: none; }
  .js .site-nav.open .nav-theme { display: inline-flex; padding: 0 .3rem; }
  .site-nav .nav-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; }
}
@media (min-width: 1120px) {
  .js .menu-btn { display: none; }
  .js .site-nav, .site-nav { display: flex; align-items: center; order: 2; flex-basis: auto; }
  .js .site-nav ul { flex-direction: row; }
  .site-nav .nav-tools { order: 9; padding: 0; }
  .head-tools { order: 3; }
}
.fixture-ribbon { margin: 0; text-align: center; background: repeating-linear-gradient(-45deg, var(--paper-3) 0 10px, var(--paper) 10px 20px); color: var(--accent); font-size: .9rem; padding: .2rem 16px; border-bottom: 1px solid var(--rule); }

/* ---------- generic frames and controls ---------- */
.page-narrow, .page-wide, .book { margin: 0 auto; padding: 1.5rem 16px 3rem; }
.page-narrow { max-width: 860px; }
.page-wide { max-width: 1240px; }
.page-head { margin: 1rem 0 1.6rem; }
.page-head h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.8rem); }
.page-head p { color: var(--ink-2); max-width: 65ch; }
.empty { padding: 1rem 1.1rem; border: 1px dashed var(--rule); color: var(--ink-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .35rem 1rem; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pt-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- madhhab chooser ---------- */
.chooser { border: 1px solid var(--ink); background: var(--paper); color: var(--ink); padding: 1.4rem 1.2rem 1.2rem; width: min(46rem, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.chooser::backdrop { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.chooser h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); margin: 0 0 .4rem; }
.chooser > p { color: var(--ink-2); max-width: 40rem; }
.ch-x { position: absolute; inset-inline-end: .4rem; top: .4rem; margin: 0; }
.ch-x button { min-width: 44px; min-height: 44px; border: 0; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--ink-2); }
.chooser { position: fixed; }
.picks { display: grid; gap: .7rem; margin: 1.2rem 0 .6rem; }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; text-align: start; padding: 1rem 1.1rem; min-height: 5.2rem; background: var(--paper); border: 1px solid var(--rule); border-inline-start: 6px solid var(--m); cursor: pointer; }
.pick b { font-family: var(--font-display); font-size: 1.9rem; line-height: 1.3; color: var(--m); }
html[lang="en"] .pick b { font-family: var(--font-ui); font-size: 1.5rem; }
.pick span { color: var(--ink-2); font-size: .92rem; }
.pick:hover, .pick[aria-pressed="true"] { border-color: var(--m); background: color-mix(in srgb, var(--m) 7%, var(--paper)); }
.pick-all { margin: .4rem 0 0; }
.pick-all button { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; min-height: 44px; padding: 0; }
@media (min-width: 700px) { .picks { grid-template-columns: repeat(3, 1fr); } .pick { min-height: 8rem; border-inline-start-width: 1px; border-top: 6px solid var(--m); } }

/* ---------- home: the line of the books is the subject ---------- */
.hero, .start, .line { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }
.hero { display: flex; flex-direction: column; padding-top: 1.1rem; padding-bottom: 1.6rem; }
.hero-head { display: contents; }
.hero h1 { order: 1; font-size: clamp(2.15rem, 1.5rem + 3.2vw, 3.7rem); line-height: 1.4; margin: 0; }
html[lang="en"] .hero h1 { line-height: 1.15; letter-spacing: -.015em; margin-bottom: .3rem; }
.hero-sub { order: 2; font-family: var(--font-text); font-size: clamp(1.02rem, .95rem + .45vw, 1.3rem); color: var(--accent); margin: 0 0 .9rem; line-height: 1.7; }
html[lang="en"] .hero-sub { font-family: var(--font-ui); }
.hero-go { order: 3; margin: 0 0 1.1rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.kline { order: 4; }
.hero-what { order: 5; font-family: var(--font-text); font-size: 1.08rem; line-height: 2; color: var(--ink-2); max-width: 34rem; margin: 1.2rem 0 0; }
html[lang="en"] .hero-what { font-family: var(--font-ui); line-height: 1.65; }
.go-btn { font-size: 1.08rem; padding-inline: 1.3rem; min-height: 50px; max-width: 100%; flex-direction: column; align-items: flex-start; line-height: 1.35; gap: 0; text-align: start; }
.go-k { font-family: var(--font-ui); font-size: .78rem; font-weight: 500; opacity: .85; }
.go-t { font-family: var(--font-text); font-weight: 700; font-size: 1.05rem; }
.path-btn { min-height: 50px; }
@media (min-width: 960px) {
  .hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: clamp(2.5rem, 5vw, 5rem); align-items: start; padding-top: 3.2rem; padding-bottom: 3rem; }
  .hero-head { display: block; position: sticky; top: 1.5rem; }
  .hero-what { margin: 0 0 1.6rem; }
  .hero-go { margin: 0; }
}

/* the line: a lapis spine, a ring per book filling with the reader's progress, the names large */
.kline-h { font-family: var(--font-ui) !important; font-size: .88rem !important; font-weight: 600; color: var(--ink-2); margin: 0 0 .5rem; line-height: 1.5; }
.kline ol { list-style: none; margin: 0; padding: 0; }
.kn { position: relative; --dot: 1.3rem; --col: 2.1rem; }
.kn::before { content: ""; position: absolute; inset-inline-start: calc(var(--col) / 2 - 1px); top: 0; bottom: 0; width: 2px; background: var(--accent); }
.kn:first-child::before { top: 1.25rem; }
.kn:last-child::before { bottom: auto; height: 1.25rem; }
.kn.is-off::before { background: repeating-linear-gradient(to bottom, var(--rule) 0 6px, transparent 6px 11px); }
.kn.is-off:first-of-type::before, .kn.is-on + .kn.is-off::before, .kn.is-review + .kn.is-off::before { background: linear-gradient(to bottom, var(--accent) 0 1.1rem, transparent 1.1rem), repeating-linear-gradient(to bottom, var(--rule) 0 6px, transparent 6px 11px); }
.kn > a, .kn-a { position: relative; display: grid; grid-template-columns: var(--col) minmax(0, 1fr); column-gap: .85rem; padding: .3rem 0 .45rem; color: var(--ink); text-decoration: none; }
.kn-dot { grid-row: 1 / span 2; justify-self: center; margin-top: .62em; width: var(--dot); height: var(--dot); border-radius: 50%; border: 2px solid var(--accent);
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1%), var(--paper) 0); position: relative; z-index: 1; font-size: clamp(1.5rem, 1.15rem + 1.7vw, 2.35rem); }
.kn-t { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.5rem, 1.15rem + 1.7vw, 2.35rem); line-height: 1.38; }
html[lang="en"] .kn-t { font-family: var(--font-ui); font-weight: 600; font-size: clamp(1.25rem, 1rem + 1.2vw, 1.85rem); line-height: 1.3; }
.kn-p { grid-column: 2; font-family: var(--font-ui); font-size: .84rem; color: var(--ink-2); line-height: 1.45; display: flex; flex-wrap: wrap; gap: 0 .8rem; }
.kn-rev { color: var(--ink-2); }
.kn-rev::before, .kn-pct::before { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-inline-end: .35rem; vertical-align: .1em; border: 1.5px dashed var(--ink-2); }
.kn-pct { color: var(--accent); font-weight: 600; }
.kn-pct::before { border: 0; background: var(--accent); }
.kn > a:hover .kn-t, .kn > a:focus-visible .kn-t { color: var(--accent); }
.kn.is-review .kn-dot { border-style: dashed; background: var(--paper); }
.kn.is-review .kn-t { color: var(--ink-2); }
.kn.is-off { --dot: .8rem; }
.kn.is-off .kn-dot { border-color: var(--rule); background: var(--paper); margin-top: .7em; font-size: 1.15rem; }
.kn.is-off .kn-t { font-family: var(--font-text); font-weight: 400; font-size: clamp(1.08rem, 1rem + .4vw, 1.3rem); color: var(--ink-2); }
html[lang="en"] .kn.is-off .kn-t { font-family: var(--font-ui); }
.kn.is-off .kn-p { font-size: .78rem; }
.kn.is-off .kn-a { padding: .1rem 0 .3rem; }
/* a cell per lesson: outlined, half filled after the matn, full when every cycle is marked */
.kn-ls { grid-column: 2; display: flex; flex-wrap: wrap; gap: 3px; margin: .3rem 0 .15rem; max-width: 22rem; }
.kn-ls i { width: 10px; height: 10px; border: 1.5px solid var(--accent); }
.kn-ls i.r { border-style: dashed; border-color: var(--ink-2); }
.kn-ls i.c1 { background: linear-gradient(to top, var(--accent) 50%, transparent 50%); }
.kn-ls i.full { background: var(--accent); }
@media (min-width: 960px) { .kn-ls i { width: 12px; height: 12px; } }
.mp-toc > summary { cursor: pointer; font-family: var(--font-ui); font-weight: 600; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.mp-toc[open] > summary { margin-bottom: .4rem; }

/* «ابدأ من هنا»: the three cycles, once, in order */
.start { padding-top: 2rem; padding-bottom: 2.2rem; border-top: 1px solid var(--rule); }
.start h2 { font-family: var(--font-display); font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.3rem); margin: 0 0 .2rem; }
html[lang="en"] .start h2 { font-family: var(--font-ui); }
.start-lead { color: var(--ink-2); margin: 0 0 1.2rem; }
.st-steps { list-style: none; margin: 0 0 1.4rem; padding: 0; counter-reset: st; display: grid; gap: 1.1rem 2.5rem; }
.st-steps li { counter-increment: st; display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); column-gap: .7rem; font-family: var(--font-text); line-height: 1.95; }
html[lang="en"] .st-steps li { font-family: var(--font-ui); line-height: 1.6; }
.st-steps li::before { content: counter(st, arabic-indic); grid-row: 1 / span 2; font-family: var(--font-display); font-weight: 700; font-size: 2.6rem; line-height: 1.1; color: var(--accent); text-align: center; }
html[lang="en"] .st-steps li::before { content: counter(st); font-family: var(--font-ui); font-weight: 600; font-size: 2rem; }
.st-k { display: block; font-size: 1.22rem; }
.st-steps span { color: var(--ink-2); }
@media (min-width: 860px) { .st-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.has-progress .start { display: none; }

/* the lessons of each open book */
.line { padding-bottom: 3rem; }
.line-h { font-family: var(--font-display) !important; font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.3rem); margin: 0; padding: 2rem 0 .2rem; border-top: 1px solid var(--rule); }
html[lang="en"] .line-h { font-family: var(--font-ui) !important; }
.line-note { color: var(--ink-2); font-size: .95rem; max-width: 46rem; margin: 0 0 .3rem; }
.rev-note { font-size: .88rem; }
.kitab { padding: 1.2rem 0 1rem; scroll-margin-top: .5rem; }
.kitab h3 { font-family: var(--font-display); font-size: clamp(1.45rem, 1.2rem + 1vw, 1.95rem); margin: 0 0 .5rem; color: var(--accent); }
html[lang="en"] .kitab h3 { font-family: var(--font-ui); }
.ln-list { list-style: none; margin: 0; padding: 0; position: relative; }
.ln { --dot: 2.2rem; display: grid; grid-template-columns: var(--dot) minmax(0, 1fr); column-gap: .9rem; align-items: baseline; padding: .55rem 0; position: relative; border-top: 1px solid var(--rule); }
.ln::before { content: ""; position: absolute; inset-inline-start: calc(var(--dot) / 2 - 1px); top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .45; z-index: 0; }
.ln.is-pending::before { background: var(--rule); opacity: 1; }
.ln-n { position: relative; z-index: 1; width: var(--dot); height: var(--dot); border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 2px solid var(--accent); color: var(--accent); font-weight: 600; font-size: .95rem; align-self: start; }
.ln.is-pending .ln-n { border-color: var(--rule); color: var(--ink-2); }
.ln.is-review .ln-n { border-style: dashed; border-color: var(--ink-2); }
.ln.is-done .ln-n { background: var(--accent); color: var(--on-accent); }
.ln-t { font-family: var(--font-text); font-size: 1.15rem; line-height: 1.7; }
html[lang="en"] .ln-t { font-size: 1.08rem; }
.ln-t a { color: var(--ink); text-decoration: none; }
.ln-t a:hover { color: var(--accent); text-decoration: underline; }
.ln-en { display: block; font-family: var(--font-ui); font-size: .9rem; color: var(--ink-2); }
.ln.is-pending .ln-t { color: var(--ink-2); }
.pend { font-family: var(--font-ui); font-size: .78rem; color: var(--ink-2); border: 1px dashed var(--rule); padding: 0 .35rem; white-space: nowrap; }
.is-review .pend { border-color: var(--ink-2); }
.cys { grid-column: 2; display: flex; flex-wrap: wrap; gap: .3rem .45rem; align-items: center; margin-top: .25rem; }
.cy { display: inline-flex; align-items: center; gap: .35rem; min-height: 34px; padding: 0 .55rem; border: 1px solid var(--rule); color: var(--ink-2); font-size: .82rem; text-decoration: none; }
.cy::before { content: ""; width: .7rem; height: .7rem; border: 1.5px solid var(--accent); flex: none; }
.cy:hover { border-color: var(--accent); color: var(--accent); }
.cy.is-done { color: var(--ink); border-color: var(--accent); }
.cy.is-done::before { background: var(--accent); }
.cy.is-next { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.qz-score { font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
@media (min-width: 860px) {
  .ln { grid-template-columns: var(--dot) minmax(0, 1fr) auto; }
  .cys { grid-column: 3; margin: 0; justify-content: flex-end; }
}
.sf-chip { display: inline-flex; align-items: center; gap: .35rem; min-height: 34px; padding: 0 .55rem; border: 1px solid var(--accent); color: var(--accent); font-size: .82rem; font-weight: 600; text-decoration: none; }
.sf-chip::before { content: ""; width: .9rem; height: .55rem; flex: none; background: linear-gradient(90deg, var(--accent) 0 2px, transparent 2px 5px, var(--accent) 5px 7px, transparent 7px 10px, var(--accent) 10px 12px, transparent 12px); }
.sf-chip:hover { background: var(--accent); color: var(--on-accent); }
.sf-chip:hover::before { filter: brightness(0) invert(1); }

/* ---------- your path ---------- */
.path-on { font-family: var(--font-ui); font-weight: 600; color: var(--m, var(--ink)); margin: -.6rem 0 .6rem; }
.path-next { margin: 0 0 2rem; }
.pk { padding: 1.4rem 0 .6rem; border-top: 1px solid var(--ink); }
.pk h2 { font-family: var(--font-display); font-size: clamp(1.5rem, 1.25rem + 1vw, 2rem); color: var(--accent); margin: 0 0 .6rem; }
html[lang="en"] .pk h2 { font-family: var(--font-ui); }
.ps-list { list-style: none; margin: 0; padding: 0; counter-reset: ps; }
.ps { counter-increment: ps; padding: .4rem 0 1.1rem; }
.ps-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; margin: 0 0 .35rem; }
.ps-h b { font-family: var(--font-text); font-size: 1.25rem; }
.ps-h b::before { content: counter(ps, arabic-indic) " "; color: var(--accent); font-family: var(--font-display); font-size: 1.5rem; margin-inline-end: .2rem; }
html[lang="en"] .ps-h b::before { content: counter(ps) " "; font-family: var(--font-ui); }
.ps-n { font-family: var(--font-ui); font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ps-bar { display: block; height: 4px; background: var(--paper-3); margin: 0 0 .5rem; }
.ps-bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.ps.is-done .ps-h b { color: var(--accent); }
.pl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0 1.6rem; }
@media (min-width: 700px) { .pl-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pl a { display: flex; align-items: baseline; gap: .6rem; padding: .32rem 0; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); font-family: var(--font-text); line-height: 1.65; min-height: 44px; }
.pl a:hover { color: var(--accent); }
.pl-box { flex: none; width: .85rem; height: .85rem; border: 1.5px solid var(--accent); transform: translateY(.1rem); }
.pl.is-done .pl-box { background: var(--accent); }
.pl.is-done a { color: var(--ink-2); }
.pl.is-next a { color: var(--accent); font-weight: 700; }
.pl.is-next .pl-box { outline: 3px solid var(--accent-soft); }
.ps-matn { margin: .6rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .92rem; }
.ps-matn a { color: var(--m); font-weight: 600; }
.go-btn .go-k { display: block; }

/* ---------- lesson page ---------- */
.lesson { max-width: 46rem; margin: 0 auto; padding: 1.2rem 16px 3rem; }
.ls-head { padding: 1rem 0 0; }
.ls-k { font-size: .92rem; color: var(--ink-2); margin: 0 0 .2rem; }
.ls-k a { color: var(--ink-2); }
.ls-head h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.9rem); margin: 0 0 .6rem; }
.ls-usul { font-size: .92rem; color: var(--ink-2); }
.ls-prog { font-size: .92rem; color: var(--ink-2); }
.en-intro { margin: .4rem 0 .8rem; padding: .1rem 1rem; border-inline-start: 3px solid var(--accent); }
.en-intro > summary { cursor: pointer; list-style: none; min-height: 44px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .8rem; padding-top: .3rem; }
.en-intro > summary::-webkit-details-marker { display: none; }
.en-title { font-size: 1.15rem; font-weight: 600; }
.en-more { font-size: .85rem; color: var(--accent); text-decoration: underline; text-underline-offset: .2em; }
.en-intro[open] .en-more { display: none; }
.en-summary { margin: .3rem 0 .6rem; color: var(--ink-2); line-height: 1.65; }
html[lang="en"] .matn-h { font-family: var(--font-ui) !important; font-weight: 600; font-size: 1.45rem; }
.ls-acts { display: flex; flex-wrap: wrap; gap: .5rem; margin: .9rem 0 0; }
.lesson { --navh: 43px; }
.ls-nav { position: sticky; top: 0; z-index: 12; background: var(--paper); border-bottom: 1px solid var(--ink); margin: 1rem 0 0; transition: transform .18s ease-out; }
.ls-nav ol { list-style: none; margin: 0; padding: 0; display: flex; }
.ls-nav li { flex: 1 1 0; min-width: 0; }
.ls-nav a { display: flex; align-items: center; justify-content: center; gap: .3rem; min-height: 42px; padding: 0 .3rem; color: var(--ink); text-decoration: none; font-weight: 500; text-align: center; line-height: 1.3; }
.ls-nav a:hover, .ls-nav a.is-cur { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.ls-nav a.is-done::after { content: ""; width: .45rem; height: .45rem; background: var(--accent); flex: none; }
/* reading down, the tabs tuck away and the contents bar takes the top; the first move up brings them back */
.nav-tuck .ls-nav { transform: translateY(-101%); }
.nav-tuck .ls-toc.is-live:not(.side) { top: 0; }
.ls-toc.is-live { transition: top .18s ease-out; }
.ls-sec { padding: 1.6rem 0 1rem; scroll-margin-top: 3.2rem; }
.ls-h { font-size: clamp(1.4rem, 1.2rem + 1vw, 1.85rem); display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; padding-bottom: .3rem; border-bottom: 1px solid var(--rule); }
.ls-h small { font-family: var(--font-ui); font-size: .8rem; font-weight: 500; color: var(--accent); }
.ls-body, .ch-body, .matn-body { font-family: var(--font-text); font-size: var(--fs-body); line-height: 2.05; }
.ch-body h2 { margin-top: 2rem; font-size: 1.55rem; padding-bottom: .2rem; border-bottom: 1px solid var(--rule); }
.ch-body h3 { margin-top: 1.5rem; font-size: 1.28rem; }
.ch-body h2, .ch-body h3, .blk[id], .anc, .tree { scroll-margin-top: 4rem; }
.js .ch-body h2, .js .ch-body h3, .js .sharh-body .blk[id], .js .sharh-body .anc, .js .sharh-body .tree { scroll-margin-top: calc(var(--navh) + 56px); }
.sifa-go { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; font-family: var(--font-ui); font-size: .92rem; margin: .4rem 0 1rem; }
.ch-body ol, .matn-body ol { list-style-type: arabic-indic; padding-inline-start: 1.8rem; }
html[lang="en"] .ch-body ol, html[lang="en"] .matn-body ol { list-style-type: arabic-indic; }
.ch-body table { border-collapse: collapse; width: 100%; margin: 1rem 0 1.4rem; font-size: .95em; line-height: 1.7; display: block; overflow-x: auto; }
.ch-body th, .ch-body td, .blk-haykal th, .blk-haykal td { border: 1px solid var(--rule); padding: .4rem .65rem; text-align: start; vertical-align: top; }
.ch-body th, .blk-haykal th { background: var(--paper-2); font-weight: 700; }
.ch-body blockquote { margin: 1rem 0; padding: .2rem 1rem; border-inline-start: 3px solid var(--rule); }
.footnote { font-size: .92em; color: var(--ink-2); border-top: 1px solid var(--rule); margin-top: 2.5rem; padding-top: .5rem; }
.footnote hr { display: none; }
a.footnote-ref { text-decoration: none; font-size: .8em; padding: 0 .1em; }
.xref-pending { border-bottom: 1px dashed var(--ink-2); }
.usul-link::after { content: "↗"; font-family: var(--font-ui); font-size: .75em; margin-inline-start: .15em; }
/* the commentary's contents: without JS a plain list; with JS a sticky bar under the tabs that
   opens downward on narrow screens, and a sticky side column at 1300px and wider */
.ls-toc { margin: .8rem 0 1rem; border-bottom: 1px solid var(--rule); }
.toc-h { font-family: var(--font-ui); font-size: .9rem; font-weight: 600; color: var(--ink-2); margin: .4rem 0 .2rem; }
.ls-toc ol { list-style: none; margin: 0 0 .8rem; padding: 0; font-family: var(--font-text); line-height: 1.7; }
.ls-toc a { color: var(--ink); text-decoration: none; display: block; padding: .25rem 0; padding-inline-start: .6rem; border-inline-start: 3px solid transparent; }
.ls-toc a:hover { color: var(--accent); }
.ls-toc a.is-cur { color: var(--accent); border-inline-start-color: var(--accent); font-weight: 700; }
.ls-toc .toc-3 a { padding-inline-start: 1.6rem; color: var(--ink-2); font-size: .95em; }
.ls-toc .toc-3 a.is-cur { color: var(--accent); }
.ls-toc .toc-l3 a::after { content: " ·  ٣"; color: var(--accent); font-family: var(--font-ui); font-size: .8em; }
.toc-btn { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 46px; padding: 0 .1rem; border: 0; background: none; cursor: pointer; text-align: start; color: var(--ink); }
.toc-btn::after { content: ""; width: .55rem; height: .55rem; border-inline-end: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); margin-inline-start: auto; flex: none; transition: transform .15s; }
.ls-toc.open .toc-btn::after { transform: rotate(-135deg); }
.toc-k { font-family: var(--font-ui); font-size: .82rem; font-weight: 600; color: var(--accent); flex: none; }
.toc-cur { font-family: var(--font-text); font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ls-toc.is-live { position: sticky; top: var(--navh); z-index: 11; background: var(--paper); margin: 0 0 1rem; }
.ls-toc.is-live .toc-h { display: none; }
.ls-toc.is-live:not(.side) ol { display: none; }
.ls-toc.is-live.open ol { display: block; position: absolute; inset-inline: 0; top: 100%; margin: 0; padding: .3rem 0 .6rem; max-height: min(65vh, 34rem); overflow: auto; background: var(--paper); border-bottom: 1px solid var(--ink); }
#sharh { position: relative; }
@media (min-width: 1300px) {
  .ls-toc.is-live.side { position: absolute; top: 4.2rem; bottom: 0; inset-inline-end: calc(-15rem - 2.5rem); width: 15rem; margin: 0; border: 0; background: none; z-index: 1; }
  .ls-toc.side .toc-btn { display: none; }
  .ls-toc.side .toc-h { display: block; position: sticky; top: calc(var(--navh) + .8rem); margin: 0; background: var(--paper); }
  .ls-toc.side ol { position: sticky; top: calc(var(--navh) + 2.6rem); max-height: calc(100vh - var(--navh) - 4rem); overflow: auto; font-size: .95rem; line-height: 1.6; border-inline-start: 1px solid var(--rule); }
  .ls-toc.side a { border-inline-start-width: 2px; margin-inline-start: -1px; }
  .js .ch-body h2, .js .ch-body h3, .js .sharh-body .blk[id], .js .sharh-body .anc, .js .sharh-body .tree { scroll-margin-top: calc(var(--navh) + 1rem); }
}

/* blocks: a label, a rule, no boxes */
.blk { margin: 1.5rem 0; padding: .1rem 0 .1rem; padding-inline-start: 1rem; border-inline-start: 3px solid var(--rule); }
.blk > :last-child { margin-bottom: 0; }
.blk-head { font-family: var(--font-ui); margin: 0 0 .4rem; line-height: 1.5; display: flex; flex-wrap: wrap; gap: .1rem .6rem; align-items: baseline; }
.blk-type { font-size: .8rem; font-weight: 600; color: var(--accent); }
.blk-title { font-family: var(--font-text); font-weight: 700; font-size: 1.1rem; color: var(--ink); }
a.blk-title { text-decoration: none; }
a.blk-title:hover { color: var(--accent); text-decoration: underline; }
.blk-sura { border-inline-start-color: var(--accent); }
.ls-body > .blk-sura { font-size: 1.08em; }
.blk-muftaraq { border-inline-start-color: var(--ink); }
.blk-dabit { border-inline-start-color: var(--accent); }
.blk-farq { border-inline-start-style: double; border-inline-start-width: 5px; }
.blk-tanbih { border-inline-start-style: dashed; }
.blk-nazila { border-inline-start-color: var(--ink-2); border-inline-start-style: dotted; border-inline-start-width: 4px; }
.blk-matn blockquote { font-family: var(--font-display); font-size: 1.25em; line-height: 2.1; border: 0; padding: 0; margin: .3rem 0 .8rem; }
.blk[data-m] { border-inline-start-color: var(--m); }
.blk[data-m] .blk-type { color: var(--m); }

/* muftaraq: one line per school, the reader's first; the others fold */
.blk-muftaraq ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.mline { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: .1rem .9rem; padding: .4rem 0; border-top: 1px solid var(--rule); align-items: baseline; }
.mline:first-child { border-top: 0; }
.mline > p { margin: 0; display: contents; }
.mf-x { min-width: 0; }
.mf-x > p { margin: 0; }
.mf-x > p + p { margin-top: .4rem; }
.mf-l { font-family: var(--font-ui); font-weight: 600; font-size: .9rem; color: var(--m, var(--ink-2)); display: inline-flex; align-items: baseline; gap: .4rem; }
.ms .mf-l::before { content: ""; width: .65rem; height: .65rem; background: var(--m); flex: none; align-self: center; }
.mline.m-maliki.m-shafii .mf-l::before, .mline.m-hanafi.m-maliki .mf-l::before, .mline.m-hanafi.m-shafii .mf-l::before { background: linear-gradient(90deg, var(--c1) 0 50%, var(--c2) 50%); }
.mline.m-maliki.m-shafii { --c1: var(--m-maliki); --c2: var(--m-shafii); --m: var(--ink); }
.mline.m-hanafi.m-maliki { --c1: var(--m-hanafi); --c2: var(--m-maliki); --m: var(--ink); }
.mline.m-hanafi.m-shafii { --c1: var(--m-hanafi); --c2: var(--m-shafii); --m: var(--ink); }
.mx-sabab .mf-l, .mx-makhadh .mf-l { color: var(--accent); }
.mx { order: 2; }
@media (max-width: 559px) { .mline { grid-template-columns: 1fr; } }
html[data-m="hanafi"] .mline.m-hanafi, html[data-m="maliki"] .mline.m-maliki, html[data-m="shafii"] .mline.m-shafii { order: -1; border-top: 0; background: color-mix(in srgb, var(--m-mine) 8%, transparent); margin-inline-start: calc(-1rem - 3px); padding-inline-start: calc(1rem - 3px); border-inline-start: 6px solid var(--m-mine); }
html[data-m="hanafi"] { --m-mine: var(--m-hanafi); }
html[data-m="maliki"] { --m-mine: var(--m-maliki); }
html[data-m="shafii"] { --m-mine: var(--m-shafii); }
html.js[data-m="hanafi"] .blk-muftaraq:not(.show-all):not(.k-muttafaq) .ms:not(.m-hanafi),
html.js[data-m="maliki"] .blk-muftaraq:not(.show-all):not(.k-muttafaq) .ms:not(.m-maliki),
html.js[data-m="shafii"] .blk-muftaraq:not(.show-all):not(.k-muttafaq) .ms:not(.m-shafii) { display: none; }
/* agreed («متفق عليه»): every line stays open, the label in the accent */
.blk-muftaraq.k-muttafaq { border-inline-start-color: var(--accent); }
.mf-toggle { margin: .3rem 0 0; font-family: var(--font-ui); font-size: .9rem; }
.mf-toggle button { background: none; border: 0; padding: 0; min-height: 40px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: .2em; }
.mf-toggle .mf-hidden { color: var(--ink-2); margin-inline-start: .4rem; }

/* blocks of another school fold to their heading for a reader who chose a school */
.blk.is-folded > :not(.blk-head) { display: none; }
.blk-fold { background: none; border: 0; padding: 0 .2rem; min-height: 32px; color: var(--accent); cursor: pointer; font-size: .85rem; text-decoration: underline; }

/* haykal: try, then reveal */
.haykal-wrap { margin: 1.5rem 0; }
.hk-try { font-family: var(--font-ui); font-size: .95rem; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.blk-haykal { border: 0; padding: 0; }
.blk-haykal table { border-collapse: collapse; width: 100%; font-size: .95em; line-height: 1.7; }
.hk-count { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.hk-hidden td.hc:not(.hc-empty) { color: transparent; background: repeating-linear-gradient(-45deg, var(--paper-2) 0 6px, var(--paper) 6px 12px); cursor: pointer; user-select: none; position: relative; min-height: 2.6rem; }
.hk-hidden td.hc:not(.hc-empty) > * { visibility: hidden; }
.hk-hidden td.hc:not(.hc-empty):not(.is-shown)::after { content: "؟"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent); font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; visibility: visible; }
html[lang="en"] .hk-hidden td.hc:not(.hc-empty):not(.is-shown)::after { content: "?"; }
.hk-hidden td.hc:not(.is-shown):hover, .hk-hidden td.hc:not(.is-shown):focus-visible { background: var(--accent-soft); }
.hk-hidden td.hc.is-shown { color: inherit; background: none; cursor: default; animation: hk-in .25s ease-out; }
.hk-hidden td.hc.is-shown > * { visibility: visible; }
@keyframes hk-in { from { background: var(--accent-soft); } to { background: transparent; } }
@media (max-width: 639px) { .hk-hidden td.hc:not(.hc-empty) { min-height: 3rem; } .hk-hidden td.hc:not(.hc-empty):not(.is-shown)::after { place-items: center start; padding-inline-start: 7.5rem; } }
html[data-m="hanafi"] .blk-haykal [data-m="hanafi"], html[data-m="maliki"] .blk-haykal [data-m="maliki"], html[data-m="shafii"] .blk-haykal [data-m="shafii"] { box-shadow: inset 0 3px 0 var(--m); }
html[data-m="hanafi"] .blk-haykal th[data-m="hanafi"], html[data-m="maliki"] .blk-haykal th[data-m="maliki"], html[data-m="shafii"] .blk-haykal th[data-m="shafii"] { color: var(--m); }
@media (max-width: 639px) {
  .blk-haykal table, .blk-haykal tbody, .blk-haykal tr, .blk-haykal td { display: block; width: 100%; }
  .blk-haykal thead { display: none; }
  .blk-haykal tr { display: flex; flex-direction: column; border-top: 1px solid var(--ink); padding: .4rem 0 .6rem; }
  .blk-haykal td { border: 0; padding: .15rem 0; }
  .blk-haykal td:first-child { font-weight: 700; }
  .blk-haykal td[data-h]::before { content: attr(data-h) ": "; font-family: var(--font-ui); font-size: .82rem; font-weight: 600; color: var(--m, var(--ink-2)); }
  html[data-m="hanafi"] .blk-haykal td[data-m="hanafi"], html[data-m="maliki"] .blk-haykal td[data-m="maliki"], html[data-m="shafii"] .blk-haykal td[data-m="shafii"] { order: -1; box-shadow: none; border-inline-start: 4px solid var(--m); padding-inline-start: .5rem; }
  html[data-m] .blk-haykal td:first-child { order: -2; }
}

/* the matn: the first reading surface of a lesson. The reader's school in large Naskh, the
   proposition numbers rubricated in the margin, «الحل» and «صورة» as glosses under their proposition.
   The other two schools are a small switch above it. */
.mt-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .3rem; margin: .4rem 0 .6rem; font-family: var(--font-ui); font-size: .88rem; }
.mt-l { color: var(--ink-2); margin-inline-end: .2rem; }
.mt-tab { min-height: 40px; padding: 0 .7rem; border: 1px solid var(--rule); background: none; cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.mt-tab:hover { border-color: var(--m); color: var(--m); }
.mt-tab[aria-selected="true"] { color: var(--paper); background: var(--m); border-color: var(--m); }
.matn-panel { padding: .2rem 0 .6rem; }
.matn-k { font-family: var(--font-ui); font-size: .8rem; font-weight: 500; color: var(--accent); margin: .6rem 0 0; }
.matn-h { font-family: var(--font-display) !important; font-size: clamp(1.7rem, 1.35rem + 1.3vw, 2.2rem); color: var(--m); margin: 0 0 .5rem; line-height: 1.45; }
/* with the switch in place, the section's own heading gives way to the school's («متن المالكية») */
.js .ls-matn.mt-ready > .ls-h { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.js .ls-matn.mt-ready { padding-top: .9rem; }
.ls-matn .mt-tabs { justify-content: flex-end; margin: 0; }
.ls-matn .mt-tab { min-height: 36px; padding: 0 .55rem; font-size: .84rem; }
.matn-src { font-size: .85rem; color: var(--ink-2); margin: .8rem 0 0; }
.matn-body { font-size: var(--fs-matn); line-height: 2.15; }
.matn-body > p { margin: 0 0 .9em; }
.matn-body ol { padding-inline-start: 2.6rem; margin: 0 0 1em; }
.matn-body ol > li { padding: .15rem 0 .55rem; }
.matn-body ol > li::marker { font-family: var(--font-display); font-weight: 700; font-size: 1.15em; color: var(--accent); }
.matn-body ol > li:target, .matn-body .anc:target { background: var(--accent-soft); }
.gl { display: block; margin: .35rem 0 0; padding-inline-start: .8rem; border-inline-start: 2px solid var(--rule); font-size: .82em; line-height: 1.95; color: var(--ink-2); }
.gl-k { font-family: var(--font-ui); font-size: .78em; font-weight: 600; color: var(--accent); margin-inline-end: .35rem; }
.gl-sura { border-inline-start-style: dotted; }
.matn-all-link { margin: .5rem 0 0; font-size: .9rem; font-family: var(--font-ui); }
.ls-matn .cy-done { margin-top: 1rem; }

/* cycle marks */
.cy-done { margin: 1.6rem 0 .4rem; padding-top: 1rem; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; }
.cy-done + .cy-done { margin-top: .4rem; border-top: 0; padding-top: 0; }
.cy-mark[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.cy-mark[aria-pressed="true"]::before { content: "✓"; font-weight: 700; }
.cy-msg { font-size: .9rem; color: var(--ink-2); }

/* cycle three and answers: folded */
details.sec { margin: 2rem 0 0; border-top: 1px solid var(--ink); }
details.sec > summary { cursor: pointer; list-style: none; padding-top: .6rem; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary h2 { margin: .1rem 0 .4rem; border: 0; display: inline; }
details.sec > summary::after { content: "+"; float: inline-end; font-family: var(--font-ui); font-size: 1.4rem; color: var(--accent); line-height: 1; }
details.sec[open] > summary::after { content: "−"; }
.tq-k { display: block; font-family: var(--font-ui); font-size: .8rem; font-weight: 600; color: var(--accent); }
details.tahqiq { border-top: 2px solid var(--accent); }

/* glossary popovers */
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: help; text-decoration: underline dotted var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: .35em; line-height: inherit; }
.term:hover { color: var(--accent); }
.term-pop { margin: 0; inset: auto; max-width: min(22rem, calc(100vw - 32px)); padding: .8rem 1rem; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); font-family: var(--font-text); font-size: 1rem; line-height: 1.8; position: fixed; }
.term-pop:not(:popover-open) { display: none; }
.term-pop:popover-open { display: block; }
.pop-term { display: block; font-size: 1.15rem; }
.pop-en { display: block; font-family: var(--font-ui); font-size: .85rem; color: var(--ink-2); }
.pop-m { margin: .2rem 0 .3rem; }
.pop-def { display: block; }
.pop-more { display: inline-block; margin-top: .4rem; font-family: var(--font-ui); font-size: .85rem; }

/* decision trees */
.tree { margin: 2rem 0; padding: 1rem 0; border-top: 2px solid var(--accent); border-bottom: 1px solid var(--rule); }
.tree-note { font-family: var(--font-ui); font-size: .88rem; color: var(--ink-2); padding-inline-start: .7rem; border-inline-start: 3px solid var(--accent); }
/* the trees page says it once in its header; each tree keeps it for the printed card */
@media screen { .p-trees .tree .tree-note { display: none; } }
.tree-title { font-size: 1.4rem; margin: .4rem 0; }
.tree-from, .tree-intro { color: var(--ink-2); }
.ts-h { font-family: var(--font-ui); font-size: .85rem; font-weight: 600; color: var(--ink-2); margin: .6rem 0 .3rem; }
.ts h4 { font-family: var(--font-ui); font-size: .95rem; color: var(--m, var(--ink)); margin: .8rem 0 .3rem; }
.ts[data-ms^="hanafi"] { --m: var(--m-hanafi); }
.ts[data-ms^="maliki"] { --m: var(--m-maliki); }
.ts[data-ms^="shafii"] { --m: var(--m-shafii); }
.ts-body { font-family: var(--font-text); line-height: 1.9; }
.ts-body ul { list-style: none; margin: 0 0 .3rem; padding-inline-start: 1.2rem; border-inline-start: 1px solid var(--rule); }
.ts-body .tq { margin: .2rem 0; font-weight: 700; }
.ts-body .ta { font-family: var(--font-ui); font-size: .85rem; font-weight: 600; color: var(--accent); margin-inline-end: .4rem; }
.ts-body .ta::after { content: " ←"; }
html[dir="ltr"] .ts-body .ta::after { content: " →"; }
.tl-hukm { margin: .2rem 0; padding-inline-start: .6rem; border-inline-start: 3px solid var(--m, var(--accent)); }
.tl-link { font-family: var(--font-ui); font-size: .85rem; white-space: nowrap; }
.tl-note { display: block; color: var(--ink-2); font-size: .95em; }
.js .tree.is-live .tree-static { display: none; }
.tree-live { font-family: var(--font-text); }
.tr-ms { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--rule); margin: .6rem 0 1rem; font-family: var(--font-ui); }
.tr-ms button { flex: 1 1 0; min-height: 44px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; color: var(--ink-2); font-weight: 600; }
.tr-ms button[aria-pressed="true"] { color: var(--m); border-bottom-color: var(--m); }
.tr-path { list-style: none; margin: 0 0 .6rem; padding: 0; font-size: .95rem; color: var(--ink-2); }
.tr-path li { padding: .15rem 0; }
.tr-path b { color: var(--accent); font-family: var(--font-ui); font-size: .85rem; margin-inline-start: .3rem; }
.tr-q { font-size: clamp(1.25rem, 1.1rem + .8vw, 1.6rem); font-weight: 700; line-height: 1.8; margin: .4rem 0 .8rem; }
.tr-ans { display: flex; flex-wrap: wrap; gap: .6rem; }
.tr-ans button { min-height: 48px; min-width: 6rem; padding: .3rem 1.2rem; border: 1px solid var(--ink); background: var(--paper); cursor: pointer; font-family: var(--font-text); font-size: 1.1rem; }
.tr-ans button:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 559px) { .tr-ans button { flex: 1 1 100%; text-align: start; } }
.tr-leaf { margin: .6rem 0; padding: .6rem 1rem; border-inline-start: 6px solid var(--m, var(--accent)); background: color-mix(in srgb, var(--m, var(--accent)) 7%, transparent); font-size: 1.15rem; line-height: 1.9; }
.tr-leaf a { font-family: var(--font-ui); font-size: .92rem; }
.tr-ctl { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; font-family: var(--font-ui); }
.tree-tools { margin: .8rem 0 0; }
.tree-index ol { font-family: var(--font-text); line-height: 1.9; }
html[lang="ar"] .tree-index ol, html[lang="ar"] .quiz-static, html[lang="ar"] .opts-static { list-style-type: arabic-indic; }

/* quizzes */
.qz-filter { margin: .4rem 0; font-size: .92rem; }
.quiz-static { padding-inline-start: 1.4rem; }
.quiz-static > li { padding: .6rem 0; border-top: 1px solid var(--rule); }
.quiz-static .m-tag { margin-bottom: .3rem; }
.opts-static { font-family: var(--font-text); }
.qz { list-style: none; margin: 0; padding: 0; counter-reset: qz; }
.qz-item { padding: 1rem 0; border-top: 1px solid var(--rule); counter-increment: qz; }
.qz-q { font-family: var(--font-text); font-size: 1.12rem; line-height: 1.9; font-weight: 600; }
.qz-q::before { content: counter(qz, arabic-indic) ". "; color: var(--accent); }
html[lang="en"] .qz-q::before { content: counter(qz) ". "; }
.qz-opts { display: grid; gap: .45rem; }
.qz-opts button { text-align: start; min-height: 46px; padding: .4rem .9rem; border: 1px solid var(--rule); background: var(--paper); cursor: pointer; font-family: var(--font-text); font-size: 1.02rem; line-height: 1.7; }
.qz-opts button:hover:not(:disabled) { border-color: var(--accent); }
.qz-opts button:disabled { cursor: default; color: var(--ink-2); }
.qz-opts .is-right { border: 2px solid var(--m-maliki); color: var(--ink) !important; }
.qz-opts .is-right::before { content: "✓ "; color: var(--m-maliki); font-weight: 700; }
.qz-opts .is-wrong { border: 2px solid var(--m-hanafi); color: var(--ink) !important; }
.qz-opts .is-wrong::before { content: "✗ "; color: var(--m-hanafi); font-weight: 700; }
.qz-opts .is-picked { box-shadow: inset 0 0 0 1px currentColor; }
.qz-fb { margin-top: .7rem; padding: .5rem .95rem .6rem; border-inline-start: 4px solid var(--accent); background: var(--accent-soft); font-family: var(--font-text); line-height: 1.95; }
.qz-fb p { margin: 0 0 .35rem; }
.qz-fb p:last-child { margin: 0; }
.qz-fb.is-ok { border-inline-start-color: var(--m-maliki); background: color-mix(in srgb, var(--m-maliki) 8%, var(--paper)); }
.qz-fb.is-bad { border-inline-start-color: var(--m-hanafi); background: color-mix(in srgb, var(--m-hanafi) 7%, var(--paper)); }
.qz-verdict { font-family: var(--font-ui); font-weight: 700; font-size: 1rem; }
.qz-fb.is-ok .qz-verdict { color: var(--m-maliki); }
.qz-fb.is-bad .qz-verdict { color: var(--m-hanafi); }
.qz-verdict::before { content: "✓ "; }
.qz-fb.is-bad .qz-verdict::before { content: "✗ "; }
.qz-fb b { font-family: var(--font-ui); font-size: .85rem; font-weight: 600; margin-inline-end: .25rem; }
.qz-why b { color: var(--accent); }
.qz-err { display: block; color: var(--ink-2); }
.qz-go { font-family: var(--font-ui); font-size: .9rem; }
.qz-gate { margin: .6rem 0; padding: .6rem 1rem; border: 1px solid var(--accent); font-weight: 600; }
.qz-gate.is-ok { border-color: var(--m-maliki); color: var(--m-maliki); }
.qz-gate.is-bad { border-color: var(--m-hanafi); color: var(--ink); }
.qz-item .m-tag { margin-bottom: .3rem; }
.qz-total { font-weight: 600; margin: 1rem 0 .5rem; }

/* compare and gathering pages */
.filters { display: grid; gap: .7rem; margin-bottom: 1.4rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
.filters label { display: flex; flex-direction: column; gap: .2rem; font-size: .88rem; color: var(--ink-2); min-width: 0; }
.filters input[type="search"], .filters select, .quiz-pick select { min-height: 44px; padding: .3rem .6rem; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); font-size: 1rem; width: 100%; max-width: 100%; }
.f-count { margin: 0; align-self: end; color: var(--ink-2); }
.f-more { display: grid; gap: .7rem; min-width: 0; }
.f-toggle.is-set { border-color: var(--accent); color: var(--accent); font-weight: 600; }
@media (max-width: 759px) {
  .filters.f-ready { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .5rem .5rem; }
  .filters.f-ready .f-more { grid-column: 1 / -1; display: none; grid-template-columns: 1fr; }
  .filters.f-ready.f-open .f-more { display: grid; }
  .filters.f-ready .f-count { grid-column: 1 / -1; font-size: .88rem; }
  .filters.f-ready .f-search > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (min-width: 760px) {
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
  .f-more { display: contents; }
  .f-toggle { display: none !important; }
}
.cmp-list { display: grid; gap: 1.8rem; }
.cmp { border-top: 1px solid var(--ink); padding-top: .6rem; }
.mq-note p { margin: .2rem 0; }
/* 700+ cards: the browser lays out only those near the screen */
@media screen { .cmp { content-visibility: auto; contain-intrinsic-size: auto 340px; } }
.cmp-meta { font-size: .85rem; color: var(--ink-2); margin: 0 0 .1rem; }
.cmp h2 { font-size: 1.35rem; margin: 0 0 .5rem; }
.cmp-en { color: var(--ink-2); margin-top: -.3rem; }
.kind { font-weight: 600; color: var(--accent); }
.positions { display: grid; gap: .6rem 1.4rem; }
@media (min-width: 760px) { .positions { grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); } }
.pos { border-top: 3px solid var(--m); padding-top: .3rem; min-width: 0; }
.pos-h { font-weight: 600; color: var(--m); margin: 0 0 .1rem; font-size: .92rem; }
.pos-t { font-family: var(--font-text); line-height: 1.85; margin: 0 0 .3rem; }
.pos-src { font-size: .85rem; color: var(--ink-2); margin: 0; }
html[data-m="hanafi"] .positions .pos[data-m="hanafi"], html[data-m="maliki"] .positions .pos[data-m="maliki"], html[data-m="shafii"] .positions .pos[data-m="shafii"] { order: -1; border-top-width: 6px; }
.cmp-sabab, .cmp-links { margin: .6rem 0 0; font-size: .95rem; }
.cmp-sabab span { font-family: var(--font-text); }
.m-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin: 0 0 1.2rem; font-size: .9rem; color: var(--ink-2); }
.m-filter button { min-height: 40px; padding: 0 .7rem; border: 1px solid var(--rule); background: none; cursor: pointer; color: var(--m, var(--ink)); }
.m-filter button[aria-pressed="true"] { border-color: var(--m, var(--ink)); box-shadow: inset 0 -3px 0 var(--m, var(--ink)); font-weight: 600; }
.g-sec { margin-bottom: 2rem; }
.g-sec h2 { font-size: 1.3rem; border-bottom: 1px solid var(--rule); padding-bottom: .2rem; }
.g-sec h2 a { color: var(--ink); text-decoration: none; }
.g-item [lang="ar"] { font-family: var(--font-text); }
.qaida { padding: 1rem 0; border-top: 1px solid var(--ink); }
.qaida h2 { font-size: 1.6rem; color: var(--accent); margin: 0; }
.q-en { color: var(--ink-2); }
.q-list { font-family: var(--font-text); line-height: 1.9; }
.q-les { font-family: var(--font-ui); font-size: .82rem; color: var(--ink-2); }

/* glossary */
.letters ul { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.letters a { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; border: 1px solid var(--rule); text-decoration: none; font-family: var(--font-text); font-size: 1.1rem; color: var(--ink); }
.letters a:hover { border-color: var(--accent); color: var(--accent); }
.g-letter h2 { font-size: 1.8rem; color: var(--accent); border-bottom: 1px solid var(--rule); }
.g-letter dl { margin: 0; }
.g-letter .g-item { padding: .7rem 0; border-bottom: 1px solid var(--rule); scroll-margin-top: 1rem; }
.g-letter dt { font-family: var(--font-text); font-size: 1.25rem; font-weight: 700; display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; }
.g-en { font-family: var(--font-ui); font-size: .88rem; font-weight: 400; color: var(--ink-2); }
.g-letter dd { margin: 0; font-family: var(--font-text); line-height: 1.95; }
.g-where { font-family: var(--font-ui); font-size: .85rem; color: var(--ink-2); margin: 0; }

/* review */
.practice-grid { display: grid; gap: 2rem; }
@media (min-width: 980px) { .practice-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 3rem; } }
.cards-sec h2, .quiz-sec h2, .progress-tools h2 { font-size: 1.35rem; border-bottom: 1px solid var(--rule); padding-bottom: .2rem; }
.js .nojs-note { display: none; }
.fc-stats { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: flex-end; margin-bottom: .8rem; color: var(--ink-2); font-size: .9rem; }
.fc-stats b { color: var(--ink); font-size: 1.15rem; }
.boxes { display: inline-flex; gap: 3px; align-items: flex-end; height: 36px; }
.boxes span { width: 8px; background: var(--accent); }
.flashcard { border: 1px solid var(--ink); padding: 1.2rem; }
.fc-term { font-family: var(--font-display); font-size: 2rem; font-weight: 700; margin: 0; }
.fc-en { color: var(--ink-2); margin: 0 0 .4rem; }
.fc-def { font-family: var(--font-text); font-size: 1.15rem; line-height: 1.95; border-top: 1px solid var(--rule); padding-top: .6rem; }
.fc-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.quiz-pick { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .6rem; font-size: .9rem; color: var(--ink-2); }
.js .quiz-sec .quiz-static-wrap { display: none; }
.quiz-static-sec h3 { margin-top: 1.2rem; }
.progress-tools { margin-top: 2.5rem; }
.pt-msg { color: var(--ink-2); }

/* «الصفة»: the step is the subject. Without JS: the three schools as numbered lists.
   With JS: one step fills the screen, the school's term as a mark, controls at the thumb. */
.sifa { max-width: 52rem; margin: 0 auto; padding: 1rem 16px 2rem; }
.sf-k { margin: 0; font-size: .92rem; }
.sf-k a { color: var(--ink-2); }
.sf-head h1 { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.6rem); margin: 0 0 .4rem; }
.sf-intro { color: var(--ink-2); font-family: var(--font-text); }
.sf-intro p { margin: 0 0 .4rem; }
.sf-en { font-size: .9rem; }
.sf-school { --m: var(--ink); padding: 1rem 0 1.5rem; }
.sf-school.m-hanafi { --m: var(--m-hanafi); } .sf-school.m-maliki { --m: var(--m-maliki); } .sf-school.m-shafii { --m: var(--m-shafii); }
.sf-sh { color: var(--m); border-bottom: 3px solid var(--m); padding-bottom: .2rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; }
.sf-sh small { font-family: var(--font-ui); font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.sf-list { list-style: none; margin: 0; padding: 0; }
.sf-step { display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: .1rem .9rem; padding: .8rem 0; border-top: 1px solid var(--rule); }
.sf-step:first-child { border-top: 0; }
.sf-n { font-family: var(--font-display); font-size: 1.7rem; line-height: 1.2; color: var(--accent); font-weight: 700; text-align: center; }
html[lang="en"] .sf-n { font-family: var(--font-ui); font-weight: 600; }
.sf-body { min-width: 0; }
.sf-marks { display: flex; flex-wrap: wrap; gap: .35rem; margin: .15rem 0 .35rem; }
.sf-mark, .sf-in { display: inline-block; font-family: var(--font-ui); font-weight: 600; font-size: .85rem; line-height: 1.55; padding: 0 .55rem; border: 2px solid var(--accent); color: var(--accent); white-space: nowrap; }
.sf-mark.k-fard, .sf-in.k-fard { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.sf-mark.k-wajib, .sf-in.k-wajib { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sf-mark.k-fadila, .sf-in.k-fadila { border-style: dashed; }
.sf-mark.k-adab, .sf-in.k-adab { border-width: 1px; border-color: var(--ink-2); color: var(--ink-2); }
.sf-in { font-size: .72em; padding: 0 .4rem; vertical-align: .12em; margin: 0 .1rem; }
.sf-act { font-family: var(--font-text); font-size: 1.2rem; line-height: 1.9; margin: 0 0 .3rem; }
.sf-full { font-family: var(--font-text); color: var(--ink-2); margin: 0 0 .3rem; padding-inline-start: .7rem; border-inline-start: 2px solid var(--rule); }
.sf-link { font-size: .88rem; }
.sf-notes { margin-top: 1rem; padding: .3rem 0 .3rem 0; padding-inline-start: 1rem; border-inline-start: 3px solid var(--m); font-family: var(--font-text); line-height: 1.95; }
.sf-notes-h { font-family: var(--font-ui); font-size: .82rem; font-weight: 600; color: var(--m); margin: 0 0 .2rem; }
.sf-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; margin: 1.2rem 0 1rem; }
.sf-listbtn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.sf-hint { font-size: .85rem; }
.sf-ms { display: flex; border-bottom: 1px solid var(--rule); margin: .6rem 0 0; }
.sf-ms button { flex: 1 1 0; min-height: 46px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; color: var(--ink-2); font-weight: 600; }
.sf-ms button[aria-pressed="true"] { color: var(--m); border-bottom-color: var(--m); }
.sf-prog { height: 5px; background: var(--paper-3); margin: 0; }
.sf-prog span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease-out; }
.sifa[data-m="hanafi"] { --m: var(--m-hanafi); } .sifa[data-m="maliki"] { --m: var(--m-maliki); } .sifa[data-m="shafii"] { --m: var(--m-shafii); }

/* the viewer */
.sf-live { padding-top: .6rem; padding-bottom: 0; }
.sf-live .sf-intro { display: none; }
.sf-live.sf-all .sf-intro { display: block; }
.sf-live .sf-head h1 { font-size: clamp(1.25rem, 1rem + 1.4vw, 2rem); margin: 0; }
.sf-live:not(.sf-all) .sf-sh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sf-live:not(.sf-all) .sf-school { padding: 0; }
.sf-live:not(.sf-all) .sf-step:not(.is-cur) { display: none; }
.sf-live:not(.sf-all):not(.at-end) .sf-notes { display: none; }
.sf-live:not(.sf-all) .sf-step.is-cur {
  border: 0; outline: none; grid-template-columns: 1fr; align-content: center; justify-items: start; gap: .4rem;
  min-height: calc(100svh - 15.5rem); padding: 1.2rem 0 1.4rem;
}
.sf-live:not(.sf-all) .sf-n { font-size: clamp(5rem, 3rem + 14vw, 9.5rem); line-height: .95; text-align: start; color: var(--m); }
.sf-live:not(.sf-all) .sf-marks { margin: .2rem 0 .4rem; gap: .5rem; }
.sf-live:not(.sf-all) .sf-mark { font-size: clamp(1.05rem, .95rem + .6vw, 1.35rem); padding: .1rem .9rem; border-width: 2px; }
.sf-live:not(.sf-all) .sf-mark.k-adab { border-width: 2px; }
.sf-live:not(.sf-all) .sf-act { font-size: clamp(1.65rem, 1.1rem + 2.6vw, 2.75rem); line-height: 1.75; font-weight: 600; margin: 0 0 .5rem; }
.sf-live:not(.sf-all) .sf-full { font-size: clamp(1.05rem, .95rem + .5vw, 1.3rem); }
.sf-live:not(.sf-all) .sf-link { font-size: .95rem; }
.sf-live.sf-all .sf-step { cursor: pointer; }
.sf-live.sf-all .sf-step:hover { background: var(--paper-2); }
.sf-live.sf-all .sf-step.is-cur { background: color-mix(in srgb, var(--m) 8%, transparent); box-shadow: inset 4px 0 0 var(--m); }
html[dir="rtl"] .sf-live.sf-all .sf-step.is-cur { box-shadow: inset -4px 0 0 var(--m); }
.sf-ctl { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem;
  background: var(--paper); border-top: 1px solid var(--ink); padding: .55rem 0 calc(.55rem + env(safe-area-inset-bottom)); margin: 0 -16px; padding-inline: 16px; }
.sf-all .sf-ctl { display: none; }
.sf-ctl button { min-height: 54px; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; font-size: 1.05rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: 0 .8rem; }
.sf-ctl .sf-next { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
@media (hover: hover) {
  .sf-ctl button:hover:not(:disabled) { border-color: var(--accent); }
  .sf-ctl .sf-next:hover:not(:disabled) { background: var(--ink); border-color: var(--ink); color: var(--paper); }
}
.sf-ctl button:disabled { opacity: .35; cursor: default; }
.sf-ctl button span[aria-hidden] { font-size: 1.3rem; line-height: 1; }
.sf-count { margin: 0; font-size: .9rem; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 420px) { .sf-ctl .sf-bl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } .sf-ctl button span[aria-hidden] { font-size: 1.6rem; } }
@media (min-width: 760px) { .sf-live:not(.sf-all) .sf-step.is-cur { min-height: calc(100svh - 17rem); } .sf-ctl { margin: 0; padding-inline: 0; } }

/* book, about, corrections */
.book-list { list-style: none; margin: 0; padding: 0; }
.book-list li { padding: 1rem 0; border-top: 1px solid var(--ink); }
.book-list h2 { font-size: 1.3rem; }
.book-list li.m-hanafi h2, .book-list li.m-maliki h2, .book-list li.m-shafii h2 { color: var(--m); }
.about-text p { font-family: var(--font-text); font-size: 1.12rem; line-height: 2; }
html[lang="en"] .about-text p { font-family: var(--font-ui); line-height: 1.65; }
.nisba-grid { display: grid; gap: 1rem 2rem; }
@media (min-width: 760px) { .nisba-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.nisba h3 { color: var(--m, var(--ink)); border-bottom: 3px solid var(--m, var(--rule)); padding-bottom: .2rem; font-size: 1.15rem; }
.nisba ul { list-style: none; margin: 0; padding: 0; font-family: var(--font-text); line-height: 1.9; }
.hasm { font-family: var(--font-ui); font-size: .75rem; font-weight: 600; color: var(--accent); border: 1px solid var(--accent); padding: 0 .3rem; margin-inline-start: .3rem; }
.cr-list { list-style: none; padding: 0; }
.cr-list li { border-top: 1px solid var(--rule); padding: .8rem 0; }
.cr-h { font-weight: 600; }
.prevnext { display: grid; gap: .6rem; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.pn { display: flex; flex-direction: column; padding: .6rem 1rem; border: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.pn:hover { border-color: var(--accent); }
.pn span { font-size: .85rem; color: var(--ink-2); }
.pn b { font-family: var(--font-text); }
.pn-next { text-align: end; }
@media (min-width: 640px) { .prevnext { grid-template-columns: 1fr 1fr; } .pn-next { grid-column: 2; } }

/* the printable book pages */
.book { max-width: 48rem; }
.b-title { text-align: center; padding: 3rem 0 2rem; border-bottom: 1px solid var(--rule); margin-bottom: 2rem; }
.b-title-main { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; margin: 0; }
.b-title-sub { font-family: var(--font-text); color: var(--ink-2); font-size: 1.15rem; line-height: 1.9; }
.b-meta { margin-top: 2rem; color: var(--ink-2); }
.b-toc ol { list-style: none; padding: 0; font-family: var(--font-text); line-height: 1.9; }
.b-toc .toc-k { font-weight: 700; margin-top: .6rem; }
.b-toc a { display: flex; gap: .6rem; color: inherit; text-decoration: none; }
.b-toc .pg { margin-inline-start: auto; color: var(--ink-2); }
.b-toc .pg:empty { display: none; }
.b-part-h { text-align: center; font-size: 2rem; margin: 3rem 0 1.5rem; color: var(--accent); }
.b-ch-h { font-size: 2rem; margin-top: 2.5rem; padding-bottom: .3rem; border-bottom: 2px solid var(--accent); }
.p-print .tree-live, .p-print .tree-tools { display: none !important; }
.p-print .tree-static { display: block !important; }

/* ---------- the full matn ---------- */
.matn-index { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.matn-index li.is-mine { order: -1; }
.matn-index a { display: grid; gap: .1rem; padding: 1rem 0 1.1rem; padding-inline-start: 1rem; border-top: 1px solid var(--rule); border-inline-start: 6px solid var(--m); color: var(--ink); text-decoration: none; margin-bottom: .6rem; }
.matn-index b { font-family: var(--font-display); font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.5rem); color: var(--m); line-height: 1.3; }
html[lang="en"] .matn-index b { font-family: var(--font-ui); font-weight: 600; font-size: 1.6rem; }
.matn-index span { color: var(--ink-2); }
.matn-index .mi-n { font-family: var(--font-ui); font-size: .85rem; }
.matn-index a:hover { background: color-mix(in srgb, var(--m) 6%, var(--paper)); }
.matn-page { max-width: 46rem; margin: 0 auto; padding: 1rem 16px 3rem; }
.mp-k { margin: 0; font-size: .9rem; }
.mp-head h1 { color: var(--m); }
.mp-other { font-size: .92rem; color: var(--ink-2); }
.mp-other a { color: var(--m); font-weight: 600; margin-inline-start: .5rem; }
.mp-toc { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: .6rem 0; margin-bottom: 1.5rem; }
.mp-toc ol { list-style: none; margin: 0; padding: 0; columns: 2 14rem; column-gap: 2rem; font-family: var(--font-text); line-height: 1.75; }
.mp-toc li { break-inside: avoid; }
.mp-toc a { color: var(--ink); text-decoration: none; }
.mp-toc a:hover { color: var(--accent); }
.mp-toc .mt-k { font-weight: 700; color: var(--accent); margin-top: .3rem; }
.mp-toc .mt-k a { color: var(--accent); }
.mk-h { font-family: var(--font-display) !important; font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.5rem); text-align: center; color: var(--accent); margin: 2.6rem 0 .6rem; scroll-margin-top: 1rem; }
.mk-h::before, .mk-h::after { content: ""; display: inline-block; width: 2.5rem; height: 1px; background: var(--accent); vertical-align: middle; margin: 0 .8rem; }
.ml { padding: 1rem 0 .4rem; border-top: 1px solid var(--rule); scroll-margin-top: 1rem; }
.ml-h { font-size: 1.35rem; margin: 0 0 .4rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .8rem; }
.ml-h a { color: var(--ink); text-decoration: none; }
.ml-h a:hover { color: var(--accent); }
.ml-h small { font-family: var(--font-ui); font-size: .8rem; font-weight: 500; color: var(--ink-2); }

/* ---------- search ---------- */
.site-search { grid-template-columns: 1fr !important; }
.site-search input[type="search"] { font-family: var(--font-text); font-size: 1.2rem; min-height: 52px; border-width: 2px; }
.sr-list { list-style: none; margin: 0; padding: 0; }
html[lang="en"] .sr-list { direction: ltr; }
.sr a { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); column-gap: .8rem; padding: .55rem 0; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.sr a:hover .sr-t { color: var(--accent); text-decoration: underline; }
.sr-k { grid-row: 1 / span 2; font-family: var(--font-ui); font-size: .78rem; font-weight: 600; color: var(--accent); padding-top: .35rem; }
.sr-t { font-family: var(--font-text); font-size: 1.12rem; line-height: 1.7; direction: rtl; text-align: start; }
.sr-c { font-family: var(--font-text); font-size: .92rem; color: var(--ink-2); line-height: 1.7; direction: rtl; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
html[lang="en"] .sr-t, html[lang="en"] .sr-c { text-align: right; }
@media (max-width: 479px) { .sr a { grid-template-columns: 1fr; } .sr-k { grid-row: auto; padding: 0; } }
.js .p-search .nojs-note { display: none; }

/* ---------- onboarding, 404, lesson extras ---------- */
.chooser.is-next > h2, .chooser.is-next > p:not(.pick-all), .chooser.is-next .picks, .chooser.is-next .pick-all { display: none; }
.ch-next-h { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.2rem); margin: 0 0 .6rem; }
html[lang="en"] .ch-next-h { font-family: var(--font-ui); }
.ch-steps { list-style: none; margin: 0 0 1.2rem; padding: 0; counter-reset: st; display: grid; gap: .8rem; }
.ch-steps li { counter-increment: st; display: grid; grid-template-columns: 2.2rem minmax(0, 1fr); font-family: var(--font-text); line-height: 1.9; color: var(--ink-2); }
.ch-steps li::before { content: counter(st, arabic-indic); grid-row: 1 / span 2; font-family: var(--font-display); font-weight: 700; font-size: 2.2rem; line-height: 1.1; color: var(--accent); }
html[lang="en"] .ch-steps li::before { content: counter(st); font-family: var(--font-ui); font-size: 1.8rem; }
.ch-steps b { display: block; color: var(--ink); font-size: 1.15rem; }
.nf-k { font-family: var(--font-display); font-size: clamp(4rem, 3rem + 6vw, 7rem); line-height: 1; color: var(--accent); margin: 1rem 0 .5rem; }
.ls-usul { margin: 1.6rem 0 0; padding-top: .8rem; border-top: 1px solid var(--rule); font-size: .9rem; color: var(--ink-2); line-height: 1.9; }
.sf-check-h { display: none; }

/* footer */
.site-foot { border-top: 1px solid var(--rule); color: var(--ink-2); font-size: .9rem; }
.foot-in { max-width: 1320px; margin: 0 auto; padding: 1rem 16px 1.4rem; }
.foot-nav { list-style: none; margin: 0 0 .8rem; padding: 0; display: flex; flex-wrap: wrap; gap: .1rem 1.3rem; }
.foot-nav a { color: var(--ink); display: inline-block; padding: .35rem 0; }
.foot-in p { margin: 0 0 .2rem; }
.foot-fatwa { color: var(--ink); font-weight: 500; }

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

/* ---------------- print ---------------- */
@page { size: 176mm 250mm; margin: 18mm 16mm 20mm;
  @bottom-center { content: counter(page, arabic-indic); font-family: "Noto Naskh Arabic", "Amiri", serif; font-size: 9pt; color: #444; } }
@page cover { @bottom-center { content: none; } }
@media print {
  :root { --paper: #fff; --paper-2: #fff; --paper-3: #f2f2f2; --ink: #000; --ink-2: #333; --rule: #bbb; --accent: #1d4e89; color-scheme: light;
    --m-hanafi: #8a3b2a; --m-maliki: #2d6a3e; --m-shafii: #7a5a0b; --font-ui: "Noto Naskh Arabic", "Amiri", serif; }
  body { background: #fff; font-size: 10.5pt; }
  .site-head, .site-foot, .skip, .fixture-ribbon, .ls-nav, .prevnext, .book-head, .menu-btn, .print-btn, .cy-done, .mf-toggle, .blk-fold,
  .hk-try, .tree-tools, .tree-live, .qz-filter, .quiz-live, .chooser, .ls-toc, .progress-tools, .m-filter, .filters { display: none !important; }
  .tree-static { display: block !important; }
  .sf-ctl, .sf-ms, .sf-prog, .sf-tools, .toc-btn { display: none !important; }
  .sifa .sf-step { display: grid !important; min-height: 0 !important; }
  .sifa .sf-school:not([hidden]) .sf-sh { position: static !important; width: auto; height: auto; clip-path: none; }
  .blk-muftaraq .ms { display: grid !important; }
  .blk.is-folded > * { display: block !important; }
  .hk-hidden td.hc { color: #000 !important; background: none !important; }
  details.sec > summary::after, details.sec[open] > summary::after { content: none; }
  details > :not(summary) { display: block; }
  .book { max-width: none; padding: 0; }
  .ch-body, .matn-body { font-size: 11pt; line-height: 1.95; }
  .b-title { page: cover; break-after: page; border: 0; padding-top: 45mm; }
  .b-toc { break-after: page; }
  .b-part-h { break-before: page; margin: 70mm 0 0; break-after: page; font-size: 26pt; }
  .b-ch { break-before: page; }
  .b-part-h + .b-ch { break-before: auto; }
  /* the padding keeps a heading's upper vowel marks on its own page when it opens a page */
  h1, h2, h3, h4 { break-after: avoid; padding-top: .3em; }
  /* short blocks stay whole; a long muftaraq or table may run on to the next page between its lines,
     so pages are not left half empty */
  .blk-dabit, .blk-farq, .blk-tanbih, .blk-nazila, .blk-sura, blockquote, tr, .mline, .tl-hukm { break-inside: avoid; }
  .blk-head { break-after: avoid; }
  .blk-head + *, .blk-head + ul > li:first-child { break-before: avoid; }
  thead { display: table-header-group; }
  .ch-body table th:first-child, .ch-body table td:first-child { min-width: 5.5em; }
  p { orphans: 2; widows: 2; }
  a { color: inherit; text-decoration: none; }
  .term-pop { display: none !important; }
  .term { text-decoration: none; }
  .usul-link::after { content: none; }
  .ch-body table { display: table; }
  /* «بطاقة عمل»: one tree on its own, on the reader's school */
  body.print-tree > *:not(.print-sheet) { display: none !important; }
  .print-sheet .tree { border: 0; margin: 0; }
  .print-sheet .ts.is-off { display: none !important; }
  .print-sheet .ts-body { font-size: 13pt; line-height: 2; }
}
@media screen { .print-sheet { display: none; } }
@media print {
  .nav-tools, .search-btn, .mt-tabs, .matn-all-link, .mp-toc, .mp-other, .sf-print, .print-btn, .path-next, .hero-go, .start { display: none !important; }
  .matn-body ol > li::marker { color: #1d4e89; }
  .gl { color: #333; }
  .mk-h { break-before: page; }
  .ml { break-inside: auto; }
  /* «قائمة التحقق» of the sifa: the reader's school, a box before every step */
  .p-sifa .sf-head h1 { font-size: 18pt; }
  .p-sifa .sf-check-h { display: block; font-family: "Noto Naskh Arabic", serif; font-weight: 700; color: #1d4e89; margin: 0 0 4mm; }
  .p-sifa .sf-intro, .p-sifa .tree-note, .p-sifa .sf-link, .p-sifa .sf-k { display: none !important; }
  .p-sifa .sf-step { grid-template-columns: 6mm 9mm minmax(0, 1fr) !important; column-gap: 3mm; padding: 2mm 0 !important; break-inside: avoid; }
  .p-sifa .sf-step::before { content: ""; width: 4.5mm; height: 4.5mm; border: 1.2pt solid #000; margin-top: 2mm; }
  .p-sifa .sf-n { font-size: 14pt !important; text-align: center; }
  .p-sifa .sf-act { font-size: 12pt !important; line-height: 1.8 !important; font-weight: 400 !important; margin: 0 !important; }
  .p-sifa .sf-marks { margin: 0 0 1mm !important; }
  .p-sifa .sf-mark { font-size: 8pt !important; padding: 0 2mm !important; }
}
