:root {
    --bg-base:      #0d0f1a;
    --bg-surface:   #141728;
    --bg-card:      #1a1e30;
    --bg-input:     #0f1120;
    --accent:       #6c63ff;
    --accent-light: #8b85ff;
    --accent-glow:  rgba(108, 99, 255, 0.35);
    --success:      #22c55e;
    --warning:      #f59e0b;
    --danger:       #ef4444;
    --text-primary: #e8eaf6;
    --text-muted:   #7b82a3;
    --text-dim:     #4a5068;
    --border:       rgba(108, 99, 255, 0.18);
    --border-hover: rgba(108, 99, 255, 0.45);
    --radius:       14px;
    --radius-sm:    8px;
    --shadow:       0 4px 24px rgba(0,0,0,0.45);
    --font:         'Inter', system-ui, sans-serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse 80% 50% at 20% 10%, rgba(108,99,255,0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 90%, rgba(139,133,255,0.06) 0%, transparent 60%);
}

a { color: var(--accent-light); text-decoration: none; }

/* ── Header ─────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 2rem;
    background: rgba(20, 23, 40, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}

.header-logo {
    display: flex; align-items: center; gap: 0.75rem;
    font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em;
}

.header-logo svg { color: var(--accent); }

.header-nav { display: flex; align-items: center; gap: 0.75rem; }

.lang-switcher { display: flex; gap: 0.2rem; align-items: center; }

.lang-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem 0.25rem;
    opacity: 0.45;
    transition: opacity 0.15s, border-color 0.15s, transform 0.1s;
    display: flex;
    align-items: center;
}

.lang-btn img {
    display: block;
    border-radius: 3px;
    object-fit: cover;
}

.lang-btn:hover { opacity: 0.85; transform: scale(1.08); }

.lang-btn.active {
    opacity: 1;
    border-color: var(--border-hover);
    background: rgba(108, 99, 255, 0.12);
}

/* ── Layout ──────────────────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ── Cards ───────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    transition: border-color 0.2s;
}

.card:hover { border-color: var(--border-hover); }

.card-title {
    display: flex; align-items: center; gap: 0.6rem;
    font-size: 0.85rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin-bottom: 1.25rem;
}

.card-title span { font-size: 1rem; }

/* ── Form elements ───────────────────────────────── */
.form-group { margin-bottom: 1rem; }

label {
    display: block;
    font-size: 0.82rem; font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    letter-spacing: 0.02em;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
select,
textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.92rem;
    padding: 0.65rem 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select { cursor: pointer; }
select option { background: var(--bg-card); }

textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ──────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1.3rem;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-family: var(--font); font-size: 0.88rem; font-weight: 600;
    transition: all 0.2s; letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 20px var(--accent-glow);
}
.btn-primary:hover {
    background: var(--accent-light);
    box-shadow: 0 0 30px rgba(108,99,255,0.55);
    transform: translateY(-1px);
}

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

