/* من الدليل إلى الحكم: platform stylesheet. Mobile first. */

@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; }

:root {
  --paper: #f2ebdc;
  --paper-2: #faf6ec;
  --paper-3: #e9dfc9;
  --ink: #1e2230;
  --ink-2: #4a4f5e;
  --rule: #d6c9ad;
  --lapis: #1f4f8f;
  --lapis-soft: #dfe7f1;
  --gold: #85621a;
  --gold-soft: #c9a24e;
  --rubric: #8e2b1e;
  --focus: #1f4f8f;
  --m-hanafi: #1f5fa8;
  --m-maliki: #0d6f5c;
  --m-shafii: #94560a;
  --m-hanbali: #87386f;
  --p-thamara: #85621a;
  --p-muthmir: #1f4f8f;
  --p-istithmar: #8e2b1e;
  --p-mustathmir: #3d4a5f;
  --p-maqasid: #5d6b2a;
  --p-amal: #6a4a2e;
  --p-muqaddimat: #1e2230;
  --ring-in: #e4d8bb;
  --ring-out: #ebe1ca;
  --shadow: 0 1px 0 rgba(60, 40, 10, .06), 0 6px 18px -10px rgba(60, 40, 10, .25);
  --radius: 10px;
  --font-ui: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-text: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", serif;
  --font-matn: "Amiri", "Noto Naskh Arabic", serif;
  --fs-body: 1.125rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15171d; --paper-2: #1c1f27; --paper-3: #252935; --ink: #ebe4d4; --ink-2: #b4ad9e; --rule: #363a48;
    --lapis: #93b6e8; --lapis-soft: #24324a; --gold: #d8b363; --gold-soft: #9c7d3a; --rubric: #e3907e; --focus: #e6c27a;
    --m-hanafi: #84b3ef; --m-maliki: #5dc6aa; --m-shafii: #e6aa5e; --m-hanbali: #d996c9;
    --p-thamara: #d8b363; --p-muthmir: #93b6e8; --p-istithmar: #e3907e; --p-mustathmir: #b9c3d6; --p-maqasid: #b8c46e; --p-amal: #d2a882; --p-muqaddimat: #ebe4d4;
    --ring-in: #262a33; --ring-out: #20232b; --shadow: 0 6px 18px -10px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15171d; --paper-2: #1c1f27; --paper-3: #252935; --ink: #ebe4d4; --ink-2: #b4ad9e; --rule: #363a48;
  --lapis: #93b6e8; --lapis-soft: #24324a; --gold: #d8b363; --gold-soft: #9c7d3a; --rubric: #e3907e; --focus: #e6c27a;
  --m-hanafi: #84b3ef; --m-maliki: #5dc6aa; --m-shafii: #e6aa5e; --m-hanbali: #d996c9;
  --p-thamara: #d8b363; --p-muthmir: #93b6e8; --p-istithmar: #e3907e; --p-mustathmir: #b9c3d6; --p-maqasid: #b8c46e; --p-amal: #d2a882; --p-muqaddimat: #ebe4d4;
  --ring-in: #262a33; --ring-out: #20232b; --shadow: 0 6px 18px -10px rgba(0, 0, 0, .6);
  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: anywhere;
}
html[lang="en"] body { line-height: 1.6; }
img, svg { max-width: 100%; }
a { color: var(--lapis); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--font-text); line-height: 1.45; margin: 0 0 .5em; font-weight: 700; }
html[lang="en"] h1, html[lang="en"] h2, html[lang="en"] h3 { font-family: var(--font-ui); font-weight: 600; letter-spacing: -.005em; }
[lang="ar"] { font-family: inherit; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); }
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; border-radius: 6px; }
.skip:focus { top: .5rem; }
main { display: block; outline: none; }

