.modal-bg {
  position: fixed;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  top: 0;
  left: 0;
  z-index: 5;
  opacity: 1;
  perspective: 5000px;
  overflow-y: auto;
  transition: opacity 0.4s ease-in-out;
}
.modal-bg.closed {
  opacity: 0;
  pointer-events: none;
}

.modal-panel {
  margin-top: 0;
  max-width: 580px;
  width: 100%;
  background-color: #FFFFFF;
  overflow-y: hidden;
  padding: 40px;
  transform: rotateX(0) scale(1);
  transform-origin: 50% 10%;
  transition: margin-top 0.6s ease-in-out, transform 0.4s ease 0.4s;
}
.closed .modal-panel {
  transform: rotateX(30deg) scale(1.2);
  margin-top: -120%;
}
.modal-panel.modal-panel-wide {
  max-width: 90%;
}
.modal-panel.modal-panel-wide .modal-content {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.modal-header {
  display: flex;
  padding-bottom: 30px;
}

.modal-title {
  flex: 2;
  margin: 0;
}

.modal-close i {
  color: #59B381;
  font-size: 36px;
  margin-top: -6px;
  margin-right: -6px;
  cursor: pointer;
}

.modal-content {
  padding-bottom: 30px;
  overflow-x: hidden;
  overflow-y: auto;
}
.modal-content form, .modal-content .form {
  width: 100%;
}
.modal-content.no-padding {
  padding-bottom: 0;
}

.modal-actions {
  display: flex;
  align-items: center;
}

.modal-actions * {
  margin-left: 30px;
  margin-right: 30px;
}

.modal-divider {
  border: none;
  border-top: 2px solid #DEF0E6;
  width: 100%;
  margin: 1em 0;
}

.modal-footer {
  text-align: center;
  padding-top: 30px;
  border-top: 2px solid #DEF0E6;
}
.modal-footer.no-divider {
  padding-bottom: 0;
  padding-top: 0;
  border-top: none;
}
.modal-footer.no-padding {
  padding-top: 0;
}

.modal-link .link {
  margin-left: 10px;
}

.lightbox-bg {
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  top: 0;
  left: 0;
  z-index: 20;
  cursor: zoom-out;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-image-wrap {
  width: 80vw;
  height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.lightbox-image-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  cursor: zoom-in;
  user-select: none;
  transition: transform 0.15s ease-out;
}
.lightbox-image-wrap.zoomed img {
  cursor: grab;
}
.lightbox-image-wrap.dragging img {
  cursor: grabbing;
  transition: none;
}

.lightbox-caption {
  color: #FFFFFF;
  text-align: center;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.lightbox-counter {
  opacity: 0.7;
  font-size: 0.9em;
}

.lightbox-close {
  position: absolute;
  top: 64px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  cursor: pointer;
}
.lightbox-close i {
  color: #FFFFFF;
  font-size: 32px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  cursor: pointer;
}
.lightbox-nav i {
  color: #FFFFFF;
  font-size: 28px;
}
.lightbox-nav.lightbox-prev {
  left: 8px;
}
.lightbox-nav.lightbox-next {
  right: 8px;
}

.lightbox-thumbnails {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 0 80px;
  overflow-x: auto;
}

.lightbox-thumbnail {
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.6;
  border: 2px solid transparent;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.lightbox-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lightbox-thumbnail:hover {
  opacity: 0.85;
}
.lightbox-thumbnail.active {
  opacity: 1;
  border-color: #FFFFFF;
}

@media screen and (max-width: 767px) {
  .lightbox-image-wrap {
    width: 94vw;
    height: 56vh;
  }
  .lightbox-close {
    top: 8px;
    right: 8px;
  }
  .lightbox-nav {
    width: 56px;
    height: 56px;
  }
  .lightbox-nav.lightbox-prev {
    left: 0;
  }
  .lightbox-nav.lightbox-next {
    right: 0;
  }
  .lightbox-thumbnails {
    bottom: 12px;
    padding: 0 12px;
    gap: 6px;
  }
  .lightbox-thumbnail {
    width: 44px;
    height: 44px;
  }
  .lightbox-caption {
    margin-top: 8px;
    font-size: 0.9em;
  }
}