/* ==============================
   com_kilchgallery - Gallery page
   ============================== */

/* Ensure Helix sticky header is always above gallery page content */
body.com-kilchgallery.view-gallery #sp-header,
body.com-kilchgallery.view-gallery #sp-top-bar,
body.com-kilchgallery.view-gallery .sticky-header{
  position: relative !important;
  z-index: 999999 !important;
}

/* Prevent any gallery panel/pseudo-elements from overlaying the header */
body.com-kilchgallery.view-gallery .kilch-gallery,
body.com-kilchgallery.view-gallery .kilch-gallery::before,
body.com-kilchgallery.view-gallery .gallery-header{
  z-index: 0 !important;
}

/* Blueprint background for SINGLE GALLERY page (Helix Ultimate) */
body.com-kilchgallery.view-gallery .body-wrapper{
  background: url("/images/Kilch-Gallery-System-Photos/bg.jpg") no-repeat left top / cover !important;
  background-attachment: fixed !important;
}

/* Ensure inner section doesn't paint over it */
body.com-kilchgallery.view-gallery #sp-main-body{
  background: transparent !important;
}

/* ----------------------------------------------------------
   IMPORTANT: Sticky header scroll behavior (webpage mode)
   Content must scroll UNDER the sticky header, never OVER it.
   ---------------------------------------------------------- */
body.com-kilchgallery.view-gallery.sticky-header .gallery-header,
body.com-kilchgallery.view-gallery.sticky-header .kilch-gallery{
  position: relative !important;
  z-index: 0 !important; /* header stays above */
  background-color: rgba(255, 255, 255, 0.85) !important;
  border-radius: 8px;
  padding: 10px 15px;
  border: 1px solid #ccc;
}

/* Basic header */
.gallery-header{
  margin-bottom: 18px;
}

.gallery-title{
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 800;
}

.gallery-description{
  margin: 0 0 12px;
  color: #555;
  line-height: 1.6;
}

/* Tools row under description */
.kg-gallery-tools{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 18px;
}

.kg-gallery-tools-controls{
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

/* ==============================
   Rating
   ============================== */
.kg-ratingwrap{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.kg-rating{
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.kg-star{
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: #c7c7c7;
  padding: 0;
}

.kg-star.is-on{ color: #f2c200; }

.kg-star:focus{
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.kg-star:disabled{
  cursor: not-allowed;
  opacity: 0.75;
}

.kg-ratingavg{
  display: inline-block;
  min-width: 2.4em;
  text-align: right;
  font-size: 0.9rem;
  opacity: 0.85;
  line-height: 1;
  color: #333;
  padding-right: 10px;
}

/* ==============================
   Share icon button
   ============================== */
.kg-share.kg-share-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: #d3d3d3;
  border: 0;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2);
  transition: background 0.2s ease;
  color: #333;
  flex: 0 0 auto;
}

.kg-share.kg-share-icon:hover{
  background: #c0c0c0;
}

/* ==============================
   Share popup
   ============================== */
.kg-share-popup{
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 3000;
}

.kg-share-popup-inner{
  background: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 14px;
  width: 350px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  position: fixed;
}

.kg-share-title{
  font-weight: 600;
  margin-bottom: 10px;
}

.kg-share-links{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 10px 0 14px;
}

.kg-share-link,
.kg-share-copy{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #f0f0f0;
  border: 0;
  color: #333;
  text-decoration: none;
  cursor: pointer;
  flex: 0 0 auto;
}

.kg-share-link:hover,
.kg-share-copy:hover{ background: #ddd; }

.kg-share-close{
  display: block;
  margin: 0 auto;
}

/* ==============================
   Sections + Photo Grid
   ============================== */
.kg-section-title{
  margin: 22px 0 12px;
  font-size: 18px;
  font-weight: 800;
}

.kg-photo-grid{
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr));
}

@media (max-width: 1200px){
  .kg-photo-grid{ grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr)); }
}
@media (max-width: 800px){
  .kg-photo-grid{ grid-template-columns: repeat(min(2, var(--kg-photos-cols, 4)), minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .kg-photo-grid{ grid-template-columns: minmax(0, 1fr); }
}

.kg-photo-grid a,
.kg-photo-grid img,
.kg-photo-card img{
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(17,24,39,0.10);
}

.kilch-gallery .kg-photo-card,
.kilch-gallery .kg-photo-link{
  overflow: hidden;
  border-radius: 14px;
}
.kilch-gallery .kg-photo-card img,
.kilch-gallery .kg-photo-grid img{
  filter: grayscale(1);
  transform: scale(1);
  transition: filter 0.2s ease, transform 0.2s ease;
}
.kilch-gallery .kg-photo-card:hover img,
.kilch-gallery .kg-photo-link:hover img,
.kilch-gallery .kg-photo-card:focus-within img,
.kilch-gallery .kg-photo-link:focus-visible img{
  filter: grayscale(0);
  transform: scale(1.06);
}
@media (max-width: 700px){
  .kilch-gallery .kg-photo-card:hover img,
  .kilch-gallery .kg-photo-link:hover img,
  .kilch-gallery .kg-photo-card:focus-within img{
    filter: grayscale(1);
    transform: scale(1);
  }
  .kilch-gallery .kg-photo-card:active img,
  .kilch-gallery .kg-photo-link:active img,
  .kilch-gallery .kg-photo-link:focus-visible img{
    filter: grayscale(0);
    transform: scale(1.06);
  }
}
#kg-lightbox img,
#kg-lightbox-img{
  filter: none;
  transform: none;
}

/* ==============================
   Lightbox
   ============================== */
.kg-lightbox{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kg-lightbox-inner{
  max-width: min(1100px, 92vw);
  max-height: 92vh;
  background: #111;
  padding: 10px;
  border-radius: 10px;
}

#kg-lightbox-img{
  max-width: 100%;
  max-height: 100dvh;
  display: block;
  margin: 0 auto;
}

.kg-lightbox-caption{
  color: #eee;
  font-size: 14px;
  margin-top: 10px;
  text-align: center;
}

/* =========================================================
   FINAL OVERRIDES — match your requested single-gallery layout
   (keeps title visible on the page)
   ========================================================= */

/* Grid uses ACP Front End Settings column count */
body.com-kilchgallery.view-gallery .kg-photo-grid,
body.com_kilchgallery.view-gallery .kg-photo-grid{
  gap: 18px !important;
  grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr)) !important;
  justify-content: stretch !important;
  justify-items: stretch !important;
}

