/* ============================================================================
 * brand.css — the Study Maps design system.
 *
 * ONE identity for the whole site. Before this file the site was four
 * different websites wearing the same domain: the homepage (cream / navy /
 * gold, Newsreader + Karla, from the Claude Design build), the map pages
 * (forest-green hero, Segoe UI), exam.html + transcripts.html (slate blue,
 * Segoe UI) and learn.html (teal on peach). Every page also invented its own
 * type scale, so a heading was 27px here, 19px there and 26px on master.html.
 *
 * The homepage is the brand — it is the one the user chose — so this file
 * takes the homepage's tokens and pushes them outward to everything else.
 *
 * ── HOW IT ATTACHES ────────────────────────────────────────────────────────
 * Every page already carries a hand-written <style> block full of :root
 * custom properties (--ink, --bg, --line, --green, --blue …). This file is
 * linked AFTER that block, so re-declaring those same names retones an entire
 * page without touching one line of its markup. That is the whole trick behind
 * section 3, and it is why 12 map pages could be rebranded without a rewrite.
 *
 * ⚠ community.css is linked at the END OF BODY, i.e. after this file, so a
 * plain `.cm-wrap` rule here would LOSE to it. Section 6 uses `:root .cm-wrap`
 * — one extra specificity point, after which order no longer matters. Do not
 * "tidy" that `:root` away.
 *
 * ⚠ Load order in <head> is: page <style> → responsive.css → brand.css.
 * responsive.css keeps its phone corrections for the homepage (which does not
 * load this file); where the two overlap on map pages, this file wins.
 *
 * ⚠ No @layer anywhere. The page styles are unlayered, and unlayered rules
 * beat layered ones regardless of order — a layer here would silently lose.
 * ========================================================================= */

/* ═══════════════════════════════════════════════════════ 1. TOKENS ═══════ */

:root {
  /* ---- ground & paper ------------------------------------------------- */
  --sm-cream:      #F4F1EA;   /* the page itself */
  --sm-cream-2:    #EFEADF;   /* recessed areas, table headers */
  --sm-paper:      #FFFDF8;   /* cards, sections */
  --sm-paper-2:    #FBF8F1;   /* nested cards, quiet rows */

  /* ---- ink ------------------------------------------------------------- */
  --sm-ink:        #17212E;   /* body copy, headings */
  --sm-ink-2:      #3F4A58;   /* secondary copy */
  --sm-ink-3:      #66707E;   /* captions, meta */
  --sm-ink-4:      #98A1AC;   /* micro-labels, disabled */

  /* ---- lines ----------------------------------------------------------- */
  --sm-line:       #E7E1D3;   /* the standard hairline */
  --sm-line-2:     #F1ECE0;   /* an even quieter one */
  --sm-line-3:     #DDD6C6;   /* dividers that need to read */

  /* ---- night (the rail, heroes, footers) ------------------------------- */
  --sm-night:      #0B131F;
  --sm-night-2:    #101D2E;
  --sm-night-3:    #17293D;
  --sm-night-ink:  #E8E3D6;   /* text on night */

  /* ---- gold — the one thing every page shares -------------------------- */
  --sm-gold:       #B0862F;
  --sm-gold-deep:  #8A6A1E;
  --sm-gold-lift:  #E0C57E;
  --sm-gold-wash:  #F6EFDD;
  --sm-gold-line:  #E4D6AE;

  /* ---- subject accents (verbatim from the homepage's SUBJECTS table) --- */
  --sm-aqidah:  #B0862F;  --sm-aqidah-wash:  #F6EFDD;
  --sm-hadith:  #2E6B5E;  --sm-hadith-wash:  #E7F0ED;
  --sm-adab:    #6B7F4A;  --sm-adab-wash:    #EDF0E5;
  --sm-arabic:  #3B5C8A;  --sm-arabic-wash:  #E9EEF5;
  --sm-adhkar:  #7C4A6B;  --sm-adhkar-wash:  #F3EAF0;
  --sm-fiqh:    #3C3F8F;  --sm-fiqh-wash:    #EAEBF7;
  --sm-seerah:  #A4552F;  --sm-seerah-wash:  #F7EBE4;

  /* The accent of the page you are on. brand.js sets data-subject on <body>;
     until it does, gold is the safe default because gold is the house colour. */
  --sm-accent:      var(--sm-gold);
  --sm-accent-wash: var(--sm-gold-wash);

  /* ---- semantic ------------------------------------------------------- */
  --sm-ok:      #2E6B5E;  --sm-ok-wash:   #E7F0ED;
  --sm-warn:    #B0862F;  --sm-warn-wash: #F6EFDD;
  --sm-stop:    #9C2F3D;  --sm-stop-wash: #FAECEE;

  /* ---- the categorical ramp ------------------------------------------- *
   * For content that is genuinely colour-CODED — the Arabic map gives each of
   * its five topics a hue, and those hues carry meaning, so flattening them to
   * one accent would destroy information. These are the site's own subject
   * accents reused as a ramp: five hues that already read as one family,
   * where the page's originals were #3b82f6 / #db2777 / #ea580c — full-chroma
   * web colours that belonged to no palette at all.
   * ==================================================================== */
  --sm-c1: #3B5C8A;  --sm-c1-wash: #E9EEF5;
  --sm-c2: #6B7F4A;  --sm-c2-wash: #EDF0E5;
  --sm-c3: #7C4A6B;  --sm-c3-wash: #F3EAF0;
  --sm-c4: #A4552F;  --sm-c4-wash: #F7EBE4;
  --sm-c5: #B0862F;  --sm-c5-wash: #F6EFDD;

  /* ---- type ------------------------------------------------------------ */
  --sm-serif: Newsreader, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sm-sans:  Karla, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --sm-arabic-face: Amiri, "Noto Naskh Arabic", "Traditional Arabic", "Segoe UI", serif;
  --sm-mono:  ui-monospace, "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", monospace;

  /* Fluid scale. Every step is clamp(min, preferred, max) where the preferred
     term is rem + vw, so the page scales with the viewport but never stops
     honouring the reader's own font size — a vw-only scale ignores it. */
  --sm-fs-micro: clamp(0.625rem,  0.600rem + 0.10vw, 0.6875rem);
  --sm-fs-xs:    clamp(0.750rem,  0.720rem + 0.14vw, 0.8125rem);
  --sm-fs-sm:    clamp(0.8125rem, 0.780rem + 0.18vw, 0.9063rem);
  --sm-fs-base:  clamp(0.9688rem, 0.940rem + 0.20vw, 1.0625rem);
  --sm-fs-lead:  clamp(1.0313rem, 0.990rem + 0.28vw, 1.1563rem);
  --sm-fs-h4:    clamp(0.9688rem, 0.930rem + 0.26vw, 1.0938rem);
  --sm-fs-h3:    clamp(1.0625rem, 1.000rem + 0.38vw, 1.2500rem);
  --sm-fs-h2:    clamp(1.1875rem, 1.090rem + 0.55vw, 1.5000rem);
  --sm-fs-h1:    clamp(1.6250rem, 1.360rem + 1.35vw, 2.5000rem);
  --sm-fs-mega:  clamp(2.0000rem, 1.550rem + 2.20vw, 3.2500rem);

  --sm-lh-tight:  1.18;
  --sm-lh-snug:   1.35;
  --sm-lh-body:   1.62;
  --sm-lh-arabic: 2.0;
  --sm-track-label: 0.15em;   /* the uppercase micro-label tracking */

  /* ---- space (fluid, so a phone is not padded like a monitor) ---------- */
  --sm-1:  clamp(0.25rem, 0.24rem + 0.05vw, 0.3125rem);
  --sm-2:  clamp(0.50rem, 0.47rem + 0.13vw, 0.6250rem);
  --sm-3:  clamp(0.75rem, 0.70rem + 0.22vw, 0.9375rem);
  --sm-4:  clamp(1.00rem, 0.92rem + 0.35vw, 1.3750rem);
  --sm-5:  clamp(1.25rem, 1.10rem + 0.65vw, 1.8750rem);
  --sm-6:  clamp(1.75rem, 1.52rem + 1.00vw, 2.7500rem);
  --sm-7:  clamp(2.25rem, 1.90rem + 1.55vw, 3.7500rem);
  --sm-gutter: clamp(0.875rem, 0.45rem + 2.1vw, 2.5rem);

  /* ---- shape ----------------------------------------------------------- */
  --sm-r-1: 8px;  --sm-r-2: 11px; --sm-r-3: 14px;
  --sm-r-4: 18px; --sm-r-5: 24px; --sm-r-pill: 999px;

  /* ---- elevation — cast in the ink, never in neutral grey -------------- */
  --sm-sh-1: 0 1px 2px rgba(23,33,46,.05);
  --sm-sh-2: 0 1px 2px rgba(23,33,46,.05), 0 4px 14px rgba(23,33,46,.05);
  --sm-sh-3: 0 2px 6px rgba(23,33,46,.06), 0 14px 34px rgba(23,33,46,.09);
  --sm-sh-4: 0 8px 20px rgba(23,33,46,.10), 0 32px 64px rgba(23,33,46,.14);
  --sm-sh-gold: 0 4px 12px rgba(176,134,47,.35);

  /* ---- motion ---------------------------------------------------------- */
  --sm-ease:     cubic-bezier(.2,.7,.3,1);    /* the house curve */
  --sm-ease-out: cubic-bezier(.16,1,.3,1);    /* for things entering */
  --sm-t-fast: .16s;
  --sm-t:      .24s;
  --sm-t-slow: .38s;

  /* ---- layout ---------------------------------------------------------- */
  --sm-rail-w:  268px;         /* matches the homepage's rail exactly */
  --sm-toc-w:   232px;
  --sm-measure: 68ch;          /* a comfortable line, not a full-width one */
  --sm-topbar-h: 58px;
  --sm-safe-t: env(safe-area-inset-top, 0px);
  --sm-safe-b: env(safe-area-inset-bottom, 0px);
  --sm-safe-l: env(safe-area-inset-left, 0px);
  --sm-safe-r: env(safe-area-inset-right, 0px);

  /* how far a heading must clear the sticky top bar when jumped to */
  --sm-scroll-pad: calc(var(--sm-topbar-h) + var(--sm-safe-t) + 14px);

  color-scheme: light;
}

/* Per-subject accent. brand.js writes data-subject from the page's entry in
   nav-data.js, so a map is coloured by its SUBJECT rather than by whatever
   palette that page happened to be hand-written with. */
body[data-subject="aqidah"] { --sm-accent: var(--sm-aqidah); --sm-accent-wash: var(--sm-aqidah-wash); }
body[data-subject="hadith"] { --sm-accent: var(--sm-hadith); --sm-accent-wash: var(--sm-hadith-wash); }
body[data-subject="adab"]   { --sm-accent: var(--sm-adab);   --sm-accent-wash: var(--sm-adab-wash); }
body[data-subject="arabic"] { --sm-accent: var(--sm-arabic); --sm-accent-wash: var(--sm-arabic-wash); }
body[data-subject="adhkar"] { --sm-accent: var(--sm-adhkar); --sm-accent-wash: var(--sm-adhkar-wash); }
body[data-subject="fiqh"]   { --sm-accent: var(--sm-fiqh);   --sm-accent-wash: var(--sm-fiqh-wash); }
body[data-subject="seerah"] { --sm-accent: var(--sm-seerah); --sm-accent-wash: var(--sm-seerah-wash); }


