.image-lightbox:not([open]) {
  display: none;
}

.image-lightbox[open] {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding:
    max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px));
  border: none;
  background: transparent;
  overflow: hidden;
}

.image-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.94);
}

.image-lightbox-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: min(calc(100vw - 1.5rem), 100%);
  height: min(calc(100dvh - 1.5rem), 100%);
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  margin: 0;
}

.image-lightbox-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  max-height: calc(100dvh - 5rem);
}

.image-lightbox-close {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  z-index: 10001;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #f3e6cf;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.image-lightbox-close:hover {
  border-color: rgba(255, 255, 255, 0.55);
}

.image-lightbox-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: calc(100vw - 1.5rem);
  max-height: calc(100dvh - 5rem);
  object-fit: contain;
  border-radius: 0.35rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.image-lightbox-caption {
  flex: 0 0 auto;
  max-width: min(100%, 48rem);
  margin: 0;
  padding: 0 0.25rem;
  color: rgba(243, 230, 207, 0.82);
  font-size: clamp(0.82rem, 2vw, 0.95rem);
  line-height: 1.35;
  text-align: center;
}

.image-lightbox-caption:empty {
  display: none;
}

body.is-lightbox-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}

img.is-zoomable {
  cursor: zoom-in;
}

@media (max-width: 640px) {
  .image-lightbox {
    padding:
      max(0.5rem, env(safe-area-inset-top, 0px))
      max(0.5rem, env(safe-area-inset-right, 0px))
      max(0.5rem, env(safe-area-inset-bottom, 0px))
      max(0.5rem, env(safe-area-inset-left, 0px));
  }

  .image-lightbox-stage {
    max-height: calc(100dvh - 4rem);
  }

  .image-lightbox-image {
    max-height: calc(100dvh - 4rem);
  }
}
