.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(9, 11, 14, 0.84);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 28px;
  z-index: 2000;
}

.lightbox__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  contain: layout paint;
}

.lightbox__stage.is-dragging {
  cursor: grabbing;
}

.lightbox__image {
  max-width: min(1200px, 92vw);
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  backface-visibility: hidden;
}


.lightbox__image,
.lightbox__image--buffer {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
}

.lightbox__image--buffer {
  pointer-events: none;
}

.lightbox__image--buffer {
  position: absolute;
}

.lightbox__close,
.lightbox__nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.08);
  color: #fff;
  line-height: 1;
}

.lightbox__close {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 1.8rem;
  z-index: 2;
}

.lightbox__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.lightbox__count {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(9, 11, 14, 0.6);
  color: #fff;
  font: 600 0.9rem/1 Arial, Helvetica, sans-serif;
}

@media (max-width: 700px) {
  .lightbox {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 18px 12px 24px;
  }

  .lightbox__stage {
    order: 1;
  }

  .lightbox__nav {
    position: fixed;
    bottom: 18px;
    z-index: 2;
  }

  .lightbox__nav--prev {
    left: 18px;
  }

  .lightbox__nav--next {
    right: 18px;
  }

  .lightbox__image {
    max-width: 100%;
    max-height: calc(100vh - 120px);
  }

  .lightbox__close {
    top: 10px;
    right: 10px;
  }
}

body.lightbox-open {
  overflow: hidden;
  overscroll-behavior: none;
}

.lightbox {
  overscroll-behavior: contain;
  touch-action: none;
}

.lightbox__stage {
  touch-action: none;
}

.lightbox__image {
  touch-action: none;
}
