/* ===== 1. Design System (SZD Family) ===== */
:root {
  --sz-burgundy: #631a34;
  --sz-burgundy-dark: #4A1228;
  --sz-burgundy-light: #7A2D45;
  --sz-gold: #C2A360;
  --sz-gold-light: #D4B87A;
  --sz-cream: #FAF8F3;
  --sz-white: #FFFFFF;
  --sz-text: #2D2D2D;
  --sz-text-light: #6B6B6B;
  --sz-border: #E0D8CC;
  --sz-border-light: #EDE8DF;
  --sz-success: #2d6a2d;
  --sz-success-bg: #d4e8d4;
  --sz-warning: #8a6914;
  --sz-warning-bg: #f0e4c0;
  --sz-danger: #a0522d;
  --sz-danger-bg: #e8d4c4;
  --sz-img-bg: #e8e4de;
  --diff-a-bg: #fde8e8;
  --diff-a-text: #991b1b;
  --diff-a-border: rgba(153, 27, 27, 0.25);
  --diff-b-bg: #dbeafe;
  --diff-b-text: #1e40af;
  --diff-b-border: rgba(30, 64, 175, 0.25);
  --diff-edit-old-bg: #fef3c7;
  --diff-edit-old-text: #92400e;
  --diff-edit-old-border: rgba(146, 64, 14, 0.25);
  --diff-edit-new-bg: #d1fae5;
  --diff-edit-new-text: #065f46;
  --diff-edit-new-border: rgba(6, 95, 70, 0.25);
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, 'Courier New', monospace;
  /* Review trust tiers (dark green → green → slate → gray → amber) */
  --sz-review-verified: #1a5c1a;
  --sz-review-verified-bg: #c8e6c8;
  --sz-review-approved: #2d6a2d;
  --sz-review-approved-bg: #d4e8d4;
  --sz-review-auto: #475569;
  --sz-review-auto-bg: #e2e8f0;
  --sz-review-unchecked: #4b5563;
  --sz-review-unchecked-bg: #e5e7eb;
  --sz-review-flagged: #b45309;
  --sz-review-flagged-bg: #fef3c7;
  --max-width: 1400px;
  --header-height: 56px;
  --transition: 0.15s ease;
}

/* ===== 2. Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.is-hidden { display: none !important; }

::selection {
  background: var(--sz-burgundy);
  color: var(--sz-cream);
}

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  background: var(--sz-cream);
  color: var(--sz-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== 3. Typography ===== */
h1, h2, h3 { font-family: var(--font-serif); font-weight: 400; }
a { color: var(--sz-burgundy); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--sz-burgundy-dark); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===== 3a. Focus & Skip Link ===== */
:focus-visible {
  outline: 2px solid var(--sz-burgundy);
  outline-offset: 2px;
}

.catalog__search-input:focus-visible,
.catalog__filter:focus-visible,
.viewer__transcription-edit:focus-visible,
.viewer__notes-edit:focus-visible {
  outline: none;
  border-color: var(--sz-burgundy);
  box-shadow: 0 0 0 2px rgba(99, 26, 52, 0.15);
}

.catalog__table tbody tr:focus-visible {
  box-shadow: inset 3px 0 0 var(--sz-burgundy);
  background: rgba(99, 26, 52, 0.03);
  outline: none;
}

.site-header__nav a:focus-visible,
.site-header__nav button:focus-visible {
  color: var(--sz-white);
  border-bottom-color: var(--sz-gold);
  outline: none;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 999;
  background: var(--sz-burgundy);
  color: var(--sz-white);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus { top: 0; }

/* ===== 4. Header ===== */
.site-header {
  height: var(--header-height);
  background: var(--sz-burgundy);
  color: var(--sz-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.site-header__title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--sz-white);
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.site-header__subtitle {
  font-size: 0.65rem;
  opacity: 0.55;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
  font-style: italic;
}

.site-header__badge {
  font-family: var(--font-sans);
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  white-space: nowrap;
}

.site-header__badge strong {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-header__catalog-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-header__nav a,
.site-header__nav button {
  color: rgba(255,255,255,0.8);
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.15rem;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.site-header__nav a:hover,
.site-header__nav button:hover {
  color: var(--sz-white);
  border-bottom-color: var(--sz-gold);
}

.site-header__back {
  display: none;
}

body:not(.view-catalog) .site-header__back { display: inline-flex; align-items: center; gap: 0.3rem; }
body.view-viewer .site-header__catalog-nav { display: none; }

/* ===== 5. Footer ===== */
.site-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sz-border);
  font-size: 0.75rem;
  color: var(--sz-text-light);
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
}

.site-footer a { color: var(--sz-burgundy); }

body.view-viewer .site-footer { display: none; }

/* ===== 6. View Toggle ===== */
body.view-catalog #viewer,
body.view-catalog #knowledge,
body.view-catalog #knowledgeDoc,
body.view-catalog #about,
body.view-catalog #help,
body.view-catalog #stats { display: none; }

body.view-viewer #catalog,
body.view-viewer #knowledge,
body.view-viewer #knowledgeDoc,
body.view-viewer #about,
body.view-viewer #help,
body.view-viewer #stats { display: none; }

body.view-knowledge #catalog,
body.view-knowledge #viewer,
body.view-knowledge #knowledgeDoc,
body.view-knowledge #about,
body.view-knowledge #help,
body.view-knowledge #stats { display: none; }

body.view-knowledge-doc #catalog,
body.view-knowledge-doc #viewer,
body.view-knowledge-doc #knowledge,
body.view-knowledge-doc #about,
body.view-knowledge-doc #help,
body.view-knowledge-doc #stats { display: none; }

body.view-about #catalog,
body.view-about #viewer,
body.view-about #knowledge,
body.view-about #knowledgeDoc,
body.view-about #help,
body.view-about #stats { display: none; }

body.view-help #catalog,
body.view-help #viewer,
body.view-help #knowledge,
body.view-help #knowledgeDoc,
body.view-help #about,
body.view-help #stats { display: none; }

body.view-stats #catalog,
body.view-stats #viewer,
body.view-stats #knowledge,
body.view-stats #knowledgeDoc,
body.view-stats #about,
body.view-stats #help { display: none; }

/* ===== 7. Catalog View ===== */
.catalog {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  flex: 1;
}

/* Stats bar */
.catalog__stats {
  background: var(--sz-white);
  border: 1px solid var(--sz-border);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  color: var(--sz-text);
}

.catalog__stats-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.catalog__stats-total {
  font-weight: 600;
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  color: var(--sz-burgundy);
}

.catalog__stats-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.catalog__stats-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--sz-border-light);
  font-size: 0.72rem;
  color: var(--sz-text-light);
  white-space: nowrap;
}