/* Header */
.site-head { background: var(--paper-2); border-bottom: 1px solid var(--rule); position: relative; z-index: 20; }
.head-in { max-width: 1320px; margin: 0 auto; padding: .5rem 16px; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-family: var(--font-text); font-weight: 700; font-size: 1.15rem; min-height: 44px; }
html[lang="en"] .brand { font-family: var(--font-ui); font-weight: 600; font-size: 1.05rem; }
.brand-mark { width: 30px; height: 30px; color: var(--gold); flex: none; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 .15rem; }
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .6rem; color: var(--ink); text-decoration: none; border-radius: 6px; font-weight: 500; }
.site-nav a:hover { background: var(--paper-3); }
.site-nav a[aria-current="page"] { color: var(--lapis); box-shadow: inset 0 -2px 0 var(--gold-soft); border-radius: 0; }
.head-tools { display: flex; align-items: center; gap: .4rem; 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: .95rem; white-space: nowrap; }
.lang .on { color: var(--ink); font-weight: 600; }
.theme-btn, .menu-btn { min-width: 44px; min-height: 44px; border: 1px solid var(--rule); background: var(--paper); border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.theme-btn svg { width: 20px; height: 20px; fill: var(--ink); }
.menu-btn { display: none; padding: 0 .8rem; }
.js .menu-btn { display: inline-flex; order: 3; }
.js .head-tools { order: 2; }
.js .site-nav { order: 4; flex-basis: 100%; display: none; }
.js .site-nav.open { display: block; padding-bottom: .5rem; }
.js .site-nav.open ul { flex-direction: column; }
@media (min-width: 1080px) {
  .js .menu-btn { display: none; }
  .js .site-nav, .site-nav { display: block; order: 2; flex-basis: auto; }
  .js .site-nav ul { flex-direction: row; }
  .js .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(--rubric); font-size: .9rem; padding: .2rem 16px; border-bottom: 1px solid var(--rule); }

/* Generic page frames */
.page-narrow, .page-wide, .book { margin: 0 auto; padding: 1.5rem 16px 3rem; }
.page-narrow { max-width: 860px; }
.page-wide { max-width: 1320px; }
.page-head { margin-bottom: 1.5rem; }
.page-head p { color: var(--ink-2); max-width: 65ch; }
.empty { padding: 1.25rem; border: 1px dashed var(--rule); border-radius: var(--radius); color: var(--ink-2); background: var(--paper-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .4rem 1rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper-2); color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--gold-soft); }
.btn-primary { background: var(--lapis); color: var(--paper-2); border-color: var(--lapis); }
:root[data-theme="dark"] .btn-primary { color: #11141a; }
.pt-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.tag { display: inline-block; font-size: .85rem; padding: .05rem .55rem; border-radius: 99px; border: 1px solid currentColor; margin-inline-end: .35rem; margin-bottom: .3rem; line-height: 1.7; }
.m-sym { display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 50%; font-family: var(--font-text); font-weight: 700; font-size: .85em; color: var(--paper-2); margin-inline-end: .35em; line-height: 1; flex: none; }

/* Madhhab and pole colour hooks */
.mb-hanafi, .mc-hanafi, .lane-hanafi, .pos-hanafi, .kh-hanafi { --m: var(--m-hanafi); }
.mb-maliki, .mc-maliki, .lane-maliki, .pos-maliki, .kh-maliki { --m: var(--m-maliki); }
.mb-shafii, .mc-shafii, .lane-shafii, .pos-shafii, .kh-shafii { --m: var(--m-shafii); }
.mb-hanbali, .mc-hanbali, .lane-hanbali, .pos-hanbali, .kh-hanbali { --m: var(--m-hanbali); }
.m-sym { background: var(--m, var(--ink-2)); }
.pole-thamara, .stn-thamara { --p: var(--p-thamara); }
.pole-muthmir, .stn-muthmir { --p: var(--p-muthmir); }
.pole-istithmar, .stn-istithmar { --p: var(--p-istithmar); }
.pole-mustathmir, .stn-mustathmir { --p: var(--p-mustathmir); }
.pole-maqasid, .stn-maqasid, .ring-maqasid { --p: var(--p-maqasid); }
.pole-amal, .stn-amal, .ring-amal { --p: var(--p-amal); }
.pole-muqaddimat, .pole-center { --p: var(--p-muqaddimat); }
.pole-tag, .stn-tag { color: var(--p); }

/* ---------------- Home: system map ---------------- */
.hero { max-width: 1320px; margin: 0 auto; padding: 1rem 16px 1.5rem; }
.hero-head { max-width: 70ch; margin-bottom: .5rem; }
.hero-head h1 { margin-bottom: .2rem; }
.hero-lead { color: var(--ink-2); margin: 0; }
.map-wrap { display: grid; gap: 1rem; }
.map-fig { margin: 0; }
.sysmap { display: block; width: 100%; height: auto; max-height: calc(100vh - 165px); margin: 0 auto; font-family: var(--font-ui); }
.sysmap a { cursor: pointer; outline: none; }
.sysmap text { text-anchor: middle; fill: var(--ink); pointer-events: none; }
.ring-band { fill: none; }
.ring-amal .ring-band { stroke: var(--ring-out); stroke-width: 44; }
.ring-maqasid .ring-band { stroke: var(--ring-in); stroke-width: 42; }
.ring:hover .ring-band, .ring.is-active .ring-band { stroke: color-mix(in srgb, var(--p) 22%, var(--ring-in)); }
.ring-label { font-size: 21px; font-weight: 600; fill: var(--p) !important; font-family: var(--font-text); }
html[lang="en"] .ring-label { font-family: var(--font-ui); font-size: 18px; letter-spacing: .02em; }
.ring-core { fill: var(--paper-2); stroke: var(--gold-soft); stroke-width: 1.2; }
.route { fill: none; stroke: var(--gold-soft); stroke-width: 3; stroke-dasharray: 2 7; stroke-linecap: round; }
.medallion { fill: var(--paper); stroke: var(--gold); stroke-width: 2; }
.medallion-in { fill: none; stroke: var(--gold-soft); stroke-width: 1; }
.m-t { font-family: var(--font-text); font-size: 19px; font-weight: 700; }
.m-en { font-family: var(--font-ui); font-size: 15px; }
.pole-box { fill: var(--paper); stroke: var(--p); stroke-width: 2; }
.p-main { font-family: var(--font-text); font-size: 25px; font-weight: 700; fill: var(--p) !important; }
.p-en { font-family: var(--font-ui); font-size: 19px; font-weight: 600; }
.p-sub { font-size: 16px; font-weight: 500; fill: var(--ink-2) !important; }
.stn-dot { fill: var(--p); stroke: var(--paper-2); stroke-width: 3; }
.stn-n { fill: var(--paper-2) !important; font-size: 16px; font-weight: 600; }
.pole:hover .pole-box, .pole:focus-visible .pole-box, .pole.is-active .pole-box { fill: color-mix(in srgb, var(--p) 12%, var(--paper)); stroke-width: 3; }
.pole:focus-visible .pole-box, .stn:focus-visible .stn-dot, .ring:focus-visible .ring-band, .pole-center:focus-visible .medallion { stroke: var(--focus); stroke-width: 4; }
.ring:focus-visible .ring-band { stroke-width: 44; stroke: color-mix(in srgb, var(--focus) 35%, var(--ring-in)); }
.pole-center:hover .medallion, .pole-center.is-active .medallion { fill: color-mix(in srgb, var(--gold-soft) 25%, var(--paper)); }
.stn:hover .stn-dot, .stn.is-active .stn-dot, .stn.is-rel .stn-dot { stroke: var(--p); stroke-width: 5; r: 19; }
.stn.is-active .stn-dot { stroke: var(--ink); }
.pole.is-rel .pole-box { stroke-width: 3.5; }
.has-sel .sysmap .pole:not(.is-active):not(.is-rel), .has-sel .sysmap .stn:not(.is-active):not(.is-rel) { opacity: .45; }
@media (prefers-reduced-motion: no-preference) {
  .sysmap .pole, .sysmap .stn { transition: opacity .2s ease; }
  .stn-dot { transition: r .15s ease; }
}

.map-panel { background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); align-self: start; }
.panel-h { font-size: 1.3rem; margin-bottom: .2rem; }
.panel-lead { color: var(--ink-2); font-size: .95rem; }
.pl { list-style: none; margin: 0; padding: 0; position: relative; }
.pl::before { content: ""; position: absolute; inset-inline-start: 17px; top: 18px; bottom: 18px; border-inline-start: 2px dotted var(--gold-soft); }
.pl-item a { display: grid; grid-template-columns: 36px 1fr; column-gap: .7rem; align-items: center; padding: .35rem .2rem; color: var(--ink); text-decoration: none; border-radius: 8px; position: relative; min-height: 48px; }
.pl-item a:hover, .pl-item a.is-active { background: var(--paper-3); }
.pl-n { grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; background: var(--p); color: var(--paper-2); display: grid; place-items: center; font-weight: 600; }
.pl-t { font-weight: 600; line-height: 1.4; }
.pl-s { font-size: .88rem; color: var(--ink-2); line-height: 1.4; }
.panel-detail .info { border: 0; padding: 0; margin: 0; background: none; }
.panel-back { margin-bottom: .75rem; }
.info { border-inline-start: 4px solid var(--p); padding: .75rem 1rem; background: var(--paper-2); border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1rem; }
.info h3 { color: var(--p); font-size: 1.3rem; }
.panel-detail .info h3 { border-inline-start: 4px solid var(--p); padding-inline-start: .6rem; }
.info h4 { font-family: var(--font-ui); font-size: .95rem; color: var(--ink-2); margin: .9rem 0 .3rem; font-weight: 600; }
.info-q { font-family: var(--font-text); font-size: 1.15rem; font-weight: 600; }
html[lang="en"] .info-q { font-family: var(--font-ui); }
.info-q span { display: block; font-family: var(--font-ui); font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.info-ch, .info-terms { margin: 0; padding-inline-start: 1.2rem; }
.info-terms { display: flex; flex-wrap: wrap; gap: .3rem .5rem; list-style: none; padding: 0; }
.info-terms a { display: inline-block; padding: 0 .5rem; border: 1px solid var(--rule); border-radius: 99px; text-decoration: none; font-family: var(--font-text); }
.info-stns a { display: inline-grid; place-items: center; min-width: 28px; height: 28px; border-radius: 50%; background: var(--p); color: var(--paper-2); text-decoration: none; font-weight: 600; margin: .15rem; }
.ch-pending { color: var(--ink-2); }
.ch-pending small, .pend { font-size: .8rem; color: var(--ink-2); }
.js .map-static { display: none; }
.map-static { max-width: 1320px; margin: 0 auto; padding: 0 16px; display: grid; gap: .5rem; }
@media (min-width: 760px) { .map-static { grid-template-columns: 1fr 1fr; } }

@media (min-width: 980px) {
  .map-wrap { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .map-panel { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
  .hero-head { display: flex; align-items: baseline; gap: 1.5rem; max-width: none; }
  .hero-head h1 { white-space: nowrap; }
}
@media (max-width: 979px) {
  .sysmap { max-height: none; }
}

.home-intro { max-width: 1320px; margin: 0 auto; padding: 2rem 16px 3rem; display: grid; gap: 2rem; border-top: 1px solid var(--rule); }
.intro-text p { font-family: var(--font-text); font-size: 1.15rem; line-height: 2; max-width: 65ch; }
html[lang="en"] .intro-text p { font-family: var(--font-ui); line-height: 1.7; font-size: 1.05rem; }
.layer-grid { display: grid; gap: 1rem; }
.layer { padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--paper-2); border: 1px solid var(--rule); }
.layer-t { border-top: 4px solid var(--gold-soft); }
.layer-f { border-top: 4px solid var(--lapis); }
.layer p { margin: 0; color: var(--ink-2); }
.entries ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.entry { display: flex; flex-direction: column; padding: .8rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--paper-2); min-height: 44px; }
.entry:hover { border-color: var(--gold-soft); }
.entry-k { font-weight: 600; color: var(--lapis); font-size: 1.05rem; }
.entry-d { color: var(--ink-2); font-size: .93rem; }
@media (min-width: 760px) {
  .home-intro { grid-template-columns: 1fr 1fr; }
  .entries { grid-column: 1 / -1; }
  .entries ul { grid-template-columns: repeat(5, 1fr); }
  .layer-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------------- Reader ---------------- */
.reader { max-width: 1320px; margin: 0 auto; padding: 1rem 16px 3rem; display: grid; gap: 1rem; }
.toc { background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); }
.toc summary { cursor: pointer; padding: .6rem 1rem; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.toc ol { list-style: none; margin: 0; padding: 0 .6rem .8rem; font-family: var(--font-text); font-size: .98rem; line-height: 1.6; }
.toc li a { display: block; padding: .3rem .5rem; color: var(--ink); text-decoration: none; border-radius: 6px; }
.toc li a:hover, .toc li a.is-current { background: var(--paper-3); }
.toc li a.is-current { box-shadow: inset -3px 0 0 var(--gold-soft); }
.toc .toc-3 a { padding-inline-start: 1.4rem; font-size: .92rem; color: var(--ink-2); }
.chapter { min-width: 0; max-width: 50rem; }
.ch-meta { color: var(--ink-2); font-size: .93rem; margin-bottom: .2rem; }
.ch-head h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); margin-bottom: .4rem; }
.en-intro { margin: 1rem 0; padding: 1rem 1.1rem; border-inline-start: 3px solid var(--lapis); background: var(--paper-2); border-radius: 0 var(--radius) var(--radius) 0; }
.en-title { font-size: 1.2rem; font-weight: 600; margin-bottom: .4rem; }
.en-summary { margin: 0; color: var(--ink-2); line-height: 1.65; }
.toolbar { display: none; }
.js .toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(6px); padding: .6rem 0; border-bottom: 1px solid var(--rule); margin-bottom: 1rem; }
.tb-group { display: flex; flex-direction: column; gap: .15rem; }
.tb-l { font-size: .8rem; color: var(--ink-2); }
.seg { display: flex; flex-wrap: wrap; gap: .25rem; }
.seg button { min-height: 40px; padding: 0 .65rem; border: 1px solid var(--rule); background: var(--paper-2); border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; font-size: .92rem; }
.seg button[aria-pressed="true"] { border-color: var(--m, var(--ink)); box-shadow: inset 0 0 0 1px var(--m, var(--ink)); font-weight: 600; background: color-mix(in srgb, var(--m, var(--ink)) 9%, var(--paper-2)); }
@media (max-width: 640px) {
  .js .toolbar { position: static; }
  .seg button { padding: 0 .5rem; font-size: .88rem; }
}
.ch-body { font-family: var(--font-text); font-size: var(--fs-body); line-height: 2.05; }
.ch-body p, .ch-body li { max-width: 68ch; }
.ch-body ol, [lang="ar"] .ch-body ol { list-style-type: arabic-indic; }
.ch-body h2 { margin-top: 2.2rem; font-size: 1.55rem; color: var(--ink); padding-bottom: .2rem; border-bottom: 1px solid var(--rule); }
.ch-body h3 { margin-top: 1.6rem; font-size: 1.28rem; }
.ch-body h2, .ch-body h3 { scroll-margin-top: 6rem; }
.lvl { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; font-size: .62em; vertical-align: .25em; border-radius: 4px; margin-inline-start: .4em; font-family: var(--font-ui); font-weight: 600; border: 1px solid var(--gold-soft); color: var(--gold); }
.lvl-1 { background: var(--gold-soft); color: #241a05; border-color: var(--gold-soft); }
.lvl-3 { border-style: dashed; }
[data-show-level="1"] .sec[data-l="2"], [data-show-level="1"] .sec[data-l="3"], [data-show-level="2"] .sec[data-l="3"] { display: none; }
[data-show-level="1"] .toc li[data-l="2"], [data-show-level="1"] .toc li[data-l="3"], [data-show-level="2"] .toc li[data-l="3"] { display: none; }
.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 { border: 1px solid var(--rule); padding: .4rem .7rem; text-align: start; vertical-align: top; }
.ch-body th { background: var(--paper-3); font-weight: 700; }
.ch-body blockquote { margin: 1rem 0; padding: .4rem 1rem; border-inline-start: 3px solid var(--gold-soft); }
.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; }
.footnote-ref a, a.footnote-ref { text-decoration: none; font-family: var(--font-ui); font-size: .8em; padding: 0 .1em; }

