:root {
  --ink: #1e201b;
  --paper: #f1eee5;
  --paper-deep: #e3ded0;
  --acid: #e7ff46;
  --red: #e95735;
  --line: rgba(30, 32, 27, 0.22);
  --serif: "Iowan Old Style", "Baskerville", "Noto Serif SC", serif;
  --sans: "Avenir Next", "Futura", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 4%, rgba(231, 255, 70, 0.34), transparent 22rem),
    var(--paper);
  font-family: var(--sans);
}

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

.grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.site-header,
main {
  width: min(1320px, calc(100% - 64px));
  margin-inline: auto;
}

.site-header {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  font: 24px var(--serif);
  transform: rotate(-3deg);
}

.brand small {
  display: block;
  margin-top: 7px;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.28em;
}

.api-button {
  min-height: 42px;
  padding: 0 17px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.api-button:hover { background: var(--acid); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5b9a35;
  box-shadow: 0 0 0 4px rgba(91, 154, 53, 0.14);
}

.eyebrow {
  margin: 0 0 20px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.23em;
}

.gallery-section {
  padding: 64px 0 140px;
  scroll-margin-top: 20px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 52px;
}

.section-heading h2,
.dialog-head h2 {
  margin: 0;
  font: 500 clamp(42px, 5vw, 68px)/1 var(--serif);
  letter-spacing: -0.05em;
}

.gallery-count {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.gallery-list {
  display: grid;
  gap: 36px;
}

.collection {
  animation: rise 500ms both;
}

.collection-head {
  min-height: 96px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--ink);
}

.collection-toggle {
  min-width: 0;
  flex: 1;
  padding: 18px 10px 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.collection-title {
  display: grid;
  grid-template-columns: 88px auto;
  align-items: baseline;
  gap: 5px 18px;
}

.collection-number {
  grid-row: 1 / span 2;
  color: var(--red);
  font: 13px var(--serif);
}

.collection-name {
  font: 500 34px/1.12 var(--serif);
}

.collection-meta {
  font-size: 10px;
  letter-spacing: 0.12em;
}

.collection-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 22px;
}

.download-all {
  min-height: 48px;
  padding: 0 10px 0 18px;
  display: flex;
  align-items: center;
  gap: 22px;
  border: 1px solid var(--ink);
  background: var(--acid);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.download-all b {
  padding: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.image-grid {
  padding-top: 18px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.image-grid[hidden] { display: none; }

.image-card {
  min-height: 320px;
  grid-column: span 4;
  position: relative;
  margin: 0;
  overflow: hidden;
  background: var(--paper-deep);
}

.image-card:nth-child(5n + 1) { grid-column: span 5; }
.image-card:nth-child(5n + 2) { grid-column: span 7; }

.image-view {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.image-view img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
  object-fit: cover;
  filter: saturate(0.9);
  transition: transform 500ms cubic-bezier(.2,.7,.2,1), filter 300ms ease;
}

.image-view:hover img {
  transform: scale(1.035);
  filter: saturate(1.05);
}

.image-index {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 7px 9px;
  background: var(--acid);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  pointer-events: none;
}

.image-download {
  min-width: 98px;
  min-height: 46px;
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 7px 6px 15px;
  background: rgba(30, 32, 27, 0.92);
  color: white;
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.image-download b {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--acid);
  color: var(--ink);
  font-size: 17px;
}

.empty-state {
  min-height: 330px;
  display: grid;
  place-content: center;
  text-align: center;
  border: 1px dashed rgba(30, 32, 27, 0.35);
}

.empty-state span {
  color: var(--red);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.empty-state h3 {
  margin: 15px 0 5px;
  font: 500 30px var(--serif);
}

.empty-state p {
  margin: 0;
  color: rgba(30, 32, 27, 0.55);
  font-size: 12px;
}

.api-dialog {
  width: min(720px, calc(100% - 32px));
  padding: 38px;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 14px 14px 0 var(--ink);
}

.api-dialog::backdrop {
  background: rgba(30, 32, 27, 0.72);
  backdrop-filter: blur(5px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.dialog-head h2 { font-size: 45px; }

.dialog-head > button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: none;
  font-size: 25px;
  cursor: pointer;
}

.api-dialog > p { font: 15px/1.8 var(--serif); }
.code-block { margin-top: 27px; background: var(--ink); color: #f4f0e6; }

.code-label {
  padding: 13px 16px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.18);
  color: var(--acid);
  font-size: 10px;
  letter-spacing: .12em;
}

.code-label button {
  border: 0;
  background: none;
  color: white;
  cursor: pointer;
}

pre {
  margin: 0;
  padding: 22px;
  overflow-x: auto;
  font: 12px/1.7 "SFMono-Regular", Consolas, monospace;
}

.api-note {
  color: rgba(30, 32, 27, 0.65);
  font-size: 13px !important;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 75px 30px 30px;
  background: rgba(17, 18, 15, 0.96);
}

.lightbox[hidden] { display: none; }

.lightbox img {
  max-width: 94vw;
  max-height: calc(100vh - 130px);
  object-fit: contain;
}

.lightbox-bar {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  color: white;
}

.lightbox-bar p {
  margin: 0;
  overflow: hidden;
  font: 15px var(--serif);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-bar > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-download {
  min-height: 42px;
  padding: 0 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.5);
  color: white;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.lightbox-bar button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 50%;
  background: none;
  color: white;
  font-size: 27px;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 50;
  padding: 14px 22px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  transform: translate(-50%, 120px);
  transition: transform 250ms ease;
}

.toast.show { transform: translate(-50%, 0); }

@keyframes rise {
  from { opacity: 0; transform: translateY(25px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 700px) {
  .site-header,
  main {
    width: calc(100% - 28px);
  }

  .site-header {
    height: 76px;
    padding-top: env(safe-area-inset-top);
  }

  .brand { gap: 10px; font-size: 12px; }
  .brand-mark { width: 38px; height: 38px; font-size: 20px; }
  .brand small { margin-top: 5px; font-size: 6px; }
  .api-button { min-height: 38px; padding: 0 12px; font-size: 10px; }

  .eyebrow { margin-bottom: 15px; font-size: 8px; }

  .gallery-section {
    padding: 38px 0 calc(90px + env(safe-area-inset-bottom));
  }

  .section-heading { margin-bottom: 38px; }
  .section-heading h2 { font-size: 44px; }
  .gallery-count { display: none; }
  .gallery-list { gap: 28px; }

  .collection-head {
    min-height: 0;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 12px;
  }

  .collection-toggle {
    width: 100%;
    padding: 8px 0 4px;
  }

  .collection-title {
    grid-template-columns: 52px 1fr;
    gap: 5px 8px;
  }

  .collection-number { font-size: 11px; }
  .collection-name { font-size: 28px; }
  .collection-meta { font-size: 9px; }

  .collection-actions {
    width: 100%;
    display: block;
  }

  .download-all {
    width: 100%;
    min-height: 52px;
    justify-content: space-between;
    font-size: 13px;
  }

  .image-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    padding-top: 14px;
  }

  .image-card,
  .image-card:nth-child(n) {
    min-height: 0;
    grid-column: 1;
    aspect-ratio: 4 / 5;
  }

  .image-view,
  .image-view img { min-height: 0; }

  .image-download {
    right: 10px;
    bottom: 10px;
    min-width: 104px;
    min-height: 48px;
  }

  .image-index { left: 10px; top: 10px; }

  .api-dialog {
    max-height: calc(100vh - 28px);
    padding: 24px 20px;
    overflow-y: auto;
    box-shadow: 7px 7px 0 var(--ink);
  }

  .dialog-head h2 { font-size: 36px; }
  .api-dialog > p { font-size: 14px; }
  pre { padding: 16px; font-size: 10px; }

  .lightbox {
    padding: 75px 10px calc(16px + env(safe-area-inset-bottom));
  }

  .lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 105px - env(safe-area-inset-bottom));
  }

  .lightbox-bar {
    left: 12px;
    right: 12px;
  }

  .lightbox-bar p { max-width: 42vw; font-size: 12px; }
}

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