/* ============================================================================
   Tax Code Website — Main Stylesheet
   All design tokens live at the top. To change a color or font, edit here.
   ============================================================================ */

:root {
  /* Colors — new palette */
  --ink:            #22272e;
  --paper:          #fdfcf6;
  --paper-warm:     #f6f3e8;
  --rule:           #e3e0d4;
  --irc:            #c79a1f;
  --cfr:            #3f6693;
  --irc-pale:       #f5edd8;
  --cfr-pale:       #d8e2ef;

  /* Backwards-compat aliases — existing rules pick up the new palette automatically */
  --navy:           var(--ink);
  --navy-mid:       #2e353e;
  --navy-light:     #3a424c;
  --gold:           var(--irc);
  --gold-light:     #d8b250;
  --gold-pale:      var(--irc-pale);
  --warm-white:     var(--paper);
  --warm-gray:      var(--paper-warm);
  --border:         var(--rule);
  --text-primary:   var(--ink);
  --text-secondary: #5a6068;
  --text-muted:     #8a8d96;

  /* Fonts */
  --font-sans:    'DM Sans', system-ui, sans-serif;
  --font-serif:   'Crimson Pro', Georgia, serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  /* Spacing */
  --nav-height: 56px;

  /* Button tokens — see "Button system" comment block below for the rules.
     Three shapes: primary (filled CTA), secondary (outlined), pill (filter).
     A fourth pattern — link-arrow (e.g. "Browse the full code →") — is text,
     not a button. */
  --btn-radius: 7px;
  --btn-radius-pill: 999px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--warm-white);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-sans); }
::selection { background: rgba(199,154,31,0.25); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Top navigation ─────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(34,39,46,0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(199,154,31,0.2);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 8px;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--irc);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
}
.nav-logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: white;
  letter-spacing: -0.01em;
}
.nav-links {
  display: flex;
  align-items: stretch;
  height: var(--nav-height);
  margin-left: 16px;
  flex: 1;
}
.nav-link {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  color: rgba(255,255,255,0.55);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 13px;
  height: 100%;
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: color 0.15s;
}
.nav-link:hover { color: rgba(255,255,255,0.85); }
.nav-link.active {
  color: white;
  font-weight: 600;
  border-bottom-color: var(--irc);
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-search-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: var(--font-sans);
  transition: background 0.15s;
}
.nav-search-btn:hover { background: rgba(255,255,255,0.12); }
.nav-search-btn .kbd {
  font-family: var(--font-mono);
  font-size: 9.5px;
  opacity: 0.45;
  letter-spacing: 0.04em;
  margin-left: 4px;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 28px;
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}
.footer a { color: var(--text-muted); text-decoration: underline; }
.footer a:hover { color: var(--text-secondary); }
.footer-currency {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.footer-currency-irc {
  font-family: var(--font-mono);
  color: var(--irc);
  font-weight: 500;
}
.footer-currency-cfr {
  font-family: var(--font-mono);
  color: var(--cfr);
  font-weight: 500;
}
.footer-currency-sep { color: var(--text-muted); opacity: 0.6; }

/* ── Homepage hero ──────────────────────────────────────────────────────── */
.hero {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 72px 24px 80px;
  position: relative;
}
.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(199,154,31,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(199,154,31,0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
.hero-inner {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 64px;
}
.hero-left {
  flex: 0 0 45%;
  text-align: left;
}
.hero-right {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.hero-eyebrow {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}
.hero-eyebrow-irc {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--irc);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hero-eyebrow-cfr {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--cfr);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hero-eyebrow-dot {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(56px, 11vw, 104px);
  color: var(--ink);
  line-height: 1;
  letter-spacing: -2px;
  margin-bottom: 28px;
}
.hero-divider {
  width: 64px;
  height: 2px;
  background: var(--irc);
  margin: 0 auto 28px;
  opacity: 0.7;
}
.hero-sub {
  font-size: 19px;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 36px;
  max-width: 540px;
}

/* ── Search bar ─────────────────────────────────────────────────────────── */
.search-form {
  display: flex;
  max-width: 560px;
}
.search-input-wrap {
  flex: 1;
  position: relative;
}
.search-input-wrap svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.4;
  pointer-events: none;
}
.search-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  padding: 16px 120px 16px 46px;
  border: 2px solid var(--text-secondary);
  border-radius: 10px;
  outline: none;
  background: white;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(34,39,46,0.04);
}
.search-input:focus {
  border-color: var(--text-secondary);
  box-shadow: none;
}
.search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13.5px;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: var(--btn-radius);
  padding: 9px 18px;
  white-space: nowrap;
  letter-spacing: 0.01em;
  transition: background 0.15s;
  cursor: pointer;
}
.search-btn:hover { background: #2e353e; }

/* ── Search hint ─────────────────────────────────────────────────────────── */
.search-hint {
  font-family: var(--font-sans);
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 10px;
  text-align: left;
}

/* ── Hero treemap (Chapter 1 subchapters) ────────────────────────────────── */
.treemap {
  position: relative;
  width: 100%;
  max-width: 620px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
}
.treemap-caption { width: 100%; max-width: 620px; }
.treemap-box {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 8px 10px;
  text-decoration: none;
  border-right: 1px solid rgba(34,39,46,0.08);
  border-bottom: 1px solid rgba(34,39,46,0.08);
  overflow: hidden;
  transition: filter 0.12s, transform 0.12s, box-shadow 0.12s, z-index 0s;
  cursor: pointer;
}
.treemap-box:hover {
  filter: brightness(0.97);
  z-index: 5;
  transform: translateY(-1.5px) scale(1.012);
  box-shadow:
    0 1px 2px rgba(34,39,46,0.07),
    0 4px 8px rgba(34,39,46,0.10),
    0 12px 22px rgba(34,39,46,0.14);
}
.treemap-letter {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 4px;
}
.treemap-heading {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0.85;
}
.treemap-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: auto;
  letter-spacing: 0.04em;
}

/* Color tiers — gold/teal washes, dark slate, and clean white */
.treemap-gold  { background: var(--irc-pale); }
.treemap-gold .treemap-letter { color: var(--irc); }
.treemap-teal  { background: var(--cfr-pale); }
.treemap-teal .treemap-letter { color: var(--cfr); }
.treemap-gray  { background: #3e434c; }
.treemap-gray .treemap-letter,
.treemap-gray .treemap-heading { color: white; }
.treemap-gray .treemap-count { color: rgba(255,255,255,0.6); }
.treemap-white { background: white; }

/* Hide labels and counts in tiny boxes — only the letter shows */
.treemap-box.treemap-compact { padding: 4px 6px; }
.treemap-box.treemap-compact .treemap-heading,
.treemap-box.treemap-compact .treemap-count { display: none; }
.treemap-box.treemap-compact .treemap-letter { font-size: 16px; }

/* Mid-size boxes: keep heading (2 lines max) but drop the count */
.treemap-box.treemap-short .treemap-count { display: none; }
.treemap-box.treemap-short .treemap-heading { -webkit-line-clamp: 2; }
.treemap-box.treemap-short .treemap-letter { font-size: 18px; }

.treemap-caption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.treemap-caption a {
  color: var(--irc);
  text-decoration: none;
  font-weight: 500;
  font-size: 12.5px;
}
.treemap-caption a:hover { color: var(--ink); }

/* Stack layout below ~960px */
@media (max-width: 960px) {
  .hero-inner { flex-direction: column; gap: 48px; align-items: stretch; }
  .hero-left, .hero-right { flex: 1 1 auto; }
  .treemap { max-width: 100%; }
}

/* ── Quick section pills ─────────────────────────────────────────────────── */
.hero-pills {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.hero-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 5px 12px;
  transition: all 0.15s;
  text-decoration: none;
}
.hero-pill:hover {
  color: white;
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
}
.hero-pill-label {
  font-family: var(--font-sans);
  font-size: 12px;
  color: rgba(255,255,255,0.25);
}

/* ── Homepage body ──────────────────────────────────────────────────────── */
.home-body-wrap {
  background: var(--paper-warm);
}
.home-body-wrap + .home-body-wrap > .home-body {
  padding-top: 16px;
}
.home-body {
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 24px;
}
.home-body-h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
  color: var(--ink);
  margin-bottom: 20px;
  letter-spacing: -0.5px;
  text-align: left;
  line-height: 1;
}

/* ── Section card (homepage) — compact tile grid ─────────────────────────── */
.section-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.section-card {
  text-align: left;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 16px 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 110px;
}
.section-card:hover {
  background: white;
  border-color: var(--gold-light);
  transform: translateY(-1.5px) scale(1.008);
  box-shadow:
    0 1px 2px rgba(15,32,68,0.05),
    0 4px 8px rgba(15,32,68,0.07),
    0 10px 20px rgba(15,32,68,0.09);
}
.section-card-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--gold);
  background: var(--gold-pale);
  padding: 3px 8px;
  border-radius: 5px;
  flex-shrink: 0;
  display: inline-block;
  white-space: nowrap;
}
.section-card-title {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.35;
  color: var(--navy);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Citation map page ───────────────────────────────────────────────────── */
.map-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}
/* The HTML `hidden` attribute sets display:none in the user-agent stylesheet
 * but my `display: flex` rules above would override it. Force [hidden] to
 * win on the map page's affected elements. */
