:root {
  --red: #e3120b;
  --red-dark: #c10d08;
  --ink: #1a1918;
  --ink-soft: #434140;
  --muted: #6b6864;
  --line: #ddd8cf;
  --paper: #f7f4ee;
  --paper-deep: #efeae0;
  --card: #fffdf8;
  --shadow: 0 1px 2px rgba(26, 25, 24, 0.06), 0 8px 24px rgba(26, 25, 24, 0.06);
  --serif: "Source Serif Pro", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans: "Source Sans Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --max: 1180px;
  --header-h: 0px;
}

@font-face {
  font-family: "Source Serif Pro";
  src: url("fonts/SourceSerifPro-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif Pro";
  src: url("fonts/SourceSerifPro-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans Pro";
  src: url("fonts/SourceSansPro-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans Pro";
  src: url("fonts/SourceSansPro-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans Pro";
  src: url("fonts/SourceSansPro-It.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

img { max-width: 100%; height: auto; display: block; }

a { color: var(--red); }
a:hover { color: var(--red-dark); }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--red);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip:focus { left: 0; }

.masthead {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.masthead-bar {
  height: 5px;
  background: var(--red);
}

.masthead-inner, .toolbar-inner, .wrap, .footer-inner {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
}

.masthead-inner {
  padding: 1.15rem 0 1.05rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1.5rem;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.25rem);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
  color: var(--ink);
}

.wordmark span {
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 244, 238, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.toolbar-inner {
  padding: 0.7rem 0 0.8rem;
  display: grid;
  gap: 0.65rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}

.decade {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
}

.decade button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  border-right: 1px solid var(--line);
}

.decade button:last-child { border-right: 0; }
.decade button:hover { background: var(--paper-deep); }
.decade button[aria-pressed="true"] {
  background: var(--red);
  color: #fff;
}

label.field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

select, input[type="search"] {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
}

select:focus, input[type="search"]:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

.search-wrap {
  flex: 1 1 16rem;
  min-width: 12rem;
}

.search-wrap input {
  width: 100%;
}

.status {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.status strong { color: var(--ink-soft); font-weight: 600; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1.15rem 0.85rem;
  padding: 1.25rem 0 2.5rem;
}

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 1.35rem 1rem; }
}

.card {
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  width: 100%;
  border-radius: 2px;
}

.card:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.cover {
  background: var(--paper-deep);
  aspect-ratio: 400 / 526;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover .cover, .card:focus-visible .cover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(26, 25, 24, 0.14);
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--paper-deep);
}

.placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.8rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #c9c2b5;
  background:
    repeating-linear-gradient(
      -45deg,
      #f3efe6,
      #f3efe6 8px,
      #efe8db 8px,
      #efe8db 16px
    );
}

.placeholder strong {
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.placeholder span { font-size: 0.78rem; line-height: 1.3; }

.meta { padding: 0.45rem 0.1rem 0; }

.date {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--red);
  margin-bottom: 0.1rem;
}

.headline {
  display: block;
  font-size: 0.86rem;
  line-height: 1.25;
  color: var(--ink);
  /* two-line clamp */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.headline.unknown {
  font-style: italic;
  color: var(--muted);
  font-weight: 400;
}

.empty {
  padding: 3rem 0 4rem;
  text-align: center;
  color: var(--muted);
}

.empty h2 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.4rem;
}

.footer {
  border-top: 1px solid var(--line);
  background: var(--paper-deep);
  padding: 1.5rem 0 2.2rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.footer h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
}

.footer p { margin: 0 0 0.7rem; max-width: 62ch; }
.footer p:last-child { margin-bottom: 0; }

/* Lightbox */
.lightbox[hidden] { display: none; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(18, 16, 14, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox-dialog {
  width: min(720px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--card);
  color: var(--ink);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  position: relative;
  padding: 0.75rem 0.75rem 1.1rem;
}

.lightbox-image {
  background: var(--paper-deep);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image img {
  max-height: min(72vh, 820px);
  width: auto;
  margin: 0 auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.lightbox-image .placeholder {
  min-height: 280px;
  aspect-ratio: 400 / 526;
  max-width: 320px;
  margin: 0 auto;
}

.lightbox-body { padding: 0.9rem 0.6rem 0.2rem; }

.lightbox-body .date {
  font-size: 0.86rem;
  margin-bottom: 0.25rem;
}

.lightbox-body h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.2rem, 3vw, 1.7rem);
  line-height: 1.2;
  margin: 0 0 0.7rem;
}

.lightbox-body h2.unknown {
  font-style: italic;
  font-weight: 400;
  color: var(--muted);
}

.edition-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 0.05rem;
}

.chrome-btn {
  appearance: none;
  border: 0;
  background: rgba(26, 25, 24, 0.08);
  color: var(--ink);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chrome-btn:hover { background: rgba(26, 25, 24, 0.16); }
.chrome-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.lightbox-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255, 253, 248, 0.92);
  z-index: 2;
}

.lightbox-nav {
  position: absolute;
  top: 38%;
  transform: translateY(-50%);
  background: rgba(255, 253, 248, 0.92);
}

.lightbox-nav.prev { left: 0.4rem; }
.lightbox-nav.next { right: 0.4rem; }

.lightbox-nav[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 639px) {
  .masthead-inner, .toolbar-inner, .wrap, .footer-inner {
    width: min(var(--max), calc(100% - 1.25rem));
  }
  .decade button { padding: 0.38rem 0.58rem; font-size: 0.78rem; }
  .lightbox { padding: 0.5rem; }
  .lightbox-dialog { max-height: calc(100vh - 1rem); }
  .lightbox-nav { top: auto; bottom: 5.6rem; transform: none; }
}
