/* ============================================
   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;

  /* Animation tokens — 8px spacing grid */
  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

  /* 8-point spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --sp-7: 48px; --sp-8: 64px;
}

* { 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; overflow-x: clip; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--parchment);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
}

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: rgba(15, 36, 56, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  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: rgba(10, 26, 43, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    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: none !important; }
}

/* ============================================
   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 8px;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.15s ease, padding-left 0.15s ease;
  border-radius: var(--radius);
}
.topic-row:hover {
  background-color: var(--parchment-dim);
  padding-left: 12px;
}
.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: 6px; margin-bottom: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(15,36,56,.04); transition: box-shadow var(--transition-fast); }
.sl-section:hover { box-shadow: 0 2px 8px rgba(15,36,56,.08); }
.sl-section-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; cursor: pointer; background: #F7F4EE; border-bottom: 1px solid transparent; transition: background var(--transition-fast); user-select: none; min-height: 48px; }
.sl-section-head:hover { background: #EDE9E0; }
.sl-section-head:active { background: #E5E0D5; }
.sl-section-head.sl-open { border-bottom-color: #DDD8CE; background: #F0ECE2; }
.sl-section-head h2 { font-family: 'Crimson Pro', 'Source Serif 4', Georgia, serif; font-size: 1.15rem; font-weight: 600; color: #0F2438; margin: 0; line-height: 1.3; }
.sl-toggle { font-size: .6rem; color: #B8923D; transition: transform var(--transition-base); flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.sl-section-head.sl-open .sl-toggle { transform: rotate(90deg); }
/* Smooth accordion: use max-height transition */
.sl-section-body { display: block; max-height: 0; overflow: hidden; transition: max-height var(--transition-slow), padding var(--transition-fast); padding: 0 20px; border-top: 1px solid transparent; }
.sl-section-body.sl-open { max-height: 1800px; padding: 20px; border-top: 1px solid #DDD8CE; transition: max-height 0.6s var(--ease-out), padding var(--transition-fast); }

/* Section body typography — Kindle-grade reading comfort */
.sl-section-body h3 { font-family: 'Crimson Pro', 'Source Serif 4', Georgia, serif; font-size: 1.05rem; font-weight: 600; color: #0F2438; margin: 22px 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: .91rem; line-height: 1.78; color: #2a2f3a; margin: 0 0 14px; }
.sl-section-body ul, .sl-section-body ol { padding-left: 20px; margin: 0 0 14px; }
.sl-section-body li { font-size: .89rem; line-height: 1.72; color: #2a2f3a; margin-bottom: 6px; }
.sl-section-body li ul, .sl-section-body li ol { margin-top: 6px; margin-bottom: 4px; }
.sl-section-body strong { color: #0F2438; font-weight: 700; }

/* 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 accordion with smooth max-height animation */
.toc-group-links { display: flex; flex-direction: column; padding: 0; max-height: 0; overflow: hidden; transition: max-height var(--transition-base); }
.toc-group-links.sl-open { max-height: 600px; padding: 4px 0; transition: max-height 0.3s var(--ease-out); }
.toc-group-links a { font-size: .78rem; color: #5A6478; text-decoration: none; padding: 7px 18px 7px 28px; border-left: 3px solid transparent; transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast); line-height: 1.4; }
.toc-group-links a:hover { color: #0F2438; background: rgba(184,146,61,.07); border-left-color: rgba(184,146,61,.3); }
.toc-group-links a.sl-active { color: #0F2438; font-weight: 600; border-left-color: #B8923D; background: rgba(184,146,61,.08); }

/* 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; max-width: 740px; }

/* 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: 8px; width: 100%; max-width: 100%; }
  .sl-sidebar { width: 100%; max-width: 100%; position: static; max-height: 320px; margin-bottom: 0; }
  .sl-article { width: 100%; max-width: 100%; }
  .sl-hero { padding: 24px 20px; margin-bottom: 12px; }
  .sl-hero h1 { font-size: 1.6rem; }
  .sl-section-body { padding: 16px; }

  /* Hero visual height and stats reductions for Kindle density */
  .hero { padding: 36px 0 28px !important; }
  .hero h1 { font-size: 1.6rem !important; margin-bottom: 12px !important; }
  .hero p.lede { font-size: 0.9rem !important; line-height: 1.6 !important; margin-bottom: 18px !important; }
  .hero-stats { display: none !important; } /* hide stats to bring browse cards above fold */
}

/* ── 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 — mobile Kindle reading density */
  .sl-section-body { padding: 0 16px; max-width: 100%; }
  .sl-section-body.sl-open { padding: 16px; }
  .sl-section-body h3 { font-size: 0.98rem; margin: 18px 0 6px; }
  .sl-section-body p, .sl-section-body li { font-size: .875rem; line-height: 1.72; }

  /* 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 48px for interactive elements */
@media (max-width: 768px) {
  .sl-section-head { padding: 8px 14px; min-height: 48px; }
  .paper-tab { min-height: 48px; display: flex; align-items: center; justify-content: center; }
  nav.main-nav a { min-height: 48px; display: flex; align-items: center; }
  .topic-row { min-height: 54px; }
  input[type="search"], .search-input { font-size: 16px; min-height: 48px; } /* 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: 9998;
  border-top: 2px solid var(--gold);
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
  transform: translateY(calc(100% + 90px));
  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; }
}

/* ============================================
   PREMIUM MOBILE & DESTRUCTION REFINEMENTS
   ============================================ */

/* Stylized List Bulleting for Suture Line Content */
.sl-section-body ul {
  list-style: none !important;
  padding-left: 4px !important;
  margin: 0 0 14px 0 !important;
}
.sl-section-body ul > li {
  position: relative !important;
  padding-left: 18px !important;
  margin-bottom: 7px !important;
  font-size: 0.88rem !important;
  line-height: 1.65 !important;
}
.sl-section-body ul > li::before {
  content: "•" !important;
  position: absolute !important;
  left: 4px !important;
  color: var(--gold) !important;
  font-weight: 700 !important;
  font-size: 1.15rem !important;
  line-height: 1.25 !important;
  top: -1px !important;
}
.sl-section-body ul ul {
  padding-left: 16px !important;
  margin-top: 4px !important;
  margin-bottom: 4px !important;
}
.sl-section-body ul ul > li::before {
  content: "◦" !important;
  color: var(--gold-light) !important;
  font-size: 0.95rem !important;
  top: 0px !important;
}

/* Global scrollable container styling for inline content tables */
div[style*="overflow-x:auto"] {
  border: 1px solid var(--line, #ddd6c4) !important;
  border-radius: 6px !important;
  background: var(--paper, #fffdf8) !important;
  box-shadow: 0 1px 3px rgba(15,36,56,.04) !important;
  scrollbar-width: thin;
}
div[style*="overflow-x:auto"]::-webkit-scrollbar {
  height: 4px;
}
div[style*="overflow-x:auto"]::-webkit-scrollbar-thumb {
  background: var(--line-strong, #c7bea3);
  border-radius: 2px;
}

/* ============================================
   MOBILE APP PARADIGM OVERRIDES & REDESIGN
   ============================================ */

/* Mobile global layouts and active nav offsets */
@media (max-width: 820px) {
  .bottom-nav {
    display: flex !important;
  }
  .toc-fab {
    display: flex !important;
  }
  nav.main-nav {
    display: none !important;
  }
  body {
    padding-bottom: 64px !important;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .hero-search-trigger {
    display: block !important;
  }
}

/* ── Bottom Navigation Bar — Native App Style ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(10, 18, 28, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,0.07);
  z-index: 9999;
  justify-content: space-around;
  align-items: center;
  padding: 0;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.3);
  box-sizing: border-box;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 0.62rem;
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.01em;
  gap: 3px;
  flex: 1;
  height: 100%;
  padding: 0;
  position: relative;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
  flex-shrink: 0;
}
.bottom-nav-item:active { opacity: 0.7; }
.bottom-nav-item.active {
  color: var(--gold-light, #d4af5f);
}
.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-light, #d4af5f);
}

/* ── Focus Mode (Distraction-Free Reading) ── */
body.focus-mode-active {
  background: var(--paper, #fffdf8) !important;
}
body.focus-mode-active .site-header,
body.focus-mode-active .sl-sidebar,
body.focus-mode-active .site-footer,
body.focus-mode-active .sl-hero,
body.focus-mode-active .topic-sources-box,
body.focus-mode-active .site-footer-support,
body.focus-mode-active .section.alt {
  display: none !important;
}
body.focus-mode-active .sl-page-wrap {
  padding-top: 12px !important;
  padding-bottom: 80px !important;
}
/* Focus mode top indicator */
.focus-header {
  display: none;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--paper, #fffdf8);
  border-bottom: 1px solid var(--line, #ddd6c4);
  z-index: 1000;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-sizing: border-box;
  font-family: var(--font-body);
}
body.focus-mode-active .focus-header {
  display: flex !important;
}
.focus-header-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy-900, #0f2438);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 24ch;
}
.focus-exit-btn {
  background: none;
  border: 1px solid var(--line-strong, #c7bea3);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft, #4a4843);
  cursor: pointer;
}

/* Focus Mode toggle — first-class, full-width on mobile */
.focus-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: stretch;
  margin: 0 0 20px 0;
}
.focus-toggle-btn {
  background: var(--paper, #fffdf8);
  border: 1.5px solid var(--line-strong, #c7bea3);
  border-radius: 6px;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy-900, #0f2438);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  box-shadow: 0 1px 4px rgba(15,36,56,.06);
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.focus-toggle-btn:hover,
.focus-toggle-btn:focus-visible {
  border-color: var(--gold, #b8923d);
  background: rgba(184,146,61,.04);
  box-shadow: 0 0 0 3px rgba(184,146,61,.12);
}
.focus-toggle-btn:active { transform: scale(0.98); }
.focus-toggle-btn svg { width: 18px; height: 18px; color: var(--gold); stroke-width: 1.75; }

/* ── Scroll Depth Progress Indicator ── */
.scroll-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--gold, #b8923d);
  z-index: 10001;
  width: 0%;
  transition: width 0.1s ease-out;
}
body.focus-mode-active .scroll-progress-bar {
  top: 48px; /* place below focus-header */
}

/* ── Floating TOC FAB — refined, integrated ── */
.toc-fab {
  display: none;
  position: fixed;
  bottom: 92px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--navy-900, #0f2438);
  color: var(--gold-light, #d4af5f);
  box-shadow: 0 2px 8px rgba(0,0,0,0.22), 0 0 0 1px rgba(184,146,61,0.3);
  z-index: 999;
  border: 1px solid rgba(184,146,61,0.35);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.toc-fab svg { width: 20px; height: 20px; stroke-width: 1.75; }
.toc-fab:active { transform: scale(0.88); }
.toc-fab:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 0 1px rgba(184,146,61,0.5); }
body.focus-mode-active .toc-fab { bottom: 32px; }

/* TOC Drawer Sheet */
.toc-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 290px;
  background: var(--paper, #fffdf8);
  border-left: 1px solid var(--line, #ddd6c4);
  box-shadow: -6px 0 24px rgba(0,0,0,0.15);
  z-index: 10002;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.toc-drawer.open {
  transform: translateX(0);
}
.toc-drawer-header {
  background: var(--navy-900, #0f2438);
  color: var(--gold-light, #d4af5f);
  padding: 14px 18px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toc-drawer-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}
.toc-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.toc-drawer-body .toc-group-label {
  background: rgba(239,235,225,0.8);
  font-size: 0.65rem;
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 4px 16px;
}
.toc-drawer-body .toc-group-links a {
  padding: 7px 20px;
  font-size: 0.76rem;
  min-height: 34px;
  display: flex;
  align-items: center;
}

/* Overlay Backdrop behind TOC Drawer */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,18,30,0.55);
  backdrop-filter: blur(2px);
  z-index: 10001;
}
.drawer-backdrop.visible {
  display: block;
}

/* Sticky Bottom Focus Nav Controllers */
.focus-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--paper, #fffdf8);
  border-top: 1px solid var(--line, #ddd6c4);
  z-index: 1000;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-sizing: border-box;
}
body.focus-mode-active .focus-bottom-nav {
  display: flex !important;
}
.focus-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy-900, #0f2438);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--line-strong, #c7bea3);
  border-radius: 4px;
  background: var(--paper, #fffdf8);
}
.focus-nav-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ============================================
   HOMEPAGE REFINEMENTS
   ============================================ */

/* Creator strip — visible below hero on mobile */
.creator-strip {
  display: none;
  background: var(--navy-900);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 14px 16px;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
@media (max-width: 820px) {
  .creator-strip { display: flex; }
}
.creator-strip-text {
  font-size: 0.8rem;
  color: rgba(247,244,238,0.65);
  line-height: 1.5;
}
.creator-strip-text strong { color: var(--gold-light); }
.creator-strip-link {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold-light);
  border: 1px solid rgba(184,146,61,0.4);
  padding: 6px 12px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background var(--transition-fast);
}
.creator-strip-link:hover { background: rgba(184,146,61,0.1); }

/* Continue Reading widget */
.continue-reading-widget {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  text-decoration: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 1px 4px rgba(15,36,56,.05);
}
.continue-reading-widget:hover { border-color: var(--gold); box-shadow: 0 2px 10px rgba(15,36,56,.1); }
.continue-reading-widget:active { transform: scale(0.99); }
.crw-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background: rgba(184,146,61,0.12);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
}
.crw-icon svg { width: 18px; height: 18px; stroke-width: 1.75; }
.crw-body { flex: 1; min-width: 0; }
.crw-label { font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); font-weight: 700; margin-bottom: 2px; }
.crw-title { font-size: 0.88rem; font-weight: 600; color: var(--navy-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crw-meta { font-size: 0.72rem; color: var(--ink-faint); margin-top: 1px; }
.crw-arrow { color: var(--gold); opacity: 0.7; flex-shrink: 0; }
.crw-arrow svg { width: 16px; height: 16px; stroke-width: 2; }

/* Hero search trigger — unified desktop/mobile pill search */
.hero-search-trigger {
  display: block;
  margin-bottom: 24px;
}
.hero-search-trigger a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 24px !important;
  padding: 13px 18px !important;
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid rgba(255,255,255,0.15) !important;
  color: rgba(247,244,238,0.55) !important;
  text-decoration: none;
  width: 100%;
  max-width: 540px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.hero-search-trigger a:hover {
  background: rgba(255,255,255,0.09) !important;
  border-color: rgba(255,255,255,0.25) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.hero-search-trigger a:active {
  background: rgba(255,255,255,0.13) !important;
  transform: scale(0.99);
}

/* Home cards — denser, premium press feedback */
.home-card {
  transition: box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast) !important;
}
.home-card:active { transform: scale(0.98) !important; }

/* Bookmark button on topic rows */
.topic-row-bookmark {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--ink-faint);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
  min-width: 36px;
  min-height: 36px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.topic-row-bookmark:hover { color: var(--gold); background: rgba(184,146,61,.08); }
.topic-row-bookmark.bookmarked { color: var(--gold); }
.topic-row-bookmark svg { width: 16px; height: 16px; stroke-width: 1.75; }

/* Reading time badge on topic rows */
.topic-read-time {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.topic-read-time svg { width: 11px; height: 11px; stroke-width: 1.75; flex-shrink: 0; }

/* High-yield tag */
.hy-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(196,80,46,0.1);
  color: var(--flag);
  border: 1px solid rgba(196,80,46,0.25);
  border-radius: 3px;
  padding: 2px 6px;
  flex-shrink: 0;
}

/* Focus Mode exit button polish */
.focus-exit-btn {
  background: none;
  border: 1px solid rgba(15,36,56,0.2);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.focus-exit-btn:active { background: rgba(15,36,56,.06); }

/* Hero bookmark button on topic page hero */
.hero-bookmark-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--parchment-dim);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  min-height: 28px;
  -webkit-tap-highlight-color: transparent;
}
.hero-bookmark-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--gold-light);
}
.hero-bookmark-btn.bookmarked {
  background: rgba(184, 146, 61, 0.16);
  border-color: var(--gold-light);
  color: var(--gold-light);
}
.hero-bookmark-btn svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.2;
}

/* Bookmarks list widget on topics.html */
.bookmarks-widget .topic-row {
  border-left-color: var(--gold) !important;
}

/* Accordion scroll jump highlight */
.sl-section.sl-highlight {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(184, 146, 61, 0.25) !important;
  transition: all var(--transition-fast) ease;
}

/* Section bookmark buttons inside topic details heads */
.section-bookmark-btn {
  background: none;
  border: none;
  color: var(--sl-muted, #5A6478);
  padding: 6px;
  margin-left: auto;
  margin-right: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
  opacity: 0.65;
}
.section-bookmark-btn:hover {
  color: var(--gold, #B8923D);
  opacity: 1;
}
.section-bookmark-btn.bookmarked {
  color: var(--gold, #B8923D);
  opacity: 1;
}
.section-bookmark-btn.bookmarked svg {
  fill: var(--gold, #B8923D);
}
.section-bookmark-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}
/* PWA Banner mobile stack positioning overrides to prevent overlapping bottom nav or FAB */
@media (max-width: 820px) {
  .pwa-banner {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    padding-bottom: 14px !important;
  }
  body.pwa-banner-visible .toc-fab {
    bottom: 168px !important;
  }
  body.focus-mode-active.pwa-banner-visible .toc-fab {
    bottom: 108px !important;
  }
}