/* ═══════════════════════════════════════════════ 2. BASE / SEMANTICS ═════ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--sm-scroll-pad);
}

body {
  margin: 0;
  background: var(--sm-cream);
  color: var(--sm-ink);
  font-family: var(--sm-sans);
  font-size: var(--sm-fs-base);
  line-height: var(--sm-lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  text-wrap: pretty;
  -webkit-tap-highlight-color: transparent;
  padding-left: var(--sm-safe-l);
  padding-right: var(--sm-safe-r);
}

/* Headings are the serif. This single change does more for "premium" than any
   amount of shadow. Newsreader is an optical-size face, so it is set with the
   tighter tracking that large text wants. */
h1, h2, h3, h4, h5 {
  font-family: var(--sm-serif);
  font-weight: 500;
  color: var(--sm-ink);
  line-height: var(--sm-lh-snug);
  letter-spacing: -0.008em;
  text-wrap: balance;
}
h1 { font-size: var(--sm-fs-h1); line-height: var(--sm-lh-tight); letter-spacing: -0.018em; }
h2 { font-size: var(--sm-fs-h2); }
h3 { font-size: var(--sm-fs-h3); }
h4 { font-size: var(--sm-fs-h4); font-weight: 600; }
:where(h1, h2, h3, h4, h5) { scroll-margin-top: var(--sm-scroll-pad); }

p { margin: 0 0 var(--sm-3); }
p:last-child { margin-bottom: 0; }

strong, b { font-weight: 700; color: var(--sm-ink); }
em, i { font-style: italic; }
small { font-size: var(--sm-fs-xs); color: var(--sm-ink-3); }

a { color: var(--sm-gold-deep); text-decoration: none; transition: color var(--sm-t-fast) var(--sm-ease); }
a:hover { color: var(--sm-gold); }

/* One focus treatment for the whole site. :focus-visible only, so a mouse
   click never draws a ring but a Tab key always does. */
:focus-visible { outline: 2px solid var(--sm-gold); outline-offset: 2px; border-radius: 4px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* Native controls take the house colour rather than the OS blue — one line
   that keeps checkboxes, radios and progress bars on-brand for free. */
input, select, textarea, progress { accent-color: var(--sm-gold); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; cursor: pointer; }

img, svg, video, canvas, iframe { max-width: 100%; }
img, video { height: auto; }

hr { border: 0; border-top: 1px solid var(--sm-line); margin: var(--sm-5) 0; }

/* 0.87em keeps code visually level with the surrounding text, but inside an
   already-small context that lands at 10.5px — under the floor. */
code, kbd, samp, pre { font-family: var(--sm-mono); font-size: max(11.5px, 0.87em); }
code {
  background: var(--sm-gold-wash);
  color: var(--sm-gold-deep);
  border: 1px solid var(--sm-gold-line);
  border-radius: 5px;
  padding: 0.08em 0.42em;
  overflow-wrap: anywhere;
}
p, li, td, th, dd, figcaption, summary { overflow-wrap: break-word; }

/* Numbers line up wherever they are compared. */
td, th, time, .num, [data-sm-num] { font-variant-numeric: tabular-nums; }

::selection { background: var(--sm-gold-lift); color: var(--sm-night); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--sm-line-3); border-radius: 8px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--sm-ink-4); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Arabic. Every Arabic run on the site goes through one face and one line
   height — the class reads these aloud, and cramped naskh is unreadable.
 *
 * ⚠ font-family is the one property here that carries !important, and it has
 * to. The pages name their Arabic face at every specificity you can think of:
 * `.ar` (0,1,0) on one map, `header .ar-title` (0,1,1) on the Arabic maps,
 * `header.hero .ar` (0,2,1) on the Adhkār map. Outbidding each of them in turn
 * is a game with no end, and losing it is not cosmetic: every one of those
 * stacks leads with "Noto Naskh Arabic", which ships on no Windows machine and
 * on no iPhone, so the text silently fell back to whatever the OS chose. The
 * same dhikr rendered in three different faces on three of the class's
 * phones. Amiri is loaded from the same stylesheet the homepage uses, so it is
 * the one face guaranteed to be there.
 *
 * The other properties stay unflagged on purpose — a page may still want its
 * own size or leading for a particular block. */
:root :is(.ar, .ar-title, .arabic, [lang="ar"], [dir="rtl"]) {
  font-family: var(--sm-arabic-face) !important;
  direction: rtl;
  unicode-bidi: isolate;
  line-height: var(--sm-lh-arabic);
  font-size: 1.16em;
}

/* Screen-reader-only, used by the injected chrome. */
.sm-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}


/* ═══════════════════════════════════ 3. LEGACY TOKEN REMAP ══════════════ *
 * The one high-leverage block. Each hand-written page declares these names in
 * its own :root; re-declaring them here retones the page wholesale. The old
 * names are kept — rather than renamed across 12 files — precisely so that no
 * markup has to change and nothing can be missed.
 *
 * The mapping is deliberate, not mechanical: --green was the map pages' whole
 * identity (hero, section numbers, links, table headers), so it becomes the
 * per-page SUBJECT accent. That is how a Ḥadīth map ends up jade and a Seerah
 * map terracotta while both still read as the same website.
 * ======================================================================== */

body:not([data-sm-shell="home"]) {
  --bg:         var(--sm-cream);
  --card:       var(--sm-paper);
  --ink:        var(--sm-ink);
  --ink2:       var(--sm-ink-2);
  --muted:      var(--sm-ink-3);
  --mute:       var(--sm-ink-4);
  --line:       var(--sm-line);
  --line2:      var(--sm-line-2);

  --green:      var(--sm-accent);
  --green-soft: var(--sm-accent-wash);
  --green-deep: var(--sm-night-2);

  --gold:       var(--sm-gold);
  --gold-soft:  var(--sm-gold-wash);

  --blue:       var(--sm-accent);
  --blue-soft:  var(--sm-accent-wash);
  --blue-deep:  var(--sm-night-2);

  --rose:       var(--sm-stop);
  --rose-soft:  var(--sm-stop-wash);
  --plum:       var(--sm-adhkar);
  --plum-soft:  var(--sm-adhkar-wash);

  --brand:      var(--sm-gold);
  --brand-d:    var(--sm-gold-deep);
  --brand-l:    var(--sm-gold-wash);
  --ok:         var(--sm-ok);   --ok-l:  var(--sm-ok-wash);
  --bad:        var(--sm-stop); --bad-l: var(--sm-stop-wash);
  --red:        var(--sm-stop);

  /* --accent is the three Arabic maps' own name for their identity colour
     (#0e6b8a teal, #9c2f3d wine, #0f766e green — three unrelated hues for
     three pages of the SAME subject). It becomes the subject accent, so all
     three now read as Arabic. */
  --accent:     var(--sm-accent);
  --accent2:    var(--sm-c4);
  --accent3:    var(--sm-c3);

  /* one-off hues invented per page for a callout or a table column */
  --teal:       var(--sm-accent);   --teal-soft:  var(--sm-accent-wash);
  --teal-deep:  var(--sm-night-2);
  --wine:       var(--sm-c3);       --wine-soft:  var(--sm-c3-wash);
  --steel:      var(--sm-c1);       --steel-soft: var(--sm-c1-wash);

  /* the five-topic ramp on the Listening & Speaking map */
  --t1: var(--sm-c1); --t2: var(--sm-c2); --t3: var(--sm-c3);
  --t4: var(--sm-c4); --t5: var(--sm-c5);

  --shadow:     var(--sm-sh-2);
  --shadow-lg:  var(--sm-sh-3);
  --sh:         var(--sm-sh-2);
  --sh2:        var(--sm-sh-3);
  --r:          var(--sm-r-4);
}

/* ⚠ NOT remapped, deliberately: --sun --sea --grass --berry --grape.
   Those are learn-art.js's DRAWING palette, not page furniture — they colour
   the sun, the sea and the grass in the illustrations the Arabic app draws.
   Retoning them to the brand would put a navy sun in the sky. */


/* ═══════════════════════════════════════════ 4. THE APP SHELL ═══════════ *
 * Grid on <body> itself. The rail and the content column are direct children,
 * so no wrapper div holds the layout together — the elements ARE the layout.
 * Below 1180px the whole thing collapses to one column and the rail becomes an
 * off-canvas drawer with no change of markup.
 * ======================================================================== */

body[data-sm-shell="doc"],
body[data-sm-shell="tool"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100dvh;
  align-content: start;
}

body[data-sm-shell="doc"]  > *,
body[data-sm-shell="tool"] > * { min-width: 0; }

/* ⚠ The wide-screen rail is `position: fixed`, NOT a grid column, and that is
   deliberate. As a grid item it lands in row 1 alongside the top bar, and a
   100dvh-tall item makes row 1 900px tall — so <main>, being in row 2, started
   one whole viewport down the page, under a screenful of blank cream. The
   number of body children varies per page, so there is no row count to span:
   `grid-row: 1 / -1` resolves against the EXPLICIT grid, which here has one
   line, and quietly spans nothing. Taking the rail out of flow and reserving
   its width with padding is the technique that actually holds.
   The `position: fixed` half of this lives in section 4a, after the base
   `.sm-rail` rule — put it here and the later `position: sticky` wins. */
@media (min-width: 1180px) {
  body[data-sm-shell="doc"],
  body[data-sm-shell="tool"] {
    padding-left: calc(var(--sm-rail-w) + var(--sm-safe-l));
  }
}

/* The reading column. brand.js promotes div.wrap to a real <main>; both are
   matched so the page is styled correctly in the split second before the
   script runs — and still styled correctly if it never does. */
main, body > .wrap {
  display: block;
  width: 100%;
  max-width: calc(var(--sm-measure) + 2 * var(--sm-gutter));
  margin-inline: auto;
  padding: var(--sm-5) var(--sm-gutter) var(--sm-7);
}

/* A second rail carries the contents, docs-style, and the reading column can
   afford to grow a little.
   ⚠ 1280px, not 1440px. A 1920 laptop screen at Windows' default 150% display
   scaling is 1280 CSS px, and a 1920 at 125% is 1536 — so 1440 put the most
   common laptop setup in a band with the dock hidden (>=1180) and the contents
   rail not yet shown, i.e. no way to see the page's sections at all. */
@media (min-width: 1280px) {
  body[data-sm-shell="doc"] { --sm-measure: 72ch; }
  body[data-sm-shell="doc"][data-sm-toc] > main,
  body[data-sm-shell="doc"][data-sm-toc] > .wrap {
    padding-right: calc(var(--sm-toc-w) + var(--sm-5));
    max-width: calc(var(--sm-measure) + var(--sm-toc-w) + 3 * var(--sm-gutter));
  }
}
@media (min-width: 1600px) {
  body[data-sm-shell="doc"] { --sm-measure: 76ch; }
}

/* ── 4a. the night rail ─────────────────────────────────────────────────── */

