dialog.media-viewer[open] {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #151115;
  color: #fffaf9;
}

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

.media-viewer-controls {
  display: flex;
  justify-content: center;
  gap: .375rem;
  padding: max(.5rem, env(safe-area-inset-top)) .5rem .5rem;
}

.media-viewer-controls button {
  min-width: 44px;
  min-height: 44px;
  padding: .4rem .7rem;
  border: 1px solid #a78392;
  border-radius: .35rem;
  background: #32262f;
  color: #fffaf9;
  font: inherit;
  cursor: pointer;
}

.media-viewer-controls button:disabled { opacity: .5; cursor: default; }
.media-viewer-controls :focus-visible, .media-viewer-viewport:focus-visible { outline: 2px solid #f4c5d4; outline-offset: -2px; }

.media-viewer-viewport {
  display: grid;
  grid-template: minmax(min-content, 1fr) / minmax(min-content, 1fr);
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
  margin-bottom: env(safe-area-inset-bottom);
}

.media-viewer-viewport > :is(img, video) {
  display: block;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
