.elk-gallery-manager,
.elk-gallery-grid,
.elk-gallery-lightbox,
.elk-gallery-manager * ,
.elk-gallery-grid * ,
.elk-gallery-lightbox * {
    box-sizing: border-box;
}

.elk-gallery-manager {
    display: grid;
    gap: 24px;
}

.elk-gallery-manager__panel {
    padding: 22px;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 14px;
    background: #fff;
}

.elk-gallery-manager__panel h2 {
    margin: 0 0 18px;
}

.elk-gallery-upload-form {
    display: grid;
    gap: 16px;
}

.elk-gallery-field {
    display: grid;
    gap: 7px;
}

.elk-gallery-field label {
    font-weight: 700;
}

.elk-gallery-field input[type="text"],
.elk-gallery-field input[type="file"],
.elk-gallery-field select {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid #cfcfcf;
    border-radius: 10px;
    background: #fff;
    font: inherit;
}

.elk-gallery-field small {
    opacity: .7;
}

.elk-gallery-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 16px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.elk-gallery-btn--primary {
    background: #1d4ed8;
    color: #fff;
}

.elk-gallery-btn--danger {
    background: #b91c1c;
    color: #fff;
}

.elk-gallery-status {
    min-height: 24px;
    font-weight: 600;
}

.elk-gallery-progress {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.elk-gallery-progress__bar {
    width: 0;
    height: 100%;
    background: #1d4ed8;
    transition: width .2s ease;
}

.elk-gallery-admin-category,
.elk-gallery-admin-album {
    margin: 0 0 12px;
    border: 1px solid rgba(0,0,0,.1);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.elk-gallery-admin-category > summary,
.elk-gallery-admin-album > summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 700;
}

.elk-gallery-admin-category__body,
.elk-gallery-admin-album__body {
    padding: 14px 16px 16px;
    border-top: 1px solid rgba(0,0,0,.08);
}

.elk-gallery-count {
    opacity: .65;
    font-size: .9em;
    font-weight: 500;
}

.elk-gallery-admin-actions {
    margin-bottom: 14px;
}

.elk-gallery-admin-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
}

.elk-gallery-admin-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 10px;
    background: #eee;
}

.elk-gallery-admin-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.elk-gallery-admin-image__delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: rgba(0,0,0,.8);
    color: #fff;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.elk-gallery-empty {
    margin: 0;
    opacity: .7;
}

.elk-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 360px);
    gap: 30px;
    justify-content: center;
}

.elk-gallery-tile {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 14px;
    background: #111;
    cursor: pointer;
    appearance: none;
}

.elk-gallery-tile__images {
    position: absolute;
    inset: 0;
    display: grid;
    gap: 2px;
    background: #111;
}

.elk-gallery-tile__images--1 { grid-template-columns: 1fr; }
.elk-gallery-tile__images--2 { grid-template-columns: 1fr 1fr; }
.elk-gallery-tile__images--3,
.elk-gallery-tile__images--4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.elk-gallery-tile__images--3 .elk-gallery-tile__image:first-child {
    grid-row: 1 / 3;
}

.elk-gallery-tile__image {
    overflow: hidden;
}

.elk-gallery-tile__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.elk-gallery-tile:hover .elk-gallery-tile__image img {
    transform: scale(1.03);
}

.elk-gallery-tile__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.28);
}

.elk-gallery-tile__title {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #fff;
    text-align: center;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    font-weight: 800;
    line-height: 1.2;
    text-shadow: 0 2px 10px rgba(0,0,0,.75);
    z-index: 2;
}

.elk-gallery-lightbox[hidden] { display: none !important; }

.elk-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.elk-gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.94);
}

.elk-gallery-lightbox__dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 54px 72px 42px;
}

.elk-gallery-lightbox__figure {
    margin: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.elk-gallery-lightbox__image {
    max-width: 100%;
    max-height: calc(100vh - 110px);
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.elk-gallery-lightbox__caption {
    color: #fff;
    text-align: center;
    min-height: 22px;
}

.elk-gallery-lightbox__close {
    position: fixed;
    top: 14px;
    right: 18px;
    z-index: 3;
    width: 54px;
    height: 54px;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 54px;
    font-weight: 700;
    line-height: .9;
}

.elk-gallery-lightbox__nav {
    position: fixed;
    top: 50%;
    z-index: 3;
    width: 58px;
    height: 72px;
    transform: translateY(-50%);
    border: 0;
    background: rgba(0,0,0,.32);
    color: #fff;
    font-size: 58px;
    cursor: pointer;
}

.elk-gallery-lightbox__nav--prev { left: 10px; }
.elk-gallery-lightbox__nav--next { right: 10px; }

body.elk-gallery-lightbox-open {
    overflow: hidden;
}

@media (max-width: 700px) {
    .elk-gallery-manager__panel {
        padding: 16px;
        border-radius: 10px;
    }

    .elk-gallery-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .elk-gallery-tile {
        aspect-ratio: 16 / 11;
    }

    .elk-gallery-lightbox__dialog {
        padding: 58px 12px 28px;
    }

    .elk-gallery-lightbox__nav {
        top: auto;
        bottom: 14px;
        transform: none;
        width: 58px;
        height: 58px;
        border-radius: 999px;
        font-size: 48px;
        background: rgba(0,0,0,.55);
    }

    .elk-gallery-lightbox__nav--prev { left: 18px; }
    .elk-gallery-lightbox__nav--next { right: 18px; }

    .elk-gallery-lightbox__close {
        top: 10px;
        right: 10px;
        width: 52px;
        height: 52px;
        font-size: 52px;
    }
}
