html.dafa-gallery-open { overflow: hidden; }
.gallery-viewer {
  width: min(1100px, calc(100% - 32px));
  height: min(820px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--dafa-border);
  border-radius: 6px;
  background: var(--dafa-surface);
  color: var(--dafa-text);
  box-shadow: 0 24px 80px rgb(0 0 0 / 20%);
}
.gallery-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.gallery-viewer::backdrop { background: rgb(0 0 0 / 72%); }
.gallery-viewer > :is(header, footer) { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.gallery-viewer > header { border-bottom: 1px solid var(--dafa-border); }
.gallery-viewer > header span { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--dafa-text-soft); }
.gallery-viewer > footer { border-top: 1px solid var(--dafa-border); }
.gallery-viewer :is(button, a) { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 14px; border: 1px solid var(--dafa-border); border-radius: 4px; background: transparent; color: var(--dafa-text); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.gallery-viewer :is(button, a):hover { border-color: var(--dafa-accent); color: var(--dafa-accent); }
.gallery-viewer button:disabled { opacity: .4; cursor: default; color: var(--dafa-text-soft); border-color: var(--dafa-border); }
.gallery-viewer__stage { display: flex; align-items: center; justify-content: center; min-height: 0; padding: 16px; background: var(--dafa-bg); overflow: auto; }
.gallery-viewer__stage img { flex-shrink: 0; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.gallery-viewer__stage p { margin: 0; font-size: 14px; color: var(--dafa-text-soft); text-align: center; }
.gallery-viewer [hidden] { display: none; }
@media (max-width: 640px) {
  .gallery-viewer { width: calc(100% - 16px); height: calc(100dvh - 16px); }
  .gallery-viewer > :is(header, footer) { gap: 8px; padding: 8px; }
  .gallery-viewer__stage { padding: 12px; }
}
