/* Knight Archive V1 — editorial, evidence-first */
:root {
  --paper: #f2efe7;
  --paper-light: #fbfaf6;
  --ink: #171713;
  --muted: #69675f;
  --rule: #c8c3b7;
  --accent: #b94330;
  --accent-dark: #8f2d20;
  --dark: #171713;
  --dark-surface: #24241f;
  --dark-rule: #44443c;
  --white: #fffef9;
  --success: #427355;
  --warning: #b2782c;
  --danger: #a83b34;
  --display: Georgia, 'Times New Roman', serif;
  --ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --max: 1500px;
  --gutter: clamp(20px, 4vw, 64px);
  --focus: 0 0 0 3px rgba(185, 67, 48, .25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: var(--focus); }
button, a.button { min-height: 44px; }
::selection { background: var(--accent); color: var(--white); }

.skip-link {
  position: fixed;
  z-index: 100;
  left: 12px;
  top: -80px;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
}
.skip-link:focus { top: 12px; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px var(--gutter);
  border-bottom: 1px solid rgba(23, 23, 19, .22);
  background: rgba(242, 239, 231, .94);
  backdrop-filter: blur(18px) saturate(140%);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 13px;
  font-weight: 720;
  letter-spacing: .07em;
  text-decoration: none;
  text-transform: uppercase;
}
.wordmark span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: var(--display);
  font-size: 15px;
  font-style: italic;
  letter-spacing: -.02em;
}
.site-header nav { display: flex; align-items: center; gap: clamp(14px, 2.2vw, 34px); }
.site-header nav a {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .04em;
  text-decoration: none;
  text-transform: uppercase;
}
.site-header nav a[aria-current='page'] { color: var(--accent); }
.site-header .editor-link { padding: 7px 12px; border: 1px solid currentColor; border-radius: 999px; }

.kicker, .machine-label {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .13em;
  line-height: 1.3;
  text-transform: uppercase;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  text-decoration: none;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: var(--white); }
.button-primary:hover { background: var(--accent-dark); color: var(--white); }
.button-light { background: var(--white); color: var(--ink); }
.button-light:hover { background: var(--accent); color: var(--white); }
.button-dark { background: var(--ink); color: var(--white); }
.button-dark:hover { background: var(--accent); color: var(--white); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.text-link { font-size: 14px; font-weight: 700; }

.hero {
  min-height: calc(100svh - 66px);
  max-width: var(--max);
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(420px, 1.1fr);
  align-items: stretch;
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}
.hero-copy { min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(54px, 8vw, 126px) var(--gutter);
}
.hero h1 {
  max-width: 780px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(58px, 7vw, 116px);
  font-weight: 400;
  letter-spacing: -.06em;
  line-height: .9;
  text-wrap: balance;
}
.hero-intro {
  max-width: 560px;
  margin: 32px 0 0;
  color: #4c4a43;
  font-family: var(--display);
  font-size: clamp(21px, 2vw, 30px);
  line-height: 1.28;
}
.hero-actions { display: flex; align-items: center; gap: 24px; margin-top: 36px; }
.hero-figure {
  min-width: 0;
  margin: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--dark);
  overflow: hidden;
}
.hero-figure img { width: 100%; height: 100%; min-height: 520px; object-fit: cover; object-position: center 30%; filter: grayscale(1) contrast(1.08); opacity: .92; }
.hero-figure figcaption { display: flex; gap: 16px; padding: 16px 20px; border-top: 1px solid var(--dark-rule); color: #cbc8be; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.hero-figure figcaption span { color: var(--white); }

.ruled-section {
  position: relative;
  max-width: var(--max);
  margin: auto;
  padding: clamp(72px, 10vw, 160px) var(--gutter);
  border: 1px solid var(--rule);
  border-top: 0;
}
.section-marker { position: absolute; top: 24px; left: var(--gutter); font-family: var(--display); font-size: 14px; font-style: italic; }
.story-section { display: grid; grid-template-columns: .9fr 1.1fr; gap: clamp(40px, 9vw, 140px); }
.story-heading h2, .archive-intro h2, .featured-section h2, .next-chapter h2, .page-heading h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -.045em;
  line-height: .98;
  text-wrap: balance;
}
.story-heading h2, .archive-intro h2 { font-size: clamp(48px, 6vw, 88px); }
.story-copy { max-width: 720px; }
.story-copy p { margin: 0 0 24px; }
.story-copy .lead { font-family: var(--display); font-size: clamp(25px, 2.4vw, 36px); line-height: 1.28; }
.source-note { padding-top: 18px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px; }