.sm-rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(86vw, 320px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(178deg, #0B131F 0%, #101D2E 55%, #0C1725 100%);
  color: var(--sm-night-ink);
  padding-top: var(--sm-safe-t);
  padding-bottom: var(--sm-safe-b);
  padding-left: var(--sm-safe-l);
  z-index: 60;
}

/* On wide screens it is permanent furniture rather than a drawer; body's
   padding-left (section 4) reserves the column it sits in. */
@media (min-width: 1180px) {
  .sm-rail { width: calc(var(--sm-rail-w) + var(--sm-safe-l)); }
}

/* the ʿayn watermark, exactly as the homepage's rail carries it */
.sm-rail::after {
  content: "ع";
  position: absolute; right: -70px; top: 120px;
  font-family: var(--sm-arabic-face); font-size: 260px; line-height: 1;
  color: rgba(224,197,126,.045);
  pointer-events: none; user-select: none;
}

.sm-rail-head {
  padding: var(--sm-5) var(--sm-4) var(--sm-4);
  border-bottom: 1px solid rgba(232,227,214,.09);
  position: relative;
}

.sm-brand {
  display: flex; align-items: center; gap: 11px;
  background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  color: inherit; width: 100%;
}
.sm-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--sm-gold-lift), var(--sm-gold));
  display: grid; place-items: center;
  font-family: var(--sm-arabic-face); font-size: 21px; color: var(--sm-night);
  padding-bottom: 3px;
  box-shadow: var(--sm-sh-gold);
}
.sm-brand-name {
  font-family: var(--sm-serif); font-size: 19px; font-weight: 500;
  color: #FBF8F1; line-height: 1.15; display: block;
}
.sm-brand-sub {
  font-size: 10.5px; letter-spacing: var(--sm-track-label);
  text-transform: uppercase; color: rgba(232,227,214,.42);
  margin-top: 1px; display: block;
}

.sm-railsearch {
  margin-top: var(--sm-4); width: 100%;
  display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(232,227,214,.1);
  border-radius: 9px; padding: 10px 11px;
  color: rgba(232,227,214,.55); font-size: 13px;
  cursor: pointer; text-align: left;
  transition: background var(--sm-t-fast), border-color var(--sm-t-fast), color var(--sm-t-fast);
}
.sm-railsearch:hover {
  background: rgba(255,255,255,.09);
  border-color: rgba(224,197,126,.32);
  color: rgba(232,227,214,.8);
}
.sm-railsearch kbd {
  margin-left: auto; font-family: var(--sm-sans); font-size: 10.5px;
  border: 1px solid rgba(232,227,214,.18); border-radius: 4px;
  padding: 1px 5px; color: rgba(232,227,214,.5);
}

.sm-rail nav { flex: 1; overflow-y: auto; padding: var(--sm-4) 14px var(--sm-3); position: relative; }
.sm-rail nav::-webkit-scrollbar { width: 6px; }
.sm-rail nav::-webkit-scrollbar-thumb { background: rgba(232,227,214,.13); border: 0; }

.sm-navlabel {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(232,227,214,.34); padding: var(--sm-4) 10px 9px; display: block;
}
.sm-rail nav > .sm-navlabel:first-child { padding-top: 0; }

.sm-navitem {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: none; border: 0; border-radius: 9px;
  padding: 9px 10px; margin-bottom: 1px;
  color: rgba(232,227,214,.74); font-size: 13.5px; text-align: left;
  cursor: pointer; line-height: 1.3;
  transition: background var(--sm-t-fast) var(--sm-ease), color var(--sm-t-fast) var(--sm-ease);
}
.sm-navitem:hover { background: rgba(255,255,255,.06); color: #FBF8F1; }
.sm-navitem[aria-current="page"] {
  background: rgba(224,197,126,.13);
  color: #FBF8F1;
  box-shadow: inset 2px 0 0 var(--sm-gold-lift);
}
.sm-navitem .sm-glyph {
  width: 24px; height: 24px; flex: 0 0 24px; border-radius: 7px;
  display: grid; place-items: center;
  font-family: var(--sm-arabic-face); font-size: 15px; padding-bottom: 2px;
  background: rgba(255,255,255,.07); color: rgba(232,227,214,.85);
}
.sm-navitem .sm-navtext { flex: 1; min-width: 0; }
.sm-navitem .sm-count { font-size: 10.5px; color: rgba(232,227,214,.4); font-variant-numeric: tabular-nums; }
.sm-navitem .sm-tick { width: 3px; height: 16px; border-radius: 2px; background: var(--tick, transparent); }
.sm-navitem svg { flex: 0 0 auto; }

/* maps nested under their subject */
.sm-subnav { display: grid; margin: 2px 0 var(--sm-2) 34px; }
.sm-subnav a {
  font-size: 12.5px; color: rgba(232,227,214,.5);
  padding: 7px 10px; border-radius: 7px; line-height: 1.35;
  border-left: 1px solid rgba(232,227,214,.12);
  transition: color var(--sm-t-fast), background var(--sm-t-fast), border-color var(--sm-t-fast);
}
.sm-subnav a:hover { color: #FBF8F1; background: rgba(255,255,255,.05); }
.sm-subnav a[aria-current="page"] {
  color: var(--sm-gold-lift);
  border-left-color: var(--sm-gold-lift);
  background: rgba(224,197,126,.08);
}

.sm-rail-foot {
  padding: var(--sm-3) var(--sm-4) var(--sm-4);
  border-top: 1px solid rgba(232,227,214,.09);
  position: relative;
  font-size: 11.5px; color: rgba(232,227,214,.45); line-height: 1.5;
}
.sm-rail-foot .sm-navlabel { padding: 0 0 8px; }

/* ── 4b. drawer behaviour (below 1180px) ────────────────────────────────── */

@media (max-width: 1179.98px) {
  .sm-rail {
    transform: translate3d(-102%, 0, 0);
    transition: transform var(--sm-t-slow) var(--sm-ease);
    visibility: hidden;
    /* the drawer scrolls itself; the page behind it must not follow */
    overscroll-behavior: contain;
  }
  body[data-sm-drawer="open"] .sm-rail {
    transform: none;
    visibility: visible;
    box-shadow: var(--sm-sh-4);
  }
  /* while a thumb is dragging, brand.js drives the transform frame by frame,
     so the CSS transition has to get out of the way */
  body[data-sm-dragging] .sm-rail { transition: none; visibility: visible; }
}

.sm-scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(11,19,31,.42);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--sm-t) var(--sm-ease);
}
body[data-sm-drawer="open"] .sm-scrim,
body[data-sm-sheet="open"] .sm-scrim { opacity: 1; pointer-events: auto; }

/* ── 4c. the top bar ────────────────────────────────────────────────────── */

.sm-top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--sm-2);
  height: calc(var(--sm-topbar-h) + var(--sm-safe-t));
  padding: var(--sm-safe-t) var(--sm-3) 0;
  background: color-mix(in srgb, var(--sm-cream) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid var(--sm-line);
  /* the bar hides on the way down and returns on the way up — iOS reading
     behaviour. brand.js flips data-sm-chrome. */
  transition: transform var(--sm-t) var(--sm-ease);
}
body[data-sm-chrome="hidden"] .sm-top { transform: translate3d(0, -100%, 0); }

.sm-iconbtn {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--sm-r-2);
  background: none; color: var(--sm-ink-2); cursor: pointer;
  transition: background var(--sm-t-fast) var(--sm-ease),
              color var(--sm-t-fast) var(--sm-ease),
              border-color var(--sm-t-fast) var(--sm-ease),
              transform var(--sm-t-fast) var(--sm-ease);
}
.sm-iconbtn:hover { background: var(--sm-paper); color: var(--sm-ink); border-color: var(--sm-line); }
.sm-iconbtn:active { transform: scale(.94); }

.sm-top-title { flex: 1; min-width: 0; display: grid; gap: 1px; }
.sm-top-kicker {
  font-size: var(--sm-fs-micro); letter-spacing: var(--sm-track-label);
  text-transform: uppercase; color: var(--sm-accent); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sm-top-name {
  font-family: var(--sm-serif); font-size: var(--sm-fs-h4);
  color: var(--sm-ink); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (min-width: 1180px) {
  .sm-top { padding-inline: var(--sm-5); }
  .sm-top [data-sm-act="drawer"] { display: none; }
}

/* the reading-progress hairline, welded to the bottom of the bar */
.sm-progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--sm-gold), var(--sm-gold-lift));
  transform-origin: 0 50%;
  transform: scaleX(var(--sm-read, 0));
  transition: transform .1s linear;
}

/* ── 4d. the contents rail / sheet ──────────────────────────────────────── */

/* ⚠ `.sm-toc` is the LIST STYLE, worn by two different things: the fixed rail
   on wide screens and the list inside the bottom sheet on a phone. Only the
   rail carries `.sm-toc-rail`. Positioning rules must key off `.sm-toc-rail`
   alone — when they keyed off `.sm-toc` they also pinned the sheet's own list
   to the top-right corner of the viewport, outside the sheet. */
.sm-toc-rail { display: none; }

/* The contents button in the app bar stands down only where the fixed rail is
   actually on screen — everywhere else it is the only way in. */
@media (min-width: 1280px) {
  body[data-sm-shell="doc"][data-sm-toc] .sm-contents-btn { display: none; }
}

