:root {
  --bg: #f4f0e5;
  --paper: #fffdf7;
  --ink: #1d1f22;
  --muted: #596169;
  --accent: #b3362d;
  --accent-soft: #d9734e;
  --line: #dfd5bd;
  --shadow: 0 8px 20px rgba(29, 31, 34, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, #fff7de 0, transparent 35%),
    radial-gradient(circle at 88% 8%, #f0dcc9 0, transparent 24%),
    linear-gradient(160deg, #efe4cf 0%, #f8f5ec 45%, #ece7db 100%);
  min-height: 100vh;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.85), rgba(255, 253, 247, 0.55));
  backdrop-filter: blur(3px);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2.5rem 1rem 2rem;
}

.back-link {
  display: inline-block;
  margin: 0 0 0.9rem;
  font: 600 0.78rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.6);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(179, 54, 45, 0.08);
}

.eyebrow {
  margin: 0;
  font: 600 0.78rem/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0.4rem 0 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  letter-spacing: -0.02em;
}

.summary {
  margin: 0.6rem 0 0;
  color: var(--muted);
}

.gallery-root {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.folder-section {
  margin: 1.5rem 0 2.5rem;
  padding-top: 0.7rem;
  border-top: 2px solid var(--line);
  animation: fadeInUp 0.35s ease both;
}

.folder-title {
  margin: 0 0 0.8rem;
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.image-card {
  margin: 0;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 9px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  transform: translateZ(0);
}

.image-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 11px 22px rgba(29, 31, 34, 0.2);
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #efe9d9;
}

.image-card figcaption {
  padding: 0.44rem 0.55rem 0.52rem;
  font: 500 0.79rem/1.35 "IBM Plex Mono", monospace;
  color: #2f3236;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}

.image-card .caption-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-card figcaption.expanded .caption-text {
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}

.image-card .caption-toggle {
  flex: 0 0 auto;
  background: none;
  border: none;
  padding: 0 0.15rem;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  line-height: 1.35;
  border-radius: 3px;
}

.image-card .caption-toggle:hover {
  color: var(--accent);
  background: rgba(179, 54, 45, 0.08);
}

.image-card .caption-toggle[hidden] {
  display: none;
}

.empty,
.error {
  font: 500 1rem/1.4 "IBM Plex Mono", monospace;
  color: var(--muted);
  padding: 1rem;
  border: 1px dashed var(--line);
  background: rgba(255, 253, 247, 0.75);
}

/* Lightbox */
.lb-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.lb-overlay[hidden] {
  display: none;
}

.lb-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(100vw - 8rem);
  max-height: 100vh;
}

#lb-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 5rem);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  outline: none;
}

.lb-caption {
  margin: 0.6rem 0 0;
  color: rgba(255,255,255,0.75);
  font: 500 0.85rem/1.3 "IBM Plex Mono", monospace;
  text-align: center;
  max-width: 60ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-close,
.lb-prev,
.lb-next {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 2.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  align-self: center;
}

.lb-close:hover,
.lb-prev:hover,
.lb-next:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
}

.lb-close {
  position: fixed;
  top: 0.75rem;
  right: 1rem;
  font-size: 2rem;
  align-self: auto;
}

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

@media (max-width: 640px) {
  .header-inner {
    padding-top: 1.7rem;
  }

  .folder-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 0.62rem;
  }
}
