:root {
    color-scheme: dark;
    --bg: #070a12;
    --card: rgba(16, 24, 39, 0.88);
    --border: rgba(148, 163, 184, 0.18);
    --text: #f8fafc;
    --muted: #94a3b8;
    --primary: #7c3aed;
    --primary-strong: #a855f7;
    --accent: #22d3ee;
    --danger: #fb7185;
    --success: #34d399;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(124, 58, 237, 0.3), transparent 32rem),
        radial-gradient(circle at top right, rgba(34, 211, 238, 0.18), transparent 30rem),
        linear-gradient(135deg, #070a12, #101827 58%, #0b1120);
}

button,
input {
    font: inherit;
}

button,
.drop-zone {
    cursor: pointer;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

.app {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 max(56px, env(safe-area-inset-bottom));
}

.card {
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero {
    padding: 36px;
    overflow: hidden;
    position: relative;
}

.hero::after {
    content: "";
    position: absolute;
    right: -90px;
    top: -130px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.22);
    filter: blur(12px);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

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

h1 {
    max-width: 780px;
    margin-bottom: 14px;
    font-size: clamp(38px, 7vw, 76px);
    line-height: 0.95;
    letter-spacing: -0.06em;
}

.hero p:not(.eyebrow) {
    max-width: 720px;
    margin-bottom: 22px;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.75;
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.badges span {
    border: 1px solid rgba(34, 211, 238, 0.22);
    border-radius: 999px;
    padding: 8px 12px;
    color: #a5f3fc;
    background: rgba(8, 47, 73, 0.28);
    font-size: 13px;
    font-weight: 700;
}

.uploader-card,
.status-card,
.results-card {
    margin-top: 22px;
    padding: 26px;
}

.drop-zone {
    display: grid;
    place-items: center;
    min-height: 230px;
    border: 1.5px dashed rgba(148, 163, 184, 0.42);
    border-radius: 26px;
    background: rgba(15, 23, 42, 0.56);
    text-align: center;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
    border-color: rgba(34, 211, 238, 0.78);
    background: rgba(34, 211, 238, 0.08);
    transform: translateY(-1px);
}

.drop-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.drop-zone strong {
    display: block;
    margin-bottom: 10px;
    font-size: 22px;
}

.drop-zone small {
    display: block;
    max-width: 420px;
    color: var(--muted);
    line-height: 1.7;
}

.preview-grid,
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
}

.preview-grid:not(:empty) {
    margin-top: 18px;
}

.preview-item,
.result-card {
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 22px;
    background: rgba(15, 23, 42, 0.72);
}

.preview-item img,
.result-card img {
    display: block;
    width: 100%;
    background: #020617;
    object-fit: cover;
}

.preview-item img {
    aspect-ratio: 1;
}

.result-card img {
    aspect-ratio: 2 / 3;
}

.preview-item span,
.result-info {
    display: block;
    overflow: hidden;
    padding: 10px 12px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 58px;
    margin-top: 18px;
    border: 0;
    border-radius: 20px;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    font-weight: 900;
    box-shadow: 0 16px 40px rgba(124, 58, 237, 0.34);
    transition: transform 0.2s ease, opacity 0.2s ease;
    touch-action: manipulation;
}

.primary-button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.68;
}

.spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.primary-button.is-loading .spinner {
    display: inline-block;
}

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

.message {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    padding: 14px 16px;
    color: var(--muted);
    background: rgba(15, 23, 42, 0.56);
    line-height: 1.7;
    white-space: pre-wrap;
}

.message.is-error {
    border-color: rgba(251, 113, 133, 0.34);
    color: #fecdd3;
    background: rgba(127, 29, 29, 0.24);
}

.message.is-success {
    border-color: rgba(52, 211, 153, 0.3);
    color: #bbf7d0;
    background: rgba(6, 78, 59, 0.2);
}

.progress {
    margin-top: 14px;
}

.progress-track {
    overflow: hidden;
    height: 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--primary-strong));
    transition: width 0.25s ease;
}

.progress small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.section-title h2 {
    margin-bottom: 0;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.section-title span {
    color: var(--muted);
    font-size: 13px;
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 12px 12px;
}

.result-actions a,
.result-actions button {
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 999px;
    padding: 9px 10px;
    color: var(--text);
    background: rgba(15, 23, 42, 0.84);
    font-size: 13px;
    text-align: center;
    text-decoration: none;
}

.result-actions a:hover,
.result-actions button:hover {
    border-color: rgba(34, 211, 238, 0.54);
}

@media (max-width: 640px) {
    .app {
        width: min(100% - 20px, 1120px);
        padding-top: 10px;
        padding-bottom: calc(22px + env(safe-area-inset-bottom));
    }

    .hero,
    .uploader-card,
    .status-card,
    .results-card {
        padding: 18px;
        border-radius: 22px;
    }

    .hero::after {
        right: -150px;
        top: -150px;
    }

    h1 {
        font-size: clamp(36px, 13vw, 50px);
    }

    .hero p:not(.eyebrow) {
        font-size: 15px;
        line-height: 1.65;
    }

    .drop-zone {
        min-height: 180px;
        padding: 18px;
    }

    .drop-zone strong {
        font-size: 18px;
    }

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

    .result-actions {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

@media (max-width: 380px) {
    .preview-grid,
    .results-grid {
        grid-template-columns: 1fr;
    }
}