@media (min-width: 1280px) {
  body[data-sm-shell="doc"] .sm-toc-rail {
    display: block;
    position: fixed;
    top: calc(var(--sm-topbar-h) + var(--sm-safe-t) + var(--sm-5));
    right: max(var(--sm-4), var(--sm-safe-r));
    width: var(--sm-toc-w);
    max-height: calc(100dvh - var(--sm-topbar-h) - var(--sm-6));
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 20;
  }
}
.sm-toc h2, .sm-toc .sm-navlabel {
  font-family: var(--sm-sans); font-size: var(--sm-fs-micro);
  letter-spacing: var(--sm-track-label); text-transform: uppercase;
  color: var(--sm-ink-4); font-weight: 700;
  margin: 0 0 var(--sm-3); padding: 0;
}
.sm-toc ol, ol.sm-toc { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.sm-toc a {
  display: flex; gap: 9px; align-items: baseline;
  font-size: var(--sm-fs-sm); line-height: 1.4;
  color: var(--sm-ink-3);
  padding: 8px 10px 8px 12px;
  border-left: 2px solid var(--sm-line);
  border-radius: 0 var(--sm-r-1) var(--sm-r-1) 0;
  transition: color var(--sm-t-fast), border-color var(--sm-t-fast), background var(--sm-t-fast);
}
.sm-toc a:hover { color: var(--sm-ink); background: var(--sm-paper); }
.sm-toc a[aria-current="true"] {
  color: var(--sm-ink); font-weight: 600;
  border-left-color: var(--sm-accent);
  background: var(--sm-accent-wash);
}
.sm-toc a .sm-toc-n {
  font-family: var(--sm-serif); font-size: max(12px, var(--sm-fs-micro));
  color: var(--sm-ink-4);
  font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
.sm-toc a[aria-current="true"] .sm-toc-n { color: var(--sm-accent); }

/* On phones the same list is a bottom sheet — one that can be thrown away with
   a downward flick, which is what a thumb expects of a sheet. */
.sm-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  max-height: min(74dvh, 640px);
  display: flex; flex-direction: column;
  background: var(--sm-paper);
  border-radius: var(--sm-r-5) var(--sm-r-5) 0 0;
  box-shadow: var(--sm-sh-4);
  padding-bottom: var(--sm-safe-b);
  transform: translate3d(0, 102%, 0);
  transition: transform var(--sm-t-slow) var(--sm-ease);
  visibility: hidden;
  overscroll-behavior: contain;
}
body[data-sm-sheet="open"] .sm-sheet { transform: none; visibility: visible; }
body[data-sm-dragging] .sm-sheet { transition: none; visibility: visible; }

.sm-sheet-grip {
  flex: 0 0 auto; padding: 10px 0 6px; display: grid; place-items: center;
  cursor: grab; touch-action: none;
}
.sm-sheet-grip::before { content: ""; width: 42px; height: 4px; border-radius: 2px; background: var(--sm-line-3); }
.sm-sheet-head {
  display: flex; align-items: baseline; gap: var(--sm-2);
  padding: 0 var(--sm-4) var(--sm-3);
  border-bottom: 1px solid var(--sm-line-2);
}
.sm-sheet-head h2 {
  font-family: var(--sm-sans); font-size: var(--sm-fs-micro);
  letter-spacing: var(--sm-track-label); text-transform: uppercase;
  color: var(--sm-ink-4); font-weight: 700; margin: 0;
}
.sm-sheet-head span { margin-left: auto; font-size: var(--sm-fs-xs); color: var(--sm-ink-4); }
.sm-sheet-body { overflow-y: auto; padding: var(--sm-3) var(--sm-3) var(--sm-4); overscroll-behavior: contain; }
.sm-sheet-body a { font-size: var(--sm-fs-base); padding: 12px; }

/* ── 4e. the floating dock (phones and tablets) ─────────────────────────── */

.sm-dock {
  position: fixed; z-index: 45;
  left: 50%; bottom: calc(var(--sm-3) + var(--sm-safe-b));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  padding: 5px;
  background: color-mix(in srgb, var(--sm-night) 92%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(232,227,214,.1);
  border-radius: var(--sm-r-pill);
  box-shadow: var(--sm-sh-4);
  transition: transform var(--sm-t) var(--sm-ease), opacity var(--sm-t) var(--sm-ease);
}
body[data-sm-chrome="hidden"] .sm-dock {
  transform: translateX(-50%) translateY(calc(100% + var(--sm-5)));
  opacity: 0;
}
.sm-dock button, .sm-dock a {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 42px; padding: 0 15px;
  border: 0; background: none; border-radius: var(--sm-r-pill);
  color: rgba(232,227,214,.8); font-size: var(--sm-fs-sm); font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background var(--sm-t-fast) var(--sm-ease), color var(--sm-t-fast) var(--sm-ease), transform var(--sm-t-fast) var(--sm-ease);
}
.sm-dock button:hover, .sm-dock a:hover { background: rgba(255,255,255,.09); color: #FBF8F1; }
.sm-dock button:active, .sm-dock a:active { transform: scale(.95); }
.sm-dock .sm-dock-sep { width: 1px; height: 20px; background: rgba(232,227,214,.14); }

@media (min-width: 1180px) { .sm-dock { display: none; } }

/* ── 4f. the command palette ────────────────────────────────────────────── */

.sm-palette {
  position: fixed; inset: 0; z-index: 90;
  display: grid; align-items: start; justify-items: center;
  padding: clamp(48px, 12vh, 140px) var(--sm-4) var(--sm-4);
  background: rgba(11,19,31,.38);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--sm-t) var(--sm-ease);
}
body[data-sm-palette="open"] .sm-palette { opacity: 1; pointer-events: auto; }
.sm-palette-box {
  width: min(620px, 100%);
  max-height: min(62dvh, 560px);
  display: flex; flex-direction: column;
  background: var(--sm-paper);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-r-4);
  box-shadow: var(--sm-sh-4);
  overflow: hidden;
  transform: translateY(-10px) scale(.985);
  transition: transform var(--sm-t) var(--sm-ease-out);
}
body[data-sm-palette="open"] .sm-palette-box { transform: none; }
.sm-palette input {
  border: 0; border-bottom: 1px solid var(--sm-line-2);
  padding: var(--sm-4);
  font-size: var(--sm-fs-lead); background: none; outline: none;
  font-family: var(--sm-serif);
  border-radius: 0;
}
.sm-palette input::placeholder { color: var(--sm-ink-4); }
.sm-palette-results { overflow-y: auto; padding: var(--sm-2); overscroll-behavior: contain; }
.sm-palette-results a {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: var(--sm-r-2);
  color: var(--sm-ink); font-size: var(--sm-fs-sm);
}
.sm-palette-results a[data-sel="1"], .sm-palette-results a:hover { background: var(--sm-accent-wash); }
.sm-palette-results .sm-glyph {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 7px;
  display: grid; place-items: center; font-family: var(--sm-arabic-face);
  font-size: 15px; padding-bottom: 2px;
  background: var(--sm-cream-2); color: var(--sm-ink-2);
}
.sm-palette-results .sm-pal-meta {
  margin-left: auto; font-size: var(--sm-fs-micro); color: var(--sm-ink-4);
  text-transform: uppercase; letter-spacing: .1em; white-space: nowrap;
}
.sm-palette-empty { padding: var(--sm-5); text-align: center; color: var(--sm-ink-4); font-size: var(--sm-fs-sm); }

/* The palette now searches CONTENT, not only titles, so a result needs room
   for the line it matched on — otherwise "Al-Uṣūl ath-Thalātha, printed p.31"
   appears eight times over with nothing to tell the eight apart. align-items
   moves to flex-start because these rows are two lines tall. */
.sm-palette-results a { align-items: flex-start; }
.sm-palette-results a > span:nth-child(2) { min-width: 0; }
.sm-palette-results .sm-glyph { margin-top: 1px; }
.sm-pal-snip {
  display: block; font-style: normal; margin-top: 3px;
  font-size: var(--sm-fs-micro); line-height: 1.45; color: var(--sm-ink-4);
  /* two lines, then ellipsis — a snippet that grows to six lines turns the
     result list back into the wall of text it exists to replace */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.sm-pal-group {
  margin: 12px 4px 4px; padding-top: 9px; border-top: 1px solid var(--sm-line-2);
  font-size: var(--sm-fs-micro); text-transform: uppercase; letter-spacing: .1em;
  color: var(--sm-ink-4); font-weight: 600;
}
.sm-pal-wait { border-top: 0; opacity: .7; font-weight: 400; letter-spacing: .06em; }
.sm-palette-results a.sm-pal-ask .sm-glyph {
  background: var(--sm-gold, #a9791c); color: #fff; font-family: var(--sm-sans);
  font-weight: 700; font-size: 14px; padding-bottom: 0;
}

/* ── 4g. the prev / next pager ──────────────────────────────────────────── */

.sm-pager {
  display: grid; gap: var(--sm-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  width: 100%;
  max-width: calc(var(--sm-measure) + 2 * var(--sm-gutter));
  margin: 0 auto;
  padding: 0 var(--sm-gutter) var(--sm-7);
}
.sm-pager a {
  display: grid; gap: 3px;
  padding: var(--sm-4);
  background: var(--sm-paper);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-r-3);
  box-shadow: var(--sm-sh-1);
  transition: transform var(--sm-t) var(--sm-ease), box-shadow var(--sm-t) var(--sm-ease), border-color var(--sm-t) var(--sm-ease);
}
.sm-pager a:hover { transform: translateY(-2px); box-shadow: var(--sm-sh-3); border-color: var(--sm-gold-line); }
.sm-pager a:active { transform: translateY(0) scale(.995); }
.sm-pager .sm-pager-dir {
  font-size: var(--sm-fs-micro); letter-spacing: var(--sm-track-label);
  text-transform: uppercase; color: var(--sm-ink-4); font-weight: 700;
}
.sm-pager .sm-pager-name {
  font-family: var(--sm-serif); font-size: var(--sm-fs-h4); color: var(--sm-ink); line-height: 1.25;
}
.sm-pager .sm-pager-sub { font-size: var(--sm-fs-xs); color: var(--sm-ink-3); }
.sm-pager [data-dir="next"] { text-align: right; }

/* ── 4h. swipe affordance ───────────────────────────────────────────────── */
/* The page slides under the thumb. Without this the gesture is invisible, and
   a half-swipe that does not commit looks like the site froze. */
body[data-sm-swiping] main,
body[data-sm-swiping] > .wrap {
  transform: translate3d(var(--sm-swipe, 0px), 0, 0);
  transition: none;
  will-change: transform;
}
.sm-swipe-hint {
  position: fixed; top: 50%; z-index: 44;
  display: grid; place-items: center;
  width: 46px; height: 46px; margin-top: -23px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--sm-night) 90%, transparent);
  color: var(--sm-gold-lift);
  box-shadow: var(--sm-sh-3);
  opacity: 0; pointer-events: none;
  transition: opacity var(--sm-t-fast) var(--sm-ease), background var(--sm-t-fast) var(--sm-ease);
}
.sm-swipe-hint[data-side="left"]  { left: var(--sm-3); }
.sm-swipe-hint[data-side="right"] { right: var(--sm-3); }
.sm-swipe-hint[data-armed="1"] { opacity: 1; }
.sm-swipe-hint[data-armed="1"][data-ready="1"] { background: var(--sm-gold); color: var(--sm-night); }


/* ═══════════════════════════════════════════ 5. CONTENT RE-SKIN ═════════ *
 * From here down, the selectors are the ones the hand-written map pages, the
 * master doc, the exam page and the transcript reader already use. Nothing
 * below needs a markup change.
 * ======================================================================== */

/* ── 5a. the legacy back-bar ────────────────────────────────────────────── */
/* brand.js removes these once the top bar exists. This rule is what the page
   looks like in the fraction of a second before it does, and if JS is off. */
.backbar {
  background: var(--sm-night) !important;
  color: rgba(232,227,214,.6) !important;
  font-size: var(--sm-fs-xs);
  padding: 10px var(--sm-gutter);
}
.backbar a { color: var(--sm-gold-lift) !important; font-weight: 600; }
body[data-sm-chromed] .backbar { display: none; }

/* A legacy strip that brand.js decided it could NOT delete, because one of its
   links goes somewhere the rail does not list. It keeps its links and loses
   its own dark styling and its top:0 sticky seat. */
[data-sm-keptbar] {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sm-2);
  max-width: calc(var(--sm-measure) + 2 * var(--sm-gutter));
  margin: var(--sm-4) auto 0;
  padding: 0 var(--sm-gutter);
  font-size: var(--sm-fs-xs); color: var(--sm-ink-3);
}
[data-sm-keptbar] a {
  color: var(--sm-gold-deep) !important; font-weight: 700;
  min-height: 38px; display: inline-flex; align-items: center;
}

/* ── 5b. the hero ───────────────────────────────────────────────────────── */

header.hero, body > header:not(.sm-top) {
  position: relative;
  overflow: hidden;
  background: linear-gradient(152deg, var(--sm-night) 0%, var(--sm-night-2) 58%, var(--sm-night-3) 100%);
  color: var(--sm-night-ink);
  border: 1px solid rgba(232,227,214,.08);
  border-radius: var(--sm-r-5);
  padding: var(--sm-6) var(--sm-5) var(--sm-5);
  box-shadow: var(--sm-sh-3);
  isolation: isolate;
}
/* The accent lives in a hairline at the top and a wash of colour behind the
   text — not in a slab of colour, which is what made every map look like a
   different site. */
