.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: none;
  background: var(--ht-scrim);
  backdrop-filter: var(--ht-scrim-blur);
  -webkit-backdrop-filter: var(--ht-scrim-blur);
  color: #fff;
  touch-action: none;
}

.gallery-lightbox.is-open {
  display: block;
}

.gallery-lightbox-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.gallery-lightbox-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.gallery-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  transform-origin: center center;
  will-change: transform;
}

.gallery-lightbox-img.is-zoomed {
  cursor: grab;
}

.gallery-lightbox-img.is-dragging {
  cursor: grabbing;
  transition: none;
}
/* 外觀來自 .ht-lightbox-close（custom.css）；這裡只留定位。 */
.gallery-lightbox-close {
  position: absolute;
  z-index: 3;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
}

.gallery-lightbox-close:hover {
  background: rgba(17,24,39,.78);
  border-color: rgba(255,255,255,.32);
}

.gallery-lightbox-close svg {
  width: 1.25rem;
  height: 1.25rem;
}

.gallery-lightbox-count {
  position: absolute;
  top: max(1.125rem, env(safe-area-inset-top));
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  background: rgba(17,24,39,.56);
  color: #fff;
  font-size: var(--ht-text-sm);
  font-weight: 600;
  line-height: 1.25;
}

.gallery-lightbox-hint {
  position: absolute;
  left: 50%;
  bottom: max(2rem, calc(env(safe-area-inset-bottom) + 1.25rem));
  z-index: 3;
  transform: translateX(-50%) translateY(0.5rem);
  margin: 0;
  padding: 0.5rem 0.875rem;
  border-radius: 999px;
  background: rgba(17,24,39,.62);
  color: #fff;
  font-size: var(--ht-text-sm);
  font-weight: 600;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease, transform .24s ease;
}

.gallery-lightbox-hint.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 47.9375rem) {
  .gallery-lightbox-close {
    top: max(0.75rem, env(safe-area-inset-top));
    right: max(0.75rem, env(safe-area-inset-right));
  }

  .gallery-lightbox--floorplan .floorplan-lightbox-viewport {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .floorplan-lightbox-thumbs {
    gap: 0.5rem;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }

  .floorplan-lightbox-thumb {
    width: 5rem;
    border-radius: 0.5rem;
  }

  .floorplan-lightbox-info {
    align-items: stretch;
    flex-direction: column;
    gap: 0.75rem;
  }

  .floorplan-lightbox-title {
    font-size: var(--ht-text-base);
  }

  .floorplan-lightbox-meta {
    font-size: var(--ht-text-xs);
  }

  .floorplan-lightbox-cta {
    width: 100%;
  }
}

@media (min-width: 48rem) {
  .gallery-lightbox-hint {
    display: none;
  }
}
.ht-lightbox-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0.0625rem solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(17, 24, 39, .56);
  color: #fff;
  cursor: pointer;
  transition: background .15s, opacity .15s, border-color .15s;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  /* Keep video/WebGL embeds on their own compositor layer. Live backdrop
     blur forces the browser to re-rasterize the entire page for every media
     frame and was the source of the lightbox-wide lag regression. */
  background: rgba(0, 0, 0, .92);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  /* 上方留一條給我們自己的關閉鈕。影片與環景是外部服務嵌進來的，他們的控制項也在
     角落——環景四個角都用掉了（左上作者資訊、右上自家按鈕列、下方工具列與縮圖），
     換個角落躲不掉，而且對方改版就又會撞上。留一條自己的空間才不依賴他們的版面。
     4rem 剛好容得下 2.75rem 的按鈕加上 1rem 的邊距。 */
  --ht-lightbox-top-band: max(4rem, calc(env(safe-area-inset-top) + 3rem));
  padding-top: var(--ht-lightbox-top-band);
}

.modal-overlay.open {
  display: flex;
}

.media-modal-frame {
  position: relative;
  width: min(72rem, 100%);

