:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #24211c;
  --text-muted: #6b6558;
  --border: #e4ddd0;
  --accent: #7a4a2b;
  --accent-soft: #efe2d4;
  --link: #6b3d1f;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17;
    --surface: #262320;
    --text: #ece7dd;
    --text-muted: #ada496;
    --border: #3a3530;
    --accent: #d8a878;
    --accent-soft: #33291f;
    --link: #e0b083;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
}

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.brand-mark {
  color: var(--accent);
  letter-spacing: 0.05em;
}

.site-header nav a {
  margin-left: 1.25rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.site-header nav a:hover { color: var(--text); }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.intro h1 {
  font-family: var(--serif);
  font-size: 2.2rem;
  margin-bottom: 0.75rem;
}

.intro p {
  color: var(--text-muted);
  max-width: 70ch;
}

.intro h2 {
  font-family: var(--serif);
  font-size: 1.2rem;
  margin: 1.75rem 0 0.4rem;
  color: var(--text);
}

.search-section {
  margin: 2rem 0;
}

#search .pagefind-ui__search-input {
  font-size: 1rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 1.5rem 0 1rem;
}

.filters input[type="search"] {
  flex: 1 1 260px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

.filters select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.filters .filter-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.filters .filter-check input {
  accent-color: var(--accent);
  cursor: pointer;
}

.result-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: auto;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

thead th {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

thead th:hover { color: var(--accent); }

tbody td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--accent-soft); }

.col-title { min-width: 260px; }

.col-actions { white-space: nowrap; text-align: right; }

.icon-link {
  display: inline-flex;
  padding: 0.2rem;
  color: var(--text-muted);
}

.icon-link:hover { color: var(--accent); }

.badge {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  vertical-align: middle;
}

.doc-page .back {
  margin-bottom: 0.5rem;
}

.doc-page h1 {
  font-family: var(--serif);
  font-size: 1.9rem;
  margin-bottom: 1rem;
}

dl.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.meta-row { display: contents; }
dl.meta dt { color: var(--text-muted); font-size: 0.85rem; }
dl.meta dd { margin: 0; }

.pdf-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.95rem;
}

.pdf-actions .btn { margin-bottom: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* The few documents that were scanned into several PDFs list them instead of
   showing the single View/Download pair. */
.pdf-parts-block {
  margin-bottom: 1.5rem;
}

.pdf-parts-note {
  margin: 0 0 0.6rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pdf-parts {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.pdf-part {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border);
}

.pdf-part:first-child { border-top: none; }

.pdf-part-name {
  font-size: 0.9rem;
  word-break: break-word;
}

.pdf-part-size { color: var(--text-muted); }

.pdf-part-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.pdf-part-actions .btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
}

/* Separates each part's text within a multi-part document's extracted text. */
.doc-content .part-title {
  margin: 2rem 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
  word-break: break-word;
}

.doc-content .part-title:first-child { margin-top: 0; }

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.viewer-bar h1 {
  flex: 1;
  font-family: var(--serif);
  font-size: 1.1rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#viewer-frame {
  display: block;
  width: 100%;
  height: 80vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.viewer-fallback {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.doc-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  white-space: pre-wrap;
  font-size: 0.95rem;
  color: var(--text);
  max-width: 74ch;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.site-footer a { color: var(--text-muted); }

.footer-logo {
  display: block;
  height: 64px;
  width: auto;
  margin: 0 auto 0.9rem;
  opacity: 0.85;
}

@media (prefers-color-scheme: dark) {
  .footer-logo { filter: invert(1); }
}