header.hero::before, body > header:not(.sm-top)::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px; z-index: 1;
  background: linear-gradient(90deg, var(--sm-accent), var(--sm-gold-lift) 62%, transparent);
}
header.hero::after, body > header:not(.sm-top)::after {
  content: ""; position: absolute; z-index: -1;
  width: 420px; height: 420px; right: -140px; top: -180px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--sm-accent) 34%, transparent), transparent 68%);
  pointer-events: none;
}
header.hero h1, body > header:not(.sm-top) h1 {
  color: #FBF8F1;
  margin: 0 0 var(--sm-2);
  font-size: var(--sm-fs-h1);
  font-weight: 400;
}
header.hero p, body > header:not(.sm-top) p,
header.hero .sub, body > header:not(.sm-top) .sub,
header.hero .cite, body > header:not(.sm-top) .cite {
  color: rgba(232,227,214,.66);
  font-size: var(--sm-fs-sm);
  margin: var(--sm-2) 0 0;
  max-width: 62ch;
}
header.hero em, body > header:not(.sm-top) em { color: rgba(232,227,214,.8); }
header.hero b, header.hero strong,
body > header:not(.sm-top) b, body > header:not(.sm-top) strong { color: #FBF8F1; }
header.hero a, body > header:not(.sm-top) a { color: var(--sm-gold-lift); }

header.hero .kicker, body > header:not(.sm-top) .kicker {
  font-family: var(--sm-sans);
  font-size: var(--sm-fs-micro); letter-spacing: var(--sm-track-label);
  text-transform: uppercase; font-weight: 700;
  color: var(--sm-gold-lift);
  margin: 0 0 var(--sm-3);
}
header.hero .ar, header.hero .ar-title,
body > header:not(.sm-top) .ar, body > header:not(.sm-top) .ar-title {
  color: var(--sm-gold-lift);
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.9rem);
  margin-top: var(--sm-3);
  opacity: .95;
}
header.hero .scope, body > header:not(.sm-top) .scope {
  display: inline-block; margin-top: var(--sm-4);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(232,227,214,.16);
  color: rgba(232,227,214,.82);
  padding: 8px 15px; border-radius: var(--sm-r-pill);
  font-size: var(--sm-fs-xs);
}

/* A hero that is a direct child of <body> (three of the Arabic maps) needs the
   page's own gutters, because it sits outside .wrap. */
body > header:not(.sm-top) {
  max-width: calc(var(--sm-measure) + 2 * var(--sm-gutter));
  margin: var(--sm-5) auto 0;
  width: calc(100% - 2 * var(--sm-gutter));
}

/* The quick-facts strip brand.js measures from the page itself: how many
   sections, how long it reads. Nothing here is invented — it is counted. */
.sm-facts {
  display: flex; flex-wrap: wrap; gap: var(--sm-4) var(--sm-5);
  margin-top: var(--sm-5); padding-top: var(--sm-4);
  border-top: 1px solid rgba(232,227,214,.12);
}
.sm-facts div { display: grid; gap: 2px; }
.sm-facts b {
  font-family: var(--sm-serif); font-size: var(--sm-fs-h3); font-weight: 500;
  color: var(--sm-gold-lift); line-height: 1; font-variant-numeric: tabular-nums;
}
.sm-facts span {
  font-size: var(--sm-fs-micro); letter-spacing: .12em; text-transform: uppercase;
  color: rgba(232,227,214,.45);
}

/* ── 5c. sections ───────────────────────────────────────────────────────── */

main > section, .wrap > section {
  position: relative;
  background: var(--sm-paper);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-r-4);
  padding: var(--sm-5);
  margin-top: var(--sm-4);
  box-shadow: var(--sm-sh-1);
  scroll-margin-top: var(--sm-scroll-pad);
  transition: box-shadow var(--sm-t) var(--sm-ease), border-color var(--sm-t) var(--sm-ease);
}
main > section:hover, .wrap > section:hover { box-shadow: var(--sm-sh-2); }

/* the section header: a gold numeral tile, the serif title, a quiet subtitle */
.sec-head {
  display: flex; align-items: flex-start; gap: var(--sm-3);
  margin: 0 0 var(--sm-4);
  padding-bottom: var(--sm-3);
  border-bottom: 1px solid var(--sm-line-2);
}
.sec-head .num {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--sm-serif); font-weight: 500; font-size: 16px;
  color: var(--sm-night) !important;
  /* The per-page inline `style="background:var(--plum)"` on some numerals is
     overridden on purpose: the numeral is house furniture, the SUBJECT is what
     carries colour, and six different numeral colours on one page was a large
     part of why the maps read as disorganised. */
  background: linear-gradient(145deg, var(--sm-gold-lift), var(--sm-gold)) !important;
  box-shadow: var(--sm-sh-gold);
  font-variant-numeric: tabular-nums;
}
.sec-head h2, .sec-head h3 { margin: 0; flex: 1; min-width: 0; align-self: center; }
.sec-head h2 .sub, .sec-head h3 .sub, h2 .sub {
  display: block;
  font-family: var(--sm-sans);
  font-size: var(--sm-fs-xs); font-weight: 500;
  color: var(--sm-ink-3);
  letter-spacing: 0; margin-top: 3px;
  text-transform: none;
}

/* a click-to-copy anchor beside every section heading */
.sm-anchor {
  opacity: 0; margin-left: 8px; color: var(--sm-ink-4);
  font-size: .8em; text-decoration: none;
  transition: opacity var(--sm-t-fast), color var(--sm-t-fast);
}
:is(h2, h3):hover .sm-anchor, .sm-anchor:focus-visible { opacity: 1; }
.sm-anchor:hover { color: var(--sm-accent); }
@media (pointer: coarse) { .sm-anchor { display: none; } }

/* ── 5d. lists ──────────────────────────────────────────────────────────── */

ul, ol { margin: 0 0 var(--sm-3); padding-left: 1.35em; }
li { margin: var(--sm-1) 0; }
li::marker { color: var(--sm-accent); }
ul ul, ol ol, ul ol, ol ul { margin-bottom: 0; }

/* the checklist the maps use for revision */
.check { list-style: none; padding-left: 0; }
.check li { padding-left: 32px; position: relative; margin: 10px 0; }
.check li::before {
  content: ""; position: absolute; left: 0; top: .28em;
  width: 17px; height: 17px; border-radius: 5px;
  border: 1.5px solid var(--sm-gold);
  background: var(--sm-gold-wash);
  font-size: 0;
}

/* ── 5e. tables ─────────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  margin: var(--sm-3) 0;
  font-size: var(--sm-fs-sm);
  background: var(--sm-paper);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-r-3);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: var(--sm-3);
  border-bottom: 1px solid var(--sm-line-2);
  vertical-align: top;
}
th {
  background: var(--sm-cream-2) !important;
  color: var(--sm-ink-3) !important;
  font-family: var(--sm-sans);
  font-size: var(--sm-fs-micro) !important;
  font-weight: 700;
  letter-spacing: var(--sm-track-label);
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr:last-child td, tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--sm-t-fast) var(--sm-ease); }
tbody tr:hover { background: var(--sm-paper-2); }
.lvl { font-weight: 700; color: var(--sm-accent); white-space: nowrap; }
.mistake td:first-child { color: var(--sm-stop); font-weight: 700; }

/* A table of Arabic terms will not shrink below its longest word. Give it a
   scroll box of its own rather than letting it widen the document — a page
   that slides sideways makes every vertical swipe feel like a fight. The
   four-layer background is the standard shadow trick: the two `local` layers
   ride the scroll and uncover the two `scroll` shadows only while there is
   more table to reach. */
@media (max-width: 900px) {
  table {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    background-image:
      linear-gradient(to right, var(--sm-paper) 30%, rgba(255,253,248,0)),
      linear-gradient(to left,  var(--sm-paper) 30%, rgba(255,253,248,0)),
      linear-gradient(to right, rgba(23,33,46,.10), rgba(23,33,46,0) 12px),
      linear-gradient(to left,  rgba(23,33,46,.10), rgba(23,33,46,0) 12px);
    background-repeat: no-repeat;
    background-size: 34px 100%, 34px 100%, 14px 100%, 14px 100%;
    background-position: 0 0, 100% 0, 0 0, 100% 0;
    background-attachment: local, local, scroll, scroll;
  }
}

/* ── 5f. callouts & cards ───────────────────────────────────────────────── */

.callout {
  border: 1px solid var(--sm-gold-line);
  border-left: 3px solid var(--sm-gold);
  background: var(--sm-gold-wash);
  padding: var(--sm-3) var(--sm-4);
  border-radius: 0 var(--sm-r-3) var(--sm-r-3) 0;
  margin: var(--sm-4) 0;
  font-size: var(--sm-fs-sm);
  color: var(--sm-ink-2);
}
.callout b, .callout strong { color: var(--sm-ink); }
.callout.green, .callout.blue {
  border-color: color-mix(in srgb, var(--sm-accent) 26%, var(--sm-line));
  border-left-color: var(--sm-accent);
  background: var(--sm-accent-wash);
}

.card, .ex {
  background: var(--sm-paper-2);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-r-3);
  padding: var(--sm-4);
  transition: border-color var(--sm-t) var(--sm-ease), box-shadow var(--sm-t) var(--sm-ease);
}
.card:hover { border-color: var(--sm-gold-line); box-shadow: var(--sm-sh-1); }
.card h4 { margin: 0 0 var(--sm-2); color: var(--sm-accent); font-size: var(--sm-fs-h4); }
.card p { margin: 0; font-size: var(--sm-fs-sm); color: var(--sm-ink-2); }
.ex { font-size: var(--sm-fs-sm); margin-top: var(--sm-2); }
.ex b { color: var(--sm-accent); }
.verse, .ex.verse { font-style: italic; color: var(--sm-ink-2); }
.big { font-family: var(--sm-serif); font-size: var(--sm-fs-h1); font-weight: 500; color: var(--sm-accent); line-height: 1; }
.lead { font-size: var(--sm-fs-lead); color: var(--sm-ink-2); }

/* every hand-rolled 2- and 3-up grid, made fluid rather than fixed */
.grid2, .grid3, .grid4 {
  display: grid;
  gap: var(--sm-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--sm-track, 210px)), 1fr));
}
.grid2 { --sm-track: 260px; }
.grid3 { --sm-track: 190px; }
.grid4 { --sm-track: 150px; }

/* ── 5g. pills & badges ─────────────────────────────────────────────────── */

.pill, .pg, .board-tag, .badge {
  display: inline-block;
  font-family: var(--sm-sans);
  font-size: var(--sm-fs-micro);
  font-weight: 700; letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: var(--sm-r-pill);
  vertical-align: middle; white-space: nowrap;
  background: var(--sm-gold-wash); color: var(--sm-gold-deep);
  border: 1px solid var(--sm-gold-line);
}
.p-green, .p-blue {
  background: var(--sm-accent-wash); color: var(--sm-accent);
  border-color: color-mix(in srgb, var(--sm-accent) 26%, transparent);
}
.p-rose { background: var(--sm-stop-wash); color: var(--sm-stop); border-color: color-mix(in srgb, var(--sm-stop) 24%, transparent); }
.p-gold { background: var(--sm-gold-wash); color: var(--sm-gold-deep); border-color: var(--sm-gold-line); }
/* The page citation is the point of the badge under RULE ZERO — it has to stay
   readable on a phone, so it never shrinks below 12px. */
