/* Footer separation belongs to the shared column shell (--lea-page-end-gap).
   These markers remove only terminal, redundant space; never card-to-card gaps. */
.topic-page .page-body > .lea-topic-empty-tail,
.external-authentication.lea-empty-auth-slot { display: none; }
.topic-page .page-body > .lea-topic-last-block { margin-bottom: 0; }

/* Catalog spacing is known before JavaScript/AJAX runs. Keep the existing
   1/2/3-column float layout and its internal row gaps; only trim the last row. */
:is(.html-category-page, .html-manufacturer-page, .html-vendor-page,
    .html-product-tag-page, .html-recently-added-products-page, .html-search-page,
    .html-product-details-page)
  .master-column-wrapper { --lea-page-end-gap: var(--lea-catalog-page-end-gap, 80px); }

@media (max-width: 768px) {
  :root { --lea-catalog-page-end-gap: 48px; }
}

.products-wrapper > .product-grid,
.products-wrapper > .product-list { margin-bottom: 0; }
.products-wrapper > .pager { margin: 32px 0 0; }
/* The first relocated sidebar block may be Recently Viewed, not Popular Tags. */
.page-body > [data-lea-mobile-side-block="1"] { margin-top: 48px; }

@media (max-width: 480px) {
  .products-wrapper .item-box:last-child { margin-bottom: 0; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .products-wrapper .item-box:nth-child(2n+1):nth-last-child(-n+2),
  .products-wrapper .item-box:nth-child(2n+1):nth-last-child(-n+2) ~ .item-box {
    margin-bottom: 0;
  }
}
@media (min-width: 769px) {
  .products-wrapper .product-grid .item-box:nth-child(3n+1):nth-last-child(-n+3),
  .products-wrapper .product-grid .item-box:nth-child(3n+1):nth-last-child(-n+3) ~ .item-box,
  .products-wrapper .product-list .item-box:last-child { margin-bottom: 0; }
}

/* Detail recommendations use four desktop columns (catalog lists use three).
   Let the shared page-end gap own the space after the final recommendation grid. */
.product-details-page .product-grid:last-child,
.lea-tour-lower-section > .product-collateral:last-child { margin-bottom: 0; }
@media (max-width: 480px) {
  .product-details-page .product-grid:last-child .item-box:last-child { margin-bottom: 0; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .product-details-page .product-grid:last-child .item-box:nth-child(2n+1):nth-last-child(-n+2),
  .product-details-page .product-grid:last-child .item-box:nth-child(2n+1):nth-last-child(-n+2) ~ .item-box { margin-bottom: 0; }
}
@media (min-width: 769px) and (max-width: 1000px) {
  .product-details-page .product-grid:last-child .item-box:nth-child(3n+1):nth-last-child(-n+3),
  .product-details-page .product-grid:last-child .item-box:nth-child(3n+1):nth-last-child(-n+3) ~ .item-box { margin-bottom: 0; }
}
@media (min-width: 1001px) {
  .product-details-page .product-grid:last-child .item-box:nth-child(4n+1):nth-last-child(-n+4),
  .product-details-page .product-grid:last-child .item-box:nth-child(4n+1):nth-last-child(-n+4) ~ .item-box { margin-bottom: 0; }
}
