.gallery-photo {
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  text-align: inherit;
}

.film-play {
  cursor: pointer;
}

.media-dialog {
  --media-gap: var(--bar-top);
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--ground);
  color: var(--ink);
  overflow: hidden;
}

.media-dialog::backdrop {
  background: var(--ground);
}

html:has(.media-dialog[open]) {
  overflow: hidden;
  scrollbar-gutter: auto;
}

html:has(.media-dialog[open]) .stage {
  overflow-x: clip;
}

.media-shell {
  position: relative;
  height: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0,1fr) auto;
  gap: clamp(16px,2.5vh,28px);
  padding: clamp(20px,2.2vw,32px);
  background: var(--ground);
}

.media-close {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: -8px -10px -8px 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--ink);
}

.media-close svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1;
  fill: none;
}

.media-stage {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.media-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: pan-y pinch-zoom;
}

.media-footer {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  min-width: 0;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
}

.media-footer::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--ink);
  transform: scaleX(var(--gallery-progress, 0));
  transform-origin: left;
  pointer-events: none;
}

.media-description {
  display: flex;
  align-items: baseline;
  gap: 24px;
  min-width: 0;
  font-size: var(--t-caption);
  line-height: 1.5;
}

.media-caption {
  margin: 0;
  overflow-wrap: anywhere;
}

#gallery-lightbox .media-close {
  position: absolute;
  top: max(var(--bar-top), env(safe-area-inset-top));
  right: max(var(--edge), env(safe-area-inset-right));
  z-index: 1;
  margin: 0;
  background: var(--ground);
}

.media-arrows {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.media-arrows button {
  width: 56px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
}

.media-arrows button:disabled {
  opacity: .25;
  cursor: default;
}

.media-arrows svg {
  width: 24px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1;
  fill: none;
}

.media-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  margin: 0;
  background: var(--ground);
  font-size: var(--t-control);
}

#film-dialog {
  padding: 0;
  background: #000;
}

#film-dialog .video-frame {
  width: 100%;
  height: 100%;
}

#film-dialog .media-close {
  position: absolute;
  top: max(var(--bar-top), env(safe-area-inset-top));
  right: max(var(--edge), env(safe-area-inset-right));
  z-index: 1;
  margin: 0;
  color: var(--ground);
  background: rgba(0,0,0,.65);
}

.video-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width:700px) {
  .media-dialog {
    --media-gap: 12px;
  }

  .media-shell {
    padding: 16px;
    gap: 16px;
  }

  .media-footer {
    gap: 12px;
    padding-top: 12px;
  }

  .media-description {
    flex-direction: column;
    gap: 4px;
  }

  .media-arrows button {
    width: 44px;
    height: 44px;
  }

}

@media (max-height:480px) {
  .media-dialog {
    --media-gap: 12px;
  }

  .media-shell {
    padding: 12px 20px;
    gap: 10px;
  }

  .media-footer {
    padding-top: 8px;
  }

  .media-arrows button {
    height: 44px;
  }

}
