.custom-gallery {
  width: 100%;
  max-width: 600px;

  display: flex;
  flex-wrap: wrap;

  column-gap: 8px;
  row-gap: 8px;

  align-items: flex-start;
  align-content: flex-start;

  padding: 20px 0;
}

.gallery-item {
  flex: 0 0 calc((100% - 16px) / 3);
  max-width: calc((100% - 16px) / 3);

  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  overflow: hidden;
  border-radius: 12px;
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.06);
  opacity: 0.85;
}

.gallery-item:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  padding: 2rem;
}

.lightbox.is-active {
  display: flex;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 85vh;
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close,
.lightbox-arrow {
  position: absolute;
  border: 0;
  background: transparent;
  color: #c8c8c8;
  cursor: pointer;
  line-height: 1;
}

.lightbox-close {
  top: 1rem;
  right: 1.25rem;
  font-size: 1rem;
}

.lightbox-arrow {
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  padding: 1rem;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-close:hover,
.lightbox-arrow:hover,
.lightbox-close:focus-visible,
.lightbox-arrow:focus-visible {
  opacity: 0.7;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .lightbox {
    padding: 1rem;
  }

  .lightbox-arrow {
    font-size: 2.25rem;
    padding: 0.5rem;
  }

  .lightbox-prev {
    left: 0.25rem;
  }

  .lightbox-next {
    right: 0.25rem;
  }

  .lightbox-close {
    font-size: 2.5rem;
  }
}

@media (max-width: 400px) {
  .gallery-item {
    flex: 0 0 calc((100% - 8px) / 2);
    max-width: calc((100% - 8px) / 2);
  }
}