/* ── Design tokens ── */

:root {
  /* Color — warm, authoritative palette */
  --fg:          #1c1917;
  --fg-muted:    #57534e;
  --fg-faint:    #a8a29e;
  --bg:          #f5f5f4;
  --surface:     #ffffff;
  --surface-alt: #fafaf9;
  --accent:      #1e40af;
  --accent-hover:#1e3a8a;
  --accent-light:#dbeafe;
  --border:      #d6d3d1;
  --border-light:#e7e5e4;
  --hover-bg:    #f5f5f4;
  --active-bg:   #dbeafe;
  --overlay:     rgba(0,0,0,0.35);

  /* Type scale */
  --text-xs:  12px;
  --text-sm:  13px;
  --text-base:15px;
  --text-md:  16px;
  --text-lg:  18px;
  --text-xl:  22px;
  --text-2xl: 28px;
  --text-3xl: 36px;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;

  /* Layout */
  --reading-w:  740px;
  --page-w:     1060px;
  --sidebar-w:  280px;
  --header-h:   56px;
  --radius:     8px;
  --radius-sm:  4px;
}

/* ── Reset ── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: var(--text-base);
  line-height: 1.65;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  height: 100%;
  padding: 0 var(--sp-6);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: var(--text-xl);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  color: var(--fg);
  border-radius: var(--radius-sm);
}
.sidebar-toggle:hover { background: var(--hover-bg); }

.site-name {
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.site-name:hover { text-decoration: none; color: var(--accent); }

#search { flex: 1; margin-left: auto; }

/* (Pagefind UI loaded only on /search/ page via search.js) */

/* ── Layout ── */

.layout { display: flex; }

/* ── Sidebar ── */

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-sm);
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: var(--text-base);
}
.sidebar-title a { color: var(--fg); }
.sidebar-title a:hover { text-decoration: none; }

#toc { flex: 1; overflow-y: auto; padding: var(--sp-1) 0; min-height: 0; }

/* When section outline is present, limit TOC height to share space */
#sidebar:has(.section-outline) #toc { flex: 1; max-height: 40%; }
#sidebar:has(.section-outline) .section-outline { flex: 1; }

.nav-node { user-select: none; }

.nav-label {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  cursor: pointer;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}
.nav-label:hover { background: var(--hover-bg); }
.nav-label.active { background: var(--active-bg); font-weight: 600; }

.nav-toggle {
  width: 14px;
  flex-shrink: 0;
  text-align: center;
  color: var(--fg-faint);
  font-size: 10px;
}

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}

.nav-section .nav-text { color: var(--accent); }
.nav-group > .nav-label .nav-text { font-weight: 600; color: var(--fg-muted); font-size: 12px; }

.nav-children { display: none; padding-left: var(--sp-3); }
.nav-node.open > .nav-children { display: block; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ── Main content ── */

main {
  flex: 1;
  min-width: 0;
  padding: var(--sp-8) var(--sp-10) var(--sp-20);
  max-width: var(--page-w);
  margin: 0 auto;
}

/* When sidebar is present, don't center — let flex handle it */
#sidebar ~ main {
  margin: 0;
  max-width: var(--reading-w);
}

main h1 { font-size: var(--text-2xl); margin-bottom: var(--sp-3); line-height: 1.25; letter-spacing: -0.01em; }

/* ── Breadcrumb ── */

.breadcrumb {
  font-size: var(--text-sm);
  margin-bottom: var(--sp-5);
  color: var(--fg-muted);
}
.breadcrumb a { color: var(--fg-muted); }
.breadcrumb a:hover { color: var(--accent); }

/* ── Shared page subtitle ── */

.page-sub, .home-sub {
  color: var(--fg-muted);
  font-size: var(--text-md);
  margin-bottom: var(--sp-8);
}

/* ── Homepage ── */

.home {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 0 var(--sp-6) var(--sp-20);
}

.home-hero {
  text-align: center;
  padding: var(--sp-20) 0 var(--sp-12);
}

.home-hero h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--sp-3);
  letter-spacing: -0.02em;
}
.home-hero .home-sub { margin-bottom: var(--sp-6); font-size: var(--text-lg); }

#home-search { max-width: 560px; margin: 0 auto; }

.home-wip {
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--fg-faint);
  margin-bottom: var(--sp-6);
}

