/* Schema Gallery Pro - Hardened Against Theme Conflicts */

/* Hide masonry grid until JavaScript sets up columns */
.sg-gallery.sg-layout-masonry .sg-grid {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Show grid after masonry columns are built */
.sg-gallery.sg-layout-masonry .sg-grid.sg-masonry-ready {
  opacity: 1;
}
/* ===== MOBILE SCROLL HINT ===== */
.sg-mobile-scroll-hint {
  display: none;
}
.schema-unique-note {
  color: #d9e0ff !important;
  font-size: 0.95rem !important;
  text-align: center !important;
  margin-top: 8px !important;
  line-height: 1.5 !important;
}
.schema-unique-note em {
  display: block !important;
  margin-top: 4px !important;
  font-style: italic !important;
  opacity: 0.9 !important;
}
@media (max-width: 480px) {
  .schema-unique-note {
    white-space: normal !important;
    font-size: 0.9rem !important;
  }
}
@media (max-width: 767px) {
  .sg-mobile-scroll-hint {
    display: block !important;
    text-align: center !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: #555 !important;
    opacity: 0.85 !important;
    margin: 8px auto 4px !important;
    letter-spacing: 0.3px !important;
    width: 100% !important;
  }
}
/* ===== POWERED BY ===== */
.sg-powered-by {
  text-align: center !important;
  margin-top: 20px !important;
  margin-bottom: 0 !important;
  font-size: 10px !important;
  font-weight: 300 !important;
  color: #555 !important;
  opacity: 0.85 !important;
  line-height: 1.4 !important;
  letter-spacing: 0.3px !important;
}
.sg-powered-by a {
  color: #555 !important;
  text-decoration: none !important;
  font-weight: 400 !important;
  transition: all 0.2s ease;
}
.sg-powered-by a:hover {
  color: #1f4170 !important;
  text-decoration: underline !important;
  opacity: 1 !important;
}
/* ===== VIDEO SUPPORT STYLES ===== */
.sg-lightbox-video-container {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.sg-lightbox-video-wrapper {
  position: relative !important;
  width: 90vw !important;
  max-width: 1200px !important;
  padding-bottom: 56.25% !important;
  height: 0 !important;
}
.sg-lightbox-video-wrapper iframe {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 4px !important;
}
.sg-lightbox-img {
  max-width: 85vw !important;
  max-height: 75vh !important;
  object-fit: contain !important;
}
/* Video Play Icon Overlay */
.sg-item-video {
  position: relative !important;
}
.sg-video-play-icon {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  pointer-events: none !important;
  z-index: 2 !important;
  opacity: 0.9 !important;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.sg-item-video:hover .sg-video-play-icon {
  opacity: 1 !important;
  transform: translate(-50%, -50%) scale(1.1) !important;
}
.sg-video-play-icon svg {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4)) !important;
}
.sg-item-video::after {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.3) 100%) !important;
  pointer-events: none !important;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: var(--sg-border-radius, 16px);
}
.sg-item-video:hover::after {
  opacity: 1 !important;
}
.sg-layout-masonry .sg-item-video {
  position: relative !important;
}
.sg-theme-carousel .sg-item-video .sg-video-play-icon {
  opacity: 1 !important;
}
.sg-theme-compact .sg-item-video .sg-video-play-icon svg {
  width: 48px !important;
  height: 36px !important;
}
/* ===== GALLERY CORE - MAXIMUM DEFENSE ===== */
.sg-gallery {
  margin: 1.5rem 0 !important;
  padding: 0 15px !important;
  box-sizing: border-box !important;
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  position: relative !important;
  float: none !important;
  clear: both !important;
}
/* Base Grid Layout */
.sg-gallery:not(.sg-layout-masonry):not(.sg-theme-carousel):not(.sg-theme-compact) .sg-grid {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 4px !important;
  margin: 0 !important;
  padding: 15px !important;
  box-sizing: border-box !important;
  list-style: none !important;
  width: 100% !important;
  position: relative !important;
  float: none !important;
}
/* Dynamic column counts for Grid layout */
.sg-gallery.sg-layout-grid:not(.sg-theme-carousel):not(.sg-theme-compact)[data-columns="2"] .sg-grid {
  grid-template-columns: repeat(2, 1fr) !important;
}
.sg-gallery.sg-layout-grid:not(.sg-theme-carousel):not(.sg-theme-compact)[data-columns="3"] .sg-grid {
  grid-template-columns: repeat(3, 1fr) !important;
}
.sg-gallery.sg-layout-grid:not(.sg-theme-carousel):not(.sg-theme-compact)[data-columns="4"] .sg-grid {
  grid-template-columns: repeat(4, 1fr) !important;
}
.sg-gallery.sg-layout-grid:not(.sg-theme-carousel):not(.sg-theme-compact)[data-columns="5"] .sg-grid {
  grid-template-columns: repeat(5, 1fr) !important;
}
@media (max-width: 1024px) {
  .sg-gallery.sg-layout-grid:not(.sg-theme-carousel):not(.sg-theme-compact)[data-columns="4"] .sg-grid,
  .sg-gallery.sg-layout-grid:not(.sg-theme-carousel):not(.sg-theme-compact)[data-columns="5"] .sg-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 767px) {
  .sg-gallery:not(.sg-layout-masonry):not(.sg-theme-carousel):not(.sg-theme-compact) .sg-grid {
    grid-template-columns: 1fr !important;
  }
}
/* ===== MASONRY LAYOUT (PRO) - MAXIMUM DEFENSE ===== */
.sg-gallery.sg-layout-masonry {
  width: 100% !important;
  max-width: 100% !important;
  overflow: visible !important;
  position: relative !important;
}
.sg-gallery.sg-layout-masonry .sg-grid {
  display: flex !important;
  flex-direction: row !important;
  gap: 4px !important;
  align-items: flex-start !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 100% !important;
  /* Kill all grid properties */
  grid-template-columns: none !important;
  grid-auto-flow: unset !important;
  grid-auto-rows: unset !important;
  grid-template-rows: unset !important;
  /* Kill carousel/slider properties */
  overflow-x: visible !important;
  overflow-y: visible !important;
  scroll-behavior: auto !important;
  scroll-snap-type: none !important;
  -webkit-overflow-scrolling: auto !important;
  /* Standard resets */
  margin: 0 !important;
  padding: 15px !important;
  box-sizing: border-box !important;
}
/* Masonry column containers created by JavaScript */
.sg-masonry-column {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  min-width: 0 !important;
}
.sg-gallery.sg-layout-masonry .sg-item {
  display: block !important;
  width: 100% !important;
  margin-bottom: 0 !important;
  margin-top: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  float: none !important;
  /* Kill flex properties */
  flex: none !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  flex-basis: auto !important;
  /* Kill carousel properties */
  scroll-snap-align: none !important;
  min-width: 100% !important;
  max-width: 100% !important;
}
.sg-gallery.sg-layout-masonry .sg-item img {
  height: auto !important;
  width: 100% !important;
  min-height: auto !important;
  max-height: none !important;
  object-fit: cover !important;
}
/* ===== CAROUSEL/SLIDER THEME ===== */
.sg-gallery.sg-theme-carousel {
  max-width: 100% !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
  position: relative !important;
  padding: 20px 0 !important;
}
.sg-gallery.sg-theme-carousel .sg-grid {
  display: flex !important;
  overflow-x: auto !important;
  scroll-behavior: smooth !important;
  scroll-snap-type: x mandatory !important;
  -webkit-overflow-scrolling: touch !important;
  gap: 20px !important;
  padding: 20px 15px !important;
  grid-template-columns: none !important;
  column-count: 1 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  width: 100% !important;
}
.sg-gallery.sg-theme-carousel .sg-grid::-webkit-scrollbar {
  height: 22px !important;
}
.sg-gallery.sg-theme-carousel .sg-grid::-webkit-scrollbar-track {
  background: #eceff1 !important;
  border-radius: 10px !important;
  margin: 0 40px !important;
}
.sg-gallery.sg-theme-carousel .sg-grid::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border-radius: 10px !important;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.35) !important;
}
.sg-gallery.sg-theme-carousel .sg-grid::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.45) !important;
}
.sg-gallery.sg-theme-carousel .sg-grid::-webkit-scrollbar-thumb:active {
  background: linear-gradient(135deg, #4a3d8f 0%, #1f4170 100%) !important;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3) !important;
}
.sg-gallery.sg-theme-carousel .sg-item {
  flex: 0 0 auto !important;
  width: 320px !important;
  scroll-snap-align: start !important;
  display: block !important;
  break-inside: auto !important;
  margin-bottom: 0 !important;
  margin-top: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding: 0 !important;
}
.sg-gallery.sg-theme-carousel .sg-grid::before,
.sg-gallery.sg-theme-carousel .sg-grid::after {
  content: '' !important;
  flex: 0 0 20px !important;
}
@media (max-width: 768px) {
  .sg-gallery.sg-theme-carousel .sg-item {
    width: 280px !important;
  }
}
@media (max-width: 480px) {
  .sg-gallery.sg-theme-carousel .sg-item {
    width: 85vw !important;
  }
  .sg-gallery.sg-theme-carousel .sg-grid {
    gap: 15px !important;
  }
}
.sg-gallery.sg-theme-carousel .sg-pagination {
  margin-top: 30px !important;
}
/* ===== GALLERY ITEMS - STRUCTURAL PROTECTION ===== */
.sg-thumb-title {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0)) !important;
  color: #fff !important;
  padding: 30px 12px 15px 12px !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  text-align: center !important;
  pointer-events: none !important;
  margin: 0 !important;
  border: none !important;
  box-sizing: border-box !important;
}
.sg-item a {
  position: relative !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  text-decoration: none !important;
  border: none !important;
  background: transparent !important;
}
.sg-item a:hover .sg-thumb-title {
  opacity: 1 !important;
}
.sg-item {
  position: relative !important;
  background: transparent !important;
  border: none !important;
  border-radius: var(--sg-border-radius, 16px) !important;
  overflow: hidden !important;
  box-shadow: none !important;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  display: block !important;
  float: none !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
}
.sg-item:hover {
  border-color: #fafafa !important;
}
.sg-item img {
  width: 101% !important;
  height: 220px !important;
  object-fit: cover !important;
  display: block !important;
  margin: 0 0 0 -0.5% !important;
  padding: 0 !important;
  border: none !important;



  border-radius: var(--sg-border-radius, 16px) !important;
  box-sizing: border-box !important;
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  transition: transform 0.4s ease;
  max-width: 101% !important;
  min-width: 101% !important;
  max-height: 220px !important;
  min-height: 220px !important;
  flex-shrink: 0 !important;
  position: relative !important;
  filter: none !important;
  opacity: 1 !important;
}
.sg-item:hover img {
  transform: scale(1.05) !important;
}
.sg-caption {
  font-size: 14px !important;
  padding: 10px 12px !important;
  margin: 0 !important;
  color: #1f2937 !important;
  background: transparent !important;
  display: block !important;
  box-sizing: border-box !important;
  text-align: left !important;
  line-height: 1.4 !important;
}
.sg-empty,
.sg-error {
  color: #6b7280 !important;
  padding: 20px !important;
  text-align: center !important;
}
/* ===== THEME LIGHTBOX CONFLICT PREVENTION ===== */
.sg-lightbox-link.sg-no-theme-lightbox {
  pointer-events: auto !important;
}
/* ===== LIGHTBOX - MAXIMUM PROTECTION ===== */
.sg-lightbox-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0,0,0,0.92) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  opacity: 0;
  transition: opacity .3s ease;
  z-index: 999999 !important;
  padding: 60px 20px 60px !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}
