.custom-divi-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
    width: 100%;
    margin: 0 auto 32px auto;
    padding: 0;
}

.custom-gallery-item {
    position: relative;
    background: #fff;
    overflow: hidden;
    /* Cień tylko od dołu */
    box-shadow: 0 22px 38px -18px rgba(40,40,40,0.22);
    transition: box-shadow 0.34s cubic-bezier(.33,1,.68,1), transform 0.17s cubic-bezier(.33,1,.68,1);
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    border-radius: 0;
    z-index: 1;
    min-width: 0;
}
.custom-gallery-item:hover,
.custom-gallery-item:focus-within {
    box-shadow: 0 28px 54px -10px rgba(34,34,34,0.25);
    transform: scale(1.015) translateY(-3px);
    z-index: 5;
}

.custom-gallery-item img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    object-position: center;
    display: block;
    background: #eee;
}

.caption-bg {
    /* Gradient do ciemności, z lekkością */
    background: linear-gradient(0deg, rgba(30,30,30,0.94) 92%, rgba(44,44,44,0.65) 100%);
    color: #fff;
    padding: 18px 18px 12px 18px;
    text-align: left;
    font-family: 'Roboto', Helvetica, Arial, Lucida, sans-serif;
    width: 100%;
    margin-top: auto;
    box-sizing: border-box;
    min-height: 64px;
    position: relative;
    z-index: 2;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.caption-bg span {
    font-size: 1.09rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.36;
    color: #fff;
    display: block;
    margin-bottom: 12px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.14);
}

.custom-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 0;
}

.custom-buttons a {
    background: #044890;
    color: #fff !important;
    font-size: 0.98em;
    padding: 7px 18px;
    border: 2px solid #fff !important;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(34,34,34,0.09);
    transition: background 0.16s, color 0.16s, border-color 0.18s, box-shadow 0.14s, transform 0.13s;
    cursor: pointer;
    line-height: 1.2;
    letter-spacing: 0.01em;
    outline: none;
    display: inline-block;
}

.custom-buttons a:hover,
.custom-buttons a:focus {
    background: #fff !important;
    color: #044890 !important;
    border-color: #044890 !important;
    box-shadow: 0 4px 16px 0 rgba(4,72,144,0.14);
    transform: translateY(-1px) scale(1.06);
}

.custom-buttons a:active {
    background: #044890 !important;
    color: #fff !important;
    border-color: #fff !important;
}

@media (max-width: 1350px) {
    .custom-divi-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
    .custom-gallery-item img {
        height: 180px;
    }
}

@media (max-width: 900px) {
    .custom-divi-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    .custom-gallery-item img {
        height: 140px;
    }
    .caption-bg {
        padding: 10px 8px 8px 10px;
        min-height: 46px;
        font-size: 1em;
    }
    .caption-bg span {
        font-size: 1em;
        margin-bottom: 7px;
    }
}

@media (max-width: 600px) {
    .custom-divi-gallery {
        grid-template-columns: 1fr;
        gap: 8px;
        width: 100vw;
        padding-left: 0;
        padding-right: 0;
    }
    .custom-gallery-item {
        width: 98vw;
        max-width: 99vw;
        margin-left: auto;
        margin-right: auto;
        min-width: 0;
    }
    .custom-gallery-item img {
        height: 95px;
    }
    .caption-bg {
        padding: 7px 6px 5px 8px;
        min-height: 22px;
        font-size: 0.95em;
    }
    .caption-bg span {
        font-size: 0.97em;
        margin-bottom: 4px;
    }
    .custom-buttons {
        gap: 5px;
    }
    .custom-buttons a {
        font-size: 0.83em;
        padding: 3px 7px;
        border-width: 1.2px !important;
        border-radius: 4px;
    }
}