.btn-lg {
    padding: 0.85rem 2.5rem;
    font-size: 1rem;
    border-radius: var(--radius);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Project selector ─────────────────────────────── */
.project-selector {
    display: flex; gap: 1rem; align-items: flex-end;
    margin-bottom: 1.5rem;
}
.project-selector .form-group { flex: 1; margin: 0; }

/* ── Image upload ─────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(108,99,255,0.05);
}

.upload-zone input[type="file"] {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.upload-label {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    pointer-events: none;
}

.upload-icon { font-size: 2rem; }

.upload-hint {
    font-size: 0.78rem; color: var(--text-dim);
}

/* ── Icon preview grid ────────────────────────────── */
.icon-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.icon-preview-item {
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
    font-size: 0.65rem; color: var(--text-dim);
}

.icon-preview-item img {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff1;
}

/* ── Image placeholder ────────────────────────────── */
.img-placeholder-row {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.85rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.img-thumb {
    width: 52px; height: 52px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-surface);
}

.img-placeholder-info { flex: 1; }

.img-placeholder-info strong { font-size: 0.87rem; display: block; }
.img-placeholder-info small { color: var(--text-dim); font-size: 0.75rem; }

/* ── Build button area ────────────────────────────── */
.build-area {
    text-align: center;
    padding: 0.5rem 0 1rem;
}

/* ── Progress ─────────────────────────────────────── */
.progress-card { display: none; }
.progress-card.visible { display: block; }

.stages {
    display: flex; justify-content: space-between;
    margin-bottom: 1.25rem;
    position: relative;
}

.stages::before {
    content: '';
    position: absolute; top: 18px; left: 18px; right: 18px; height: 2px;
    background: var(--bg-input); z-index: 0;
}

.stage {
    display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
    font-size: 0.72rem; color: var(--text-dim);
    z-index: 1;
}

.stage-dot {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    transition: all 0.4s;
}

.stage.active .stage-dot {
    border-color: var(--accent);
    background: var(--accent-glow);
    animation: pulse 1.5s infinite;
}

.stage.done .stage-dot {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.stage.failed .stage-dot {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.stage.active { color: var(--accent-light); }
.stage.done   { color: var(--success); }
.stage.failed { color: var(--danger); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50%       { box-shadow: 0 0 0 8px transparent; }
}

.progress-bar-wrap {
    height: 6px; background: var(--bg-input);
    border-radius: 99px; overflow: hidden;
    margin-bottom: 1.25rem;
}

.progress-bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 99px;
    transition: width 0.5s ease;
}

/* ── Log terminal ─────────────────────────────────── */
.log-terminal {
    background: #080a12;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.76rem;
    line-height: 1.6;
    height: 280px;
    overflow-y: auto;
    color: #c8e6c9;
}

.log-line { display: block; }
.log-line.err { color: #ef9a9a; }
.log-line.warn { color: #fff176; }
.log-line.info { color: #90caf9; }

/* ── Download button ──────────────────────────────── */
.download-area {
    display: none;
    text-align: center;
    padding: 1rem 0;
}

.download-area.visible { display: block; }

.download-btn {
    display: inline-flex; align-items: center; gap: 0.6rem;
    padding: 1rem 2.5rem;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff; border-radius: var(--radius);
    font-weight: 700; font-size: 1rem;
    box-shadow: 0 0 30px rgba(34,197,94,0.35);
    animation: glow-pulse 2s infinite;
    transition: transform 0.2s;
}

.download-btn:hover { transform: scale(1.04); color: #fff; }

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(34,197,94,0.35); }
    50%       { box-shadow: 0 0 40px rgba(34,197,94,0.6); }
}

/* ── Toast ────────────────────────────────────────── */
.toast-container {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    display: flex; flex-direction: column; gap: 0.5rem;
    z-index: 1000;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500;
    animation: slide-in 0.3s ease;
    max-width: 320px;
}

.toast.success { background: #166534; border: 1px solid #22c55e; color: #bbf7d0; }
.toast.error   { background: #7f1d1d; border: 1px solid #ef4444; color: #fecaca; }
.toast.info    { background: #1e3a5f; border: 1px solid #3b82f6; color: #bfdbfe; }

@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Admin link ───────────────────────────────────── */
.admin-badge {
    font-size: 0.75rem; padding: 0.3rem 0.75rem;
    border-radius: 99px;
    background: rgba(108,99,255,0.15);
    border: 1px solid var(--border);
    color: var(--accent-light);
    cursor: pointer;
    transition: all 0.2s;
}
.admin-badge:hover { background: rgba(108,99,255,0.3); }

/* ── Spinner ──────────────────────────────────────── */
.spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

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

/* ── Empty state ──────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-dim);
}

.empty-state svg { opacity: 0.3; margin-bottom: 1rem; }

/* ── Token modal ──────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 420px; max-width: 95vw;
    box-shadow: var(--shadow);
    animation: modal-in 0.25s ease;
}

@keyframes modal-in {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.modal h2 {
    font-size: 1.1rem; margin-bottom: 0.4rem;
}

.modal p {
    font-size: 0.83rem; color: var(--text-muted); margin-bottom: 1.25rem;
}

/* ── Divider ──────────────────────────────────────── */
.divider {
    height: 1px; background: var(--border);
    margin: 1.25rem 0;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 600px) {
    .stages { flex-wrap: wrap; gap: 1rem; }
    .stages::before { display: none; }
    .project-selector { flex-direction: column; }
}
