:root {
  color-scheme: light;
  --paper: #fcfcfa;
  --surface: #ffffff;
  --ink: #171817;
  --muted: #596361;
  --quiet: #707875;
  --line: #dddcd6;
  --line-strong: #c8c7c0;
  --blue: #31566d;
  --blue-soft: #edf3f5;
  --rust: #7a4f3a;
  --sage: #53675f;
  --max: 1240px;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  scroll-behavior: smooth;
}

body { margin: 0; background: var(--paper); }

a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--rust); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 20;
  padding: .7rem 1rem;
  background: var(--ink);
  color: white;
}
.skip-link:focus { top: 1rem; }

.shell { width: min(calc(100% - 48px), var(--max)); margin-inline: auto; }

.masthead {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.brand {
  color: var(--ink);
  font: 500 24px/1 Georgia, "Times New Roman", serif;
  text-decoration: none;
}
.collection-link {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: uppercase;
}

.intro { padding: 54px 0 30px; max-width: 850px; }
.eyebrow, .section-label, .record-label {
  margin: 0 0 12px;
  color: var(--sage);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: 0;
}
h1 { max-width: 820px; font-size: clamp(36px, 4vw, 52px); line-height: 1.04; }
h2 { font-size: 30px; line-height: 1.15; }
h3 { font-size: 22px; line-height: 1.2; }
.lede {
  max-width: 760px;
  margin: 22px 0 0;
  color: var(--muted);
  font: 400 21px/1.5 Georgia, "Times New Roman", serif;
}

.view-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid var(--line-strong);
}
.view-nav a {
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 10px 16px;
  border-right: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.view-nav a:last-child { border-right: 0; }
.view-nav a[aria-current="page"] { background: var(--blue-soft); color: var(--blue); }

.tools {
  display: grid;
  grid-template-columns: minmax(250px, 620px) auto;
  align-items: end;
  gap: 24px;
  padding: 30px 0 24px;
}
.search-label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 650; }
.search-label input {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.result-summary { margin: 0 0 13px; color: var(--quiet); font-size: 13px; text-align: right; }

.content-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 23px 0 14px;
  border-top: 1px solid var(--line);
}
.content-header p { margin: 0; color: var(--quiet); font-size: 13px; }

.result-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.result-row { border-bottom: 1px solid var(--line); }
.letter-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) minmax(180px, 250px);
  gap: 24px;
  align-items: center;
  min-height: 116px;
  padding: 18px 0;
}
.thumb { width: 68px; min-height: 82px; display: grid; place-items: center; }
.thumb img {
  display: block;
  width: auto;
  height: auto;
  max-width: 66px;
  max-height: 86px;
  border: 1px solid #d5d1c9;
}
.letter-id { color: var(--quiet); font-size: 12px; font-weight: 650; }
.result-title { display: inline-block; margin-top: 7px; color: var(--ink); font: 400 21px/1.23 Georgia, "Times New Roman", serif; }
.route { margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.letter-meta { color: var(--muted); font-size: 13px; line-height: 1.55; }
.letter-meta span { display: block; }

.entity-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 24px;
  align-items: center;
  min-height: 82px;
  padding: 17px 0;
}
details.entity-row > summary { list-style: none; cursor: pointer; }
details.entity-row > summary::-webkit-details-marker { display: none; }
details.entity-row > summary::after { content: "+"; color: var(--blue); font-size: 22px; }
details.entity-row[open] > summary::after { content: "−"; }
.entity-title { color: var(--ink); font: 400 22px/1.25 Georgia, "Times New Roman", serif; }
.entity-sub { margin-top: 7px; color: var(--muted); font-size: 13px; }
.badge {
  display: inline-block;
  margin-left: 8px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  vertical-align: 2px;
}
.entity-documents { margin: 0 0 20px 22px; padding-left: 18px; color: var(--muted); }
.entity-documents li { margin: 8px 0; line-height: 1.45; }

.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.theme-block { padding: 24px 24px 26px 0; border-bottom: 1px solid var(--line); }
.theme-block:nth-child(odd) { border-right: 1px solid var(--line); }
.theme-block:nth-child(even) { padding-left: 24px; }
.theme-count { margin: 8px 0 15px; color: var(--rust); font-size: 13px; }
.year-strip { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 18px 0 0; }
.year-strip a { font-size: 13px; }

.back-link { margin: 0 0 22px; font-size: 13px; }
.back-link a { color: var(--muted); text-decoration: none; }
.back-link a:hover { color: var(--blue); text-decoration: underline; }
.record { padding-bottom: 60px; }
.record-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(260px, .7fr); gap: 72px; }
.record-main, .record-aside { min-width: 0; }
.record-section { padding: 28px 0; border-top: 1px solid var(--line); }
.record-section p { color: var(--muted); font: 400 18px/1.58 Georgia, "Times New Roman", serif; }
.facts { margin: 0; }
.facts div { padding: 14px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--quiet); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.facts dd { margin: 5px 0 0; color: var(--ink); line-height: 1.45; }
.name-list, .source-list, .connection-list { margin: 16px 0 0; padding-left: 22px; }
.name-list li, .source-list li, .connection-list li { margin: 10px 0; line-height: 1.5; }
.source-list { color: var(--muted); }
.source-list a { overflow-wrap: anywhere; }
.document-links { margin-top: 16px; }

.empty-state { padding: 44px 0; color: var(--muted); font: 400 19px/1.5 Georgia, serif; }
[hidden] { display: none !important; }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 48px;
  padding: 24px 0 36px;
  border-top: 1px solid var(--line-strong);
  color: var(--quiet);
  font-size: 12px;
}

@media (max-width: 820px) {
  .shell { width: min(calc(100% - 28px), var(--max)); }
  .masthead { min-height: 58px; }
  .brand { font-size: 20px; }
  .intro { padding-top: 38px; }
  h1 { font-size: 37px; }
  .lede { font-size: 18px; }
  .view-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-nav a:nth-child(2) { border-right: 0; }
  .view-nav a:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .tools { grid-template-columns: 1fr; gap: 10px; }
  .result-summary { text-align: left; }
  .letter-row { grid-template-columns: 58px minmax(0, 1fr); gap: 14px; }
  .thumb { width: 54px; }
  .thumb img { max-width: 52px; max-height: 72px; }
  .letter-meta { grid-column: 2; }
  .result-title { font-size: 19px; }
  .theme-grid { grid-template-columns: 1fr; }
  .theme-block, .theme-block:nth-child(even) { padding: 22px 0; border-right: 0; }
  .record-grid { grid-template-columns: 1fr; gap: 18px; }
  .footer { flex-direction: column; }
}

@media print {
  .view-nav, .tools, .skip-link { display: none; }
  .shell { width: 100%; }
  a { color: black; text-decoration: none; }
}
