/* Keep photo controls outside the scrolling product content. */
.modal-header > div { min-width: 0; }
.modal-header h2 { overflow-wrap: anywhere; }
.close-btn { flex-shrink: 0; touch-action: manipulation; }
.lightbox-arrow { touch-action: manipulation; }
.lightbox-arrow[hidden] { display: none; }
.product-modal-scroll { min-width: 0; }
.qc-scroll-hint[hidden] { display: none; }

@media (max-width: 700px), (max-height: 500px) {
  #productModal,
  #imageLightbox {
    --viewer-top: max(10px, env(safe-area-inset-top, 0px));
    --viewer-right: max(10px, env(safe-area-inset-right, 0px));
    --viewer-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    --viewer-left: max(10px, env(safe-area-inset-left, 0px));
    height: 100%;
    height: 100dvh;
    padding: var(--viewer-top) var(--viewer-right) var(--viewer-bottom) var(--viewer-left);
  }
  #productModal .product-modal-refresh {
    display: flex;
    flex-direction: column;
    width: min(1080px, 100%);
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    padding: 0;
    border-radius: 18px;
  }
  #productModal .modal-header {
    flex: 0 0 auto;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px;
  }
  #productModal .modal-header > div { flex: 1; }
  #productModal .modal-header h2 { font-size: 19px; line-height: 1.25; }
  #productModal .modal-header .eyebrow { font-size: 8px; }
  #productModal .product-category-line { margin-top: 5px; font-size: 11px; }
  #productModal .product-modal-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
    scrollbar-width: thin;
  }
  #productModal .close-btn,
  #imageLightbox .close-btn,
  #imageLightbox .lightbox-arrow {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 24px;
    line-height: 1;
  }
  #productModal .main-qc-preview { height: min(43vh, 380px); height: min(43dvh, 380px); }
  #imageLightbox .lightbox-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 68px minmax(0, 1fr) auto;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  #imageLightbox .lightbox-close { position: absolute; top: 13px; right: 13px; }
  #imageLightbox .lightbox-content > img {
    grid-row: 2;
    justify-self: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: none;
  }
  #imageLightbox .lightbox-arrow {
    position: absolute;
    top: 50%;
    margin-top: -22px;
    font-size: 16px;
    background: rgba(8, 12, 22, .9);
  }
  #imageLightbox .lightbox-prev { left: 2px; }
  #imageLightbox .lightbox-next { right: 2px; }
  #imageLightbox .lightbox-arrow[hidden] { display: none; }
  #imageLightbox .lightbox-caption {
    position: static;
    grid-row: 3;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 10px 8px;
    font-size: 12px;
    line-height: 1.4;
  }
  #imageLightbox .lightbox-caption span:first-child { min-width: 0; overflow-wrap: anywhere; }
  #imageLightbox .lightbox-caption span:last-child { flex-shrink: 0; }
}
