/* ============================================================
   Vascular Surgery Field Guide — shared styles
   Light-box clinical system: film grey, slate ink,
   arterial red and venous blue used as a real colour code.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --film: #F2F4F6;
  --sheet: #FFFFFF;
  --sunk: #E7EBEF;
  --ink: #17222D;
  --ink-2: #4E5B67;
  --ink-3: #75818C;
  --rule: #DDE2E7;
  --rule-2: #C4CCD4;

  --artery: #B01E2E;
  --artery-tint: #FBEEEF;
  --vein: #23539E;
  --vein-tint: #EDF2FA;
  --pearl: #0B7559;
  --pearl-tint: #E7F4EE;
  --mnem: #8A5A00;
  --mnem-tint: #FAF2E0;
  --tip: #583D96;
  --tip-tint: #F2EEF9;

  --vessel: #1B2631;
  --vessel-ghost: #C9D0D7;
  --angio-bg: #E4E8EC;

  --shadow: 0 1px 2px rgba(23, 34, 45, .06), 0 10px 30px -14px rgba(23, 34, 45, .22);
  --focus: #23539E;

  --f-body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-head: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --topbar-h: 3.75rem;
  --measure: 44rem;
  --gutter: 1rem;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --film: #0C1319;
    --sheet: #111A22;
    --sunk: #19242F;
    --ink: #E3E8ED;
    --ink-2: #A9B4BE;
    --ink-3: #7F8B96;
    --rule: #23303C;
    --rule-2: #34424F;
    --artery: #FF7C84;
    --artery-tint: #2A161A;
    --vein: #8DB3F3;
    --vein-tint: #142337;
    --pearl: #5FCDA9;
    --pearl-tint: #0F2820;
    --mnem: #E8B65C;
    --mnem-tint: #2B2212;
    --tip: #BCA7F2;
    --tip-tint: #1E1A2F;
    --vessel: #E9EEF2;
    --vessel-ghost: #2B3845;
    --angio-bg: #0A1015;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 30px -14px rgba(0, 0, 0, .7);
    --focus: #8DB3F3;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --film: #0C1319;
  --sheet: #111A22;
  --sunk: #19242F;
  --ink: #E3E8ED;
  --ink-2: #A9B4BE;
  --ink-3: #7F8B96;
  --rule: #23303C;
  --rule-2: #34424F;
  --artery: #FF7C84;
  --artery-tint: #2A161A;
  --vein: #8DB3F3;
  --vein-tint: #142337;
  --pearl: #5FCDA9;
  --pearl-tint: #0F2820;
  --mnem: #E8B65C;
  --mnem-tint: #2B2212;
  --tip: #BCA7F2;
  --tip-tint: #1E1A2F;
  --vessel: #E9EEF2;
  --vessel-ghost: #2B3845;
  --angio-bg: #0A1015;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 30px -14px rgba(0, 0, 0, .7);
  --focus: #8DB3F3;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 1rem);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0;
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
@media (min-width: 48em) {
  body { font-size: 1.125rem; }
}
img, svg { max-width: 100%; }
a { color: var(--vein); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--vein-tint); color: var(--ink); }
b, strong { font-weight: 700; }
abbr[title] { text-decoration: underline dotted; cursor: help; }
kbd {
  font-family: var(--f-body);
  font-size: .8em;
  padding: .05em .4em;
  border: 1px solid var(--rule-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--sheet);
  color: var(--ink-2);
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--ink);
  color: var(--sheet);
  border-radius: var(--r-s);
}
.skip:focus { top: .75rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--sheet) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name {
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 1.12rem;
  line-height: 1.1;
  letter-spacing: -.005em;
  white-space: nowrap;
}
.brand-name span { font-weight: 600; color: var(--ink-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0 .7rem;
  border: 1px solid transparent;
  border-radius: var(--r-m);
  background: transparent;
  color: var(--ink);
  font: 600 .95rem/1 var(--f-body);
  cursor: pointer;
}
.icon-btn:hover { background: var(--film); }
.icon-btn svg { width: 20px; height: 20px; flex: none; }
.search-btn {
  border-color: var(--rule);
  color: var(--ink-2);
  font-weight: 400;
}
.search-btn .lbl, .search-btn kbd { display: none; }
.menu-btn { border-color: var(--rule); }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}
@media (max-width: 39.99em) {
  .topbar { gap: .4rem; padding-right: .5rem; padding-left: .5rem; }
  .topbar-actions { gap: .1rem; }
  .icon-btn { min-width: 2.6rem; padding: 0 .55rem; }
  .brand { gap: .5rem; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-name { font-size: 1rem; }
  .search-btn { border-color: transparent; }
}
@media (max-width: 23.5em) {
  .brand-mark { display: none; }
}
@media (min-width: 40em) {
  :root { --gutter: 2rem; }
  .search-btn { min-width: 15rem; justify-content: flex-start; padding: 0 .6rem 0 .8rem; }
  .search-btn .lbl { display: inline; }
  .search-btn kbd { display: inline; margin-left: auto; }
}

/* ---------- Frame: rail · main · aside ---------- */
.frame { position: relative; }
.rail {
  position: fixed;
  z-index: 60;
  top: 0; bottom: 0; left: 0;
  width: min(21rem, 88vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1rem 2.5rem;
  background: var(--film);
  border-right: 1px solid var(--rule);
  transform: translateX(-102%);
  visibility: hidden;
  transition: transform .26s ease, visibility 0s linear .26s;
}
.rail.open {
  transform: none;
  visibility: visible;
  transition: transform .26s ease;
  box-shadow: var(--shadow);
}
.rail-close { display: flex; justify-content: flex-end; margin-bottom: .25rem; }
.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(10, 16, 22, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.scrim.show { opacity: 1; pointer-events: auto; }
.rail-group + .rail-group { margin-top: 1.4rem; }
.rail-label {
  margin: 0 0 .35rem;
  padding: 0 .65rem;
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: .01em;
}
.rail ol { list-style: none; margin: 0; padding: 0; }
.rail-link {
  display: flex;
  align-items: baseline;
  gap: .65rem;
  padding: .5rem .65rem;
  border-radius: var(--r-s);
  color: var(--ink);
  text-decoration: none;
  font-size: .98rem;
  line-height: 1.35;
}
.rail-link:hover { background: var(--sunk); }
.rail-n {
  flex: none;
  width: 1.4rem;
  font-variant-numeric: tabular-nums;
  font-size: .82rem;
  color: var(--ink-3);
  text-align: right;
}
.rail-link[aria-current="page"] {
  background: var(--sheet);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--artery), 0 0 0 1px var(--rule);
}
.rail-link[aria-current="page"] .rail-n { color: var(--artery); }
.rail-note {
  margin: 2rem .65rem 0;
  font-size: .86rem;
  line-height: 1.5;
  color: var(--ink-3);
}

@media (min-width: 70em) {
  .frame {
    display: grid;
    grid-template-columns: 17.5rem minmax(0, 1fr);
  }
  .rail {
    position: sticky;
    top: var(--topbar-h);
    z-index: 1;
    height: calc(100vh - var(--topbar-h));
    height: calc(100dvh - var(--topbar-h));
    width: auto;
    transform: none;
    visibility: visible;
    transition: none;
    box-shadow: none;
    padding-top: 1.5rem;
  }
  .rail-close, .menu-btn, .scrim { display: none; }
}
@media (min-width: 85em) {
  .frame { grid-template-columns: 17.5rem minmax(0, 1fr) 16rem; }
  .home .frame { grid-template-columns: 17.5rem minmax(0, 1fr); }
}

/* ---------- Page ---------- */
.page {
  min-width: 0;
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 2rem var(--gutter) 4rem;
}
@media (min-width: 70em) {
  .page { padding-top: 3rem; padding-left: 3rem; padding-right: 3rem; max-width: calc(var(--measure) + 6rem); }
}
.page-head { margin-bottom: 2.5rem; }
.crumb {
  margin: 0 0 .75rem;
  font-size: .92rem;
  color: var(--ink-3);
}
.crumb a { color: var(--ink-2); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.crumb .sep { margin: 0 .35rem; color: var(--rule-2); }

h1, h2, h3 {
  font-family: var(--f-head);
  color: var(--ink);
  text-wrap: balance;
}
h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.15rem, 1.6rem + 2.3vw, 3.35rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -.018em;
  font-optical-sizing: auto;
}
.summary {
  margin: 0;
  max-width: 40rem;
  font-size: 1.16em;
  line-height: 1.55;
  color: var(--ink-2);
  text-wrap: pretty;
}

/* inline "on this page" (small screens) */
.toc-inline {
  margin-top: 1.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--film);
}
.toc-inline > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  font-weight: 700;
  font-size: .98rem;
}
.toc-inline > summary::-webkit-details-marker { display: none; }
.toc-inline > summary .count { font-weight: 400; color: var(--ink-3); }
.toc-inline > summary::after {
  content: "";
  width: .55rem; height: .55rem;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .2s ease;
}
.toc-inline[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.toc-inline ol {
  margin: 0;
  padding: .25rem 1rem 1rem 2.6rem;
  columns: 2 13rem;
  column-gap: 2rem;
  font-size: .97rem;
}
.toc-inline li { break-inside: avoid; padding: .2rem 0; }
.toc-inline a { color: var(--ink); text-decoration: none; }
.toc-inline a:hover { color: var(--vein); text-decoration: underline; }
.toc-inline li::marker { color: var(--ink-3); font-size: .85em; }
@media (min-width: 85em) { .toc-inline { display: none; } }

/* right-hand "on this page" (wide screens) */
.aside { display: none; }
@media (min-width: 85em) {
  .aside {
    display: block;
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    max-height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 3.25rem 1.5rem 2rem 0;
  }
  .aside-label { margin: 0 0 .6rem; font-size: .85rem; font-weight: 700; color: var(--ink-3); }
  .aside ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
  .aside a {
    display: block;
    margin-left: -1px;
    padding: .32rem 0 .32rem .9rem;
    border-left: 2px solid transparent;
    color: var(--ink-2);
    text-decoration: none;
    font-size: .9rem;
    line-height: 1.35;
  }
  .aside a:hover { color: var(--ink); }
  .aside a.current { color: var(--ink); font-weight: 700; border-left-color: var(--artery); }
  .aside a[data-bed="venous"].current { border-left-color: var(--vein); }
}

/* ---------- Sections and prose ---------- */
.sec { padding-top: 1rem; margin-top: 3.25rem; }
.page-head + .sec { margin-top: 0; }
.sec > h2:first-child, .sec > .sec-head:first-child { margin-top: 0; }
.sec h2 {
  position: relative;
  margin: 0 0 1rem;
  padding-top: 1rem;
  font-size: clamp(1.6rem, 1.35rem + 1vw, 2.15rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.012em;
}
/* the bed bar: arterial red, venous blue, both = split */
.sec h2::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 2.75rem;
  height: 4px;
  border-radius: 2px;
  background: var(--ink-3);
}
.sec[data-bed="arterial"] h2::before { background: var(--artery); }
.sec[data-bed="venous"] h2::before { background: var(--vein); }
.sec[data-bed="both"] h2::before { background: linear-gradient(90deg, var(--artery) 0 50%, var(--vein) 50% 100%); }
.sec-lede { margin: 0 0 1.25rem; font-size: 1.06em; color: var(--ink-2); }
.tag {
  display: inline-block;
  vertical-align: .25em;
  margin-left: .5rem;
  padding: .12rem .5rem;
  border-radius: 999px;
  font-family: var(--f-body);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
  background: var(--film);
  color: var(--ink-2);
  border: 1px solid var(--rule);
}
.tag.urgent { background: var(--artery-tint); color: var(--artery); border-color: transparent; }

.page h3 {
  margin: 2.25rem 0 .6rem;
  font-size: 1.36rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.005em;
}
.page h4 {
  margin: 1.75rem 0 .4rem;
  font-family: var(--f-body);
  font-size: 1.02em;
  font-weight: 700;
  line-height: 1.35;
}
.page p { margin: 0 0 1rem; text-wrap: pretty; }
.page ul, .page ol { margin: 0 0 1.25rem; padding-left: 1.35rem; }
.page li { margin: 0 0 .45rem; padding-left: .2rem; }
.page li::marker { color: var(--ink-3); }
.page ul > li::marker { content: "■  "; font-size: .55em; }
.lead-in { font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: .9em; }
hr.rule { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* ---------- Steps (true sequences only) ---------- */
.page ol.steps { list-style: none; padding: 0; counter-reset: step; margin: 1rem 0 1.5rem; }
.page ol.steps > li {
  position: relative;
  counter-increment: step;
  padding: 0 0 1rem 2.9rem;
  margin: 0;
}
.page ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: .05rem;
  width: 1.95rem; height: 1.95rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--film);
  border: 1px solid var(--rule-2);
  font-family: var(--f-head);
  font-weight: 700;
  font-size: .95rem;
  color: var(--ink);
  font-variant-numeric: lining-nums;
}
.page ol.steps > li::after {
  content: "";
  position: absolute;
  left: .97rem; top: 2.2rem; bottom: .2rem;
  width: 1px;
  background: var(--rule);
}
.page ol.steps > li:last-child::after { display: none; }
.page ol.steps > li > strong:first-child { display: block; }