.home-vfv {
  margin-top: var(--sp-6);
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.collections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-12);
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.collection {
  display: block;
  padding: var(--sp-6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.collection:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.collection h2 { font-size: var(--text-lg); margin-bottom: var(--sp-2); }
.collection p { font-size: var(--text-base); color: var(--fg-muted); margin: 0; }

.collection-status {
  display: inline-block;
  margin-top: var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.collection-soon { opacity: 0.5; pointer-events: none; }
.collection-soon .collection-status { color: var(--fg-muted); }

/* ── Title table (USC index) ── */

.title-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.title-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: var(--header-h);
  background: var(--bg);
  z-index: 2;
}
.title-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  vertical-align: baseline;
}
.title-table tbody tr { transition: background 0.1s; }
.title-table tbody tr:hover { background: var(--surface); }
.title-table a { text-decoration: none; }
.title-table a:hover { text-decoration: underline; }
.col-num { width: 56px; font-weight: 600; }
.col-count { text-align: right; color: var(--fg-muted); font-size: var(--text-sm); white-space: nowrap; }

/* ── Reserved title rows ── */

.title-table tr.reserved,
.stats-table tr.reserved {
  color: var(--fg-faint);
  font-style: italic;
}

.col-source, .col-date {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  white-space: nowrap;
}

.col-source a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.col-source a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ── Collection body (shared by USC TOC + Constitution) ── */

.collection-body {
  max-width: var(--reading-w);
  line-height: 1.7;
}

.collection-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin: var(--sp-10) 0 var(--sp-6);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
}
.collection-divider::before,
.collection-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.collection-part {
  margin-bottom: var(--sp-8);
}

.collection-part-heading {
  font-size: var(--text-xl);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--border);
}

/* ── Collection: section blocks (shared heading pattern) ── */

.collection-section {
  margin: var(--sp-5) 0;
}

.collection-section-heading {
  font-size: var(--text-base);
  font-weight: 400;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.collection-section-num {
  font-weight: 700;
  white-space: nowrap;
}

.collection-section-topic {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-style: italic;
}

/* ── Collection: inline text (Constitution) ── */

.collection-text {
  font-size: var(--text-base);
}
.collection-text p { margin: var(--sp-2) 0; }
.collection-text .num { font-weight: 700; }
.collection-text .clause { margin-left: var(--sp-5); margin-top: var(--sp-2); }
.collection-text .section { margin-top: var(--sp-3); }

/* ── Collection: TOC links (USC) ── */

.collection-toc { list-style: none; padding-left: 0; }
.collection-toc .collection-toc { padding-left: var(--sp-6); }

.collection-toc-group {
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--sp-3) 0 var(--sp-1);
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.collection-toc-item { font-size: var(--text-base); padding: 2px 0; }
.collection-toc-item a { display: block; padding: var(--sp-1) 0; }

/* Chapter cards on title pages */
.collection-chapter {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: var(--fg);
  transition: background 0.1s;
}
.collection-chapter:first-child,
.collection-divider + .collection-chapter {
  border-top: 1px solid var(--border-light);
}
.collection-chapter:hover {
  background: var(--surface);
  text-decoration: none;
}

.collection-chapter-label {
  font-weight: 500;
}

.collection-chapter-count {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Collection: grouped sections (Constitution amendments) ── */

.collection-group {
  margin: var(--sp-8) 0;
  border-left: 3px solid var(--accent-light);
  padding-left: var(--sp-5);
}

.collection-group-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}

.collection-group-name {
  font-size: var(--text-lg);
  margin: 0;
}

.collection-group-meta {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

/* Constitution-specific detail page topic */
.const-detail-topic {
  color: var(--fg-muted);
  font-size: var(--text-md);
  font-style: italic;
  margin-bottom: var(--sp-4);
}

/* ── Section content ── */

[data-pagefind-filter] { display: none; }

.section-content {
  margin-top: var(--sp-2);
  line-height: 1.8;
  max-width: var(--reading-w);
}
.section-content p { margin: var(--sp-3) 0; }
.section-content .num { font-weight: 700; }
.section-content .subsection { margin-left: 0; margin-top: var(--sp-4); }
.section-content .paragraph { margin-left: var(--sp-6); }
.section-content .subparagraph { margin-left: var(--sp-6); }
.section-content .clause { margin-left: var(--sp-6); }
.section-content .subclause { margin-left: var(--sp-6); }

.section-content h2 { font-size: var(--text-xl); margin-top: var(--sp-8); margin-bottom: var(--sp-2); }
.section-content h3 { font-size: var(--text-lg); margin-top: var(--sp-6); margin-bottom: var(--sp-2); }
.section-content h4,
.section-content h5,
.section-content h6 { font-size: var(--text-md); margin-top: var(--sp-5); margin-bottom: var(--sp-2); }

.xref {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}
.xref:hover { text-decoration-color: var(--accent); }

/* ── Section prev/next nav ── */

.section-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-top: var(--sp-12);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  max-width: var(--reading-w);
}
.section-nav a { max-width: 45%; }
.nav-next { margin-left: auto; text-align: right; }

/* ── Stats page ── */

.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-4);
  margin: var(--sp-8) 0;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5) var(--sp-6);
  text-align: center;
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-top: var(--sp-2);
}

