* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
    background: #f4f6f8;
    color: #17202a
}

.topbar {
    height: 68px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5%;
    position: sticky;
    top: 0;
    z-index: 5
}

.brand {
    font-size: 20px;
    font-weight: 800
}

.topbar nav {
    display: flex;
    gap: 8px
}

.container {
    width: min(1200px, 92%);
    margin: 34px auto
}

.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .04)
}

.small {
    width: min(430px, 92%)
}

.center-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #f4f6f8
}

.center {
    text-align: center
}

.access-card {
    max-width: 460px;
    margin: 10vh auto
}

.page-head,
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px
}

h1 {
    margin: 0 0 8px;
    font-size: 30px
}

h2 {
    margin: 0 0 20px
}

label {
    display: block;
    font-weight: 700;
    margin: 15px 0 7px
}

input[type=text],
input[type=password],
input[type=file] {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #ccd2d8;
    border-radius: 10px;
    font: inherit;
    background: #fff
}

input:focus {
    outline: 2px solid #c9d7ff;
    border-color: #7c9cff
}

.btn,
.danger {
    border: 0;
    border-radius: 10px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-block
}

.btn {
    background: #111827;
    color: #fff
}

.btn.ghost {
    background: #eef1f4;
    color: #17202a
}

.danger {
    background: #fee2e2;
    color: #991b1b
}

.muted {
    color: #6b7280
}

.notice,
.success,
.error {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 18px
}

.notice {
    background: #fff7ed;
    color: #9a3412
}

.success {
    background: #ecfdf5;
    color: #065f46
}

.error {
    background: #fef2f2;
    color: #991b1b
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px
}

.photo {
    margin: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden
}

.photo a {
    display: block
}

.photo img {
    display: block;
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    transition: transform .2s
}

.photo:hover img {
    transform: scale(1.02)
}

figcaption {
    padding: 11px 13px;
    font-weight: 600
}

.empty {
    text-align: center;
    padding: 50px
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px
}

.admin-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px
}

.admin-photo {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background: #fff
}

.admin-photo img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    display: block
}

.photo-info {
    padding: 12px
}

.photo-info strong,
.photo-info small {
    display: block;
    margin-bottom: 6px
}

.photo-info small {
    color: #6b7280
}

.photo-info form {
    margin-top: 10px
}

hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 25px 0
}

code {
    background: #f1f5f9;
    padding: 2px 5px;
    border-radius: 5px
}

@media(max-width:700px) {
    .admin-grid {
        grid-template-columns: 1fr
    }

    .gallery {
        grid-template-columns: repeat(2, 1fr)
    }

    .container {
        margin: 22px auto
    }

    .card {
        padding: 20px
    }

    .topbar {
        padding: 0 4%
    }

    h1 {
        font-size: 25px
    }
}

/* Image preview lightbox */
.photo-open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    overflow: hidden
}

.photo-open img {
    display: block;
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    transition: transform .2s
}

.photo-open:hover img {
    transform: scale(1.02)
}

body.lightbox-open {
    overflow: hidden
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px
}

.lightbox.open {
    display: flex
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .9);
    backdrop-filter: blur(4px)
}

.lightbox-dialog {
    position: relative;
    z-index: 2;
    width: min(1200px, 100%);
    height: min(92vh, 900px);
    display: flex;
    align-items: center;
    justify-content: center
}

.lightbox-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 4;
    padding: 8px 0
}

.lightbox-title {
    color: #fff;
    font-weight: 700;
    max-width: 65%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.lightbox-actions {
    display: flex;
    gap: 8px
}

.lightbox-btn {
    border: 0;
    border-radius: 9px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, .28)
}

.lightbox-image-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 65px 60px 45px
}

.lightbox-image-wrap img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    user-select: none
}

.lightbox-nav {
    position: absolute;
    z-index: 5;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 70px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 52px;
    cursor: pointer
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, .28)
}

.lightbox-nav.prev {
    left: 0
}

.lightbox-nav.next {
    right: 0
}

.lightbox-counter {
    position: absolute;
    bottom: 7px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, .4);
    padding: 6px 11px;
    border-radius: 20px
}

@media(max-width:700px) {
    .lightbox {
        padding: 8px
    }

    .lightbox-dialog {
        height: 96vh
    }

    .lightbox-title {
        max-width: 45%;
        font-size: 13px
    }

    .lightbox-btn {
        padding: 9px 10px;
        font-size: 13px
    }

    .lightbox-image-wrap {
        padding: 58px 8px 42px
    }

    .lightbox-nav {
        width: 42px;
        height: 58px;
        font-size: 42px
    }

    .lightbox-nav.prev {
        left: 3px
    }

    .lightbox-nav.next {
        right: 3px
    }
}