.catalog__stats-chip strong {
  color: var(--sz-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.catalog__stats-toggle {
  border: none;
  background: none;
  color: var(--sz-burgundy);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  white-space: nowrap;
}

.catalog__stats-toggle:hover {
  text-decoration: underline;
}

.catalog__stats-details {
  display: none;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--sz-border-light);
  font-size: 0.78rem;
}

.catalog__stats-details.open {
  display: block;
}

.catalog__stats-section {
  margin-bottom: 0.5rem;
}

.catalog__stats-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sz-gold);
  margin-bottom: 0.25rem;
}

.catalog__stats-bar {
  display: flex;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
}

.catalog__stats-bar-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--sz-text-light);
}

.catalog__stats-bar-item strong {
  color: var(--sz-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.catalog__stats-review {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--sz-burgundy);
  font-size: 0.78rem;
}

.catalog__toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.catalog__search {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.catalog__search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--sz-border);
  border-radius: 4px;
  font-size: 0.875rem;
  background: var(--sz-white);
  color: var(--sz-text);
  transition: border-color var(--transition);
}

.catalog__search-input:focus {
  outline: none;
  border-color: var(--sz-burgundy);
}

.catalog__search::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.9rem;
  height: 0.9rem;
  pointer-events: none;
  background: currentColor;
  color: var(--sz-text-light);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") center/contain no-repeat;
}

.catalog__filter {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--sz-border);
  border-radius: 4px;
  background: var(--sz-white);
  font-size: 0.8125rem;
  color: var(--sz-text);
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: auto;
}

.catalog__filter:focus { outline: none; border-color: var(--sz-burgundy); }

.catalog__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--sz-text);
  cursor: pointer;
  white-space: nowrap;
}

.catalog__toggle input {
  accent-color: var(--sz-burgundy);
}

.catalog__filter--active {
  border-color: var(--sz-burgundy);
  background: rgba(99, 26, 52, 0.04);
}

.catalog__active-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 0;
}

.catalog__active-filters:empty { display: none; }

.catalog__filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--sz-burgundy-light);
  border-radius: 12px;
  background: rgba(99, 26, 52, 0.06);
  font-size: 0.75rem;
  color: var(--sz-burgundy);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.catalog__filter-chip:hover {
  background: rgba(99, 26, 52, 0.14);
  border-color: var(--sz-burgundy);
}

.catalog__filter-chip-x {
  font-size: 0.85em;
  line-height: 1;
  opacity: 0.6;
}

.catalog__filter-chip:hover .catalog__filter-chip-x { opacity: 1; }

.catalog__filter-chip--reset {
  background: transparent;
  border-color: var(--sz-border);
  color: var(--sz-text-light);
}

.catalog__filter-chip--reset:hover {
  border-color: var(--sz-burgundy-light);
  color: var(--sz-burgundy);
  background: rgba(99, 26, 52, 0.04);
}

/* Table */
.catalog__table-wrap {
  background: var(--sz-white);
  border: 1px solid var(--sz-border);
  border-radius: 6px;
  overflow-x: auto;
}

.catalog__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.catalog__table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sz-text-light);
  border-bottom: 2px solid var(--sz-border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.catalog__table th:hover { color: var(--sz-burgundy); }

.catalog__table th.sorted { color: var(--sz-burgundy); }

.catalog__table th .sort-arrow {
  margin-left: 0.3rem;
  font-size: 0.65rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.catalog__table th:hover .sort-arrow { opacity: 0.4; }
.catalog__table th.sorted .sort-arrow { opacity: 1; color: var(--sz-burgundy); }

.catalog__table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--sz-border-light);
  vertical-align: middle;
}

.catalog__table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}

.catalog__table tbody tr:hover {
  background: rgba(99, 26, 52, 0.03);
  box-shadow: inset 3px 0 0 var(--sz-burgundy);
}
.catalog__table tbody tr:last-child td { border-bottom: none; }

.catalog__table .col-thumb { width: 56px; padding: 0.3rem 0.5rem; }
.catalog__table .col-thumb img {
  width: 40px; height: 56px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--sz-border-light);
  display: block;
  background: var(--sz-border-light);
  font-size: 0;
}
.catalog__table .col-title {
  min-width: 180px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sz-burgundy);
  font-weight: 500;
}
.catalog__table tbody tr:hover .col-title { text-decoration: underline; text-underline-offset: 2px; }
.catalog__table .col-sig { width: 140px; white-space: nowrap; }
.catalog__table .col-pid { width: 100px; font-family: var(--font-mono); font-size: 0.78rem; }
.catalog__table .col-collection { width: 130px; }
.catalog__table .col-group { width: 145px; white-space: nowrap; }
.catalog__table .col-lang { width: 80px; }
.catalog__table .col-review { width: 60px; text-align: center; }
.catalog__table .col-quality { width: 110px; }
.catalog__table .col-pages { width: 50px; text-align: right; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}