.map-empty[hidden],
.map-legend[hidden],
.map-truncation[hidden] { display: none !important; }
/* Don't let the mobile-search width:100% rule blow up the Map-it button. */
.map-search .search-btn { width: auto; }
.map-header h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 36px;
  line-height: 1.1;
  color: var(--ink);
  margin: 0 0 8px;
}
.map-tagline {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 720px;
  margin: 0 0 22px;
}
.map-search { margin-bottom: 8px; }
.map-search-hint {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 4px 0;
  min-height: 18px;
}
.map-search-hint.error { color: #b91c1c; }

.map-stage {
  position: relative;
  margin-top: 20px;
  height: 70vh;
  min-height: 520px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: #fafaf6;
  overflow: hidden;
}
.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}
.map-empty-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0;
}
.map-example {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: white;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.map-example:hover {
  background: var(--paper-warm);
  border-color: var(--gold-light);
}
.map-graph {
  width: 100%;
  height: 100%;
}
.map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}
.map-legend-row { display: flex; align-items: center; gap: 8px; }
.map-legend-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid;
}
.map-legend-dot.map-legend-irc { background: var(--irc); border-color: var(--irc); }
.map-legend-dot.map-legend-cfr { background: var(--cfr); border-color: var(--cfr); }
.map-legend-hint { color: var(--text-muted); font-style: italic; margin-top: 2px; }

/* Tooltip overlay shown on node/edge hover. */
.map-tooltip {
  position: absolute;
  z-index: 20;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink);
  box-shadow: 0 6px 20px rgba(15, 32, 68, 0.12), 0 1px 3px rgba(15, 32, 68, 0.08);
  pointer-events: none;
}
.map-tooltip[hidden] { display: none !important; }
.map-tooltip .map-tt-num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 2px;
}
.map-tooltip .map-tt-heading {
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 4px;
}
.map-tooltip .map-tt-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.map-tooltip .map-tt-expanded {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.map-tooltip .map-tt-context {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
  font-style: italic;
}
.map-legend-arrow {
  display: inline-block;
  width: 18px; height: 0;
  border-top: 2px solid;
  position: relative;
}
.map-legend-arrow::after {
  content: '';
  position: absolute;
  right: -1px; top: -4px;
  border-left: 6px solid;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}
.map-legend-arrow.map-legend-out { border-color: var(--cfr); color: var(--cfr); }
.map-legend-arrow.map-legend-in  { border-color: var(--irc); color: var(--irc); }
.map-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}
.map-controls[hidden] { display: none !important; }
.map-control-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.map-control-btn:hover {
  background: #fff;
  color: var(--ink);
  border-color: var(--text-muted);
}
.map-control-btn:active { transform: translateY(1px); }

.map-truncation {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 300px;
  pointer-events: none;
}

/* ── Citations panel (slide-out on map page) ─────────────────────────────── */
.cite-panel-toggle {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--ink);
  color: white;
  border: 1px solid var(--ink);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  z-index: 15;
  box-shadow: 0 2px 6px rgba(15, 32, 68, 0.12);
  transition: background 0.12s, transform 0.12s;
}
.cite-panel-toggle[hidden] { display: none !important; }
.cite-panel-toggle:hover { background: #2c333d; }
.cite-panel-toggle svg { opacity: 0.9; }

.cite-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92%);
  background: white;
  border-left: 1px solid var(--rule);
  box-shadow: -8px 0 24px rgba(15, 32, 68, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 25;
}
.cite-panel[hidden] { display: none !important; }
.cite-panel.cite-panel-open { transform: translateX(0); }
.cite-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--rule);
}
.cite-panel-title {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.cite-panel-subtitle {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
}
.cite-panel-close {
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 4px;
}
.cite-panel-close:hover { color: var(--ink); background: var(--paper-warm); }

.cite-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 24px;
}
.cite-panel-loading,
.cite-panel-error {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-muted);
  padding: 24px 0;
  text-align: center;
}
.cite-panel-error { color: #b91c1c; }

.cite-section { margin-top: 16px; }
.cite-section:first-child { margin-top: 4px; }
.cite-section-h {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 4px;
}
.cite-section-sub {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  font-style: italic;
}

.cite-group { margin-top: 10px; }
.cite-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.cite-group-count {
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
}
.cite-group-empty-msg {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}
.cite-group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cite-pill {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.cite-pill:hover { background: var(--paper-warm); }
.cite-pill-irc { border-left: 3px solid var(--irc); }
.cite-pill-cfr { border-left: 3px solid var(--cfr); }
.cite-pill-num {
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.cite-pill-irc .cite-pill-num { color: var(--irc); }
.cite-pill-cfr .cite-pill-num { color: var(--cfr); }
.cite-pill-text {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.cite-pill-weight {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--paper-warm);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Section page → map link button ──────────────────────────────────────── */
.section-footer-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}
.section-footer-row .citation-block {
  flex: 1;
  min-width: 240px;
}
.map-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--ink);
  color: white;
  border-radius: var(--btn-radius);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.12s, transform 0.12s;
}
.map-link-btn:hover { background: #2e353e; }
.map-link-btn svg { opacity: 0.9; }

/* ── Frequently Referenced — row layout ──────────────────────────────────── */
.section-rows {
  display: flex;
  flex-direction: column;
}
.section-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 32px;
  align-items: baseline;
  padding: 16px 4px;
  text-decoration: none;
  color: inherit;
  border-top: 1px solid #ebe8dc;
  transition: background 0.12s;
}
.section-row:first-child { border-top: none; }
.section-row:hover { background: rgba(34,39,46,0.025); }
.section-row-tag {
  display: inline-block;
  width: fit-content;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  padding: 7px 11px;
  border-radius: 4px;
  white-space: nowrap;
}
.section-row.irc .section-row-tag {
  color: var(--irc);
  background: var(--irc-pale);
}
.section-row.cfr .section-row-tag {
  color: var(--cfr);
  background: var(--cfr-pale);
}
.section-row-title {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.35;
  color: #22272e;
}

/* ── Homepage sidebar widgets ────────────────────────────────────────────── */
.sidebar-widget {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 20px;
}
.sidebar-widget h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--navy);
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}
.sidebar-widget.gold-bg {
  background: var(--gold-pale);
  border-color: rgba(184,145,47,0.3);
}
.browse-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: color 0.15s;
}
.browse-link:hover { color: var(--gold); }
.browse-link:last-child { border-bottom: none; }
.browse-link-label { font-size: 13px; line-height: 1.3; }
.browse-link-range {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 8px;
}

