.gallery-section {
  background: #fff;
}

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

.dynamic-gallery-item {
  position: relative;
  overflow: hidden;
  min-height: 270px;
  border: 0;
  border-radius: 9px;
  background: #eef1f4;
  cursor: zoom-in;
  box-shadow: 0 8px 28px rgba(7, 24, 42, .07);
}

.dynamic-gallery-item img {
  width: 100%;
  height: 100%;
  min-height: 270px;
  object-fit: cover;
  transition: transform .35s ease;
}

.dynamic-gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(7, 24, 42, .28), transparent 42%);
  opacity: 0;
  transition: opacity .3s ease;
}

.dynamic-gallery-item:hover img {
  transform: scale(1.035);
}

.dynamic-gallery-item:hover::after {
  opacity: 1;
}

.gallery-message {
  grid-column: 1 / -1;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 34px 76px;
  background: rgba(3, 12, 22, .94);
}

.gallery-lightbox.open {
  display: flex;
}

.gallery-lightbox-image {
  display: block;
  max-width: min(92vw, 1500px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 5px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .38);
}

.gallery-lightbox-close,
.gallery-lightbox-prev,
.gallery-lightbox-next {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  color: #fff;
  background: rgba(255, 255, 255, .1);
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-prev:hover,
.gallery-lightbox-next:hover {
  background: rgba(248, 170, 0, .92);
  color: var(--navy);
}

.gallery-lightbox-close {
  top: 22px;
  right: 24px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 1.75rem;
  line-height: 1;
}

.gallery-lightbox-prev,
.gallery-lightbox-next {
  top: 50%;
  width: 52px;
  height: 66px;
  border-radius: 7px;
  font-size: 2rem;
  transform: translateY(-50%);
}

.gallery-lightbox-prev {
  left: 18px;
}

.gallery-lightbox-next {
  right: 18px;
}

.gallery-lightbox-counter {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .8);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .06em;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .dynamic-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-lightbox {
    padding: 58px 58px;
  }
}

@media (max-width: 650px) {
  .dynamic-gallery {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .dynamic-gallery-item,
  .dynamic-gallery-item img {
    min-height: 240px;
  }

  .gallery-lightbox {
    padding: 68px 12px 58px;
  }

  .gallery-lightbox-image {
    max-width: 96vw;
    max-height: 78vh;
  }

  .gallery-lightbox-close {
    top: 14px;
    right: 14px;
  }

  .gallery-lightbox-prev,
  .gallery-lightbox-next {
    top: auto;
    bottom: 11px;
    width: 48px;
    height: 42px;
    transform: none;
  }

  .gallery-lightbox-prev {
    left: 14px;
  }

  .gallery-lightbox-next {
    right: 14px;
  }

  .gallery-lightbox-counter {
    bottom: 22px;
  }
}