.pg, .board-tag { font-size: max(12px, var(--sm-fs-micro)); }

/* ── a citation you can actually follow ─────────────────────────────────── *
 * brand.js turns "📖 p.54" into a link that opens the book at that page, and
 * "🎧 04:14" into a control that plays the lesson from that second. The badge
 * keeps its own colour; what changes is that it now advertises being live.
 * Citations whose offset is unverified are left untouched and inert — the
 * absence of the underline is the honest signal there.
 * ==================================================================== */
[data-sm-cited] { cursor: pointer; transition: background var(--sm-t-fast) var(--sm-ease), border-color var(--sm-t-fast) var(--sm-ease); }
.sm-cite {
  color: inherit; font: inherit; background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  text-decoration-color: currentColor;
  display: inline-flex; align-items: center; gap: 4px;
}
[data-sm-cited]:hover { filter: brightness(.94); }
[data-sm-cited]:hover .sm-cite { text-decoration-style: solid; }
.sm-cite:focus-visible { outline: 2px solid var(--sm-gold); outline-offset: 3px; }
.sm-cite-time::after {
  content: "▸";
  font-size: .9em; line-height: 1;
}
@media (pointer: coarse) {
  [data-sm-cited] { padding: 5px 10px; }
}

/* ── 5h. disclosure (the memory questions) ──────────────────────────────── */

.qa .q, details.q {
  background: var(--sm-paper-2);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-r-3);
  padding: var(--sm-3) var(--sm-4);
  margin: var(--sm-2) 0;
  transition: border-color var(--sm-t) var(--sm-ease);
}
.qa .q:hover { border-color: var(--sm-gold-line); }
.qa .q .qtext { font-weight: 600; color: var(--sm-ink); }
details summary {
  cursor: pointer;
  color: var(--sm-accent);
  font-size: var(--sm-fs-sm); font-weight: 700;
  list-style: none;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 0; min-height: 32px;
  user-select: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--sm-t) var(--sm-ease);
}
details[open] summary::before { transform: rotate(90deg); }
.qa .ans, details .ans {
  margin-top: var(--sm-2);
  font-size: var(--sm-fs-sm);
  color: var(--sm-ink-2);
  background: var(--sm-accent-wash);
  border-radius: var(--sm-r-2);
  padding: var(--sm-3);
  animation: smReveal var(--sm-t) var(--sm-ease-out);
}
@keyframes smReveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── 5h-bis. LESSONS — the unit the class actually studies ──────────────── *
 * A map's "Class Lessons" section was one long run of headings and bullets
 * with no seam between one lesson and the next. brand.js turns each into an
 * <article id="lesson-N">; this gives it a card, an index, and a focus mode.
 * ======================================================================== */

.sm-lesson {
  position: relative;
  background: var(--sm-paper-2);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-r-3);
  padding: var(--sm-4) var(--sm-4) var(--sm-2);
  margin: var(--sm-3) 0;
  scroll-margin-top: calc(var(--sm-scroll-pad) + 52px);
  transition: border-color var(--sm-t) var(--sm-ease), box-shadow var(--sm-t) var(--sm-ease);
}
.sm-lesson:hover { border-color: var(--sm-gold-line); }
.sm-lesson[data-sm-hidden] { display: none; }
.sm-lesson:target, body[data-sm-focus] .sm-lesson:not([data-sm-hidden]) {
  border-color: var(--sm-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sm-gold) 14%, transparent);
  background: var(--sm-paper);
}

.sm-lesson-head {
  display: flex; align-items: flex-start; gap: var(--sm-3);
  margin-bottom: var(--sm-3);
  padding-bottom: var(--sm-2);
  border-bottom: 1px solid var(--sm-line-2);
}
.sm-lesson-n {
  flex: 0 0 auto;
  min-width: 30px; height: 30px; padding: 0 7px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-family: var(--sm-serif); font-size: 15px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: var(--sm-night); color: var(--sm-gold-lift);
}
.sm-lesson-t { display: grid; gap: 2px; min-width: 0; }
.sm-lesson-title {
  font-family: var(--sm-serif); font-size: var(--sm-fs-h3); font-weight: 500;
  color: var(--sm-ink); line-height: 1.28;
}
.sm-lesson-meta { font-size: var(--sm-fs-xs); color: var(--sm-ink-3); }

/* the lesson's own bullets read as notes, not as a bulleted wall */
.sm-lesson > ul { list-style: none; padding-left: 0; margin: 0; }
.sm-lesson > ul > li {
  position: relative;
  padding: var(--sm-2) 0 var(--sm-2) var(--sm-5);
  margin: 0;
  border-top: 1px solid var(--sm-line-2);
  font-size: var(--sm-fs-sm);
  line-height: 1.62;
  color: var(--sm-ink-2);
}
.sm-lesson > ul > li:first-child { border-top: 0; }
/* ✅ / 🎧 already open each bullet in the source text; pull them into the
   margin so the eye can sort "printed in the book" from "the teacher said" at
   a glance, which is the distinction RULE ZERO turns on. */
.sm-lesson > ul > li::before {
  content: "";
  position: absolute; left: 6px; top: 1.05em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sm-gold);
}
.sm-lesson > ul > li b:first-child,
.sm-lesson > ul > li strong:first-child { color: var(--sm-ink); }

.sm-lesson-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sm-2);
  margin-top: var(--sm-3);
  padding-top: var(--sm-3);
  border-top: 1px solid var(--sm-line-2);
}
.sm-lesson-foot a {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--sm-fs-xs); font-weight: 700;
  color: var(--sm-ink-3);
  padding: 8px 12px; border-radius: var(--sm-r-pill);
  border: 1px solid var(--sm-line);
  background: var(--sm-paper);
  transition: color var(--sm-t-fast) var(--sm-ease), border-color var(--sm-t-fast) var(--sm-ease);
}
.sm-lesson-foot a:hover { color: var(--sm-gold-deep); border-color: var(--sm-gold); }

/* ---- the index across the top of the lessons -------------------------- */

.sm-lessonbar {
  position: sticky;
  top: calc(var(--sm-topbar-h) + var(--sm-safe-t));
  z-index: 24;
  display: flex; align-items: center; gap: var(--sm-3);
  margin: var(--sm-3) 0 var(--sm-4);
  padding: var(--sm-2) 0;
  background: color-mix(in srgb, var(--sm-paper) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--sm-line-2);
  transition: transform var(--sm-t) var(--sm-ease);
}
body[data-sm-chrome="hidden"] .sm-lessonbar {
  transform: translateY(calc(-1 * (var(--sm-topbar-h) + var(--sm-safe-t))));
}
.sm-lessonbar-label {
  flex: 0 0 auto;
  font-size: var(--sm-fs-micro); letter-spacing: var(--sm-track-label);
  text-transform: uppercase; font-weight: 700; color: var(--sm-ink-4);
}
.sm-lessonbar-chips {
  display: flex; gap: 5px; overflow-x: auto; flex: 1; min-width: 0;
  scrollbar-width: none; scroll-snap-type: x proximity;
  padding: 2px 0;
}
.sm-lessonbar-chips::-webkit-scrollbar { display: none; }
.sm-lessonbar-chips a {
  flex: 0 0 auto; scroll-snap-align: start;
  min-width: 34px; min-height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--sm-line);
  background: var(--sm-paper);
  border-radius: 9px;
  font-size: var(--sm-fs-xs); font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--sm-ink-3);
  transition: color var(--sm-t-fast) var(--sm-ease), border-color var(--sm-t-fast) var(--sm-ease),
              background var(--sm-t-fast) var(--sm-ease);
}
.sm-lessonbar-chips a:hover {
  color: var(--sm-gold-deep); border-color: var(--sm-gold); background: var(--sm-gold-wash);
}
.sm-lessonbar-chips a[aria-current="true"] {
  background: var(--sm-night); color: var(--sm-gold-lift); border-color: var(--sm-night);
}
.sm-lessonbar-all {
  flex: 0 0 auto;
  border: 1px solid var(--sm-gold);
  background: var(--sm-gold-wash);
  color: var(--sm-gold-deep);
  border-radius: var(--sm-r-pill);
  padding: 8px 15px; min-height: 36px;
  font-size: var(--sm-fs-xs); font-weight: 700;
  cursor: pointer;
  transition: background var(--sm-t-fast) var(--sm-ease);
}
.sm-lessonbar-all:hover { background: var(--sm-gold); color: var(--sm-night); }

/* In focus mode the surrounding sections stay, but the lesson section says
   plainly that it is showing one of many — never a silent filter. */
body[data-sm-focus] .sm-has-lessons { border-color: var(--sm-gold-line); }

@media (max-width: 620px) {
  .sm-lessonbar { flex-wrap: wrap; gap: var(--sm-2); }
  .sm-lessonbar-label { width: 100%; }
  .sm-lesson { padding-inline: var(--sm-3); }
  .sm-lesson > ul > li { padding-left: var(--sm-4); }
}

/* the nested lesson list inside "On this page" */
.sm-toc-sub { list-style: none; margin: 0 0 2px 0; padding: 0 0 0 18px; display: grid; gap: 1px; }
.sm-toc-sub a { font-size: var(--sm-fs-xs); padding: 6px 10px 6px 10px; border-left-width: 1px; }
.sm-toc-sub a .sm-toc-n { font-size: var(--sm-fs-micro); }
@media (pointer: coarse) { .sm-toc-sub a { min-height: 40px; } }

/* ── 5i. the footer line every map ends with ────────────────────────────── */

.foot, main > footer, body > footer {
  margin: var(--sm-5) auto 0;
  text-align: center;
  color: var(--sm-ink-4);
  font-size: var(--sm-fs-xs);
  line-height: 1.6;
  padding: var(--sm-4) var(--sm-gutter) var(--sm-6);
  max-width: 62ch;
}

/* ── 5j. the ▶ Listen / Transcript row (lesson-audio.js) ────────────────── */

