/* Native WordPress galleries: one grid per gallery, including pre-nested Gutenberg markup.
   Scoped to GTG single-post content and Catalogue previews; no media or link rewrites. */
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) :is(.wp-block-gallery.has-nested-images, .wp-block-gallery, .blocks-gallery-grid, .gallery) {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 12px !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 24px auto !important;
  padding: 0 !important;
  box-sizing: border-box;
  list-style: none;
}
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .wp-block-gallery:has(> .blocks-gallery-grid) {
  display: block !important;
}
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .wp-block-gallery > .blocks-gallery-grid {
  margin: 0 !important;
}
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) :is(.wp-block-gallery, .blocks-gallery-grid, .gallery) :is(.blocks-gallery-item, .wp-block-image, .gallery-item, .gallery-icon),
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .blocks-gallery-item > figure {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  float: none !important;
  flex: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box;
}
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) :is(.blocks-gallery-item, .wp-block-gallery > .wp-block-image, .gallery-icon) > a {
  display: block;
  width: 100%;
}
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) :is(.wp-block-gallery, .blocks-gallery-grid, .gallery) img {
  display: block;
  float: none;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  margin: 0 auto !important;
}
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) :is(.wp-block-gallery, .blocks-gallery-grid, .gallery) :is(figcaption, .gallery-caption) {
  position: static !important;
  width: auto !important;
  max-width: 100% !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 8px 4px !important;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-align: center;
  background: transparent !important;
  color: inherit !important;
}
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .gallery > br {display: none !important;}
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .wp-block-gallery > .blocks-gallery-caption {grid-column: 1 / -1;}
/* Count gallery items, not their file extensions: six GIFs behave like six stills. */
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .blocks-gallery-grid:has(> li.blocks-gallery-item:nth-of-type(6):last-of-type),
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .wp-block-gallery:has(> li.blocks-gallery-item:nth-of-type(6):last-of-type),
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .wp-block-gallery.has-nested-images:has(> figure.wp-block-image:nth-of-type(6):last-of-type),
html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) .gallery:has(> .gallery-item:nth-of-type(6):last-of-type) {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
@media (max-width: 767px) {
  html body :is(.gtg-single .gtg-entry-content, .gtgc-entry) :is(.wp-block-gallery.has-nested-images, .wp-block-gallery, .blocks-gallery-grid, .gallery) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
}
