:root {
  --bg: #05070b;
  --panel: rgba(11, 15, 22, 0.86);
  --panel-strong: rgba(14, 20, 30, 0.96);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef3f9;
  --muted: #9aa7b6;
  --accent: #e8b36a;
  --accent-soft: rgba(232, 179, 106, 0.14);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  background: linear-gradient(180deg, #05070b 0%, #070c13 52%, #04060a 100%);
  color: var(--text);
  color-scheme: dark;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.gallery-page {
  min-height: 100vh;
  padding: 14px 20px 28px;
}

.gallery-page__inner {
  width: min(1680px, 100%);
  margin: 0 auto;
}

.gallery-hero {
  padding: 4px 0 10px;
}

.gallery-hero__copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
}

.gallery-hero h1 {
  margin: 0;
  font-size: clamp(1.85rem, 3.2vw, 3.2rem);
  line-height: 1;
  letter-spacing: 0;
}

.gallery-eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.86rem;
  letter-spacing: 0;
}

.gallery-intro {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.species-filter {
  margin: 0 0 14px;
  padding: 8px 0 0;
  border-top: 1px solid var(--border);
}

.species-filter__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.gallery-stream {
  display: block;
  width: 100%;
  columns: 4 270px;
  column-gap: 16px;
}

.photo-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  break-inside: avoid;
  vertical-align: top;
}

.photo-card__button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.photo-card__frame {
  aspect-ratio: var(--photo-aspect, 16 / 9);
  max-height: min(58vh, 560px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: rgba(9, 13, 19, 0.92);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.32);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.photo-card__button:hover .photo-card__frame {
  transform: translateY(-4px);
  border-color: rgba(232, 179, 106, 0.22);
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.42);
}

.photo-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-card__title {
  margin: 8px 0 0;
  padding: 0 2px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.25;
  font-weight: 600;
  text-align: left;
}

.gallery-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.gallery-pagination button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.gallery-pagination button:disabled {
  color: rgba(154, 167, 182, 0.46);
  cursor: default;
}

.photo-card__species {
  margin: 3px 0 0;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.25;
  text-align: left;
}

.image-fallback {
  display: grid;
  width: 100%;
  min-height: 220px;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: rgba(9, 13, 19, 0.92);
}

.gallery-empty {
  padding: 48px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
}

.gallery-empty p {
  margin: 0;
  color: var(--muted);
}

.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 6, 10, 0.82);
  backdrop-filter: blur(18px);
}

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

.viewer-shell {
  width: min(1540px, 100%);
  height: min(920px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 36px 120px rgba(0, 0, 0, 0.62);
}

.viewer-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 26px;
  overflow: hidden;
  background: #060910;
}

.viewer-image-frame {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  align-items: center;
  justify-content: center;
}

.viewer-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

.viewer-close,
.viewer-nav {
  position: absolute;
  z-index: 2;
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(5, 8, 13, 0.72);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  backdrop-filter: blur(12px);
}

.viewer-close {
  top: 18px;
  right: 18px;
}

.viewer-nav {
  top: 50%;
  transform: translateY(-50%);
}

.viewer-nav--prev {
  left: 18px;
}

.viewer-nav--next {
  right: 18px;
}

.viewer-caption {
  display: flex;
  width: min(760px, 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin: 16px auto 0;
  pointer-events: none;
}

.viewer-caption h2 {
  max-width: 100%;
  margin: 0;
  padding: 0;
  color: var(--text);
  font-size: 1.08rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-align: center;
}

.viewer-caption p {
  max-width: 100%;
  margin: 4px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-align: center;
}

@media (max-width: 1120px) {
  .gallery-stream {
    columns: 3 250px;
  }
}

@media (max-width: 860px) {
  .gallery-page {
    padding: 22px 14px 48px;
  }

  .gallery-stream {
    columns: 2 220px;
  }

  .viewer-overlay {
    padding: 0;
  }

  .viewer-shell {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .viewer-stage {
    min-height: 52vh;
    padding: 58px 14px 18px;
  }
}

@media (max-width: 560px) {
  .gallery-hero h1 {
    font-size: 2rem;
  }

  .gallery-stream {
    columns: 1;
  }

  .viewer-caption h2 {
    font-size: 1rem;
  }
}
