:root {
  --bg: #f4efe4;
  --paper: rgba(255, 251, 243, 0.9);
  --paper-strong: #fffaf1;
  --paper-deep: #efe5d2;
  --ink: #1f2a24;
  --muted: #5e675f;
  --line: rgba(31, 42, 36, 0.12);
  --accent: #0d5c46;
  --accent-2: #b4642a;
  --shadow: 0 20px 50px rgba(43, 48, 33, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Work Sans", sans-serif;
  font-size: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 18%),
    radial-gradient(circle at top left, rgba(180, 100, 42, 0.16), transparent 32%),
    radial-gradient(circle at top right, rgba(13, 92, 70, 0.13), transparent 28%),
    linear-gradient(180deg, #f8f2e7 0%, var(--bg) 100%);
}

.page-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 118px;
}

.hero,
.controls,
.category-section,
.archive-callout {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero,
.controls,
.category-section,
.archive-callout {
  padding: 28px;
}

.hero {
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -110px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(180, 100, 42, 0.16), transparent 68%);
  pointer-events: none;
}

.eyebrow,
.panel-label,
.filters-title,
.card-category,
.section-kicker {
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
}

.hero h1 {
  margin: 10px 0 12px;
  max-width: 9ch;
  font-family: "Fraunces", serif;
  font-size: clamp(2.5rem, 6vw, 4.8rem);
  line-height: 1;
}

.hero-copywrap {
  position: relative;
  z-index: 1;
}

.hero-brand {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(220px, 320px);
  gap: 20px;
  align-items: center;
}

.hero-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 240px;
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.52), rgba(255,255,255,0.86));
  border: 1px solid var(--line);
}

.hero-logo {
  display: block;
  width: min(100%, 290px);
  max-height: 260px;
  object-fit: contain;
  filter: drop-shadow(0 14px 24px rgba(43, 48, 33, 0.12));
}

.hero-copy,
.filters-subtitle,
.card-path,
.stat-caption,
.config-warning {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.hero-copy-strong {
  color: var(--ink);
  font-weight: 700;
}

.hero-note {
  max-width: 52ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.shelf-copy {
  margin: 2px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.hero-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.summary-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.summary-card strong {
  color: var(--ink);
  font-family: "Fraunces", serif;
  font-size: 1.55rem;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.quick-link,
.chip,
.primary-link,
.ghost-button,
.ghost-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  transition: 140ms ease;
}

.quick-link,
.chip {
  border: 1px solid rgba(13, 92, 70, 0.18);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
}

.quick-link {
  gap: 8px;
  border-radius: 999px;
  padding: 0 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.68), rgba(255,255,255,0.98)),
    var(--paper-deep);
}

.quick-link strong {
  font-size: 0.98rem;
}

.quick-link-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.ghost-button,
.ghost-link {
  border: 1px solid rgba(13, 92, 70, 0.18);
  background: white;
  color: var(--ink);
  cursor: pointer;
}

.quick-link:hover,
.chip:hover,
.chip:focus-visible,
.primary-link:hover {
  transform: translateY(-1px);
}

.stat-number,
.stat-date {
  margin: 8px 0 4px;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 4vw, 3rem);
}

.controls {
  margin-top: 22px;
}

.search-field {
  display: grid;
  gap: 10px;
}

.search-field span {
  font-size: 0.9rem;
  font-weight: 600;
}

input {
  width: 100%;
  border: 1px solid rgba(13, 92, 70, 0.18);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: white;
}

input:focus {
  outline: 2px solid rgba(13, 92, 70, 0.16);
  border-color: var(--accent);
}

.filters-header,
.section-head,
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.filters-header {
  margin-top: 18px;
}

