html.gallery-open {
  overflow: hidden;
}
main article .pic_container figure img,
main article .pic_container figure img:hover {
  transform: none;
  transition: none;
  cursor: zoom-in;
}
#mainpic[role="button"] {
  cursor: zoom-in;
}
[role="button"]:focus-visible,
.gallery-dialog button:focus-visible {
  outline: 3px solid var(--gallery-focus);
  outline-offset: 4px;
}
.gallery-dialog {
  box-sizing: border-box;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  padding: 3.5rem 0.5rem 0.5rem;
  border: none;
  background: var(--gallery-surface);
  color: var(--gallery-text);
}
.gallery-dialog[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
.gallery-dialog::backdrop {
  background: var(--gallery-backdrop);
}
.gallery-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}
.gallery-prev,
.gallery-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}
.gallery-prev {
  left: 0.25rem;
}
.gallery-next {
  right: 0.25rem;
}
.gallery-image,
.gallery-player {
  display: block;
  min-width: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.25rem;
}
.gallery-dialog.gallery-single :is(.gallery-image, .gallery-player) {
  max-width: 100%;
}
main article .pic_container .gallery-video-preview {
  position: relative;
  height: auto;
  padding: 0;
  font-size: 1rem;
  max-width: 100%;
  transform: none;
}
.gallery-video-preview video {
  display: block;
  max-width: 100%;
  max-height: 15rem;
  border-radius: 0.25rem;
}
#mainvideo {
  display: block;
  position: relative;
  max-width: 100%;
  padding: 0;
  border: 0;
  margin: 0 auto;
  background: var(--gallery-preview-background);
  cursor: pointer;
}
#mainvideo video {
  max-height: 40rem;
}
#mainvideo.left,
#mainvideo.right {
  max-width: 25%;
  margin: 0.5rem;
}
#mainvideo.left {
  float: left;
}
#mainvideo.right {
  float: right;
}
.gallery-dialog button {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--gallery-button-border);
  border-radius: 50%;
  background: var(--gallery-button-background);
  color: var(--gallery-text);
  font: 2rem/1 sans-serif;
  cursor: pointer;
}
.gallery-dialog button:hover {
  background: var(--gallery-button-hover);
}
.gallery-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
}
.gallery-caption {
  margin: 0.5rem 0 0;
  max-height: 4.5rem;
  overflow: auto;
  text-align: center;
  font: 1rem/1.5 sans-serif;
  overflow-wrap: anywhere;
}
.gallery-dialog [hidden],
main button[hidden],
main article[hidden] {
  display: none;
}
main .request-status:empty {
  display: none;
}
main .linkItem a.content-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
main #searchTags button {
  background: var(--color-transparent);
  color: inherit;
  border: 0;
  padding: 0.25rem;
  font: inherit;
  cursor: pointer;
}
@media (max-width: 600px) {
  .gallery-stage {
    gap: 0.25rem;
  }
  .gallery-image,
  .gallery-player {
    max-width: calc(100% - 6rem);
  }
}

main article .pic_container .gallery-expand {
  position: static;
  transform: none;
  width: auto;
  height: auto;
  padding: 0.4rem 0.75rem;
  font-size: 1rem;
}

/* Image-only zoom; navigation stays outside the clipped image viewport. */
.gallery-image-viewport { width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; }
.gallery-image-viewport.is-zoomed { cursor: grab; touch-action: none; }
.gallery-image-viewport.is-zoomed:active { cursor: grabbing; }
.gallery-image-viewport .gallery-image { max-width: 100%; user-select: none; }
.gallery-zoom { position: absolute; top: .5rem; right: 4rem; }
@media (max-width: 600px) { .gallery-image-viewport { width: calc(100% - 6rem); } .gallery-single .gallery-image-viewport { width: 100%; } }