.sg-lightbox-overlay.visible {
  opacity: 1 !important;
}
.sg-lightbox-overlay.visible .sg-lightbox-content {
  opacity: 1 !important;  /* Fade in content */
}
.sg-lightbox-container {
  position: relative !important;
  display: inline-block !important;
  max-width: 95vw !important;
  margin: 0 !important;
  padding: 0 !important;
}
.sg-lightbox-content {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #fff !important;
  padding: 8px !important;
  border-radius: 6px !important;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6) !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  opacity: 0 !important;  /* Start invisible */
  transition: opacity 0.2s ease 0.1s;  /* Fade in after 100ms */
}
.sg-lightbox-content img {
  max-width: 85vw !important;
  max-height: 75vh !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  box-sizing: border-box !important;
}
.sg-lightbox-title {
  position: absolute !important;
  bottom: 8px !important;
  left: 8px !important;
  right: 8px !important;
  background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.7) 50%, rgba(0,0,0,0) 100%) !important;
  color: #fff !important;
  font-size: 18px !important;
  font-weight: 600 !important;
  text-align: center !important;
  padding: 50px 20px 16px 20px !important;
  pointer-events: none !important;
  margin: 0 !important;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5) !important;
  border-radius: 0 0 4px 4px !important;
  border: none !important;
  box-sizing: border-box !important;
}
.sg-lightbox-close {
  position: absolute !important;
  top: -40px !important;
  right: -40px !important;
  font-size: 36px !important;
  color: #fff !important;
  cursor: pointer !important;
  width: 44px !important;
  height: 44px !important;
  border-radius: 50% !important;
  background: transparent !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.25s ease;
  z-index: 10000 !important;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8) !important;
  border: none !important;
  margin: 0 !important;

  padding: 0 !important;
  line-height: 1 !important;
}
.sg-lightbox-close:hover {
  transform: scale(1.15) !important;
}

