/* ==========================================================================
   Modern Victorian theme — shared stylesheet for all lessons and
   reference pages (Farsi, RTL)
   Workspace: teach / epidemiology
   A modern take on the Victorian printed-book look: period silhouette
   (double rules, ornaments, small caps) on a flat white/slate paper with
   soft radii and a single accent family.
   Palette: Tailwind blue-700 / blue-800 / blue-900 / blue-400 / blue-200 /
   blue-100 / slate family / white — every colour value lives in :root only,
   except the one scoped accent swap right below :root (anatomy & histology
   use Tailwind taupe-500 instead of blue-700).
   Include with: <link rel="stylesheet" href="../assets/victorian-theme.css">
   ========================================================================== */

@import url("iran-font.css"); /* IRAN family (FontIRAN) — local woff2/woff, no webfont */

:root {
  /* --- Palette (Tailwind values only) ------------------------------------ */
  --accent: #1d4ed8; /* blue-700 */
  --accent-hover: #1e40af; /* blue-800 */
  --accent-2: #1e3a8a; /* blue-900 — sparingly: tree level 2, cartouche, tip */
  --blue-100: #dbeafe; /* blue-100 — tint fills */
  --blue-200: #bfdbfe; /* blue-200 — decorative hairlines only (<4.5:1) */
  --blue-400: #60a5fa; /* blue-400 — visible ornamental rules */
  --line: #e2e8f0; /* slate-200 */
  --bg: #ffffff; /* white */
  --bg-soft: #fff; /* slate-50 */
  --text: #334155; /* slate-700 */
  --muted: #64748b; /* slate-500 */
  --paper-edge: #cbd5e1; /* slate-300 — print page-frame hairline */
  --paper: #ffffff; /* white — print paper */
  --shadow-plate:
    0 1px 2px rgba(29, 78, 216, 0.06), 0 8px 24px rgba(29, 78, 216, 0.07); /* screen-only plate lift */

  /* --- Print layout (tune these to resize the printed page) --------------- */
  --frame-inset: 13mm; /* paper edge → page-frame border */
  --content-pad-x: 17mm; /* paper edge → text, left/right */
  --content-pad-y: 24mm; /* paper edge → text, top/bottom (repeats per page) */

  /* --- Ornament kit (inline-SVG masks, recoloured via background-color) ---- */
  /* Fleuron: four-point star with corner dots — orientation-free. */
  --orn-fleuron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 C12 8 14 10 20 12 C14 14 12 16 12 22 C12 16 10 14 4 12 C10 10 12 8 12 2 Z'/%3E%3Ccircle cx='7' cy='7' r='1'/%3E%3Ccircle cx='17' cy='7' r='1'/%3E%3Ccircle cx='7' cy='17' r='1'/%3E%3Ccircle cx='17' cy='17' r='1'/%3E%3C/svg%3E");
  /* Rosette: the lesson-divider petal-4 flower, scaled to 24. */
  --orn-rosette: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 C14.4 5 14.4 8.6 12 11 C9.6 8.6 9.6 5 12 2 Z'/%3E%3Cpath d='M12 2 C14.4 5 14.4 8.6 12 11 C9.6 8.6 9.6 5 12 2 Z' transform='rotate(90 12 12)'/%3E%3Cpath d='M12 2 C14.4 5 14.4 8.6 12 11 C9.6 8.6 9.6 5 12 2 Z' transform='rotate(180 12 12)'/%3E%3Cpath d='M12 2 C14.4 5 14.4 8.6 12 11 C9.6 8.6 9.6 5 12 2 Z' transform='rotate(270 12 12)'/%3E%3Ccircle cx='7.2' cy='7.2' r='.9'/%3E%3Ccircle cx='16.8' cy='7.2' r='.9'/%3E%3Ccircle cx='7.2' cy='16.8' r='.9'/%3E%3Ccircle cx='16.8' cy='16.8' r='.9'/%3E%3Ccircle cx='12' cy='12' r='1.1'/%3E%3C/svg%3E");
  /* Notice marks — Apple emoji artwork (assets/emoji/, 160px PNG, source and
     licence in its README). One mark per variant, the same on screen and on
     paper: the emoji are the design, not a screen-only flourish. */
  --emoji-tip: url("emoji/apple-1f4a1.png");
  --emoji-key: url("emoji/apple-1f4cc.png");
  --emoji-exam: url("emoji/apple-1f3af.png");
  --emoji-warn: url("emoji/apple-26a0-fe0f.png");

  /* --- Quiz feedback (existing functional colours) ----------------------- */
  --correct: #1a7f5a;
  --incorrect: #b3402e;
  --correct-bg: #e4f5ee;
  --incorrect-bg: #fbe9e6;

  /* --- Type -------------------------------------------------------------- */
  /* Single family: IRAN (FontIRAN) for Persian and Latin alike, loaded by
     iran-font.css; system fonts only as a last-resort fallback. */
  --serif: "IRAN", Georgia, serif;
  --sans: "IRAN", system-ui, sans-serif;
  --mono: "IRAN", "SFMono-Regular", Menlo, Consolas, monospace;

  /* --- Layout ------------------------------------------------------------ */
  --measure: 68.75rem; /* 1100px */
  --radius: 8px;
  --radius-sm: 6px;
}

/* --- Subject accent: anatomy & histology (Tailwind taupe) -----------------
   The workspace accent above is blue-700; the anatomy and histology pages and
   the anatomy question bank wear Tailwind v4.3 taupe-500 instead (user,
   14 Nov 2026). Only the accent family is remapped — every rule in this sheet
   keeps reading the same token names, so those pages stay one theme with
   epidemiology (blue) and the hub. The opt-in is a class on <html>:
   `anatomy` (skeletal-anatomy, respiratory-anatomy, question-bank/anatomy.html)
   and `histology` (which already carried it for the print heading rule).

   Values are Tailwind taupe 100/200/400/500/600/700, converted oklch → sRGB.
   Contrast is unchanged or better: taupe-500 on paper is 4.95:1, taupe-600
   7.9:1, taupe-700 10.6:1 — AA holds for the rail, the labels and the links,
   and the two hairline steps stay decorative (<4.5:1) exactly as blue-200 and
   blue-400 were. */
html.anatomy,
html.histology {
  --accent: #7c6d67; /* taupe-500 — links, rails, active states */
  --accent-hover: #5b4f4b; /* taupe-600 */
  --accent-2: #473c39; /* taupe-700 — tree level 2, cartouche, tip */
  --blue-100: #f3f1f1; /* taupe-100 — tint fills */
  --blue-200: #e8e4e3; /* taupe-200 — decorative hairlines only (<4.5:1) */
  --blue-400: #aba09c; /* taupe-400 — visible ornamental rules */
  --shadow-plate:
    0 1px 2px rgba(124, 109, 103, 0.06), 0 8px 24px rgba(124, 109, 103, 0.07);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg);
  /* Faint slate-50 wash at the top of the page, fading to flat white; screen
     only — the print block resets `background` and drops the image. */
  background-image: linear-gradient(180deg, var(--bg-soft) 0, var(--bg) 420px);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* --- Header band ---------------------------------------------------------- */