.badge-markers {
  font-weight: 500;
  font-size: 0.72rem;
}

.badge-markers-clean { background: var(--sz-success-bg); color: var(--sz-success); }
.badge-markers-some { background: var(--sz-warning-bg); color: var(--sz-warning); }
.badge-markers-many { background: var(--sz-danger-bg); color: var(--sz-danger); }

/* Prompt group badge */
.badge-prompt {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.08rem 0.35rem;
  border-radius: 3px;
  background: rgba(99, 26, 52, 0.08);
  color: var(--sz-burgundy);
  letter-spacing: 0.02em;
  cursor: help;
}

/* Consensus badges */
.badge-consensus { font-size: 0.68rem; font-weight: 600; text-transform: capitalize; }

/* Diff button inline consensus status */
.diff-btn__status {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.05rem 0.3rem;
  border-radius: 2px;
  margin-left: 0.15rem;
}
.diff-btn__status--verified { background: var(--sz-success-bg); color: var(--sz-success); }
.diff-btn__status--moderate { background: var(--sz-warning-bg); color: var(--sz-warning); }
.diff-btn__status--review { background: var(--sz-danger-bg); color: var(--sz-danger); }
.diff-btn__status--divergent { background: var(--sz-danger-bg); color: #991b1b; }
.badge-consensus-verified { background: var(--sz-success-bg); color: var(--sz-success); }
.badge-consensus-moderate { background: var(--sz-warning-bg); color: var(--sz-warning); }
.badge-consensus-review { background: var(--sz-danger-bg); color: var(--sz-danger); }
.badge-consensus-divergent { background: var(--sz-danger-bg); color: #991b1b; }

/* Per-page agreement dot */
.viewer__page-agreement { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 0.3rem; vertical-align: middle; background: var(--sz-text-light); }
.agreement-high { background: var(--sz-success); }
.agreement-moderate { background: var(--sz-warning); }
.agreement-low { background: var(--sz-danger); }
.agreement-skipped { background: var(--sz-text-light); }

/* Empty state placeholder */
.placeholder-message {
  color: var(--sz-text-light);
  font-style: italic;
  padding: 2rem;
}

/* Source indicator (human vs. machine) */
.indicator-source {
  font-size: 0.65em;
  opacity: 0.45;
  margin-left: 0.15em;
  font-style: normal;
  font-weight: 400;
}

/* DWR score badges */
.badge-dwr-good { background: var(--sz-success-bg); color: var(--sz-success); }
.badge-dwr-moderate { background: var(--sz-warning-bg); color: var(--sz-warning); }
.badge-dwr-low { background: var(--sz-danger-bg); color: var(--sz-danger); }

/* Page type badges */
.badge-page-type { font-size: 0.65rem; padding: 0.1rem 0.35rem; border-radius: 3px; margin-left: 0.3rem; font-weight: 500; }
.badge-page-blank { background: var(--sz-border-light); color: var(--sz-text-light); }
.badge-page-chart { background: var(--sz-warning-bg); color: var(--sz-gold); }

/* Review status badges — unified 5-tier pill system */
.badge-review {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-review-verified {
  background: var(--sz-review-verified-bg);
  color: var(--sz-review-verified);
}

.badge-review-approved {
  background: var(--sz-review-approved-bg);
  color: var(--sz-review-approved);
}

.badge-review-auto {
  background: var(--sz-review-auto-bg);
  color: var(--sz-review-auto);
}

.badge-review-unchecked {
  background: var(--sz-review-unchecked-bg);
  color: var(--sz-review-unchecked);
}

.badge-review-flagged {
  background: var(--sz-review-flagged-bg);
  color: var(--sz-review-flagged);
}

.catalog__stats-chip--agent {
  background: var(--sz-review-auto-bg);
  color: var(--sz-review-auto);
}

/* Page anomaly marker */
.viewer__page-anomaly {
  color: var(--sz-burgundy);
  font-size: 0.6rem;
  margin-left: 0.2rem;
}

/* Pagination */
.catalog__pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  font-size: 0.8125rem;
  color: var(--sz-text-light);
}

.catalog__pagination-info { font-variant-numeric: tabular-nums; }

.catalog__pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.catalog__page-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--sz-border);
  border-radius: 4px;
  background: var(--sz-white);
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--sz-text);
}

.catalog__page-btn:hover:not(:disabled) {
  border-color: var(--sz-burgundy);
  color: var(--sz-burgundy);
}

.catalog__page-btn:focus-visible {
  outline: 2px solid var(--sz-burgundy);
  outline-offset: 2px;
}

.catalog__page-btn:disabled {
  color: var(--sz-border);
  background: var(--sz-border-light);
  opacity: 1;
  cursor: default;
}

.catalog__empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--sz-text-light);
  font-style: italic;
}

/* ===== 8. Viewer View ===== */
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - var(--header-height));
}

/* Metadata bar */
.viewer__meta {
  padding: 0.3rem 1.25rem;
  background: var(--sz-white);
  border-bottom: 1px solid var(--sz-border);
  font-size: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.75rem;
  align-items: baseline;
}

.viewer__meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
}

.viewer__meta-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sz-gold);
}

.viewer__meta-value {
  color: var(--sz-text);
}

.viewer__meta-link {
  color: var(--sz-burgundy);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--sz-gold-light);
}

.viewer__meta-link::after {
  content: " \2197";
  font-size: 0.7rem;
}

.viewer__meta-title {
  font-weight: 600;
}

