:root {
    --color-white: #ffffff;
    --color-warm-white: #fffafb;
    --color-soft-gray: #f4f1f4;
    --color-text: #3e3740;
    --color-muted: #7f737d;
    --color-gold: #b99245;
    --color-gold-light: #ead7a8;
    --color-lilac: #d8c5ee;
    --color-lilac-strong: #9d79bd;
    --color-rose: #f3cbd6;
    --color-rose-deep: #c87991;
    --color-shadow: rgba(83, 64, 86, 0.12);
    --radius: 8px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --font-title: Georgia, "Times New Roman", serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--color-warm-white);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at 12% 4%, rgba(243, 203, 214, 0.42), transparent 32rem),
        radial-gradient(circle at 92% 0%, rgba(216, 197, 238, 0.42), transparent 30rem),
        linear-gradient(180deg, #fffafb 0%, #ffffff 46%, #fbf7fb 100%);
}

body.is-locked {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

:focus-visible {
    outline: 3px solid rgba(185, 146, 69, 0.55);
    outline-offset: 3px;
}

.page-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 18px 14px calc(34px + var(--safe-bottom));
}

.hero {
    padding: 20px 4px 18px;
    text-align: center;
}

.hero__ornament {
    display: grid;
    width: 112px;
    min-height: 96px;
    margin: 0 auto 12px;
    place-items: center;
}

.wedding-logo {
    display: block;
    width: min(112px, 34vw);
    max-height: 118px;
    object-fit: contain;
}

.wedding-date,
.eyebrow {
    margin: 0;
    color: var(--color-rose-deep);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero h1,
.section-heading h2,
.gallery-heading h2 {
    margin: 6px 0 0;
    color: var(--color-text);
    font-family: var(--font-title);
    font-weight: 500;
    letter-spacing: 0;
}

.hero h1 {
    font-size: clamp(2.25rem, 12vw, 4rem);
    line-height: 0.98;
}

.hero__subtitle {
    max-width: 23rem;
    margin: 12px auto 0;
    color: var(--color-muted);
    font-size: 1.03rem;
    line-height: 1.55;
}

.app-flow {
    display: grid;
    gap: 16px;
}

.card {
    width: 100%;
    border: 1px solid rgba(185, 146, 69, 0.16);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 18px 42px var(--color-shadow);
}

.guest-card,
.upload-card {
    padding: 22px 18px;
}

.section-heading p {
    margin: 10px 0 0;
    color: var(--color-muted);
    font-size: 0.98rem;
    line-height: 1.55;
}

.section-heading h2,
.gallery-heading h2 {
    font-size: 1.65rem;
    line-height: 1.12;
}

.stacked-form,
.upload-form {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

label {
    color: var(--color-text);
    font-size: 0.95rem;
    font-weight: 700;
}

input[type="text"] {
    width: 100%;
    min-height: 54px;
    border: 1px solid rgba(157, 121, 189, 0.24);
    border-radius: var(--radius);
    background: var(--color-white);
    color: var(--color-text);
    padding: 0 15px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

input[type="text"]::placeholder {
    color: #b1a8b0;
}

.button,
.download-link {
    display: inline-flex;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
    transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.button--primary {
    width: 100%;
    background: linear-gradient(135deg, var(--color-rose-deep), var(--color-lilac-strong));
    color: var(--color-white);
    box-shadow: 0 12px 26px rgba(157, 121, 189, 0.26);
}

.button:active,
.download-link:active,
.file-picker:active {
    transform: translateY(1px) scale(0.995);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none;
}

.file-picker {
    display: grid;
    min-height: 118px;
    place-items: center;
    gap: 8px;
    border: 1.5px dashed rgba(185, 146, 69, 0.45);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 250, 251, 0.96)),
        linear-gradient(135deg, rgba(243, 203, 214, 0.24), rgba(216, 197, 238, 0.24));
    padding: 22px 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.file-picker--library {
    border-style: solid;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 250, 251, 0.96)),
        linear-gradient(135deg, rgba(234, 215, 168, 0.22), rgba(216, 197, 238, 0.24));
}

.file-picker:hover {
    border-color: rgba(185, 146, 69, 0.8);
    box-shadow: 0 12px 28px rgba(185, 146, 69, 0.12);
}

.file-picker__icon {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    border-radius: 50%;
    background: var(--color-white);
    color: var(--color-gold);
    font-size: 2rem;
    line-height: 1;
    box-shadow: 0 10px 24px rgba(185, 146, 69, 0.18);
}

.file-picker__title {
    color: var(--color-text);
    font-size: 1.05rem;
    font-weight: 800;
}

.selected-file {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.selected-file {
    min-height: 1.3rem;
    text-align: center;
}

.status-message {
    min-height: 1.4rem;
    margin: 14px 0 0;
    color: var(--color-lilac-strong);
    font-weight: 800;
    line-height: 1.4;
    text-align: center;
}

.status-message.is-error {
    color: #a8495f;
}

.gallery-section {
    padding: 8px 0 0;
}

.gallery-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin: 10px 2px 14px;
}

.download-link {
    min-height: 42px;
    flex: 0 0 auto;
    border: 1px solid rgba(185, 146, 69, 0.28);
    background: rgba(255, 255, 255, 0.82);
    color: var(--color-gold);
    padding: 0 13px;
    font-size: 0.88rem;
    text-align: center;
    white-space: normal;
}

.empty-state {
    border: 1px solid rgba(216, 197, 238, 0.35);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.74);
    padding: 24px 18px;
    color: var(--color-muted);
    text-align: center;
}

