html {
  scroll-behavior: smooth;
}

.custom-gallery {
  --custom-gallery-columns: 4;
  --custom-gallery-radius: 18px;
  --custom-gallery-lightbox-radius: 20px;
  --custom-gallery-gap: 18px;
  --custom-gallery-nav-top-desktop: 15px;
  --custom-gallery-nav-top-mobile: 15px;
  --custom-gallery-nav-radius: 20px;
  position: relative;
}

.custom-gallery__download-block { margin: 0 0 28px; }
.custom-gallery__download-block--center { text-align: center; }
.custom-gallery__download-block--right { text-align: right; }

.custom-gallery__download-all,
.custom-gallery__download-current,
.custom-gallery__icon-button,
.custom-gallery__nav,
.custom-gallery__chapter-link,
.custom-gallery__mobile-toggle {
  color: #fff;
  text-decoration: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  cursor: pointer;
  transition: opacity .2s ease, transform .28s ease;
}

.custom-gallery__download-all,
.custom-gallery__download-current,
.custom-gallery__mobile-toggle,
.custom-gallery__chapter-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.custom-gallery__icon-button,
.custom-gallery__download-current,
.custom-gallery__nav {
  font-size: 25px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 12px 30px;
  flex: 0 0 44px;
}

.custom-gallery__download-current,
.custom-gallery__icon-button,
.custom-gallery__nav,
.custom-gallery__download-all,
.custom-gallery__chapter-link,
.custom-gallery__mobile-toggle { opacity: .9; }

.custom-gallery__nav { font-size: 40px; width: 48px; height: 48px; flex-basis: 48px; }

.custom-gallery__download-current:hover,
.custom-gallery__icon-button:hover,
.custom-gallery__nav:hover,
.custom-gallery__download-all:hover,
.custom-gallery__chapter-link:hover,
.custom-gallery__mobile-toggle:hover {
  opacity: 1;
  transform: translateY(-2px);
  color: inherit;
  background: transparent;
}

.custom-gallery__download-all {
  font-size: 15px;
  letter-spacing: .02em;
}

.custom-gallery__chapters-wrap {
  position: sticky;
  top: var(--custom-gallery-nav-top-desktop);
  z-index: 20;
  margin: 0 0 clamp(26px, 4vw, 46px);
  padding: 10px 0;
}

.custom-gallery__chapters {
  width: max-content;
  max-width: min(92vw, 1120px);
  margin: 0 auto;
  padding: 12px 30px;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--custom-gallery-nav-radius);
  overflow: hidden;
}

.custom-gallery__chapters-inner {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.custom-gallery__chapter-link,
.custom-gallery__mobile-toggle {
  font-size: 14px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.custom-gallery__chapter-link.is-active { opacity: 1; }
.custom-gallery__mobile-toggle { display: none; width: 100%; justify-content: center; }

.custom-gallery__section {
  scroll-margin-top: var(--custom-gallery-nav-scroll-offset, 120px);
}

.custom-gallery__section + .custom-gallery__section {
  margin-top: clamp(56px, 8vw, 112px);
}

.custom-gallery__heading {
  margin: 0 0 clamp(20px, 3.5vw, 34px);
  text-align: center;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.08;
  letter-spacing: -.03em;
  font-weight: 500;
}

.custom-gallery__grid {
  position: relative;
  min-height: 0;
  gap: var(--custom-gallery-gap);
}

.custom-gallery__item {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.custom-gallery__image-wrap {
  display: block;
  overflow: hidden;
  border-radius: var(--custom-gallery-radius);
  width: 100%;
}

.custom-gallery__image {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transform: scale(1.01);
  transition: opacity .3s ease, transform .55s cubic-bezier(.22,1,.36,1);
}

.custom-gallery__image.is-loaded { opacity: 1; }
.custom-gallery__item:hover .custom-gallery__image,
.custom-gallery__item:focus-visible .custom-gallery__image { transform: scale(1.06); }

.custom-gallery__lightbox[hidden] { display: none !important; }
.custom-gallery__lightbox { position: fixed; inset: 0; z-index: 999999; }
.custom-gallery__backdrop { position: absolute; inset: 0; background: #000000b2; backdrop-filter: blur(8px); }

.custom-gallery__lightbox-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: clamp(18px, 3vw, 32px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.custom-gallery__lightbox-topbar {
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) 1fr;
  align-items: center;
  gap: 18px;
  min-height: 48px;
}

.custom-gallery__lightbox-section-title {
  color: #fff;
  text-align: center;
  justify-self: center;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.1;
  letter-spacing: -.03em;
}

.custom-gallery__lightbox-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-end;
}

.custom-gallery__lightbox-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
}

.custom-gallery__lightbox-image-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow: visible;
}

.custom-gallery__lightbox-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  border-radius: var(--custom-gallery-lightbox-radius);
}


