.custom-gallery {
  --custom-gallery-columns: 4;
  --custom-gallery-radius: 18px;
  --custom-gallery-lightbox-radius: 20px;
  --custom-gallery-gap: 18px;
  --custom-gallery-nav-top-desktop: 0px;
  --custom-gallery-nav-top-tablet: 0px;
  --custom-gallery-nav-top-mobile: 0px;
  --custom-gallery-nav-bg-color: #000000c4;
  --custom-gallery-nav-bg-blur: 10px;
  position: relative;
}

.custom-gallery__download-current,
.custom-gallery__icon-button,
.custom-gallery__nav {
  color: var(--custom-gallery-controls-color, #fff);
  text-decoration: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  box-sizing: border-box;
  cursor: pointer;
  opacity: .9;
  font-size: 25px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  flex: 0 0 44px;
  transition: opacity .2s ease, transform .28s ease;
}

.custom-gallery__download-current { gap: 10px; }

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

.custom-gallery__download-current:hover,
.custom-gallery__download-current:focus,
.custom-gallery__download-current:active,
.custom-gallery__icon-button:hover,
.custom-gallery__icon-button:focus,
.custom-gallery__icon-button:active,
.custom-gallery__nav:hover,
.custom-gallery__nav:focus,
.custom-gallery__nav:active {
  opacity: 1;
  transform: translateY(-2px);
}

.custom-gallery__download-current:hover,
.custom-gallery__download-current:focus,
.custom-gallery__download-current:active,
.custom-gallery__download-current:visited {
  color: var(--custom-gallery-controls-color, #fff);
}

.custom-gallery__chapter-link {
  color: var(--custom-gallery-nav-text-color, #fff);
  text-decoration: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  cursor: pointer;
  opacity: .9;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: opacity .2s ease, transform .28s ease, color .2s ease;
}

.custom-gallery__chapter-link:hover,
.custom-gallery__chapter-link:focus,
.custom-gallery__chapter-link:active {
  opacity: 1;
  transform: translateY(-2px);
  color: var(--custom-gallery-nav-text-color, #fff);
}

.custom-gallery__chapter-link.is-active {
  opacity: 1;
  color: var(--custom-gallery-nav-text-color-active, #fff);
}

.custom-gallery__chapters-wrap {
  position: relative;
  z-index: 20;
  margin: 0;
  padding: 0;
}

.custom-gallery__chapters-wrap.is-pinned {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--custom-gallery-nav-top-desktop);
  margin: 0;
  z-index: 999;
}

@media (max-width: 991px) {
  .custom-gallery__chapters-wrap.is-pinned { top: var(--custom-gallery-nav-top-tablet); }
}

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

.custom-gallery__chapters-spacer {
  height: 0;
}

.custom-gallery__chapters {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: var(--custom-gallery-nav-bg-color, #000000c4);
  backdrop-filter: blur(var(--custom-gallery-nav-bg-blur, 10px));
  -webkit-backdrop-filter: blur(var(--custom-gallery-nav-bg-blur, 10px));
  border: 0;
  border-radius: 0;
}

.custom-gallery__chapters-inner {
  display: flex;
  flex-wrap: nowrap;
  gap: 18px;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 30px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.custom-gallery__chapters-inner::-webkit-scrollbar { display: none; }

.custom-gallery__chapter-link {
  font-size: 16px;
  letter-spacing: .02em;
  white-space: nowrap;
  flex: 0 0 auto;
}

.custom-gallery__chapters-fade {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 56px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
  z-index: 2;
}

.custom-gallery__chapters-fade--left {
  left: 0;
  background: linear-gradient(to right, var(--custom-gallery-nav-bg-color, #000000c4), transparent);
}

.custom-gallery__chapters-fade--right {
  right: 0;
  background: linear-gradient(to left, var(--custom-gallery-nav-bg-color, #000000c4), transparent);
}

.custom-gallery__chapters.has-fade-left .custom-gallery__chapters-fade--left,
.custom-gallery__chapters.has-fade-right .custom-gallery__chapters-fade--right {
  opacity: 1;
}

.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__chapters-wrap + .custom-gallery__section,
.custom-gallery__chapters-spacer + .custom-gallery__section {
  margin-top: clamp(28px, 4vw, 48px);
}

.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 {
  position: relative;
  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__item-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: 54px 18px 17px;
  text-align: center;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: .01em;
  color: var(--custom-gallery-grid-title-color, #fff);
  background: linear-gradient(to top, var(--custom-gallery-grid-title-bg, #000000c4), transparent);
  background: linear-gradient(to top, color-mix(in srgb, var(--custom-gallery-grid-title-bg, #000000c4) 55%, transparent), transparent);
  pointer-events: none;
  overflow-wrap: break-word;
}

.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: var(--custom-gallery-backdrop-color, #000000c4);
  backdrop-filter: blur(var(--custom-gallery-backdrop-blur, 10px));
  -webkit-backdrop-filter: blur(var(--custom-gallery-backdrop-blur, 10px));
}

.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: var(--custom-gallery-controls-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: 28px;
  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: var(--custom-gallery-controls-color, #fff);
  text-align: center;
  font-size: 14px;
  letter-spacing: .04em;
}

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

@media (max-width: 767px) {
  .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[data-columns="1"] .custom-gallery__grid .custom-gallery__item {
  left: 0 !important;
  width: 100% !important;
}

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

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