.tb-gallery .gallery-item img {
    box-shadow: none!important;
    margin-bottom: 0!important;
}
/* ----------------------------------------------------------------------------- Spacing */
.tb-gallery.spacing-none .gallery-item {
    padding: 0;
    margin: 0;
}
.tb-gallery.spacing-small .gallery-item {
    padding: 0.25rem;
}
.tb-gallery.spacing-medium .gallery-item {
    padding: 0.5rem;
}
.tb-gallery.spacing-large .gallery-item {
    padding: 1rem;
}

/* ----------------------------------------------------------------------------- caption */
.tb-gallery .gallery-item {
    position: relative;
    overflow: hidden;
}
/* Captions - below the image */
.tb-gallery .caption-below {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #444;
    text-align: center;
}

/* Captions - overlay on image */
.tb-gallery .caption-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.9rem;
    padding: 0.5rem;
    text-align: center;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.tb-gallery .gallery-item:hover .caption-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* Tooltip caption — handled by browser's native title attribute */
.tb-gallery .caption-tooltip {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 3px;
    cursor: help;
    white-space: nowrap;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
}

/* ----------------------------------------------------------------------------- Layout */

/* --------------------------------------------------------------------- Masonry */
.tb-gallery.layout-masonry {
    column-count: 1;
    column-gap: 0;
}
.tb-gallery.layout-masonry .gallery-item {
    break-inside: avoid;
}
@media (min-width: 480px) {
    .tb-gallery.layout-masonry.columns-2 { column-count: 2; }
    .tb-gallery.layout-masonry.columns-3 { column-count: 2; }
    .tb-gallery.layout-masonry.columns-4 { column-count: 2; }
    .tb-gallery.layout-masonry.columns-5 { column-count: 2; }
    .tb-gallery.layout-masonry.columns-6 { column-count: 2; }
}
@media (min-width: 640px) {
    .tb-gallery.layout-masonry.columns-3 { column-count: 3; }
    .tb-gallery.layout-masonry.columns-4 { column-count: 3; }
    .tb-gallery.layout-masonry.columns-5 { column-count: 3; }
    .tb-gallery.layout-masonry.columns-6 { column-count: 3; }
}
@media (min-width: 768px) {
    .tb-gallery.layout-masonry.columns-3 { column-count: 3; }
    .tb-gallery.layout-masonry.columns-4 { column-count: 4; }
    .tb-gallery.layout-masonry.columns-5 { column-count: 4; }
    .tb-gallery.layout-masonry.columns-6 { column-count: 4; }
}
@media (min-width: 1024px) {
    .tb-gallery.layout-masonry.columns-4 { column-count: 4; }
    .tb-gallery.layout-masonry.columns-5 { column-count: 5; }
    .tb-gallery.layout-masonry.columns-6 { column-count: 5; }
}
@media (min-width: 1280px) {
    .tb-gallery.layout-masonry.columns-5 { column-count: 5; }
    .tb-gallery.layout-masonry.columns-6 { column-count: 6; }
}

/* --------------------------------------------------------------------- Mosaic */
.tb-gallery.layout-mosaic {
    display: grid;
    gap: 0.5rem;
    grid-auto-flow: dense;
}

/* Columns and row heights */
.tb-gallery.layout-mosaic.columns-2 {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 320px;
}
.tb-gallery.layout-mosaic.columns-3 {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 280px;
}
.tb-gallery.layout-mosaic.columns-4 {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 240px;
}
.tb-gallery.layout-mosaic.columns-5 {
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: 200px;
}
.tb-gallery.layout-mosaic.columns-6 {
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 180px;
}

