/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  --navy-950: #0a1a2b;
  --navy-900: #0f2438;
  --navy-800: #163652;
  --navy-700: #1f4866;
  --parchment: #f7f4ee;
  --parchment-dim: #efebe1;
  --paper: #fffdf8;
  --ink: #1a1a1a;
  --ink-soft: #4a4843;
  --ink-faint: #8a8780;
  --gold: #b8923d;
  --gold-light: #d4af5f;
  --flag: #c4502e;
  --flag-soft: #f3e2da;
  --line: #ddd6c4;
  --line-strong: #c7bea3;

  --font-display: 'Source Serif 4', 'Georgia', serif;
  --font-body: 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', monospace;

  --radius: 3px;
  --max-width: 1180px;
}

* { box-sizing: border-box; }

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--parchment);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

::selection { background: var(--gold-light); color: var(--navy-950); }

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

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 28px;
}

/* ============================================
   ECG PULSE DIVIDER — signature element
   ============================================ */
.pulse-divider {
  width: 100%;
  height: 28px;
  margin: 0 auto;
  opacity: 0.55;
}
.pulse-divider svg { width: 100%; height: 100%; display: block; }
.pulse-divider path {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pulse-divider.flag path { stroke: var(--flag); }

/* ============================================
   HEADER / NAV
   ============================================ */
.site-header {
  background: var(--navy-900);
  color: var(--parchment);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--navy-700);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--paper);
  text-decoration: none;
  line-height: 1;
}
.brand .brand-mark {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gold-light);
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand .brand-sub {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--gold-light);
  font-weight: 500;
  opacity: 0.8;
}
/* Nav links */
nav.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
nav.main-nav a {
  font-size: 0.84rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius);
  color: var(--parchment-dim);
  transition: color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
nav.main-nav a:hover { color: var(--paper); background: var(--navy-800); }
nav.main-nav a.active {
  color: var(--gold-light);
  position: relative;
}
nav.main-nav a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--gold);
  border-radius: 1px;
}

/* Hamburger toggle */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--paper);
  font-size: 1.1rem;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.nav-toggle:hover { background: var(--navy-800); border-color: rgba(255,255,255,.3); }

/* Mobile nav */
@media (max-width: 820px) {
  .site-header .wrap { height: 56px; }

  .brand-sub { display: none; }

  nav.main-nav {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--navy-950);
    flex-direction: column;
    align-items: stretch;
    padding: 6px 0 12px;
    border-bottom: 1px solid var(--navy-700);
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
    z-index: 99;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }
  nav.main-nav.open { display: flex; }
  nav.main-nav a {
    padding: 13px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    border-radius: 0;
    font-size: .9rem;
    font-weight: 500;
    color: var(--parchment-dim);
  }
  nav.main-nav a:last-child { border-bottom: none; }
  nav.main-nav a:hover { background: var(--navy-800); color: var(--paper); }
  nav.main-nav a.active { color: var(--gold-light); background: rgba(184,146,61,.08); }
  nav.main-nav a.active::after { display: none; }
  .nav-toggle { display: flex; }
}

/* ============================================
   HERO
   ============================================ */
.hero {
  background: var(--navy-900);
  color: var(--parchment);
  padding: 64px 0 56px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(transparent, transparent 23px, rgba(184,146,61,0.05) 23px, rgba(184,146,61,0.05) 24px);
  pointer-events: none;
}
.hero .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero .eyebrow::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--flag);
  box-shadow: 0 0 0 3px rgba(196,80,46,0.25);
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.6vw, 3.4rem);
  line-height: 1.12;
  font-weight: 600;
  margin: 0 0 18px;
  max-width: 16ch;
  color: var(--paper);
}
.hero h1 em {
  font-style: normal;
  color: var(--gold-light);
}
.hero p.lede {
  font-size: 1.08rem;
  color: var(--parchment-dim);
  max-width: 56ch;
  margin: 0 0 30px;
}
.hero-stats {
  display: flex;
  gap: 36px;
  flex-wrap: wrap;
}
.hero-stat .num {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--gold-light);
  line-height: 1;
}
.hero-stat .label {
  font-size: 0.74rem;
  color: var(--ink-faint);
  color: #a8a59a;
  margin-top: 4px;
}

/* ============================================
   SECTION HEADERS
   ============================================ */
.section { padding: 56px 0; }
.section.alt { background: var(--parchment-dim); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.section-head .tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0;
  color: var(--navy-900);
}
.section-head .desc {
  font-size: 0.92rem;
  color: var(--ink-soft);
  max-width: 42ch;
}

