:root {
  --paper: #f4f1e9;
  --ink: #151515;
  --muted: #716e67;
  --line: #c9c4b8;
  --panel: #fbfaf5;
  --accent: #ef4e22;
  --blue: #2347ff;
  --shadow: 0 24px 80px rgba(24, 22, 17, .18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }

.masthead {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ink);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 241, 233, .94);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 750; letter-spacing: -.03em; }
.brand-mark { width: 34px; height: 34px; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 12px; letter-spacing: .06em; }
.brand { flex-shrink: 0; }
.site-nav { display: flex; gap: 14px; align-items: center; overflow-x: auto; margin: 0 20px; white-space: nowrap; font-size: 12px; }
.site-nav a { text-decoration: none; padding: 16px 0; }
.site-nav a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
.site-nav a:hover { color: var(--accent); }
.masthead-meta { display: flex; align-items: center; gap: 24px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
#load-state { display: flex; align-items: center; gap: 8px; }
#load-state i { width: 7px; height: 7px; border-radius: 50%; background: #d79e00; }
#load-state.ready i { background: #198754; }
#load-state.error i { background: #c62020; }

.hero {
  min-height: 420px;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, .8fr);
  border-bottom: 1px solid var(--ink);
}
.hero > div { padding: 48px clamp(24px, 4vw, 64px); }
.hero > div + div { border-left: 1px solid var(--ink); }
.kicker, .index-title { font-size: 11px; font-weight: 750; letter-spacing: .12em; }
.hero h1 { margin: 45px 0 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(56px, 8vw, 126px); line-height: .82; letter-spacing: -.065em; }
.hero h1 em { color: var(--accent); font-weight: 400; }
.hero-copy { display: flex; flex-direction: column; justify-content: space-between; }
.hero-copy > p { margin: 0; max-width: 470px; font-size: 19px; line-height: 1.48; letter-spacing: -.015em; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.hero-stats div { padding: 18px 14px 0 0; }
.hero-stats strong { display: block; font: 400 35px/1 Georgia, serif; }
.hero-stats span { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }

.explorer-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.filters { border-right: 1px solid var(--ink); padding: 24px; min-height: calc(100vh - 64px); position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; }
.filter-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; font-size: 11px; font-weight: 750; letter-spacing: .11em; }
.filter-head button { border: 0; background: none; color: var(--accent); padding: 0; font-size: 11px; text-transform: uppercase; }
.filters > label:not(.check-row) { display: block; margin: 20px 0 7px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .11em; font-weight: 700; }
.filters input[type="search"], .filters select, .view-controls select {
  width: 100%; border: 1px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); padding: 11px 34px 11px 11px; outline: 0;
}
.filters input:focus, .filters select:focus, .view-controls select:focus { box-shadow: inset 0 0 0 2px var(--blue); }
.search-field { position: relative; }
.search-field kbd { position: absolute; right: 10px; bottom: 10px; border: 1px solid var(--line); padding: 1px 6px; color: var(--muted); background: var(--panel); font: 11px/1.5 ui-monospace, monospace; }
.check-row { display: flex; align-items: center; gap: 9px; margin: 22px 0 28px; font-size: 13px; cursor: pointer; }
.check-row input { position: absolute; opacity: 0; }
.fake-check { width: 17px; height: 17px; border: 1px solid var(--ink); display: grid; place-items: center; }
.check-row input:checked + .fake-check { background: var(--ink); }
.check-row input:checked + .fake-check::after { content: "✓"; color: white; font-size: 12px; }
.category-index { padding-top: 22px; border-top: 1px solid var(--line); }
#category-counts { margin-top: 14px; }
.count-row { display: grid; grid-template-columns: minmax(0, 1fr) 32px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid rgba(201,196,184,.6); font-size: 11px; }
.count-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-value { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.results { min-width: 0; padding: 0 clamp(18px, 3vw, 44px) 56px; }
.results-head { min-height: 124px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--ink); }
.results-head p { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.results-head h2 { margin: 0; font: 400 clamp(30px, 4vw, 52px)/1 Georgia, serif; letter-spacing: -.04em; }
.view-controls { min-width: 190px; }
.view-controls label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }

.record-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; background: transparent; border: 1px solid var(--ink); margin-top: 28px; }
.record-card { min-width: 0; border: 0; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 0; background: var(--panel); color: var(--ink); text-align: left; position: relative; }
.record-card:focus-visible { outline: 4px solid var(--blue); outline-offset: -4px; z-index: 2; }
.card-image { aspect-ratio: 4 / 3; position: relative; display: grid; place-items: center; overflow: hidden; background: #ddd9cf; }
.card-image img, .card-image svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.card-image img { object-fit: contain; }
.bbox-layer { pointer-events: none; overflow: visible; }
.bbox-layer rect { fill: none; stroke: var(--accent); stroke-width: 1px; vector-effect: non-scaling-stroke; }
body.hide-boxes .bbox-layer { display: none; }
.card-index { position: absolute; left: 10px; top: 10px; z-index: 2; background: var(--ink); color: white; padding: 5px 7px; font: 10px/1 ui-monospace, monospace; }
.card-copy { min-height: 145px; padding: 17px; border-top: 1px solid var(--ink); }
.card-copy small { display: block; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-copy h3 { margin: 12px 0 9px; font: 400 31px/1 Georgia, serif; letter-spacing: -.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-copy p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.load-more { display: block; width: 100%; margin-top: 20px; border: 1px solid var(--ink); background: transparent; padding: 16px; text-transform: uppercase; letter-spacing: .1em; font-weight: 750; }
.load-more:hover { background: var(--ink); color: var(--paper); }
.empty-state { padding: 100px 20px; text-align: center; }
.empty-state span { color: var(--accent); font: 100px/1 Georgia, serif; }
.empty-state h3 { margin: 10px 0; font: 42px/1 Georgia, serif; }
.empty-state p { color: var(--muted); }

dialog { width: min(1500px, calc(100vw - 28px)); height: min(920px, calc(100vh - 28px)); padding: 0; border: 1px solid var(--ink); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20, 20, 17, .68); backdrop-filter: blur(5px); }
.dialog-bar { height: 52px; border-bottom: 1px solid var(--ink); display: flex; align-items: center; justify-content: space-between; padding-left: 17px; font: 11px/1 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .07em; }
.dialog-bar > div { height: 100%; display: flex; }
.dialog-bar button { min-width: 52px; padding: 0 16px; border: 0; border-left: 1px solid var(--ink); background: transparent; }
.dialog-bar button:hover { background: var(--ink); color: white; }
.dialog-layout { height: calc(100% - 52px); display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(350px, .75fr); }
.image-panel { display: grid; grid-template-rows: 49px minmax(0, 1fr); min-width: 0; border-right: 1px solid var(--ink); background: #dcd8ce; }
.image-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-left: 15px; border-bottom: 1px solid var(--ink); background: var(--paper); font: 11px/1 ui-monospace, monospace; overflow: hidden; }
.image-toolbar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-toolbar div { height: 100%; display: flex; flex: none; }
.image-toolbar button { border: 0; border-left: 1px solid var(--ink); background: transparent; padding: 0 13px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.image-toolbar button:hover { color: var(--accent); }
.dialog-image-viewport { min-height: 0; overflow: auto; padding: 24px; text-align: center; position: relative; }
.dialog-image-viewport.is-focused { overflow: hidden; padding: 0; }
.dialog-image-stack { position: relative; display: inline-block; transform-origin: top left; line-height: 0; }
.dialog-image-stack img { display: block; max-width: 100%; max-height: calc(100vh - 154px); width: auto; height: auto; }
.dialog-image-stack.is-focused { display: block; margin: 0; position: absolute; inset: 0 auto auto 0; }
.dialog-image-stack.is-focused img { width: 100%; max-width: none; max-height: none; }
.dialog-image-stack svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.metadata-panel { min-width: 0; overflow-y: auto; padding: clamp(24px, 3vw, 48px); }
.dialog-category { margin: 0; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; font-weight: 800; }
.metadata-panel > h2 { margin: 28px 0 22px; font: 400 clamp(52px, 6vw, 90px)/.9 Georgia, serif; letter-spacing: -.06em; overflow-wrap: anywhere; }
.dialog-question { margin: 0 0 34px; font-size: 17px; line-height: 1.5; }
.metadata-panel dl { margin: 0; border-top: 1px solid var(--line); }
.metadata-panel dl > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.metadata-panel dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.metadata-panel dd { margin: 0; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 24px 0; }
.dialog-actions button, .dialog-actions a { display: grid; place-items: center; min-height: 44px; border: 1px solid var(--ink); background: transparent; color: var(--ink); text-decoration: none; font-size: 12px; }
.dialog-actions button:hover, .dialog-actions a:hover { background: var(--ink); color: white; }
.metadata-panel details { border-top: 1px solid var(--line); padding: 14px 0; }
.metadata-panel summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 750; }
.metadata-panel details p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.metadata-panel pre { padding: 13px; overflow: auto; background: #ebe7de; font: 10px/1.5 ui-monospace, monospace; white-space: pre-wrap; }
#toast { position: fixed; z-index: 50; right: 20px; bottom: 20px; padding: 12px 16px; background: var(--ink); color: white; font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .masthead-meta #load-state { display: none; }
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-layout { grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr); }
}
@media (max-width: 780px) {
  .masthead { padding: 8px 14px 0; height: auto; flex-wrap: wrap; }
  .site-nav { order: 3; width: 100%; margin: 0; }
  .masthead-meta #load-state { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero > div + div { border-left: 0; border-top: 1px solid var(--ink); }
  .hero h1 { margin-top: 30px; }
  .explorer-shell { grid-template-columns: 1fr; }
  .filters { position: static; min-height: 0; max-height: none; border-right: 0; border-bottom: 1px solid var(--ink); }
  .category-index { display: none; }
  .results-head { min-height: 105px; }
  .record-grid { grid-template-columns: 1fr; }
  .dialog-layout { display: block; overflow-y: auto; }
  .image-panel { height: 55vh; border-right: 0; border-bottom: 1px solid var(--ink); }
  .metadata-panel { overflow: visible; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
