.gallery-body {
    min-height: 100vh;
}

.gallery-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--line);
    background: rgba(4, 5, 10, .78);
    backdrop-filter: blur(18px);
}

.gallery-topbar nav {
    display: flex;
    gap: .75rem;
}

.gallery-topbar nav a {
    color: var(--muted);
    font-weight: 850;
}

.gallery-topbar nav a:hover {
    color: var(--cyan);
}

.gallery-shell {
    width: min(1500px, calc(100% - 1rem));
    margin: 0 auto;
    padding: 1rem 0 7.8rem;
}

.gallery-card,
.photo-card,
.gallery-flash {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(17, 23, 36, .76), rgba(7, 10, 18, .78));
    box-shadow: 0 22px 60px rgba(0, 0, 0, .22);
    backdrop-filter: blur(18px);
}

.gallery-flash {
    margin: 1rem 0;
    padding: .85rem 1rem;
    border-radius: 16px;
    color: var(--text);
}

.gallery-flash-success {
    border-color: rgba(55, 214, 223, .34);
}

.gallery-flash-error {
    border-color: rgba(248, 113, 113, .4);
}

.gallery-login {
    min-height: calc(100vh - 7rem);
    display: grid;
    align-items: center;
    gap: 1.2rem;
    padding: 2rem 0;
}

.gallery-login-copy {
    display: grid;
    gap: 1rem;
}

.gallery-login-copy h1,
.gallery-hero h1 {
    margin: 0;
    font-size: clamp(2.4rem, 10vw, 5.5rem);
    line-height: .96;
    letter-spacing: 0;
}

.photo-panel h1 {
    margin: 0;
    max-width: 100%;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.gallery-login-copy p,
.gallery-hero p,
.gallery-muted {
    margin: 0;
    color: var(--muted);
}

.gallery-login-form {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border-radius: 24px;
}

.gallery-login-form label,
.gallery-toolbar label,
.comment-form label {
    display: grid;
    gap: .45rem;
    color: var(--text);
    font-weight: 850;
}

.gallery-login-form input,
.gallery-toolbar select,
.comment-form input,
.comment-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: rgba(3, 6, 12, .74);
    padding: .84rem .95rem;
}

.gallery-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: .8rem 1rem;
    border: 1px solid transparent;
    border-radius: 15px;
    color: var(--text);
    font-weight: 900;
    cursor: pointer;
    text-align: center;
    white-space: normal;
}

.gallery-btn-primary {
    background: var(--gradient);
    box-shadow: 0 16px 34px rgba(139, 92, 246, .22);
}

.gallery-btn-secondary {
    background: rgba(255, 255, 255, .055);
    border-color: var(--line);
}

.gallery-hero {
    display: grid;
    gap: 1rem;
    padding: 1.5rem 0;
}

.gallery-hero-actions {
    display: grid;
    gap: .7rem;
}

.gallery-toolbar {
    display: grid;
    gap: .85rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 22px;
}

.gallery-toolbar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.gallery-toolbar-head strong {
    font-size: 1.08rem;
}

.gallery-filter-apply {
    width: 100%;
}

.gallery-toolbar input,
.gallery-toolbar select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: rgba(3, 6, 12, .74);
    padding: .84rem .95rem;
}

.gallery-page-head {
    display: grid;
    gap: .9rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: .9rem;
    border-radius: 22px;
}

.gallery-page-title {
    display: grid;
    gap: .15rem;
}

.gallery-page-title span {
    color: var(--muted);
}

.gallery-page-actions {
    display: grid;
    gap: .65rem;
}

.gallery-overview {
    display: grid;
    gap: 1rem;
    padding: 1.5rem 0;
}

.gallery-overview h1 {
    margin: 0;
    font-size: clamp(2.25rem, 8vw, 5rem);
    line-height: .96;
}

.gallery-overview p {
    max-width: 48rem;
    color: var(--muted);
}

.gallery-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .7rem;
}

.gallery-metrics article {
    padding: .9rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .045);
}

.gallery-metrics strong {
    display: block;
    font-size: clamp(1.6rem, 6vw, 2.5rem);
    line-height: 1;
}

.gallery-metrics span {
    color: var(--muted);
    font-size: .88rem;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}

.photo-card {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
}