/* Blocks */
.blk { margin: 1.5rem 0; padding: .9rem 1.1rem; border-radius: var(--radius); background: var(--paper-2); border: 1px solid var(--rule); position: relative; }
.blk > :last-child { margin-bottom: 0; }
.blk-head { font-family: var(--font-ui); margin-bottom: .5rem; line-height: 1.5; display: flex; flex-wrap: wrap; gap: .1rem .6rem; align-items: baseline; }
.blk-type { font-size: .82rem; font-weight: 600; color: var(--bc, var(--ink-2)); }
.blk-title { font-family: var(--font-text); font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.blk-khilaf { --bc: var(--rubric); border-top: 3px solid var(--rubric); }
.blk-matn { --bc: var(--gold); background: var(--paper); border: 1px solid var(--gold-soft); box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5px var(--gold-soft); }
.blk-matn blockquote { font-family: var(--font-matn); font-size: 1.3em; line-height: 2.1; border: 0; padding: 0; margin: .3rem 0 .8rem; text-align: center; color: var(--ink); }
.blk-case { --bc: var(--lapis); border-inline-start: 4px solid var(--lapis); }
.blk-tool { --bc: var(--p-maqasid); border-inline-start: 4px solid var(--p-maqasid); }
.blk-tanbih { --bc: var(--gold); background: color-mix(in srgb, var(--gold-soft) 14%, var(--paper-2)); border-inline-start: 4px solid var(--gold-soft); }
.blk-sual { --bc: var(--lapis); background: var(--lapis-soft); border: 0; padding: 1.1rem 1.3rem; font-size: 1.1em; }
.blk-sual p:not(.blk-head) { font-weight: 600; margin: 0; }
.blk-khilaf ul { list-style: none; padding: 0; margin: 0; }
.kh { display: grid; grid-template-columns: 7.2rem 1fr; gap: .2rem .9rem; padding: .45rem 0 .45rem; border-top: 1px solid var(--rule); align-items: baseline; }
.kh:first-child { border-top: 0; }
.kh > p { margin: 0; display: contents; }
.kh-label { font-family: var(--font-ui); font-weight: 600; font-size: .9rem; color: var(--m, var(--ink-2)); display: inline-flex; align-items: center; gap: .4rem; }
.kh-label::before { content: ""; width: .7rem; height: .7rem; border-radius: 2px; background: var(--m, transparent); border: 1px solid var(--m, var(--ink-2)); flex: none; }
.kh-hanafi .kh-label::before { border-radius: 50%; }
.kh-maliki .kh-label::before { transform: rotate(45deg) scale(.85); }
.kh-shafii .kh-label::before { border-radius: 0; }
.kh-hanbali .kh-label::before { border-radius: 50% 0; }
.kh-sabab, .kh-thamara, .kh-tahqiq { background: var(--paper); margin-inline: -1.1rem; padding-inline: 1.1rem; }
.kh-sabab .kh-label { color: var(--rubric); }
.kh-thamara .kh-label { color: var(--gold); }
.kh-tahqiq .kh-label { color: var(--lapis); }
.kh-jumhur .kh-label::before { background: linear-gradient(90deg, var(--m-maliki) 0 33%, var(--m-shafii) 33% 66%, var(--m-hanbali) 66%); border: 0; }
@media (max-width: 520px) { .kh { grid-template-columns: 1fr; } }
body[data-madhhab] .kh:is(.kh-hanafi, .kh-maliki, .kh-shafii, .kh-hanbali) { opacity: .42; }
body[data-madhhab="hanafi"] .kh-hanafi, body[data-madhhab="maliki"] .kh-maliki, body[data-madhhab="shafii"] .kh-shafii, body[data-madhhab="hanbali"] .kh-hanbali { opacity: 1; background: color-mix(in srgb, var(--m) 11%, transparent); margin-inline: -1.1rem; padding-inline: calc(1.1rem - 4px) 1.1rem; border-inline-start: 4px solid var(--m); }

/* Glossary term popovers */
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: help; border-bottom: 1.5px dotted var(--gold); line-height: inherit; }
.term:hover { color: var(--lapis); }
.term-pop { margin: 0; inset: auto; max-width: min(22rem, calc(100vw - 32px)); padding: .8rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-2); color: var(--ink); box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .35); 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; }
.no-anchor .term-pop { inset: 0; margin: auto; height: fit-content; }
.pop-term { display: block; font-size: 1.15rem; }
.pop-en { display: block; font-family: var(--font-ui); font-size: .85rem; color: var(--ink-2); margin-bottom: .3rem; }
.pop-def { display: block; }
.pop-more { display: inline-block; margin-top: .4rem; font-family: var(--font-ui); font-size: .85rem; }
.xref-pending { border-bottom: 1px dashed var(--ink-2); }