/* Airy, centred title band: running head, display title, cartouche pill, and a
   thin blue double rule closing it off. Background is transparent so the body's
   slate-50 wash shows through. */

.band {
  background: transparent;
  color: var(--text);
  padding: 3rem 1.5rem 0;
  text-align: center;
}
.band__inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding-bottom: 2.25rem;
  border-bottom: 3px double var(--blue-400);
}
.band__kicker {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.band__title {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.25;
  margin: 0.6rem 0 0;
}
.band__part {
  display: inline-block;
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  background: var(--blue-100);
  border: 1px solid var(--blue-200);
  border-radius: 999px;
  padding: 0.25rem 0.95rem;
  color: var(--accent-hover);
}

/* Title-page corner fleurons, aligned to the edges of the centred band. */
@media screen {
  .band {
    position: relative;
  }
  .band::before,
  .band::after {
    content: "";
    position: absolute;
    top: 1.6rem;
    width: 16px;
    height: 16px;
    background-color: var(--blue-400);
    -webkit-mask: var(--orn-fleuron) no-repeat center / contain;
    mask: var(--orn-fleuron) no-repeat center / contain;
    pointer-events: none;
  }
  .band::before {
    inset-inline-start: max(1.5rem, calc(50% - var(--measure) / 2));
  }
  .band::after {
    inset-inline-end: max(1.5rem, calc(50% - var(--measure) / 2));
  }
}

/* --- Site navbar (subject + lecture switcher) ----------------------------- */
/* Modern pill row over the body wash; active/current = solid blue-700 plate
   with white text (6.7:1 on #1d4ed8). */

.sitenav {
  background: transparent;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1.5rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--text);
}
.sitenav__subjects,
.sitenav__lectures {
  max-width: var(--measure);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.sitenav__lectures {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--line);
}
.sitenav__subject {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.95rem;
  cursor: pointer;
  text-decoration: none;
}
.sitenav__subject:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.sitenav__subject:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sitenav__subject.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.sitenav__lecture {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.95rem;
  text-decoration: none;
}
.sitenav__lecture:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-soft);
  text-decoration: none;
}
.sitenav__lecture.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.sitenav__bank {
  border-style: dashed;
  font-weight: 600;
}
.sitenav__bank.is-current {
  border-style: solid;
}
.sitenav__empty {
  color: var(--muted);
  font-size: 0.875rem;
}
.sitenav__home {
  font-weight: 600;
  background: var(--bg-soft);
}

/* --- Layout --------------------------------------------------------------- */

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

section {
  margin: 0;
  padding: 3rem 0;
}
@media (min-width: 48rem) {
  section {
    padding: 4rem 0;
  }
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--text);
}
h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  margin: 0 0 0.5rem;
}
h2 {
  font-size: clamp(1.7rem, 3.5vw, 2.2rem);
  margin: 3rem 0 0.5rem;
}
h3 {
  font-size: 1.35rem;
  margin: 1.75rem 0 0.5rem;
}
h4 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.4rem;
  color: var(--accent);
}
section > h2:first-child {
  margin-top: 0;
  line-height: 200%;
}

/* Heading icons (.h-ico) — a small engraved plate set before a section title:
   <h2><img class="h-ico h-ico--2" src="../../assets/assets/h2.png"
   alt="" aria-hidden="true">عنوان</h2>. Decorative (empty alt, aria-hidden), so the
   heading text stays the accessible name. Shared here because skeletal-anatomy,
   respiratory-anatomy, the anatomy question bank and the histology lessons all
   wear the same plate; the mark sits on the reading edge, before the text in RTL.
   em units mean it scales with the heading on screen and in print alike. */
.h-ico {
  display: inline-block;
  width: 2em;
  height: 2em;
  margin-inline-end: .4em;
  vertical-align: -.65em;
  object-fit: contain;
}
.h-ico--3 { width: 2.05em; height: 2.05em; }

/* Section divider: ornament between two thin double rules.
   Markup (after a section <h2>, never inside .toc / cards / navigation):
   <div class="divider"><svg viewBox="0 0 40 40" width="22" height="22"
   aria-hidden="true"><path id="petal-4" d="…"/><use href="#petal-4" …/>
   …</svg></div>
   Every divider gets its own id: petal-4, petal-4b, petal-4c, … */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0.4rem 0;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 0;
  border-bottom: 3px double var(--blue-400);
}
.divider svg {
  flex: none;
  fill: var(--accent);
}

p {
  margin: 0.75rem 0;
}
ul,
ol {
  padding-inline-start: 1.5rem;
}
li {
  margin: 0.4rem 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

strong {
  font-weight: 700;
}
em {
  font-style: italic;
}
.mark {
  color: var(--incorrect);
  font-weight: 700;
}

code,
kbd,
.term-en {
  font-family: var(--mono);
  font-size: 0.92em;
  direction: ltr;
  unicode-bidi: embed;
}
:not(pre) > code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05em 0.4em;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

/* --- From-your-class card ------------------------------------------------- */

.from-class {
  position: relative;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-inline-start: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 1.25rem 0 2rem;
  box-shadow:
    var(--shadow-plate),
    inset 0 0 0 1px var(--blue-200);
}
.from-class dl {
  margin: 0.4rem 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
}
.from-class dt {
  color: var(--accent);
  font-weight: 600;
}
.from-class dd {
  margin: 0;
}
/* --- Notice plates: the tip and the callouts are one family ----------------
   A notice is the same object wherever it appears: a flat sheet, a hairline
   edge, one rail on the reading edge (inline-start — the right side in this RTL
   page), and a mark. The tip adds a fleuron; the callouts add the lecturer's
   small label, in front of which the mark sits.

   A variant is a **token swap and nothing else** — the pattern of the aside
   component on joshwcomeau.com (`.b1btlj5u`), where every variant only sets its
   own accent pair and the geometry lives in one shared rule. Here the pair is:

     --notice-accent  rail, label colour, and (through currentColor) the mark
     --notice-plate   the sheet

   so `--notice-accent` alone recolours a whole notice, and no variant can drift
   into declaring its own padding or radius. The one geometric difference is
   the rail's weight: 3px for every notice, 6px for «نکتهٔ امتحانی», because on
   paper — photopied — weight, not hue, is what separates the two flags.

   The corners are square on the rail side and rounded on the reading side, so
   the rail meets the page like a printed marginal rule instead of a floating
   card (the reference does the same: `border-radius: 0 4px 4px 0`).

   Screen and paper share this geometry; the @media print block only rescales
   the metrics, which is what keeps the family recognisable at 7.5pt. */
.tip,
.callout {
  --notice-accent: var(--accent);
  --notice-plate: var(--bg-soft);
  background: var(--notice-plate);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--notice-accent); /* the rail */
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-start-end-radius: var(--radius-sm);
  border-end-end-radius: var(--radius-sm);
  padding: 0.95rem 1.1rem;
  margin: 1.15rem 0;
}

