:root {
    --bg: #0a0a0f;
    --surface: #13131a;
    --surface2: #1c1c28;
    --border: #2a2a3d;
    --accent: #7c3aed;
    --accent2: #a855f7;
    --text: #e2e8f0;
    --muted: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Header ── */
header {
    background: linear-gradient(135deg, #1a0533 0%, #0d0d1a 100%);
    border-bottom: 1px solid var(--border);
    padding: 1.2rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
header .logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}
header p { color: var(--muted); font-size: 0.85rem; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 768px) { .grid { grid-template-columns: 1fr; } }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--accent2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Drop Zone ── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.05);
}
.drop-zone input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-zone .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.drop-zone p { color: var(--muted); font-size: 0.9rem; }
.drop-zone .preview {
    max-width: 100%; max-height: 280px; border-radius: 8px;
    object-fit: contain; display: none;
}

/* ── Tabs ── */
.tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.tab-btn {
    padding: 0.45rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn.active, .tab-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Form Elements ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.4rem; }
.form-group select,
.form-group input[type=text],
.form-group textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }

.range-wrap { display: flex; align-items: center; gap: 0.8rem; }
input[type=range] { flex: 1; accent-color: var(--accent); }
.range-val { font-size: 0.85rem; color: var(--accent2); min-width: 2.5rem; text-align: right; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.7rem 1.4rem;
    border-radius: 8px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    width: 100%;
    justify-content: center;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent2); }

/* ── Result Panel ── */
.result-panel {
    grid-column: 1 / -1;
    display: none;
}
.result-panel.show { display: block; }
.result-img-wrap {
    position: relative;
    background: var(--surface2);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.result-img-wrap img {
    max-width: 100%; max-height: 600px;
    object-fit: contain;
    border-radius: var(--radius);
}
.result-actions { display: flex; gap: 0.8rem; margin-top: 1rem; flex-wrap: wrap; }

/* ── Progress ── */
.progress-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(4px);
}
.progress-overlay.show { display: flex; }
.progress-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 3rem;
    text-align: center;
    min-width: 280px;
}
.spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1.2rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-box p { color: var(--muted); font-size: 0.9rem; margin-top: 0.5rem; }

/* ── Toast ── */
.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); color: #fff; }
.toast.error   { background: var(--error);   color: #fff; }

/* ── History ── */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}
.history-item {
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    aspect-ratio: 1;
    background: var(--surface2);
}
.history-item:hover { border-color: var(--accent); }
.history-item img { width: 100%; height: 100%; object-fit: cover; }

/* ── Badge ── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(124,58,237,0.2);
    color: var(--accent2);
    border: 1px solid rgba(124,58,237,0.3);
}
