*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0d0d12;
    --surface: #16161f;
    --surface2: #1e1e2a;
    --border: #2a2a3a;
    --text: #f0f0f8;
    --muted: #8888aa;
    --purple: #7c3aed;
    --purple-light: #a855f7;
    --pink: #db2777;
    --radius: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background glow effect */
.bg-glow {
    position: fixed;
    top: -300px;
    left: 50%;
    transform: translateX(-50%);
    width: 900px;
    height: 600px;
    background: radial-gradient(ellipse, rgba(124,58,237,0.1) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 780px;
    margin: 0 auto;
    padding: 48px 20px 80px;
    position: relative;
    z-index: 1;
}

/* ── Header ───────────────────────────────────────── */
header {
    text-align: center;
    margin-bottom: 36px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 1.8rem;
    font-weight: 300;
    letter-spacing: -0.5px;
    margin-bottom: 10px;
}

.logo strong { font-weight: 700; }

.logo-icon {
    display: flex;
    align-items: center;
}

.tagline {
    color: var(--muted);
    font-size: 0.95rem;
}

/* ── Backend status badge ─────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-loading {
    background: rgba(124,58,237,0.08);
    border-color: rgba(124,58,237,0.2);
    color: #a78bfa;
}
.status-loading .status-dot {
    background: #a78bfa;
    animation: pulse 1.2s ease-in-out infinite;
}

.status-ready {
    background: rgba(34,197,94,0.08);
    border-color: rgba(34,197,94,0.2);
    color: #4ade80;
}
.status-ready .status-dot { background: #4ade80; }

.status-offline {
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.2);
    color: #f87171;
}
.status-offline .status-dot { background: #f87171; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ── Upload Zone ──────────────────────────────────── */
.upload-zone {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 56px 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 24px;
}

.upload-zone:hover, .upload-zone.dragging {
    border-color: var(--purple);
    background: rgba(124,58,237,0.05);
}

.upload-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.upload-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.upload-sub {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.upload-link {
    color: var(--purple-light);
    font-weight: 500;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--muted);
    opacity: 0.7;
}

/* ── Preview section ──────────────────────────────── */
.preview-section {
    margin-bottom: 24px;
}

.preview-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.preview-col {
    flex: 1;
    min-width: 160px;
}

.preview-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 10px;
    text-align: center;
}

.img-wrap {
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface2);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Checkerboard pattern for transparent result */
.img-wrap.checker {
    background-image:
        linear-gradient(45deg, #1e1e2a 25%, transparent 25%),
        linear-gradient(-45deg, #1e1e2a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1e1e2a 75%),
        linear-gradient(-45deg, transparent 75%, #1e1e2a 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #13131c;
}

.result-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
}

.processing-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 0.85rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(124,58,237,0.2);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.preview-divider {
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Error Banner ─────────────────────────────────── */
.error-banner {
    background: rgba(220,38,38,0.1);
    border: 1px solid rgba(220,38,38,0.25);
    color: #f87171;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.88rem;
    margin-bottom: 16px;
}

/* ── Buttons ──────────────────────────────────────── */
.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border: none;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:active  { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: white;
    flex: 1;
    justify-content: center;
    min-width: 180px;
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-secondary {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-secondary:hover {
    border-color: var(--purple);
    color: var(--purple-light);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover {
    color: var(--text);
    border-color: var(--muted);
}

/* ── Features ─────────────────────────────────────── */
.features {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feature {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}

.feature-icon { font-size: 1.3rem; flex-shrink: 0; }

.feature strong {
    display: block;
    font-size: 0.88rem;
    margin-bottom: 2px;
}

.feature p {
    font-size: 0.8rem;
    color: var(--muted);
}

/* ── Footer ───────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 1.5rem 0 0.5rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.site-footer strong {
    color: #a78bfa;
}

/* ── Utilities ────────────────────────────────────── */
.hidden { display: none !important; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.preview-section:not(.hidden) {
    animation: fadeIn 0.3s ease;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 500px) {
    .preview-divider { width: 100%; justify-content: center; }
    .logo { font-size: 1.4rem; }
}