/* ---------- Callouts ---------- */
.note {
  --c: var(--ink-2);
  --t: var(--film);
  margin: 1.6rem 0;
  padding: 1rem 1.15rem 1.05rem;
  background: var(--t);
  border-left: 4px solid var(--c);
  border-radius: 0 var(--r-m) var(--r-m) 0;
}
.note > :last-child { margin-bottom: 0; }
.note-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .35rem !important;
  color: var(--c);
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.3;
}
.note-label::before {
  content: "";
  flex: none;
  width: 1.05rem; height: 1.05rem;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.note.flag { --c: var(--artery); --t: var(--artery-tint);
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 1 21h22L12 2zm-1 7h2v6h-2V9zm0 8h2v2h-2v-2z'/%3E%3C/svg%3E"); }
.note.pearl { --c: var(--pearl); --t: var(--pearl-tint);
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3C/svg%3E"); }
.note.mnem { --c: var(--mnem); --t: var(--mnem-tint);
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-4 12.7V17h8v-2.3A7 7 0 0 0 12 2zM9 19h6v1.5a1.5 1.5 0 0 1-1.5 1.5h-3A1.5 1.5 0 0 1 9 20.5V19z'/%3E%3C/svg%3E"); }
.note.tip { --c: var(--tip); --t: var(--tip-tint);
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 14.9 8.6 22 9.3l-5.4 4.7L18.2 21 12 17.3 5.8 21l1.6-7L2 9.3l7.1-.7L12 2z'/%3E%3C/svg%3E"); }
.note.local { --c: var(--vein); --t: var(--vein-tint);
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.2 7 13 7 13s7-7.8 7-13a7 7 0 0 0-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E"); }
.note.plain { --c: var(--ink-2); --t: var(--film);
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 7h2v2h-2zm0 4h2v6h-2zm1-9a10 10 0 1 0 0 20 10 10 0 0 0 0-20z'/%3E%3C/svg%3E"); }

/* ---------- Questions (tap to reveal) ---------- */
.qa {
  margin: 1rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--sheet);
}
.qa + .qa { margin-top: -.35rem; }
.qa > summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  padding: .95rem 1rem .95rem 3rem;
  font-weight: 700;
  line-height: 1.45;
}
.qa > summary::-webkit-details-marker { display: none; }
.qa > summary::before {
  content: "Q";
  position: absolute;
  left: 1rem; top: .92rem;
  width: 1.5rem; height: 1.5rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--vein-tint);
  color: var(--vein);
  font-family: var(--f-head);
  font-size: .85rem;
}
.qa > summary .reveal-hint {
  display: block;
  margin-top: .3rem;
  font-weight: 400;
  font-size: .86rem;
  color: var(--vein);
}
.qa[open] > summary .reveal-hint::before { content: "Hide answer"; }
.qa:not([open]) > summary .reveal-hint::before { content: "Show answer"; }
.qa > summary:hover { background: var(--film); border-radius: var(--r-m); }
.qa-a { padding: .1rem 1.1rem 1rem 3rem; }
.qa-a > :last-child { margin-bottom: 0; }
.qa[open] > summary { border-bottom: 1px dashed var(--rule); border-radius: var(--r-m) var(--r-m) 0 0; }
.qa[open] .qa-a { padding-top: .85rem; }
.qa-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 2.6rem;
  padding: .45rem .95rem;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-m);
  background: var(--sheet);
  color: var(--ink);
  font: 600 .94rem/1.2 var(--f-body);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--film); }
.btn.primary { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); }