.lsn-audio {
  display: flex; flex-wrap: wrap; gap: var(--sm-2); align-items: center;
  margin: var(--sm-3) 0 var(--sm-2);
  padding: var(--sm-2) var(--sm-3);
  background: var(--sm-paper-2);
  border: 1px solid var(--sm-line-2);
  border-radius: var(--sm-r-3);
}
.lsn-audio button, .lsn-audio a.la-tx {
  font-family: var(--sm-sans);
  font-size: var(--sm-fs-xs) !important; font-weight: 700 !important;
  border: 1px solid var(--sm-line) !important;
  background: var(--sm-paper) !important;
  color: var(--sm-ink-2) !important;
  border-radius: var(--sm-r-pill) !important;
  padding: 8px 15px !important;
  min-height: 38px;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; text-decoration: none; line-height: 1;
  transition: border-color var(--sm-t-fast) var(--sm-ease), color var(--sm-t-fast) var(--sm-ease), background var(--sm-t-fast) var(--sm-ease);
}
.lsn-audio button:hover, .lsn-audio a.la-tx:hover {
  border-color: var(--sm-gold) !important; color: var(--sm-gold-deep) !important;
}
.lsn-audio .la-play {
  background: var(--sm-night) !important; color: var(--sm-gold-lift) !important;
  border-color: var(--sm-night) !important;
}
.lsn-audio .la-play:hover { background: var(--sm-night-2) !important; color: #FBF8F1 !important; }
.lsn-audio .la-part.on {
  background: var(--sm-gold) !important; color: var(--sm-night) !important;
  border-color: var(--sm-gold) !important;
}
.lsn-audio audio { height: 36px; max-width: 100%; flex: 1 1 240px; min-width: 180px; }
.lsn-audio .la-note { color: var(--sm-ink-4); font-size: var(--sm-fs-xs); }


/* ═══════════════════════════ 6. THE COMMUNITY LAYER (quiz + notes) ══════ *
 * community.css is linked at the end of <body>, i.e. AFTER this file, so a
 * bare `.cm-wrap` rule would lose. `:root .cm-wrap` costs one specificity
 * point and settles it regardless of order. Do not remove the `:root`.
 * ======================================================================== */

:root .cm-wrap {
  --cm-ink:        var(--sm-ink);
  --cm-muted:      var(--sm-ink-3);
  --cm-line:       var(--sm-line);
  --cm-green:      var(--sm-accent);
  --cm-green-soft: var(--sm-accent-wash);
  --cm-gold:       var(--sm-gold);
  --cm-gold-soft:  var(--sm-gold-wash);
  --cm-rose:       var(--sm-stop);
  --cm-rose-soft:  var(--sm-stop-wash);
  --cm-card:       var(--sm-paper);
  font-family: var(--sm-sans);
  max-width: calc(var(--sm-measure) + 2 * var(--sm-gutter));
  padding-inline: var(--sm-gutter);
  margin: 0 auto var(--sm-6);
}
:root .cm-block {
  background: var(--sm-paper);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-r-4);
  padding: var(--sm-5);
  margin-top: var(--sm-4);
  box-shadow: var(--sm-sh-1);
}
:root .cm-h h3 { font-family: var(--sm-serif); font-weight: 500; font-size: var(--sm-fs-h2); }
:root .cm-h .cm-ic {
  border-radius: 10px;
  background: linear-gradient(145deg, var(--sm-gold-lift), var(--sm-gold));
  color: var(--sm-night);
  box-shadow: var(--sm-sh-gold);
}
:root .cm-sub { color: var(--sm-ink-3); font-size: var(--sm-fs-sm); }
:root .cm-qtext { font-family: var(--sm-serif); font-weight: 500; font-size: var(--sm-fs-h3); line-height: 1.35; }
:root .cm-qtopic { color: var(--sm-accent); letter-spacing: var(--sm-track-label); }
:root .cm-opt {
  background: var(--sm-paper-2);
  border: 1.5px solid var(--sm-line);
  border-radius: var(--sm-r-3);
  padding: var(--sm-3) var(--sm-4);
  font-size: var(--sm-fs-sm);
  min-height: 46px;
  transition: border-color var(--sm-t-fast) var(--sm-ease), background var(--sm-t-fast) var(--sm-ease), transform var(--sm-t-fast) var(--sm-ease);
}
:root .cm-opt:hover:not(:disabled) { border-color: var(--sm-gold); background: var(--sm-paper); }
:root .cm-opt:active:not(:disabled) { transform: scale(.99); }
:root .cm-opt.correct { border-color: var(--sm-ok); background: var(--sm-ok-wash); }
:root .cm-opt.wrong   { border-color: var(--sm-stop); background: var(--sm-stop-wash); }
:root .cm-opt.correct .cm-mk { color: var(--sm-ok); }
:root .cm-opt.wrong   .cm-mk { color: var(--sm-stop); }
:root .cm-btn {
  background: var(--sm-night); color: var(--sm-gold-lift);
  border-radius: var(--sm-r-pill); padding: 12px 24px;
  font-weight: 700; font-size: var(--sm-fs-sm);
  min-height: 44px;
  transition: background var(--sm-t-fast) var(--sm-ease), transform var(--sm-t-fast) var(--sm-ease);
}
:root .cm-btn:hover { background: var(--sm-night-2); filter: none; }
:root .cm-btn:active { transform: scale(.97); }
:root .cm-btn.ghost { background: var(--sm-paper); color: var(--sm-ink-2); border: 1.5px solid var(--sm-line); }
:root .cm-btn.ghost:hover { border-color: var(--sm-gold); color: var(--sm-gold-deep); }
:root .cm-score .cm-big { font-family: var(--sm-serif); font-weight: 500; color: var(--sm-accent); font-size: var(--sm-fs-mega); }
:root .cm-dot { border-radius: 3px; background: var(--sm-line); }
:root .cm-dot.done  { background: var(--sm-ok); }
:root .cm-dot.wrong { background: var(--sm-stop); }
:root .cm-dot.cur   { background: var(--sm-gold); }
:root .cm-explain {
  background: var(--sm-gold-wash); border-left: 3px solid var(--sm-gold);
  border-radius: 0 var(--sm-r-2) var(--sm-r-2) 0; color: var(--sm-ink-2);
  font-size: var(--sm-fs-sm);
}
:root .cm-input, :root .cm-ta, :root .cm-select {
  border: 1px solid var(--sm-line); border-radius: var(--sm-r-2);
  background: var(--sm-paper); color: var(--sm-ink);
  padding: 11px 13px; font-size: var(--sm-fs-sm); font-family: inherit;
  min-height: 44px;
  transition: border-color var(--sm-t-fast) var(--sm-ease), box-shadow var(--sm-t-fast) var(--sm-ease);
}
:root .cm-input:focus, :root .cm-ta:focus, :root .cm-select:focus {
  outline: none; border-color: var(--sm-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sm-gold) 18%, transparent);
}
:root .cm-note { background: var(--sm-paper); border: 1px solid var(--sm-line); border-radius: var(--sm-r-3); }
:root .cm-badge { border-radius: var(--sm-r-pill); font-size: var(--sm-fs-micro); font-weight: 700; }


/* ══════════════════════════════════ 7. PER-PAGE ADJUSTMENTS ═════════════ */

/* ── master.html — the rendered markdown ───────────────────────────────── */

#md h1 {
  font-size: var(--sm-fs-h1); font-weight: 400;
  margin: var(--sm-7) 0 var(--sm-2);
  padding-top: var(--sm-4);
  border-top: 1px solid var(--sm-line);
}
#md h1:first-child { border-top: none; margin-top: var(--sm-4); }
#md h2 { font-size: var(--sm-fs-h2); font-weight: 500; color: var(--sm-ink); margin: var(--sm-5) 0 var(--sm-2); }
#md h3 { font-size: var(--sm-fs-h3); font-weight: 600; margin: var(--sm-4) 0 var(--sm-1); }
#md h4 {
  font-family: var(--sm-sans); font-size: var(--sm-fs-micro); font-weight: 700;
  letter-spacing: var(--sm-track-label); text-transform: uppercase;
  color: var(--sm-ink-4); margin: var(--sm-4) 0 var(--sm-1);
}
#md a {
  color: var(--sm-gold-deep); font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
  text-decoration-color: var(--sm-gold-line);
}
#md a:hover { text-decoration-color: var(--sm-gold); }
#md blockquote {
  margin: var(--sm-4) 0;
  padding: var(--sm-3) var(--sm-4);
  background: var(--sm-gold-wash);
  border: 1px solid var(--sm-gold-line);
  border-left: 3px solid var(--sm-gold);
  border-radius: 0 var(--sm-r-3) var(--sm-r-3) 0;
  color: var(--sm-ink-2); font-size: var(--sm-fs-sm);
}
/* `#md code{white-space:nowrap}` is an ID selector, so this needs !important —
   without it a long source filename is clipped rather than wrapped. */
#md code { white-space: normal !important; }
.tbl-scroll {
  overflow-x: auto; margin: var(--sm-4) 0;
  border-radius: var(--sm-r-3);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  box-shadow: none;
}
#md table { border: 1px solid var(--sm-line); }
#md td:first-child { font-weight: 600; white-space: normal; }
.loading { color: var(--sm-ink-4); text-align: center; padding: var(--sm-7) 0; font-size: var(--sm-fs-sm); }

/* master.html's own jump nav — restyled rather than removed, because it is
   built from the six subject headings and predates the shared contents rail. */
nav.jump {
  position: sticky;
  top: calc(var(--sm-topbar-h) + var(--sm-safe-t));
  z-index: 30;
  background: color-mix(in srgb, var(--sm-cream) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sm-line);
  transition: transform var(--sm-t) var(--sm-ease);
}
body[data-sm-chrome="hidden"] nav.jump {
  transform: translateY(calc(-1 * (var(--sm-topbar-h) + var(--sm-safe-t))));
}
nav.jump .inner {
  display: flex; gap: var(--sm-2); overflow-x: auto;
  padding: var(--sm-3) var(--sm-gutter);
  max-width: calc(var(--sm-measure) + 2 * var(--sm-gutter));
  margin: 0 auto; scrollbar-width: none;
  scroll-snap-type: x proximity;
}
nav.jump .inner::-webkit-scrollbar { display: none; }
nav.jump a {
  white-space: nowrap; scroll-snap-align: start;
  font-size: var(--sm-fs-xs); font-weight: 700;
  color: var(--sm-ink-3);
  border: 1px solid var(--sm-line);
  background: var(--sm-paper);
  padding: 9px 15px; border-radius: var(--sm-r-pill);
  flex: 0 0 auto; min-height: 38px; display: inline-flex; align-items: center;
  transition: color var(--sm-t-fast) var(--sm-ease), border-color var(--sm-t-fast) var(--sm-ease), background var(--sm-t-fast) var(--sm-ease);
}
nav.jump a:hover { color: var(--sm-gold-deep); border-color: var(--sm-gold); background: var(--sm-gold-wash); }

/* ── .toolbar — the maps' own jump/filter row ──────────────────────────── *
 * Five map pages carry one of these: a row of pills that jumps to a topic or
 * filters the list. It is the closest thing the maps had to navigation, so it
 * matters that it reads as part of the shell rather than as five different
 * hand-rolled button bars.
 *
 * ⚠ Three of those pages set `position: sticky; top: 0`, which was written
 * when nothing else was pinned to the top of the window. It now has to clear
 * the app bar, or it parks itself underneath one and both are unreadable.
 * ==================================================================== */
.toolbar {
  display: flex; flex-wrap: wrap; gap: var(--sm-2);
  margin: var(--sm-4) 0 var(--sm-3);
  padding: var(--sm-2) 0;
}
.wrap > .toolbar, main > .toolbar {
  position: sticky;
  top: calc(var(--sm-topbar-h) + var(--sm-safe-t));
  z-index: 25;
  background: color-mix(in srgb, var(--sm-cream) 90%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sm-line-2);
  transition: transform var(--sm-t) var(--sm-ease);
}
body[data-sm-chrome="hidden"] :is(.wrap, main) > .toolbar {
  transform: translateY(calc(-1 * (var(--sm-topbar-h) + var(--sm-safe-t))));
}
.toolbar button, .toolbar a {
  border: 1px solid var(--sm-line);
  background: var(--sm-paper);
  color: var(--sm-ink-3);
  padding: 9px 16px;
  border-radius: var(--sm-r-pill);
  font-family: var(--sm-sans);
  font-size: var(--sm-fs-xs); font-weight: 700;
  min-height: 40px; display: inline-flex; align-items: center;
  cursor: pointer; line-height: 1;
  transition: color var(--sm-t-fast) var(--sm-ease), border-color var(--sm-t-fast) var(--sm-ease),
              background var(--sm-t-fast) var(--sm-ease), transform var(--sm-t-fast) var(--sm-ease);
}
.toolbar button:hover, .toolbar a:hover {
  color: var(--sm-gold-deep); border-color: var(--sm-gold); background: var(--sm-gold-wash);
}
.toolbar button:active { transform: scale(.97); }
.toolbar button.active {
  background: var(--sm-night); color: var(--sm-gold-lift); border-color: var(--sm-night);
}