.viewer__meta-model {
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.viewer__meta-review {
  gap: 0.4rem;
}

.catalog__stats-chip--review-warn { background: var(--sz-review-flagged-bg); color: var(--sz-review-flagged); }
.catalog__stats-chip--llm-ok { background: var(--sz-review-unchecked-bg); color: var(--sz-review-unchecked); }
.catalog__stats-chip--verified { background: var(--sz-review-verified-bg); color: var(--sz-review-verified); }
.catalog__stats-chip--approved { background: var(--sz-review-approved-bg); color: var(--sz-review-approved); }
.catalog__stats-chip--consensus { background: #dbeafe; }

/* Navigation bar */
.viewer__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 1.25rem;
  background: var(--sz-white);
  border-bottom: 1px solid var(--sz-border);
  gap: 0.35rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.viewer__nav-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.viewer__nav-btn {
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--sz-border);
  border-radius: 50%;
  background: var(--sz-white);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--sz-text);
}

.viewer__nav-btn:hover:not(:disabled) {
  border-color: var(--sz-burgundy);
  color: var(--sz-burgundy);
}

.viewer__nav-btn:focus-visible {
  outline: 2px solid var(--sz-burgundy);
  outline-offset: 2px;
}

.viewer__nav-btn:disabled {
  color: var(--sz-border);
  opacity: 1;
  cursor: default;
}

.viewer__page-info {
  font-size: 0.8125rem;
  font-weight: 600;
  min-width: 8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  transition: background var(--transition);
}

.viewer__page-info:hover {
  background: rgba(99, 26, 52, 0.06);
}

.viewer__nav-sep {
  width: 1px;
  height: 1.4rem;
  background: var(--sz-border);
  margin: 0 0.15rem;
}

.viewer__nav-btn--tool {
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.8rem;
  border-color: transparent;
  background: transparent;
  color: var(--sz-text-light);
}

.viewer__nav-btn--tool:hover:not(:disabled) {
  background: rgba(99, 26, 52, 0.06);
  color: var(--sz-burgundy);
  border-color: transparent;
}

.viewer__scan-info {
  font-size: 0.68rem;
  color: var(--sz-text-light);
  font-weight: 400;
}

.viewer__page-jump {
  width: 6ch;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: none;
  border-bottom: 2px solid var(--sz-burgundy);
  background: transparent;
  color: var(--sz-text);
  outline: none;
  padding: 0;
  -moz-appearance: textfield;
}

.viewer__page-jump::-webkit-inner-spin-button,
.viewer__page-jump::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.viewer__obj-info {
  font-size: 0.72rem;
  color: var(--sz-text-light);
}

/* Action buttons */
.viewer__action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--sz-border);
  border-radius: 4px;
  background: var(--sz-white);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--sz-text);
  transition: all var(--transition);
}

.viewer__action-btn:hover:not(:disabled) {
  border-color: var(--sz-burgundy);
  color: var(--sz-burgundy);
}

.viewer__action-btn:focus-visible {
  outline: 2px solid var(--sz-burgundy);
  outline-offset: 2px;
}

.viewer__action-btn:disabled {
  color: var(--sz-border);
  background: var(--sz-border-light);
  border-color: var(--sz-border-light);
  opacity: 1;
  cursor: default;
}

.viewer__action-btn.active {
  background: var(--sz-burgundy);
  color: var(--sz-white);
  border-color: var(--sz-burgundy);
}

.viewer__action-btn.approved {
  background: var(--sz-success);
  color: var(--sz-white);
  border-color: var(--sz-success);
}

.viewer__action-btn .indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sz-gold);
  display: none;
}

.viewer__action-btn .indicator.visible { display: inline-block; }

/* Split panels */
.viewer__panels {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.06);
}

.viewer__img-panel,
.viewer__text-panel,
.viewer__diff-panel {
  min-height: 0;
}

.viewer__panel-label {
  padding: 0.15rem 1rem;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sz-text-light);
  background: var(--sz-border-light);
  border-bottom: 1px solid var(--sz-border);
}

.viewer__panel-label:last-of-type {
  border-left: 1px solid var(--sz-border);
}

.viewer__img-panel {
  overflow: hidden;
  background: var(--sz-img-bg);
  position: relative;
  cursor: grab;
}

.viewer__img-panel.dragging { cursor: grabbing; }

.viewer__img-wrapper {
  position: relative;
  display: inline-block;
  transform-origin: 0 0;
}

.viewer__img-panel img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Fit-to-height: whole page visible, centered (default) */
.viewer__img-panel.fit-height .viewer__img-wrapper {
  width: 100%;
  height: 100%;
}
.viewer__img-panel.fit-height img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Fit-to-width: full width, scroll vertically */
.viewer__img-panel.fit-width .viewer__img-wrapper {
  width: 100%;
}
.viewer__img-panel.fit-width img {
  width: 100%;
  height: auto;
}