/* ---------- Tables ---------- */
.table-wrap {
  margin: 1.5rem 0;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--sheet);
  -webkit-overflow-scrolling: touch;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .94rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
table.data caption {
  caption-side: top;
  text-align: left;
  padding: .8rem 1rem;
  font-weight: 700;
  font-size: .98rem;
  border-bottom: 1px solid var(--rule);
}
table.data th, table.data td {
  padding: .65rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
table.data thead th {
  background: var(--film);
  font-size: .86rem;
  color: var(--ink-2);
  font-weight: 700;
  white-space: nowrap;
}
table.data tbody tr:last-child > * { border-bottom: 0; }
table.data tbody th { font-weight: 700; }
table.data td.num, table.data th.num { white-space: nowrap; }
table.data tr.hot > * { background: var(--artery-tint); }
table.data tr.hot > :first-child { box-shadow: inset 3px 0 0 var(--artery); }
@media (max-width: 40em) {
  table.data { font-size: .9rem; }
  table.data th, table.data td { padding: .6rem .75rem; }
  table.data:not(.no-sticky) tbody > tr > :first-child,
  table.data:not(.no-sticky) thead > tr > :first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--sheet);
    box-shadow: 1px 0 0 var(--rule);
  }
  table.data:not(.no-sticky) thead > tr > :first-child { background: var(--film); }
  table.data:not(.no-sticky) tbody > tr.hot > :first-child {
    background: var(--artery-tint);
    box-shadow: inset 3px 0 0 var(--artery), 1px 0 0 var(--rule);
  }
  table.data td { min-width: 9rem; }
}

