.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: rgb(5 7 8 / 96%);
  color: #fff;
}

.lightbox::backdrop {
  background: rgb(5 7 8 / 96%);
}

.lightbox[open] {
  display: block;
}

.lightbox__stage {
  position: absolute;
  inset: 5vh 5vw;
  inset: 5dvh 5vw;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox__image {
  display: block;
  max-width: 90vw;
  max-height: 90vh;
  max-height: 90dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 12px 48px rgb(0 0 0 / 45%);
  opacity: 1;
  transition: opacity 140ms ease;
  -webkit-user-drag: none;
}

.lightbox__image.is-loading {
  opacity: 0.28;
}

.lightbox__control {
  position: fixed;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 34%);
  border-radius: 999px;
  background: rgb(12 14 16 / 72%);
  color: #fff;
  font: 400 36px/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.lightbox__control:hover {
  border-color: rgb(255 255 255 / 80%);
  background: rgb(255 255 255 / 18%);
  transform: scale(1.05);
}

.lightbox__control:focus-visible {
  outline: 3px solid #8ec2ce;
  outline-offset: 3px;
}

.lightbox__close {
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  font-size: 30px;
}

.lightbox__previous,
.lightbox__next {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__previous:hover,
.lightbox__next:hover {
  transform: translateY(-50%) scale(1.05);
}

.lightbox__previous {
  left: max(14px, env(safe-area-inset-left));
}

.lightbox__next {
  right: max(14px, env(safe-area-inset-right));
}

.lightbox__status {
  position: fixed;
  z-index: 2;
  right: 72px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 72px;
  margin: 0;
  color: rgb(255 255 255 / 82%);
  font: 600 13px/1.3 Arial, Helvetica, sans-serif;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 1px 4px #000;
}

body.lightbox-is-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .lightbox__stage {
    inset: 6vh 4vw;
    inset: 6dvh 4vw;
  }

  .lightbox__control {
    width: 44px;
    height: 44px;
    background: rgb(12 14 16 / 82%);
    font-size: 32px;
  }

  .lightbox__close {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .lightbox__previous {
    left: max(8px, env(safe-area-inset-left));
  }

  .lightbox__next {
    right: max(8px, env(safe-area-inset-right));
  }

  .lightbox__status {
    right: 58px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox__image,
  .lightbox__control {
    transition: none;
  }
}
