.gallery-popup-dialog { width:auto; max-width:min(96vw, 960px); padding:0; border:0; border-radius:12px; }
.gallery-popup-dialog::backdrop { background:rgba(0,0,0,.7); }
.gallery-popup-panel {
  box-sizing:border-box; width:min(92vw, 620px); padding:clamp(18px, 4vw, 40px);
  background:var(--popup-background); color:var(--popup-foreground);
  text-align:var(--popup-text-align, center); overflow-wrap:anywhere;
}
.gallery-popup-panel[data-width=compact] { width:min(92vw, 420px); }
.gallery-popup-panel[data-width=wide] { width:min(92vw, 860px); }
.gallery-popup-panel[data-alignment=start] { --popup-text-align:start; }
.gallery-popup-panel h2 { color:inherit; font-size:clamp(1.35rem, 3vw, 2rem); margin:0 0 18px; }
.gallery-popup-panel h3 { color:inherit; font-size:1.18rem; margin:0; }
.gallery-popup-panel p { margin:0; white-space:pre-wrap; }
.gallery-popup-copy { display:grid; gap:15px; justify-items:center; }
.gallery-popup-panel[data-alignment=start] .gallery-popup-copy { justify-items:start; }
.gallery-popup-panel img { display:block; width:100%; max-height:60vh; object-fit:contain; border-radius:5px; }
.gallery-popup-panel img[data-size=medium] { width:70%; }
.gallery-popup-panel img[data-size=small] { width:45%; }
.gallery-popup-content[data-layout]:has(.gallery-popup-copy) { display:grid; grid-template-columns:1fr 1fr; gap:20px; align-items:center; }
.gallery-popup-content[data-layout=image-right] > img { order:1; }
.gallery-popup-panel [data-emphasis=bold] { font-weight:700; }
.gallery-popup-panel [data-emphasis=italic] { font-style:italic; }
.gallery-popup-panel .gallery-popup-button {
  display:inline-block; padding:.55em 1em; border-radius:5px; border:1px solid var(--popup-accent);
  color:var(--popup-background); background:var(--popup-accent); text-decoration:none; font-weight:650;
}
.gallery-popup-panel > form, .gallery-popup-panel > .gallery-popup-button { margin-top:20px; }
@media (max-width:600px) {
  .gallery-popup-content[data-layout]:has(.gallery-popup-copy) { grid-template-columns:minmax(0,1fr); }
  .gallery-popup-content[data-layout=image-right] > img { order:0; }
}

#gallery-popup { width:min(92vw, 620px); max-width:92vw; overflow-x:hidden; }
#gallery-popup:has(.gallery-popup-panel[data-width=compact]) { width:min(92vw, 420px); }
#gallery-popup:has(.gallery-popup-panel[data-width=wide]) { width:min(92vw, 860px); }
#gallery-popup .gallery-popup-panel { width:100%; max-width:none; }