body.com-kilchgallery.view-gallery .kg-photo-card{
  width: 100% !important;
  max-width: none !important;
}

/* In overlay iframe mode (tmpl=component): hide the in-page return button,
   because the overlay topbar provides the correct one. */
body.com-kilchgallery.view-gallery .kg-open-gallery-overlay{
  display: none !important;
}

/* =========================================================
   Single Gallery page header controls layout
   - Remove Viewing Options bar
   - Add Return to Galleries in place of old fullscreen button
   - Move Go Full Screen next to title (right aligned)
   ========================================================= */

/* 1) Remove the Viewing Options bar completely */
body.com-kilchgallery.view-gallery .kg-viewing-options,
body.com-kilchgallery.view-gallery .kg-viewing-options-bar,
body.com-kilchgallery.view-gallery .kg-viewing,
body.com-kilchgallery.view-gallery .kg-viewing-options-wrap,
body.com-kilchgallery.view-gallery .kg-toolbar-viewing{
  display: none !important;
}

/* 2) Title row becomes a flex row so fullscreen can sit to the right */
body.com-kilchgallery.view-gallery .gallery-header{
  display: block;
}

body.com-kilchgallery.view-gallery .gallery-header .gallery-title,
body.com-kilchgallery.view-gallery .kilch-gallery h1.gallery-title,
body.com-kilchgallery.view-gallery .kilch-gallery h1{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 10px;
}

/* 3) Go Full Screen button moved into the title line (right side)
   Assumes the button already exists with [data-kg-viewer-open].
   If your selector differs, tell me the button HTML and I’ll adjust. */
body.com-kilchgallery.view-gallery [data-kg-viewer-open]{
  margin-left: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}

/* 4) Replace the old button area under the title with Return to Galleries
   We create it via CSS only if you already have a return link/button element.
   If you do NOT have one on this page yet, see note below. */
body.com-kilchgallery.view-gallery .kg-return-to-galleries,
body.com-kilchgallery.view-gallery a.kg-return-to-galleries{
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid #cfd6e4;
  background: #ffffff;
  color: #111;
  font-weight: 600;
  text-decoration: none !important;
}

/* If the old fullscreen button container exists, hide it (we moved fullscreen) */
body.com-kilchgallery.view-gallery .kg-fullscreen-row,
body.com-kilchgallery.view-gallery .kg-fullscreen-wrap{
  display: none !important;
}

/* Place Return to Galleries beneath title (left) */
body.com-kilchgallery.view-gallery .kg-gallery-tools{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin: 6px 0 18px;
}

/* Hide the bottom fullscreen helper/popup bar */
body.com-kilchgallery.view-gallery .kg-fullscreen-hint,
body.com-kilchgallery.view-gallery .kg-fullscreen-popup,
body.com-kilchgallery.view-gallery .kg-fullscreen-toast,
body.com-kilchgallery.view-gallery .kg-viewer-hint,
body.com-kilchgallery.view-gallery .kg-viewer-toast,
body.com-kilchgallery.view-gallery .kg-viewer-bottombar,
body.com-kilchgallery.view-gallery .kg-overlay-bottombar{
  display: none !important;
}

/* PAGE VERSION (not iframe): remove Viewing Options UI + bottom re-enter bar */
body.com-kilchgallery.view-gallery summary.kg-fs-tip__summary,
body.com-kilchgallery.view-gallery summary.kg-fs-tip__summary *{
  display: none !important;
}

body.com-kilchgallery.view-gallery #kg-fs-reenter{
  display: none !important;
}

/* =========================================================
   Gallery PAGE version: remove FullScreen tip bar + re-enter popup
   ========================================================= */
body.com-kilchgallery.view-gallery summary.kg-fs-tip__summary,
body.com-kilchgallery.view-gallery #kg-fs-reenter{
  display: none !important;
}

/* =========================================================
   Gallery PAGE version: title row with Return + Full Screen inline
   ========================================================= */
body.com-kilchgallery.view-gallery .kg-gallery-headrow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 12px;
}

body.com-kilchgallery.view-gallery .kg-gallery-headrow .gallery-title{
  margin: 0 !important;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
}

body.com-kilchgallery.view-gallery .kg-gallery-headrow .kg-return-to-galleries{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #cfd6e4;
  background: #fff;
  color: #111;
  font-weight: 700;
  text-decoration: none !important;
  white-space: nowrap;
}

