:root {
  --bg: #f6f1e6;
  --paper: #fffaf0;
  --paper-strong: #fffdf7;
  --forest: #063a2d;
  --forest-2: #10513f;
  --ink: #122f2b;
  --blue: #15364a;
  --teal: #177a7d;
  --olive: #697c2e;
  --amber: #bd7a12;
  --sand: #d4b778;
  --muted: #5f6f69;
  --line: #ded2bd;
  --line-strong: #c9b991;
  --shadow: 0 16px 36px rgba(20, 42, 37, 0.12);
  --soft-shadow: 0 8px 18px rgba(20, 42, 37, 0.1);
  --radius: 8px;
  --shell: min(1180px, calc(100vw - 36px));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(246, 241, 230, 0.94), rgba(246, 241, 230, 0.96)),
    repeating-linear-gradient(0deg, rgba(21, 54, 74, 0.055) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(90deg, rgba(23, 122, 125, 0.05) 0 1px, transparent 1px 42px),
    var(--bg);
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-radial-gradient(ellipse at 18% 12%, transparent 0 18px, rgba(6, 58, 45, 0.045) 19px 20px, transparent 21px 42px),
    repeating-radial-gradient(ellipse at 86% 20%, transparent 0 24px, rgba(21, 54, 74, 0.045) 25px 26px, transparent 27px 56px);
  opacity: 0.6;
  z-index: -1;
}

img,
svg {
  display: block;
}

img {
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.shell {
  width: var(--shell);
  margin-inline: auto;
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  transform: translateY(-140%);
  padding: 10px 14px;
  background: var(--forest);
  color: #fff;
  border-radius: var(--radius);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246, 241, 230, 0.9);
  border-bottom: 1px solid rgba(201, 185, 145, 0.75);
  backdrop-filter: blur(18px);
}

.header-inner,
.footer-inner {
  width: var(--shell);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.header-inner {
  min-height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background:
    linear-gradient(135deg, var(--forest), var(--teal));
  border: 3px solid rgba(255, 250, 240, 0.92);
  box-shadow: var(--soft-shadow);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px 12px 11px 12px;
  border: 2px solid #fffaf0;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg);
}

.brand strong {
  display: block;
  color: var(--forest);
  font-size: 1rem;
  letter-spacing: 0;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav a,
.button,
.icon-button,
.filter-chip {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.site-nav a {
  padding: 9px 12px;
  color: var(--blue);
  font-weight: 650;
  font-size: 0.93rem;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: rgba(23, 122, 125, 0.12);
  color: var(--forest);
}

.button {
  padding: 10px 14px;
  font-weight: 750;
  font-size: 0.94rem;
}

.button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button.primary {
  background: var(--forest);
  color: #fffaf0;
  box-shadow: var(--soft-shadow);
}

.button.primary:hover,
.button.primary:focus-visible {
  background: var(--forest-2);
  transform: translateY(-1px);
}

.button.secondary {
  background: var(--paper-strong);
  border-color: var(--line);
  color: var(--forest);
}

.button.secondary:hover,
.button.secondary:focus-visible,
.button.quiet:hover,
.button.quiet:focus-visible {
  border-color: var(--teal);
  background: rgba(23, 122, 125, 0.1);
}

.button.quiet {
  background: transparent;
  color: var(--blue);
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--paper-strong);
  border-color: var(--line);
  color: var(--forest);
}

.icon-button:hover,
.icon-button:focus-visible,
.icon-button[aria-pressed="true"] {
  background: var(--forest);
  color: #fffaf0;
}

.home-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  padding: 58px 0 26px;
  align-items: end;
}

.eyeless-label,
.page-label {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--forest);
  line-height: 1.08;
  letter-spacing: 0;
}

.intro-copy h1,
.collection-copy h1 {
  max-width: 880px;
  font-size: clamp(2.35rem, 6vw, 5.6rem);
  font-weight: 900;
  text-wrap: balance;
}