/* ============================================
   CHART-CARD — the case-file motif
   ============================================ */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}
.chart-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.chart-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15,36,56,0.08);
}
.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--navy-900);
  color: var(--parchment-dim);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chart-card-header .yr { color: var(--gold-light); font-weight: 600; }
.chart-card-body { padding: 16px 14px 14px; }
.chart-card-body h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 8px;
  color: var(--navy-900);
  font-weight: 600;
  line-height: 1.3;
}
.chart-card-body p {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.chart-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.dl-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy-800);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dl-link:hover { color: var(--gold); }
.flag-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--flag-soft);
  color: var(--flag);
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}

/* ============================================
   TOPIC LIST (ward-round checklist motif)
   ============================================ */
.topic-list {
  border-top: 1px solid var(--line);
}
.topic-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  transition: padding-left 0.15s ease;
}
.topic-row:hover { padding-left: 6px; }
.topic-row .check {
  width: 18px; height: 18px;
  border: 1.5px solid var(--line-strong);
  border-radius: 3px;
  flex-shrink: 0;
}
.topic-row .check.must { border-color: var(--flag); background: var(--flag-soft); }
.topic-row-main { flex: 1; min-width: 0; }
.topic-row-main a {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--navy-900);
}
.topic-row-main a:hover { color: var(--gold); }
.topic-row-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
  margin-top: 2px;
}
.topic-row-action {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--navy-700);
  white-space: nowrap;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--gold); color: var(--navy-950); }
.btn-primary:hover { background: var(--gold-light); }
.btn-outline { border-color: var(--parchment-dim); color: var(--paper); }
.btn-outline:hover { background: rgba(247,244,238,0.08); }
.btn-ghost { color: var(--navy-800); border-color: var(--line-strong); background: var(--paper); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  background: var(--navy-950);
  color: #a8a59a;
  padding: 44px 0 28px;
  font-size: 0.85rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
.footer-grid h4 {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin: 0 0 14px;
}
.footer-grid p { margin: 0 0 10px; line-height: 1.6; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 9px; }
.footer-grid a:hover { color: var(--paper); }
.footer-bottom {
  border-top: 1px solid var(--navy-800);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.76rem;
  color: #6e6c64;
}
.footer-bottom a { color: #8e8b80; }
.footer-bottom a:hover { color: var(--gold-light); }
.footer-bottom .ig-link { display: inline-flex; align-items: center; gap: 6px; }
.footer-bottom .ig-link svg { flex-shrink: 0; }

@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 24px; }
}

/* ============================================
   DISCLAIMER STRIP
   ============================================ */
.disclaimer-strip {
  background: var(--flag-soft);
  border-top: 1px solid #e8c9bc;
  border-bottom: 1px solid #e8c9bc;
  padding: 10px 0;
}
.disclaimer-strip .wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: #8a3e26;
}

/* ============================================
   TOPIC NOTE PAGE
   ============================================ */
.note-shell { display: grid; grid-template-columns: 230px 1fr; gap: 40px; align-items: start; }
.note-toc {
  position: sticky;
  top: 84px;
  border-left: 2px solid var(--line);
  padding-left: 16px;
  font-size: 0.82rem;
}
.note-toc .toc-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.note-toc a {
  display: block;
  padding: 5px 0;
  color: var(--ink-soft);
  font-weight: 500;
  border-left: 2px solid transparent;
  margin-left: -18px;
  padding-left: 16px;
}
.note-toc a:hover { color: var(--navy-900); }
.note-toc a.active { color: var(--gold); border-left-color: var(--gold); font-weight: 600; }

.note-body { max-width: 74ch; }
.note-body h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--navy-900);
  margin: 44px 0 16px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 80px;
}
.note-body h2:first-child { border-top: none; margin-top: 0; }
.note-body h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-800);
  margin: 24px 0 10px;
}
.note-body p { color: var(--ink); font-size: 0.95rem; margin: 0 0 14px; }
.note-body ul, .note-body ol { padding-left: 22px; margin: 0 0 16px; }
.note-body li { margin-bottom: 7px; font-size: 0.95rem; }
.note-body li ul { margin-top: 7px; margin-bottom: 0; }
.note-body strong { color: var(--navy-900); font-weight: 700; }

.note-table-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--line); border-radius: var(--radius); }
.note-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.note-table th {
  background: var(--navy-900);
  color: var(--parchment-dim);
  text-align: left;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}
