.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 4, 14, 0.82);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
  overflow: hidden;
}
.gallery-lightbox.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.gallery-lightbox-inner {
  position: relative;
  width: min(1200px, 100%);
  height: calc(100dvh - 32px);
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 12px;
}
.gallery-lightbox-stage {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 8px 72px;
}
.gallery-lightbox-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 30px 100px rgba(0, 0, 0, 0.55),
    0 0 70px rgba(255, 92, 168, 0.18);
  transform: scale(0.94);
  opacity: 0;
  transition:
    transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.3s ease;
}
.gallery-lightbox.open .gallery-lightbox-stage img {
  transform: scale(1);
  opacity: 1;
}
.gallery-lightbox-close,
.gallery-lightbox-nav {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-size: 25px;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  transition:
    transform 0.25s ease,
    background 0.25s ease;
  flex: none;
}
.gallery-lightbox-close:hover,
.gallery-lightbox-nav:hover {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.22);
}
.gallery-lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
}
.gallery-lightbox-caption {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 160px));
  padding: 10px 18px;
  border-radius: 18px;
  text-align: center;
  background: rgba(20, 7, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 2;
}
.gallery-lightbox-title {
  font-weight: 700;
}
.gallery-lightbox-counter {
  font-size: 0.78rem;
  color: #ffb4d7;
  margin-top: 3px;
}
.memory-card {
  cursor: zoom-in;
}
.memory-card.focus {
  transform: translateY(-5px) rotate(0) !important;
  box-shadow: 0 25px 80px rgba(255, 75, 160, 0.25);
}
.gallery-lightbox.swapping .gallery-lightbox-stage img {
  opacity: 0;
  transform: scale(0.96);
}
@media (max-width: 700px) {
  .gallery-lightbox {
    padding: 8px;
  }
  .gallery-lightbox-inner {
    width: 100%;
    height: 100dvh;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 2px;
  }
  .gallery-lightbox-stage {
    padding: 54px 2px 74px;
  }
  .gallery-lightbox-stage img {
    max-width: calc(100vw - 100px);
    max-height: calc(100dvh - 130px);
    border-radius: 14px;
  }
  .gallery-lightbox-nav,
  .gallery-lightbox-close {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }
  .gallery-lightbox-close {
    top: 6px;
    right: 4px;
  }
  .gallery-lightbox-caption {
    bottom: 6px;
    width: calc(100% - 100px);
    padding: 8px 12px;
    font-size: 0.86rem;
  }
}
@media (max-width: 420px) {
  .gallery-lightbox-inner {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
  }
  .gallery-lightbox-stage {
    padding-left: 0;
    padding-right: 0;
  }
  .gallery-lightbox-stage img {
    max-width: calc(100vw - 84px);
    max-height: calc(100dvh - 125px);
  }
  .gallery-lightbox-nav,
  .gallery-lightbox-close {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  .gallery-lightbox-caption {
    width: calc(100% - 84px);
    font-size: 0.8rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .gallery-lightbox,
  .gallery-lightbox-stage img {
    transition: none;
  }
}
