#simpleimagepopup[hidden] {
  display: none !important;
}

#simpleimagepopup.sip-popup {
  position: fixed;
  inset: 0;
  z-index: 100000;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 24px;
  overflow: auto;
  background: rgb(0 0 0 / 65%);
  overscroll-behavior: contain;
}

#simpleimagepopup .sip-popup__dialog {
  position: relative;
  flex: 0 1 auto;
  width: max-content;
  max-width: min(var(--sip-max-width, 800px), 100%);
  margin: auto;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 4px;
  box-shadow: 0 16px 64px rgb(0 0 0 / 30%);
  line-height: 0;
  animation: sip-popup-appear 160ms ease-out;
}

#simpleimagepopup .sip-popup__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  margin: 0 auto;
  border-radius: 4px;
  object-fit: contain;
}

#simpleimagepopup .sip-popup__link {
  display: block;
  max-width: 100%;
  border-radius: 4px;
}

#simpleimagepopup .sip-popup__close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  color: #171717;
  background: #fff;
  border: 1px solid #d5d5d5;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgb(0 0 0 / 20%);
  font: 32px/1 Arial, sans-serif;
  text-transform: none;
  cursor: pointer;
  appearance: none;
}

#simpleimagepopup .sip-popup__close:hover {
  color: #000;
  background: #f0f0f0;
}

#simpleimagepopup .sip-popup__close:focus-visible,
#simpleimagepopup .sip-popup__link:focus-visible {
  outline: 3px solid #005fcc;
  outline-offset: 3px;
}

@keyframes sip-popup-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 480px) {
  #simpleimagepopup.sip-popup { padding: 12px; }
  #simpleimagepopup .sip-popup__image {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #simpleimagepopup .sip-popup__dialog { animation: none; }
}