/* ===== LIGHTBOX NAVIGATION - HIDDEN BY DEFAULT TO PREVENT CENTER FLASH ===== */
.sg-lightbox-prev,
.sg-lightbox-next {
  position: absolute !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  font-size: 48px !important;
  width: 50px !important;
  height: 100px !important;
  border-radius: 5% !important;
  background: rgba(242, 108, 79, 0.3) !important;
  color: #fff !important;
  display: flex !important;  /* Keep in layout */
  visibility: hidden !important;  /* Hide until ready */
  opacity: 0 !important;  /* Start transparent */
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  user-select: none !important;
  transition: all 0.25s ease, opacity 0.15s ease 0.05s, visibility 0s linear 0s;
  z-index: 10001 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5) !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
}

/* Show navigation only when lightbox is visible */
.sg-lightbox-overlay.visible .sg-lightbox-prev,
.sg-lightbox-overlay.visible .sg-lightbox-next {
  visibility: visible !important;
  opacity: 1 !important;
}

.sg-lightbox-prev:hover,
.sg-lightbox-next:hover {
  transform: translateY(-50%) scale(1.15) !important;
  background: rgba(139, 115, 85, 1) !important;
}
.sg-lightbox-prev {
  left: -60px !important;
  right: auto !important;
}
.sg-lightbox-next {
  right: -60px !important;
  left: auto !important;
}

