.gallery-main,
.gallery-thumb {
  background: #f4f4f4;
  color: inherit;
  min-width: 0;
  min-height: 0 !important;
  overflow: hidden;
}

.detail-gallery {
  height: clamp(300px, 64vw, 520px);
  max-height: min(520px, 72vh);
  min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
}

.detail-gallery.single {
  height: clamp(260px, 58vw, 500px);
}

.detail-gallery .gallery-main,
.detail-gallery .gallery-thumb {
  aspect-ratio: auto !important;
  height: 100%;
}

.gallery-main.gallery-photo {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.gallery-main img,
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f4f4f4;
}

.gallery-photo:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .16), inset 0 0 0 2px #fff;
}

.gallery-lightbox-sources {
  display: none;
}

.photo-lightbox[hidden] {
  display: none;
}

body.photo-lightbox-open {
  overflow: hidden;
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 16px;
}

.photo-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(8px);
}

.photo-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  height: min(760px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
}

.photo-lightbox-close,
.photo-lightbox-nav {
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  backdrop-filter: blur(8px);
}

.photo-lightbox-close {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  z-index: 2;
}

.photo-lightbox-nav {
  width: 48px;
  height: 56px;
  border-radius: 16px;
  font-size: 24px;
  font-weight: 900;
}

.photo-lightbox-nav:disabled {
  opacity: .35;
  cursor: default;
}

.photo-lightbox-figure {
  grid-column: 2;
  margin: 0;
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.photo-lightbox-image {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: calc(100dvh - 118px);
  object-fit: contain;
}

.photo-lightbox-caption {
  min-height: 24px;
  color: rgba(255, 255, 255, .82);
  font-size: 13px;
  text-align: center;
  overflow-wrap: anywhere;
}

.password-toggle-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.password-toggle-wrap input {
  padding-right: 54px !important;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: var(--brand-soft);
  color: var(--brand-ink);
  outline: 0;
}

.password-toggle-icon {
  position: relative;
  width: 21px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 999px;
  display: block;
}

.password-toggle-icon:after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.password-toggle.is-visible .password-toggle-icon:before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 2px;
  background: currentColor;
  transform: rotate(-35deg);
}

html[data-theme="dark"] .gallery-main,
html[data-theme="dark"] .gallery-thumb,
html[data-theme="dark"] .gallery-main img,
html[data-theme="dark"] .gallery-thumb img {
  background: #111;
}

html[data-theme="dark"] .gallery-photo:focus-visible {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .2), inset 0 0 0 2px #111;
}

html[data-theme="dark"] .photo-lightbox-backdrop {
  background: rgba(0, 0, 0, .86);
}

html[data-theme="dark"] .password-toggle:hover,
html[data-theme="dark"] .password-toggle:focus-visible {
  background: #242424;
  color: var(--brand-ink);
}

@media (min-width: 720px) {
  .detail-gallery {
    height: clamp(380px, 42vw, 520px);
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .detail-gallery.single {
    height: clamp(360px, 40vw, 500px);
  }
}

@media (max-width: 620px) {
  .detail-gallery {
    height: clamp(300px, 92vw, 440px);
    max-height: min(440px, 68vh);
  }

  .detail-gallery.single {
    height: clamp(260px, 82vw, 390px);
  }

  .photo-lightbox {
    padding: 12px;
  }

  .photo-lightbox-panel {
    height: calc(100dvh - 24px);
    grid-template-columns: 1fr;
    gap: 0;
  }

  .photo-lightbox-figure {
    grid-column: 1;
    grid-row: 1;
  }

  .photo-lightbox-close {
    right: 0;
    top: 0;
  }

  .photo-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 50px;
    border-radius: 14px;
    z-index: 2;
  }

  .photo-lightbox-prev {
    left: 0;
  }

  .photo-lightbox-next {
    right: 0;
  }

  .photo-lightbox-image {
    max-height: calc(100dvh - 104px);
  }

  .photo-lightbox-caption {
    font-size: 12px;
    padding: 0 48px;
  }

  .password-toggle-wrap input {
    padding-right: 52px !important;
  }
}