.stats-note {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin: var(--sp-4) 0 var(--sp-8);
  line-height: 1.7;
  max-width: var(--reading-w);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--sp-10);
}
.stats-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--sp-3) var(--sp-3);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: var(--header-h);
  background: var(--bg);
  z-index: 2;
}
.stats-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-light);
}
.stats-table tbody tr { transition: background 0.1s; }
.stats-table tbody tr:hover { background: var(--surface); }
.stats-table a { text-decoration: none; }
.stats-table a:hover { text-decoration: underline; }

.stats-compact { max-width: 640px; }

.pos-yes { color: var(--accent); font-weight: 600; }
.pos-no { color: var(--fg-faint); }

/* ── Reading progress bar ── */

.reading-progress {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 49;
  transition: transform 0.1s linear;
  pointer-events: none;
}

/* ── Copy-link anchors ── */

.copy-link {
  position: absolute;
  left: -1.3em;
  top: 0;
  font-size: var(--text-sm);
  color: var(--fg-faint);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}
.subsection:hover > .num .copy-link,
.paragraph:hover > .num .copy-link,
.subparagraph:hover > .num .copy-link,
.clause:hover > .num .copy-link,
.subclause:hover > .num .copy-link {
  opacity: 1;
}
.copy-link:hover {
  color: var(--accent);
  text-decoration: none;
}
.copy-link.copied {
  opacity: 1;
  color: var(--accent);
}

/* ── Section outline (in-section navigation) ── */

