.image-viewer {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: #171a20;
  color: white;
}

.image-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

html:has(.image-viewer[open]) {
  overflow: hidden;
}

.image-viewer form { margin: 0; }

.image-viewer button {
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid white;
  border-radius: 999px;
  background: white;
  color: #18232f;
  font: 600 17px/1.4 system-ui, sans-serif;
  cursor: pointer;
}

.image-viewer button:focus-visible,
.image-viewer-stage img:focus-visible {
  outline: 3px solid #77bcff;
  outline-offset: 2px;
}

.image-viewer-stage {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  overflow: auto;
  overscroll-behavior: contain;
}

.image-viewer-stage img {
  place-self: center;
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.image-viewer-stage img[role="button"] { cursor: zoom-in; }
.image-viewer-stage img[aria-pressed="true"] {
  place-self: start;
  margin: auto;
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