/* Two notices in a row tuck into one stack instead of standing apart with a
   doubled gutter (the reference does it with `+ { margin-top: -16px }`). */
.tip + .tip,
.tip + .callout,
.callout + .tip,
.callout + .callout {
  margin-top: -0.5rem;
}

/* Tip: icon + running text, no label — it is a remark, not a finding. Its rail
   is the deep blue, the family's quietest voice. */
.tip {
  --notice-accent: var(--accent-2);
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  line-height: 1.8;
  color: var(--text);
  break-inside: avoid; /* don't split across printed pages */
}
.tip-icon {
  flex-shrink: 0;
  width: 1.3rem;
  height: 1.3rem;
  margin-top: 0.35rem; /* sits on the first text line */
  background: var(--emoji-tip) center / contain no-repeat;
}
.tip-body {
  flex: 1;
}

@media screen {
  .from-class::after {
    content: "";
    position: absolute;
    top: 0.55rem;
    inset-inline-end: 0.55rem;
    width: 13px;
    height: 13px;
    background-color: var(--accent);
    -webkit-mask: var(--orn-rosette) no-repeat center / contain;
    mask: var(--orn-rosette) no-repeat center / contain;
    pointer-events: none;
  }
}

/* --- Callouts ------------------------------------------------------------- */

/* Plate, rail and metrics come from "Notice plates" above; what is left here
   is the callout's own parts: the label row and the variant rails. */
.callout > .label {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--notice-accent);
  margin-bottom: 0.35rem;
}
.callout p:first-of-type {
  margin-top: 0;
}
.callout p:last-child {
  margin-bottom: 0;
}

/* The mark in front of a label: the variant's emoji (`--notice-emoji`, set
   below), screen and paper alike — the @media print block only rescales it.
   `.callout--addition` gets none. */
.callout--key > .label::before,
.callout--exam > .label::before,
.callout--warn > .label::before,
.callout--tip > .label::before {
  content: "";
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  margin-inline-end: 0.25em;
  vertical-align: -0.3em;
  background-image: var(--notice-emoji);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
/* Which glyph each flag wears.

   key  — 📌 pin: pin it, it comes back in the exam.
   exam — 🎯 target: the examiner aims here.
   warn — ⚠️ caution: this reading needs a second look.
   tip  — 💡 bulb: a clarification.
   callout--addition keeps the dashed plate and no mark: it is our addition,
   not the lecturer's. */
.callout--key > .label {
  --notice-emoji: var(--emoji-key);
}
.callout--exam > .label {
  --notice-emoji: var(--emoji-exam);
}
.callout--warn > .label {
  --notice-emoji: var(--emoji-warn);
}
.callout--tip > .label {
  --notice-emoji: var(--emoji-tip);
}

/* Variants: a token swap each, nothing else — geometry stays in the family
   rule above. `--notice-accent` recolours rail, label and mark together. */
.callout--warn {
  --notice-accent: var(--incorrect);
  --notice-plate: var(--incorrect-bg); /* the one alert keeps its tint */
}
.callout--tip {
  --notice-accent: var(--accent-2);
}
.callout--exam {
  border-inline-start-width: 6px; /* the loudest notice: a doubled rail */
}
.callout--addition {
  border-style: dashed;
}

/* --- Side / margin note --------------------------------------------------- */

.margin-note {
  display: block;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--text);
  border-inline-start: 1px solid var(--blue-200);
  padding-inline-start: 0.85rem;
  margin: 0.85rem 0 1.25rem;
}
.margin-note .src {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

/* --- Instructor's slide figures -------------------------------------------
   Markup:
   <figure class="slide">
   <img src="../slides/slide-NNN.jpg" alt="…" loading="lazy">
   <figcaption><span class="slide__no">اسلاید N</span> — توضیح.</figcaption>
   </figure>
   Number must match the slide number in epidemiology/slides/ (3 digits). */

figure.slide {
  position: relative;
  margin: 1.35rem 0;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  max-width: 46rem;
  box-shadow: var(--shadow-plate);
}
figure.slide img {
  display: block;
  width: 100%;
  height: auto;
  /* border: 1px solid var(--line); */
  border-radius: var(--radius-sm);
  background: var(--bg);
}
figure.slide figcaption {
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
  margin-top: 0.5rem;
}
figure.slide figcaption .slide__no {
  color: var(--accent);
  font-weight: 600;
}

/* Full-page plate: a slide that stands between sections instead of inside
   one, so it can span the whole printed sheet (see the print block at the
   end of this file). Centred on screen like its siblings. */
figure.slide--page {
  margin-inline: auto;
}

/* Mounted-plate treatment: thin blue inner border, small-caps slide number,
   corner fleuron in the caption row. */
@media screen {
  figure.slide img {
    border-color: var(--blue-200);
  }
  figure.slide figcaption .slide__no {
    font-variant: small-caps;
    letter-spacing: 0.06em;
  }
  figure.slide::after {
    content: "";
    position: absolute;
    bottom: 0.5rem;
    inset-inline-end: 0.5rem;
    width: 12px;
    height: 12px;
    background-color: var(--blue-400);
    -webkit-mask: var(--orn-fleuron) no-repeat center / contain;
    mask: var(--orn-fleuron) no-repeat center / contain;
    pointer-events: none;
  }
}

/* Side-by-side slides (collapses to one column on narrow screens) */
.slide-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 0.3rem;
  align-items: start;
  margin: 1.35rem 0;
}
.slide-row figure.slide {
  margin: 0;
  max-width: none;
}

/* Asymmetric pair: a tall narrow plate beside a wide one — first figure takes
   1/3 of the row, second 2/3. Collapses to one column on narrow screens. */
.slide-row--split-1-2 {
  grid-template-columns: 1fr 2fr;
}
@media screen and (max-width: 47.999rem) {
  .slide-row--split-1-2 {
    grid-template-columns: 1fr;
  }
}

/* --- Tables --------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
  margin: 1.25rem 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.9rem;
  border-top: 3px solid var(--accent);
}
caption {
  caption-side: top;
  text-align: start;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
  padding-bottom: 0.45rem;
}
th,
td {
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 0.8rem;
  text-align: start;
  vertical-align: top;
}
thead th {
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  border-top: 3px solid var(--accent);
  border-bottom: 3px double var(--blue-200);
}
tbody tr:nth-child(odd) {
  background: var(--bg-soft);
}
tbody tr:nth-child(even) {
  background: var(--bg);
}

/* --- Contents ------------------------------------------------------------- */