/* ---------- Term lists ---------- */
.terms { margin: 1.25rem 0 1.5rem; border-top: 1px solid var(--rule); }
.terms > div { padding: .85rem 0; border-bottom: 1px solid var(--rule); }
.terms dt { font-weight: 700; margin: 0 0 .2rem; }
.terms dt .aka { font-weight: 400; color: var(--ink-3); font-size: .92em; }
.terms dd { margin: 0; color: var(--ink); }
.terms dd > p:last-child { margin-bottom: 0; }
@media (min-width: 48em) {
  .terms > div { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); gap: 1.25rem; }
  .terms dt { margin: 0; }
  .terms.wide > div { grid-template-columns: 15rem minmax(0, 1fr); }
}

/* ---------- Key numbers ---------- */
.facts {
  list-style: none !important;
  margin: 1.25rem 0 1.75rem !important;
  padding: 0 !important;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  gap: 0;
  border-top: 1px solid var(--rule);
}
.facts > li {
  margin: 0 !important;
  padding: .9rem 1rem .9rem 0 !important;
  border-bottom: 1px solid var(--rule);
}
.facts > li::marker { content: none; }
.facts b {
  display: block;
  font-family: var(--f-head);
  font-size: 1.55rem;
  line-height: 1.15;
  letter-spacing: -.01em;
  font-variant-numeric: lining-nums;
}
.facts span { display: block; margin-top: .2rem; font-size: .92rem; color: var(--ink-2); line-height: 1.4; }