.empty-state p {
    margin: 0;
}

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

.gallery-item {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius);
    background: var(--color-soft-gray);
    box-shadow: 0 10px 24px rgba(83, 64, 86, 0.1);
    cursor: pointer;
    aspect-ratio: 1 / 1.16;
}

.gallery-item img,
.gallery-placeholder {
    width: 100%;
    height: 100%;
}

.gallery-item img {
    display: block;
    object-fit: cover;
    transition: transform 260ms ease;
}

.gallery-item:active img {
    transform: scale(1.025);
}

.gallery-placeholder {
    display: grid;
    place-items: center;
    padding: 12px;
    background:
        linear-gradient(135deg, rgba(243, 203, 214, 0.36), rgba(216, 197, 238, 0.42)),
        var(--color-white);
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 800;
    text-align: center;
}

.gallery-meta {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    gap: 1px;
    padding: 28px 9px 8px;
    background: linear-gradient(180deg, transparent, rgba(42, 34, 44, 0.72));
    color: var(--color-white);
    text-align: left;
}

.gallery-meta strong,
.gallery-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-meta strong {
    font-size: 0.84rem;
}

.gallery-meta span {
    font-size: 0.73rem;
    opacity: 0.86;
}

.upload-overlay,
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 20;
}

.upload-overlay {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 18px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--color-text);
    text-align: center;
}

.upload-overlay p {
    margin: 0;
    font-weight: 800;
}

.spinner {
    width: 72px;
    height: 72px;
    border: 5px solid rgba(216, 197, 238, 0.34);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 900ms linear infinite;
}

.lightbox {
    display: grid;
    grid-template-rows: auto 1fr;
    background: rgba(23, 19, 24, 0.96);
    color: var(--color-white);
    padding: calc(14px + env(safe-area-inset-top, 0px)) 12px calc(14px + var(--safe-bottom));
}

.lightbox__close {
    justify-self: end;
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-white);
    padding: 0 16px;
    cursor: pointer;
    font-weight: 800;
}

.lightbox__figure {
    display: grid;
    min-height: 0;
    grid-template-rows: 1fr auto;
    align-items: center;
    margin: 0;
}

.lightbox__figure img {
    display: block;
    width: 100%;
    max-width: 980px;
    max-height: calc(100vh - 150px);
    margin: 0 auto;
    object-fit: contain;
}

.lightbox__figure img.is-broken {
    display: none;
}

.lightbox__figure figcaption {
    min-height: 2rem;
    margin-top: 12px;
    padding: 0 104px 0 8px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.92rem;
    line-height: 1.35;
    text-align: center;
}

.lightbox__download {
    position: absolute;
    right: 12px;
    bottom: calc(14px + var(--safe-bottom));
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.12);
    color: var(--color-white);
    padding: 0 13px;
    font-size: 0.88rem;
    font-weight: 800;
    text-decoration: none;
}

.lightbox__nav {
    position: absolute;
    top: 50%;
    display: grid;
    width: 46px;
    height: 58px;
    place-items: center;
    border: 0;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.14);
    color: var(--color-white);
    cursor: pointer;
    font-size: 2.8rem;
    line-height: 1;
    transform: translateY(-50%);
}

.lightbox__nav--prev {
    left: 8px;
}

.lightbox__nav--next {
    right: 8px;
}

.is-hidden {
    display: none !important;
}

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

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

@media (min-width: 430px) {
    .page-shell {
        padding-right: 18px;
        padding-left: 18px;
    }

    .guest-card,
    .upload-card {
        padding: 26px 22px;
    }

    .lightbox__figure figcaption {
        padding-right: 118px;
    }
}

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

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

@media (min-width: 920px) {
    .page-shell {
        width: min(100%, 1040px);
    }

    .app-flow {
        grid-template-columns: minmax(320px, 420px) 1fr;
        align-items: start;
    }

    .guest-card,
    .upload-card {
        position: sticky;
        top: 20px;
        grid-column: 1;
    }

    .gallery-section {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

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