:root {
  --paper: #f3f0ea;
  --ink: #1c1b19;
  --muted: #6f6a62;
  --line: #ddd7cc;
  --card: #fbfaf7;
  --queue: #e7e1d6;
  --accent: #7d332c;
  --shadow: 0 18px 50px rgba(28, 27, 25, 0.16);
  --serif: Newsreader, "Iowan Old Style", Palatino, Georgia, serif;
  --sans: Outfit, "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
}

body {
  min-height: 100vh;
}

button, input {
  font: inherit;
  color: inherit;
}

.top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 460px);
  gap: 32px;
  align-items: end;
  padding: 28px 32px 18px;
  border-bottom: 1px solid var(--line);
}

.mark {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(40px, 5vw, 68px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 0.92;
}

.subtitle {
  margin: 8px 0 0;
  max-width: 46rem;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 18px;
  font-style: italic;
  line-height: 1.35;
}

.tools {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.search {
  display: grid;
  gap: 4px;
  width: min(100%, 420px);
}

.search span, .ready span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.search input {
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  outline: none;
}

.search input:focus {
  border-bottom-color: var(--accent);
}

.ready {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
}

.progress {
  height: 2px;
  background: var(--line);
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 140px);
}

nav {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow: auto;
  padding: 18px 0 40px;
  border-right: 1px solid var(--line);
}

nav button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  padding: 9px 18px 9px 22px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

nav button strong {
  font-weight: 500;
  font-size: 14px;
  line-height: 1.3;
}

nav button em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}

nav button[aria-current="true"] {
  box-shadow: inset 2px 0 0 var(--ink);
}

nav button:hover strong {
  text-decoration: underline;
  text-underline-offset: 3px;
}

main {
  padding: 28px 32px 72px;
}

.blurb {
  max-width: 42rem;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.group {
  margin: 0 0 36px;
}

.group h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.note {
  margin: 6px 0 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px 16px;
  margin-top: 16px;
}

.card {
  display: grid;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.frame {
  display: block;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--queue);
  border: 1px solid var(--line);
}

.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.queued {
  display: flex;
  height: 100%;
  align-items: flex-end;
  padding: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.meta .num {
  font-variant-numeric: tabular-nums;
}

.who {
  color: var(--accent);
  letter-spacing: 0.08em;
}

.meta .section, .where {
  color: var(--muted);
  font-weight: 500;
}

.excerpt {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.3;
}

.card:hover .frame {
  border-color: var(--ink);
}

.card:focus-visible, nav button:focus-visible, .viewer-actions button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.empty {
  margin: 48px 0;
  font-family: var(--serif);
  font-size: 28px;
}

dialog {
  width: min(1080px, calc(100vw - 40px));
  height: min(780px, calc(100vh - 40px));
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--card);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(28, 27, 25, 0.48);
}

dialog[open] {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
}

.viewer-frame {
  background: var(--queue);
  min-height: 0;
}

.viewer-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ece7de;
}

.viewer-frame .queued {
  height: 100%;
  align-items: center;
  justify-content: center;
}

.viewer-copy {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 28px 28px 20px;
  border-left: 1px solid var(--line);
}

.viewer-kicker {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.viewer-prompt {
  margin: 0;
  overflow: auto;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.4;
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
}

.viewer-actions button {
  padding: 8px 12px;
  border: 1px solid var(--ink);
  background: transparent;
  cursor: pointer;
}

.viewer-actions button:hover {
  background: var(--ink);
  color: var(--paper);
}

@media (max-width: 860px) {
  .top, .shell, dialog[open] {
    grid-template-columns: 1fr;
  }

  .tools {
    justify-items: start;
  }

  nav {
    position: static;
    max-height: none;
    display: flex;
    gap: 0;
    overflow-x: auto;
    background: var(--paper);
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0;
  }

  nav button {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
    border-right: 1px solid var(--line);
  }

  nav button[aria-current="true"] {
    box-shadow: inset 0 -2px 0 var(--ink);
  }

  .viewer-frame {
    height: 46vh;
  }

  .viewer-copy {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
