.gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(3px);
  color: #fff;
  opacity: 0;
}

.gallery-overlay[hidden] {
  display: none;
}

.gallery-overlay.is-open {
  display: block;
  animation: gallery-in 320ms ease forwards;
}

.gallery-overlay.is-open.is-closing {
  animation: gallery-out 280ms ease forwards;
}

@keyframes gallery-in {
  to {
    opacity: 1;
  }
}

@keyframes gallery-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.gallery-track {
  display: grid;
  width: 100%;
  height: 100%;
  overflow: hidden;
  outline: none;
  touch-action: none;
}

.gallery-slide {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  padding: 66px 84px 48px;
  overflow: hidden;
}

.gallery-heading {
  width: 100%;
  text-align: center;
}

.gallery-image-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.gallery-slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: auto;
  object-fit: contain;
  object-position: center center;
  opacity: 0;
  transition: opacity 420ms ease;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

.gallery-slide img.is-active {
  z-index: 1;
  opacity: 1;
}

.gallery-slide figcaption {
  margin-bottom: 18px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.gallery-controls {
  display: contents;
}

.gallery-close,
.gallery-arrow {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: transform 180ms ease;
}

.gallery-close {
  top: 18px;
  right: 20px;
  width: 54px;
  height: 54px;
}

.gallery-close span {
  position: absolute;
  width: 30px;
  height: 1.5px;
  background-color: #fff;
  opacity: 1;
  backface-visibility: hidden;
}

.gallery-close span:first-child {
  transform: rotate(45deg);
}

.gallery-close span:last-child {
  transform: rotate(-45deg);
}

.gallery-close:hover {
  transform: scale(1.05);
}

.gallery-arrow {
  top: 50%;
  width: 56px;
  height: 64px;
  transform: translateY(-50%);
}

.gallery-arrow span {
  width: 24px;
  height: 24px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
}

.gallery-arrow:hover {
  transform: translateY(-50%) scale(1.05);
}

.gallery-previous {
  left: 18px;
}

.gallery-previous span {
  transform: rotate(-135deg);
}

.gallery-next {
  right: 18px;
}

.gallery-next span {
  transform: rotate(45deg);
}

.gallery-arrow[hidden] {
  display: none;
}

.gallery-counter {
  position: absolute;
  right: 24px;
  bottom: 20px;
  z-index: 2;
  margin: 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
  letter-spacing: 0.14em;
}

html.gallery-open,
body.gallery-open {
  overflow: hidden;
  overscroll-behavior: none;
}

@media (max-width: 767px) {
  .gallery-overlay {
    position: absolute;
    top: var(--gallery-page-top, 0);
    right: 0;
    bottom: auto;
    left: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    overflow: visible;
    background: transparent;
  }

  .gallery-overlay::before {
    position: absolute;
    inset: -240px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(3px);
    content: "";
    pointer-events: none;
  }

  .gallery-overlay.is-open {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .gallery-track {
    flex: 0 0 auto;
    height: auto;
  }

  .gallery-slide {
    display: flex;
    height: auto;
    padding: 0 18px;
    flex-direction: column;
    overflow: visible;
  }

  .gallery-heading {
    position: relative;
    margin-bottom: 40px;
  }

  .gallery-slide figcaption {
    margin: 0;
  }

  .gallery-image-stage {
    flex: none;
    width: min(calc(100vw - 36px), 900px);
    height: auto;
    aspect-ratio: 3 / 2;
  }

  .gallery-image-stage.is-portrait {
    width: min(calc(100vw - 36px), 50dvh);
    max-height: 70dvh;
    aspect-ratio: 3 / 4;
  }

  .gallery-image-stage.is-portrait img {
    object-fit: cover;
  }

  .gallery-controls {
    display: flex;
    width: min(260px, 75vw);
    margin: 40px auto 0;
    align-items: center;
    justify-content: space-between;
  }

  .gallery-arrow {
    position: static;
    width: 42px;
    height: 42px;
    transform: none;
  }

  .gallery-arrow:hover {
    transform: scale(1.05);
  }

  .gallery-counter {
    position: static;
    font-size: 14px;
    transform: none;
  }

  .gallery-close {
    position: absolute;
    z-index: 5;
    top: max(8px, env(safe-area-inset-top));
    right: 18px;
    width: 42px;
    height: 42px;
    transform: none;
  }

  .gallery-close:hover {
    transform: scale(1.05);
  }
}

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

  .gallery-overlay.is-open {
    animation-duration: 0s;
  }
}