.photo-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    border: 0;
    overflow: hidden;
    padding: 0;
    background: #02030a;
    cursor: zoom-in;
}

.photo-thumb img,
.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.photo-card:hover .photo-thumb img {
    transform: scale(1.05);
}

.photo-card-tools {
    position: absolute;
    inset: .75rem .75rem auto .75rem;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
}

.icon-button,
.icon-check span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    width: 2.35rem;
    height: 2.35rem;
    border: 1px solid var(--line);
    border-radius: 999px; 
    color: var(--text);
    background: rgba(4, 5, 10, .62);
    backdrop-filter: blur(12px);
    cursor: pointer;
    font-weight: 900;
}

.gallery-mobile-bar {
    position: fixed;
    left: .7rem;
    right: .7rem;
    bottom: max(.7rem, env(safe-area-inset-bottom));
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .45rem;
    padding: .55rem;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(16, 22, 35, .92), rgba(5, 8, 15, .92));
    box-shadow: 0 18px 50px rgba(0, 0, 0, .5), 0 0 34px rgba(55, 214, 223, .12);
    backdrop-filter: blur(18px);
}

.gallery-mobile-bar button {
    min-width: 0;
    min-height: 3.65rem;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 16px;
    color: var(--text);
    background: rgba(255, 255, 255, .055);
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.gallery-mobile-bar span,
.gallery-mobile-bar strong {
    display: block;
    line-height: 1.1;
}

.gallery-mobile-bar span {
    font-size: .8rem;
    color: var(--muted);
}

.gallery-mobile-bar strong {
    margin-top: .25rem;
    font-size: 1rem;
}

.gallery-mobile-bar .is-primary {
    border-color: transparent;
    background: var(--gradient);
    box-shadow: 0 10px 24px rgba(139, 92, 246, .25);
}

.gallery-mobile-bar .is-disabled {
    opacity: .55;
    cursor: not-allowed;
}

.gallery-filter-scrim {
    position: fixed;
    inset: 0;
    z-index: 84;
    background: rgba(1, 2, 6, .6);
    backdrop-filter: blur(8px);
}

.gallery-filter-scrim[hidden] {
    display: none;
}

.icon-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.icon-check input:checked + span,
.favorite-button.is-active {
    color: #ffd3ea;
    border-color: rgba(236, 72, 153, .45);
    background: rgba(236, 72, 153, .18);
}

.photo-card-content {
    padding: 1rem;
}

.photo-card-content p {
    margin: 0 0 .25rem;
    color: var(--cyan);
    font-size: .8rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.photo-card-content h2 {
    margin: 0;
    font-size: 1.12rem;
}

.photo-card-content span {
    display: block;
    margin-top: .25rem;
    color: var(--dim);
    font-size: .82rem;
}

.photo-detail {
    display: grid;
    gap: 1rem;
    padding: 1rem 0;
    align-items: start;
}

.photo-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 26px;
    min-width: 0;
    min-height: 18rem;
    background:
        radial-gradient(circle at 50% 0%, rgba(55, 214, 223, .08), transparent 22rem),
        #02030a;
}

.photo-main-image,
.photo-stage > img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 18rem;
    object-fit: contain;
}

.photo-open-button {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 2;
    display: inline-flex;
    width: auto;
    appearance: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    background: rgba(4, 5, 10, .68);
    cursor: zoom-in;
    padding: .55rem .75rem;
    font-size: .85rem;
    font-weight: 850;
    line-height: 1.2;
    opacity: .9;
    transition: opacity .18s ease, transform .18s ease;
    backdrop-filter: blur(12px);
}

.photo-open-button:hover,
.photo-open-button:focus-visible {
    opacity: 1;
    transform: translateY(-2px);
}

.photo-panel {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border-radius: 24px;
    min-width: 0;
    overflow: hidden;
}

.gallery-back-link {
    color: var(--cyan);
    font-weight: 850;
}

.photo-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .7rem;
    min-width: 0;
}

.comment-form {
    display: grid;
    gap: .85rem;
    min-width: 0;
}

.star-input {
    display: inline-flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: .25rem;
}

.star-input input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.star-input label {
    color: var(--dim);
    cursor: pointer;
    font-size: 1.6rem;
}

