@media (max-width: 768px) {
  /* The controls overlay the image after initialization, so don't reserve a second row. */
  html.ah-gallery-stable .woocommerce-product-gallery:has(.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:nth-child(2)):not(:has(.flex-control-thumbs)) { padding-bottom: 0; }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready { position: relative; }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready .flex-control-thumbs {
    position: absolute; z-index: 5; left: 8px; right: 8px; bottom: 8px;
    display: flex; flex-wrap: nowrap; align-items: center; gap: 5px;
    width: auto; max-width: none; margin: 0; padding: 4px;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    opacity: 0; pointer-events: none; transition: opacity .18s ease;
  }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready .flex-control-thumbs::-webkit-scrollbar { display: none; }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready .flex-control-thumbs li {
    flex: 0 0 46px; float: none; width: 46px !important; height: 46px; margin: 0; padding: 2px;
    box-sizing: border-box; background: rgba(255,255,255,.22);
  }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready .flex-control-thumbs li:first-child { margin-left: auto; }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready .flex-control-thumbs li:last-child { margin-right: auto; }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready .flex-control-thumbs li img { width: 100%; height: 100%; object-fit: contain; opacity: .45 !important; }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready .flex-control-thumbs li img.flex-active { opacity: 1 !important; outline: none; }
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready.ah-gallery-controls-visible .flex-control-thumbs,
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready:has(:focus-visible) .flex-control-thumbs { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) {
  body.single-product.woocommerce div.product div.images.ah-mobile-gallery-ready .flex-control-thumbs { transition: none; }
}