/* --- Layout overlay --- */
.viewer__layout-overlay {
  position: absolute;
  pointer-events: none;
  /* top/left/width/height set by syncLayoutOverlayPosition() */
}
.viewer__layout-overlay rect {
  pointer-events: auto;
  cursor: pointer;
  stroke-width: 0.3;
  rx: 0.2;
}
.layout-region--paragraph   { fill: rgba(59, 130, 246, 0.12); stroke: rgba(59, 130, 246, 0.6); }
.layout-region--heading     { fill: rgba(234, 88, 12, 0.12); stroke: rgba(234, 88, 12, 0.6); }
.layout-region--list        { fill: rgba(22, 163, 74, 0.12); stroke: rgba(22, 163, 74, 0.6); }
.layout-region--table       { fill: rgba(147, 51, 234, 0.12); stroke: rgba(147, 51, 234, 0.6); }
.layout-region--marginalia  { fill: rgba(220, 38, 38, 0.12); stroke: rgba(220, 38, 38, 0.6); }
.layout-region--paragraph:hover   { fill: rgba(59, 130, 246, 0.28); }
.layout-region--heading:hover     { fill: rgba(234, 88, 12, 0.28); }
.layout-region--list:hover        { fill: rgba(22, 163, 74, 0.28); }
.layout-region--table:hover       { fill: rgba(147, 51, 234, 0.28); }
.layout-region--marginalia:hover  { fill: rgba(220, 38, 38, 0.28); }
.layout-region-label {
  font-size: 1.8px;
  fill: #333;
  font-weight: 600;
  pointer-events: none;
}
.viewer__nav-btn--layout-active {
  background: var(--sz-burgundy) !important;
  color: #fff !important;
}
.viewer__layout-legend {
  position: absolute;
  bottom: 8px;
  left: 8px;
  display: flex;
  gap: 8px;
  background: rgba(255,255,255,0.92);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  z-index: 3;
  border: 1px solid var(--sz-border-light);
}
.viewer__layout-legend-item {
  display: flex;
  align-items: center;
  gap: 3px;
}
.viewer__layout-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.swatch--paragraph   { background: rgba(59, 130, 246, 0.5); }
.swatch--heading     { background: rgba(234, 88, 12, 0.5); }
.swatch--list        { background: rgba(22, 163, 74, 0.5); }
.swatch--table       { background: rgba(147, 51, 234, 0.5); }
.swatch--marginalia  { background: rgba(220, 38, 38, 0.5); }


.viewer__img-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--sz-text-light);
  font-size: 0.8125rem;
}

.viewer__img-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--sz-text-light);
  font-size: 0.875rem;
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

.viewer__text-panel {
  overflow: auto;
  border-left: 1px solid var(--sz-border);
  background: var(--sz-white);
  display: flex;
  flex-direction: column;
}

.viewer__transcription-wrap {
  flex: 1;
  padding: 1rem 1.25rem;
  overflow: auto;
}

.viewer__transcription {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  line-height: 1.85;
  white-space: pre-wrap;
}

.viewer__transcription del { color: var(--sz-text-light); text-decoration: line-through; }

.viewer__transcription-edit {
  width: 100%;
  min-height: 300px;
  border: 1px solid var(--sz-border);
  border-radius: 4px;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--sz-text);
  background: var(--sz-cream);
  resize: vertical;
}

.viewer__transcription-edit:focus {
  outline: none;
  border-color: var(--sz-burgundy);
}


.viewer__modified-label {
  font-size: 0.6875rem;
  color: var(--sz-gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Context bar (full-width metadata below panels) */
.viewer__context {
  flex-shrink: 0;
  padding: 0.4rem 1.25rem;
  background: var(--sz-white);
  border-top: 1px solid var(--sz-border);
  font-size: 0.72rem;
  color: var(--sz-text-light);
  overflow-y: auto;
  max-height: 20vh;
}

.viewer__ctx-notes {
  font-style: italic;
  color: var(--sz-text);
  margin-bottom: 0.3rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--sz-border-light);
  font-size: 0.75rem;
  line-height: 1.5;
}

.viewer__ctx-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  align-items: center;
  line-height: 1.7;
}

.viewer__ctx-section {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.viewer__ctx-model {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--sz-text-light);
}

.viewer__ctx-dim {
  color: var(--sz-text-light);
  font-size: 0.68rem;
}

/* ===== 8a. Edit Status Bar & Toast ===== */
.viewer__edit-status {
  padding: 0.35rem 1.25rem;
  background: var(--sz-warning-bg);
  border-bottom: 1px solid var(--sz-border);
  font-size: 0.75rem;
  color: var(--sz-text);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.viewer__edit-status-icon {
  font-size: 0.85rem;
}

.viewer__edit-status-text {
  flex: 1;
}

.viewer__edit-status-storage {
  color: var(--sz-text-light);
  font-size: 0.68rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--sz-burgundy-dark);
  color: var(--sz-white);
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* ===== 8b. Diff View ===== */
.viewer__diff-panel {
  background: var(--sz-white);
  overflow: auto;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--sz-border);
}

.diff__header {
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--sz-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.diff__provider-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.diff__provider-label {
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 600;
}
.diff__provider-label--old { background: var(--diff-edit-old-bg); color: var(--diff-edit-old-text); }
.diff__provider-label--new { background: var(--diff-edit-new-bg); color: var(--diff-edit-new-text); }

.diff__provider-a {
  background: var(--diff-a-bg);
  color: var(--diff-a-text);
}

.diff__provider-b {
  background: var(--diff-b-bg);
  color: var(--diff-b-text);
}

.diff__vs {
  font-size: 0.72rem;
  color: var(--sz-text-light);
  font-style: italic;
}

.diff__stats {
  font-size: 0.78rem;
  color: var(--sz-text-light);
  display: flex;
  gap: 1rem;
  align-items: center;
}

.diff__stats-agreement {
  font-weight: 600;
  color: var(--sz-success);
}

.diff__stats-divergent {
  font-weight: 600;
  color: var(--sz-danger);
}

.diff__content {
  flex: 1;
  overflow: auto;
  padding: 1.25rem;
}

.diff__side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.diff__column {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  line-height: 1.85;
  white-space: pre-wrap;
}

.diff__column-header {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sz-text-light);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--sz-border);
}

.diff__word {
  display: inline;
  border-radius: 2px;
  transition: background var(--transition);
}

.diff__word--match {
  color: var(--sz-text);
}

.diff__word--only-a {
  background: var(--diff-a-bg);
  color: var(--diff-a-text);
  text-decoration: line-through;
  text-decoration-color: var(--diff-a-border);
}

.diff__word--only-b {
  background: var(--diff-b-bg);
  color: var(--diff-b-text);
}