/* Counter - also hidden by default */
.sg-lightbox-counter {
  position: absolute !important;
  bottom: -50px !important;
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  transform: translateX(-50%) !important;
  color: #fff !important;
  font-size: 14px !important;
  background: rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(10px);
  padding: 8px 16px !important;
  border-radius: 20px !important;
  z-index: 10000 !important;
  white-space: nowrap !important;
  margin: 0 !important;
  border: none !important;
  line-height: 1.4 !important;
  display: block !important;  /* Keep in layout */
  visibility: hidden !important;  /* Hide until ready */
  opacity: 0 !important;  /* Start transparent */
  transition: opacity 0.15s ease 0.05s, visibility 0s linear 0s;
}

/* Show counter only when lightbox is visible */
.sg-lightbox-overlay.visible .sg-lightbox-counter {
  visibility: visible !important;
  opacity: 1 !important;
}

/* Mobile: Move counter further down to avoid overlap with image */
@media (max-width: 768px) {
  .sg-lightbox-counter {
    bottom: -70px !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
  }
}

/* Very small mobile: Even more spacing */
@media (max-width: 480px) {
  .sg-lightbox-counter {
    bottom: -80px !important;
  }
}

/* ===== LOADING SPINNER (Between Frame Navigation) ===== */
.sg-lightbox-spinner {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 60px !important;
  height: 60px !important;
  border: 4px solid rgba(242, 108, 79, 0.2) !important;
  border-top: 4px solid rgba(242, 108, 79, 1) !important;
  border-radius: 50% !important;
  z-index: 10002 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transition: opacity 0.05s ease, visibility 0s linear 0.05s !important;
  animation: sg-spin 0.8s linear infinite !important;
  pointer-events: none !important;
}

.sg-lightbox-spinner.active {
  opacity: 1 !important;
  visibility: visible !important;
  transition: opacity 0.05s ease, visibility 0s linear 0s !important;
}