.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: .7rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--paper-2); }
.pn span { font-size: .85rem; color: var(--ink-2); }
.pn b { font-family: var(--font-text); }
.pn-next { text-align: end; }
.ch-quiz { margin-top: 2rem; }
@media (min-width: 640px) { .prevnext { grid-template-columns: 1fr 1fr; } .pn-next { grid-column: 2; } }
@media (min-width: 1000px) {
  .reader { grid-template-columns: 280px minmax(0, 1fr); gap: 2.5rem; }
  .toc-side { order: 0; }
  .toc { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
  .toc summary { pointer-events: none; }
  .toc summary::-webkit-details-marker { display: none; }
  .toc summary { list-style: none; }
}

/* Chapter index */
.idx-part { margin-bottom: 2rem; }
.idx-part h2 { border-bottom: 2px solid var(--gold-soft); padding-bottom: .2rem; }
.idx-part h3 { font-size: 1.05rem; color: var(--ink-2); margin: 1.2rem 0 .3rem; }
.idx-list { list-style: none; padding: 0; margin: 0; }
.idx-list li { display: grid; grid-template-columns: 3rem 1fr; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.idx-id { font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; direction: ltr; text-align: end; }
html[lang="en"] .idx-id { text-align: start; }
.idx-t a, .idx-t > span[lang="ar"] { font-family: var(--font-text); font-size: 1.1rem; }
.idx-en { display: block; color: var(--ink-2); font-size: .92rem; }
.is-pending .idx-t > span[lang="ar"] { color: var(--ink-2); }

/* ---------------- Lab ---------------- */
.case-tabs ul { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.case-tabs a { display: inline-flex; min-height: 44px; align-items: center; padding: 0 1rem; border: 1px solid var(--rule); border-radius: 99px; text-decoration: none; color: var(--ink); background: var(--paper-2); }
.case-tabs a.is-active { border-color: var(--lapis); color: var(--lapis); font-weight: 600; }
.js .case-tabs ~ .case:not(.is-shown) { display: none; }
.case { margin-bottom: 3rem; }
.case-head { max-width: 52rem; }
.case-head h2 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); }
.case-en { color: var(--ink-2); margin-top: -.3rem; }
.case-q { font-family: var(--font-text); font-size: 1.2rem; line-height: 1.9; padding: .7rem 1rem; background: var(--lapis-soft); border-radius: var(--radius); }
.texts { margin: .8rem 0; }
.texts summary { cursor: pointer; font-weight: 600; min-height: 40px; display: flex; align-items: center; }
.texts ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.tx { display: grid; grid-template-columns: 5rem 1fr; gap: .2rem .8rem; padding: .4rem 0; border-bottom: 1px solid var(--rule); }
.tx-k { font-size: .85rem; color: var(--gold); font-weight: 600; }
.tx-t { font-family: var(--font-matn); font-size: 1.15rem; line-height: 1.9; }
.tx-r { grid-column: 2; font-size: .85rem; color: var(--ink-2); }
.m-choose { border: 0; padding: 0; margin: 1.2rem 0 .8rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.m-choose legend { font-weight: 600; margin-bottom: .4rem; padding: 0; }
.js .m-choose { display: flex; }
.m-choose { display: none; }
.mc { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .9rem; border: 1px solid var(--rule); border-radius: 99px; cursor: pointer; background: var(--paper-2); }
.mc input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mc:has(input:checked) { border-color: var(--m, var(--ink)); box-shadow: inset 0 0 0 1px var(--m, var(--ink)); font-weight: 600; background: color-mix(in srgb, var(--m, var(--ink)) 9%, var(--paper-2)); }
.mc:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.track { display: none; }
.js .track { display: flex; list-style: none; padding: 0; margin: .5rem 0 1rem; gap: 0; align-items: center; }
.tr-st { flex: 1; display: flex; align-items: center; position: relative; }
.tr-st::after { content: ""; flex: 1; height: 2px; background: var(--rule); margin-inline: .2rem; }
.tr-st:last-child { flex: 0; }
.tr-st:last-child::after { display: none; }
.tr-n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--p); color: var(--p); font-weight: 600; font-size: .9rem; background: var(--paper); flex: none; }
.tr-div .tr-n { border-style: double; border-width: 4px; }
.tr-st.is-done .tr-n, .tr-st.is-cur .tr-n { background: var(--p); color: var(--paper-2); }
.tr-st.is-cur .tr-n { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--p); }
.steps { list-style: none; padding: 0; margin: 0; position: relative; }
.step { position: relative; padding: 0 0 1.5rem; padding-inline-start: 3.2rem; }
.step::before { content: ""; position: absolute; inset-inline-start: 17px; top: 36px; bottom: 0; border-inline-start: 3px solid var(--rule); }
.step:last-child::before { display: none; }
.js .steps.is-stepping .step:not(.is-cur) { display: none; }
.js .steps.is-stepping .step::before { display: none; }
.step-head { display: flex; gap: .8rem; align-items: flex-start; margin-inline-start: -3.2rem; }
.step-n { width: 37px; height: 37px; flex: none; border-radius: 50%; background: var(--p); color: var(--paper-2); display: grid; place-items: center; font-weight: 600; }
.step-st { margin: 0; font-size: .85rem; color: var(--ink-2); }
.step h3 { margin: 0 0 .5rem; font-size: 1.25rem; }
.common { padding: .6rem .9rem; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: .6rem; }
.common-h, .cause-h, .lane-h { font-size: .82rem; font-weight: 600; color: var(--ink-2); margin: 0 0 .1rem; }
.common p:last-child, .cause p:last-child { margin: 0; font-family: var(--font-text); line-height: 1.95; }
.fork { display: flex; align-items: center; gap: .5rem; color: var(--rubric); font-weight: 600; margin: .4rem 0; }
.fork svg { width: 40px; height: 24px; stroke: var(--rubric); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.lanes { display: grid; gap: .5rem; grid-template-columns: 1fr; }
.lane { border: 1px solid var(--rule); border-top: 4px solid var(--m); border-radius: var(--radius); padding: .55rem .8rem; background: var(--paper-2); min-width: 0; }
.lane-h { display: flex; align-items: center; color: var(--m); font-size: .92rem; }
.lane-t { font-family: var(--font-text); line-height: 1.9; }
.step:not(.is-div) .lanes .lane { border-top-width: 1px; border-inline-start: 4px solid var(--m); }
.cause { margin-top: .6rem; padding: .6rem .9rem; border: 1px dashed var(--rubric); border-radius: var(--radius); background: color-mix(in srgb, var(--rubric) 6%, var(--paper)); }
.cause-h { color: var(--rubric); }
.agree { color: var(--ink-2); font-size: .92rem; }
.st-ch { font-size: .92rem; color: var(--ink-2); margin-top: .5rem; }
[data-sel] .lane { opacity: .5; }
[data-sel="hanafi"] .lane.lane-hanafi, [data-sel="maliki"] .lane.lane-maliki, [data-sel="shafii"] .lane.lane-shafii, [data-sel="hanbali"] .lane.lane-hanbali { opacity: 1; box-shadow: 0 0 0 2px var(--m); }
@media (min-width: 760px) {
  .lanes { grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); }
  .is-div .lanes { position: relative; }
}
.stepper { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 1.5rem; }
.stepper button { min-height: 44px; padding: 0 1rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper-2); cursor: pointer; }
.stepper .st-next { background: var(--lapis); color: var(--paper-2); border-color: var(--lapis); }
.stepper button:disabled { opacity: .45; cursor: default; }
.st-pos { color: var(--ink-2); min-width: 6rem; text-align: center; }
.rulings { margin-top: 1rem; padding-top: 1rem; border-top: 2px solid var(--gold-soft); }
.root { margin-top: .8rem; padding: .7rem 1rem; background: var(--paper-3); border-radius: var(--radius); }
.root > span:first-child { display: block; font-size: .85rem; font-weight: 600; color: var(--rubric); }
.root [lang="ar"] { font-family: var(--font-text); font-size: 1.1rem; }