/* Gallery item and image base styles */
.tb-gallery.layout-mosaic .gallery-item {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Image wrapper to handle layout properly */
.tb-gallery.layout-mosaic .gallery-media {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}
.tb-gallery.layout-mosaic .gallery-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Captions - below the image */
.tb-gallery.layout-mosaic .caption-below {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #444;
    text-align: center;
}

/* Enhance early layout for interest */
.tb-gallery.layout-mosaic .gallery-item:nth-of-type(1) {
    grid-column: span 2;
    grid-row: span 2;
}
.tb-gallery.layout-mosaic .gallery-item:nth-of-type(2) {
    grid-row: span 2;
}
.tb-gallery.layout-mosaic .gallery-item:nth-of-type(3) {
    grid-column: span 2;
}
.tb-gallery.layout-mosaic .gallery-item:nth-of-type(5) {
    grid-row: span 2;
}

/* Mosaic layout rules at desktop */
@media (min-width: 768px) {
    /* Columns 2 */
    .tb-gallery.layout-mosaic.columns-2 .gallery-item:nth-of-type(3n) {
        grid-column: span 2;
    }
    .tb-gallery.layout-mosaic.columns-2 .gallery-item:nth-of-type(5n) {
        grid-row: span 2;
    }

    /* Columns 3 */
    .tb-gallery.layout-mosaic.columns-3 .gallery-item:nth-of-type(7n),
    .tb-gallery.layout-mosaic.columns-3 .gallery-item:nth-of-type(11n) {
        grid-column: span 2;
    }
    .tb-gallery.layout-mosaic.columns-3 .gallery-item:nth-of-type(5n) {
        grid-row: span 2;
    }

    /* Columns 4 */
    .tb-gallery.layout-mosaic.columns-4 .gallery-item:nth-of-type(8n),
    .tb-gallery.layout-mosaic.columns-4 .gallery-item:nth-of-type(13n) {
        grid-column: span 2;
    }
    .tb-gallery.layout-mosaic.columns-4 .gallery-item:nth-of-type(6n) {
        grid-row: span 2;
    }

    /* Columns 5 */
    .tb-gallery.layout-mosaic.columns-5 .gallery-item:nth-of-type(7n),
    .tb-gallery.layout-mosaic.columns-5 .gallery-item:nth-of-type(11n),
    .tb-gallery.layout-mosaic.columns-5 .gallery-item:nth-of-type(14n) {
        grid-row: span 2;
    }
    .tb-gallery.layout-mosaic.columns-5 .gallery-item:nth-of-type(9n),
    .tb-gallery.layout-mosaic.columns-5 .gallery-item:nth-of-type(13n) {
        grid-column: span 2;
    }

    /* Columns 6 */
    .tb-gallery.layout-mosaic.columns-6 .gallery-item:nth-of-type(5n),
    .tb-gallery.layout-mosaic.columns-6 .gallery-item:nth-of-type(10n),
    .tb-gallery.layout-mosaic.columns-6 .gallery-item:nth-of-type(14n) {
        grid-row: span 2;
    }
    .tb-gallery.layout-mosaic.columns-6 .gallery-item:nth-of-type(7n),
    .tb-gallery.layout-mosaic.columns-6 .gallery-item:nth-of-type(12n) {
        grid-column: span 2;
    }
}

/* Mobile fallback: single column */
@media (max-width: 640px) {
    .tb-gallery.layout-mosaic {
        grid-template-columns: 1fr !important;
        grid-auto-rows: auto !important;
    }
    .tb-gallery.layout-mosaic .gallery-item {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }
}

/* --------------------------------------------------------------------- grid */
.tb-gallery.layout-grid {
    --gap: 0.25em;
    display: grid;
    gap: var(--gap);
    align-items: stretch;
    list-style: none;
}

/* Define column overrides */
.tb-gallery.layout-grid.columns-2 { --numcolumns: 2; }
.tb-gallery.layout-grid.columns-3 { --numcolumns: 3; }
.tb-gallery.layout-grid.columns-4 { --numcolumns: 4; }
.tb-gallery.layout-grid.columns-5 { --numcolumns: 5; }
.tb-gallery.layout-grid.columns-6 { --numcolumns: 6; }

/* Use --numcolumns to define grid layout */
.tb-gallery.layout-grid.columns-2,
.tb-gallery.layout-grid.columns-3,
.tb-gallery.layout-grid.columns-4,
.tb-gallery.layout-grid.columns-5,
.tb-gallery.layout-grid.columns-6 {
    --size: calc(100vw / var(--numcolumns));
    grid-template-columns: repeat(var(--numcolumns), 1fr);
}

/* Make each gallery-item flexible for caption support */
.tb-gallery.layout-grid .gallery-item {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: hidden;
}

/* Separate media container to constrain image height */
.tb-gallery.layout-grid .gallery-media {
    /* height: calc(var(--size) - var(--gap)); */
    /* aspect-ratio: 3 / 2; */
    /* height: calc((var(--size) - var(--gap)) * 0.66); */
    aspect-ratio: 3 / 3;
    overflow: hidden;
    flex-shrink: 0;
}
.tb-gallery.layout-grid .gallery-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Caption below image */
.tb-gallery.layout-grid .caption-below {
    margin-top: 0.4em;
    font-size: 0.9rem;
    text-align: center;
    color: #444;
}

/* --------------------------------------------------------------------- Blog */
.tb-gallery.layout-blog .gallery-item {
    display: flex;
    flex-direction: column;
    margin-bottom: 2rem;
}
.tb-gallery.layout-blog .caption {
    margin-top: 0.5rem;
    font-size: 0.95rem;
    color: #555;
}

/* --------------------------------------------------------------------- Browser */
.tb-gallery.layout-browser {
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    background-color: #f9f9f9;
}
.tb-gallery.layout-browser .gallery-browser-track {
    display: flex;
    transition: transform 0.4s ease-in-out;
    will-change: transform;
}
.tb-gallery.layout-browser .gallery-item {
    min-width: 100%;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}
.tb-gallery.layout-browser .gallery-item img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

/* Navigation buttons */
.tb-gallery.layout-browser button.gallery-prev,
.tb-gallery.layout-browser button.gallery-next,
.tb-gallery.layout-browser button.gallery-prev:focus,
.tb-gallery.layout-browser button.gallery-next:focus {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(215, 215, 215, 0.4)!important;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    user-select: none;
    z-index: 10;
    width: 3rem;
    height: 3rem;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.2rem; /* Fixed size for the icon */
    transition: background-color 0.3s ease, outline 0.3s ease, transform 0.2s ease;
    outline: 2px solid rgba(215, 215, 215, 0);
}
.tb-gallery.layout-browser button.gallery-prev {
    left: 0.75rem;
    background-image: url("data:image/svg+xml,%3csvg fill='757575d6' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath d='M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z'/%3e%3c/svg%3e")!important;
}
.tb-gallery.layout-browser button.gallery-next {
    right: 0.75rem;
    background-image: url("data:image/svg+xml,%3csvg fill='757575d6' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath d='M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6z'/%3e%3c/svg%3e")!important;
}
.tb-gallery.layout-browser button.gallery-prev:active,
.tb-gallery.layout-browser button.gallery-next:active,
.tb-gallery.layout-browser button.gallery-prev:hover,
.tb-gallery.layout-browser button.gallery-next:hover {
    background-color: rgba(215, 215, 215, 0.6);
    outline: 2px solid rgba(215, 215, 215, 0.6);
    outline-offset: 2px;
}
.tb-gallery.layout-browser .caption-below {
    text-align: left;
    max-width: 80%;
    width: 600px;
    padding: 10px 60px 10px 30px;
    margin: 0.5rem auto 0.25rem;
    font-size: 0.95rem;
    color: #444;
    line-height: 1.6;
}

@media (min-width: 900px) {
  .tb-gallery.layout-browser .gallery-item {
    display: flex;
  }
}
@media (max-width: 900px) {
  .tb-gallery.layout-browser .caption-below {
    width: 100%;
    max-width: 100%;
    padding: 0.75rem 1rem;
    margin: 0.5rem auto 0;
    font-size: 0.85rem;
    text-align: center;
    box-sizing: border-box;
    text-align: center;
  }
}
@media (max-width: 768px) {
  .tb-gallery.layout-browser {
    overflow-x: hidden;
    padding: 0 1rem; /* Optional: Adds horizontal breathing room */
  }

  .tb-gallery.layout-browser .gallery-browser-track {
    flex-wrap: nowrap;
  }

  .tb-gallery.layout-browser .gallery-item {
    min-width: 100%;
    box-sizing: border-box;
    padding: 0.25em;
    overflow: hidden;
  }

  .tb-gallery.layout-browser .gallery-item img {
    max-width: 100%;
    max-height: 50vh;
    height: auto;
    object-fit: contain;
  }

  .tb-gallery.layout-browser .caption-below {
    width: 100%;
    max-width: 100%;
    padding: 8px 1rem;
    font-size: 0.85rem;
    box-sizing: border-box;
  }

  .tb-gallery.layout-browser button.gallery-prev,
  .tb-gallery.layout-browser button.gallery-next {
    width: 2.5rem;
    height: 2.5rem;
    background-size: 1rem;
    top: 45%;
    transform: translateY(-50%);
  }

  .tb-gallery.layout-browser button.gallery-prev {
    left: 0.5rem;
  }

  .tb-gallery.layout-browser button.gallery-next {
    right: 0.5rem;
  }
}
@media (max-width: 480px) {
  .tb-gallery.layout-browser .gallery-item img {
    max-height: 40vh;
  }

  .tb-gallery.layout-browser .caption-below {
    font-size: 0.8rem;
    padding: 6px 0.75rem;
  }

  .tb-gallery.layout-browser button.gallery-prev,
  .tb-gallery.layout-browser button.gallery-next {
    width: 2rem;
    height: 2rem;
    background-size: 0.9rem;
  }
}

/* --------------------------------------------------------------------- Slider and carousel */
.tb-gallery.layout-slideshow {
  position: relative;
}
.swiper {
    overflow: hidden;
    padding-bottom: 40px;
    box-sizing: border-box;
}
/* Reset flex for carousel and slideshow */
.tb-gallery.layout-carousel .gallery-item,
.tb-gallery.layout-slideshow .gallery-item {
    display: block!important;
    text-align: center;
}
.tb-gallery.layout-slideshow .gallery-item {
    margin: auto;
}
.tb-gallery.layout-carousel .swiper-slide,
.tb-gallery.layout-slideshow .swiper-slide {
  display: flex;
  justify-content: center;
  align-items: center;
}
.tb-gallery.layout-carousel .swiper-slide img,
.tb-gallery.layout-slideshow .swiper-slide img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}
.tb-gallery.layout-carousel .gallery-media,
.tb-gallery.layout-slideshow .gallery-media {
  display: inline-block;
  text-align: center;
}