/* ── Hero stats (inline under the search bar) ────────────────────────────── */
.hero-stats {
  display: flex;
  gap: 0;
  margin-top: 24px;
}
.stat { text-align: left; padding: 0 28px 0 0; }
.stat + .stat {
  border-left: 1px solid var(--rule);
  padding-left: 28px;
}
.stat-n {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat-label.irc { color: var(--irc); }
.stat-label.cfr { color: var(--cfr); }

/* ── Browse page ─────────────────────────────────────────────────────────── */
.browse-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-height));
}
.browse-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 14px 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--warm-white);
  flex-shrink: 0;
}
.browse-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 36px;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin-right: 24px;
  padding-bottom: 10px;
}
.browse-tab {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 16px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.12s;
  text-decoration: none;
}
.browse-tab:hover { color: var(--navy); }
.browse-tab.active {
  font-weight: 600;
  color: var(--navy);
  border-bottom-color: var(--gold);
}
.miller-container {
  flex: 1;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
}
@keyframes miller-col-slide {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.miller-column {
  width: 240px;
  min-width: 240px;
  border-right: 1px solid var(--border);
  animation: miller-col-slide 160ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: colSlide 0.18s ease;
}
.miller-column.sections-col {
  width: 280px;
  min-width: 280px;
}
.miller-col-header {
  padding: 11px 16px 9px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  background: var(--warm-gray);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 1;
}
.miller-back {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--warm-gray);
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 100%;
  text-align: left;
  min-height: 44px;
}
.miller-back:hover { background: var(--border); }
.miller-back svg { flex-shrink: 0; }
body.dark-mode .miller-back { background: #2e353e; color: var(--ink); }

.miller-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-left: 3px solid transparent;
  transition: background 0.09s;
  text-decoration: none;
  color: inherit;
}
@media (prefers-reduced-motion: reduce) {
  .miller-column { animation: none !important; }
}
.miller-row:hover { background: var(--warm-gray); }
.miller-row.active {
  background: var(--gold-pale);
  border-left-color: var(--gold);
}
.miller-row-body { flex: 1; min-width: 0; }
.miller-row-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.miller-row-heading {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--navy);
  font-weight: 400;
  line-height: 1.3;
}
.miller-row.active .miller-row-heading { font-weight: 600; }
.miller-row-count {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.miller-chevron { color: var(--text-muted); flex-shrink: 0; font-size: 13px; }
.miller-section-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 44px;
}
.miller-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 40px;
}
.miller-loading {
  padding: 20px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}