.intro-copy p:last-child,
.collection-copy p:not(.collection-count) {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--blue);
  font-size: clamp(1.04rem, 2vw, 1.28rem);
}

.collection-count {
  margin: 16px 0 0;
  color: var(--amber);
  font-size: 0.95rem;
  font-weight: 850;
}

.intro-stats {
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.intro-stats span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  background: rgba(255, 250, 240, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  box-shadow: var(--soft-shadow);
}

.intro-stats strong {
  color: var(--forest);
  font-size: 1.16rem;
}

.collection-list {
  display: grid;
  gap: 22px;
  padding: 18px 0 70px;
}

.collection-card {
  display: grid;
  grid-template-columns: minmax(260px, 42%) minmax(0, 1fr);
  gap: 0;
  background: rgba(255, 250, 240, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: clip;
  box-shadow: var(--shadow);
}

.collection-media {
  background: var(--forest);
  min-height: 280px;
}

.collection-media img,
.cover-preview img,
.page-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.collection-media img {
  object-fit: contain;
  padding: 12px;
}

.collection-card-body {
  padding: clamp(24px, 4vw, 44px);
}

.collection-card h2 {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
}

.collection-card h2 a,
.page-card h2 a {
  text-decoration: none;
}

.collection-card p {
  max-width: 720px;
  color: var(--muted);
  font-size: 1rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 22px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  background: rgba(23, 122, 125, 0.1);
  border: 1px solid rgba(23, 122, 125, 0.2);
  border-radius: 999px;
  color: var(--forest);
  font-size: 0.8rem;
  font-weight: 700;
}

.breadcrumbs {
  padding: 26px 0 0;
}

.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.breadcrumbs li + li::before {
  content: "/";
  color: var(--line-strong);
}

.breadcrumbs a {
  color: var(--blue);
  text-decoration-color: rgba(21, 54, 74, 0.35);
}

.collection-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 32px;
  align-items: center;
  padding: 38px 0 30px;
}

.cover-preview {
  aspect-ratio: 1.5;
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.browser-layout {
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 12px 0 72px;
}

.toc-panel,
.page-card,
.page-meta,
.related-card,
.toolbar,
.tag-filter,
.empty-state,
.error-state,
.loading-state {
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
}

.toc-panel {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 18px;
}

.toc-panel h2 {
  font-size: 1.12rem;
  margin-bottom: 14px;
}

.toc-group + .toc-group {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.toc-group h3 {
  color: var(--blue);
  font-size: 0.92rem;
  line-height: 1.25;
}

.toc-group ol {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 6px;
}

.toc-group a {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.86rem;
}

.toc-group a:hover,
.toc-group a:focus-visible {
  background: rgba(23, 122, 125, 0.1);
}

.toc-group span {
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.gallery-panel {
  min-width: 0;
}

.toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  margin-bottom: 14px;
}

.search-box {
  min-width: 0;
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 13px;
  width: 19px;
  height: 19px;
  stroke: var(--teal);
  stroke-width: 2;
  fill: none;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px 10px 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  color: var(--ink);
  outline: none;
}

.search-box input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 122, 125, 0.16);
}

.result-count {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
}

.filter-section {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.filter-chip {
  padding: 8px 11px;
  background: rgba(255, 250, 240, 0.78);
  border-color: var(--line);
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 750;
}

.filter-chip:hover,
.filter-chip:focus-visible,
.filter-chip.is-active {
  color: #fffaf0;
  background: var(--forest);
  border-color: var(--forest);
}

.filter-chip.subtle.is-active {
  background: var(--teal);
  border-color: var(--teal);
}

.tag-filter {
  padding: 12px 14px 2px;
  margin-bottom: 18px;
}

.tag-filter summary {
  cursor: pointer;
  color: var(--forest);
  font-weight: 850;
  margin-bottom: 10px;
}

.tag-scroll {
  max-height: 172px;
  overflow: auto;
  padding-bottom: 10px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.page-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page-thumb {
  aspect-ratio: 1.414;
  background: #ece3d1;
  border-bottom: 1px solid var(--line);
}

.page-card-body {
  padding: 16px;
}

.page-card h2 {
  font-size: 1.12rem;
  line-height: 1.18;
}

.page-card p:not(.page-label) {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.91rem;
}

.page-card .tag-row {
  margin-bottom: 0;
}

.viewer {
  padding: 30px 0 78px;
}

.viewer-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: start;
  margin-bottom: 18px;
}

.viewer-header h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  max-width: 950px;
}

.viewer-header p:not(.page-label) {
  max-width: 850px;
  color: var(--blue);
  font-size: 1.05rem;
}

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

.viewer-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.viewer-nav > :last-child {
  justify-self: end;
}

.viewer-frame {
  margin: 0;
  background: rgba(255, 250, 240, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.image-scroll {
  width: 100%;
  max-height: min(78vh, 920px);
  overflow: auto;
  padding: clamp(10px, 1.6vw, 18px);
}

.viewer-image {
  width: 100%;
  max-width: 1491px;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(18, 47, 43, 0.16);
  cursor: zoom-in;
}

.viewer-image.is-zoomed {
  max-width: none;
  width: min(1491px, 180vw);
  cursor: zoom-out;
}

.page-meta {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  margin-top: 18px;
}

.page-meta h2 {
  color: var(--blue);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.page-meta p {
  margin: 8px 0 0;
  font-weight: 760;
}

.related-pages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.related-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  text-decoration: none;
}

.related-card:hover,
.related-card:focus-visible {
  border-color: var(--teal);
  background: var(--paper-strong);
}

.related-card span,
.related-card small {
  color: var(--muted);
  font-weight: 750;
}

.related-card strong {
  color: var(--forest);
  font-size: 1.05rem;
}

.empty-state,
.error-state,
.loading-state {
  padding: 38px;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(6, 58, 45, 0.94);
  color: #fffaf0;
}

.footer-inner {
  min-height: 82px;
  padding: 18px 0;
}

.footer-inner p {
  margin: 0;
  color: rgba(255, 250, 240, 0.78);
}

.footer-inner a {
  color: #fffaf0;
  font-weight: 800;
  text-decoration-color: rgba(255, 250, 240, 0.45);
}

:focus-visible {
  outline: 3px solid rgba(189, 122, 18, 0.75);
  outline-offset: 3px;
}

@media (max-width: 980px) {
  .home-intro,
  .collection-hero,
  .collection-card,
  .browser-layout {
    grid-template-columns: 1fr;
  }

  .toc-panel {
    position: static;
    max-height: none;
  }

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

@media (max-width: 680px) {
  :root {
    --shell: min(100vw - 24px, 1180px);
  }

  .header-inner,
  .footer-inner,
  .toolbar,
  .viewer-header,
  .page-meta,
  .related-pages {
    grid-template-columns: 1fr;
  }

  .header-inner,
  .footer-inner,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .site-nav {
    overflow-x: auto;
    padding-bottom: 10px;
  }

  .home-intro {
    padding-top: 34px;
  }

  .intro-copy h1,
  .collection-copy h1 {
    font-size: clamp(2.15rem, 13vw, 3.35rem);
  }

  .collection-card-body {
    padding: 22px;
  }

  .collection-media {
    min-height: 220px;
  }

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

  .result-count {
    white-space: normal;
  }

  .viewer-nav {
    grid-template-columns: 1fr;
  }

  .viewer-nav > :last-child {
    justify-self: stretch;
  }

  .viewer-nav .button {
    width: 100%;
  }

  .image-scroll {
    max-height: 72vh;
    padding: 8px;
  }

  .viewer-image.is-zoomed {
    width: 150vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
