:root {
    --bg: #fff8f4;
    --surface: #ffffff;
    --text: #2d2522;
    --muted: #756965;
    --rose: #b85d75;
    --rose-dark: #8f3f59;
    --sage: #60766a;
    --sage-light: #e8efe8;
    --line: #eadbd5;
    --danger: #a93636;
    --success: #2f7754;
    --shadow: 0 18px 50px rgba(79, 48, 45, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(255, 248, 244, 0.92), rgba(232, 239, 232, 0.86)),
        url("data:image/svg+xml,%3Csvg width='180' height='180' viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d8bbb0' stroke-opacity='.32' stroke-width='1.2'%3E%3Cpath d='M40 118c22-18 51-36 88-52'/%3E%3Cpath d='M52 132c24-16 47-26 76-31'/%3E%3Cpath d='M93 55c6 18 4 34-4 48'/%3E%3Cpath d='M120 79c-17 9-35 13-54 12'/%3E%3C/g%3E%3C/svg%3E");
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

.page {
    width: min(1180px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.page-home {
    display: grid;
    place-items: center;
}

.hero {
    width: min(560px, 100%);
    padding: 32px 22px;
    text-align: center;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--sage);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.4rem, 12vw, 4.5rem);
    font-weight: 500;
    line-height: 0.98;
}

.lead {
    margin: 20px auto 0;
    max-width: 34rem;
    color: var(--muted);
    font-size: 1.06rem;
}

.upload-panel {
    margin-top: 30px;
}

.actions {
    display: grid;
    gap: 12px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 14px 18px;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:disabled {
    cursor: wait;
    opacity: 0.68;
}

.button:not(:disabled):active {
    transform: translateY(1px);
}

.button-primary {
    color: #ffffff;
    background: var(--rose);
    box-shadow: var(--shadow);
}

.button-primary:hover {
    background: var(--rose-dark);
}

.button-secondary {
    color: var(--sage);
    background: var(--sage-light);
    border-color: rgba(96, 118, 106, 0.2);
}

.button-link {
    margin-top: 18px;
    background: var(--surface);
    border-color: var(--line);
}

.hint {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.status {
    margin-top: 22px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    text-align: left;
}

.status-row {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.95rem;
}

.progress {
    height: 10px;
    margin-top: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #eadbd5;
}

.progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--rose);
    transition: width 220ms ease;
}

.result-list {
    display: grid;
    gap: 6px;
    max-height: 170px;
    margin: 12px 0 0;
    padding: 0;
    overflow: auto;
    list-style: none;
    font-size: 0.9rem;
}

.result-success {
    color: var(--success);
}

.result-error {
    color: var(--danger);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.gallery-header {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(234, 219, 213, 0.9);
}

.gallery-header h1 {
    font-size: clamp(2rem, 7vw, 3.15rem);
    line-height: 1.04;
}

.gallery-header .button {
    width: auto;
    min-width: 138px;
}

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

.photo-card {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(234, 219, 213, 0.9);
    border-radius: 8px;
    background: linear-gradient(135deg, #efe0da, #e8efe8);
    box-shadow: 0 12px 34px rgba(79, 48, 45, 0.1);
    cursor: zoom-in;
}

.photo-card::after {
    position: absolute;
    inset: auto 0 0;
    height: 42%;
    background: linear-gradient(to top, rgba(45, 37, 34, 0.58), rgba(45, 37, 34, 0));
    content: "";
    opacity: 0;
    transition: opacity 180ms ease;
}

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

.photo-card span {
    position: absolute;
    right: 10px;
    bottom: 8px;
    left: 10px;
    z-index: 1;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: left;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 180ms ease;
}

.photo-card:hover::after,
.photo-card:hover span,
.photo-card:focus-visible::after,
.photo-card:focus-visible span {
    opacity: 1;
}

.empty-state {
    padding: 36px 0;
    color: var(--muted);
}

.empty-state h2 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 1.35rem;
}

.empty-state p {
    margin: 0;
}

.lightbox {
    width: min(980px, calc(100% - 24px));
    max-height: calc(100vh - 24px);
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
}

.lightbox::backdrop {
    background: rgba(25, 20, 18, 0.82);
}

.lightbox img {
    display: block;
    width: 100%;
    max-height: calc(100vh - 24px);
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 999px;
    color: var(--text);
    background: #ffffff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

@media (min-width: 640px) {
    .page {
        padding: 36px 28px 52px;
    }

    .hero {
        padding: 48px 28px;
    }

    .actions {
        grid-template-columns: 1fr 1fr;
    }

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

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

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

@media (max-width: 520px) {
    .gallery-header {
        display: grid;
        align-items: start;
    }

    .gallery-header .button {
        width: 100%;
    }
}