.section-outline {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.outline-header {
  padding: var(--sp-3) var(--sp-4);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.outline-nav {
  overflow-y: auto;
  padding-bottom: var(--sp-4);
}

.outline-item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  padding: 2px var(--sp-3);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--fg-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.15s, color 0.15s;
}
.outline-item:hover {
  background: var(--hover-bg);
  color: var(--fg);
  text-decoration: none;
}
.outline-item.active {
  border-left-color: var(--accent);
  color: var(--accent);
  background: var(--active-bg);
}

.outline-num {
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.outline-heading {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Subsection-level items are slightly more prominent */
.outline-item[data-level="0"] {
  font-weight: 500;
  color: var(--fg);
}

/* Highlight flash when navigating to a subsection */
.highlight-target {
  animation: outline-flash 1.5s ease-out;
}

@keyframes outline-flash {
  0%   { background: var(--accent-light); }
  100% { background: transparent; }
}

/* ── Cross-reference hover preview ── */

.xref-tooltip {
  position: absolute;
  z-index: 200;
  width: 360px;
  max-width: calc(100vw - 16px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: var(--sp-3) var(--sp-4);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.xref-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.xref-tooltip-header {
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: var(--sp-2);
  color: var(--fg);
}

.xref-tooltip-body {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.5;
  max-height: 120px;
  overflow: hidden;
}

/* ── Back trail (cross-reference navigation) ── */

.back-trail {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  font-size: var(--text-sm);
  flex-wrap: wrap;
}

.back-trail-label {
  color: var(--fg-faint);
  font-weight: 500;
  white-space: nowrap;
}

.back-trail-link {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.back-trail-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ── Cited-by section ── */

.cited-by {
  margin-top: var(--sp-12);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
  max-width: var(--reading-w);
}

.cited-by-heading {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: var(--sp-4);
  color: var(--fg-muted);
}

.cited-by-list {
  list-style: none;
  padding: 0;
  columns: 2;
  column-gap: var(--sp-6);
}

.cited-by-item {
  font-size: var(--text-sm);
  padding: 2px 0;
  break-inside: avoid;
  line-height: 1.5;
}

.cited-by-title {
  color: var(--fg-faint);
  font-size: var(--text-xs);
}

.cited-by-more {
  display: inline-block;
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.cited-by-more:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Mobile section outline ── */

.mobile-outline-btn {
  display: none;
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: var(--text-lg);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 90;
  transition: transform 0.15s, box-shadow 0.15s;
}
.mobile-outline-btn:active {
  transform: scale(0.95);
}

.mobile-outline-dropdown {
  display: none;
  position: fixed;
  bottom: 72px;
  right: var(--sp-5);
  width: 280px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 91;
  padding: var(--sp-2) 0;
}
.mobile-outline-dropdown.open {
  display: block;
}

.mobile-outline-item {
  display: block;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--fg);
  text-decoration: none;
  transition: background 0.1s;
}
.mobile-outline-item:hover {
  background: var(--hover-bg);
  text-decoration: none;
}

/* ── Footer ── */

.site-footer {
  padding: var(--sp-8) var(--sp-6) var(--sp-8);
  font-size: var(--text-sm);
  color: var(--fg-muted);
  border-top: 1px solid var(--border);
  text-align: center;
  background: var(--surface);
}
.footer-inner { max-width: var(--page-w); margin: 0 auto; }
.disclaimer {
  margin-top: var(--sp-3);
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--fg-faint);
}

/* ── Search redirect (header + homepage) ── */

.search-redirect { display: flex; }
.search-redirect-input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s;
}
.search-redirect-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

/* ── Search page ── */

.search-page {
  max-width: var(--page-w);
}

.search-page h1 {
  margin-bottom: var(--sp-5);
}

.search-form {
  margin-bottom: var(--sp-3);
}

.search-form input[type="search"] {
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-lg);
  background: var(--surface);
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s;
}
.search-form input[type="search"]:focus {
  border-color: var(--accent);
}

.search-filters {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  flex-wrap: wrap;
}

.search-filters select {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  outline: none;
  min-width: 160px;
  transition: border-color 0.15s;
}
.search-filters select:focus {
  border-color: var(--accent);
}
.search-filters select.filter-hidden {
  display: none;
}

.search-help {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-bottom: var(--sp-8);
}
.search-help a {
  display: inline-block;
  padding: 2px 10px;
  margin: 2px 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.search-help a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* Structural results */
#structural-results {
  margin-bottom: var(--sp-6);
}
#structural-results.has-results {
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: var(--sp-6);
}

.sr-item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
  transition: background 0.1s;
}
a.sr-item:hover {
  background: var(--surface);
  text-decoration: none;
}

.sr-icon {
  font-size: var(--text-lg);
  color: var(--accent);
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.sr-label {
  font-weight: 600;
  white-space: nowrap;
}

.sr-desc {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-hint {
  flex-direction: column;
  gap: var(--sp-1);
  color: var(--fg-muted);
  font-style: italic;
}
.sr-hint .sr-label { font-weight: 400; }

/* Full-text results */
.fulltext-section {
  margin-top: var(--sp-2);
}

#fulltext-status {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-bottom: var(--sp-4);
}

.ft-item {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
  transition: background 0.1s;
  margin-bottom: var(--sp-1);
}
.ft-item:hover {
  background: var(--surface);
  text-decoration: none;
}

.ft-title {
  display: block;
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: var(--sp-1);
  color: var(--accent);
}

.ft-excerpt {
  display: block;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.5;
}
.ft-excerpt mark {
  background: var(--accent-light);
  color: var(--fg);
  padding: 0 2px;
  border-radius: 2px;
}

.ft-more {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--fg-faint);
  font-style: italic;
}

/* ── About page ── */

.about { max-width: var(--reading-w); line-height: 1.8; }
.about h2 { font-size: var(--text-lg); margin-top: var(--sp-10); margin-bottom: var(--sp-3); }
.about p { margin: var(--sp-3) 0; }
.about ul { margin: var(--sp-3) 0 var(--sp-3) var(--sp-6); }
.about li { margin: var(--sp-2) 0; }

/* ── Responsive ── */

@media (max-width: 768px) {
  .sidebar-toggle { display: block; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }

  main {
    padding: var(--sp-5) var(--sp-5) var(--sp-16);
    max-width: 100%;
  }
  main h1 { font-size: var(--text-xl); }

  .home { padding: 0 var(--sp-5) var(--sp-16); }
  .home-hero { padding: var(--sp-12) 0 var(--sp-8); }
  .home-hero h1 { font-size: var(--text-2xl); }
  .collections { grid-template-columns: 1fr; }

  .title-table th { position: static; }
  .title-table { font-size: var(--text-sm); }
  .title-table td, .title-table th { padding: var(--sp-2) var(--sp-3); }

  .section-content .paragraph,
  .section-content .subparagraph,
  .section-content .clause,
  .section-content .subclause { margin-left: var(--sp-4); }

  .section-nav { flex-direction: column; }
  .section-nav a { max-width: 100%; }

  .stats-table { display: block; overflow-x: auto; }
  .stats-table th { position: static; }
  .stats-summary { grid-template-columns: repeat(3, 1fr); }

  .mobile-outline-btn { display: block; }
  .xref-tooltip { width: 260px; }
}

@media (max-width: 480px) {
  .stats-summary { grid-template-columns: repeat(2, 1fr); }
  .col-source, .col-date { display: none; }
}