.toc {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow:
    var(--shadow-plate),
    inset 0 0 0 1px var(--blue-200);
}
.toc h2 {
  margin-top: 0;
  border: none;
  font-size: 1.1rem;
}
.toc ol {
  margin: 0;
  padding-inline-start: 1.3rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.toc a {
  color: var(--accent);
  text-decoration: none;
}
.toc a:hover {
  color: var(--accent-hover);
}

/* --- Part navigation ------------------------------------------------------ */

.partnav {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: stretch;
  margin: 1.5rem 0;
  font-family: var(--sans);
  font-size: 0.88rem;
}
.partnav a,
.partnav span {
  flex: 1 1 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  text-decoration: none;
}
.partnav a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.partnav .dir {
  display: block;
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.partnav .next {
  text-align: end;
}
.partnav .disabled {
  opacity: 0.45;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-plate);
}
.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
  text-decoration: none;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn--ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn--ghost:hover {
  background: var(--bg-soft);
  color: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* --- Quiz widget ---------------------------------------------------------- */

.quiz {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow:
    var(--shadow-plate),
    inset 0 0 0 1px var(--blue-200);
}
.quiz h3 {
  margin-top: 0;
}
.quiz__q {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--text);
  margin: 0.25rem 0 0.65rem;
}
.quiz__opts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.quiz__opts li {
  margin: 0;
}
.quiz__opt {
  width: 100%;
  text-align: start;
  font-family: var(--sans);
  font-size: 0.9rem;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  cursor: pointer;
}
.quiz__opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg);
}
.quiz__opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.quiz__opt[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--bg);
}
.quiz__opt.is-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  font-weight: 600;
}
.quiz__opt.is-incorrect {
  border-color: var(--incorrect);
  background: var(--incorrect-bg);
  color: var(--incorrect);
}
.quiz__opt:disabled {
  cursor: default;
}
.quiz__fb {
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.6;
  margin-top: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  display: none;
}
.quiz__fb.show {
  display: block;
}
.quiz__fb.ok {
  background: var(--correct-bg);
  color: var(--correct);
  border: 1px solid var(--correct);
}
.quiz__fb.no {
  background: var(--incorrect-bg);
  color: var(--incorrect);
  border: 1px solid var(--incorrect);
}
.quiz__fb .src {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  opacity: 0.85;
}
.quiz__fb .ans {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

/* Fill-in-the-blank */
.blank {
  font-family: var(--mono);
  font-size: 0.95rem;
  direction: ltr;
  border: none;
  border-bottom: 1px dashed var(--accent);
  background: transparent;
  color: var(--accent);
  text-align: center;
  min-width: 7rem;
  padding: 0.05rem 0.3rem;
}
.blank:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-bottom-style: solid;
}
.blank.is-correct {
  color: var(--correct);
  border-bottom-color: var(--correct);
}
.blank.is-incorrect {
  color: var(--incorrect);
  border-bottom-color: var(--incorrect);
}

/* Reveal-in-your-own-words */
.reveal {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1.05rem;
  background: var(--bg-soft);
  margin: 1rem 0;
  box-shadow:
    var(--shadow-plate),
    inset 0 0 0 1px var(--blue-200);
}
.reveal > summary {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.reveal[open] > summary {
  margin-bottom: 0.45rem;
}

/* --- Question bank -------------------------------------------------------- */

.qb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  padding: 0.85rem 1.05rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:
    var(--shadow-plate),
    inset 0 0 0 1px var(--blue-200);
}
.qb-toolbar__field {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.qb-toolbar select {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
}
.qb-toolbar select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.qb-toolbar__count {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}
.qb-toolbar__count.is-complete {
  color: var(--accent);
}
.qb-toolbar .btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}
.qb-toolbar .btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.qb-count {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0.5rem 0 1rem;
}
.qb-count.is-complete {
  color: var(--accent);
}
.qb-group {
  margin-bottom: 1.75rem;
}
.qb-hidden {
  display: none;
}
.qb-empty {
  display: none;
}
@media print {
  .qb-toolbar {
    display: none;
  }
}

/* --- Footer --------------------------------------------------------------- */

.footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--muted);
  background: var(--bg);
  border-top: 1px solid var(--line);
  text-align: center;
}
.footer p {
  margin-inline: auto;
}

/* Closing colophon: ornamental double rule above, rosette mark below. */
@media screen {
  .footer {
    border-top: none;
  }
  .footer::before {
    content: "";
    display: block;
    width: min(22rem, 72%);
    height: 0;
    margin: 0 auto 1.35rem;
    border-bottom: 3px double var(--blue-400);
  }
  .footer::after {
    content: "";
    display: block;
    width: 13px;
    height: 13px;
    margin: 1.25rem auto 0;
    background-color: var(--accent);
    -webkit-mask: var(--orn-rosette) no-repeat center / contain;
    mask: var(--orn-rosette) no-repeat center / contain;
    pointer-events: none;
  }
}

/* Ornaments hide on narrow screens (except the centred footer marks). */
@media screen and (max-width: 39.999rem) {
  .band::before,
  .band::after,
  .card::after,
  .from-class::after,
  figure.slide::after {
    display: none;
  }
}

/* --- Reference page helpers ---------------------------------------------- */

.ref-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 40rem) {
  .ref-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow:
    var(--shadow-plate),
    inset 0 0 0 1px var(--blue-200);
}
.card h3 {
  margin-top: 0;
}
@media screen {
  .card::after {
    content: "";
    position: absolute;
    top: 0.6rem;
    inset-inline-end: 0.6rem;
    width: 13px;
    height: 13px;
    background-color: var(--blue-400);
    -webkit-mask: var(--orn-fleuron) no-repeat center / contain;
    mask: var(--orn-fleuron) no-repeat center / contain;
    pointer-events: none;
  }
}
dl.terms {
  margin: 0;
}
dl.terms dt {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.85rem;
}
dl.terms dd {
  margin: 0.15rem 0 0;
}
.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg-soft);
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.5rem;
  margin-inline-start: 0.35rem;
  vertical-align: middle;
}

/* --- Slide-exposure pages (reference) ------------------------------------- */

.slide-block {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  margin-top: 1.6rem;
  break-inside: avoid;
  page-break-inside: avoid;
}
.slide-block:first-child {
  border-top: none;
  margin-top: 0.5rem;
}
.slide-block h4 {
  font-family: var(--sans);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.3rem;
}
.slide-block h4 .num {
  color: var(--muted);
  font-weight: 600;
}
.slide-line {
  margin: 0.2rem 0;
  font-size: 0.93rem;
  line-height: 1.75;
}
.slide-line .slide-img {
  font-size: 0.8rem;
}
.layer-note {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
}

/* --- Index page (lecture list) -------------------------------------------- */

.index-intro {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--text);
}

.index-subject > h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.index-subject > h2 .count {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.65rem;
}

.lecture-card {
  display: flex;
  flex-direction: column;
  box-shadow:
    var(--shadow-plate),
    inset 0 0 0 1px var(--blue-200);
}
.lecture-card__head {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}
.lecture-card__num {
  flex: none;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--bg);
  background: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
}
.lecture-card.is-soon .lecture-card__num {
  background: var(--line);
  color: var(--accent);
}
.lecture-card h3 {
  margin: 0;
  font-size: 1.1rem;
}
.lecture-card__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}
.lecture-card__links a,
.lecture-card__links span {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.75rem;
  text-decoration: none;
}
.lecture-card__links a:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: var(--bg);
  text-decoration: none;
}
.lecture-card__links a.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.lecture-card__links a.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
}
.lecture-card__links span {
  opacity: 0.7;
}

