.lightbox-overlay {
  /* Driven from JS while a swipe-to-dismiss drag is in flight. */
  --lightbox-dim: 0.92;
  --lightbox-chrome: 1;
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, var(--lightbox-dim));
  z-index: 1000;
  align-items: center;
  justify-content: center;
  touch-action: none;
  transition: background 0.2s ease;
}

/* While a finger is down, everything tracks the drag frame-for-frame. */
.lightbox-overlay.dragging,
.lightbox-overlay.dragging .lightbox-image,
.lightbox-overlay.dragging .lightbox-caption,
.lightbox-overlay.dragging .lightbox-close,
.lightbox-overlay.dragging .lightbox-download,
.lightbox-overlay.dragging .lightbox-prev,
.lightbox-overlay.dragging .lightbox-next {
  transition: none;
}

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

.lightbox-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  box-sizing: border-box;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0;
  border-radius: 4px;
  transition: opacity 0.15s ease, transform 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-image.loaded {
  opacity: 1;
}

.lightbox-caption {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  opacity: var(--lightbox-chrome);
  transition: opacity 0.2s ease;
}

.lightbox-close,
.lightbox-download,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: var(--lightbox-chrome);
  transition: background 0.15s ease, opacity 0.2s ease;
}

.lightbox-close:hover,
.lightbox-download:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-close {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 24px;
  line-height: 1;
}

.lightbox-download {
  top: 16px;
  right: 64px;
  width: 40px;
  height: 40px;
  text-decoration: none;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 18px;
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

body.lightbox-locked {
  overflow: hidden;
}