/* CFR part 1 warning (3,770 sections) */
.miller-large-note {
  padding: 12px 14px;
  background: var(--gold-pale);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

@keyframes colSlide {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Section page ────────────────────────────────────────────────────────── */
.section-layout {
  display: flex;
  min-height: calc(100vh - var(--nav-height));
}

/* Left sidebar */
.section-sidebar {
  width: 260px;
  min-width: 260px;
  background: white;
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
}
.section-sidebar.collapsed {
  width: 44px;
  min-width: 44px;
}
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  width: 100%;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.sidebar-toggle-label {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-toggle svg { flex-shrink: 0; }
.sidebar-contents { flex: 1; overflow-y: auto; }
.sidebar-sub-item.active {
  background: var(--gold-pale);
  border-left-color: var(--gold);
  color: var(--navy);
  font-weight: 600;
}
.sidebar-sub-item.active .neighborhood-num { color: var(--navy-dark); }
.sidebar-section-label {
  padding: 14px 16px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar-browse-label {
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

/* ── Neighborhood (sidebar Browse panel) ─────────────────────────────────── */
.neighborhood-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.neighborhood-link {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 16px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.neighborhood-link:hover { background: var(--warm-gray); color: var(--navy); }
.neighborhood-num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--gold);
  flex-shrink: 0;
}
.neighborhood-heading {
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.neighborhood-item.current > .neighborhood-link {
  background: var(--gold-pale);
  border-left-color: var(--gold);
  color: var(--navy);
  font-weight: 600;
}
.neighborhood-item.current .neighborhood-num { color: var(--navy-dark); }
.neighborhood-item.muted { opacity: 0.55; }

.neighborhood-more {
  display: block;
  padding: 6px 16px 10px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--gold);
  text-decoration: none;
}
.neighborhood-more:hover { color: var(--gold-light); }

.neighborhood-details { margin-top: 8px; }
.neighborhood-details > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  position: relative;
  padding-right: 28px;
}
.neighborhood-details > summary::-webkit-details-marker { display: none; }
.neighborhood-details > summary::after {
  content: "▸";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.neighborhood-details[open] > summary::after { transform: translateY(-50%) rotate(90deg); }

.sidebar-location {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-location-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.sidebar-location-item {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Progress bar */
.reading-progress {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 2px;
  background: var(--border);
}
.reading-progress-fill {
  height: 100%;
  background: var(--gold);
  transition: width 0.12s;
  width: 0%;
}

/* Section main content */
.section-main {
  flex: 1;
  overflow-y: auto;
  height: calc(100vh - var(--nav-height));
}
.section-sticky-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 20px 48px 16px;
}
.section-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  margin-bottom: 12px;
  text-decoration: none;
  transition: color 0.15s;
}
.section-back:hover { color: var(--navy); }
.section-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}
/* Title wrapper claims available width so the title doesn't get squeezed
   to its longest-word width when the action row is wide (e.g. iPad landscape). */
.section-header-top > div:first-child { flex: 1 1 auto; min-width: 0; }
.section-badge {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  color: var(--irc);
  background: var(--irc-pale);
  border: 1px solid var(--irc);
  padding: 3px 10px;
  border-radius: 5px;
  display: inline-block;
  margin-bottom: 6px;
}
.section-badge.cfr {
  color: var(--cfr);
  background: var(--cfr-pale);
  border-color: var(--cfr);
}
.section-breadcrumb {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.section-breadcrumb a { color: var(--text-muted); }
.section-breadcrumb a:hover { color: var(--gold); }
.section-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 26px;
  color: var(--navy);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.section-actions { display: flex; gap: 8px; flex-shrink: 0; }
.section-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--btn-radius);
  padding: 7px 12px;
  transition: all 0.15s;
}
.section-action-btn:hover { background: var(--warm-gray); color: var(--navy); }
.section-meta {
  display: flex;
  gap: 20px;
  margin-top: 12px;
}
.section-meta-item {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
}
.section-meta-item strong {
  color: var(--text-secondary);
  font-weight: 500;
}
/* Repealed / Reserved banner */
.section-status-banner {
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
}
.section-status-banner.repealed {
  background: #FEF3F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
}
.section-status-banner.reserved {
  background: var(--warm-gray);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Section body */
.section-body {
  max-width: 740px;
  margin: 0 auto;
  padding: 48px 48px 80px;
}

/* Legal text — rendered from content_html */
.section-content { font-family: var(--font-serif); font-size: 17px; line-height: 1.7; color: #2A3A5A; }
.section-content .uslm-subsection,
.section-content .uslm-paragraph,
.section-content .uslm-subparagraph,
.section-content .uslm-clause,
.section-content .uslm-subclause,
.section-content .uslm-item,
.section-content .uslm-subitem { margin-bottom: 2px; padding-left: 24px; }
.section-content .uslm-subsection { padding-left: 0; margin-bottom: 16px; }
.section-content .uslm-num { font-weight: 600; color: var(--navy); }
.section-content .uslm-heading { font-style: normal; font-weight: 700; }
.section-content .uslm-ref { color: var(--gold); border-bottom: 1px solid var(--gold-light); cursor: pointer; font-weight: 500; }
.section-content .uslm-ref:hover { color: var(--gold-light); }
.section-content .uslm-note { display: none; }
.section-content .uslm-source-credit { font-size: 12.5px; color: var(--text-muted); margin-top: 24px; }
.section-content .uslm-source-credit a { color: inherit; text-decoration: none; border-bottom: 0; pointer-events: none; cursor: text; font-weight: inherit; }

/* Heading inline with period — num + heading run inline, content follows on same line */
.section-content .uslm-heading + .uslm-chapeau,
.section-content .uslm-heading + .uslm-content,
.section-content .uslm-heading + .uslm-p { display: inline; }
.section-content .uslm-heading:has(+ .uslm-chapeau)::after,
.section-content .uslm-heading:has(+ .uslm-content)::after,
.section-content .uslm-heading:has(+ .uslm-p)::after { content: ".\00a0"; }
/* Heading followed by a block-level child (subsection/paragraph/etc): period only, breathing room handled below. */
.section-content .uslm-heading:has(+ .uslm-subsection)::after,
.section-content .uslm-heading:has(+ .uslm-paragraph)::after,
.section-content .uslm-heading:has(+ .uslm-subparagraph)::after,
.section-content .uslm-heading:has(+ .uslm-clause)::after,
.section-content .uslm-heading:has(+ .uslm-subclause)::after,
.section-content .uslm-heading:has(+ .uslm-item)::after,
.section-content .uslm-heading:has(+ .uslm-subitem)::after { content: "."; }
.section-content .uslm-heading + .uslm-subsection { margin-top: 18px; }
.section-content .uslm-num + .uslm-content { display: inline; }
.section-content .uslm-num + .uslm-chapeau { display: inline; }
.section-content .uslm-num + .uslm-p { display: inline; }
/* Section-level title is shown in the sticky header — hide the duplicate at the top of the body. */
.section-content > span.uslm-num,
.section-content > span.uslm-heading { display: none; }
.section-content .uslm-heading + .uslm-content > .uslm-p:first-child,
.section-content .uslm-num + .uslm-content > .uslm-p:first-child { display: inline; }

/* Hide editorial notes / amendments block entirely */
.section-content .uslm-notes { display: none; }

/* CFR: bold (not italic) the leading subsection title — only the first <em>
 * in each paragraph. Other <em> elements keep default italic emphasis. */
.section-content p > em:first-of-type { font-weight: 700; font-style: normal; }

/* CFR "-0" table-of-contents sections — render as plain prose, no special styling. */
.section-content.toc-plain blockquote {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-style: normal;
}
.section-content.toc-plain em { font-style: normal; font-weight: 500; }
.section-content.toc-plain p { margin: 0 0 6px 0; padding-left: 0; }

/* CFR: subsection indentation by depth */
.section-content p[data-cfr-depth="2"] { padding-left: 24px; }
.section-content p[data-cfr-depth="3"] { padding-left: 48px; }
.section-content p[data-cfr-depth="4"] { padding-left: 72px; }
.section-content p[data-cfr-depth="5"] { padding-left: 96px; }
.section-content p[data-cfr-depth="6"] { padding-left: 120px; }
.section-content p[data-cfr-depth="7"] { padding-left: 144px; }

/* CFR: vertical spacing between paragraphs */
.section-content p[data-full-cite] { margin-bottom: 8px; }
.section-content p[data-full-cite]:not([data-cfr-depth]) { margin-top: 12px; }

/* CFR examples: subtle background, bold padded title, no outline indentation */
.section-content .cfr-example {
  background: var(--cfr-pale);
  border-left: 3px solid var(--cfr);
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 4px;
}
.section-content .cfr-example .ecfr-hed {
  display: block;
  font-weight: 700;
  padding-top: 4px;
  padding-bottom: 8px;
}
.section-content .cfr-example p { margin-bottom: 8px; padding-left: 0; }
.section-content .cfr-example p:last-child { margin-bottom: 0; }

/* CFR: hide the duplicate section-number h2 at top of content_html */
.section-content > h2:first-child { display: none; }
.section-content .uslm-p { margin-bottom: 12px; }
.section-content table {
  border-collapse: collapse;
  font-size: 14px;
  margin: 16px 0;
  width: auto;
  max-width: 100%;
}
.section-content td, .section-content th {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.section-content thead th {
  background: var(--warm-gray);
  font-weight: 700;
  color: var(--navy);
}
.section-content tbody tr:nth-child(even) { background: rgba(242, 240, 234, 0.4); }
.section-content table p { margin: 0; }

/* Cross-reference tooltip */
.xref-tooltip {
  position: fixed;
  z-index: 9999;
  width: 340px;
  min-height: 96px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(15,32,68,0.14), 0 2px 8px rgba(15,32,68,0.06);
  padding: 14px 16px;
  pointer-events: auto;
  display: none;
}
.xref-tooltip-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: xref-spin 0.7s linear infinite;
}
@keyframes xref-spin { to { transform: rotate(360deg); } }
.xref-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 9998;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
  display: none;
}
.xref-backdrop.visible { opacity: 1; pointer-events: auto; }

/* Mobile sticky mini-header (shown after user scrolls past the section title).
   Default display:none keeps it out of the DOM flow on desktop entirely. */
.section-mini-header { display: none; }

/* Desktop: hide the toggle label when the sidebar is in its 44px-wide collapsed
   stub. JS sets the label text; CSS controls visibility per breakpoint. */
.section-sidebar.collapsed .sidebar-toggle-label { display: none; }
.xref-tooltip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.xref-tooltip-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  background: var(--gold-pale);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}
.xref-tooltip-title {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
}
.xref-tooltip-text {
  font-family: var(--font-serif);
  font-size: 13.5px;
  line-height: 1.6;
  color: #3A4A6A;
  margin: 0;
}
.xref-tooltip-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.xref-open-link {
  font-size: 11px;
  font-weight: 500;
  color: var(--gold);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
  text-decoration: none;
}

/* Related sections */
.related-sections { margin-top: 48px; padding-top: 32px; border-top: 2px solid var(--border); }
.related-sections-label {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.related-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.related-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--navy);
  background: var(--warm-gray);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.related-pill:hover { background: var(--gold-pale); border-color: var(--gold-light); }
.related-pill-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.related-pill-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Citation block */
.citation-block {
  margin-top: 32px;
  padding: 18px 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.citation-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.citation-block-label { font-family: var(--font-sans); font-weight: 600; font-size: 13px; color: var(--navy); }
.citation-copy-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--gold);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}
.citation-copy-btn.copied { color: #16a34a; }
.citation-text { font-family: var(--font-mono); font-size: 13px; color: var(--text-secondary); display: block; }

/* ── Search results ──────────────────────────────────────────────────────── */
.search-page { max-width: 860px; margin: 0 auto; padding: 48px 24px; }
.search-page-header { margin-bottom: 32px; }
.search-page-title { font-family: var(--font-sans); font-weight: 600; font-size: 22px; color: var(--navy); margin-bottom: 8px; }
.search-page-meta { font-size: 14px; color: var(--text-muted); }
.search-results { display: grid; gap: 12px; }
.search-result {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.search-result:hover {
  border-color: var(--ink);
  box-shadow: 0 4px 16px rgba(15,32,68,0.07);
}
.search-result-cite {
  flex-shrink: 0;
  width: 132px;
  padding: 18px 12px;
  background: var(--gold-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1.2;
  white-space: nowrap;
}
.search-result.corpus-cfr .search-result-cite {
  background: var(--cfr-pale);
  color: var(--cfr);
}
.search-result-body {
  flex: 1;
  min-width: 0;
  padding: 18px 22px;
}
.search-result-heading {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 15.5px;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 8px;
}
.search-result-snippet {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result-snippet mark {
  background: var(--gold-pale);
  color: var(--ink);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 500;
}
.search-result.corpus-cfr .search-result-snippet mark {
  background: var(--cfr-pale);
}
.search-no-results { font-family: var(--font-sans); color: var(--text-muted); font-size: 14px; padding: 40px 0; text-align: center; }

/* ── About / Error pages ─────────────────────────────────────────────────── */
.simple-page { max-width: 700px; margin: 0 auto; padding: 64px 24px; }
.simple-page h1 { font-family: var(--font-display); font-size: 44px; font-weight: 500; color: var(--ink); letter-spacing: -0.5px; margin-bottom: 20px; }
.simple-page p { font-family: var(--font-sans); font-size: 16px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 16px; }
.simple-page a { color: var(--gold); }
.simple-page .error-code { font-family: var(--font-mono); font-size: 72px; font-weight: 500; color: var(--border); margin-bottom: 8px; }

/* ── Search overlay ──────────────────────────────────────────────────────── */
#search-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
}
.search-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(63,102,147,0.55);
  backdrop-filter: blur(4px);
}
.search-overlay-box-wrap {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  max-width: calc(100vw - 48px);
}
.search-overlay-box {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(15,32,68,0.22);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
}
.search-overlay-hint {
  font-family: var(--font-sans);
  font-size: 13px;
  font-style: italic;
  font-weight: 500;
  color: white;
  margin-top: 12px;
  padding: 0 4px;
  text-shadow: 0 1px 3px rgba(15,32,68,0.55);
}
.search-overlay-icon { flex-shrink: 0; opacity: 0.35; }
.search-overlay-input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--navy);
  background: none;
  border: none;
  outline: none;
}
.search-overlay-esc {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--warm-gray);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.search-overlay-filters {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding: 0 4px;
}
.sof-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: var(--btn-radius-pill);
  border: 1.5px solid rgba(255,255,255,0.45);
  background: transparent;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sof-btn:hover {
  background: rgba(255,255,255,0.15);
  color: white;
  border-color: rgba(255,255,255,0.8);
}
.sof-btn.active {
  background: white;
  color: var(--navy);
  border-color: white;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Font-size toggle ────────────────────────────────────────────────────── */
.font-size-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-secondary);
  padding: 2px 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
  min-height: 24px;
}
.font-size-btn:hover { border-color: var(--text-muted); color: var(--ink); background: var(--warm-gray); }

