html:has(#image-viewer[open]) { overflow: hidden; }
#image-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  box-sizing: border-box;
  margin: 0;
  padding: 4rem 1rem 1rem;
  border: 0;
  background: transparent;
}
#image-viewer[open] { display: grid; place-items: center; }
#image-viewer::backdrop { background: rgb(12 15 20 / 90%); }
#image-viewer img { display: block; max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; }
#image-viewer button {
  position: absolute;
  top: max(.65rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid #888;
  border-radius: .5rem;
  background: #222;
  color: white;
  font: 600 1rem system-ui, sans-serif;
  cursor: pointer;
}