/* ---------------- Compare ---------------- */
.filters { display: grid; gap: .8rem; padding: 1rem; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 1.2rem; }
.filters label > span:not(.m-sym), .filters legend { display: block; font-size: .85rem; color: var(--ink-2); margin-bottom: .2rem; padding: 0; }
.filters input[type="search"], .filters select, .quiz-pick select { width: 100%; min-height: 44px; padding: 0 .8rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); }
.f-cols { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.f-cols legend { width: 100%; }
.f-count { margin: 0; color: var(--ink-2); align-self: end; }
.filters:not(.js *) { }
html:not(.js) .filters { display: none; }
@media (min-width: 900px) { .p-compare .filters { grid-template-columns: 1.4fr 1fr 2fr auto; align-items: end; } }
.cmp-list { display: grid; gap: 1rem; }
.cmp { background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.1rem; }
.cmp[hidden] { display: none; }
.cmp-area { font-size: .82rem; color: var(--gold); font-weight: 600; margin: 0; }
.cmp h2 { font-size: 1.3rem; margin-bottom: .1rem; }
.cmp-en { color: var(--ink-2); font-size: .92rem; margin-bottom: .6rem; }
.positions { display: grid; gap: .5rem; margin: .6rem 0; }
.pos { padding: .5rem .8rem; border-radius: 8px; background: var(--paper); border-inline-start: 4px solid var(--m); }
.pos-h { display: flex; align-items: center; color: var(--m); font-weight: 600; font-size: .9rem; margin: 0 0 .1rem; }
.pos-t { font-family: var(--font-text); line-height: 1.85; }
.pos.is-off { display: none; }
@media (min-width: 760px) { .positions { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } }
.jumhur { font-family: var(--font-text); }
.why summary { cursor: pointer; font-weight: 600; color: var(--lapis); min-height: 44px; display: flex; align-items: center; }
.why h4 { font-family: var(--font-ui); font-size: .9rem; color: var(--ink-2); margin: .5rem 0 .1rem; }
.why p, .why ul { font-family: var(--font-text); line-height: 1.9; }

/* ---------------- Glossary ---------------- */
.letters ul { list-style: none; padding: 0; margin: 0 0 1.5rem; display: flex; flex-wrap: wrap; gap: .3rem; }
.letters a { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--rule); border-radius: 8px; text-decoration: none; font-family: var(--font-text); font-size: 1.2rem; background: var(--paper-2); color: var(--ink); }
.g-letter h2 { font-size: 2rem; color: var(--gold); border-bottom: 1px solid var(--rule); margin-top: 1rem; }
.g-letter dl { margin: 0; }
.g-item { padding: .7rem 0; border-bottom: 1px solid var(--rule); scroll-margin-top: 1rem; }
.g-item:target { background: color-mix(in srgb, var(--gold-soft) 18%, transparent); }
.g-item[hidden], .g-letter[hidden] { display: none; }
.g-item dt { font-family: var(--font-text); font-size: 1.25rem; font-weight: 700; }
.g-en { font-family: var(--font-ui); font-size: .9rem; font-weight: 400; color: var(--ink-2); margin-inline-start: .4rem; }
.g-item dd { margin: 0; }
.g-item dd p { margin: .1rem 0; font-family: var(--font-text); line-height: 1.9; }
.g-item dd .g-where { font-family: var(--font-ui); font-size: .9rem; color: var(--ink-2); }

