.ids-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 1000ms ease, visibility 0s linear 1000ms;
}

.ids-lightbox.ids-lightbox--open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 1000ms ease;
}

.ids-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  transition: opacity 1000ms ease;
}

.ids-lightbox.ids-lightbox--open .ids-lightbox__backdrop {
  opacity: 1;
}

.ids-lightbox__dialog {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  transform: translateY(6px);
  transition: transform 1000ms ease;
}

.ids-lightbox.ids-lightbox--open .ids-lightbox__dialog {
  transform: translateY(0);
}

.ids-lightbox__figure {
  /* Reserve enough room for long captions without moving the image. */
  --idslb-bar-h: clamp(64px, 18vh, 240px);
  margin: 0;
  max-width: min(100%, 1100px);
  width: min(100%, 1100px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ids-lightbox__stage {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  display: grid;
  place-items: center;
  position: relative;
}

.ids-lightbox__img {
  display: block;
  max-width: 100%;
  /* Keep image position stable: reserve fixed bar height below */
  max-height: min(calc(100vh - 32px - var(--idslb-bar-h) - 24px), 900px);
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 1000ms ease;
}

.ids-lightbox__img--a,
.ids-lightbox__img--b {
  grid-area: 1 / 1;
}

.ids-lightbox__img--active {
  opacity: 1;
}

.ids-lightbox__bar {
  width: 100%;
  min-height: var(--idslb-bar-h);
  max-height: var(--idslb-bar-h);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
}

.ids-lightbox__caption {
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.2;
  max-width: 80ch;
  flex: 1 1 auto;
  max-height: var(--idslb-bar-h);
  overflow: auto;
  padding: 0;
}

.ids-lightbox__meta {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-height: var(--idslb-bar-h);
  overflow: auto;
}

.ids-lightbox__title {
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.2;
}

.ids-lightbox__nav {
  position: static;
  transform: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 28px;
  line-height: 44px;
  cursor: pointer;
  user-select: none;
  flex: 0 0 auto;
}

.ids-lightbox__nav--prev {
  margin-right: auto;
}

.ids-lightbox__nav--next {
  margin-left: auto;
}

.ids-lightbox__nav[disabled] {
  opacity: 0.35;
  cursor: default;
}

.ids-lightbox__nav:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.ids-lightbox__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 28px;
  line-height: 44px;
  cursor: pointer;
  z-index: 2;
}

.ids-lightbox__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .ids-lightbox__dialog {
    padding: 10px;
  }

  .ids-lightbox__img {
    max-height: calc(100vh - 20px - var(--idslb-bar-h) - 24px);
  }

  .ids-lightbox__nav {
    width: 40px;
    height: 40px;
    line-height: 40px;
  }
}
