:root {
    --bg: #0b0d12;
    --panel: #141926;
    --panel-soft: #1a2134;
    --text: #edf2ff;
    --muted: #98a3bf;
    --primary: #7f5cff;
    --primary-strong: #6b45ff;
    --danger: #f04363;
    --success: #3ccf91;
    --border: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: radial-gradient(circle at top, #18213a 0, #0b0d12 40%);
    color: var(--text);
    font-family: Inter, sans-serif;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: rgba(11, 13, 18, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand { color: var(--text); text-decoration: none; display: flex; gap: 8px; align-items: center; }
.brand-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--primary); box-shadow: 0 0 18px var(--primary); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.pill { padding: 6px 10px; border-radius: 999px; background: var(--panel-soft); color: var(--muted); }

.main { padding: 24px; }
.card {
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { background: var(--panel-soft); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }

.muted { color: var(--muted); }
.alert { margin: 12px 0; padding: 10px 14px; border-radius: 10px; }
.alert-error { background: rgba(240,67,99,0.14); border: 1px solid rgba(240,67,99,0.3); }
.alert-success { background: rgba(60,207,145,0.14); border: 1px solid rgba(60,207,145,0.3); }

.centered { min-height: calc(100vh - 140px); display: grid; place-items: center; }
.login-card { width: min(460px, 94vw); padding: 24px; }
.form { display: grid; gap: 10px; margin-top: 14px; }
input {
    background: #0f1421;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 11px;
}
textarea {
    background: #0f1421;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 11px;
    font-family: Inter, sans-serif;
}

.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.new-project { display: flex; gap: 8px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { overflow: hidden; }
.thumb { width: 100%; height: 210px; object-fit: cover; display: block; border-bottom: 1px solid var(--border); }
.thumb-empty { height: 210px; display: grid; place-items: center; color: var(--muted); background: #101626; border-bottom: 1px solid var(--border); }
.project-meta { padding: 14px 14px 8px; }
.project-actions { padding: 0 14px 14px; display: flex; gap: 8px; }
.empty-state { padding: 20px; }

.editor-layout { display: grid; grid-template-columns: 320px 1fr 340px; gap: 14px; align-items: start; }
.panel { padding: 14px; position: sticky; top: 78px; max-height: calc(100vh - 100px); overflow: auto; }
.tools-panel { display: grid; gap: 10px; }
.canvas-panel { padding: 14px; }
.canvas-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.canvas-actions { display: flex; gap: 8px; }
.canvas-wrap { margin-top: 12px; overflow: auto; background: #fff; border-radius: 8px; border: 1px solid var(--border); max-height: 72vh; }
.canvas-wrap canvas { display: block; margin: 0 auto; }
.drop-zone { border: 1px dashed var(--border); border-radius: 10px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.drop-zone.drag { border-color: var(--primary); color: var(--text); }
.color-palette { display: flex; flex-wrap: wrap; gap: 8px; }
.color-chip { width: 28px; height: 28px; border-radius: 999px; border: 2px solid rgba(255,255,255,0.24); cursor: pointer; }
.template-list { display: grid; gap: 8px; }
.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ai-brief { min-height: 100px; resize: vertical; }
.ai-actions { display: grid; gap: 8px; }
.ai-generate-main { position: relative; font-size: 15px; padding: 12px 16px; }
.ai-spark { margin-right: 6px; font-size: 16px; }
.ai-generate-main:disabled { opacity: .5; cursor: wait; }

.ai-creatives { display: grid; gap: 14px; }
.ai-creative-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255,255,255,0.03);
    transition: box-shadow .2s;
}
.ai-creative-card:hover { box-shadow: 0 0 20px rgba(127,92,255,.15); }
.ai-creative-img-wrap {
    width: 100%;
    aspect-ratio: 1;
    background: var(--panel-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ai-creative-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ai-creative-skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
}
.ai-pulse {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    animation: aiPulse 1.4s ease-in-out infinite;
}
@keyframes aiPulse {
    0%, 100% { transform: scale(.8); opacity: .4; }
    50% { transform: scale(1.2); opacity: 1; }
}
.ai-creative-error {
    color: var(--danger);
    font-size: 12px;
    padding: 16px;
    text-align: center;
}
.ai-creative-meta {
    padding: 10px 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ai-creative-meta strong { font-size: 13px; }
.ai-creative-style { font-size: 11px; color: var(--muted); }
.ai-creative-actions {
    padding: 8px 12px 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.ai-creative-actions .btn { font-size: 12px; padding: 8px 10px; }

.ai-empty { border: 1px dashed var(--border); border-radius: 10px; padding: 16px; text-align: center; font-size: 13px; }

.asset-item { position: relative; }
.asset-item.asset-selected { outline: 3px solid var(--primary); outline-offset: -2px; border-radius: 8px; }
.asset-item.asset-selected::after {
    content: "✓";
    position: absolute;
    top: 2px;
    right: 4px;
    background: var(--primary);
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}
.assets-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.asset-item { border: 0; border-radius: 8px; overflow: hidden; padding: 0; cursor: pointer; }
.asset-item img { width: 100%; height: 76px; object-fit: cover; display: block; }
.format-list h4 { margin: 14px 0 6px; }
.format-row { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.preview-box {
    width: 100%;
    height: 80px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0f1421 center/contain no-repeat;
    margin-bottom: 10px;
}

@media (max-width: 1400px) {
    .editor-layout { grid-template-columns: 1fr; }
    .panel { position: static; max-height: none; }
}
