/* Full-size view: fills the screen, never scrolls, image as large as it can be.
   Caption and Close share one slim bar at the bottom. */
dialog.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; inset: 0;
  padding: 16px 16px 0; overflow: hidden; background: transparent; color: #fff;
}
dialog.lightbox[open] { display: flex; flex-direction: column; align-items: center; }
dialog.lightbox::backdrop, .lightbox::backdrop { background: rgba(10, 12, 14, .95); }
dialog.lightbox img {
  flex: 1 1 auto; min-height: 0; width: 100%; height: calc(100dvh - 72px);
  max-width: 100%; max-height: calc(100dvh - 72px);
  object-fit: contain; margin: 0 auto; border-radius: 0; background: transparent;
}
dialog.lightbox p {
  flex: none; display: flex; align-items: center; justify-content: center; min-height: 56px;
  margin: 0; padding: 0 120px; max-width: 100%; text-align: center;
  font-size: 14px; line-height: 1.3; color: rgba(255, 255, 255, .85);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
dialog.lightbox [data-close] {
  position: absolute; right: 16px; bottom: 10px; margin: 0;
  padding: 7px 14px; font-size: 14px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer;
}
dialog.lightbox [data-close]:hover { background: rgba(255, 255, 255, .18); }
dialog.lightbox [data-close]:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 640px) {
  dialog.lightbox { padding: 12px 8px 0; }
  dialog.lightbox p { justify-content: flex-start; padding: 0 92px 0 8px; font-size: 13px; }
  dialog.lightbox [data-close] { right: 8px; }
}

/* The page behind stays put; the image scrolls inside the view when it's taller than the screen */
html.lb-open, html.lb-open body { overflow: hidden; }
dialog.lightbox .lb-scroll {
  flex: 1 1 auto; min-height: 0; width: 100%; overflow: auto; overscroll-behavior: contain;
  display: flex; align-items: flex-start; justify-content: center; border-radius: 8px;
}
dialog.lightbox .lb-scroll img {
  flex: none; margin: auto; width: auto; height: auto; max-width: 100%; max-height: none;
  object-fit: initial; background: #fff; border-radius: 8px;
}

/* Full-size view: big enough to read every label, never raw pixel size.
   Width is capped at 1280px (or 92% of the screen); a tall screen scrolls inside the view instead of shrinking. */
dialog.lightbox .lb-scroll { align-items: center; }
dialog.lightbox .lb-scroll img {
  width: auto; height: auto; max-width: min(88vw, 1040px); max-height: calc(100dvh - 88px);
  object-fit: contain;
}