/* ---------- Checklist ---------- */
.checklist { list-style: none !important; padding: 0 !important; margin: 1rem 0 1.5rem !important; }
.checklist > li {
  position: relative;
  margin: 0 !important;
  padding: .8rem 0 .8rem 2.3rem !important;
  border-bottom: 1px solid var(--rule);
}
.checklist > li::marker { content: none; }
.checklist > li::before {
  content: "";
  position: absolute;
  left: .1rem; top: 1.02rem;
  width: 1.15rem; height: 1.15rem;
  border: 2px solid var(--rule-2);
  border-radius: 4px;
}
.checklist > li > strong:first-child { display: block; }
.checklist .who { display: block; font-size: .88rem; color: var(--ink-3); }

/* ---------- Two-up comparison ---------- */
.compare { display: grid; gap: 1rem; margin: 1.5rem 0; }
@media (min-width: 40em) { .compare { grid-template-columns: 1fr 1fr; } }
.compare > div {
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  border-top: 4px solid var(--ink-3);
}
.compare > div.arterial { border-top-color: var(--artery); }
.compare > div.venous { border-top-color: var(--vein); }
.compare h4 { margin-top: 0 !important; }
.compare ul { margin-bottom: 0; }

/* ---------- Script / sample presentation ---------- */
.script {
  margin: 1.5rem 0;
  padding: 1.15rem 1.25rem;
  border-radius: var(--r-m);
  background: var(--film);
  border: 1px solid var(--rule);
}
.script-label { margin: 0 0 .5rem !important; font-weight: 700; font-size: .95rem; color: var(--ink-2); }
.script p { font-size: .98em; line-height: 1.7; }
.ph {
  padding: 0 .2em;
  border-radius: 3px;
  background: var(--vein-tint);
  color: var(--vein);
  font-weight: 600;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---------- Copyable templates ---------- */
.template {
  margin: 1.5rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  overflow: hidden;
  background: var(--sheet);
}
.template-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem .6rem .55rem 1rem;
  background: var(--film);
  border-bottom: 1px solid var(--rule);
}
.template-head figcaption, .template-head .t-title { font-weight: 700; font-size: .95rem; }
.copy-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  min-height: 2.25rem;
  padding: .3rem .75rem;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-s);
  background: var(--sheet);
  color: var(--ink);
  font: 600 .86rem/1 var(--f-body);
  cursor: pointer;
  white-space: nowrap;
}
.copy-btn:hover { background: var(--sunk); }
.copy-btn.done { color: var(--pearl); border-color: var(--pearl); }
.template pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--f-code);
  font-size: .84rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  tab-size: 2;
}