.custom-gallery__progress {
  color: rgba(255,255,255,.76);
  text-align: center;
  font-size: 14px;
  letter-spacing: .04em;
}

.custom-gallery-is-locked,
.custom-gallery-is-locked body { overflow: hidden; }



@media (max-width: 767px) {
  .custom-gallery__chapters-wrap { top: var(--custom-gallery-nav-top-mobile); }

  .custom-gallery__chapters-wrap { position: sticky; z-index: 40; }
  .custom-gallery__chapters { position: relative; }
  .custom-gallery__chapters-inner { position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 45; }

  .custom-gallery__grid {}

  .custom-gallery__chapters {
    width: 100%;
    padding: 0;
    border-radius: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    backdrop-filter: none;
    box-shadow: none;
  }

  .custom-gallery__mobile-toggle {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    padding: 18px 20px;
    background: rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--custom-gallery-nav-radius);
    overflow: hidden;
    isolation: isolate;
  }

  .custom-gallery__chapters-inner {
    display: none;
    margin-top: 2px;
    padding: 18px 20px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    background: rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--custom-gallery-nav-radius);
    overflow: hidden;
    isolation: isolate;
  }

  .custom-gallery__chapters.is-open .custom-gallery__chapters-inner {
    display: flex;
  }

  .custom-gallery__chapter-link {
    justify-content: center;
    width: 100%;
  }

  .custom-gallery__lightbox-topbar {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .custom-gallery__lightbox-actions {
    order: -1;
    justify-content: center;
  }

  .custom-gallery__lightbox-stage { grid-template-columns: 1fr; }
  .custom-gallery__nav { display: none; }

  .custom-gallery__lightbox-image {
    max-height: calc(100vh - 130px);
  }

  .custom-gallery__icon-button,
  .custom-gallery__download-current {
    font-size: 25px;
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .custom-gallery__nav {
    font-size: 40px;
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }
}


.custom-gallery__download-current,
.custom-gallery__download-current:hover,
.custom-gallery__download-current:focus,
.custom-gallery__download-current:active,
.custom-gallery__download-current:visited {
  color: #fff;
  background: transparent;
}





.custom-gallery__mobile-toggle,
.custom-gallery__mobile-toggle:hover,
.custom-gallery__mobile-toggle:focus,
.custom-gallery__mobile-toggle:active,
.custom-gallery__mobile-toggle:visited {
  color: #fff;
  background-color: rgba(0, 0, 0, 0.36);
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.custom-gallery__mobile-toggle:focus-visible {
  outline: none;
  box-shadow: none;
}

@media (max-width: 767px) {
  .custom-gallery__mobile-toggle {
    margin: 0;
    padding: 18px 20px;
  }

  .custom-gallery__chapters-inner {
    margin-top: 2px;
    padding: 18px 20px;
  }

  .custom-gallery__chapter-link {
    padding: 0;
    min-height: 0;
  }
}



.custom-gallery__mobile-toggle,
.custom-gallery__mobile-toggle:hover,
.custom-gallery__mobile-toggle:focus,
.custom-gallery__mobile-toggle:active,
.custom-gallery__mobile-toggle:visited {
  color: #fff;
  background-color: rgba(0, 0, 0, 0.36);
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transform: none !important;
}

.custom-gallery__mobile-toggle:hover,
.custom-gallery__mobile-toggle:focus,
.custom-gallery__mobile-toggle:active {
  transform: none !important;
}

.custom-gallery__mobile-toggle:focus-visible {
  outline: none;
  box-shadow: none;
  transform: none !important;
}

@media (max-width: 767px) {
  .custom-gallery__mobile-toggle {
    margin: 0;
    padding: 18px 20px;
    min-height: 72px;
    background: rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .custom-gallery__chapters-inner {
    margin-top: 2px;
    padding: 18px 20px;
  }

  .custom-gallery__chapter-link {
    width: 100%;
    min-height: 36px;
    padding: 0;
    line-height: 1.35;
  }
}



.custom-gallery__chapters,
.custom-gallery__mobile-toggle,
.custom-gallery__chapters-inner {
  border-radius: var(--custom-gallery-nav-radius);
}


@media (max-width: 767px) {
  .custom-gallery__chapters-wrap {
    position: sticky;
    z-index: 40;
  }

  .custom-gallery__chapters {
    position: relative;
  }

  .custom-gallery__chapters-inner {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 45;
  }

  .custom-gallery__chapters.is-open .custom-gallery__chapters-inner {
    display: flex;
  }
}



.custom-gallery__icon-button,
.custom-gallery__icon-button:hover,
.custom-gallery__icon-button:focus,
.custom-gallery__icon-button:active,
.custom-gallery__download-current,
.custom-gallery__download-current:hover,
.custom-gallery__download-current:focus,
.custom-gallery__download-current:active,
.custom-gallery__nav,
.custom-gallery__nav:hover,
.custom-gallery__nav:focus,
.custom-gallery__nav:active {
  color: #fff;
  background: transparent;
  text-decoration: none;
}

.custom-gallery__icon-button:hover,
.custom-gallery__icon-button:focus,
.custom-gallery__icon-button:active,
.custom-gallery__download-current:hover,
.custom-gallery__download-current:focus,
.custom-gallery__download-current:active,
.custom-gallery__nav:hover,
.custom-gallery__nav:focus,
.custom-gallery__nav:active {
  color: #fff;
  background: transparent;
}


.custom-gallery__mobile-toggle-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}


.custom-gallery[style*="--custom-gallery-columns: 1"] .custom-gallery__grid .custom-gallery__item {
  left: 0 !important;
  width: 100% !important;
}



.custom-gallery__fullscreen {
  color: #fff;
  background: transparent;
}






@media (max-width: 767px) {
  .custom-gallery__mobile-toggle,
  .custom-gallery__mobile-toggle:hover,
  .custom-gallery__mobile-toggle:focus,
  .custom-gallery__mobile-toggle:active,
  .custom-gallery__mobile-toggle:visited {
    background: rgba(0, 0, 0, 0.36) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important;
    opacity: 1 !important;
  }

  .custom-gallery__chapters-inner {
    background: rgba(0, 0, 0, 0.36) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important;
    opacity: 1 !important;
  }
}


@media (min-width: 1200px) {
  .custom-gallery__icon-button,
  .custom-gallery__download-current {
    font-size: 29px;
  }
}






.custom-gallery__chapter-link,
.custom-gallery__chapter-link:hover,
.custom-gallery__chapter-link:focus,
.custom-gallery__chapter-link:active,
.custom-gallery__chapter-link:visited {
  color: #fff;
}



@media (hover: none) and (pointer: coarse) {
  .custom-gallery__fullscreen {
    display: none !important;
  }
}