.result-count,
.section-count {
  margin: 0;
  font-weight: 700;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.chip {
  cursor: pointer;
}

.chip.is-active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.config-warning {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(180, 100, 42, 0.12);
}

.config-warning code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.sections {
  margin-top: 22px;
  display: grid;
  gap: 18px;
}

.page-intro {
  display: grid;
  gap: 8px;
  padding: 24px 28px;
  margin-top: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.page-intro-title {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.page-intro-copy {
  margin: 0;
  color: var(--muted);
}

.page-back {
  width: fit-content;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(13, 92, 70, 0.18);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.library-group {
  display: grid;
  gap: 18px;
}

.library-group-head {
  display: grid;
  gap: 4px;
  padding: 8px 6px 0;
}

.library-group-title {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.98;
}

.archive-callout {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.archive-callout h2 {
  margin: 10px 0 8px;
  font-family: "Fraunces", serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.archive-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  max-width: 60ch;
}

.archive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title {
  margin: 6px 0 0;
  font-family: "Fraunces", serif;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
}

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

.section-foot {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.section-toggle {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(13, 92, 70, 0.18);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: 140ms ease;
}

.section-toggle:hover,
.section-toggle:focus-visible {
  transform: translateY(-1px);
}

.category-section {
  position: relative;
  overflow: hidden;
}

.category-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.card {
  display: grid;
  gap: 12px;
  padding: 18px;
  min-height: 292px;
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 24px;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 42px rgba(43, 48, 33, 0.12);
}

.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
}

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

.card-title {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.35;
}

.card-meta {
  margin: -6px 0 0;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 600;
}

.card-path {
  font-size: 0.92rem;
  word-break: break-word;
}

.card-preview {
  min-height: 154px;
  border-radius: 18px;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(13, 92, 70, 0.12), rgba(180, 100, 42, 0.16)),
    var(--paper-deep);
  border: 1px solid rgba(13, 92, 70, 0.12);
}

.card-thumb {
  display: block;
  width: 100%;
  height: 154px;
  object-fit: cover;
  background: white;
}

.card-poster {
  display: grid;
  align-content: end;
  gap: 8px;
  height: 154px;
  padding: 16px;
  background:
    linear-gradient(150deg, rgba(255,255,255,0.12), transparent 65%),
    radial-gradient(circle at top left, rgba(255,255,255,0.45), transparent 35%);
}

.card-poster strong {
  font-family: "Fraunces", serif;
  font-size: 1.18rem;
  line-height: 1.05;
}

.card-poster p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.card-poster-badge {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-link {
  width: fit-content;
  background: var(--accent);
  color: white;
}

.primary-link.is-disabled {
  background: #a8b4ae;
  pointer-events: none;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 20, 0.72);
}

.viewer-panel {
  position: relative;
  width: min(1100px, calc(100% - 20px));
  height: min(90vh, 900px);
  margin: 5vh auto;
  background: var(--paper-strong);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.viewer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.viewer-title {
  margin: 0;
  font-weight: 700;
}

.viewer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.viewer-frame {
  width: 100%;
  height: calc(100% - 71px);
  border: 0;
  background: white;
}

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 30;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 160ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.mobile-dock {
  display: none;
}

.empty-state {
  padding: 26px;
  border-radius: 24px;
  border: 1px dashed rgba(13, 92, 70, 0.28);
  background: rgba(255, 255, 255, 0.5);
}

@media (max-width: 860px) {
  .page-shell {
    width: min(100%, calc(100% - 18px));
    padding: 18px 0 108px;
  }

  .hero-brand {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(2.2rem, 10vw, 3.2rem);
    line-height: 1.02;
  }

  .hero-copy {
    font-size: 0.98rem;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-link {
    justify-content: center;
    padding: 0 14px;
  }

  .hero-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .archive-callout {
    flex-direction: column;
    align-items: start;
  }

  .filters-header,
  .section-head,
  .card-head {
    flex-direction: column;
    align-items: start;
  }

  .section-grid {
    grid-template-columns: 1fr;
  }

  .card {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .card-preview {
    display: block;
    min-height: 92px;
  }

  .card-thumb,
  .card-poster {
    height: 92px;
  }

  .card-meta {
    margin: 0;
    font-size: 0.82rem;
  }

  .card-actions {
    gap: 8px;
  }

  .card-actions .ghost-button,
  .card-actions .primary-link {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  .mobile-dock {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 12px;
    z-index: 35;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 250, 241, 0.94);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
  }

  .hero-logo-wrap {
    min-height: 160px;
    padding: 14px;
  }

  .hero-logo {
    width: min(100%, 220px);
    max-height: 190px;
  }

  .dock-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    padding: 0 8px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 700;
    background: white;
  }

  .back-to-top {
    right: 14px;
    bottom: 84px;
  }
}