/* ---------- Device entries ---------- */
.device-grid { display: grid; gap: 1rem; margin: 1.25rem 0 1.75rem; }
@media (min-width: 40em) { .device-grid { grid-template-columns: 1fr 1fr; } }
.device {
  padding: 1rem 1.1rem 1.05rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--sheet);
}
.device h4 { margin: 0 0 .15rem !important; font-size: 1.05rem; }
.device .brands { margin: 0 0 .55rem !important; font-size: .88rem; color: var(--ink-3); }
.device p { font-size: .96rem; margin-bottom: .5rem; }
.device p:last-child { margin-bottom: 0; }
.device .spec {
  display: flex; flex-wrap: wrap; gap: .35rem;
  list-style: none !important; padding: 0 !important; margin: 0 0 .6rem !important;
}
.device .spec li {
  margin: 0 !important; padding: .1rem .5rem !important;
  border-radius: 999px;
  background: var(--film);
  border: 1px solid var(--rule);
  font-size: .8rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.device .spec li::marker { content: none; }
.device .ask { font-size: .92rem; color: var(--ink-2); }
.device .ask b { color: var(--ink); }

/* ---------- Pager ---------- */
.pager {
  display: grid;
  gap: .75rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
@media (min-width: 40em) { .pager { grid-template-columns: 1fr 1fr; } }
.pager a {
  display: block;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  text-decoration: none;
  color: var(--ink);
}
.pager a:hover { border-color: var(--rule-2); background: var(--film); }
.pager .dir { display: block; font-size: .86rem; color: var(--ink-3); }
.pager .ttl { display: block; font-family: var(--f-head); font-weight: 700; font-size: 1.15rem; line-height: 1.25; }
.pager .next { text-align: right; grid-column: -2; }

/* ---------- Footer ---------- */
.site-foot {
  border-top: 1px solid var(--rule);
  background: var(--film);
  padding: 2.5rem var(--gutter) 3rem;
  font-size: .92rem;
  color: var(--ink-2);
}
.site-foot .inner { max-width: 70rem; margin: 0 auto; display: grid; gap: 1.5rem; }
@media (min-width: 48em) { .site-foot .inner { grid-template-columns: 1.4fr 1fr; gap: 3rem; } }
.site-foot p { margin: 0 0 .6rem; }
.site-foot b { color: var(--ink); }
.site-foot a { color: var(--ink-2); }

/* ---------- Back to top ---------- */
.to-top {
  position: fixed;
  right: 1rem; bottom: 1rem;
  z-index: 30;
  width: 2.9rem; height: 2.9rem;
  display: grid; place-items: center;
  border: 1px solid var(--rule-2);
  border-radius: 50%;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top svg { width: 18px; height: 18px; }

/* ---------- Search dialog ---------- */
.search-dlg {
  width: min(42rem, calc(100vw - 1.5rem));
  max-height: min(42rem, calc(100dvh - 3rem));
  margin: 1.5rem auto auto;
  padding: 0;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-l);
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-dlg[open] { display: flex; flex-direction: column; }
.search-dlg::backdrop { background: rgba(10, 16, 22, .5); }
.search-top { display: flex; align-items: center; gap: .5rem; padding: .6rem .6rem .6rem 1rem; border-bottom: 1px solid var(--rule); }
.search-top svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.search-input {
  flex: 1;
  min-width: 0;
  height: 2.75rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 400 1.1rem/1 var(--f-body);
  outline: none;
}
.search-input::placeholder { color: var(--ink-3); }
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search-results { list-style: none; margin: 0; padding: .4rem; overflow-y: auto; }
.search-results li { margin: 0; }
.search-results a {
  display: block;
  padding: .7rem .8rem;
  border-radius: var(--r-s);
  color: var(--ink);
  text-decoration: none;
}
.search-results a:hover, .search-results a.sel { background: var(--film); }
.search-results .r-page { display: block; font-size: .82rem; color: var(--ink-3); }
.search-results .r-title { display: block; font-weight: 700; }
.search-results .r-snip { display: block; font-size: .9rem; color: var(--ink-2); line-height: 1.45; margin-top: .15rem; }
.search-results mark { background: var(--mnem-tint); color: inherit; border-radius: 2px; padding: 0 .1em; }
.search-empty { padding: 1.25rem 1.1rem; color: var(--ink-2); font-size: .95rem; margin: 0; }
.search-foot { padding: .55rem 1rem; border-top: 1px solid var(--rule); font-size: .82rem; color: var(--ink-3); }

/* ============================================================
   Home page
   ============================================================ */
.home .page { max-width: calc(64rem + 2 * var(--gutter)); }
@media (min-width: 70em) { .home .page { max-width: calc(64rem + 6rem); } }
.home .prose { max-width: var(--measure); }

.hero {
  display: grid;
  gap: 2rem;
  align-items: start;
  margin: 0 0 3.5rem;
}
@media (min-width: 56em) {
  .hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 3rem; }
}
.hero h1 { font-size: clamp(2.5rem, 1.7rem + 3.6vw, 4.4rem); margin-bottom: 1.25rem; }
.hero .summary { font-size: 1.2em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.75rem; }

/* author byline, right under the title */
.byline {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin: 0 0 1.5rem;
  padding: .7rem 1rem .7rem .7rem;
  max-width: 34rem;
  border: 1px solid var(--rule);
  border-radius: 999px 1rem 1rem 999px;
  background: var(--film);
}
.byline img {
  flex: none;
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--artery);
}
.byline p { margin: 0; line-height: 1.35; }
.byline .by-k { display: block; font-size: .82rem; color: var(--ink-3); }
.byline .by-name { display: block; font-family: var(--f-head); font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.byline .by-bio { display: block; margin-top: .15rem; font-size: .88rem; color: var(--ink-2); }
@media (max-width: 26em) {
  .byline { border-radius: 1rem; align-items: flex-start; }
  .byline img { width: 48px; height: 48px; }
}

/* the runoff angiogram */
.angio {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 1rem;
  align-items: stretch;
  padding: 1rem;
  border-radius: var(--r-l);
  background: var(--angio-bg);
  border: 1px solid var(--rule);
}
.angio svg { width: 100%; height: auto; max-height: 40rem; display: block; margin: 0 auto; }
.angio .v { fill: none; stroke: var(--vessel); stroke-linecap: round; stroke-linejoin: round; }
.angio .ghost { stroke: var(--vessel-ghost); }
.angio .pin circle { fill: var(--artery); }
.angio .pin text { fill: #fff; font: 700 15px var(--f-body); text-anchor: middle; dominant-baseline: central; }
:root[data-theme="dark"] .angio .pin text { fill: #10161c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .angio .pin text { fill: #10161c; } }
.angio .pin { transition: transform .15s ease; transform-box: fill-box; transform-origin: center; }
.angio .pin.hl circle { fill: var(--vein); }
.angio .pin.hl { transform: scale(1.35); }
.angio figcaption { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.angio .cap-title { margin: 0 0 .25rem; font-family: var(--f-head); font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.angio .cap-sub { margin: 0 0 .75rem; font-size: .86rem; color: var(--ink-2); line-height: 1.4; }
.angio ol { margin: 0; padding: 0; list-style: none; counter-reset: v; font-size: .9rem; line-height: 1.3; }
.angio ol li {
  counter-increment: v;
  display: flex; gap: .5rem; align-items: baseline;
  padding: .22rem .3rem;
  margin: 0;
  border-radius: 4px;
  cursor: default;
}
.angio ol li::before {
  content: counter(v);
  flex: none;
  width: 1.3rem;
  font-weight: 700;
  font-size: .8rem;
  color: var(--artery);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.angio ol li.hl { background: var(--sheet); }
@media (max-width: 26em) {
  .angio { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); padding: .75rem; gap: .6rem; }
  .angio ol { font-size: .84rem; }
}
/* contrast run: vessels fill once, aorta to foot */
@media (prefers-reduced-motion: no-preference) {
  .js .angio .run { stroke-dasharray: 1; stroke-dashoffset: 1; animation: fill .7s cubic-bezier(.45, 0, .2, 1) forwards; animation-delay: var(--d, 0s); }
  .js .angio .pin { opacity: 0; animation: pinIn .3s ease forwards; animation-delay: calc(var(--d, 0s) + .35s); }
}
@keyframes fill { to { stroke-dashoffset: 0; } }
@keyframes pinIn { to { opacity: 1; } }

/* role tracks */
.tracks { margin: 0 0 3.5rem; }
.tracks h2 { margin: 0 0 .5rem; font-size: clamp(1.6rem, 1.35rem + 1vw, 2.15rem); line-height: 1.15; }
.track-tabs {
  display: flex;
  gap: .25rem;
  margin: 1.25rem 0 0;
  padding: .3rem;
  background: var(--film);
  border: 1px solid var(--rule);
  border-radius: calc(var(--r-m) + .3rem);
  overflow-x: auto;
}
.track-tab {
  flex: 1 0 auto;
  min-height: 2.75rem;
  padding: .5rem .9rem;
  border: 0;
  border-radius: var(--r-m);
  background: transparent;
  color: var(--ink-2);
  font: 700 .97rem/1.2 var(--f-body);
  cursor: pointer;
  white-space: nowrap;
}
.track-tab[aria-selected="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 0 0 1px var(--rule), 0 1px 2px rgba(0,0,0,.06); }
.track-panel { padding: 1.5rem 0 0; }
.no-js .track-tabs { display: none; }
.track-panel h3 { margin-top: 0 !important; }
.track-why { margin: 0 0 1.25rem; color: var(--ink-2); max-width: var(--measure); }
.path { list-style: none !important; padding: 0 !important; margin: 0 !important; counter-reset: p; display: grid; gap: 0; border-top: 1px solid var(--rule); }
.path > li {
  counter-increment: p;
  margin: 0 !important;
  padding: 0 !important;
  border-bottom: 1px solid var(--rule);
}
.path > li::marker { content: none; }
.path a {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  gap: .1rem .75rem;
  padding: .95rem .25rem;
  color: var(--ink);
  text-decoration: none;
}
.path a::before {
  content: counter(p);
  grid-row: span 2;
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--artery);
  padding-top: .1rem;
}
.path a:hover .p-t { text-decoration: underline; text-underline-offset: .18em; }
.path .p-t { font-weight: 700; font-size: 1.05rem; }
.path .p-d { color: var(--ink-2); font-size: .95rem; line-height: 1.5; }
.path .p-when { color: var(--ink-3); font-weight: 400; }

/* resident gains */
.gains { display: grid; gap: 0; margin: 1.5rem 0 0; border-top: 1px solid var(--rule); }
@media (min-width: 48em) { .gains { grid-template-columns: 1fr 1fr; column-gap: 2.5rem; } }
.gains > div { padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.gains h3 { margin: 0 0 .35rem !important; font-size: 1.15rem !important; }
.gains p { margin: 0 !important; color: var(--ink-2); font-size: .98rem; }
.gains a { font-weight: 700; }

/* contents (book style) */
.contents { margin: 1.5rem 0 0; }
.contents-group + .contents-group { margin-top: 2rem; }
.contents-group > p { margin: 0 0 .25rem !important; font-weight: 700; color: var(--ink-3); font-size: .92rem; }
.contents ol { list-style: none !important; padding: 0 !important; margin: 0 !important; border-top: 1px solid var(--rule); }
.contents li { margin: 0 !important; padding: 0 !important; border-bottom: 1px solid var(--rule); }
.contents li::marker { content: none; }
.contents a {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0 .75rem;
  padding: .85rem .25rem;
  color: var(--ink);
  text-decoration: none;
}
@media (min-width: 48em) {
  .contents a { grid-template-columns: 2rem 15rem minmax(0, 1fr); align-items: baseline; }
}
.contents a:hover { background: var(--film); }
.contents .c-n { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: .9rem; }
.contents .c-t { font-family: var(--f-head); font-weight: 700; font-size: 1.15rem; line-height: 1.3; }
.contents .c-d { grid-column: 2 / -1; color: var(--ink-2); font-size: .95rem; line-height: 1.5; }
@media (min-width: 48em) { .contents .c-d { grid-column: auto; } }
.contents .new {
  margin-left: .4rem;
  font-family: var(--f-body);
  font-size: .74rem;
  font-weight: 700;
  color: var(--pearl);
  vertical-align: .2em;
}

/* author credit */
.credit {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 2.5rem 0 0;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-l);
  max-width: var(--measure);
}
.credit img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; filter: grayscale(.15); }
.credit p { margin: 0 !important; }
.credit .c-by { font-size: .86rem; color: var(--ink-3); }
.credit .c-name { font-family: var(--f-head); font-weight: 700; font-size: 1.2rem; line-height: 1.25; }
.credit .c-bio { font-size: .95rem; color: var(--ink-2); line-height: 1.5; margin-top: .2rem !important; }

/* legend for the colour code */
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin: 1rem 0 0; padding: 0; list-style: none; font-size: .92rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: .5rem; margin: 0; }
.legend li::marker { content: none; }
.legend i { display: inline-block; width: 1.6rem; height: 4px; border-radius: 2px; background: var(--ink-3); }
.legend i.a { background: var(--artery); }
.legend i.v { background: var(--vein); }
.legend i.b { background: linear-gradient(90deg, var(--artery) 0 50%, var(--vein) 50% 100%); }

/* ---------- Print ---------- */
@media print {
  .topbar, .rail, .aside, .scrim, .pager, .to-top, .toc-inline, .copy-btn, .search-dlg, .track-tabs, .skip { display: none !important; }
  body { font-size: 11pt; background: #fff; color: #000; }
  .frame { display: block; }
  .page { max-width: none; padding: 0; }
  .note, .qa, .table-wrap, .template, .device { break-inside: avoid; }
  .qa > summary .reveal-hint { display: none; }
  a { color: inherit; text-decoration: none; }
  .track-panel[hidden] { display: block !important; }
}