/* Slideshow nav buttons */
.tb-gallery.layout-slideshow .swiper-button-prev,
.tb-gallery.layout-slideshow .swiper-button-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(215, 215, 215, 0.4) !important;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    user-select: none;
    z-index: 10;
    width: 3rem;
    height: 3rem;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.2rem;
    transition: background-color 0.3s ease, outline 0.3s ease, transform 0.2s ease;
    outline: 2px solid rgba(215, 215, 215, 0);
}
/* LEFT arrow (Prev) */
.tb-gallery.layout-slideshow .swiper-button-prev {
    left: 0.75rem;
    background-image: url("data:image/svg+xml,%3csvg fill='757575d6' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath d='M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z'/%3e%3c/svg%3e") !important;
}
/* RIGHT arrow (Next) */
.tb-gallery.layout-slideshow .swiper-button-next {
    right: 0.75rem;
    background-image: url("data:image/svg+xml,%3csvg fill='757575d6' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath d='M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6z'/%3e%3c/svg%3e") !important;
}
.tb-gallery.layout-slideshow .swiper-button-prev:hover,
.tb-gallery.layout-slideshow .swiper-button-next:hover,
.tb-gallery.layout-slideshow .swiper-button-prev:active,
.tb-gallery.layout-slideshow .swiper-button-next:active {
    background-color: rgba(215, 215, 215, 0.6);
    outline: 2px solid rgba(215, 215, 215, 0.6);
    outline-offset: 2px;
}

