:root {
    --paper: #f4f0e7;
    --paper-strong: #fbf8f2;
    --ink: #22201d;
    --ink-soft: #5f584f;
    --line: #2a2723;
    --line-soft: rgba(42, 39, 35, 0.2);
    --surface: rgba(255, 252, 246, 0.92);
    --surface-strong: rgba(255, 252, 246, 0.98);
    --shadow-soft: 0 12px 34px rgba(41, 34, 22, 0.11);
    --shadow-press: 0 8px 20px rgba(41, 34, 22, 0.18);
    --accent: #1f1c18;
    --accent-2: #3d372f;
    --radius-xl: 28px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-pill: 24px;
    --transition: 180ms ease;
}

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

body {
    margin: 0;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
    font-family: "Manrope", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(160deg, rgba(250, 246, 238, 0.72), rgba(239, 232, 218, 0.72)),
        url("../assets/mare.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

body.is-busy,
body.lightbox-open {
    overflow: hidden;
}

button,
input,
img,
video {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
.preview-media:focus-visible {
    outline: 3px solid rgba(31, 28, 24, 0.34);
    outline-offset: 3px;
}

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

.background-glow {
    position: absolute;
    z-index: -1;
    width: 200px;
    aspect-ratio: 1;
    border-radius: 999px;
    filter: blur(34px);
    opacity: 0.55;
}

.background-glow-left {
    top: 2%;
    left: -18%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 70%);
}

.background-glow-right {
    right: -20%;
    bottom: 0;
    background: radial-gradient(circle, rgba(208, 194, 170, 0.62) 0%, rgba(208, 194, 170, 0) 72%);
}

.page-shell {
    width: min(430px, calc(100% - 18px));
    height: 100dvh;
    margin: 0 auto;
    padding: 14px 0;
    display: grid;
    align-content: center;
    justify-content: center;
    justify-items: center;
    align-items: center;
    gap: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
}

body.home-centered .page-shell {
    align-content: center;
}

body:not(.home-centered) .page-shell {
    align-content: start;
}

.hero,
.panels {
    width: 100%;
}

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

.upload-card {
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
}

.upload-card {
    padding: 15px;
}

.upload-card.is-hidden,
.upload-overlay.is-hidden,
.preview-lightbox.is-hidden,
.hero.is-hidden {
    display: none;
}

.hero {
    text-align: center;
    padding: 8px 8px 0;
}

.eyebrow {
    margin: 0;
    font-size: 0.76rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-weight: 600;
}

h1,
h2 {
    margin: 0;
    font-family: "Manrope", sans-serif;
    font-weight: 700;
}

h1 {
    margin-top: 4px;
    font-size: clamp(2rem, 8.5vw, 2.7rem);
    line-height: 1.08;
}

#site-title {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    margin-inline: auto;
    padding: 0.55rem 1rem;
    background-color: #ffa672;
    color: #000;
    text-align: center;
    position: relative;
    transform: rotate(-1.5deg);
    word-break: break-word;
}

#site-title::after {
    content: "";
    position: absolute;
    border: 1px solid #000;
    bottom: 4px;
    left: 4px;
    width: calc(100% - 1px);
    height: calc(100% - 1px);
    pointer-events: none;
}

.subtitle {
    margin: 8px auto 0;
    max-width: 28ch;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

.subtitle + #site-title {
    margin-top: 24px;
}

.title-photo {
    margin-top: 14px;
    display: flex;
    justify-content: center;
}

.title-photo-image {
    width: 138px;
    height: 138px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    border: 4px solid #efe2d1;
    box-shadow: 0 0 0 1px #2a2723, 0 10px 24px rgba(41, 34, 22, 0.18);
}

.actions {
    margin-top: 16px;
    display: grid;
    gap: 11px;
}

.primary-action {
    background-color: #e9b77f;
    border: 0 solid #e5e7eb;
    box-sizing: border-box;
    color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    text-decoration: none solid #000;
    text-decoration-thickness: auto;
    width: 100%;
    max-width: 460px;
    min-height: 76px;
    padding: 0.75rem 1.65rem;
    position: relative;
    cursor: pointer;
    transform: rotate(-2deg);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.75rem;
}

.primary-action:hover:not(:disabled) {
    transform: rotate(-2deg);
}

.primary-action::after {
    content: "";
    position: absolute;
    border: 1px solid #000;
    bottom: 4px;
    left: 4px;
    width: calc(100% - 1px);
    height: calc(100% - 1px);
    pointer-events: none;
}

.primary-action:hover::after {
    bottom: 2px;
    left: 2px;
}

.primary-action:focus,
.secondary-action:focus {
    outline: 0;
}