/* ---------------- Practice ---------------- */
.practice-grid { display: grid; gap: 2rem; }
@media (min-width: 1000px) { .practice-grid { grid-template-columns: 1fr 1fr; } }
.js .nojs-note { display: none; }
.fc-stats { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; color: var(--ink-2); margin-bottom: .8rem; }
.fc-stats b { color: var(--ink); font-size: 1.15rem; }
.boxes { display: flex; gap: 3px; align-items: flex-end; height: 34px; }
.boxes span { width: 14px; background: var(--gold-soft); border-radius: 2px 2px 0 0; min-height: 2px; }
.flashcard { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 14px; padding: 1.5rem; box-shadow: var(--shadow); min-height: 16rem; display: flex; flex-direction: column; justify-content: space-between; gap: 1rem; position: relative; }
.flashcard::before { content: ""; position: absolute; inset: 6px; border: 1px solid var(--gold-soft); border-radius: 10px; pointer-events: none; opacity: .5; }
.fc-term { font-family: var(--font-text); font-size: clamp(1.7rem, 1.3rem + 2vw, 2.4rem); font-weight: 700; text-align: center; margin: .5rem 0 0; }
.fc-en { text-align: center; color: var(--ink-2); margin: 0; }
.fc-def { font-family: var(--font-text); font-size: 1.2rem; line-height: 1.95; text-align: center; border-top: 1px solid var(--rule); padding-top: .8rem; margin: .5rem 0 0; }
.fc-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; position: relative; }
.quiz-pick { display: block; margin-bottom: 1rem; }
.js .quiz-static-wrap { display: none; }
.quiz-static ol { padding-inline-start: 1.3rem; }
.qz { list-style: none; padding: 0; margin: 0; counter-reset: q; }
.qz-item { padding: 1rem 0; border-bottom: 1px solid var(--rule); counter-increment: q; }
.qz-q { font-family: var(--font-text); font-size: 1.15rem; line-height: 1.9; font-weight: 600; }
.qz-q::before { content: counter(q, arabic-indic) ". "; color: var(--gold); }
.qz-opts { display: grid; gap: .4rem; margin: .5rem 0; }
.qz-opts button { text-align: start; min-height: 44px; padding: .45rem .9rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper-2); cursor: pointer; font-family: var(--font-text); font-size: 1.05rem; line-height: 1.7; }
.qz-opts button:hover:not(:disabled) { border-color: var(--lapis); }
.qz-opts button.is-right { border-color: var(--m-maliki); background: color-mix(in srgb, var(--m-maliki) 12%, var(--paper-2)); }
.qz-opts button.is-wrong { border-color: var(--rubric); background: color-mix(in srgb, var(--rubric) 10%, var(--paper-2)); text-decoration: line-through; text-decoration-thickness: 1px; }
.qz-opts button:disabled { cursor: default; }
.qz-fb { padding: .6rem .9rem; border-radius: 8px; background: var(--paper-3); font-family: var(--font-text); line-height: 1.9; }
.qz-fb b { font-family: var(--font-ui); }
.qz-score { font-size: 1.15rem; font-weight: 600; margin: 1rem 0; }
.progress-tools { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.progress-tools h2 { font-size: 1.15rem; }
html:not(.js) .pt-export, html:not(.js) .pt-import { display: none; }
.pt-msg { color: var(--ink-2); margin-top: .5rem; }

/* ---------------- Plan ---------------- */
.plan-progress { position: sticky; top: 0; background: var(--paper); padding: .6rem 0; z-index: 5; border-bottom: 1px solid var(--rule); margin-bottom: 1rem; }
.bar { height: 12px; border-radius: 99px; background: var(--paper-3); overflow: hidden; border: 1px solid var(--rule); }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
[dir="rtl"] .bar span { margin-inline-start: 0; }
.bar-t { margin: .3rem 0 0; color: var(--ink-2); font-size: .92rem; }
.week { margin-bottom: 1.5rem; padding: 1rem 1.1rem; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); }
.week-n { margin: 0; color: var(--gold); font-weight: 600; font-size: .9rem; }
.week-goal { color: var(--ink-2); font-family: var(--font-text); }
.week-prog { font-size: .85rem; color: var(--ink-2); margin: 0 0 .4rem; }
.tasks { list-style: none; padding: 0; margin: 0; }
.tasks li { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.tasks input { width: 22px; height: 22px; accent-color: var(--lapis); flex: none; }
.tasks label { flex: 1; min-width: 12rem; cursor: pointer; padding: .3rem 0; }
.tasks input:checked + label { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--gold-soft); }
.task-go { font-size: .9rem; }