.diff__word[data-tooltip]:hover {
  filter: brightness(0.95);
}

.diff__legend {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--sz-border-light);
  font-size: 0.72rem;
  color: var(--sz-text-light);
}

.diff__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.diff__legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.diff__legend-swatch--a { background: var(--diff-a-bg); border: 1px solid var(--diff-a-border); }
.diff__legend-swatch--b { background: var(--diff-b-bg); border: 1px solid var(--diff-b-border); }
.diff__legend-swatch--match { background: var(--sz-border-light); }

/* Edit diff colors (green/amber for agent/human corrections) */
.diff__word--edit-old {
  background: var(--diff-edit-old-bg);
  color: var(--diff-edit-old-text);
  text-decoration: line-through;
  text-decoration-color: var(--diff-edit-old-border);
}

.diff__word--edit-new {
  background: var(--diff-edit-new-bg);
  color: var(--diff-edit-new-text);
}

.diff__legend-swatch--edit-old { background: var(--diff-edit-old-bg); border: 1px solid var(--diff-edit-old-border); }
.diff__legend-swatch--edit-new { background: var(--diff-edit-new-bg); border: 1px solid var(--diff-edit-new-border); }

/* Diff tabs */
.diff__tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--sz-border);
  padding: 0 1.25rem;
}

.diff__tab {
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--sz-text-light);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}

.diff__tab:hover { color: var(--sz-text); }
.diff__tab.active { color: var(--sz-burgundy); border-bottom-color: var(--sz-burgundy); font-weight: 600; }
.diff__tab:disabled { opacity: 0.4; cursor: default; }

.diff__edit-meta {
  font-size: 0.72rem;
  color: var(--sz-text-light);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--sz-border-light);
  margin-bottom: 0.75rem;
}

@media (max-width: 900px) {
  .diff__side-by-side {
    grid-template-columns: 1fr;
  }
}

/* ===== 9. Tooltips ===== */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--sz-burgundy-dark);
  color: var(--sz-white);
  font-size: 0.72rem;
  font-family: var(--font-sans);
  font-weight: 400;
  font-style: normal;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  transition-delay: 0s;
  z-index: 200;
  max-width: 340px;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transition-delay: 0.4s;
}

[data-tooltip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 8px);
}

[data-tooltip-pos="left"]::after {
  bottom: auto;
  top: 50%;
  left: auto;
  right: calc(100% + 8px);
  transform: translateY(-50%);
}

/* ===== 10. Help Page ===== */
.help-page {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  flex: 1;
}

.help-page__content {
  background: var(--sz-white);
  border-radius: 8px;
  max-width: 720px;
  padding: 2rem;
  border: 1px solid var(--sz-border);
}

.help-page__content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.help-page__content h2 {
  font-size: 1.25rem;
  color: var(--sz-burgundy);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--sz-border);
}

.help-page__content h3 {
  font-size: 0.95rem;
  color: var(--sz-burgundy);
  margin: 1.25rem 0 0.5rem;
}

.help-page__content p, .help-page__content li {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--sz-text);
}

.help-page__content ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.help-page__content li { margin-bottom: 0.25rem; }

.help-page__content code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--sz-border-light);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.help-page__content kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--sz-cream);
  border: 1px solid var(--sz-border);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  box-shadow: 0 1px 0 var(--sz-border);
}

.help-page__content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.8125rem;
}

.help-page__content th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sz-text-light);
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid var(--sz-border);
}

.help-page__content td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--sz-border-light);
}

/* ===== 11. Loading States ===== */
.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--sz-text-light);
  font-size: 0.875rem;
}

.loading::after {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--sz-border);
  border-top-color: var(--sz-burgundy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.5rem;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

.viewer__panels.loading-data {
  opacity: 0.4;
  pointer-events: none;
}

/* ===== 12. Responsive ===== */
@media (max-width: 900px) {
  .viewer__panels {
    grid-template-columns: 1fr;
  }

  .viewer__panel-label:last-of-type {
    border-left: none;
  }

  .viewer__img-panel {
    max-height: 45vh;
  }

  .viewer__text-panel,
  .viewer__diff-panel {
    border-left: none;
    border-top: 1px solid var(--sz-border);
  }

  .viewer__nav {
    padding: 0.4rem 0.75rem;
  }

  .viewer__nav-btn {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.1rem;
  }
}

@media (max-width: 600px) {
  .site-header { padding: 0 0.75rem; }
  .site-header__subtitle { display: none; }
  .site-header__badge { display: none; }

  .catalog { padding: 1rem 0.75rem; }
  .catalog__toolbar { flex-direction: column; }
  .catalog__search { min-width: 100%; }

  /* Card layout for mobile catalog */
  .catalog__table thead { display: none; }
  .catalog__table { display: block; }
  .catalog__table tbody { display: flex; flex-direction: column; gap: 0.5rem; }
  .catalog__table tbody tr {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.15rem 0.5rem;
    border: 1px solid var(--sz-border);
    border-radius: 6px;
    padding: 0.5rem;
    background: var(--sz-white);
    box-shadow: none;
  }
  .catalog__table tbody tr:hover { box-shadow: none; }
  .catalog__table td { padding: 0; border: none; }
  .catalog__table .col-thumb { grid-row: 1 / 3; align-self: center; display: block; }
  .catalog__table .col-thumb img { width: 36px; height: 48px; }
  .catalog__table .col-title {
    grid-column: 2; grid-row: 1;
    font-size: 0.8125rem; white-space: normal; max-width: none;
  }
  .catalog__table .col-sig { grid-column: 2; grid-row: 2; font-size: 0.72rem; color: var(--sz-text-light); }
  .catalog__table .col-review { grid-column: 3; grid-row: 1; text-align: right; }
  .catalog__table .col-quality { grid-column: 3; grid-row: 2; text-align: right; }
  .catalog__table .col-collection { grid-column: 2 / 4; font-size: 0.68rem; color: var(--sz-text-light); }
  .catalog__table .col-pid,
  .catalog__table .col-group,
  .catalog__table .col-lang,
  .catalog__table .col-pages { display: none; }

  .viewer__meta { padding: 0.4rem 0.75rem; font-size: 0.7rem; gap: 0.1rem 0.6rem; }
}

/* ===== 14. GT Review Mode ===== */

.gt-review-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  overflow-y: auto;
  height: 100%;
}