.star-input input:checked ~ label,
.star-input label:hover,
.star-input label:hover ~ label {
    color: var(--gold);
}

.gallery-check {
    grid-template-columns: auto 1fr;
    align-items: center;
}

.gallery-check input {
    width: auto;
}

.comment-list {
    display: grid;
    gap: .75rem;
    min-width: 0;
}

.comment-list h2 {
    margin: 0;
    font-size: 1.15rem;
}

.comment-list article {
    padding: .85rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .04);
}

.comment-list p {
    margin: .35rem 0 0;
    color: var(--muted);
}

.lightbox-comments {
    display: grid;
    gap: .55rem;
}

.lightbox-comments article {
    padding: .7rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, .04);
}

.lightbox-comments p {
    margin: .25rem 0 0;
    color: var(--muted);
}

@media (min-width: 680px) {
    .gallery-shell {
        width: min(1320px, calc(100% - 2rem));
        padding-bottom: 3rem;
    }

    .gallery-login {
        grid-template-columns: minmax(0, 1fr) minmax(22rem, .68fr);
    }

    .gallery-login-form {
        padding: 1.25rem;
    }

    .gallery-hero {
        grid-template-columns: 1fr auto;
        align-items: end;
    }

    .gallery-hero-actions {
        grid-template-columns: max-content max-content;
    }

    .gallery-page-head {
        grid-template-columns: auto 1fr auto;
    }

    .gallery-page-actions {
        grid-template-columns: max-content max-content;
    }

    .gallery-overview {
        grid-template-columns: 1fr minmax(18rem, .5fr);
        align-items: end;
    }

    .gallery-metrics {
        grid-template-columns: repeat(4, 1fr);
    }

    .gallery-toolbar {
        grid-template-columns: 1fr minmax(12rem, 16rem) minmax(12rem, 16rem);
        align-items: end;
    }

    .gallery-toolbar-head,
    .gallery-filter-apply,
    .gallery-mobile-bar,
    .gallery-filter-scrim {
        display: none;
    }

    .gallery-toolbar span {
        justify-self: end;
    }

    .photo-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 679px) {
    .gallery-topbar nav {
        gap: .5rem;
        font-size: .86rem;
    }

    .gallery-page-actions {
        display: none;
    }

    .gallery-overview {
        padding-top: .9rem;
    }

    .gallery-metrics {
        gap: .5rem;
    }

    .gallery-metrics article {
        padding: .75rem .65rem;
    }

    .gallery-toolbar {
        position: fixed;
        left: .7rem;
        right: .7rem;
        bottom: calc(5.7rem + env(safe-area-inset-bottom));
        z-index: 90;
        margin: 0;
        border-radius: 24px;
        transform: translateY(calc(100% + 7rem));
        opacity: 0;
        pointer-events: none;
        transition: transform .24s ease, opacity .2s ease;
    }

    .gallery-toolbar.is-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .gallery-toolbar input,
    .gallery-toolbar select,
    .gallery-btn {
        min-height: 3.15rem;
        font-size: 1rem;
    }

    .photo-card {
        border-radius: 18px;
    }

    .photo-thumb {
        aspect-ratio: 1 / 1.06;
    }

    .photo-card-tools {
        inset: .5rem .5rem auto .5rem;
    }

    .icon-button,
    .icon-check span {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1rem;
    }

    .photo-card-content {
        padding: .75rem;
    }

    .photo-card-content h2 {
        font-size: .98rem;
    }

    .photo-card-content span {
        font-size: .82rem;
    }
}

@media (min-width: 1040px) {
    .photo-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .photo-detail {
        grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem);
        align-items: start;
        gap: 1.25rem;
    }

    .photo-stage {
        height: min(72vh, 48rem);
        min-height: 30rem;
    }

    .photo-main-image,
    .photo-stage > img {
        height: 100%;
        min-height: 0;
        object-fit: contain;
    }

    .photo-panel {
        position: sticky;
        top: 5.5rem;
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
    }
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 130;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0;
    padding: .75rem;
    background: rgba(1, 2, 6, .9);
    backdrop-filter: blur(18px);
}

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

.gallery-lightbox-stage {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    margin: 0;
}

.gallery-lightbox-stage img {
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
}