.font-size-big   { font-family: var(--font-serif); font-size: 16px; font-weight: 600; }
.font-size-small { font-family: var(--font-serif); font-size: 11px; font-weight: 600; }

/* Body text size modes — three options: small, medium (default), large */
body.font-small  .section-content { font-size: 15px; line-height: 1.65; }
body.font-large  .section-content { font-size: 19px; line-height: 1.7; }

/* ── Corpus accents (IRC = gold, CFR = teal) ─────────────────────────────── */

/* Home page card left-accent stripes */
.section-card.irc { border-left: 3px solid var(--irc); }
.section-card.cfr { border-left: 3px solid var(--cfr); }
.section-card.cfr .section-card-num {
  color: var(--cfr);
  background: var(--cfr-pale);
}

/* Browse page: when CFR is the active corpus, swap accents from IRC to CFR */
.browse-page.corpus-cfr .browse-tab.active { border-bottom-color: var(--cfr); }
.browse-page.corpus-cfr .miller-row.active {
  background: #b3c5dc;
  border-left-color: var(--cfr);
}
.browse-page.corpus-cfr .miller-row-label,
.browse-page.corpus-cfr .miller-section-num { color: var(--cfr); }

/* Cross-reference pills — color the § number by target corpus */
.related-pill-cfr .related-pill-num { color: var(--cfr); }
.related-pill-cfr:hover { background: var(--cfr-pale); border-color: var(--cfr); }