/* ── exam.html + transcripts.html — chips, buttons, fields ─────────────── */

.chips { display: flex; flex-wrap: wrap; gap: var(--sm-2); margin: var(--sm-3) 0 var(--sm-1); }
.chip {
  border: 1px solid var(--sm-line);
  background: var(--sm-paper);
  color: var(--sm-ink-3);
  padding: 9px 16px; border-radius: var(--sm-r-pill);
  font-size: var(--sm-fs-xs); font-weight: 700;
  min-height: 40px; display: inline-flex; align-items: center;
  cursor: pointer; user-select: none;
  transition: color var(--sm-t-fast) var(--sm-ease), border-color var(--sm-t-fast) var(--sm-ease), background var(--sm-t-fast) var(--sm-ease), transform var(--sm-t-fast) var(--sm-ease);
}
.chip:hover { color: var(--sm-gold-deep); border-color: var(--sm-gold); background: var(--sm-gold-wash); }
.chip:active { transform: scale(.97); }
.chip.on { background: var(--sm-night); color: var(--sm-gold-lift); border-color: var(--sm-night); }
.chip .n { opacity: .6; font-weight: 500; margin-left: 6px; }

.btn {
  background: var(--sm-night); color: var(--sm-gold-lift);
  border: 0; border-radius: var(--sm-r-pill);
  padding: 13px 26px; min-height: 46px;
  font-size: var(--sm-fs-sm); font-weight: 700;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background var(--sm-t-fast) var(--sm-ease), transform var(--sm-t-fast) var(--sm-ease), box-shadow var(--sm-t-fast) var(--sm-ease);
}
.btn:hover { background: var(--sm-night-2); box-shadow: var(--sm-sh-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

select, input[type="text"], input[type="search"], input[type="number"], textarea {
  border: 1px solid var(--sm-line); border-radius: var(--sm-r-2);
  padding: 10px 13px; font-size: var(--sm-fs-sm);
  background: var(--sm-paper); color: var(--sm-ink); font-family: inherit;
  min-height: 42px;
  transition: border-color var(--sm-t-fast) var(--sm-ease), box-shadow var(--sm-t-fast) var(--sm-ease);
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--sm-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sm-gold) 18%, transparent);
}
.hint { font-size: var(--sm-fs-xs); color: var(--sm-ink-3); margin: 0 0 var(--sm-3); }
.stats { display: flex; flex-wrap: wrap; gap: var(--sm-4) var(--sm-5); margin-top: var(--sm-4); }
.stats b { display: block; font-family: var(--sm-serif); font-size: var(--sm-fs-h2); font-weight: 500; color: var(--sm-gold-lift); line-height: 1.1; }
.stats span { font-size: var(--sm-fs-micro); color: rgba(232,227,214,.45); text-transform: uppercase; letter-spacing: .12em; }
.rulezero {
  border: 1px solid var(--sm-gold-line); border-left: 3px solid var(--sm-gold);
  background: var(--sm-gold-wash); border-radius: 0 var(--sm-r-3) var(--sm-r-3) 0;
  padding: var(--sm-4); margin-top: var(--sm-5); font-size: var(--sm-fs-sm);
  color: var(--sm-ink-2);
}
.rulezero b { color: var(--sm-gold-deep); }

/* ── learn.html — its own app shell, brought onto the brand ────────────── */

body[data-sm-shell="app"] {
  --brand: var(--sm-gold); --brand-d: var(--sm-gold-deep); --brand-l: var(--sm-gold-wash);
  --bg: var(--sm-cream); --card: var(--sm-paper);
  --ink: var(--sm-ink); --ink2: var(--sm-ink-2); --mute: var(--sm-ink-4);
  --line: var(--sm-line); --line2: var(--sm-line-2);
  --gold: var(--sm-gold);
  --sh: var(--sm-sh-2); --sh2: var(--sm-sh-3); --r: var(--sm-r-4);
  font-family: var(--sm-sans);
}
body[data-sm-shell="app"] .top {
  background: color-mix(in srgb, var(--sm-cream) 88%, transparent);
  border-bottom: 1px solid var(--sm-line);
  padding-top: var(--sm-safe-t);
}
body[data-sm-shell="app"] .top-t { font-family: var(--sm-serif); font-weight: 500; font-size: var(--sm-fs-h4); }
body[data-sm-shell="app"] .top-s { color: var(--sm-ink-4); font-size: var(--sm-fs-xs); }
body[data-sm-shell="app"] h1,
body[data-sm-shell="app"] h2,
body[data-sm-shell="app"] h3 { font-family: var(--sm-serif); font-weight: 500; }

/* learn.html's own micro-labels are set at 10–11px. This is the one page on
   the site aimed squarely at a phone, used by someone learning the alphabet
   from zero, so nothing on it should sit under the 11.5px floor. */
body[data-sm-shell="app"] .stat span,
body[data-sm-shell="app"] .kick,
body[data-sm-shell="app"] .badge-now { font-size: var(--sm-fs-micro); }


/* ═══════════════════════════════════════ 8. MOTION & ACCESSIBILITY ══════ */

/* Sections arrive as you reach them, once, and only where the browser can do
   it without JavaScript. `animation-range` keeps it to the element's first
   appearance rather than running the whole way up the page. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) and (min-width: 720px) {
    main > section, .wrap > section, .sm-pager a {
      animation: smRise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 42%;
    }
    @keyframes smRise {
      from { opacity: 0; transform: translateY(14px); }
      to   { opacity: 1; transform: none; }
    }
  }
}

/* Cross-document view transitions: moving between two map pages becomes a fade
   rather than a white flash. Browsers without support ignore the at-rule. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  @view-transition { navigation: none; }
}

/* Anything a finger has to hit is at least 44px on a touch screen.
   ⚠ `details summary`, not bare `summary` — section 5h styles it with two
   classes' worth of specificity and a 32px min-height, so a bare `summary`
   selector here loses and every "Reveal" stays a 36px target. */
@media (pointer: coarse) {
  .chip, .btn, .sm-iconbtn, .lsn-audio button, .lsn-audio a.la-tx,
  .sm-navitem, .sm-dock button, .sm-dock a, nav.jump a,
  .toolbar button, .toolbar a,
  .sm-lessonbar-chips a, .sm-lessonbar-all, .sm-lesson-foot a,
  details summary, .qa summary { min-height: 44px; }
  .sm-lessonbar-chips a { min-width: 44px; }
  .sm-toc a, .sm-subnav a, .sm-toc-sub a, .sm-brand { min-height: 44px; align-items: center; }
  /* the numeral column in the contents is a label, not decoration */
  .sm-toc-n { font-size: var(--sm-fs-micro); }

  /* A 13px checkbox is a 13px target even when a label surrounds it, because
     the label was laid out inline and collapsed to the checkbox's own height. */
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  label:has(input[type="checkbox"]), label:has(input[type="radio"]), label.toggle {
    display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  }

  /* The master doc's own index is a run of headings whose entire content is a
     link. As inline text those were 17px-tall tap targets sitting 6px apart —
     the kind of list where you open the wrong subject twice before the right
     one. `:only-child` keeps this off ordinary prose links, whose line rhythm
     should not change. */
  #md :is(h2, h3, h4) > a:only-child {
    display: inline-flex; align-items: center;
    min-height: 44px; padding-right: 6px;
  }
}

/* The micro size is a 10px uppercase label — right for a mouse, too small for
   a phone held at arm's length, and on these pages it is carrying the [Page N]
   citations that RULE ZERO makes the whole point of the badge. Raise its floor
   wherever the screen is small or the pointer is a thumb. */
@media (max-width: 760px), (pointer: coarse) {
  :root { --sm-fs-micro: 0.72rem; }
  .sm-navlabel, .sm-brand-sub { font-size: var(--sm-fs-micro); }
  .sm-navitem .sm-count, .sm-railsearch kbd { font-size: var(--sm-fs-xs); }

  /* Every selector on the site that was hand-set below the floor. The list is
     exhaustive as of this build; to regenerate it, scan the inline <style>
     blocks of the pages under site/public for a font-size in px below 11.5
     and collect the selectors.

     These are not decoration. `.grade` is a hadith's authenticity grading and
     `.pg` / `.board-tag` are the printed-page citations that RULE ZERO exists
     to preserve; on the Forty Hadith map alone 90 of them sat at 10.5px.

     CAUTION: no CSS comment on this page may contain the two characters that
     close one. A path written with a glob — a star, a star, a slash — ends the
     comment where you did not mean it to, and everything after it is parsed as
     a declaration. That silently deleted this entire rule once already. */
  .badge-now, .board-tag, .grade, .opp, .pg, .pill, .syn, .tag, .tl-peg,
  .vbadge, .qtopic, .stat span, .unit .kick, .form-c .lb, .nw b,
  .score div span, .exwords span i, .letter-card .lesson-lbl,
  .turn .a-lbl, .turn .q-lbl, .vtbl td.src, .vtbl th .hd,
  table.conj thead th .hd { font-size: var(--sm-fs-micro) !important; }
}

/* No page may ever scroll sideways — on a phone that turns every vertical
   swipe into a fight with the layout. Tables scroll inside their own boxes
   instead (section 5e).
 *
 * ⚠ The clip goes on <html> ONLY, and <body> is explicitly put back to
 * `visible`. responsive.css sets `html, body { overflow-x: hidden }`, and any
 * non-visible overflow on <body> does two things that break this shell: it
 * makes <body> a scroll container, which kills `position: sticky` on the top
 * bar, and it makes <body> the containing block for fixed descendants, which
 * moves the rail, the dock and the sheet off the viewport and onto the
 * document — they then scroll away with the page. Overflow set on the ROOT
 * element is propagated to the viewport instead, and the root is treated as
 * `visible`, so nothing gains a containing block. */
html { overflow-x: clip; }
body { overflow-x: visible; }

@media print {
  .sm-rail, .sm-top, .sm-dock, .sm-toc, .sm-sheet, .sm-scrim,
  .sm-palette, .sm-pager, .backbar, nav.jump, #community { display: none !important; }
  body { background: #fff; display: block; }
  main, body > .wrap { max-width: none; padding: 0; }
  main > section, .wrap > section {
    box-shadow: none; border: 1px solid #ddd;
    break-inside: avoid; page-break-inside: avoid;
  }
  header.hero, body > header:not(.sm-top) {
    background: #fff !important; color: #000 !important;
    border: 1px solid #ddd; box-shadow: none;
  }
  header.hero h1, header.hero p, header.hero .kicker { color: #000 !important; }
  a { color: #000; }
}