.tb-gallery.layout-carousel .swiper {
    padding-top: 45px;
}

.swiper-horizontal>.swiper-pagination-progressbar,
.swiper-pagination-progressbar.swiper-pagination-horizontal,
.swiper-pagination-progressbar.swiper-pagination-vertical.swiper-pagination-progressbar-opposite,
.swiper-vertical>.swiper-pagination-progressbar.swiper-pagination-progressbar-opposite {
    top: 22px;
    left: 70px;
    right: 70px;
    width: auto;
}


/* Slideshow nav buttons */
.tb-gallery.layout-carousel .swiper-button-prev,
.tb-gallery.layout-carousel .swiper-button-next {
    position: absolute;
    top: 45px;
    transform: translateY(-50%);
    background-color: rgba(215, 215, 215, 0.4) !important;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    user-select: none;
    z-index: 10;
    width: 30px;
    height: 30px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.2rem;
    transition: background-color 0.3s ease, outline 0.3s ease, transform 0.2s ease;
    outline: 2px solid rgba(215, 215, 215, 0);
}
/* LEFT arrow (Prev) */
.tb-gallery.layout-carousel .swiper-button-prev {
    left: 0.75rem;
    background-image: url("data:image/svg+xml,%3csvg fill='757575d6' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath d='M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z'/%3e%3c/svg%3e") !important;
}
/* RIGHT arrow (Next) */
.tb-gallery.layout-carousel .swiper-button-next {
    right: 0.75rem;
    background-image: url("data:image/svg+xml,%3csvg fill='757575d6' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath d='M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6z'/%3e%3c/svg%3e") !important;
}
.tb-gallery.layout-carousel .swiper-button-prev:hover,
.tb-gallery.layout-carousel .swiper-button-next:hover,
.tb-gallery.layout-carousel .swiper-button-prev:active,
.tb-gallery.layout-carousel .swiper-button-next:active {
    background-color: rgba(215, 215, 215, 0.6);
    outline: 2px solid rgba(215, 215, 215, 0.6);
    outline-offset: 2px;
}