@keyframes sg-spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== PAGINATION ===== */
.sg-pagination {
  margin-top: 20px !important;
  margin-bottom: 0 !important;
  text-align: center !important;
  padding: 0 !important;
  display: block !important;
  clear: both !important;
}
.sg-pagination a {
  display: inline-block !important;
  margin: 0 4px !important;
  padding: 8px 14px !important;
  border-radius: 6px !important;
  background: #f3f4f6 !important;
  color: #1f2937 !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  transition: background .2s, color .2s;
  border: none !important;
  box-sizing: border-box !important;
  line-height: 1.4 !important;
}
.sg-pagination a:hover {
  background: #1f4170 !important;
  color: #fff !important;
}
.sg-pagination .active {
  background: #1f4170 !important;
  color: #fff !important;
  pointer-events: none !important;
}
.sg-pagination .sg-prev,
.sg-pagination .sg-next {
  font-weight: 600 !important;
}
/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 768px) {
  .sg-lightbox-overlay {
    padding: 50px 10px 10px !important;
  }
  .sg-lightbox-container {
    max-width: 100vw !important;
  }
  .sg-lightbox-content {
    padding: 6px !important;
  }
  .sg-lightbox-content img {
    max-width: 95vw !important;
    max-height: 75vh !important;
  }
  .sg-lightbox-video-wrapper {
    width: 95vw !important;
    padding-bottom: 53.4375% !important;
  }
  .sg-lightbox-title {
    font-size: 12px !important;
    padding: 40px 16px 12px 16px !important;
    bottom: 6px !important;
    left: 6px !important;
    right: 6px !important;
  }
  .sg-lightbox-close {
    top: 15px !important;
    right: 15px !important;
    font-size: 32px !important;
    width: 44px !important;
    height: 44px !important;
  }
  .sg-lightbox-prev,
  .sg-lightbox-next {
    font-size: 40px !important;
    width: 50px !important;
    height: 50px !important;
    background-color: rgba(255,255,255,0.15) !important;
  }
  .sg-lightbox-prev {
    left: 15px !important;
  }
  .sg-lightbox-next {
    right: 15px !important;
  }
  .sg-lightbox-counter {
    bottom: -70px !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
  }
}
/* ===== COMPACT GRID THEME ===== */
.sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
  gap: 4px !important;
  column-count: initial !important;
  margin: 0 !important;
  padding: 15px !important;
  box-sizing: border-box !important;
}
.sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-item {
  margin-bottom: 0 !important;
  break-inside: auto !important;
  border-radius: var(--sg-border-radius, 8px) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.1) !important;
}
.sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-item img {
  height: 160px !important;
  max-height: 160px !important;
  min-height: 160px !important;
}
@media (max-width: 1200px) {
  .sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
  }
  .sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-item img {
    height: 140px !important;
    max-height: 140px !important;
    min-height: 140px !important;
  }
}
@media (max-width: 768px) {
  .sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
    gap: 3px !important;
  }
  .sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-item img {
    height: 120px !important;
    max-height: 120px !important;
    min-height: 120px !important;
  }
}
@media (max-width: 480px) {
  .sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    gap: 2px !important;
  }
  .sg-gallery.sg-theme-compact:not(.sg-layout-masonry) .sg-item img {
    height: 100px !important;
    max-height: 100px !important;
    min-height: 100px !important;
  }
}
.sg-gallery.sg-theme-compact .sg-pagination {
  margin-top: 30px !important;
}
/* Force single column on phones for GRID layout */
@media (max-width: 767px) {
  .sg-gallery.sg-layout-grid:not(.sg-theme-carousel):not(.sg-theme-compact)[data-columns] .sg-grid {
    grid-template-columns: 1fr !important;
  }
}
/* Mobile landscape video optimization */
@media (orientation: landscape) and (max-height: 500px) {
  .sg-lightbox-video-container {
    width: 100% !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .sg-lightbox-video-wrapper {
    width: 80vw !important;
    max-width: none !important;
    padding-bottom: 0 !important;
    height: 85vh !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .sg-lightbox-video-wrapper iframe {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
  }
}
/* ===== PAGE BUILDER DEFENSES ===== */
/* Elementor, Divi, Beaver Builder, WPBakery wrappers */
[class*="elementor"] .sg-gallery,
[class*="et_pb"] .sg-gallery,
[class*="fl-builder"] .sg-gallery,
[class*="vc_"] .sg-gallery,
.elementor-widget-container .sg-gallery,
.et_pb_module .sg-gallery,
.fl-module-content .sg-gallery {
  width: 100% !important;
  max-width: 100% !important;
  margin: 1.5rem 0 !important;
  padding: 0 !important;
}
[class*="elementor"] .sg-gallery .sg-grid,
[class*="et_pb"] .sg-gallery .sg-grid,
[class*="fl-builder"] .sg-gallery .sg-grid,
[class*="vc_"] .sg-gallery .sg-grid {
  display: grid !important;
  width: 100% !important;
}
/* Page builders with masonry */
[class*="elementor"] .sg-gallery.sg-layout-masonry .sg-grid,
[class*="et_pb"] .sg-gallery.sg-layout-masonry .sg-grid,
[class*="fl-builder"] .sg-gallery.sg-layout-masonry .sg-grid,
[class*="vc_"] .sg-gallery.sg-layout-masonry .sg-grid {
  display: flex !important;
  flex-direction: row !important;
  gap: 4px !important;
  align-items: flex-start !important;
}
@media (max-width: 767px) {
  [class*="elementor"] .sg-gallery.sg-layout-masonry .sg-grid,
  [class*="et_pb"] .sg-gallery.sg-layout-masonry .sg-grid,
  [class*="fl-builder"] .sg-gallery.sg-layout-masonry .sg-grid,
  [class*="vc_"] .sg-gallery.sg-layout-masonry .sg-grid {
    flex-direction: column !important;
  }
}
/* Page builders with carousel */
[class*="elementor"] .sg-gallery.sg-theme-carousel .sg-grid,
[class*="et_pb"] .sg-gallery.sg-theme-carousel .sg-grid,
[class*="fl-builder"] .sg-gallery.sg-theme-carousel .sg-grid,
[class*="vc_"] .sg-gallery.sg-theme-carousel .sg-grid {
  display: flex !important;
}
/* ===== ULTRA-SPECIFIC OVERRIDES FOR PROBLEM THEMES ===== */
/* These handle the most aggressive theme conflicts */
/* Prevent theme image wrappers from breaking layout */
.sg-gallery .sg-grid .sg-item a[class*="lightbox"],
.sg-gallery .sg-grid .sg-item a[class*="image"],
.sg-gallery .sg-grid .sg-item .sg-lightbox-link {
  display: block !important;
  line-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
.sg-gallery .sg-grid .sg-item figure,
.sg-gallery .sg-grid .sg-item picture {
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
}
.sg-gallery .sg-grid .sg-item img[class*="attachment"],
.sg-gallery .sg-grid .sg-item img[class*="wp-image"] {
  width: 100% !important;
  height: 220px !important;
}
.sg-gallery .sg-grid .sg-item .wp-post-image {
  width: 100% !important;
  height: 220px !important;
  margin: 0 !important;
}
/* ===== NUCLEAR OPTION: MASONRY ALWAYS WINS ===== */
/* These rules override carousel/grid even if classes conflict */
.sg-layout-masonry.sg-gallery .sg-grid,
.sg-gallery.sg-layout-masonry.sg-theme-carousel .sg-grid,
.sg-gallery.sg-layout-masonry.sg-theme-compact .sg-grid {
  display: block !important;
  column-count: 3 !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  flex-direction: column !important;
  scroll-snap-type: none !important;
}
.sg-layout-masonry.sg-gallery .sg-item,
.sg-gallery.sg-layout-masonry.sg-theme-carousel .sg-item,
.sg-gallery.sg-layout-masonry.sg-theme-compact .sg-item {
  display: inline-block !important;
  width: 100% !important;
  flex: none !important;
  scroll-snap-align: none !important;
}
.sg-layout-masonry.sg-gallery .sg-item img,
.sg-gallery.sg-layout-masonry.sg-theme-carousel .sg-item img,
.sg-gallery.sg-layout-masonry.sg-theme-compact .sg-item img {
  height: auto !important;
  max-height: none !important;
  min-height: auto !important;
}
@media (max-width: 767px) {
  .sg-layout-masonry.sg-gallery .sg-grid,
  .sg-gallery.sg-layout-masonry.sg-theme-carousel .sg-grid,
  .sg-gallery.sg-layout-masonry.sg-theme-compact .sg-grid {
    column-count: 1 !important;
  }
}
/* ===== TOGGLE CONTROLS: DROPSHADOW, IMAGE BORDER, BORDER COLOR ===== */
/* Toggle Dropshadow - ON */
.sg-gallery.sg-has-dropshadow .sg-item {
  box-shadow: 0 6px 16px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.8) !important;
}
/* Toggle Dropshadow - OFF (disable hover shadow completely) */
.sg-gallery .sg-item:hover {
  box-shadow: none !important;
}
/* Toggle Image Border - OFF (removes border entirely) */
.sg-gallery.sg-no-border .sg-item {
  border: none !important;
}
/* Toggle Image Border - ON with White border (default) */
.sg-gallery.sg-has-border.sg-border-white .sg-item {
  border: 2px solid #ffffff !important;
}
/* Toggle Image Border - ON with Black border */
.sg-gallery.sg-has-border.sg-border-black .sg-item {
  border: 2px solid #000000 !important;
}
/* Ensure img element never has border or box-shadow */
.sg-gallery .sg-item img {
  border: none !important;
  box-shadow: none !important;
}