.gt-review-panel__stats {
  font-size: 0.72rem;
  margin-left: 0.5rem;
}

.gt-review-panel__hint {
  font-size: 0.75rem;
  color: var(--sz-text-light);
}

.gt-review-panel__source {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.gt-source--consensus { background: var(--sz-success); color: #fff; }
.gt-source--majority  { background: var(--sz-gold); color: var(--sz-text); }
.gt-source--pro       { background: var(--sz-burgundy); color: #fff; }
.gt-source--skipped   { background: var(--sz-text-light); color: #fff; }

.gt-variant {
  border: 1px solid var(--sz-border);
  border-radius: 4px;
  padding: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.gt-variant:hover { border-color: var(--sz-burgundy); }
.gt-variant.selected { border-color: var(--sz-burgundy); border-width: 2px; background: rgba(99,26,52,0.04); }

.gt-variant__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sz-text-light);
}

.gt-variant__text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 12rem;
  overflow-y: auto;
  color: var(--sz-text);
}

.gt-approve-btn {
  display: block;
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.5rem;
  background: var(--sz-burgundy);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.gt-approve-btn:hover { opacity: 0.9; }
.gt-approve-btn:focus-visible { outline: 2px solid var(--sz-burgundy); outline-offset: 2px; }
.gt-approve-btn.approved { background: var(--sz-success); }

.badge-gt {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--sz-gold);
  color: var(--sz-text);
}
.badge-gt--verified { background: var(--sz-success); color: #fff; }

.viewer__action-btn.gt-active {
  background: var(--sz-gold);
  color: var(--sz-text);
}

/* ===== 15. Knowledge Vault ===== */
.knowledge {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  flex: 1;
}

.knowledge__header {
  margin-bottom: 1.5rem;
}

.knowledge__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--sz-burgundy);
  margin-bottom: 0.25rem;
}

.knowledge__subtitle {
  font-size: 0.875rem;
  color: var(--sz-text-light);
}

.knowledge__section {
  margin-bottom: 1.5rem;
}

.knowledge__section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sz-gold);
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--sz-border-light);
}

.knowledge__cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.75rem;
}

.knowledge__card {
  background: var(--sz-white);
  border: 1px solid var(--sz-border);
  border-radius: 6px;
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  display: block;
}

.knowledge__card:hover {
  border-color: var(--sz-burgundy);
  box-shadow: 0 2px 8px rgba(99, 26, 52, 0.08);
}

.knowledge__card-title {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--sz-burgundy);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.knowledge__card-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  align-items: center;
}

.knowledge__badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.knowledge__badge--active { background: var(--sz-success-bg); color: var(--sz-success); }
.knowledge__badge--stable { background: #d4dbe8; color: #1e3a5f; }
.knowledge__badge--draft { background: var(--sz-warning-bg); color: var(--sz-warning); }
.knowledge__badge--superseded { background: #e0e0e0; color: #666; }

.knowledge__badge--type {
  background: rgba(99, 26, 52, 0.08);
  color: var(--sz-burgundy);
}

.knowledge__card-words {
  color: var(--sz-text-light);
  font-size: 0.72rem;
  margin-left: auto;
}

/* ===== 16. Knowledge Document ===== */
.knowledge-doc {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  flex: 1;
  align-items: start;
}

.knowledge-doc__sidebar {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  max-height: calc(100vh - var(--header-height) - 2rem);
  overflow-y: auto;
  font-size: 0.78rem;
}

.knowledge-doc__sidebar-meta {
  background: var(--sz-white);
  border: 1px solid var(--sz-border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.knowledge-doc__sidebar-meta dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sz-text-light);
  margin-top: 0.5rem;
}

.knowledge-doc__sidebar-meta dt:first-child {
  margin-top: 0;
}

.knowledge-doc__sidebar-meta dd {
  font-size: 0.78rem;
  margin: 0.1rem 0;
}

.knowledge-doc__toc {
  background: var(--sz-white);
  border: 1px solid var(--sz-border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.knowledge-doc__toc-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sz-text-light);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.knowledge-doc__toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.knowledge-doc__toc-list li {
  margin: 0.15rem 0;
}

.knowledge-doc__toc-list a {
  font-size: 0.78rem;
  color: var(--sz-text);
  text-decoration: none;
  display: block;
  padding: 0.15rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.5rem;
  transition: all var(--transition);
}

.knowledge-doc__toc-list a:hover {
  color: var(--sz-burgundy);
  border-left-color: var(--sz-burgundy);
}

.knowledge-doc__toc-list .toc-h3 { padding-left: 1rem; font-size: 0.72rem; }
.knowledge-doc__toc-list .toc-h4 { padding-left: 1.5rem; font-size: 0.68rem; }

.knowledge-doc__sidebar-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.knowledge-doc__sidebar-nav a {
  font-size: 0.75rem;
  color: var(--sz-burgundy);
  text-decoration: none;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--sz-border);
  border-radius: 4px;
  background: var(--sz-white);
  transition: all var(--transition);
  flex: 1;
  text-align: center;
}

.knowledge-doc__sidebar-nav a:hover {
  border-color: var(--sz-burgundy);
  background: rgba(99, 26, 52, 0.03);
}

.knowledge-doc__content {
  background: var(--sz-white);
  border: 1px solid var(--sz-border);
  border-radius: 6px;
  padding: 2rem;
  min-width: 0;
}

/* ===== 17. Markdown Content ===== */
.markdown-content h1 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--sz-burgundy);
  margin-bottom: 1rem;
}

