:root {
    color-scheme: light;
    --bg: #f7f4ef;
    --surface: #ffffff;
    --text: #171615;
    --muted: #74706b;
    --line: #ded8cf;
    --accent: #4d6f63;
    --accent-text: #ffffff;
}

.palette-graphite {
    --bg: #111312;
    --surface: #1b1e1c;
    --text: #f2eee7;
    --muted: #aaa49a;
    --line: #333831;
    --accent: #d7c7a2;
    --accent-text: #171615;
    color-scheme: dark;
}

.palette-olive {
    --bg: #eef0e7;
    --surface: #ffffff;
    --text: #17201b;
    --muted: #657066;
    --line: #d3dacd;
    --accent: #5d7352;
    --accent-text: #ffffff;
}

.palette-rose {
    --bg: #f8f0ee;
    --surface: #ffffff;
    --text: #241617;
    --muted: #7d6869;
    --line: #ead8d5;
    --accent: #9a5556;
    --accent-text: #ffffff;
}

.palette-paper .gallery-hero,
.palette-olive .gallery-hero,
.palette-rose .gallery-hero {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 46%),
        var(--bg);
}

.palette-graphite .gallery-hero {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, transparent), transparent 50%),
        var(--bg);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
.button {
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-text);
    padding: 0 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button.ghost,
.button.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    padding: 11px 12px;
    font: inherit;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.92rem;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.06);
}

.auth .panel {
    width: min(420px, 100%);
}

.stack {
    display: grid;
    gap: 14px;
}

.field-grid,
.admin-grid {
    display: grid;
    gap: 18px;
}

.admin-grid {
    grid-template-columns: minmax(280px, 420px) 1fr;
    padding: 24px;
    align-items: start;
}

.topbar {
    min-height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.rows {
    display: grid;
    gap: 10px;
}

.gallery-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.gallery-row h3,
.gallery-row p {
    margin-bottom: 4px;
}

.gallery-row p,
.empty {
    color: var(--muted);
}

.gallery-row nav {
    display: flex;
    gap: 12px;
    white-space: nowrap;
    color: var(--accent);
    font-weight: 700;
}

.wide {
    width: min(1240px, 100%);
    margin: 0 auto;
    padding: 24px;
    display: grid;
    gap: 20px;
}

.hero-admin {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.admin-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

button.danger {
    background: #9f2d2d;
    color: #fff;
}

.upload-box {
    display: flex;
    gap: 12px;
    align-items: center;
}

.photo-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.admin-photo {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 8px;
    display: grid;
    gap: 8px;
}

.admin-photo img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    border-radius: 5px;
}

.admin-photo p {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.selection-list {
    margin: 0;
    padding-left: 20px;
    color: var(--text);
}

.muted {
    color: var(--muted);
}

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

.gallery-hero {
    min-height: 38vh;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding: 42px clamp(16px, 4vw, 56px);
    border-bottom: 1px solid var(--line);
}

.gallery-hero p {
    color: var(--muted);
    letter-spacing: 0;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 800;
}

.gallery-hero h1 {
    font-size: clamp(2.4rem, 7vw, 6rem);
    line-height: 0.95;
    margin-bottom: 16px;
}

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

.selection-pill {
    min-width: 150px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    color: var(--muted);
    padding: 10px 14px;
    text-align: center;
    font-size: 0.92rem;
    backdrop-filter: blur(14px);
}

.selection-pill strong {
    color: var(--accent);
    font-size: 1.1rem;
}

.selection-pill::after {
    content: attr(data-state);
    display: block;
    min-height: 15px;
    color: var(--muted);
    font-size: 0.72rem;
    margin-top: 2px;
}

.masonry {
    column-count: 4;
    column-gap: 10px;
    padding: 10px;
}

.tile {
    break-inside: avoid;
    margin: 0 0 10px;
    position: relative;
    cursor: zoom-in;
    background: var(--surface);
}

.tile img {
    display: block;
    width: 100%;
    height: auto;
}

.pick {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 50%;
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.46);
    border: 1px solid rgba(255, 255, 255, 0.58);
}

.pick::before {
    content: "♥";
    color: #fff;
    font-size: 19px;
    line-height: 1;
    transform: translateY(-1px);
}

.tile.is-selected .pick {
    background: var(--accent);
}

.tile.is-selected .pick::before {
    color: var(--accent-text);
    transform: translateY(-1px) scale(1.04);
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(7, 7, 7, 0.94);
    display: grid;
    place-items: center;
    touch-action: none;
}

.lightbox[hidden] {
    display: none;
}

.lightbox img {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
    user-select: none;
    transform-origin: center;
}

.lightbox .close,
.lightbox .prev,
.lightbox .next {
    position: fixed;
    z-index: 22;
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 28px;
    padding: 0;
}

.lightbox .close {
    top: 18px;
    right: 18px;
}

.lightbox .prev {
    left: 18px;
}

.lightbox .next {
    right: 18px;
}

.lightbox footer {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    color: #fff;
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    font-size: 0.92rem;
}

.lightbox footer a {
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 999px;
    padding: 8px 12px;
}

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

    .masonry {
        column-count: 3;
    }
}

@media (max-width: 680px) {
    .masonry {
        column-count: 2;
        column-gap: 6px;
        padding: 6px;
    }

    .tile {
        margin-bottom: 6px;
    }

    .hero-admin,
    .upload-box,
    .gallery-row {
        display: grid;
    }

    .gallery-hero {
        min-height: 30vh;
        align-items: start;
        flex-direction: column;
        justify-content: end;
    }

    .lightbox .prev,
    .lightbox .next {
        display: none;
    }
}