/* Section page — CFR corpus accents */
.section-card.cfr:hover { border-color: var(--cfr); }
.corpus-cfr .reading-progress-fill { background: var(--cfr); }
.corpus-cfr .neighborhood-num { color: var(--cfr); }
.corpus-cfr .neighborhood-item.current > .neighborhood-link {
  background: var(--cfr-pale);
  border-left-color: var(--cfr);
}
.corpus-cfr .neighborhood-more { color: var(--cfr); }
.corpus-cfr .neighborhood-more:hover { color: var(--cfr); opacity: 0.75; }
.corpus-cfr .sidebar-sub-item.active {
  background: var(--cfr-pale);
  border-left-color: var(--cfr);
}
.corpus-cfr .section-breadcrumb a:hover { color: var(--cfr); }
.corpus-cfr .citation-copy-btn { color: var(--cfr); }
body.collapse-mode .corpus-cfr #collapse-toggle-btn {
  border-color: var(--cfr);
  color: var(--cfr);
  background: var(--cfr-pale);
}
.browse-page.corpus-cfr .miller-large-note { background: var(--cfr-pale); }

/* CFR section page — all hyperlinks in body text use teal */
.corpus-cfr .section-content a,
.corpus-cfr .section-content .uslm-ref {
  color: var(--cfr);
  border-bottom-color: rgba(63,102,147,0.4);
}
.corpus-cfr .section-content a:hover,
.corpus-cfr .section-content .uslm-ref:hover {
  color: var(--cfr);
  opacity: 0.75;
}
.xref-tooltip.corpus-cfr .xref-tooltip-num {
  color: var(--cfr);
  background: var(--cfr-pale);
}
.xref-tooltip.corpus-cfr .xref-open-link { color: var(--cfr); }

/* ── Favorites pills (home page) ────────────────────────────────────────── */
.fav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.fav-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: none;
  transition: filter 0.12s;
  max-width: 300px;
}
.fav-pill:hover { filter: brightness(0.95); }
.fav-pill-irc { color: var(--irc); background: var(--irc-pale); }
.fav-pill-cfr { color: var(--cfr); background: var(--cfr-pale); }
.fav-pill-num { font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.fav-pill-heading {
  font-family: var(--font-sans);
  font-size: 12px;
  color: inherit;
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.fav-pill-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.5;
  font-size: 14px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 2px;
}
.fav-pill-remove:hover { opacity: 1; }

/* Star / Save button on section pages */
#fav-btn.active { color: var(--gold); border-color: var(--gold); background: var(--gold-pale); }
#fav-btn.active svg { fill: var(--gold); stroke: var(--gold); }
.corpus-cfr #fav-btn.active { color: var(--cfr); border-color: var(--cfr); background: var(--cfr-pale); }
.corpus-cfr #fav-btn.active svg { fill: var(--cfr); stroke: var(--cfr); }

/* ── Collapse mode (toggleable outline view) ───────────────────────────── */
.collapse-arrow {
  display: none;
  background: none;
  border: none;
  padding: 0 4px 0 0;
  margin-right: 2px;
  cursor: pointer;
  color: var(--text-muted);
  vertical-align: baseline;
  transition: transform 0.15s, color 0.15s;
  line-height: 0;
}
.collapse-arrow:hover { color: var(--gold); }
.collapse-arrow svg { display: inline-block; vertical-align: middle; transition: transform 0.15s; }
body.collapse-mode .collapse-arrow { display: inline-block; }
.collapsed > .collapse-arrow svg { transform: rotate(-90deg); }

/* IRC: hide everything inside a collapsed USLM block except num/heading/arrow */
body.collapse-mode .uslm-subsection.collapsed > *:not(.uslm-num):not(.uslm-heading):not(.collapse-arrow),
body.collapse-mode .uslm-paragraph.collapsed > *:not(.uslm-num):not(.uslm-heading):not(.collapse-arrow),
body.collapse-mode .uslm-subparagraph.collapsed > *:not(.uslm-num):not(.uslm-heading):not(.collapse-arrow),
body.collapse-mode .uslm-clause.collapsed > *:not(.uslm-num):not(.uslm-heading):not(.collapse-arrow),
body.collapse-mode .uslm-subclause.collapsed > *:not(.uslm-num):not(.uslm-heading):not(.collapse-arrow),
body.collapse-mode .uslm-item.collapsed > *:not(.uslm-num):not(.uslm-heading):not(.collapse-arrow),
body.collapse-mode .uslm-subitem.collapsed > *:not(.uslm-num):not(.uslm-heading):not(.collapse-arrow) {
  display: none !important;
}

/* CFR: hide the body text when a paragraph is collapsed. The leading <strong>
 * (citation) and the first <em> (heading) stay; everything else is wrapped in
 * a .cfr-para-body span by section.js so we can target it here. */
body.collapse-mode p[data-full-cite].collapsed > .cfr-para-body {
  display: none !important;
}

/* CFR examples: post-title content is wrapped in .cfr-example-body by JS so
 * loose text nodes (inline formula fragments like "r = c{(1 + i/b)") get
 * hidden along with the paragraphs when the example is collapsed. */
body.collapse-mode .cfr-example.collapsed > .cfr-example-body {
  display: none !important;
}

/* Toggle button active state */
body.collapse-mode #collapse-toggle-btn {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-pale);
}

/* Full-citations toggle button */
.cite-icon {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
#cite-toggle-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-pale);
}
.corpus-cfr #cite-toggle-btn.active {
  border-color: var(--cfr);
  color: var(--cfr);
  background: var(--cfr-pale);
}

/* Bulk Collapse all / Expand all — only visible in collapse mode */
.collapse-bulk-btn {
  display: none;
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: none;
  transition: color 0.15s;
}
.collapse-bulk-btn:hover { color: var(--ink); text-decoration: underline; }
body.collapse-mode .collapse-bulk-btn { display: inline-block; }

/* ── Live search dropdown ─────────────────────────────────────────────────── */
.search-live-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1.5px solid var(--rule);
  border-radius: 0 0 10px 10px;
  border-top: none;
  box-shadow: 0 8px 24px rgba(34,39,46,0.1);
  z-index: 1100;
  max-height: 380px;
  overflow-y: auto;
}
.search-live-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
}
.search-live-item:last-child { border-bottom: none; }
.search-live-item:hover,
.search-live-item.selected { background: var(--paper-warm); }
.search-live-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--irc);
  white-space: nowrap;
  flex-shrink: 0;
}
.search-live-item.corpus-cfr .search-live-num { color: var(--cfr); }
.search-live-heading {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Search corpus filter tabs ───────────────────────────────────────────── */
.search-corpus-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.search-corpus-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 16px;
  border-radius: var(--btn-radius-pill);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.search-corpus-tab:hover { border-color: var(--ink); color: var(--ink); }
.search-corpus-tab.corpus-irc:hover { border-color: var(--gold); color: var(--navy); }
.search-corpus-tab.corpus-cfr:hover { border-color: var(--cfr); color: var(--cfr); }
.search-corpus-tab.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
  font-weight: 600;
}
.search-corpus-tab.corpus-irc.active {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}
.search-corpus-tab.corpus-cfr.active {
  background: var(--cfr);
  color: white;
  border-color: var(--cfr);
}