.timeline {
  max-width: var(--max);
  margin: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--rule);
  border-top: 0;
}
.timeline article { min-height: 320px; padding: 28px; border-right: 1px solid var(--rule); }
.timeline article:last-child { border-right: 0; }
.timeline time { color: var(--accent); font-family: var(--display); font-size: 42px; font-style: italic; }
.timeline h3 { margin: 50px 0 12px; font-family: var(--display); font-size: 25px; font-weight: 400; line-height: 1.15; }
.timeline p { margin: 0; color: var(--muted); font-size: 14px; }

.dark-section { background: var(--dark); color: var(--white); }
.archive-intro {
  max-width: var(--max);
  margin: auto;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: clamp(40px, 9vw, 140px);
  padding: clamp(76px, 10vw, 160px) var(--gutter);
}
.archive-intro .kicker { color: #df8a75; }
.archive-intro-copy { max-width: 600px; color: #d4d1c8; font-size: 18px; }
.archive-intro-copy p { margin: 0 0 24px; }
.status-dot { width: 8px; height: 8px; display: inline-block; margin-right: 9px; border-radius: 50%; background: var(--accent); }

.featured-section, .archive-page, .item-page {
  max-width: var(--max);
  margin: auto;
  padding: clamp(64px, 8vw, 120px) var(--gutter);
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 38px; }
.featured-section h2 { font-size: clamp(45px, 5vw, 72px); }
.result-count { margin: 0; color: var(--muted); font-size: 14px; font-weight: 700; }

.archive-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; }
.archive-grid-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.archive-card { min-width: 0; display: flex; flex-direction: column; border-top: 1px solid var(--ink); }
.card-image-link { aspect-ratio: 4 / 5; display: block; overflow: hidden; background: #dedad0; }
.card-image-link img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.15); transition: transform .3s ease, filter .3s ease; }
.card-image-link:hover img { transform: scale(1.02); filter: grayscale(0); }
.card-body { padding: 15px 2px 8px; }
.card-topline { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.record-number { color: var(--muted); font-family: var(--display); font-size: 13px; font-style: italic; }
.archive-card h3 { margin: 17px 0 9px; font-family: var(--display); font-size: clamp(23px, 2vw, 31px); font-weight: 400; line-height: 1.04; }
.archive-card h3 a { text-decoration: none; }
.card-meta { min-height: 2.8em; margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.card-excerpt { margin: 14px 0 0; color: #59574f; font-family: var(--display); font-size: 15px; line-height: 1.45; }
.status-badge { width: fit-content; margin: 0; padding: 4px 8px; border: 1px solid currentColor; border-radius: 999px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; line-height: 1.2; text-transform: uppercase; }
.status-reviewed, .status-verified { color: var(--success); }
.status-needs-review { color: var(--warning); }
.status-disputed { color: var(--danger); }

.next-chapter { display: grid; grid-template-columns: .9fr 1.1fr; gap: clamp(40px, 9vw, 140px); align-items: end; }
.next-chapter h2 { font-size: clamp(46px, 5vw, 74px); }
.next-chapter > p { max-width: 650px; margin: 0; font-family: var(--display); font-size: 24px; }

.page-heading { max-width: 980px; margin-bottom: 52px; }
.page-heading h1 { font-size: clamp(58px, 8vw, 116px); }
.page-heading > p:last-child { max-width: 690px; color: var(--muted); font-family: var(--display); font-size: 22px; }
.search-panel {
  position: sticky;
  z-index: 10;
  top: 80px;
  display: grid;
  grid-template-columns: 1fr 240px auto;
  align-items: end;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--rule);
  background: rgba(251, 250, 246, .97);
  backdrop-filter: blur(14px);
}
.public-search-panel { grid-template-columns: 1fr auto; }
.search-field, .filter-field, .editor-form label { display: grid; gap: 7px; }
.search-field span, .filter-field span, .editor-form label > span, .queue-controls label { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.search-panel input, .search-panel select, .editor-form input, .editor-form select, .editor-form textarea, .queue-controls select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
}
.search-panel input { font-family: var(--display); font-size: 20px; }
.archive-toolbar { display: flex; justify-content: space-between; gap: 20px; margin: 24px 0; }
.machine-note { margin: 0; color: var(--muted); font-size: 12px; }
.empty-state { padding: 80px 20px; text-align: center; }
.empty-state h2 { font-family: var(--display); font-size: 42px; font-weight: 400; }
.error-message { padding: 18px; border: 1px solid var(--danger); color: var(--danger); }

.item-page { padding-top: 36px; }
.back-link { display: inline-flex; gap: 8px; margin-bottom: 46px; font-size: 13px; font-weight: 750; text-decoration: none; text-transform: uppercase; }
.item-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 34px; }
.item-heading h1 { max-width: 1000px; margin: 15px 0 10px; font-family: var(--display); font-size: clamp(42px, 5.6vw, 82px); font-weight: 400; letter-spacing: -.04em; line-height: .98; }
.item-meta { margin: 0; color: var(--muted); }
.item-nav { display: flex; }
.item-nav a { width: 50px; height: 50px; display: grid; place-items: center; border: 1px solid var(--ink); text-decoration: none; }
.item-nav a + a { border-left: 0; }
.inspect-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr); min-height: 760px; border: 1px solid var(--ink); }
.scan-panel, .transcript-panel { min-width: 0; display: flex; flex-direction: column; }
.scan-panel { border-right: 1px solid var(--ink); background: #282822; color: var(--white); }
.panel-heading { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; border-bottom: 1px solid currentColor; }
.panel-heading h2 { margin: 0; font-family: var(--display); font-size: 25px; font-weight: 400; }
.panel-heading a, .quiet-button { border: 0; background: transparent; color: inherit; font-size: 12px; font-weight: 750; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.scan-stage { flex: 1; min-height: 620px; margin: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.scan-stage img { width: 100%; height: 100%; max-height: 950px; object-fit: contain; padding: 22px; }
.scan-stage figcaption { padding: 14px 20px; border-top: 1px solid var(--dark-rule); color: #b9b6ac; font-size: 11px; }
.transcript-panel { background: var(--paper-light); }
.transcript-panel .panel-heading { border-color: var(--rule); }
.transcript-panel .machine-label { margin: 0 0 4px; }
.transcript-text { flex: 1; max-height: 790px; padding: 28px; overflow: auto; white-space: pre-wrap; font-family: var(--display); font-size: 19px; line-height: 1.6; }
.transcript-warning { margin: 0; padding: 16px 22px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 12px; }
.provenance-section { margin-top: 70px; border-top: 1px solid var(--rule); display: grid; grid-template-columns: .7fr 1.3fr; gap: 60px; }
.provenance-section h2 { margin: 0; font-family: var(--display); font-size: 54px; font-weight: 400; }
.provenance-list { margin: 0; }
.provenance-list div { display: grid; grid-template-columns: 160px 1fr; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.provenance-list dt { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.provenance-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-family: var(--display); }

.editor-body { background: #1a1a17; color: var(--white); }
.editor-header { position: relative; background: #1a1a17; border-color: var(--dark-rule); }
.editor-header .wordmark span { border-color: var(--white); }
.editor-page { min-height: 100vh; }
.editor-topbar { min-height: 156px; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 34px var(--gutter); border-bottom: 1px solid var(--dark-rule); }
.editor-topbar h1 { margin: 0; font-family: var(--display); font-size: 52px; font-weight: 400; }
.editor-actions { display: flex; align-items: center; gap: 20px; }
.editor-actions p { margin: 0; color: #b9b6ac; font-size: 13px; }
.editor-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: 900px; }
.queue-panel { border-right: 1px solid var(--dark-rule); background: #151512; }
.queue-controls { position: sticky; top: 0; z-index: 2; display: grid; gap: 8px; padding: 18px; border-bottom: 1px solid var(--dark-rule); background: #151512; }
.queue-controls select { border-color: var(--dark-rule); background: var(--dark-surface); color: var(--white); }
.queue-controls p { margin: 0; color: #8f8d84; font-size: 12px; }
.editor-queue { max-height: 960px; overflow: auto; }
.queue-item { width: 100%; min-height: 98px; display: grid; grid-template-columns: 34px 1fr; gap: 3px 8px; padding: 15px 18px; border: 0; border-bottom: 1px solid var(--dark-rule); background: transparent; color: #d9d6cd; text-align: left; cursor: pointer; }
.queue-item:hover, .queue-item.is-selected { background: var(--dark-surface); }
.queue-item.is-selected { box-shadow: inset 3px 0 0 var(--accent); }
.queue-number { grid-row: 1 / 3; color: #77746c; font-family: var(--display); font-style: italic; }
.queue-item strong { overflow: hidden; font-family: var(--display); font-size: 17px; font-weight: 400; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.queue-item small { color: #8f8d84; font-size: 10px; text-transform: uppercase; }
.review-workspace { min-width: 0; display: grid; grid-template-columns: minmax(350px, .9fr) minmax(500px, 1.1fr); }
.editor-scan-column { min-width: 0; border-right: 1px solid var(--dark-rule); }
.editor-scan-stage { height: 700px; padding: 24px; background: #262620; }
.editor-scan-stage img { width: 100%; height: 100%; object-fit: contain; }
details { border-bottom: 1px solid var(--dark-rule); }
summary { padding: 15px 20px; color: #b9b6ac; font-size: 12px; font-weight: 750; cursor: pointer; text-transform: uppercase; }
details pre { max-height: 380px; margin: 0; padding: 20px; overflow: auto; color: #d7d4cc; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55; white-space: pre-wrap; }
#revision-history { margin: 0; padding: 0 24px 22px 42px; color: #b9b6ac; font-size: 12px; }
.editor-form { min-width: 0; padding: 28px; background: var(--paper-light); color: var(--ink); }
.form-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.form-heading h2 { margin: 0; font-family: var(--display); font-size: 38px; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor-form label { margin-bottom: 16px; }
.editor-form textarea { resize: vertical; font-family: var(--display); font-size: 17px; line-height: 1.5; }
.editor-form small { font-size: 10px; font-weight: 500; text-transform: none; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 16px; border-top: 1px solid var(--rule); }
.form-footer p { margin: 0; color: var(--muted); font-size: 12px; }

.site-footer {
  min-height: 210px;
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  align-items: end;
  gap: 30px;
  padding: 54px var(--gutter);
  border-top: 1px solid var(--dark-rule);
  background: var(--dark);
  color: #c9c6bd;
  font-size: 12px;
}
.site-footer p { margin: 0; }
.site-footer strong { color: var(--white); }
.site-footer a { color: var(--white); }

@media (max-width: 1120px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .archive-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .archive-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline { grid-template-columns: repeat(2, 1fr); }
  .timeline article:nth-child(2) { border-right: 0; }
  .timeline article:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
  .review-workspace { grid-template-columns: 1fr; }
  .editor-scan-column { border-right: 0; }
}

@media (max-width: 820px) {
  body { font-size: 16px; }
  .site-header { min-height: 60px; padding-inline: 18px; }
  .wordmark { font-size: 11px; }
  .wordmark span { width: 30px; height: 30px; }
  .site-header nav { gap: 12px; }
  .site-header nav a { font-size: 10px; }
  .site-header .editor-link { padding: 6px 9px; }
  .hero { min-height: auto; grid-template-columns: 1fr; border: 0; }
  .hero-copy { min-height: 72svh; padding: 66px 22px; }
  .hero h1 { font-size: clamp(58px, 18vw, 92px); }
  .hero-figure img { min-height: 74svh; }
  .story-section, .archive-intro, .next-chapter, .provenance-section { grid-template-columns: 1fr; gap: 42px; }
  .ruled-section, .featured-section, .archive-page, .item-page { border-left: 0; border-right: 0; padding-inline: 22px; }
  .timeline { grid-template-columns: 1fr; border-left: 0; border-right: 0; }
  .timeline article { min-height: 230px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .timeline h3 { margin-top: 30px; }
  .archive-intro { padding: 80px 22px; }
  .archive-grid, .archive-grid-wide { grid-template-columns: 1fr 1fr; }
  .search-panel { top: 70px; grid-template-columns: 1fr; }
  .search-panel .button { width: 100%; }
  .inspect-layout { grid-template-columns: 1fr; }
  .scan-panel { border-right: 0; border-bottom: 1px solid var(--ink); }
  .scan-stage { min-height: 500px; }
  .provenance-section { margin-inline: -22px; padding-inline: 22px; }
  .provenance-list div { grid-template-columns: 120px 1fr; }
  .editor-topbar { align-items: flex-start; flex-direction: column; }
  .editor-actions { width: 100%; justify-content: space-between; }
  .editor-layout { grid-template-columns: 1fr; }
  .queue-panel { border-right: 0; border-bottom: 1px solid var(--dark-rule); }
  .editor-queue { max-height: 330px; }
  .review-workspace { grid-template-columns: 1fr; }
  .editor-scan-stage { height: 560px; }
  .site-footer { grid-template-columns: 1fr; align-items: start; }
}

@media (max-width: 560px) {
  .site-header nav a:first-child { display: none; }
  .hero h1 { font-size: clamp(52px, 16vw, 68px); letter-spacing: -.055em; }
  .hero-actions { align-items: flex-start; flex-direction: column; }
  .archive-grid, .archive-grid-wide { grid-template-columns: 1fr; }
  .section-title-row, .archive-toolbar, .item-heading, .editor-actions, .form-footer { align-items: flex-start; flex-direction: column; }
  .card-image-link { aspect-ratio: 5 / 6; }
  .search-panel { margin-inline: -10px; }
  .item-nav { align-self: stretch; }
  .item-nav a { flex: 1; }
  .panel-heading { align-items: flex-start; }
  .provenance-list div { grid-template-columns: 1fr; gap: 4px; }
  .form-grid { grid-template-columns: 1fr; }
  .editor-form { padding: 20px; }
  .editor-topbar h1 { font-size: 43px; }
  .editor-scan-stage { height: 430px; padding: 12px; }
  .site-footer { min-height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
