:root {
    --bg: #070b14;
    --bg-soft: #0d1320;
    --card: rgba(16, 23, 38, 0.92);
    --card-2: #0d1524;
    --line: rgba(255,255,255,.08);
    --line-strong: rgba(255,255,255,.13);
    --text: #f5f7fb;
    --muted: #8f9bb0;
    --primary: #5b6cff;
    --primary-2: #7d5cff;
    --success: #2ed39a;
    --error: #ff6d82;
    --shadow: 0 24px 70px rgba(0,0,0,.34);
    --radius: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    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 15% -10%, rgba(91,108,255,.20), transparent 34%),
        radial-gradient(circle at 90% 0%, rgba(125,92,255,.12), transparent 28%),
        linear-gradient(180deg, #070b14 0%, #0b1120 100%);
}

button, input, a { font: inherit; }
a { color: inherit; }

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 56px;
    display: grid;
    gap: 20px;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

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

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 10px 28px rgba(91,108,255,.26);
    font-size: 18px;
}

.brand strong {
    font-size: 1.02rem;
    letter-spacing: -.02em;
}

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

.uploader-card {
    padding: 28px;
}

.dropzone {
    position: relative;
    min-height: 390px;
    border-radius: 20px;
    border: 1.5px dashed rgba(255,255,255,.14);
    background:
        linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.015));
    display: grid;
    place-items: center;
    overflow: hidden;
    cursor: pointer;
    transition: .22s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
    border-color: rgba(91,108,255,.68);
    background: rgba(91,108,255,.055);
}

.upload-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px;
}

.upload-icon {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    margin-bottom: 18px;
    color: #dce2ff;
    background: linear-gradient(135deg, rgba(91,108,255,.20), rgba(125,92,255,.16));
    border: 1px solid rgba(255,255,255,.07);
}

.upload-icon svg { width: 30px; height: 30px; }

.dropzone-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -.03em;
}

.dropzone-subtitle {
    margin-top: 6px;
    color: var(--muted);
    font-size: .97rem;
}

.dropzone-meta {
    margin-top: 16px;
    color: #6f7c92;
    font-size: .86rem;
}

.file-bar {
    margin-top: 14px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: 16px;
    background: rgba(255,255,255,.035);
    border: 1px solid var(--line);
}

.file-info {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-thumb-wrap {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--card-2);
}

.file-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.file-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-copy span {
    color: var(--muted);
    font-size: .88rem;
}

.icon-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.04);
    color: #dce2ef;
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
}

.actions {
    margin-top: 16px;
    display: flex;
}

.btn {
    appearance: none;
    min-height: 46px;
    border: 0;
    border-radius: 13px;
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    transition: transform .18s ease, opacity .18s ease, background .18s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 12px 28px rgba(91,108,255,.24);
}

.btn-ghost {
    color: #eef2ff;
    background: rgba(255,255,255,.045);
    border: 1px solid var(--line);
}

.btn-large {
    width: 100%;
    min-height: 52px;
}

.feedback {
    margin-top: 14px;
    padding: 13px 15px;
    border-radius: 13px;
    font-weight: 700;
    font-size: .94rem;
}

.feedback-error {
    color: #ffd9e0;
    background: rgba(255,109,130,.10);
    border: 1px solid rgba(255,109,130,.22);
}

.feedback-success {
    color: #d7fff0;
    background: rgba(46,211,154,.10);
    border: 1px solid rgba(46,211,154,.20);
}

.processing-card,
.result-card {
    padding: 24px;
}

.processing-header,
.result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.eyebrow {
    display: block;
    margin-bottom: 6px;
    color: #75839b;
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .13em;
}

.processing-header h2,
.result-header h2 {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: -.03em;
}

.spinner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,.08);
    border-top-color: var(--primary);
    animation: spin .9s linear infinite;
}

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

.loading-panel,
.comparison-panel {
    padding: 12px;
    border-radius: 18px;
    background: var(--card-2);
    border: 1px solid var(--line);
}

.skeleton-label,
.skeleton-image {
    position: relative;
    overflow: hidden;
    background: rgba(255,255,255,.055);
}

.skeleton-label {
    width: 76px;
    height: 24px;
    border-radius: 999px;
    margin-bottom: 10px;
}

.skeleton-image {
    aspect-ratio: 4 / 3;
    border-radius: 13px;
}

.skeleton-label::after,
.skeleton-image::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.12), transparent);
    animation: shimmer 1.4s infinite;
}

.progress-track {
    height: 8px;
    margin-top: 18px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,.055);
}

.progress-track span {
    display: block;
    width: 30%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    animation: progress 1.7s ease-in-out infinite;
}

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

.comparison-top {
    margin-bottom: 10px;
}

.comparison-top span {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    color: #cfd7e6;
    background: rgba(255,255,255,.055);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .09em;
}

.comparison-top-success span {
    color: #d7fff0;
    background: rgba(46,211,154,.12);
}

.image-frame {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 14px;
    background: #060b13;
}

.image-frame img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

[hidden] { display: none !important; }

@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes progress { 0% { transform: translateX(-120%); } 100% { transform: translateX(430%); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
    .loading-grid,
    .comparison-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .app-shell {
        width: min(100% - 18px, 1180px);
        padding-top: 12px;
    }

    .topbar {
        min-height: 56px;
    }

    .brand strong {
        font-size: .94rem;
    }

    .uploader-card,
    .processing-card,
    .result-card {
        padding: 16px;
    }

    .dropzone {
        min-height: 300px;
    }

    .processing-header,
    .result-header {
        flex-direction: column;
        align-items: stretch;
    }

    .result-actions {
        width: 100%;
    }

    .result-actions .btn {
        flex: 1 1 0;
    }
}