/* ── Section prev/next navigation ────────────────────────────────────────── */
.section-nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 48px 40px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}
.section-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.15s;
  min-width: 0;
  max-width: 45%;
}
.section-nav-btn:hover { border-color: var(--gold); color: var(--gold); }
.section-nav-btn-direction {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.section-nav-btn-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Mobile responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Nav: hide text links inline; surface them via the hamburger menu */
  .nav { padding: 0 16px; }
  .nav-logo-text { font-size: 13px; }

  .nav-mobile-toggle { display: flex !important; }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    height: auto;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    background: rgba(34,39,46,0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(199,154,31,0.2);
    padding: 8px 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-link {
    height: 48px;
    padding: 0 20px;
    border-bottom: none;
    font-size: 15px;
  }
  .nav-link.active { border-bottom: none; background: rgba(199,154,31,0.08); }

  /* Touch targets — Apple's guideline is 44×44 minimum for tap reliability. */
  .section-action-btn,
  .font-size-btn,
  .collapse-bulk-btn,
  .citation-copy-btn,
  .search-btn,
  .nav-search-btn,
  .nav-dark-btn,
  .browse-tab,
  .search-corpus-tab,
  .neighborhood-more,
  .map-example,
  .fav-pill .fav-x {
    min-height: 44px;
    min-width: 44px;
  }
  .nav-search-btn { padding: 0 12px; font-size: 13px; }
  .nav-dark-btn   { padding: 0; }
}

/* Hamburger button — only visible at narrow widths via the @media block above */
.nav-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-mobile-toggle:hover { background: rgba(255,255,255,0.12); }

/* Action bar overflow trigger — only visible at narrow widths via @media below */
.section-action-overflow {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: white;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
}
.section-action-overflow:hover { background: var(--warm-gray); }
body.dark-mode .section-action-overflow { background: #2e353e; color: var(--ink); border-color: #3a424c; }

/* Inline mobile-only labels for buttons that become menu items in the popover. */
.overflow-label { display: none; }

/* On desktop, the secondary actions container is "transparent" — children
   flow inline with the rest of .section-actions just like before this refactor. */
.section-actions-secondary { display: contents; }

/* ── Below desktop: section header restructure ───────────────────────────────
   Triggers below 1400px because the inline action row (~675px) plus the
   260px sidebar plus paddings/gaps leave too little room for the title.
   Concretely, at 1280px the title wrapper collapses to ~215px; even at
   1366px it gets only ~347px, which forces long titles into 4+ short lines.
   1400px gives the title ~380px+ at desktop layout, which wraps cleanly.
   Below the breakpoint, the title goes full-width and the secondary
   buttons collapse behind a ••• popover. */
@media (max-width: 1400px) {
  .section-header-top { flex-direction: column; align-items: stretch; gap: 12px; }
  .section-breadcrumb {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
  }
  .section-actions { flex-wrap: wrap; gap: 8px; position: relative; }
  .section-action-overflow { display: flex; }
  .section-actions-secondary {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 6px;
    z-index: 80;
    min-width: 220px;
    flex-direction: column;
    align-items: stretch;
  }
  .section-actions-secondary.open { display: flex; }
  .section-actions-secondary > button,
  .section-actions-secondary > a {
    width: 100%;
    justify-content: flex-start;
    padding: 12px 14px;
    min-height: 44px;
    border-radius: 6px;
    text-align: left;
    gap: 10px;
    font-size: 14px;
  }
  .section-actions-secondary .overflow-label { display: inline; }
  .section-actions-secondary .font-size-big,
  .section-actions-secondary .font-size-small,
  .section-actions-secondary .cite-icon { font-size: 14px; }
  body.dark-mode .section-actions-secondary { background: #2e353e; border-color: #3a424c; }
}

@media (max-width: 768px) {

  /* Hero */
  .hero { padding: 48px 20px 56px; }
  .hero-sub { font-size: 15px; }

  /* Stack hero so the title/search get full readable width. */
  .hero-inner { flex-direction: column; gap: 32px; }
  .hero-left { flex: 1 1 auto; width: 100%; }
  .hero-right { width: 100%; align-items: flex-start; }
  /* Treemap clips on phones (its boxes use absolute % positions tuned for
     desktop). Hide the entire hero-right block so the caption doesn't
     orphan itself without the visual it describes. */
  .hero-right { display: none; }

  /* Stats bar */
  .stats-bar { flex-wrap: wrap; gap: 24px; padding: 20px 16px; }

  .home-body { padding: 32px 16px; }
  .section-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

  /* Section layout: sidebar collapses fully on mobile (no 44px stub).
     Tap the toggle to expand; tap again to collapse. */
  .section-layout { flex-direction: column; }
  .section-sidebar,
  .section-sidebar.collapsed {
    width: 100%;
    min-width: 0;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .section-sidebar.collapsed .sidebar-contents { display: none; }
  /* Override desktop-only label hiding so the mobile collapsed state shows
     "Show navigation" text — a lone chevron is not discoverable. */
  .section-sidebar.collapsed .sidebar-toggle-label { display: inline; }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    min-height: 44px;
  }
  .sidebar-toggle-label {
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--navy);
  }
  .section-main { height: auto; overflow-y: visible; }
  .section-sticky-header { padding: 14px 16px 12px; position: static; }

  /* Slim sticky mini-header — slides down once the user scrolls past the
     section title, so the section number/heading is always visible. */
  .section-mini-header {
    display: flex;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    z-index: 90;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    gap: 8px;
    align-items: baseline;
    transform: translateY(-100%);
    transition: transform .15s ease;
  }
  .section-mini-header.visible { transform: translateY(0); }
  .mini-num {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--navy);
    font-size: 14px;
    flex-shrink: 0;
  }
  .mini-title {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  /* iOS input-zoom fix — Safari auto-zooms when an input's font-size is
     <16px and never zooms back out. Bump only on mobile; the desktop hero
     design stays at 15px. */
  .search-input { font-size: 16px; }

  /* Bottom-sheet variant of the xref tooltip on touch devices — easier to
     read and dismiss than a popover anchored to a tiny inline citation. */
  .xref-tooltip.xref-tooltip--sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-width: none;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px 32px;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform .2s ease;
  }
  .xref-tooltip.xref-tooltip--sheet.visible { transform: translateY(0); }
  .xref-tooltip.xref-tooltip--sheet::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 0 auto 12px;
  }
  .section-body { padding: 20px 16px 48px; }
  .section-title { font-size: 22px; line-height: 1.25; }
  /* Section-header restructure rules live in the ≤1024px block above so
     iPads also get the stacked title + action overflow popover. */

  /* Browse: drill-down. Stack columns vertically; show only the deepest one
     so the user always sees a single full-width list. The Back button at the
     top of non-root columns pops back to the previous level. */
  .miller-container {
    overflow-x: visible;
    flex-direction: column;
    height: auto;
  }
  .miller-column,
  .miller-column.sections-col {
    width: 100%;
    min-width: 0;
    border-right: none;
    height: auto;
    display: none;
  }
  .miller-container .miller-column:last-child { display: flex; }
  .miller-back { display: flex !important; }
  .miller-row { padding: 14px 16px; min-height: 56px; flex-shrink: 0; }

  /* Map page: drop the truncation banner below the zoom controls so they
     don't fight for the same horizontal real estate at narrow widths. */
  .map-controls { left: 8px; top: 8px; flex-direction: row; }
  .map-truncation {
    top: 56px;
    left: 8px;
    right: 8px;
    max-width: none;
    text-align: center;
  }

  /* Footer */
  .footer { flex-direction: column; gap: 8px; text-align: center; }
}

