:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #65727b;
  --paper: #f7f8f5;
  --surface: #ffffff;
  --line: #dbe1dd;
  --accent: #177e89;
  --accent-strong: #0f5961;
  --shadow: 0 18px 40px rgba(23, 32, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(247, 248, 245, 0.94)),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 44px);
  background: rgba(247, 248, 245, 0.88);
  border-bottom: 1px solid rgba(219, 225, 221, 0.86);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  line-height: 1;
  letter-spacing: 0;
}

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

.icon-button,
.download-link,
.viewer-button {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(23, 32, 38, 0.08);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.download-link {
  padding: 0 15px;
  font-weight: 750;
}

.icon-button:hover,
.download-link:hover,
.viewer-button:hover {
  border-color: rgba(23, 126, 137, 0.45);
  color: var(--accent-strong);
}

main {
  padding: clamp(18px, 4vw, 44px);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: clamp(14px, 2vw, 22px);
  align-items: start;
}

.gallery.compact {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 12px;
}

.photo-card {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  padding: 0;
  border: 1px solid rgba(219, 225, 221, 0.96);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 26px rgba(23, 32, 38, 0.1);
  cursor: pointer;
}

.photo-card:focus-visible {
  outline: 3px solid rgba(23, 126, 137, 0.34);
  outline-offset: 3px;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.414;
  object-fit: cover;
  background: #eef1ed;
}

.photo-number {
  position: absolute;
  left: 10px;
  bottom: 10px;
  min-width: 36px;
  padding: 6px 8px;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(23, 32, 38, 0.76);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(52px, 1fr) minmax(0, auto) minmax(52px, 1fr);
  align-items: center;
  justify-items: center;
  padding: 72px clamp(12px, 2vw, 28px) 28px;
  background: rgba(13, 18, 22, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.viewer-frame {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin: 0;
  max-width: min(92vw, 1100px);
  max-height: 100%;
}

.viewer-frame img {
  display: block;
  max-width: min(92vw, 1100px);
  max-height: calc(100vh - 150px);
  border-radius: 8px;
  background: #f3f4f1;
  box-shadow: var(--shadow);
  object-fit: contain;
}

.viewer-frame figcaption {
  color: rgba(255, 255, 255, 0.86);
  font-weight: 750;
}

.viewer-button {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: none;
}

.close-button {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 2rem;
  line-height: 1;
}

.nav-button {
  width: 50px;
  height: 62px;
  font-size: 3rem;
  line-height: 1;
}

.prev-button {
  grid-column: 1;
}

.next-button {
  grid-column: 3;
}

.viewer-frame {
  grid-column: 2;
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    padding: 14px 14px;
  }

  .download-link {
    display: none;
  }

  main {
    padding: 14px;
  }

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

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

  .lightbox {
    grid-template-columns: 1fr 1fr;
    align-items: end;
    padding: 62px 12px 16px;
  }

  .viewer-frame {
    grid-column: 1 / -1;
    order: 1;
  }

  .viewer-frame img {
    max-width: 100%;
    max-height: calc(100vh - 142px);
  }

  .nav-button {
    order: 2;
    width: calc(100% - 5px);
    height: 48px;
    font-size: 2.2rem;
  }

  .prev-button {
    grid-column: 1;
    justify-self: start;
  }

  .next-button {
    grid-column: 2;
    justify-self: end;
  }
}