.primary-action:disabled,
.secondary-action:disabled,
.remove-preview:disabled,
.lightbox-close:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.action-emoji {
    font-size: inherit;
    line-height: inherit;
}

.card-header {
    text-align: center;
    margin-bottom: 10px;
}

.card-kicker {
    margin: 0;
    font-size: 0.73rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-weight: 700;
}

h2 {
    font-size: 1.32rem;
}

.card-footer {
    margin-top: 10px;
    display: grid;
    justify-items: center;
    gap: 8px;
}

.selection-summary {
    margin: 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
    text-align: center;
}

.secondary-action {
    background-color: #e9b77f;
    border: 0 solid #e5e7eb;
    box-sizing: border-box;
    color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    text-decoration: none solid #000;
    text-decoration-thickness: auto;
    width: min(240px, 100%);
    min-height: 56px;
    max-width: 460px;
    padding: 0.75rem 1.65rem;
    position: relative;
    cursor: pointer;
    transform: rotate(-2deg);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.75rem;
}

.secondary-action:hover:not(:disabled) {
    transform: rotate(-2deg);
}

.secondary-action::after {
    content: "";
    position: absolute;
    border: 1px solid #000;
    bottom: 4px;
    left: 4px;
    width: calc(100% - 1px);
    height: calc(100% - 1px);
    pointer-events: none;
}

.secondary-action:hover::after {
    bottom: 2px;
    left: 2px;
}

.preview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    justify-items: center;
}

.preview-card {
    position: relative;
    width: min(100%, 340px);
    border-radius: var(--radius-md);
    background: var(--surface-strong);
    box-shadow: 0 12px 30px rgba(31, 24, 16, 0.1);
    overflow: hidden;
}

.preview-media {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    object-position: center center;
    background: #e6dfd2;
    cursor: zoom-in;
}

.preview-media.video {
    aspect-ratio: 16 / 10;
    cursor: default;
    background: #131313;
}

.preview-meta {
    padding: 10px;
    text-align: center;
    display: grid;
    gap: 4px;
}

.preview-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-size {
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.remove-preview {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 54px;
    height: 46px;
    border: 0 solid #e5e7eb;
    border-radius: 8px;
    background-color: #e2cbb0;
    color: #000;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-2deg);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.remove-preview::after {
    content: "";
    position: absolute;
    border: 1px solid #000;
    border-radius: 8px;
    bottom: 3px;
    left: 3px;
    width: calc(100% - 1px);
    height: calc(100% - 1px);
    pointer-events: none;
}

.remove-preview:hover::after {
    bottom: 1px;
    left: 1px;
}

.upload-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(18, 16, 13, 0.5);
}

.overlay-card {
    width: min(100%, 360px);
    border-radius: var(--radius-lg);
    background: var(--surface-strong);
    box-shadow: 0 20px 44px rgba(17, 13, 8, 0.33);
    padding: 22px 16px;
    text-align: center;
}

.loader-spinner {
    width: 46px;
    height: 46px;
    margin: 0 auto 12px;
    border-radius: 50%;
    border: 3px solid #cec5b6;
    border-top-color: var(--line);
    animation: spin 0.95s linear infinite;
}

.progress-track {
    width: 100%;
    height: 10px;
    margin-top: 12px;
    border-radius: 999px;
    background: #ebe3d4;
    overflow: hidden;
}

.progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
    transition: width 120ms linear;
}

.progress-label,
#overlay-status-text {
    color: var(--ink-soft);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(14px + env(safe-area-inset-bottom));
    transform: translate(-50%, 16px);
    min-width: min(92vw, 320px);
    border-radius: 14px;
    padding: 12px 14px;
    background: #2c2925;
    color: #fff;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
    z-index: 12;
}

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

.preview-lightbox {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(10, 9, 8, 0.92);
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    width: 58px;
    height: 48px;
    border: 0 solid #e5e7eb;
    border-radius: 8px;
    background-color: #e2cbb0;
    color: #000;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-2deg);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.lightbox-close::after {
    content: "";
    position: absolute;
    border: 1px solid #000;
    border-radius: 8px;
    bottom: 3px;
    left: 3px;
    width: calc(100% - 1px);
    height: calc(100% - 1px);
    pointer-events: none;
}

.lightbox-close:hover::after {
    bottom: 1px;
    left: 1px;
}

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

@media (min-width: 768px) {
    .page-shell {
        width: min(620px, calc(100% - 28px));
        padding: 18px 0;
    }

    .actions {
        width: min(430px, 100%);
        margin-inline: auto;
    }

    .primary-action,
    .secondary-action {
        padding: 0.75rem 3rem;
        font-size: 1.25rem;
    }

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

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