.photo > a {
  cursor: zoom-in;
}

html.gallery-viewer-open {
  overflow: hidden;
  scrollbar-gutter: auto;
}

body.gallery-viewer-open {
  overflow: hidden;
}

.gallery-viewer {
  --viewer-background: rgba(8, 11, 13, 0.96);
  --viewer-control-background: rgba(8, 11, 13, 0.76);
  --viewer-control-background-active: rgba(8, 11, 13, 0.94);
  --viewer-control-line: rgba(255, 255, 255, 0.38);
  --viewer-text: #fff;
  --viewer-text-muted: rgba(255, 255, 255, 0.88);
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--viewer-background);
  color: var(--viewer-text);
  overflow: hidden;
  overscroll-behavior: contain;
}

.gallery-viewer::backdrop {
  background: var(--viewer-background);
}

.gallery-viewer__stage {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  margin: 0;
  padding:
    calc(62px + env(safe-area-inset-top))
    calc(72px + env(safe-area-inset-right))
    calc(58px + env(safe-area-inset-bottom))
    calc(72px + env(safe-area-inset-left));
  touch-action: pan-y;
  user-select: none;
}

.gallery-viewer__media {
  display: flex;
  min-width: 0;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gallery-viewer__media picture {
  display: flex;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  align-items: center;
  justify-content: center;
}

.gallery-viewer__media img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}

.gallery-viewer__counter {
  color: var(--viewer-text-muted);
  font-family: var(--mono);
}

.gallery-viewer__counter {
  position: absolute;
  z-index: 2;
  right: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  margin: 0;
  transform: translateX(50%);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.gallery-viewer__control {
  position: absolute;
  z-index: 3;
  display: grid;
  width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--viewer-control-line);
  border-radius: 50%;
  background: var(--viewer-control-background);
  color: var(--viewer-text);
  font-family: var(--mono);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    color 160ms ease,
    background 160ms ease,
    opacity 160ms ease;
}

.gallery-viewer__control:hover,
.gallery-viewer__control:focus-visible {
  border-color: var(--orange);
  background: var(--viewer-control-background-active);
  color: var(--orange);
  outline: none;
}

.gallery-viewer__close {
  top: calc(12px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  font-size: 1.8rem;
}

.gallery-viewer__previous,
.gallery-viewer__next {
  top: 50%;
  transform: translateY(-50%);
}

.gallery-viewer__previous {
  left: calc(12px + env(safe-area-inset-left));
}

.gallery-viewer__next {
  right: calc(12px + env(safe-area-inset-right));
}

.gallery-viewer--navigation-hidden .gallery-viewer__previous,
.gallery-viewer--navigation-hidden .gallery-viewer__next {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 760px) {
  .gallery-viewer__stage {
    padding:
      calc(58px + env(safe-area-inset-top))
      calc(12px + env(safe-area-inset-right))
      calc(62px + env(safe-area-inset-bottom))
      calc(12px + env(safe-area-inset-left));
  }

  .gallery-viewer__control {
    width: 44px;
    height: 44px;
  }

  .gallery-viewer__previous,
  .gallery-viewer__next {
    border: 0;
    border-radius: 0;
    background: transparent;
    color: rgba(218, 221, 223, 0.62);
    font-family: Arial, "Helvetica Neue", sans-serif;
    font-size: 1.15rem;
    font-weight: 300;
  }

  .gallery-viewer__previous:hover,
  .gallery-viewer__next:hover {
    border-color: transparent;
    background: transparent;
    color: rgba(232, 234, 235, 0.82);
  }

  .gallery-viewer__previous:focus-visible,
  .gallery-viewer__next:focus-visible {
    border-color: transparent;
    border-radius: 4px;
    background: transparent;
    color: rgba(232, 234, 235, 0.82);
    outline: 1px solid rgba(218, 221, 223, 0.5);
    outline-offset: -7px;
  }

  .gallery-viewer__previous {
    left: calc(8px + env(safe-area-inset-left));
  }

  .gallery-viewer__next {
    right: calc(8px + env(safe-area-inset-right));
  }

}

@media (prefers-reduced-motion: reduce) {
  .gallery-viewer__control {
    transition: none;
  }
}