.markdown-content h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--sz-burgundy);
  margin: 1.5rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--sz-border-light);
}

.markdown-content h3 {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--sz-burgundy);
  margin: 1.25rem 0 0.5rem;
}

.markdown-content h4 {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sz-text);
  margin: 1rem 0 0.4rem;
}

.markdown-content p {
  font-size: 0.875rem;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.markdown-content ul,
.markdown-content ol {
  font-size: 0.875rem;
  line-height: 1.7;
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}

.markdown-content li { margin-bottom: 0.2rem; }

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin: 0.75rem 0;
}

.markdown-content table th {
  text-align: left;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid var(--sz-border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sz-text-light);
}

.markdown-content table td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--sz-border-light);
}

.markdown-content table tr:hover td {
  background: rgba(99, 26, 52, 0.02);
}

.markdown-content code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--sz-border-light);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.markdown-content pre {
  background: var(--sz-burgundy-dark);
  color: var(--sz-cream);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  margin: 0.75rem 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.markdown-content blockquote {
  border-left: 3px solid var(--sz-burgundy);
  padding: 0.5rem 1rem;
  margin: 0.75rem 0;
  background: rgba(99, 26, 52, 0.03);
  font-style: italic;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--sz-border);
  margin: 1.5rem 0;
}

.markdown-content a {
  color: var(--sz-burgundy);
  text-decoration: underline;
  text-decoration-color: var(--sz-border);
  transition: text-decoration-color var(--transition);
}

.markdown-content a:hover {
  text-decoration-color: var(--sz-burgundy);
}

.knowledge__wikilink {
  text-decoration: none;
  border-bottom: 1px dashed var(--sz-gold);
}

.knowledge__wikilink:hover {
  border-bottom-style: solid;
  border-bottom-color: var(--sz-burgundy);
}

.markdown-content strong { font-weight: 600; }

/* ===== 18. About Page ===== */
.about {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  flex: 1;
}

.about__content {
  background: var(--sz-white);
  border: 1px solid var(--sz-border);
  border-radius: 6px;
  padding: 2rem;
}

/* ===== 19. Responsive: Knowledge/About ===== */
@media (max-width: 900px) {
  .knowledge-doc {
    grid-template-columns: 1fr;
  }
  .knowledge-doc__sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 600px) {
  .knowledge__cards {
    grid-template-columns: 1fr;
  }
  .knowledge-doc__sidebar {
    display: none;
  }
}

/* ===== 20. Stats Dashboard ===== */
.stats-page {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  flex: 1;
  overflow-x: hidden;
}

.stats-page__header {
  margin-bottom: 1.5rem;
}

.stats-page__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--sz-burgundy);
  margin: 0 0 0.25rem;
}

.stats-page__subtitle {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--sz-text-light);
  margin: 0;
}

.stats-page__grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stats-card {
  background: var(--sz-white);
  border: 1px solid var(--sz-border);
  border-radius: 6px;
  padding: 1.25rem;
  min-width: 0;
}

.stats-card--wide {
  grid-column: 1 / -1;
}

.stats-card__title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--sz-burgundy);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--sz-gold);
}

.stats-card__subtitle {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--sz-text-light);
  margin: -0.5rem 0 0.75rem;
}

.stats-card__chart-wrap {
  position: relative;
  width: 100%;
}

.stats-card__chart-wrap--bar {
  height: 280px;
}

.stats-card__chart-wrap--hbar {
  height: 220px;
}


/* Heatmap table */
.stats-heatmap-wrap {
  overflow-x: auto;
}

.stats-heatmap {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.75rem;
}

.stats-heatmap th {
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  text-align: center;
  color: var(--sz-text-light);
  border-bottom: 1px solid var(--sz-border);
  font-size: 0.7rem;
}

.stats-heatmap th:first-child {
  text-align: left;
  min-width: 110px;
}

.stats-heatmap td {
  padding: 0.4rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--sz-border-light);
  font-variant-numeric: tabular-nums;
}

.stats-heatmap td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--sz-text);
}

.stats-heatmap__cell {
  border-radius: 3px;
  padding: 0.2rem 0.4rem;
  display: inline-block;
  min-width: 2.5rem;
}

.stats-heatmap__cell--zero {
  color: var(--sz-border);
}

.stats-heatmap__cell--bright {
  color: #fff;
}

.stats-heatmap__group {
  color: var(--sz-text);
  text-decoration: none;
}

.stats-heatmap__group:hover {
  text-decoration: underline;
}

/* Narrative sections */
.stats-section {
  margin-bottom: 2rem;
}

.stats-section__header {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--sz-gold);
}

.stats-section__title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--sz-burgundy);
  margin: 0 0 0.15rem;
}

.stats-section__desc {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--sz-text-light);
  margin: 0;
}

.stats-section__source {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  color: var(--sz-text-light);
  opacity: 0.35;
  margin: 0.15rem 0 0;
  transition: opacity 0.2s;
}

.stats-section__header:hover .stats-section__source {
  opacity: 0.7;
}

.stats-section__source code {
  font-size: 0.6rem;
  padding: 0.05em 0.2em;
}

.stats-section__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

/* Donut chart container */
.stats-card__chart-wrap--donut {
  height: 280px;
  max-width: 320px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .stats-section__grid {
    grid-template-columns: 1fr;
  }
}

/* ===== 21. Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
