#product-gallery .pg-panel {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 0;
}

#product-gallery #pg-0:checked ~ .pg-view .pg-panel-0,
#product-gallery #pg-1:checked ~ .pg-view .pg-panel-1,
#product-gallery #pg-2:checked ~ .pg-view .pg-panel-2,
#product-gallery #pg-3:checked ~ .pg-view .pg-panel-3 {
  opacity: 1;
  visibility: visible;
  z-index: 1;
}

#product-gallery #pg-0:checked ~ .pg-thumbs label[for='pg-0'],
#product-gallery #pg-1:checked ~ .pg-thumbs label[for='pg-1'],
#product-gallery #pg-2:checked ~ .pg-thumbs label[for='pg-2'],
#product-gallery #pg-3:checked ~ .pg-thumbs label[for='pg-3'] {
  border-color: rgb(2 132 199);
  box-shadow: 0 0 0 1px rgb(2 132 199);
}

/* Иконка лупы: всегда видна на touch, на десктопе — при наведении */
#product-gallery .gallery-zoom-icon {
  opacity: 1;
}

@media (min-width: 640px) {
  #product-gallery .gallery-zoom-icon {
    opacity: 0;
  }

  #product-gallery .pg-view:hover .gallery-zoom-icon {
    opacity: 1;
  }
}

/* Лайтбокс */
.gallery-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.gallery-lightbox.is-open {
  display: flex;
}

.gallery-lightbox-scrim {
  position: absolute;
  inset: 0;
  border: none;
  margin: 0;
  padding: 0;
  background: rgba(15, 23, 42, 0.92);
  cursor: pointer;
}

.gallery-lightbox-inner {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  max-width: min(100%, 56rem);
  max-height: 100%;
  pointer-events: none;
}

.gallery-lightbox-card {
  pointer-events: auto;
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  border-radius: 0.75rem;
  background: #fff;
  padding: 2.75rem 0.75rem 0.75rem;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.35);
}

@media (min-width: 640px) {
  .gallery-lightbox-card {
    padding: 3rem 1rem 1rem;
  }
}

.gallery-lightbox-img-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.gallery-lightbox-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(52dvh, 65vh);
  object-fit: contain;
}

@media (min-width: 640px) {
  .gallery-lightbox-img {
    max-height: min(72vh, 80dvh);
  }
}

.gallery-lightbox-close {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  z-index: 20;
  display: flex;
  height: 2.75rem;
  width: 2.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid rgb(226 232 240);
  background: #fff;
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1;
  color: rgb(71 85 105);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.08);
  touch-action: manipulation;
  cursor: pointer;
}

.gallery-lightbox-close:hover {
  background: rgb(248 250 252);
  color: rgb(15 23 42);
}

.gallery-lightbox-arrow {
  display: none;
  position: absolute;
  top: 50%;
  z-index: 10;
  transform: translateY(-50%);
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  border: 1px solid rgb(226 232 240);
  background: rgb(255 255 255 / 0.95);
  color: rgb(51 65 85);
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.12);
  cursor: pointer;
  touch-action: manipulation;
}

@media (min-width: 640px) {
  .gallery-lightbox-arrow {
    display: inline-flex;
  }

  .gallery-lightbox-arrow--prev {
    left: 0.25rem;
  }

  .gallery-lightbox-arrow--next {
    right: 0.25rem;
  }
}

.gallery-lightbox-mobile-nav {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgb(226 232 240);
}

@media (min-width: 640px) {
  .gallery-lightbox-mobile-nav {
    display: none;
  }
}

.gallery-lightbox-mobile-btn {
  display: inline-flex;
  min-height: 2.75rem;
  min-width: 2.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid rgb(226 232 240);
  background: #fff;
  padding: 0 1rem;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1;
  color: rgb(51 65 85);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.06);
  touch-action: manipulation;
  cursor: pointer;
}

.gallery-lightbox-counter {
  min-width: 3.5rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgb(100 116 139);
}

body.gallery-lightbox-open {
  overflow: hidden;
  touch-action: none;
}