/* ---------------- Book ---------------- */
.book { max-width: 50rem; }
.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-text); font-size: 2.6rem; font-weight: 700; margin: 0; }
.b-title-sub { font-family: var(--font-text); color: var(--ink-2); font-size: 1.2rem; }
.b-toc ol { font-family: var(--font-text); line-height: 1.9; }
.b-part-h { text-align: center; font-size: 2rem; margin: 3rem 0 1.5rem; color: var(--gold); }
.b-ch-h { font-size: 2rem; margin-top: 2.5rem; padding-bottom: .3rem; border-bottom: 2px solid var(--gold-soft); }

/* Footer */
.site-foot { border-top: 1px solid var(--rule); background: var(--paper-2); color: var(--ink-2); font-size: .9rem; }
.foot-in { max-width: 1320px; margin: 0 auto; padding: 1rem 16px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem 1.5rem; }
.foot-in p { margin: 0; }

@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; }
@media print {
  :root { --paper: #fff; --paper-2: #fff; --paper-3: #f3efe6; --ink: #000; --ink-2: #333; --rule: #bbb; color-scheme: light; }
  body { background: #fff; font-size: 10.5pt; }
  .site-head, .site-foot, .skip, .fixture-ribbon, .toolbar, .toc-side, .prevnext, .book-head, .menu-btn, .print-btn { display: none !important; }
  .book { max-width: none; padding: 0; }
  .ch-body { font-size: 11pt; line-height: 1.95; }
  .b-title { page-break-after: always; border: 0; padding-top: 30mm; }
  .b-toc { page-break-after: always; }
  .b-part { page-break-before: always; }
  .b-ch { page-break-before: always; }
  .b-part > .b-ch:first-of-type { page-break-before: avoid; }
  .b-part-h { margin-top: 40mm; }
  h2, h3 { page-break-after: avoid; break-after: avoid; }
  .blk, table, blockquote { break-inside: avoid; }
  .blk { box-shadow: none; }
  a { color: inherit; text-decoration: none; }
  .term-pop { display: none !important; }
  .term { border: 0; }
  .ch-body table { display: table; }
}
.plan-meta { display: grid; gap: .6rem; margin: 0 0 1rem; }
.plan-meta div { padding: .6rem .9rem; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); }
.plan-meta dt { font-size: .85rem; color: var(--ink-2); }
.plan-meta dd { margin: 0; }
@media (min-width: 640px) { .plan-meta { grid-template-columns: 1fr 2fr; } }
.fr-link { display: block; color: var(--ink-2); font-size: .95em; }
.cmp-src { font-family: var(--font-ui) !important; font-size: .9rem; color: var(--ink-2); line-height: 1.7 !important; }
.cmp-note { color: var(--ink-2); }
@media (max-width: 600px) {
  .p-main { font-size: 29px; }
  .p-en { font-size: 22px; }
  .p-sub { font-size: 19px; }
  .stn-dot { r: 19; }
  .stn-n { font-size: 20px; }
  .ring-label { font-size: 24px; }
  html[lang="en"] .ring-label { font-size: 21px; }
  .m-t { font-size: 22px; }
  .m-en { font-size: 17px; }
}

/* Lab route overview: lanes merge where schools agree and split where they part */
.rg-h { font-size: 1.1rem; margin: 1rem 0 .5rem; }
.route-grid { display: grid; grid-template-columns: minmax(7.5rem, 15rem) repeat(var(--n), minmax(0, 1fr)); column-gap: .4rem; row-gap: 0; position: relative; margin-bottom: 1rem; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); padding: .6rem .7rem .8rem; }
.rg-head { display: flex; flex-direction: column; align-items: center; gap: .15rem; font-size: .85rem; font-weight: 600; color: var(--m); padding-bottom: .4rem; text-align: center; z-index: 1; }
.rg-head.rg-lbl { color: var(--ink-2); align-items: flex-start; font-weight: 500; }
.rg-line { justify-self: center; width: 4px; background: var(--m); border-radius: 2px; opacity: .55; }
.rg-lbl { grid-column: 1; }
.rg-step { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .45rem; padding: .45rem .3rem; color: var(--ink); text-decoration: none; border-radius: 6px; min-height: 52px; border-top: 1px solid var(--rule); }
.rg-step:hover, .rg-step.is-cur { background: var(--paper-3); }
.rg-n { width: 26px; height: 26px; border-radius: 50%; background: var(--p); color: var(--paper-2); display: grid; place-items: center; font-size: .85rem; font-weight: 600; flex: none; }
.rg-t { font-family: var(--font-text); font-size: .95rem; line-height: 1.5; flex: 1; min-width: 0; }
.rg-fork { flex-basis: 100%; font-size: .78rem; font-weight: 600; color: var(--rubric); padding-inline-start: calc(26px + .45rem); }
.rg-node { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .45rem 0; border-top: 1px solid var(--rule); z-index: 1; min-width: 0; }
.rg-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--m); box-shadow: 0 0 0 3px var(--paper-2); flex: none; }
.rg-x { font-family: var(--font-text); font-size: .85rem; line-height: 1.55; text-align: center; background: var(--paper-2); padding: 0 .2rem; color: var(--ink); }
.rg-merge { align-self: center; z-index: 1; margin: .45rem 0; padding: .35rem .8rem; border: 2px solid var(--gold-soft); border-radius: 99px; background: var(--paper); text-align: center; font-family: var(--font-text); font-size: .9rem; line-height: 1.6; }
.rg-end { font-weight: 600; color: var(--ink-2); font-size: .9rem; padding: .5rem .3rem; border-top: 2px solid var(--gold-soft); align-self: stretch; }
.rg-ruling { z-index: 1; margin-top: .4rem; padding: .4rem .5rem; border: 2px solid var(--m); border-radius: 8px; background: var(--paper); font-family: var(--font-text); font-size: .85rem; line-height: 1.6; text-align: center; min-width: 0; }
[data-sel] .route-grid [data-m] { opacity: .35; }
[data-sel="hanafi"] .route-grid [data-m="hanafi"], [data-sel="maliki"] .route-grid [data-m="maliki"], [data-sel="shafii"] .route-grid [data-m="shafii"], [data-sel="hanbali"] .route-grid [data-m="hanbali"] { opacity: 1; }
[data-sel] .route-grid .rg-line[data-m] { opacity: .15; }
[data-sel="hanafi"] .route-grid .rg-line[data-m="hanafi"], [data-sel="maliki"] .route-grid .rg-line[data-m="maliki"], [data-sel="shafii"] .route-grid .rg-line[data-m="shafii"], [data-sel="hanbali"] .route-grid .rg-line[data-m="hanbali"] { opacity: .9; width: 6px; }
@media (max-width: 700px) {
  .route-grid { grid-template-columns: minmax(0, 1fr) repeat(var(--n), 2.6rem); padding: .5rem; column-gap: .2rem; }
  .rg-mn, .rg-x, .rg-ruling span { display: none; }
  .rg-ruling { width: 18px; height: 18px; padding: 0; border-radius: 4px; background: var(--m); justify-self: center; align-self: center; margin: .6rem 0; }
  .rg-merge { font-size: .8rem; padding: .25rem .5rem; }
  .rg-step { min-height: 48px; }
}
@media (max-width: 759px) {
  .case-tabs ul { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .4rem; scrollbar-width: thin; }
  .case-tabs li { flex: none; }
}

html[lang="en"] .cmp-area::first-letter { text-transform: uppercase; }