body.com-kilchgallery.view-gallery .kg-gallery-headrow .kg-fs-btn{
  margin-left: auto;
  white-space: nowrap;
}

/* PAGE version: remove the Tip / Viewing Options bar completely */
body.com-kilchgallery.view-gallery summary.kg-fs-tip__summary,
body.com-kilchgallery.view-gallery details.kg-fs-tip,
body.com-kilchgallery.view-gallery .kg-fs-tip{
  display: none !important;
}

/* Hide the original button bar area under the tip bar (we relocate the button) */
body.com-kilchgallery.view-gallery .kg-fs-bar,
body.com-kilchgallery.view-gallery .kg-fs-controls,
body.com-kilchgallery.view-gallery .kg-fs-btnwrap{
  display: none !important;
}

body.com-kilchgallery.view-gallery .kg-gallery-headrow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 12px;
}

body.com-kilchgallery.view-gallery .kg-gallery-headrow .gallery-title{
  margin: 0 !important;
}

body.com-kilchgallery.view-gallery .kg-return-to-galleries{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #cfd6e4;
  background: #fff;
  color: #111;
  font-weight: 700;
  text-decoration: none !important;
  white-space: nowrap;
}

/* Remove the Tip bar (Viewing Options / Tip & Full Screen) */
body.com-kilchgallery.view-gallery summary.kg-fs-tip__summary,
body.com-kilchgallery.view-gallery summary.kg-fs-tip__summaryText,
body.com-kilchgallery.view-gallery details.kg-fs-tip{
  display: none !important;
}

/* =========================================================
   PAGE Gallery header: hide tip UI but allow JS to move the viewer button out
   ========================================================= */

/* Hide the clickable summary bar entirely */
body.com-kilchgallery.view-gallery details.kg-fs-tip > summary.kg-fs-tip__summary{
  display: none !important;
}

/* Hide the tip text + dismiss button (we don't want the tip UI at all) */
body.com-kilchgallery.view-gallery .kg-fs-tip__text,
body.com-kilchgallery.view-gallery button[data-kg-fs-tip-dismiss]{
  display: none !important;
}

/* Hide the native fullscreen button (we will use the viewer button instead) */
body.com-kilchgallery.view-gallery button[data-kg-fullscreen-btn]{
  display: none !important;
}

/* Title row layout (JS will insert .kg-gallery-headrow) */
body.com-kilchgallery.view-gallery .kg-gallery-headrow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 12px;
}

body.com-kilchgallery.view-gallery .kg-gallery-headrow .gallery-title{
  margin: 0 !important;
}

body.com-kilchgallery.view-gallery .kg-gallery-headrow .kg-fs-btn--small{
  margin-left: auto;
  white-space: nowrap;
}

/* Force-show the Return button if it got hidden */
body.com-kilchgallery.view-gallery button.kg-open-gallery-overlay[data-kg-overlay-open]{
  display: inline-flex !important;
}

body.com-kilchgallery.view-gallery button.kg-fs-btn[data-kg-fullscreen-btn]{
  display: none !important;
}

body.com-kilchgallery.view-gallery .kg-gallery-headrow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin:0 0 12px;
}
body.com-kilchgallery.view-gallery .kg-gallery-headrow .gallery-title{ margin:0 !important; }

/* Hide the "Tap to return to Full Screen" overlay inside iframe / viewer pages */
#kg-fs-reenter{
  display: none !important;
}

/* Gallery page (normal view): blueprint background like Galleries page */
body.com-kilchgallery.view-gallery{
  background-image: url("/images/Kilch-Gallery-System-Photos/bg.jpg") !important;
  background-repeat: no-repeat !important;
  background-position: center top !important;
  background-size: cover !important;
  background-attachment: scroll !important;
  background-color: transparent !important;
  background-blend-mode: lighten !important;
}

body.com-kilchgallery.view-gallery .body-innerwrapper,
body.com-kilchgallery.view-gallery #sp-main-body,
body.com-kilchgallery.view-gallery .container,
body.com-kilchgallery.view-gallery #sp-component{
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

/* Header layout: title left, actions right */
body.com-kilchgallery.view-gallery .gallery-header{
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 16px;
  row-gap: 8px;
  align-items: start;
}

/* Title occupies left column */
body.com-kilchgallery.view-gallery .gallery-header .gallery-title{
  grid-column: 1;
  grid-row: 1;
  margin: 0 !important;
}

/* Return button on right, aligned with title */
body.com-kilchgallery.view-gallery .gallery-header .kg-return-link{
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  white-space: nowrap;
}

/* Rating goes under Return button (right side) */
body.com-kilchgallery.view-gallery .gallery-header .kg-ratingwrap-gallery{
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
}

/* Gallery normal page: fixed blueprint background */
body.com-kilchgallery.view-gallery{
  background-image: url("/images/Kilch-Gallery-System-Photos/bg.jpg") !important;
  background-repeat: no-repeat !important;
  background-position: center top !important;
  background-size: cover !important;
  background-attachment: fixed !important;  /* this is the key */
  background-blend-mode: lighten !important;
}

/* Gallery normal page: title left; Return+Rating stacked on right */
body.com-kilchgallery.view-gallery .gallery-header.kg-gallery-header-grid{
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto;
  gap: 10px 16px;
  align-items: start;
}

