:root {
  --zoom-overlay-bg: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] {
  --zoom-overlay-bg: rgba(0, 0, 0, 0.8);
}

/* Keep content images within their available layout width. */
main img {
  max-width: 100%;
}

/* Native image preview dialog. */
#image-popup {
  width: max-content;
  height: max-content;
  max-width: calc(100vw - 48px);
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
}

#image-popup::backdrop {
  background: var(--zoom-overlay-bg);
  cursor: zoom-out;
}

#image-popup img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - 48px);
  max-height: min(480px, calc(100dvh - 48px));
  object-fit: contain;
}