.note-table td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.note-table tr:nth-child(even) td { background: var(--parchment-dim); }

.callout {
  border-left: 3px solid var(--gold);
  background: #faf6ec;
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 0 0 18px;
  font-size: 0.9rem;
}
.callout .callout-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}
.callout.exam-tip { border-left-color: var(--navy-700); background: #eef3f7; }
.callout.exam-tip .callout-label { color: var(--navy-700); }
.callout.mnemonic { border-left-color: var(--flag); background: var(--flag-soft); }
.callout.mnemonic .callout-label { color: var(--flag); }

.note-meta-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}
.note-meta-bar .pill {
  background: var(--navy-900);
  color: var(--gold-light);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

@media (max-width: 880px) {
  .note-shell { grid-template-columns: 1fr; }
  .note-toc { position: static; border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 14px; }
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-soft);
}
.empty-state h3 {
  font-family: var(--font-display);
  color: var(--navy-900);
  margin: 0 0 8px;
}
.empty-state p { font-size: 0.88rem; margin: 0; }
.topic-figure {
  margin: 20px 0 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.topic-figure img {
  width: 100%;
  display: block;
}
.topic-figure figcaption {
  padding: 8px 14px;
  background: var(--parchment-dim);
  font-size: 0.75rem;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  font-style: italic;
}
.toc-group {
  margin-bottom: 14px;
}
.toc-group-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gold);
  padding: 6px 0 4px 12px;
  border-left: 2px solid var(--gold);
  margin-bottom: 2px;
}
.note-toc .toc-group a {
  padding-left: 20px;
}
.topic-figure {
  margin: 20px 0 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.topic-figure img {
  width: 100%;
  display: block;
}
.topic-figure figcaption {
  padding: 8px 14px;
  background: var(--parchment-dim);
  font-size: 0.75rem;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  font-style: italic;
}
.note-body h2 { user-select: none; }
.note-body h2 .section-arrow {
  float: right;
  font-size: 0.85em;
  color: var(--gold);
  transition: transform 0.2s;
}
/* ============================================
   SL TOPIC PAGE SYSTEM (appendix-style pages)
   ============================================ */

/* Collapsible section wrapper */
.sl-section { background: #fff; border: 1px solid #DDD8CE; border-radius: 8px; margin-bottom: 16px; overflow: hidden; box-shadow: 0 1px 4px rgba(15,36,56,.06); }
.sl-section-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; cursor: pointer; background: #F7F4EE; border-bottom: 1px solid transparent; transition: background .15s; user-select: none; }
.sl-section-head:hover { background: #EDE9E0; }
.sl-section-head.sl-open { border-bottom-color: #DDD8CE; }
.sl-section-head h2 { font-family: 'Crimson Pro', 'Source Serif 4', Georgia, serif; font-size: 1.22rem; font-weight: 600; color: #0F2438; margin: 0; line-height: 1.3; }
.sl-toggle { font-size: .65rem; color: #B8923D; transition: transform .2s; flex-shrink: 0; }
.sl-section-head.sl-open .sl-toggle { transform: rotate(90deg); }
.sl-section-body { display: none; padding: 24px 28px; }
.sl-section-body.sl-open { display: block; }

/* Section body typography */
.sl-section-body h3 { font-family: 'Crimson Pro', 'Source Serif 4', Georgia, serif; font-size: 1.08rem; font-weight: 600; color: #0F2438; margin: 24px 0 8px; padding-bottom: 4px; border-bottom: 1px solid #DDD8CE; }
.sl-section-body h3:first-child { margin-top: 0; }
.sl-section-body p { font-size: .9rem; line-height: 1.72; color: #2C3342; margin: 0 0 12px; }
.sl-section-body ul, .sl-section-body ol { padding-left: 20px; margin: 0 0 12px; }
.sl-section-body li { font-size: .88rem; line-height: 1.65; color: #2C3342; margin-bottom: 4px; }
.sl-section-body li ul, .sl-section-body li ol { margin-top: 4px; margin-bottom: 4px; }

/* Callout overrides for sl-section context */
.sl-section-body .callout { border-radius: 6px; padding: 14px 18px; margin: 16px 0; font-size: .86rem; line-height: 1.65; }
.sl-section-body .callout .callout-label { font-family: 'Inter', sans-serif; font-size: .65rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; display: block; }
.sl-section-body .callout.exam-tip { background: #FFF3CD; border-left: 4px solid #B8923D; color: #7B4F12; }
.sl-section-body .callout.exam-tip .callout-label { color: #B8923D; }
.sl-section-body .callout.key-point { background: #E8F0FE; border-left: 4px solid #1A3A6B; color: #1A3A6B; }
.sl-section-body .callout.key-point .callout-label { color: #1A3A6B; }
.sl-section-body .callout.success-box { background: #D8F3DC; border-left: 4px solid #2D6A4F; color: #2D6A4F; }
.sl-section-body .callout.success-box .callout-label { color: #2D6A4F; }
.sl-section-body .callout.danger-box { background: #FCE4E4; border-left: 4px solid #C0392B; color: #7B1D1D; }
.sl-section-body .callout.danger-box .callout-label { color: #C0392B; }

/* Table overrides for sl-section context */
.sl-section-body .note-table { font-size: .82rem; line-height: 1.5; }
.sl-section-body .note-table th { background: #0F2438; color: #D4AC5A; font-weight: 600; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; padding: 9px 12px; white-space: normal; }
.sl-section-body .note-table td { padding: 8px 12px; border-bottom: 1px solid #DDD8CE; border-top: none; color: #2C3342; vertical-align: top; }
.sl-section-body .note-table tr:nth-child(even) td { background: #FAFAF7; }
.sl-section-body .note-table tr:last-child td { border-bottom: none; }

/* Pathway block */
.sl-pathway { background: #F3F5FA; border: 1px solid #C8D0E0; border-radius: 8px; padding: 16px 20px; margin: 14px 0; font-size: .84rem; line-height: 1.9; color: #1A1A2E; }
.sl-pathway strong { color: #0F2438; }

/* Topic figure — override for sl pages */
.sl-section-body .topic-figure { margin: 20px 0; text-align: center; border: none; overflow: visible; }
.sl-section-body .topic-figure img { width: auto; max-width: 100%; height: auto; max-height: 340px; border-radius: 6px; border: 1px solid #DDD8CE; cursor: zoom-in; display: inline-block; transition: box-shadow .2s, transform .2s; object-fit: contain; }
.sl-section-body .topic-figure img:hover { box-shadow: 0 4px 20px rgba(15,36,56,.2); transform: scale(1.01); }
.sl-section-body .topic-figure figcaption { font-size: .75rem; color: #5A6478; margin-top: 6px; font-style: italic; padding: 0; background: none; border: none; }

/* Sidebar TOC for sl pages */
.sl-sidebar { width: 270px; flex-shrink: 0; position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow-y: auto; background: #fff; border: 1px solid #DDD8CE; border-radius: 8px; box-shadow: 0 2px 12px rgba(15,36,56,.10); padding: 0 0 16px; scrollbar-width: thin; }
.sl-sidebar::-webkit-scrollbar { width: 4px; }
.sl-sidebar::-webkit-scrollbar-thumb { background: #DDD8CE; border-radius: 2px; }
.sl-sidebar-head { background: #0F2438; color: #B8923D; font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 12px 16px; border-radius: 8px 8px 0 0; }
.toc-group { border-bottom: 1px solid #DDD8CE; }
.toc-group:last-child { border-bottom: none; }
.toc-group-label { display: flex; align-items: center; gap: 6px; padding: 9px 16px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #0F2438; cursor: pointer; user-select: none; background: #F3F1EB; }
.toc-group-label:hover { background: #EAE7DF; }
.toc-group-label .sl-arrow { font-size: .6rem; transition: transform .2s; color: #B8923D; }
.toc-group-label.sl-open .sl-arrow { transform: rotate(90deg); }
.toc-group-links { display: none; flex-direction: column; padding: 4px 0; }
.toc-group-links.sl-open { display: flex; }
.toc-group-links a { font-size: .78rem; color: #5A6478; text-decoration: none; padding: 5px 20px 5px 28px; border-left: 3px solid transparent; transition: color .15s, border-color .15s, background .15s; line-height: 1.4; }
.toc-group-links a:hover { color: #0F2438; background: #E8F0FE; }
.toc-group-links a.sl-active { color: #0F2438; font-weight: 600; border-left-color: #B8923D; background: #EEF2FB; }

/* Hero */
.sl-hero { background: linear-gradient(135deg, #0F2438 0%, #1B3A5C 100%); border-radius: 8px; padding: 36px 40px; margin-bottom: 28px; position: relative; overflow: hidden; }
.sl-hero::before { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='60' viewBox='0 0 400 60'%3E%3Cpolyline points='0,30 30,30 45,10 60,50 75,10 90,50 105,30 140,30 155,15 170,45 185,30 400,30' fill='none' stroke='%23B8923D' stroke-width='1.5' stroke-opacity='0.25'/%3E%3C/svg%3E") right center / auto 60px no-repeat; pointer-events: none; }
.sl-hero-tag { font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #B8923D; margin-bottom: 8px; }
.sl-hero h1 { font-family: 'Crimson Pro', 'Source Serif 4', Georgia, serif; font-size: 2.1rem; font-weight: 600; color: #fff; margin: 0 0 10px; line-height: 1.2; }
.sl-hero-sub { font-size: .88rem; color: rgba(247,244,238,.7); line-height: 1.6; max-width: 560px; }
.sl-hero-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 18px; }
.sl-hero-badge { font-size: .72rem; font-weight: 600; background: rgba(184,146,61,.18); color: #D4AC5A; border: 1px solid rgba(184,146,61,.35); border-radius: 20px; padding: 4px 12px; }

/* Page wrap */
.sl-page-wrap { display: flex; align-items: flex-start; max-width: 1200px; margin: 0 auto; padding: 32px 20px 80px; gap: 32px; }
.sl-article { flex: 1; min-width: 0; }

/* Lightbox */
.sl-lightbox { display: none; position: fixed; inset: 0; background: rgba(10,18,30,.88); z-index: 9999; align-items: center; justify-content: center; padding: 24px; }
.sl-lightbox.sl-open { display: flex; }
.sl-lightbox img { max-width: min(90vw, 900px); max-height: 85vh; border-radius: 8px; box-shadow: 0 8px 48px rgba(0,0,0,.6); }
.sl-lightbox-close { position: absolute; top: 18px; right: 24px; font-size: 2rem; color: #fff; cursor: pointer; line-height: 1; background: none; border: none; opacity: .8; }
.sl-lightbox-close:hover { opacity: 1; }

/* Responsive */
@media (max-width: 768px) {
  .sl-page-wrap { flex-direction: column; padding: 16px 12px 60px; gap: 16px; }
  .sl-sidebar { width: 100%; position: static; max-height: 320px; }
  .sl-hero { padding: 24px 20px; }
  .sl-hero h1 { font-size: 1.6rem; }
  .sl-section-body { padding: 16px; }
}

/* ── sl-steps (numbered operative steps) ── */
.sl-steps { counter-reset: sl-step; list-style: none; padding: 0; margin: 0 0 16px; }
.sl-steps > li {
  counter-increment: sl-step;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  margin-bottom: 16px;
  align-items: start;
}
.sl-steps > li::before {
  content: counter(sl-step);
  width: 26px; height: 26px;
  background: #0F2438;
  color: #B8923D;
  border-radius: 50%;
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  flex-shrink: 0;
}
.sl-steps > li .sl-step-label {
  display: block;
  font-weight: 700;
  font-size: .88rem;
  color: #0F2438;
  margin-bottom: 3px;
}
.sl-steps > li .sl-step-body {
  font-size: .86rem;
  line-height: 1.65;
  color: #2C3342;
}

/* ── Figure caption credit links ── */
.topic-figure figcaption a,
.sl-section-body .topic-figure figcaption a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.8;
}
.topic-figure figcaption a:hover,
.sl-section-body .topic-figure figcaption a:hover {
  opacity: 1;
}

/* ── sl-steps FIX (overrides previous definition) ── */
.sl-steps { counter-reset: sl-step; list-style: none; padding: 0; margin: 0 0 16px; }
.sl-steps > li { counter-increment: sl-step; display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.sl-steps > li::before { content: counter(sl-step); flex-shrink: 0; width: 26px; height: 26px; background: #0F2438; color: #B8923D; border-radius: 50%; font-size: .72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.sl-steps > li .sl-step-content { flex: 1; min-width: 0; }
.sl-steps > li .sl-step-label { display: block; font-weight: 700; font-size: .88rem; color: #0F2438; margin-bottom: 3px; }
.sl-steps > li .sl-step-body { display: block; font-size: .86rem; line-height: 1.65; color: #2C3342; }

/* ============================================
   MOBILE OPTIMISATION — comprehensive pass
   ============================================ */

/* Base font scaling for small screens */
@media (max-width: 480px) {
  body { font-size: 15px; line-height: 1.65; }
  .wrap { padding: 0 16px; }

  /* Hero */
  .hero { padding: 36px 0 32px; }
  .hero h1 { font-size: clamp(1.7rem, 7vw, 2.2rem); line-height: 1.18; margin-bottom: 14px; }
  .hero p.lede { font-size: .95rem; }
  .hero-stats { gap: 20px; }
  .hero-stat .num { font-size: 1.3rem; }

  /* Section */
  .section { padding: 36px 0; }
  .section-head h2 { font-size: 1.4rem; }

  /* Nav */
  .site-header .wrap { height: 56px; }
  .brand { font-size: 1.1rem; }
  .brand-sub { display: none; } /* hide tagline on very small screens */

  /* Footer */
  .footer-bottom { flex-direction: column; gap: 6px; font-size: .72rem; }
}

/* Tables — horizontal scroll on mobile */
@media (max-width: 768px) {
  /* All tables get scroll wrapper behaviour */
  .note-table, .top50-table { font-size: .78rem; }
  .note-table th, .top50-table th { font-size: .66rem; padding: 8px 10px; }
  .note-table td, .top50-table td { padding: 7px 10px; }

  /* Overflow scroll wrapper — applied to parent div */
  div[style*="overflow-x:auto"],
  div[style*="overflow-x: auto"] { -webkit-overflow-scrolling: touch; }

  /* sl-section body */
  .sl-section-body { padding: 14px 14px; }
  .sl-section-body h3 { font-size: 1rem; }
  .sl-section-body p, .sl-section-body li { font-size: .85rem; line-height: 1.68; }

  /* sl-steps */
  .sl-steps > li { gap: 10px; margin-bottom: 14px; }
  .sl-steps > li::before { width: 22px; height: 22px; font-size: .66rem; }
  .sl-step-label { font-size: .84rem; }
  .sl-step-body { font-size: .82rem; }

  /* Callouts */
  .callout { padding: 12px 14px; font-size: .82rem; }

  /* Sidebar TOC on mobile */
  .sl-sidebar { max-height: 400px; }
  .toc-group-links a { font-size: .76rem; padding: 6px 16px 6px 24px; }

  /* Hero badge row wrap */
  .sl-hero-meta { gap: 8px; }
  .sl-hero-badge { font-size: .68rem; }
  .sl-hero h1 { font-size: 1.5rem; }
  .sl-hero { padding: 24px 16px; }

  /* FAQ grid on ms-papers */
  .faq-grid { grid-template-columns: 1fr; }
  .faq-card { padding: 12px 14px; }
  .faq-card-topic { font-size: .85rem; }
  .faq-card-meta { font-size: .72rem; }

  /* Paper tabs */
  .paper-tabs { gap: 4px; }
  .paper-tab { padding: 8px 10px; font-size: .74rem; }

  /* Topic list on topics.html */
  .topic-row { padding: 12px; gap: 8px; }
  .topic-row-title { font-size: .86rem; }
  .topic-pill { font-size: .66rem; }
  .part-title { font-size: .8rem; }

  /* Detail section lists on ms-papers */
  .detail-list li { font-size: .82rem; line-height: 1.55; }
  .detail-section-head { font-size: .95rem; }
}

/* Tap target sizes — minimum 44px for interactive elements */
@media (max-width: 768px) {
  .sl-section-head { padding: 14px 16px; min-height: 52px; }
  .paper-tab { min-height: 44px; }
  nav.main-nav a { min-height: 44px; display: flex; align-items: center; }
  .topic-row { min-height: 60px; }
  input[type="search"], .search-input { font-size: 16px; } /* prevents iOS zoom on focus */
}

/* ============================================
   PWA INSTALL BANNER
   ============================================ */
.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--navy-900);
  color: var(--parchment);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 9000;
  border-top: 2px solid var(--gold);
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.pwa-banner.visible { transform: translateY(0); }
.pwa-banner-icon {
  width: 42px;
  height: 42px;
  background: var(--gold);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 700;
  color: var(--navy-900);
}
.pwa-banner-text { flex: 1; min-width: 0; }
.pwa-banner-title { font-size: .88rem; font-weight: 700; color: var(--paper); }
.pwa-banner-sub { font-size: .74rem; color: var(--gold-light); margin-top: 2px; }
.pwa-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pwa-btn-install {
  background: var(--gold);
  color: var(--navy-900);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
}
.pwa-btn-install:hover { background: var(--gold-light); }
.pwa-btn-dismiss {
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  color: var(--parchment-dim);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.pwa-btn-dismiss:hover { border-color: rgba(255,255,255,.4); }

/* Hide PWA banner on desktop */
@media (min-width: 769px) {
  .pwa-banner { display: none !important; }
}