body.com-kilchgallery.view-gallery .gallery-header.kg-gallery-header-grid .gallery-title{
  grid-column: 1;
  margin: 0 !important;
  font-size: 24px !important;
}

body.com-kilchgallery.view-gallery .gallery-header .kg-gallery-header-right{
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Make sure rating stays compact */
body.com-kilchgallery.view-gallery .gallery-header .kg-ratingwrap-gallery{
  margin: 0 !important;
}

/* Gallery page: title left; Return+Rating stacked on the right */
body.com-kilchgallery.view-gallery .gallery-header.kg-gallery-header-grid{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: start;
}

body.com-kilchgallery.view-gallery .gallery-header .kg-gallery-header-right{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Tools row: keep share + rating aligned on the right */
body.com-kilchgallery.view-gallery .kg-gallery-tools-controls.kg-tools-flex{
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

/* Tools row: Share on left, Rating on right */
body.com-kilchgallery.view-gallery .kg-gallery-tools-controls{
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

body.com-kilchgallery.view-gallery .kg-gallery-tools-controls .kg-share{
  order: 1;
}

body.com-kilchgallery.view-gallery .kg-gallery-tools-controls .kg-ratingwrap-gallery{
  order: 2;
}

({
  ratingInTools: !!document.querySelector('.kg-gallery-tools-controls .kg-ratingwrap-gallery'),
  ratingInHeaderRight: !!document.querySelector('.gallery-header .kg-gallery-header-right .kg-ratingwrap-gallery')
})
Object { ratingInTools: true, ratingInHeaderRight: false }

body.com-kilchgallery.view-gallery .kg-gallery-tools{
  display: flex;
}
body.com-kilchgallery.view-gallery .kg-gallery-tools-controls{
  flex: 1 1 auto;


}

/* Make the tools row span full width so items can align left/right */
body.com-kilchgallery.view-gallery .kg-gallery-tools{
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
}

/* Controls area should fill remaining row width */
body.com-kilchgallery.view-gallery .kg-gallery-tools-controls{
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  margin-left: 0 !important;   /* overrides earlier margin-left:auto */
}

/* Share left, Rating right */
body.com-kilchgallery.view-gallery .kg-gallery-tools-controls .kg-share{
  margin-right: auto !important;
}

body.com-kilchgallery.view-gallery .kg-gallery-tools-controls .kg-ratingwrap-gallery{
  margin-left: auto !important;
}

/* ===== Gallery page header/tools: reduce vertical height ===== */
body.com-kilchgallery.view-gallery .gallery-header{
  padding: 8px 12px !important;      /* smaller */
  margin: 10px 0 6px !important;
  border-radius: 8px !important;
}

body.com-kilchgallery.view-gallery .gallery-header .gallery-title{
  font-size: clamp(22px, 3vw, 34px) !important;  /* slightly smaller */
  margin: 0 !important;
  line-height: 1.1 !important;
}

/* Return button a bit tighter */
body.com-kilchgallery.view-gallery .gallery-header .kg-open-gallery-overlay,
body.com-kilchgallery.view-gallery .gallery-header .kg-return-link{
  padding: 3px 8px !important;
  border-radius: 12px !important;
}

/* Tools row tighter */
body.com-kilchgallery.view-gallery .kg-gallery-tools{
  margin: 6px 0 8px !important;      /* was larger */
}

body.com-kilchgallery.view-gallery .kg-gallery-tools-controls{
  gap: 10px !important;
}

/* Smaller share button */
body.com-kilchgallery.view-gallery .kg-share.kg-share-icon{
  width: 34px !important;
  height: 34px !important;
}

/* Rating tighter/smaller */
body.com-kilchgallery.view-gallery .kg-ratingwrap-gallery .kg-star{
  font-size: 16px !important;
}
body.com-kilchgallery.view-gallery .kg-ratingwrap-gallery .kg-ratingavg{
  font-size: 0.85rem !important;
}

/* Gallery description box (appears above "Before") */
body.com-kilchgallery.view-gallery .kg-gallery-descbox{
  margin: 6px 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.80);
  line-height: 1.45;
  font-size: 0.98rem;
}

body.com-kilchgallery.view-gallery .kg-gallery-descbox{
  margin-top: 4px !important;
  background: rgba(255,255,255,0.86) !important;
}

/* Full-page gallery viewer: meta row above description */
.kg-viewer-metabar{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
}

.kg-viewer-metabar .kg-actions{
  margin-right: auto;
}

.kg-viewer-metabar .kg-ratingwrap{
  margin-left: auto;
}

/* =========================================================
   Single Gallery (tmpl=component / fullscreen iframe):
   Make header a 2-row layout:
   Row 1: Title left | Return right
   Row 2: Share left | Rating right
   Description becomes its own full-width box below
   ========================================================= */

.kilch-gallery .gallery-header{
  display: grid !important;
  grid-template-columns: 1fr auto !important;
  grid-template-rows: auto auto auto !important; /* title/return | meta | description */
  gap: 10px !important;
  align-items: center !important;
}

/* Keep ONLY the top Return button (the one in row 1) */
.kilch-gallery .gallery-header .kg-topbar-return{
  grid-column: 2 !important;
  grid-row: 1 !important;
  justify-self: end !important;
}

/* If there are multiple Return buttons, hide any extras inside the header */
.kilch-gallery .gallery-header .kg-topbar-return ~ .kg-topbar-return{
  display: none !important;
}

/* Title (whatever element it is) stays top-left */
.kilch-gallery .gallery-header .kg-overlay-modal__title,
.kilch-gallery .gallery-header h1,
.kilch-gallery .gallery-header h2,
.kilch-gallery .gallery-header .gallery-title{
  grid-column: 1 !important;
  grid-row: 1 !important;
  justify-self: start !important;
  margin: 0 !important;
}

/* Meta row: Share left, Rating right */
.kilch-gallery .gallery-header .kg-actions{
  grid-column: 1 !important;
  grid-row: 2 !important;
  justify-self: start !important;
  align-self: center !important;
  margin: 0 !important;
}

.kilch-gallery .gallery-header .kg-ratingwrap{
  grid-column: 2 !important;
  grid-row: 2 !important;
  justify-self: end !important;
  align-self: center !important;
  margin: 0 !important;
}

/* Description box becomes its own row, full width */
.kilch-gallery .gallery-header .kg-desc,
.kilch-gallery .gallery-header .gallery-description,
.kilch-gallery .gallery-header .description{
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  margin: 0 !important;
}

.kilch-gallery .gallery-header .kg-desc .kg-topbar-return,
.kilch-gallery .gallery-header .gallery-description .kg-topbar-return,
.kilch-gallery .gallery-header .description .kg-topbar-return{
  display: none !important;
}

/* FULL PAGE gallery viewer (iframe): restructure header + remove inner return */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header{
  display: grid !important;
  grid-template-columns: 1fr auto !important;
  grid-template-rows: auto auto auto !important; /* title | tools row | description */
  gap: 10px !important;
  align-items: center !important;
}

/* Title row */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .gallery-title{
  grid-column: 1 !important;
  grid-row: 1 !important;
  margin: 0 !important;
}

/* Tools row becomes the meta row */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .kg-gallery-tools-controls{
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Remove the INNER Return to Galleries button */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .kg-gallery-tools-controls .kg-open-gallery-overlay{
  display: none !important;
}

/* Share far-left */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .kg-gallery-tools-controls .kg-gallery-share{
  margin-right: auto !important;
}

/* Rating far-right */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .kg-gallery-tools-controls .kg-ratingwrap-gallery{
  margin-left: auto !important;
}

/* Description row full width, below tools */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .gallery-description{
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  margin: 0 !important;
}

/* Full page gallery: remove the INNER description box (keep only .gallery-header box) */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .gallery-description{
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .kg-gallery-tools-controls{
  padding: 0 !important;
  margin: 6px 0 8px !important;
  background: transparent !important;
  border: 0 !important;
}

/* Detached tools row (moved by JS) sits above the header box */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls.kg-tools-detached{
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  margin: 0 0 10px 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

/* Hide the inner Return button (still inside tools) */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls .kg-open-gallery-overlay{
  display: none !important;
}

/* Share far-left, rating far-right */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls .kg-gallery-share{
  margin-right: auto !important;
}
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls .kg-ratingwrap-gallery{
  margin-left: auto !important;
}

/* Remove the INNER description box look so there’s only ONE box (gallery-header) */
body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header .gallery-description{
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.kg-gallery-tools-controls--top{
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
}

.kg-gallery-tools-controls--top .kg-open-gallery-overlay{
  margin-right: auto; /* pushes share+rating to the right if desired */
}

/* If you want share far-left and rating far-right: */
.kg-gallery-tools-controls--top .kg-gallery-share{ margin-right: auto; }
.kg-gallery-tools-controls--top .kg-ratingwrap-gallery{ margin-left: auto; }

/* Full page gallery: ensure Share button is visible in the detached tools row */
body.com_kilchgallery.view-gallery .kg-gallery-tools-controls{
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

body.com_kilchgallery.view-gallery .kg-gallery-tools-controls .kg-gallery-share{
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative !important;
  z-index: 5 !important;
}

/* Share button: match site style (circle, gray, centered icon) */
.kg-share.kg-share-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: #d3d3d3;
  border: 0;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2);
  color: #333;
}

.kg-share.kg-share-icon:hover{ background: #c0c0c0; }

/* Hide the FA span if it exists (we'll draw our own icon) */
.kg-share.kg-share-icon .kg-fa{ display:none !important; }

/* Draw a share icon (SVG-ish using CSS mask) */
.kg-share.kg-share-icon::before{
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7a2.5 2.5 0 0 0 0-1.39l7-4.11A2.99 2.99 0 1 0 15 5a3 3 0 0 0 .04.49l-7 4.11A3 3 0 1 0 9 15a3 3 0 0 0-.04-.49l7.13 4.17A3 3 0 1 0 18 16.08z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7a2.5 2.5 0 0 0 0-1.39l7-4.11A2.99 2.99 0 1 0 15 5a3 3 0 0 0 .04.49l-7 4.11A3 3 0 1 0 9 15a3 3 0 0 0-.04-.49l7.13 4.17A3 3 0 1 0 18 16.08z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Landing viewer page (Itemid=662): do not show Return buttons */
body.itemid-662 .kg-topbar-return,
body.itemid-662 .kg-open-gallery-overlay {
  display: none !important;
}

/* Normal (non-overlay) gallery page: ACP column setting */
body:not(.contentpane) .kilch-gallery .kg-photo-grid{
  display: grid;
  grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr));
  gap: 18px;
}

@media (max-width: 1200px){
  body:not(.contentpane) .kilch-gallery .kg-photo-grid{
    grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr));
  }
}
@media (max-width: 800px){
  body:not(.contentpane) .kilch-gallery .kg-photo-grid{
    grid-template-columns: repeat(min(2, var(--kg-photos-cols, 4)), minmax(0, 1fr));
  }
}
@media (max-width: 520px){
  body:not(.contentpane) .kilch-gallery .kg-photo-grid{
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Normal page: match fullscreen toolbar padding/shape */
body:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls{
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
}

/* Normal gallery page (not tmpl=component): ACP column setting */
body:not(.contentpane) .kilch-gallery .kg-photo-grid,
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-photo-grid,
body.com-kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-photo-grid{
  grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr)) !important;
  justify-content: stretch !important;
  justify-items: stretch !important;
  gap: 18px !important;
}

body:not(.contentpane) .kilch-gallery .kg-photo-card{
  width: auto !important;
  max-width: none !important;
}

@media (max-width: 1200px){
  body:not(.contentpane) .kilch-gallery .kg-photo-grid,
  body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-photo-grid,
  body.com-kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-photo-grid{
    grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr)) !important;
  }
}
@media (max-width: 800px){
  body:not(.contentpane) .kilch-gallery .kg-photo-grid,
  body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-photo-grid,
  body.com-kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-photo-grid{
    grid-template-columns: repeat(min(2, var(--kg-photos-cols, 4)), minmax(0, 1fr)) !important;
  }
}
@media (max-width: 520px){
  body:not(.contentpane) .kilch-gallery .kg-photo-grid,
  body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-photo-grid,
  body.com-kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-photo-grid{
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Normal gallery page: make top tools bar match fullscreen styling */
body:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls--top{
  margin: 0 0 16px !important;
  padding: 12px 14px !important;
  border-radius: 12px !important;
}

/* Normal gallery page topbar */
body:not(.contentpane) .kilch-gallery .kg-page-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 5px 18px;
  border-radius: 12px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.08);
  margin: 0 0 14px;
}

body:not(.contentpane) .kilch-gallery .kg-page-topbar__title{
  font-size: 20px;
  font-weight: 700;
}

body:not(.contentpane) .kilch-gallery .kg-page-topbar__return{
  display:inline-flex;
  align-items:center;
  padding: 0px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.18);
  background: #fff;
  text-decoration: none;
  font-size: 0.95rem;
}

/* Normal page: remove the old/empty tools header block */
body:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls--top{
  display:none !important;
}

/* Topbar return button: override template hover/active colors */
body:not(.contentpane) .kilch-gallery .kg-page-topbar__return{
  color: #111 !important;
  background: #fff !important;
  border: 1px solid rgba(0,0,0,.18) !important;
  box-shadow: none !important;
  text-decoration: none !important;
}

body:not(.contentpane) .kilch-gallery .kg-page-topbar__return:hover,
body:not(.contentpane) .kilch-gallery .kg-page-topbar__return:focus{
  color: #111 !important;
  background: #f3f5f7 !important;  /* subtle grey like your other buttons */
  border-color: rgba(0,0,0,.28) !important;
  text-decoration: none !important;
  outline: none !important;
}

/* Tighten the tools bar height */
body:not(.contentpane) .kilch-gallery .kg-gallery-tools{
  margin-top: 10px !important;
}

body:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls{
  padding: 6px 10px !important;
  gap: 10px !important;
  min-height: 0 !important;
}

/* Make the buttons shorter */
body:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls .kg-fs-btn,
body:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls .kg-share{
  height: 32px !important;
  padding: 4px 10px !important;
  line-height: 22px !important;
}

/* Tighten the rating block */
body:not(.contentpane) .kilch-gallery .kg-ratingwrap-gallery{
  padding: 0 !important;
  margin: 0 !important;
}

body:not(.contentpane) .kilch-gallery .kg-ratingwrap-gallery .kg-star{
  padding: 0 4px !important;
  line-height: 1 !important;
}

/* Normal gallery page: tighten the entire tools row */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools{
  margin: 4px 0 6px !important;   /* was adding height */
  padding: 0 !important;          /* critical */
  min-height: 0 !important;
  line-height: 1 !important;
}

/* Tighten the controls container even more */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls{
  padding: 2px 8px !important;    /* smaller than 6px */
  margin: 0 !important;
  gap: 8px !important;            /* reduce spacing between items */
  min-height: 0 !important;
  line-height: 1 !important;
}

/* Ensure the buttons/icons don't force the row taller */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls .kg-fs-btn,
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls .kg-share{
  height: 28px !important;
  padding: 2px 10px !important;
  line-height: 24px !important;
}

/* Rating often forces height; tighten it */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-ratingwrap-gallery{
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
}
body.com_kilchgallery.view-gallery .kilch-gallery .kg-ratingavg{
  line-height: 1 !important;
}
body.com_kilchgallery.view-gallery .kilch-gallery .kg-star{
  padding: 0 3px !important;
  line-height: 1 !important;
}

body.com_kilchgallery.view-gallery .kilch-gallery .kg-page-topbar__return:hover,
body.com_kilchgallery.view-gallery .kilch-gallery .kg-page-topbar__return:focus{
  color: #111 !important;
  background: #f3f5f7 !important;
  border-color: rgba(0,0,0,.28) !important;
}

/* Hard shrink the tools row */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools{
  height: 36px !important;
  margin: 2px 0 2px !important;
  overflow: hidden; /* prevents tall children from forcing the row */
}

body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls{
  height: 36px !important;
  padding: 0 6px !important;
  align-items: center !important;
}

/* Buttons: slightly smaller */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls .kg-fs-btn,
body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls .kg-share{
  height: 28px !important;
  padding: 2px 8px !important;
}

/* Rating: this is usually what forces height */
body.com_kilchgallery.view-gallery .kilch-gallery .kg-ratingwrap-gallery{
  height: 36px !important;
  align-items: center !important;
}

body.com_kilchgallery.view-gallery .kilch-gallery .kg-ratingwrap-gallery .kg-star{
  font-size: 15px !important;
  line-height: 1 !important;
  padding: 0 2px !important;
}

body.com_kilchgallery.view-gallery .kilch-gallery .kg-ratingavg{
  font-size: 13px !important;
  line-height: 1 !important;
}


/* ==========================================================================
   KG OVERRIDES (keep all late-stage tweaks here)
   ========================================================================== */
   
/* Normal gallery page: don't force a 46px grid row in the header */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .gallery-header{
  grid-template-rows: auto !important;   /* simplest */
}

/* Normal gallery page: remove the framed tools container so it matches fullscreen look */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls{
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 8px 0 10px !important;
}

/* Make the tools row align nicely under the topbar */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-gallery-tools{
  margin: 6px 0 10px !important;
  padding: 0 !important;
}

/* Optional: keep items right-aligned like a toolbar */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls{
  justify-content: flex-end !important;
  gap: 10px !important;
}

/* Normal gallery page: kill any "boxed container" styling around the tools area */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-gallery-tools,
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-gallery-tools-controls,
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .gallery-header{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* Normal gallery page: reduce vertical gap between topbar and tools */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-page-topbar{
  margin-bottom: 6px !important;
}

body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .gallery-header{
  padding-top: 0 !important;
  margin-top: 0 !important;
  row-gap: 6px !important;   /* if it's grid, this controls spacing */
}

/* Description block often creates the big gap */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .gallery-description{
  margin: 6px 0 0 !important;
}

/* Column counts from ACP Front End Settings (--kg-photos-cols / --kg-galleries-cols) */
.kilch-gallery .kg-photo-grid{
  display: grid !important;
  gap: 16px !important;
  grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr)) !important;
  justify-content: stretch !important;
  justify-items: stretch !important;
}