.gallery-lightbox-panel {
    display: grid;
    gap: .85rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(17, 23, 36, .88), rgba(7, 10, 18, .9));
    backdrop-filter: blur(18px);
}

.gallery-lightbox-panel h2 {
    margin: 0;
    font-size: 1.5rem;
}

.gallery-lightbox-panel label {
    display: grid;
    gap: .45rem;
}

.gallery-lightbox-panel textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: rgba(3, 6, 12, .74);
    padding: .84rem .95rem;
}

.star-display {
    display: inline-flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: .2rem;
    color: var(--gold);
}

.star-display input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.star-display span {
    color: var(--dim);
    cursor: pointer;
    font-size: 1.45rem;
}

.star-display input:checked ~ span,
.star-display label:hover span,
.star-display label:hover ~ label span {
    color: var(--gold);
}

.gallery-lightbox-close,
.gallery-lightbox-arrow {
    position: fixed;
    z-index: 2;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    color: var(--text);
    background: rgba(12, 16, 27, .78);
    cursor: pointer;
    backdrop-filter: blur(12px);
}

.gallery-lightbox-close {
    top: 1rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    font-size: 1.6rem;
}

.gallery-toast {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    z-index: 200;
    max-width: calc(100% - 2rem);
    padding: .8rem 1rem;
    border: 1px solid rgba(55, 214, 223, .34);
    border-radius: 999px;
    color: var(--text);
    background: rgba(10, 14, 24, .88);
    box-shadow: 0 18px 45px rgba(0, 0, 0, .35);
    opacity: 0;
    transform: translate(-50%, .8rem);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
    backdrop-filter: blur(16px);
    font-weight: 850;
}

.gallery-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.gallery-lightbox-arrow {
    top: 38%;
    width: 3rem;
    height: 4rem;
    border-radius: 999px;
    font-size: 2rem;
}

.gallery-lightbox-prev { left: 1rem; }
.gallery-lightbox-next { right: 1rem; }

@media (max-width: 679px) {
    .gallery-lightbox {
        grid-template-rows: minmax(42vh, 1fr) auto;
        padding: .6rem;
        padding-bottom: max(.8rem, env(safe-area-inset-bottom));
    }

    .gallery-lightbox-stage img {
        max-height: 58vh;
        border-radius: 16px;
    }

    .gallery-lightbox-panel {
        max-height: 42vh;
        overflow-y: auto;
        border-radius: 20px;
        padding: .85rem;
    }

    .gallery-lightbox-panel h2 {
        font-size: 1.25rem;
    }

    .gallery-lightbox-panel textarea,
    .gallery-lightbox-panel .gallery-btn {
        min-height: 3.1rem;
        font-size: 1rem;
    }

    .gallery-lightbox-close {
        top: .75rem;
        right: .75rem;
        width: 3.3rem;
        height: 3.3rem;
    }

    .gallery-lightbox-arrow {
        top: 28%;
        width: 3.2rem;
        height: 4.4rem;
    }

    .gallery-lightbox-prev { left: .55rem; }
    .gallery-lightbox-next { right: .55rem; }
}

@media (min-width: 980px) {
    .gallery-lightbox {
        grid-template-columns: minmax(0, 1fr) minmax(22rem, 28rem);
        grid-template-rows: 1fr;
        gap: 1rem;
        padding: 1.25rem;
    }

    .gallery-lightbox-stage img {
        max-height: 94vh;
    }

    .gallery-lightbox-panel {
        align-self: center;
        max-height: 94vh;
        overflow-y: auto;
    }
}

@media (min-width: 1320px) {
    .photo-detail {
        grid-template-columns: minmax(0, 1.2fr) minmax(22rem, 27rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .photo-card img,
    .gallery-toolbar,
    .gallery-toast {
        transition: none;
    }
}

.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(1, 2, 6, .88);
    backdrop-filter: blur(16px);
}

.photo-lightbox[hidden] {
    display: none;
}

.photo-lightbox img {
    max-width: min(100%, 1600px);
    max-height: 92vh;
    object-fit: contain;
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
}

.photo-lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1;
    width: 3rem;
    height: 3rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    background: rgba(12, 16, 27, .78);
    cursor: pointer;
    font-size: 1.6rem;
}
