/* ==========================================================================
   medtopo.css — shared design system for Med Topo.
   Every module page links this first; module-specific CSS (simulator panels,
   journey decision trees, etc.) stays inline and overrides as needed.
   ========================================================================== */

/* ============ STONE PALETTE (tokens) ============ */
:root {
  --bg: #f4efe3;
  --bg-dim: #ece5d4;
  --surface: #f9f4e7;
  --surface-elev: #ffffff;
  --surface2: #f4ecd8;
  --surface3: #ebe2cc;
  --border: #d9ceb5;
  --border-strong: #b9ac8d;
  --text: #2d2821;
  --text-muted: #6e5838;
  --text-dim: #8a7454;

  --sienna: #8a4b2a;
  --gold:   #b08a3e;
  --gold-soft: #c9a75a;
  --moss:   #5a6b3e;
  --slate:  #4a5662;
  --plum:   #6a3d52;
  --teal:   #5d7578;
  --teal-soft: #7a9598;
  --rose:   #a25a3a;
  --emerald: #7a8560;
  --emerald-soft: #9aa582;
  --violet: #8a6f7e;
  --aqua:   #4a7a85;
  --aqua-soft: #6a9ba6;

  --accent: var(--aqua);

  --shadow-sm: 0 1px 2px rgba(70, 55, 30, 0.06), 0 2px 6px rgba(70, 55, 30, 0.04);
  --shadow-md: 0 2px 6px rgba(70, 55, 30, 0.08), 0 8px 24px rgba(70, 55, 30, 0.06);
  --shadow-lg: 0 4px 14px rgba(70, 55, 30, 0.10), 0 16px 40px rgba(70, 55, 30, 0.08);
}