.index-empty {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

/* --- Long-page contents sidebar ------------------------------------------ */

@media (min-width: 68rem) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, var(--measure)) 15rem;
    gap: 2.5rem;
    max-width: 62rem;
    margin: 0 auto;
    align-items: start;
  }
  .layout .wrap {
    margin: 0;
  }
  .layout .toc {
    position: sticky;
    top: 1.25rem;
    grid-column: 2;
    grid-row: 1;
  }
}

/* --- Two flowing text columns (.cols-2, opt-in) ----------------------------
   Print-style body columns for a lesson section: text fills the right column
   first and continues in the left one (the page is RTL, so no direction
   override is needed). On screen, wide blocks — slide figures, rows of
   slides, tables, the lesson tree — span both columns instead of sitting in
   one narrow one; on paper only tables and the tree span, while a slide
   fills the column it lands in (see the print rules at the end of the
   @media print block below).
   Usage (only on sections that should read as columns; leaves headings,
   practice and full-width blocks single-column):
      <section id="…" class="cols-2">
   Below 64rem everything falls back to a single column; print keeps the two
   columns. */

@media screen and (min-width: 64rem), print {
  .cols-2 {
    column-count: 2;
    column-gap: 2.75rem;
    /* column-rule: 1px solid var(--line); */
  }

  .cols-2 h2,
  .cols-2 h3,
  .cols-2 h4 {
    break-after: avoid;
    break-inside: avoid;
  }

  .cols-2 p,
  .cols-2 li {
    orphans: 2;
    widows: 2;
  }

  .cols-2 figure.slide,
  .cols-2 .slide-row,
  .cols-2 .table-scroll,
  .cols-2 .lesson-tree {
    column-span: all;
    margin-inline: auto;
  }
}

/* --- Lesson tree (نمودار درختی درس) --------------------------------------- */

.lesson-tree {
  margin-block: 1.75rem;
}

.lesson-tree .tree,
.lesson-tree .tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lesson-tree .tree li {
  position: relative;
  padding-block: 0.35rem;
}

/* Indent each level; hosts the stub that links parent node to first child. */
.lesson-tree .tree li ul {
  position: relative;
  padding-inline-start: 1.5rem;
  margin-block-start: 0.15rem;
}

.lesson-tree .tree li ul::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: -1.2rem;
  height: 1.3rem;
  width: 1px;
  background: var(--line);
}

/* Tick from this level's spine into this node. */
.lesson-tree .tree li::before {
  content: "";
  position: absolute;
  inset-inline-start: -1.5rem;
  top: 1.2rem;
  width: 1.5rem;
  height: 1px;
  background: var(--line);
}

/* Vertical spine segment: this node down to the next sibling. */
.lesson-tree .tree li::after {
  content: "";
  position: absolute;
  inset-inline-start: -1.5rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

/* Last child: stop the spine at its own tick. */
.lesson-tree .tree li:last-child::after {
  bottom: auto;
  height: 1.2rem;
}

/* The root has no incoming line. */
.lesson-tree .tree > li::before,
.lesson-tree .tree > li::after {
  display: none;
}

.lesson-tree .tree li > span {
  display: inline-block;
  max-width: 100%;
  padding: 0.15rem 0.6rem;
  overflow-wrap: break-word;
}

/* Level 1 — root: filled marker. */
.lesson-tree .tree > li > span {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.05rem;
}

/* Level 2 — main topics: solid outline in blue-900, bold, soft background. */
.lesson-tree .tree li li > span {
  background: var(--bg-soft);
  border: 1px solid var(--accent-2);
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--text);
  font-size: 9.5pt;
  padding: 1pt 4pt;
}

/* Level 3 — subtopics: dashed outline, regular weight. */
.lesson-tree .tree li li li > span {
  background: var(--bg);
  border: 1px dashed var(--muted);
  border-radius: var(--radius-sm);
  font-weight: 400;
  color: var(--text);
  font-size: 9.5pt;
  padding: 1pt 4pt;
}

/* Level 4 — leaves: no box, a leading bar instead of colour alone. */
.lesson-tree .tree li li li li > span {
  border: 0;
  border-inline-start: 3px solid var(--accent);
  border-radius: 0;
  padding-inline: 0.4rem;
  font-size: 9.5pt;
}

/* --- Motion (colour, background, border-color, opacity only) --------------- */

a,
button,
.btn,
input,
summary {
  transition:
    color 0.2s ease-in-out,
    background-color 0.2s ease-in-out,
    border-color 0.2s ease-in-out;
}

/* --- Print: A4 academic booklet -------------------------------------------- */

/* The page frame is a `position: fixed` element that Chrome repeats on every
   printed page. Fixed elements are positioned against the *page area*, so
   `@page` margin must be 0 for the frame to hug the paper edge; content
   margins are re-created by the .print-wrap spacer table in the lesson HTML
   (thead/tfoot groups repeat on every page). */
@page {
  size: A4 portrait;
  margin: 0;
}

/* Print-only page frame: hidden on screen, drawn on every printed page.
   Markup at the top of <body>:
   <div class="page-frame" aria-hidden="true"> corners + ornament SVGs </div> */
.page-frame {
  display: none;
}

/* The print-wrap table is transparent on screen: flattened to plain blocks so
   the layout is byte-for-byte what it was before the wrapper existed. Only
   @media print turns it into a real table whose spacer rows repeat.
   Every selector below is child-scoped (`>`) — a descendant selector here
   would also flatten the ledger tables nested inside the wrapper's cell,
   hiding their thead and turning each row into stacked blocks. */
.print-wrap {
  display: block;
}
.print-wrap > thead,
.print-wrap > tfoot {
  display: none;
}
.print-wrap > tbody,
.print-wrap > tbody > tr,
.print-wrap > tbody > tr > td {
  display: block;
}

/* The wrapper is still a <table> *element*, so the ledger's `table` rule
   paints a 3px accent rule above the header band and drops all prose to
   0.9rem. Both are wrapper leaks, not layout: screen only — in print the
   wrapper is a real table and clears its own border-top there. */
@media screen {
  .print-wrap {
    border-top: 0;
    font-size: inherit;
  }
}

/* --- Print-highlight switch (anatomy & histology lessons) ------------------
   A floating pill, screen only, mounted by assets/highlight-toggle.js. Its
   checkbox adds/removes `hl-print-off` on <html>, and anatomy-print.css uses
   that class to strip the inline highlight styling on paper. With JavaScript
   off no pill appears and the class is never set, so printing stays at the
   default (highlights shown). */