.kilch-gallery .kg-photo-card{
  width: 100% !important;
  max-width: none !important;
}

@media (max-width: 1200px){
  .kilch-gallery .kg-photo-grid{
    grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr)) !important;
  }
}

@media (max-width: 800px){
  .kilch-gallery .kg-photo-grid{
    grid-template-columns: repeat(min(2, var(--kg-photos-cols, 4)), minmax(0, 1fr)) !important;
  }
}

@media (max-width: 520px){
  .kilch-gallery .kg-photo-grid{
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

#kg-overlay-modal .kilch-gallery .kg-photo-grid,
body:not(.kg-overlay-open) .kilch-gallery .kg-photo-grid {
  grid-template-columns: repeat(var(--kg-photos-cols, 4), minmax(0, 1fr)) !important;
}

@media (max-width: 800px){
  #kg-overlay-modal .kilch-gallery .kg-photo-grid,
  body:not(.kg-overlay-open) .kilch-gallery .kg-photo-grid {
    grid-template-columns: repeat(min(2, var(--kg-photos-cols, 4)), minmax(0, 1fr)) !important;
  }
}

@media (max-width: 520px){
  #kg-overlay-modal .kilch-gallery .kg-photo-grid,
  body:not(.kg-overlay-open) .kilch-gallery .kg-photo-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Phone hard cap: desktop column settings never apply at <=700px */
@media (max-width: 700px){
  .kilch-gallery .kg-photo-grid,
  #kg-overlay-modal .kilch-gallery .kg-photo-grid,
  body:not(.kg-overlay-open) .kilch-gallery .kg-photo-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
}

/* The tip/details can also add spacing even when closed */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-fs-tip{
  margin: 4px 0 0 !important;
}

/* Pull tools up */
body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-gallery-tools{
  margin: 2px 0 8px !important;
  padding: 0 !important;
}
/* ==========================================================================
   NORMAL GALLERY PAGE – FINAL LAYOUT OVERRIDES
   ========================================================================== */
   
   
   body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-gallery-header-row{
     display:flex;
     align-items:center;
     justify-content:space-between;
     gap:14px;
   }
   
   body.com_kilchgallery.view-gallery:not(.contentpane) .kilch-gallery .kg-return-link{
     display:inline-flex;
     align-items:center;
     padding: 6px 12px;
     border-radius: 999px;
     border: 1px solid rgba(0,0,0,.18);
     background:#fff;
     color:#111;
     text-decoration:none !important;
     font-weight:700;
     white-space:nowrap;
}



.kilch-gallery .kg-gallery-header-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}

.kilch-gallery .kg-return-link{
  display:inline-flex;
  align-items:center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.18);
  background:#fff;
  color:#111;
  text-decoration:none !important;
  font-weight:700;
  white-space:nowrap;
}

.kilch-gallery .kg-return-link:hover{
  background:#f5f5f5;
}

/* =========================================================
   Website Gallery page PHONE only (not overlay, not desktop)
   ========================================================= */
@media (max-width: 700px){
  html:has(body.com-kilchgallery.view-gallery),
  html:has(body.com_kilchgallery.view-gallery),
  body.com-kilchgallery.view-gallery,
  body.com_kilchgallery.view-gallery{
    overflow-x: hidden !important;
    max-width: 100% !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery,
  body.com_kilchgallery.view-gallery .kilch-gallery{
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .kg-page-topbar,
  body.com-kilchgallery.view-gallery .kilch-gallery .gallery-header,
  body.com-kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools,
  body.com-kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls,
  body.com-kilchgallery.view-gallery .kilch-gallery .kg-photo-section,
  body.com-kilchgallery.view-gallery .kilch-gallery .kg-photo-grid,
  body.com-kilchgallery.view-gallery .kilch-gallery .kg-photo-card,
  body.com-kilchgallery.view-gallery .kilch-gallery .kg-section-title,
  body.com-kilchgallery.view-gallery .kilch-gallery img,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-page-topbar,
  body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-photo-section,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-photo-grid,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-photo-card,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-section-title,
  body.com_kilchgallery.view-gallery .kilch-gallery img{
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Topbar: centered button, then centered title underneath */
  body.com-kilchgallery.view-gallery .kilch-gallery .kg-page-topbar,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-page-topbar{
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 8px 10px !important;
    text-align: center !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .kg-page-topbar__actions,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-page-topbar__actions{
    order: 1 !important;
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .kg-page-topbar__return,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-page-topbar__return{
    font-size: 0.95rem !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 8px 14px !important;
    height: auto !important;
    margin: 0 auto !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .kg-page-topbar__title,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-page-topbar__title{
    order: 2 !important;
    width: 100% !important;
    display: block !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    text-align: center !important;
  }

  /* Share + rating compact under the title */
  body.com-kilchgallery.view-gallery .kilch-gallery .gallery-header,
  body.com_kilchgallery.view-gallery .kilch-gallery .gallery-header{
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools,
  body.com-kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-gallery-tools-controls{
    order: 1;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    gap: 8px !important;
    line-height: 1 !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .gallery-description,
  body.com_kilchgallery.view-gallery .kilch-gallery .gallery-description{
    order: 2;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .kg-section-title,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-section-title{
    white-space: normal !important;
    overflow-wrap: anywhere;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .kg-photo-grid,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-photo-grid{
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100% !important;
  }

  body.com-kilchgallery.view-gallery .kilch-gallery .kg-photo-card img,
  body.com_kilchgallery.view-gallery .kilch-gallery .kg-photo-card img{
    aspect-ratio: 4 / 3;
    object-fit: cover;
    width: 100% !important;
  }
}

/* Work in Progress: centered divider + text control, default collapsed */
.kilch-gallery .kg-photo-section[data-section="wip"]{
  text-align: center;
  margin: 0;
}
.kilch-gallery .kg-wip-head,
.kilch-gallery .kg-wip-foot{
  padding: 18px 0;
}
.kilch-gallery .kg-wip-toggle{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  user-select: none;
}
.kilch-gallery .kg-wip-rule{
  flex: 1 1 0;
  height: 0;
  border: 0;
  border-top: 1px solid rgba(15, 23, 42, 0.22);
  min-width: 16px;
}
.kilch-gallery .kg-wip-foot .kg-wip-rule{
  display: block;
  width: 100%;
  flex: none;
}
.kilch-gallery .kg-wip-toggle__label{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
}
.kilch-gallery .kg-wip-toggle__text{
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  color: #334155;
  white-space: nowrap;
}
.kilch-gallery .kg-wip-chevron{
  flex: 0 0 auto;
  width: 0.42em;
  height: 0.42em;
  border-right: 2px solid #334155;
  border-bottom: 2px solid #334155;
  transform: rotate(45deg);
  margin-top: -0.15em;
}
.kilch-gallery .kg-photo-section[data-section="wip"]:not(.is-collapsed) .kg-wip-chevron,
.kilch-gallery .kg-photo-section[data-section="wip"].is-open .kg-wip-chevron{
  transform: rotate(-135deg);
  margin-top: 0.12em;
}
.kilch-gallery .kg-wip-hint{
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.3;
  color: #6b7280;
  text-align: center;
}
.kilch-gallery .kg-wip-hint--phone{ display: none; }
.kilch-gallery .kg-photo-section[data-section="wip"]:not(.is-collapsed) .kg-wip-hint,
.kilch-gallery .kg-photo-section[data-section="wip"].is-open .kg-wip-hint{
  display: none;
}
.kilch-gallery .kg-wip-foot{
  display: none;
}
.kilch-gallery .kg-photo-section[data-section="wip"]:not(.is-collapsed) .kg-wip-foot,
.kilch-gallery .kg-photo-section[data-section="wip"].is-open .kg-wip-foot{
  display: block;
}
.kilch-gallery .kg-photo-section[data-section="wip"] .kg-photo-grid{
  text-align: start;
}
.kilch-gallery .kg-photo-section[data-section="wip"].is-collapsed .kg-photo-grid,
.kilch-gallery .kg-photo-section[data-section="wip"].is-collapsed .kg-wip-foot{
  display: none !important;
}
@media (max-width: 700px){
  .kilch-gallery .kg-wip-hint--desktop{ display: none; }
  .kilch-gallery .kg-wip-hint--phone{ display: inline; }
}