.swiper-pagination-progressbar {
  background: #e9e9e940;
}
.swiper-pagination-progressbar .swiper-pagination-progressbar-fill {
  background: #d9d9d9;
}
.swiper-button-next::after,
.swiper-button-prev::after {
  display: none;
}

/* Pagination */
.tb-gallery.layout-slideshow .swiper-pagination {
    bottom: 20px!important;
}
.tb-gallery .swiper-pagination-bullet {
    width: 0.75rem;
    height: 0.75rem;
    background-color: rgba(120, 120, 120, 0.3);
    border-radius: 50%;
    transition: all 0.3s ease;
    cursor: pointer;
    outline: 2px solid rgba(215, 215, 215, 0);
    outline-offset: 2px;
    opacity: 0.6;
}
.tb-gallery .swiper-pagination-bullet-main {
    background-color: rgba(50, 50, 50, 0.9);
    outline: 2px solid rgba(215, 215, 215, 0.8);
    opacity: 1;
    transform: scale(1.1);
}
.tb-gallery .swiper-pagination-bullet-active {
    background-color: rgba(50, 50, 50, 0.9);
    opacity: 1;
}

/* progress */
.tb-gallery .autoplay-progress {
    position: absolute;
    right: 1rem;
    top: 1rem;
    bottom: auto;
    width: 48px;
    height: 48px;
    z-index: 10;
    color: #555;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tb-gallery .autoplay-progress svg {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.tb-gallery .autoplay-progress circle {
    fill: none;
    stroke: rgba(0, 0, 0, 0.3);
    stroke-width: 4;
    stroke-dasharray: 126;
    stroke-dashoffset: calc(126 * var(--progress, 1));
    transition: stroke-dashoffset 0.25s linear;
}