/* ============ RESET & BASE ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: 'JetBrains Mono', monospace; }

/* ============ HEADER ============ */
header.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244, 239, 227, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.hdr-inner {
  max-width: 1340px; margin: 0 auto;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
}
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.logo-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--aqua), var(--teal));
  border-radius: 8px;
  display: grid; place-items: center;
  color: #f9f4e7; font-weight: 700;
  box-shadow: var(--shadow-sm);
  font-size: 1rem;
}
.logo-text { font-weight: 700; letter-spacing: -0.01em; font-size: 1.04rem; }
.logo-sub { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.hdr-right { display: flex; align-items: center; gap: 14px; }
.hdr-ver { font-size: 0.78rem; color: var(--text-muted); }

/* (Zoom control removed — browser zoom + pinch-to-zoom cover the same use case.) */

/* Top-bar dropdown styles live in /styles/medtopo-topnav.css — loaded by every
 * page (including those without medtopo.css: acs.html, guide.html, pdd.html). */

/* ============ GLOBAL LAYOUT + SIDEBAR ============ */
.global-layout {
  max-width: 1340px; margin: 0 auto;
  display: flex; gap: 0; align-items: flex-start;
  min-height: calc(100vh - 60px);
}
.global-sidebar {
  width: 250px; flex-shrink: 0;
  padding: 30px 18px 30px 28px;
  position: sticky; top: 60px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  font-size: 0.88rem;
  transition: width 0.22s ease, padding 0.22s ease;
}
.global-sidebar::-webkit-scrollbar { width: 4px; }
.global-sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* Collapse toggle */
.gs-toggle {
  position: absolute; top: 18px; right: 8px;
  width: 26px; height: 26px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 7px; cursor: pointer;
  font-size: 0.78rem; color: var(--text-muted);
  display: grid; place-items: center;
  transition: transform 0.2s ease;
  z-index: 2;
}
.gs-toggle:hover { background: var(--surface-elev); color: var(--text); }
.global-sidebar.collapsed {
  width: 52px;
  padding: 30px 6px 30px 6px;
  overflow: hidden;
}
/* Collapse: hide secondary elements regardless of whether the sidebar uses
   medtopo-style <a class="gs-section"> or accordion-style <div class="gs-section">. */
.global-sidebar.collapsed .gs-back,
.global-sidebar.collapsed .gs-home-link,
.global-sidebar.collapsed .gs-subs,
.global-sidebar.collapsed .gs-divider,
.global-sidebar.collapsed a.gs-section span:not(.gs-icon),
.global-sidebar.collapsed .gs-page-link span:not(.gs-icon) { display: none; }
/* Collapse: squash any raw text inside gs-page-link while keeping the icon visible. */
.global-sidebar.collapsed .gs-page-link { font-size: 0; }
.global-sidebar.collapsed .gs-page-link .gs-icon { font-size: 1rem; }
.global-sidebar.collapsed a.gs-section,
.global-sidebar.collapsed .gs-page-link {
  justify-content: center;
  padding: 8px 0;
  margin-bottom: 4px;
}
.global-sidebar.collapsed .gs-toggle { transform: rotate(180deg); }

/* Sidebar links */
.gs-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none; font-size: 0.82rem;
  padding: 4px 0 12px 0; border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.gs-back:hover { color: var(--text); }
/* Anchor-style sections (used on fluids.html, _styleguide.html, index-style sidebars).
   Accordion-style <div class="gs-section"> sidebars (cardio, hyponatremia, etc.)
   use their own inline .gs-section / .gs-page-link rules and are intentionally
   NOT matched here — scoping to `a.gs-section` keeps those pages untouched. */
a.gs-section {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 2px;
}
a.gs-section.current {
  background: var(--surface-elev);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.gs-icon { font-size: 1rem; width: 18px; display: inline-block; text-align: center; }
/* Only style sub-lists/sub-links for medtopo-style sidebars; pages with their own
   accordion scope (cardio, hyponatremia) define these inline. */
a.gs-section + .gs-subs,
.global-sidebar > .gs-subs { list-style: none; padding-left: 38px; padding-top: 2px; padding-bottom: 4px; }
a.gs-section + .gs-subs li,
.global-sidebar > .gs-subs li { margin-bottom: 1px; }
a.gs-section + .gs-subs .gs-sub-link,
.global-sidebar > .gs-subs .gs-sub-link {
  display: block;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
a.gs-section + .gs-subs .gs-sub-link:hover,
.global-sidebar > .gs-subs .gs-sub-link:hover { background: var(--surface); color: var(--text); }
a.gs-section + .gs-subs .gs-sub-link.active,
.global-sidebar > .gs-subs .gs-sub-link.active { color: var(--accent); font-weight: 600; background: var(--surface); }
.gs-divider { height: 1px; background: var(--border); margin: 14px 4px; }

.global-main { flex: 1; min-width: 0; padding: 0; }

/* ============ PAGE HEAD ============ */
.page-head {
  padding: 48px 28px 32px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-dim) 100%);
}
.page-head-inner { max-width: 1080px; margin: 0 auto; }
.eyebrow {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}
.page-title {
  font-size: 2.65rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.08;
  margin-bottom: 12px;
  color: var(--text);
}
.page-title .grad {
  background: linear-gradient(135deg, var(--aqua), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-sub {
  font-size: 1.04rem;
  color: var(--text-muted);
  max-width: 780px;
  line-height: 1.62;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 28px; }

/* ============ STAGES + STAGE NAV ============ */
section.stage { padding: 56px 0; border-bottom: 1px solid var(--border); }
section.stage:nth-child(even) { background: var(--bg-dim); }
section.stage { display: none; }
section.stage.active { display: block; }

.section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.section-head h2 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  color: var(--text);
}
.section-head h2 .grad {
  background: linear-gradient(135deg, var(--aqua), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.section-head .eyebrow { margin-bottom: 6px; }

h3 {
  font-size: 1.2rem; font-weight: 700; color: var(--text);
  margin-bottom: 12px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
}
h3 .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
h4 { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }

/* Stage nav tabs */
.journey-nav {
  display: flex;
  gap: 6px;
  margin-top: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.journey-btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.journey-btn:hover { color: var(--text); border-color: var(--border-strong); }
.journey-btn.active {
  background: var(--accent);
  color: var(--surface-elev);
  border-color: var(--accent);
}

/* ============ CARDS ============ */
.card {
  background: var(--surface-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card-elevated { box-shadow: var(--shadow-md); }
.card + .card { margin-top: 18px; }
.card p { margin-bottom: 10px; color: var(--text); }
.card p:last-child { margin-bottom: 0; }

/* ============ GRIDS ============ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ============ CALLOUT ============ */
.callout {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 14px 18px;
  font-size: 0.92rem;
  color: var(--text-muted);
}
.callout strong { color: var(--text); }
.callout.rose    { border-left-color: var(--rose); }
.callout.gold    { border-left-color: var(--gold); }
.callout.emerald { border-left-color: var(--emerald); }
.callout.teal    { border-left-color: var(--teal); }
.callout.plum    { border-left-color: var(--plum); }

/* ============ TABLES ============ */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-weight: 700; color: var(--text-muted);
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--surface);
}
.data-table tr:hover td { background: var(--surface); }
.data-table td.num { font-family: 'JetBrains Mono', monospace; font-size: 0.84rem; }

/* ============ PILLS ============ */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pill-iso      { background: rgba(93,117,120,0.15);  color: var(--teal); }
.pill-hypo     { background: rgba(176,138,62,0.18);  color: var(--gold); }
.pill-hyper    { background: rgba(162,90,58,0.18);   color: var(--rose); }
.pill-colloid  { background: rgba(138,111,126,0.18); color: var(--violet); }
.pill-balanced { background: rgba(122,133,96,0.20);  color: var(--emerald); }

/* ============ FOOTER ============ */
footer {
  padding: 32px 28px;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ============ UTILITY ============ */
.mt-20 { margin-top: 20px; }
.mt-14 { margin-top: 14px; }
.mt-10 { margin-top: 10px; }
.text-aqua    { color: var(--aqua); }
.text-teal    { color: var(--teal); }
.text-rose    { color: var(--rose); }
.text-gold    { color: var(--gold); }
.text-emerald { color: var(--emerald); }
.text-muted   { color: var(--text-muted); }
.expand-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 6px;
}
.kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-muted);
}

/* ==========================================================================
   HAMBURGER + MOBILE DRAWER BACKDROP (injected by medtopo.js on narrow screens)
   ========================================================================== */
.hdr-hamburger {
  display: none;            /* shown only at <900px via media query below */
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  align-items: center; justify-content: center;
  margin-right: 8px;
  color: var(--text);
  font-size: 1.2rem;
}
.hdr-hamburger:hover { background: var(--surface-elev); }
.hdr-hamburger .bars {
  display: inline-flex; flex-direction: column; gap: 4px;
}
.hdr-hamburger .bars span {
  display: block; width: 18px; height: 2px;
  background: currentColor; border-radius: 2px;
}
.mobile-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30, 24, 14, 0.45);
  z-index: 199;
  opacity: 0; transition: opacity 0.2s ease;
}
body.mobile-drawer-open .mobile-backdrop {
  display: block; opacity: 1;
}
body.mobile-drawer-open {
  overflow: hidden;        /* lock background scroll while drawer is open */
}

/* ==========================================================================
   CROSS-MODULE NAV — injected at top of every #globalSidebar by medtopo.js.
   Drill-down: either the ROOT view (list of specialties) OR the SPECIALTY
   view (back button + one specialty's items). Never both at once, so the
   sidebar stays compact and the page-specific nav below it sits close to
   the top of the screen.
   ========================================================================== */
.medtopo-nav {
  margin: 0 0 14px 0;
  padding: 0 0 12px 0;
  border-bottom: 1px dashed var(--border, #d0c3a7);
}
.medtopo-nav-head {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.65rem;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-muted, #8a7c65);
  padding: 2px 10px 8px 10px;
}

/* --- Specialty button (root view) --- */
.medtopo-cat-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  margin: 2px 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text-dim, #5e5344);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.medtopo-cat-toggle:hover {
  background: color-mix(in srgb, var(--sienna, #a25a3a) 10%, transparent);
  color: var(--text, #2a241c);
  border-color: color-mix(in srgb, var(--sienna, #a25a3a) 20%, transparent);
}
.medtopo-cat-toggle.is-current-spec {
  background: color-mix(in srgb, var(--sienna, #a25a3a) 8%, transparent);
  color: var(--text, #2a241c);
}
.medtopo-cat-icon {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.medtopo-cat-label { flex: 1; min-width: 0; }
.medtopo-cat-chev {
  font-size: 1rem;
  color: var(--text-muted, #8a7c65);
  flex-shrink: 0;
}

/* --- Back button (specialty view) --- */
.medtopo-back {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  margin: 0 0 8px 0;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text-muted, #8a7c65);
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.medtopo-back:hover {
  background: color-mix(in srgb, var(--sienna, #a25a3a) 8%, transparent);
  color: var(--sienna-deep, #7a3e27);
}
.medtopo-back-arrow {
  font-size: 1rem;
  line-height: 1;
  transform: translateY(-1px);
}

/* --- Specialty header (specialty view) --- */
.medtopo-spec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 10px 10px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--text, #2a241c);
}
.medtopo-spec-icon { font-size: 1.2rem; flex-shrink: 0; }
.medtopo-spec-label { flex: 1; min-width: 0; }

/* --- Subgroup (middle level) within a specialty, e.g. Hyponatremia --- */
.medtopo-sub-group { margin: 2px 0; }
.medtopo-sub-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text-dim, #5e5344);
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.medtopo-sub-toggle:hover {
  background: color-mix(in srgb, var(--sienna, #a25a3a) 8%, transparent);
  color: var(--text, #2a241c);
}
.medtopo-sub-label { flex: 1; min-width: 0; }
.medtopo-sub-chev {
  font-size: 0.9rem;
  color: var(--text-muted, #8a7c65);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.medtopo-sub-group.open > .medtopo-sub-toggle .medtopo-sub-chev { transform: rotate(90deg); }
.medtopo-sub-pages {
  list-style: none;
  margin: 0;
  padding: 1px 0 4px 18px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}
.medtopo-sub-group.open > .medtopo-sub-pages { max-height: 500px; }
.medtopo-sub-pages li { margin: 0; }

/* --- Leaf page link (used under subgroups and as direct pages) --- */
.medtopo-page-link {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text-muted, #8a7c65);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.35;
  transition: background 0.15s, color 0.15s;
}
.medtopo-page-link:hover {
  color: var(--text, #2a241c);
  background: color-mix(in srgb, var(--sienna, #a25a3a) 8%, transparent);
}
.medtopo-page-link.is-current {
  color: var(--sienna-deep, #7a3e27);
  background: color-mix(in srgb, var(--sienna, #a25a3a) 14%, transparent);
  font-weight: 700;
}

/* Direct (non-grouped) page link — slightly more prominent than
   subgroup-nested links so its top-level status reads clearly */
.medtopo-direct-page { padding: 1px 0; }
.medtopo-direct-page .medtopo-page-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim, #5e5344);
}

/* Collapsed desktop sidebar — hide labels but keep the nav clickable */
.global-sidebar.collapsed .medtopo-nav-head,
.global-sidebar.collapsed .medtopo-back,
.global-sidebar.collapsed .medtopo-spec-head,
.global-sidebar.collapsed .medtopo-cat-label,
.global-sidebar.collapsed .medtopo-cat-chev,
.global-sidebar.collapsed .medtopo-sub-group,
.global-sidebar.collapsed .medtopo-direct-page {
  display: none !important;
}
.global-sidebar.collapsed .medtopo-cat-toggle {
  justify-content: center;
  padding: 10px 6px;
}
.global-sidebar.collapsed .medtopo-nav {
  border-bottom-color: transparent;
  margin-bottom: 6px;
  padding-bottom: 4px;
}

/* ==========================================================================
   RESPONSIVE — tablet & phone overrides.
   All changes live here so individual pages don't need per-file mobile CSS.
   !important is used sparingly, scoped to mobile only, to beat inline
   per-page rules that were written pre-responsive.
   ========================================================================== */

/* --------- Tablet (≤ 900px) — sidebar becomes a slide-in drawer --------- */
@media (max-width: 900px) {

  /* Header tightens up */
  .hdr-inner {
    padding: 10px 14px !important;
    gap: 10px !important;
  }
  .logo-text { font-size: 0.96rem; }
  .logo-sub  { font-size: 0.72rem; }
  .hdr-ver   { display: none; }
  .hdr-hamburger { display: inline-flex; }

  /* Layout becomes single-column; sidebar slides in from left. */
  .global-layout {
    display: block !important;
    max-width: 100% !important;
  }
  .global-sidebar {
    display: block !important;   /* beat any page's inline `display:none` so the drawer actually shows */
    position: fixed !important;
    top: 0 !important;
    left: -300px;
    width: 280px !important;
    max-width: 82vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    padding: 64px 18px 24px 18px !important;
    background: var(--surface) !important;
    border-right: 1px solid var(--border);
    box-shadow: none;
    z-index: 200;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }
  .global-sidebar.mobile-open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  /* Mobile hides the desktop collapse toggle — the drawer itself replaces it. */
  .global-sidebar .gs-toggle { display: none; }
  /* Collapsed-state rules don't apply on mobile — drawer is either open or hidden. */
  .global-sidebar.collapsed {
    width: 280px !important;
    padding: 64px 18px 24px 18px !important;
  }
  .global-sidebar.collapsed .gs-back,
  .global-sidebar.collapsed .gs-home-link,
  .global-sidebar.collapsed .gs-subs,
  .global-sidebar.collapsed .gs-divider,
  .global-sidebar.collapsed a.gs-section span,
  .global-sidebar.collapsed .gs-page-link span,
  .global-sidebar.collapsed .gs-page-link {
    display: revert !important;
    font-size: revert !important;
  }

  .global-main {
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
  }

  /* Page header tightens */
  .page-head { padding: 28px 16px 20px 16px !important; }
  .page-title { font-size: 2rem !important; line-height: 1.1; }
  .page-sub   { font-size: 0.95rem; }
  .wrap { padding: 0 16px !important; }

  /* Stage nav horizontal-scrolls cleanly */
  .journey-nav {
    margin-top: 14px;
    gap: 6px;
    padding: 0 2px 6px 2px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .journey-btn {
    padding: 8px 14px;
    font-size: 0.84rem;
    scroll-snap-align: start;
  }
  section.stage { padding: 32px 0 !important; }
  .section-head {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
  }
  .section-head h2 { font-size: 1.45rem !important; }

  /* Cards + grids — collapse to single column */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .card { padding: 16px !important; border-radius: 12px; }

  /* Tables — never break layout; wrap in horizontal scroll if author used
     the recommended <div class="table-wrap">…</div>, else force scroll. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 480px; }   /* encourages horizontal scroll */

  /* SVG diagrams — never overflow the screen width */
  svg { max-width: 100%; height: auto; }

  /* Callouts — slightly tighter */
  .callout { padding: 12px 14px; font-size: 0.88rem; }

  /* Footer */
  footer { padding: 20px 16px; font-size: 0.78rem; }
}

/* --------- Phone (≤ 560px) — tighter type scale and spacing --------- */
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .page-title { font-size: 1.7rem !important; }
  .page-sub   { font-size: 0.9rem; }
  .section-head h2 { font-size: 1.25rem !important; }
  h3 { font-size: 1.05rem; }
  h4 { font-size: 0.95rem; }
  .journey-btn { padding: 7px 12px; font-size: 0.8rem; }
  .card { padding: 14px !important; }
  .hdr-inner { padding: 8px 12px !important; }
  .logo-mark { width: 30px; height: 30px; }
  .logo-text { font-size: 0.9rem; }
  .logo-sub  { display: none; }     /* keep header skinny on phones */
  .page-head { padding: 20px 14px 16px 14px !important; }
  .wrap { padding: 0 14px !important; }
}

/* --------- Ensure main content pushes below sticky header on mobile --------- */
@media (max-width: 900px) {
  header.site-header + .global-layout,
  header.site-header ~ .global-layout { margin-top: 0; }
}

/* ============ RESPONSIVE TABLES ============
 * medtopo.js wraps every <table> in <div class="medtopo-tablescroll"> at load.
 * Wide tables (many have an intrinsic min-width to keep columns readable)
 * then scroll horizontally INSIDE their own box instead of bleeding out of
 * the card and getting clipped by the page's overflow-x:hidden. Narrow
 * tables simply don't scroll. Keeps phones free of sideways page-drift. */
.medtopo-tablescroll {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
/* Faint edge cue that there's more table to the right when it scrolls. */
.medtopo-tablescroll { scrollbar-width: thin; }

/* ============ MOBILE: LET GRID / FLEX CARDS SHRINK ============
 * Grid & flex items default to min-width:auto, so a card refuses to shrink
 * below its widest child — a wide table or figure then bleeds off-screen and
 * gets clipped by the page's overflow-x:hidden. Resetting to 0 on phones lets
 * the card fit the column and its inner .medtopo-tablescroll actually scroll. */
@media (max-width: 720px) {
  [class*="grid"]   > *,
  [class*="col"]    > *,
  [class*="flex"]   > *,
  [class*="split"]  > *,
  [class*="row"]    > *,
  [class*="cards"]  > *,
  [class*="two"]    > *,
  [class*="pair"]   > *,
  [class*="compare"] > *,
  [class*="columns"] > * { min-width: 0; }
}

/* ==========================================================================
   CANONICAL MENU (centralized 2026-08-20)
   Single source of truth for the brand header + sidebar. Pages no longer carry
   their own copies. Appended last so it wins over the older scattered rules by
   source order. Per-specialty colour comes from --accent (set by medtopo.js).
   ========================================================================== */

/* ---- Brand header ---- */
header.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244, 239, 227, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.hdr-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.logo {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--text);
  font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em;
}
.logo-mark {
  width: 36px; height: 36px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #3a2418));
  border-radius: 10px;
  display: grid; place-items: center;
  color: #f9f4e7; font-weight: 800; font-size: 1rem;
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 28%, transparent);
}
.logo-mark svg { width: 20px; height: 20px; }
.logo-sub { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

/* ---- Layout + sidebar shell ---- */
.global-layout {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: flex-start; gap: 0;
}
.global-sidebar {
  width: 240px; min-width: 240px; flex-shrink: 0;
  padding: 20px 12px 32px 20px;
  position: sticky; top: 62px;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  font-size: 0.88rem;
  background: rgba(251, 246, 234, 0.5);
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  z-index: 50;
  transition: width 0.22s ease, padding 0.22s ease;
}
.global-main { flex: 1; min-width: 0; overflow-x: hidden; }

/* ---- "All modules" home link at the top of the sidebar ---- */
.gs-home-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 14px; border-radius: 10px;
  text-decoration: none; color: var(--text-muted);
  font-size: 0.78rem; font-weight: 600; transition: all 0.2s;
}
.gs-home-link:hover { color: var(--text); background: var(--surface); }
.gs-divider { height: 1px; background: var(--border); margin: 10px 12px 14px; }

/* ---- Accordion sidebar: div.gs-section with expandable .gs-subs (in-page
   stage nav). Scoped to div.gs-section so anchor-style sidebars are untouched.
   Active state follows --accent. ---- */
div.gs-section { margin-bottom: 4px; }
.gs-page-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  text-decoration: none; color: var(--text-dim);
  font-size: 0.82rem; font-weight: 600; line-height: 1.3;
  border: 1px solid transparent; transition: all 0.2s;
}
.gs-page-link:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.gs-page-link.active {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong); font-weight: 800;
  box-shadow: 0 2px 8px rgba(60,40,20,0.08);
}
.gs-page-link .gs-icon { width: 16px; height: 16px; min-width: 16px; opacity: 0.5; }
.gs-page-link.active .gs-icon { opacity: 1; color: var(--accent); }
div.gs-section > .gs-subs {
  list-style: none; margin: 2px 0 6px 0; padding-left: 38px;
  max-height: 0; overflow: hidden; transition: max-height 0.3s ease;
}
div.gs-section.open > .gs-subs { max-height: 600px; }
div.gs-section > .gs-subs .gs-sub-link {
  display: block; padding: 5px 10px; border-radius: 8px;
  text-decoration: none; color: var(--text-muted);
  font-size: 0.75rem; font-weight: 500; line-height: 1.35;
  border: 1px solid transparent; cursor: pointer; transition: all 0.15s;
}
div.gs-section > .gs-subs .gs-sub-link:hover { background: var(--surface); color: var(--text-dim); border-color: var(--border); }
div.gs-section > .gs-subs .gs-sub-link.active {
  color: var(--accent); font-weight: 700;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-color: color-mix(in srgb, var(--accent) 18%, transparent);
}