.hl-toggle {
  position: fixed;
  inset-inline-start: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.7rem;
  background: var(--paper, #fff);
  border: 1px solid var(--paper-edge, #cbd5e1);
  border-radius: 999px;
  font-size: 0.85rem;
  line-height: 1.4;
}
.hl-toggle__row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}
.hl-toggle__input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent, #1d4ed8);
}
.hl-toggle__text {
  color: var(--text, #334155);
}
.hl-toggle__input:focus-visible + .hl-toggle__text {
  outline: 2px solid var(--accent, #1d4ed8);
  outline-offset: 2px;
  border-radius: 2px;
}

@media print {
  .hl-toggle {
    display: none;
  }
}

@media print {
  :root {
    --page-mt: 1mm;
    --page-mr: 5mm;
    --page-mb: 8mm;
    --page-ml: 5mm;
    --frame-inset: 18mm; /* distance from the paper edge */
  }
  /* --- Base ---------------------------------------------------------------- */
  .print-wrap thead .spacer,
  .print-wrap tfoot .spacer {
    height: var(--content-pad-y);
    padding: 0;
    border: 0;
    line-height: 0;
  }
  .print-wrap tfoot .spacer {
    height: calc(
      var(--content-pad-y) + 2mm
    ); /* extra safety margin at the bottom */
  }

  html,
  body {
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0;
    background: var(--bg);
  }

  body {
    font-family: var(--sans);
    font-size: 7.5pt;
    line-height: 1.8;
    color: var(--text);
  }
  @page {
    margin: var(--page-mt) var(--page-mr) var(--page-mb) var(--page-ml);
  }
  *,
  *::before,
  *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    animation: none !important;
    transition: none !important;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* --- Page frame (fixed element, repeats on every printed page) ----------- */

  .page-frame {
    display: block;
    position: fixed;
    /* top right bottom left, each pulled back out to the paper edge */
    top: calc(var(--page-mt) + 3mm);
    right: calc(var(--page-mr) - 2mm);
    bottom: calc(var(--page-mb) - 5mm);
    left: calc(var(--page-ml) - 2mm);
    border: 0.3mm solid var(--paper-edge);
    pointer-events: none;
  }

  /* Inner hairline for the double-frame effect. */
  .page-frame::before {
    content: "";
    position: absolute;
    inset: 1mm;
    border: 0.15mm solid var(--paper-edge);
  }

  .page-frame .corner {
    position: absolute;
    width: 2.4mm;
    height: 2.4mm;
    background: var(--accent);
    transform: translate(-50%, -50%) rotate(45deg);
  }
  .page-frame .corner.tl {
    top: 0;
    left: 0;
  }
  .page-frame .corner.tr {
    top: 0;
    left: 100%;
  }
  .page-frame .corner.bl {
    top: 100%;
    left: 0;
  }
  .page-frame .corner.br {
    top: 100%;
    left: 100%;
  }

  /* Rosette centred on the top and bottom edges; white padding cuts the line. */
  .page-frame .ornament {
    position: absolute;
    left: 50%;
    width: 7mm;
    height: 7mm;
    padding: 0 3mm;
    box-sizing: content-box;
    background: var(--bg);
    fill: var(--accent);
    transform: translate(-50%, -50%);
  }
  .page-frame .ornament.top {
    top: 0;
  }
  .page-frame .ornament.bottom {
    top: 100%;
  }

  /* --- Content margins: the .print-wrap spacer table ----------------------- */

  /* The wrapper is a layout table, not a ledger table: it must be excluded
     from the ledger rules below (`table` border-top, `th,td` hairlines, zebra
     rows), or every sheet printed on slate-50 with a blue bar on the paper
     edge. `table-layout: fixed` plus `overflow-wrap: anywhere` keep it exactly
     page-wide — in auto layout the min-content of a long Latin token pushed the
     table past the page edge, so the text ran over the page frame. */
  .print-wrap {
    display: table;
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border-top: 0;
    overflow-wrap: anywhere;
  }
  /* All wrapper-only selectors are child-scoped: the ledger tables nested in
     the wrapper's cell must keep the ledger rules below — their own thead,
     4pt/5pt cell padding, hairline borders and zebra rows. Without `>`, this
     block stripped their borders, gave every cell `padding: 0 20mm` (so the
     printed table shrank to a narrow strip) and killed their row tints. */
  .print-wrap > thead > tr > td,
  .print-wrap > tbody > tr > td,
  .print-wrap > tfoot > tr > td {
    padding: 0;
    border: 0;
  }
  /* Inherited `anywhere` loses to the ledger's `break-word`, declared
     directly, which would reintroduce the page-width blow-up. */
  .print-wrap > thead > tr > td,
  .print-wrap > tbody > tr > td,
  .print-wrap > tfoot > tr > td,
  .print-wrap .lesson-tree .tree li > span {
    overflow-wrap: anywhere;
  }
  .print-wrap > tbody > tr {
    background: transparent;
  }
  .print-wrap .spacer {
    height: 30mm;
  }
  .print-wrap > thead {
    display: table-header-group;
  }
  .print-wrap > tfoot {
    display: table-footer-group;
  }
  .print-wrap > tbody {
    display: table-row-group;
  }
  .print-wrap > tbody > tr {
    display: table-row;
    /* The wrapper row spans the whole document: the ledger's
       `tbody tr { break-inside: avoid }` must not apply to it. */
    break-inside: auto;
    page-break-inside: auto;
  }
  .print-wrap > tbody > tr > td {
    display: table-cell;
    padding: 0 var(--content-pad-x);
  }

  /* --- Page rhythm --------------------------------------------------------- */

  .wrap {
    max-width: none;
    padding: 0;
  }

  section {
    padding: 14pt 0 0;
  }

  /* --- Typography ---------------------------------------------------------- */

  /* No keep-with-next on headings in print: a heading that drags its first
     block down the page is what used to leave quarter-page holes. */
  h1,
  h2,
  h3,
  h4 {
    font-family: var(--serif);
    font-weight: 900;
    line-height: 1.2;
    color: var(--text);
    break-after: auto;
    page-break-after: auto;
  }

  .band__title {
    font-weight: 900;
  }

  /* Paper is a denser medium than the screen: the whole heading ladder prints
     one step smaller (h1 22→17, h2 16→12, h3 12→9.5, h4 11→9) so a section
     title stops competing with the body it introduces, then another 15% on top
     (h1 17→14.5, h2 12→10, h3 9.5→8, h4 9→7.5) at the user's request of
     13 Nov 2026 — with the margins scaled by the same step so a smaller title
     does not keep a large title's gaps. Screen sizes are untouched. Measured on
     «بافتشناسی تنفس ۱»: printed h1 29.3→22.7→19.3px, h2 21.3→16→13.3px,
     h3 16→12.7→10.7px. h4 lands at the 7.5pt body size and is told apart by
     weight (900), not size. */
  h1 {
    font-size: 14.5pt;
    margin-top: 0;
    margin-bottom: 6pt;
  }

  h2 {
    font-size: 10pt;
    margin-top: 9.5pt;
    margin-bottom: 4pt;
    border-inline-start: 2px solid var(--accent);
    padding-inline-start: 0.6rem;
  }

  /* Histology lessons print their section titles without the accent rule
     (user, 13 Nov 2026): every one of those headings already opens with its
     engraved .h-ico plate, and the blue bar crowded it on the reading edge.
     Scoped with `html.histology`; anatomy and epidemiology keep the bar, and
     the screen never had one to remove. */
  html.histology h2 {
    border-inline-start: 0;
    padding-inline-start: 0;
  }

  h3 {
    font-size: 8pt;
    margin-top: 7.5pt;
    margin-bottom: 2.5pt;
  }

  h4 {
    font-size: 7.5pt;
    margin-top: 6.5pt;
    margin-bottom: 1.5pt;
  }

  /* Headings must not land in the leftover strip beside a float: a pair of
     46% slides leaves ~8% and the heading wraps one word per line. */
  h1,
  h2,
  h3,
  h4 {
    clear: inline-start;
  }

  section > h2:first-child {
    margin-top: 0;
    line-height: 1.2;
  }

  p {
    margin-top: 0;
    margin-bottom: 5pt;
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }

  /* --- Header band --------------------------------------------------------- */

  .band {
    position: relative;
    background: var(--bg);
    padding: 0 1.5rem 9pt;
    text-align: start;
  }

  /* Screen-only chrome: the double rule and the cartouche pill tint. */
  .band__inner {
    padding-bottom: 0;
    border-bottom: none;
  }

  .band::after {
    content: "";
    position: absolute;
    bottom: -1px;
    inset-inline-start: 1.5rem;
    width: 54pt;
    height: 2px;
    background: var(--accent);
  }

  .band__kicker {
    color: var(--accent);
  }

  .band__part {
    background: none;
    border: none;
    border-radius: 0;
    color: var(--muted);
  }

  /* --- Links --------------------------------------------------------------- */

  a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 0.5pt;
    text-underline-offset: 2pt;
  }

  /* --- Ornamental divider: slate hairline — blue ornament — slate hairline -- */

  /* Decorative: it must never hold the next heading back to this page. */
  .divider {
    margin: 10pt 0;
    gap: 10px;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: auto;
    page-break-after: auto;
  }

  .divider::before,
  .divider::after {
    height: 1px;
    background: var(--line);
    border: none;
  }

  .divider svg {
    width: 18px;
    height: 18px;
    fill: var(--accent);
  }

  /* --- Cards, callouts, quotes --------------------------------------------- */

  .from-class {
    margin: 4pt 0 10pt;
  }

  .from-class,
  .index-empty,
  .margin-note,
  blockquote {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Long teaching blocks are allowed to flow across pages — keeping them
     whole is what punched the half-page holes in the PDF. */
  .callout,
  .card,
  .reveal {
    break-inside: auto;
    page-break-inside: auto;
  }

  .callout > .label,
  .card > .label {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Notice plates on paper. The plate is already flat and white on screen, so
     nothing has to be stripped here; what paper needs is the screen box's
     screen-sized metrics undone. 1.15rem/1.3rem padding and 1.35rem margins are
     measured for 16px prose: at 7.5pt they spend ~28pt of height on padding and
     ~32pt on margins to hold two or three lines, and this workspace has 177
     notices across its lessons. At 5pt/7pt and 5pt margins a lesson with ten
     notices wins about half a page back, and a plate still separates. */
  .tip,
  .callout {
    padding: 5pt 7pt;
    margin: 5pt 0;
  }

  .tip {
    gap: 4pt;
  }

  /* Two notices in a row keep the same stack on paper as on screen. */
  .tip + .tip,
  .tip + .callout,
  .callout + .tip,
  .callout + .callout {
    margin-top: -2pt;
  }

  .tip-icon {
    width: 11pt;
    height: 11pt;
    margin-top: 3pt;
  }

  /* The mark and the rail ladder on paper. The emoji print as they are — the
     mark is the same artwork in both media — only their size changes: 9pt for
     a label mark and 11pt for the tip's stand-alone icon, big enough for Apple's
     artwork to stay legible at 300dpi, small enough not to shout. `print-color-
     adjust: exact` (set for the whole sheet above) keeps their colour. */
  .callout--exam {
    border-inline-start-width: 4pt;
  }

  .callout > .label::before {
    width: 9pt;
    height: 9pt;
    margin-inline-end: 2.5pt;
    vertical-align: -0.25em;
  }

  .quiz {
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0 0 10pt;
  }

  .quiz h3 {
    font-size: 8pt;
    margin: 0 0 3pt;
  }

  .quiz__q {
    margin-top: 0;
    margin-bottom: 3pt;
    break-after: avoid;
    page-break-after: avoid;
  }

  .quiz__opts {
    gap: 0.15rem;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .from-class,
  .tip,
  .callout,
  .quiz,
  .card,
  .reveal,
  .index-empty {
    background: var(--bg);
  }

  blockquote {
    margin: 6pt 0;
    padding-inline-start: 10pt;
    border-inline-start: 2px solid var(--accent);
  }

  /* --- Tables: the ledger look, formalised for paper ------------------------ */

  /* A ledger stays on one sheet/column: a caption, its header row and a single
     stranded body row at the foot of the page read as a broken table, and the
     repeated header then looks like a second table. The wrapper carries the
     rule because Chromium honours break-inside on the block, not on <table>;
     a ledger taller than the available space still breaks (the browser cannot
     avoid it) and falls back to the repeated header + per-row rules below. */
  .table-scroll {
    overflow: visible;
    max-width: 100%;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    border-top: 3px solid var(--accent);
    break-inside: auto;
    page-break-inside: auto;
    font-size: 7pt;
  }

  thead {
    display: table-header-group;
  }

  /* No full cell grid on paper — rows separated by hairlines, exactly like the
     screen ledger; padding and leading are tighter than screen so a ledger
     stays dense and usually fits on one page. */
  th,
  td {
    border: none;
    border-bottom: 1px solid var(--line);
    padding: 2pt 4pt;
    line-height: 1.35;
    overflow-wrap: break-word;
  }

  thead th {
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-variant: small-caps;
    letter-spacing: 0.05em;
    border-top: 3px solid var(--accent);
    border-bottom: 3px double var(--blue-200);
  }

  /* Row tints keep their colour in print (print-color-adjust: exact is global
     above) — the faint zebra is what keeps a table scannable across a break. */
  tbody tr:nth-child(odd) {
    background: var(--bg-soft);
  }

  tbody tr:nth-child(even) {
    background: var(--bg);
  }

  tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  tbody,
  tfoot {
    break-inside: auto;
  }

  /* --- Forms and practice widgets ------------------------------------------ */

  input,
  button {
    background: var(--bg);
    color: var(--text);
  }

  /* Practice reads at body size on paper (user, 14 Nov 2026): the options used
     to print at 9.5pt and the key at 9pt — larger than the 7.5pt prose that
     explains them, so the answer choices shouted and the practice ran long.
     Option, blank and key now match the body; the option's padding is trimmed
     in the same step so the button does not stay a 9.5pt-sized box around
     7.5pt text. Screen sizes are untouched (the screen button is `1em`). */
  .quiz__opt {
    background: var(--bg);
    border-color: var(--line);
    font-size: 7.5pt;
    padding: 2pt 7pt;
  }

  .blank {
    min-width: 4.5rem;
    font-size: 7.5pt;
  }

  .quiz__fb {
    display: block !important;
    font-size: 7.5pt;
    line-height: 1.5;
    margin-top: 4pt;
    padding: 4pt 8pt;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .quiz__fb .src {
    margin-top: 1pt;
    font-size: 8pt;
  }

  /* --- Practice on paper: two columns, optionally upside-down keys ---------
     Opt-in on a practice section (.practice-print): questions run in two
     columns on paper only. Add (.practice-print--rotated) on top for a key
     rotated 180°, so the page has to be turned to read it — the key then
     never sits next to its question while the sheet is upright. Rotation is
     per-section: only the pages that opt in get the upside-down key. */

  .practice-print {
    column-count: 2;
    column-gap: 2.75rem;
  }

  .practice-print .quiz,
  .practice-print .reveal,
  .practice-print .callout {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* A quiz taller than the space left in a column would drag a hole behind it,
     so a quiz may split between its question and its options; the option list
     itself stays whole. */
  .practice-print .quiz {
    break-inside: auto;
    page-break-inside: auto;
  }

  .practice-print .quiz__opts {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .practice-print--rotated .quiz__fb {
    transform: rotate(180deg);
  }

  /* --- One column flow for the whole lesson: main.print-cols ----------------
     Each .cols-2 section is its own multi-column box, and a box cannot fill a
     hole left by the one before it — a figure deferred at the end of a section
     stranded the foot of the column, page after page. Opting the whole main in
     puts every .cols-2 section in one flow, so text always runs on into the
     space a deferred figure left behind; sections that are not .cols-2
     (practice, the lesson tree) span both columns as before. */

  .print-cols {
    column-count: 2;
    column-gap: 2.75rem;
  }

  .print-cols > section.cols-2 {
    column-count: auto;
  }

  .print-cols > section:not(.cols-2) {
    column-span: all;
  }

  /* --- Images and figures -------------------------------------------------- */

  img,
  figure {
    max-width: 100%;
  }

  figure {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Slides float beside the running text instead of standing full-width: a
     slide that cannot fit is pushed down and the text simply fills the page,
     where a full-width figure would have taken half the sheet with it.
     flow-root keeps those floats inside their own section. */
  section {
    display: flow-root;
  }

  figure.slide {
    float: inline-start;
    width: 46%;
    margin: 4pt 0 6pt;
    padding: 3pt;
  }

  figure.slide img {
    width: 100%;
    border-radius: 0;
  }

  figure.slide figcaption {
    font-size: 8pt;
    line-height: 1.4;
    margin-top: 3pt;
  }

  /* Side-by-side slides become ordinary floats in print, so a pair that does
     not fit no longer drags a full-width hole behind it. */
  .slide-row {
    display: block;
    margin: 6pt 0;
  }

  /* The 1/3 + 2/3 pair keeps its proportions as adjacent floats. */
  .slide-row--split-1-2 figure.slide:first-of-type {
    width: 30%;
  }
  .slide-row--split-1-2 figure.slide:last-of-type {
    width: 64%;
  }

  /* --- Two-column sections (.cols-2) on paper --------------------------------
     `.cols-2` keeps its two RTL columns in print (the rule above now also
     matches print), so everything a figure floats in is a column, not the
     page: the usual 46% would shrink a slide to ~35mm. Inside .cols-2 a
     figure therefore fills its column instead of keeping the page float, and
     it DOES float: a column-width float that does not fit in the space left
     in the current column is deferred to the top of the next one, and the
     text that follows flows on to fill the gap the deferred figure left
     behind. Without the float the figure breaks the column as an unbreakable
     block (`figure { break-inside: avoid }`), and CSS multi-column layout has
     no way to pull later text up into the hole — every slide that did not fit
     left a blank strip at the foot of a column.
     Trade-off (deliberate): the figure now lands where it fits, so it can
     sit a paragraph or a column later than its place in the source. Slide
     rows stay in the column too, so their figures stack at full column
     width. */
  .cols-2 .slide-row,
  .cols-2 figure.slide {
    column-span: none;
  }

  .cols-2 figure.slide {
    float: inline-start;
    width: 100%;
  }

  /* …including the figures inside a .slide-row: at column width the 30/64
     pair would shrink to ~21/49mm, so the pair stacks instead. It outranks
     the split rule above, so it wins. */
  .cols-2 .slide-row figure.slide {
    width: 100%;
  }

  /* Portrait screenshots are taller than a whole page at column width
     (the tallest, 376×1398, would need ~300mm); cap the height so the figure
     always fits on one page — width follows the aspect ratio. */
  .cols-2 figure.slide img {
    width: auto;
    max-width: 100%;
    max-height: 200mm;
  }

  /* A slide that is immediately followed by a table prints as an ordinary
     block instead of a column-wide float. A 100%-wide float sitting just
     before a table makes Chrome place the table on top of what follows it:
     in the pharyngeal-arch lesson the arch table and the next section's
     heading were printed over each other (dots and table cells on the same
     baseline, page 2). Not floating that one slide keeps the table inside
     its column with the following text below it. Every other slide keeps
     its float. */
  .cols-2 figure.slide:has(+ .table-scroll),
  .cols-2 .slide-row:has(+ .table-scroll) {
    float: none;
  }

  /* --- Full-page plate (figure.slide--page) --------------------------------
     One figure printed across the whole sheet instead of at column width:
     it spans both columns and, being ~250mm tall, needs a page of its own.
     column-span only reaches children of the multicol container, so such a
     figure has to be a direct child of main.print-cols — a plate nested in a
     .cols-2 section can never span (see the .cols-2 rule above). The image is
     kept inside the printable height (297 − 20 top − 22 bottom = 255mm) so
     the plate and its table border never spill onto a second page. */
  .print-cols > figure.slide {
    column-span: all;
    float: none;
    width: auto;
    max-width: none;
    margin: 0 auto;
    padding: 3pt;
  }

  .print-cols > figure.slide img {
    width: auto;
    max-width: 100%;
    max-height: 246mm;
    margin-inline: auto;
  }

  /* --- Lesson tree: keep leaves whole, let branches split ----------------- */

  .lesson-tree .tree li {
    break-inside: auto;
    page-break-inside: auto;
  }

  /* Only leaf nodes are kept whole; a branch that holds a whole subtree must
     be splittable, or it drags a blank half-page behind it. */
  .lesson-tree .tree li:not(:has(ul)) {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .lesson-tree .tree li:has(ul) > span {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Tighter tree on paper, so the last page is not left holding a couple of
     leaves and the footer. */
  .lesson-tree {
    font-size: 9pt;
  }

  .lesson-tree .tree li {
    padding-block: 1pt;
  }

  .lesson-tree .tree li ul {
    padding-inline-start: 1rem;
  }

  /* --- Footer -------------------------------------------------------------- */

  .footer {
    position: relative;
    margin-top: 14pt;
    padding: 8pt 1.5rem 0;
    font-size: 9pt;
  }

  .footer::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 50%;
    margin-left: -27pt;
    width: 54pt;
    height: 2px;
    background: var(--accent);
  }

  /* --- Screen-only interface ----------------------------------------------- */

  .sitenav,
  .toc,
  .partnav,
  .btn {
    display: none !important;
  }
}

/* --- Reduced motion ------------------------------------------------------- */

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