/* ── Dark mode ───────────────────────────────────────────────────────────── */
body.dark-mode {
  background: #22272e;
  /* Primary tokens — gray family matching the nav bar */
  --paper:          #22272e;
  --paper-warm:     #2e353e;
  --ink:            #ddd8cf;
  --rule:           #3a424c;
  --irc:            #d4aa3a;
  --cfr:            #5b88ba;
  --irc-pale:       #3d3318;
  --cfr-pale:       #1e2830;
  /* Alias tokens — browsers resolve these at :root, must override explicitly */
  --navy:           #ddd8cf;
  --gold:           #d4aa3a;
  --gold-light:     #e0bc5a;
  --gold-pale:      #3d3318;
  --warm-white:     #22272e;
  --warm-gray:      #2e353e;
  --border:         #3a424c;
  --text-primary:   #ddd8cf;
  --text-secondary: #8a9aaa;
  --text-muted:     #546070;
  color: #ddd8cf;
}

/* Hardcoded white/light backgrounds — site-wide */
body.dark-mode .footer,
body.dark-mode .treemap,
body.dark-mode .search-overlay-box,
body.dark-mode .search-result,
body.dark-mode .search-live-dropdown,
body.dark-mode .citation-block         { background: #2e353e; }

body.dark-mode .treemap-white          { background: #434b55; }
body.dark-mode .section-card:hover     { background: #2e353e; box-shadow: none; }
body.dark-mode .search-input           { background: #2e353e; color: var(--ink); }
body.dark-mode .search-btn             { background: var(--border); color: var(--ink); }
body.dark-mode .search-btn:hover       { background: #474f5a; }

/* Browse: hardcoded active-row highlights */
body.dark-mode .miller-row.active                      { background: #3d3318; }
body.dark-mode .browse-page.corpus-cfr .miller-row.active { background: #1e2830; }

/* Section page elements */
body.dark-mode .section-sidebar        { background: #1d2228; }
body.dark-mode .section-sticky-header  { background: #1d2228; }
body.dark-mode .section-content        { color: #c8c3b8; }
body.dark-mode .section-content tbody tr:nth-child(even) { background: rgba(255,255,255,0.04); }
body.dark-mode .section-status-banner.repealed { background: #3a1a1a; color: #f87171; border-color: #7f1d1d; }
body.dark-mode .section-status-banner.reserved { background: #2e353e; }
body.dark-mode .fav-pill-irc { background: rgba(199,154,31,0.15); }
body.dark-mode .fav-pill-cfr { background: rgba(63,102,147,0.2); }

/* Cross-reference tooltip */
body.dark-mode .xref-tooltip {
  background: #2e353e;
  border-color: #3a424c;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
}
body.dark-mode .xref-tooltip-title { color: #ddd8cf; }
body.dark-mode .xref-tooltip-text  { color: #99aabf; }

/* Map page */
body.dark-mode .map-stage   { background: #22272e; }
body.dark-mode .map-example { background: #2e353e; }
body.dark-mode .map-legend  { background: rgba(34,39,46,0.95); border-color: var(--border); }
body.dark-mode .map-tooltip {
  background: rgba(46, 53, 62, 0.98);
  border-color: var(--border);
  color: var(--ink);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.4);
}
body.dark-mode .map-tooltip .map-tt-num { color: var(--ink); }
body.dark-mode .map-control-btn {
  background: rgba(46, 53, 62, 0.95);
  border-color: var(--border);
  color: var(--text-secondary);
}
body.dark-mode .map-control-btn:hover {
  background: #3a424c;
  color: var(--ink);
  border-color: var(--text-muted);
}
body.dark-mode .map-truncation {
  background: rgba(46, 53, 62, 0.95);
  border-color: var(--border);
  color: var(--text-secondary);
}
body.dark-mode .cite-panel-toggle {
  background: #2e353e;
  border-color: var(--border);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
body.dark-mode .cite-panel-toggle:hover { background: #3a424c; }
body.dark-mode .cite-panel {
  background: #2e353e;
  border-left-color: var(--border);
  box-shadow: -8px 0 24px rgba(0,0,0,0.5);
}
body.dark-mode .cite-panel-header { border-bottom-color: var(--border); }
body.dark-mode .cite-panel-close:hover { background: #3a424c; }
body.dark-mode .cite-pill {
  background: #3a424c;
  border-color: var(--border);
  color: var(--ink);
}
body.dark-mode .cite-pill:hover { background: #454e59; }
body.dark-mode .cite-pill-weight { background: #2e353e; color: var(--text-muted); }

/* Nav: tone down the gold § icon and bottom border */
body.dark-mode .nav { border-bottom-color: rgba(255,255,255,0.08); }
body.dark-mode .nav-logo-icon { background: var(--irc-pale); color: var(--irc); }

/* Homepage: section-row title and borders use hardcoded colors */
body.dark-mode .section-row        { border-top-color: var(--border); }
body.dark-mode .section-row:hover  { background: rgba(255,255,255,0.04); }
body.dark-mode .section-row-title  { color: var(--ink); }
body.dark-mode .sidebar-widget     { background: #2e353e; }

/* Nav dark mode toggle button */
.nav-dark-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  color: rgba(255,255,255,0.65);
  padding: 5px 9px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.nav-dark-btn:hover { background: rgba(255,255,255,0.1); color: white; border-color: rgba(255,255,255,0.35); }
.nav-dark-btn .light-icon { display: none; }
body.dark-mode .nav-dark-btn .dark-icon { display: none; }
body.dark-mode .nav-dark-btn .light-icon { display: flex; }

/* ── Print styles ────────────────────────────────────────────────────────── */
@media print {
  .nav, .footer, .section-sidebar, .section-sticky-header .section-actions,
  .section-back, .reading-progress, .xref-tooltip, #search-overlay,
  .citation-copy-btn, .font-size-btn, .collapse-arrow, .collapse-bulk-btn { display: none !important; }
  /* Print always shows full text — ignore any collapsed state */
  body.collapse-mode .collapsed > * { display: revert !important; }

  body { background: white; color: black; font-size: 11pt; }
  * { background: transparent !important; box-shadow: none !important; }

  .section-layout { display: block; }
  .section-main { padding: 0; max-width: 100%; }
  .section-sticky-header { position: static; box-shadow: none; border-bottom: 1px solid #ccc; margin-bottom: 16pt; }
  .section-content { font-size: 11pt; line-height: 1.6; color: black; }
  body.font-small .section-content { font-size: 9pt; }
  body.font-large .section-content { font-size: 13pt; }
  .section-body { padding: 0; }

  a[href]::after { content: none; }
  .uslm-ref { border-bottom: none; color: black; font-weight: inherit; }
}
