@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
    --color-primary: #7C3AED;
    --color-primary-dark: #6425d0;
    --color-on-primary: #FFFFFF;
    --color-secondary: #6366F1;
    --color-accent: #EC4899;
    --color-background: #FAF5FF;
    --color-surface: #FFFFFF;
    --color-foreground: #0F172A;
    --color-muted-fg: #64748B;
    --color-muted: #F7F3FD;
    --color-border: #EFE7FC;
    --color-success: #16A34A;
    --color-success-bg: #F0FDF4;
    --color-destructive: #DC2626;
    --color-destructive-bg: #FEF2F2;
    --color-warning: #D97706;
    --color-warning-bg: #FFFBEB;
    --color-ring: #7C3AED;

    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
    --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;

    --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-full: 999px;
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 8px rgba(15, 23, 42, 0.04);
    --font-display: 'Space Grotesk', 'DM Sans', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-background: #120B22;
        --color-surface: #1B1230;
        --color-foreground: #F1EAFE;
        --color-muted-fg: #B4A6D6;
        --color-muted: #241A3B;
        --color-border: #33254F;
        --color-success-bg: #0F2A1A;
        --color-destructive-bg: #2C1518;
        --color-warning-bg: #2B2110;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--color-background);
    color: var(--color-foreground);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100dvh;
}
h1, h2, h3, h4, .font-display { font-family: var(--font-display); font-weight: 600; line-height: 1.25; margin: 0; }
p { margin: 0 0 var(--space-3); color: var(--color-muted-fg); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; display: block; }
button { font-family: inherit; }

*:focus-visible {
    outline: 2px solid var(--color-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--space-5); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    padding: 11px 20px; border-radius: var(--radius-md); border: 1px solid transparent;
    font-weight: 600; font-size: 15px; cursor: pointer; transition: background-color 180ms ease, border-color 180ms ease, opacity 180ms ease;
    min-height: 44px; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-secondary { background: var(--color-surface); color: var(--color-foreground); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-muted); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--color-foreground); }
.btn-ghost:hover { background: var(--color-muted); text-decoration: none; }
.btn-danger { background: var(--color-destructive-bg); color: var(--color-destructive); }
.btn-danger:hover { opacity: 0.85; text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { padding: 10px; min-width: 44px; }

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: var(--space-5);
}

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: var(--space-2); }
.field { margin-bottom: var(--space-4); }
.hint { font-size: 13px; color: var(--color-muted-fg); margin-top: var(--space-2); }
.error-text { font-size: 13px; color: var(--color-destructive); margin-top: var(--space-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
textarea, select {
    width: 100%; padding: 12px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-surface); color: var(--color-foreground); font-size: 16px; font-family: inherit;
    min-height: 44px; transition: border-color 150ms ease;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(124,58,237,0.15); }
.select-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.select-card {
    border: 2px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4);
    cursor: pointer; text-align: center; background: var(--color-surface); transition: border-color 150ms ease, background 150ms ease;
}
.select-card input { position: absolute; opacity: 0; pointer-events: none; }
.select-card.is-checked { border-color: var(--color-primary); background: var(--color-muted); }
.select-card .icon-circle { margin: 0 auto var(--space-3); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-full);
    font-size: 13px; font-weight: 600;
}
.badge-queued { background: var(--color-muted); color: var(--color-muted-fg); }
.badge-processing { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-completed { background: var(--color-success-bg); color: var(--color-success); }
.badge-failed { background: var(--color-destructive-bg); color: var(--color-destructive); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.icon-circle {
    width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center;
    background: var(--color-muted); color: var(--color-primary); flex-shrink: 0;
}
.icon-circle svg { width: 22px; height: 22px; }
.icon-circle.lg { width: 56px; height: 56px; border-radius: var(--radius-lg); }
.icon-circle.lg svg { width: 28px; height: 28px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100dvh; }
.sidebar {
    width: 260px; flex-shrink: 0; background: var(--color-surface); border-right: 1px solid var(--color-border);
    padding: var(--space-5) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2);
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-5); }
.sidebar-brand .logo-mark {
    width: 36px; height: 36px; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-family: var(--font-display);
}
.nav-link {
    display: flex; align-items: center; gap: var(--space-3); padding: 11px 14px; border-radius: var(--radius-md);
    color: var(--color-foreground); font-weight: 500; font-size: 15px; transition: background 150ms ease;
}
.nav-link:hover { background: var(--color-muted); text-decoration: none; }
.nav-link.is-active { background: var(--color-muted); color: var(--color-primary); font-weight: 700; }
.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted-fg); padding: var(--space-4) 14px 6px; font-weight: 700; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--color-border); padding-top: var(--space-4); }
.user-chip { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); border-radius: var(--radius-md); }
.avatar {
    width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.main-content { flex: 1; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
    padding: var(--space-5); border-bottom: 1px solid var(--color-border); background: var(--color-surface);
    position: sticky; top: 0; z-index: 10;
}
.page-body { padding: var(--space-6) var(--space-5); max-width: 1200px; }
.sidebar-toggle { display: none; }

@media (max-width: 900px) {
    .sidebar { position: fixed; z-index: 40; left: 0; transform: translateX(-100%); transition: transform 220ms ease; box-shadow: 0 0 0 100vmax rgba(0,0,0,0); }
    .sidebar.is-open { transform: translateX(0); box-shadow: 20px 0 60px rgba(15,23,42,0.25); }
    .sidebar-toggle { display: inline-flex; }
    .page-body { padding: var(--space-5) var(--space-4); }
    .topbar { padding: var(--space-4); }
}

/* ---------- Grid helpers ---------- */
.grid { display: grid; gap: var(--space-5); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; } }

.stat-card { display: flex; align-items: center; gap: var(--space-4); }
.stat-card .value { font-family: var(--font-display); font-size: 28px; font-weight: 700; }

/* ---------- Project card ---------- */
.project-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.project-thumb {
    aspect-ratio: 16/9; background: var(--color-muted); position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: center; color: var(--color-muted-fg);
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-card-body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.project-card-footer { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-4) var(--space-4); }

.progress-track { height: 8px; border-radius: var(--radius-full); background: var(--color-muted); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--color-primary), var(--color-accent)); border-radius: var(--radius-full); transition: width 400ms ease; }

.tabs { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-5); overflow-x: auto; }
.tab { padding: 12px 6px; margin-right: var(--space-5); font-weight: 600; color: var(--color-muted-fg); border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; }
.tab.is-active { color: var(--color-primary); border-color: var(--color-primary); }

.empty-state { text-align: center; padding: var(--space-8) var(--space-5); color: var(--color-muted-fg); }

/* ---------- Auth pages ---------- */
.auth-shell { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); background: radial-gradient(circle at top, #F3E8FF 0%, var(--color-background) 60%); }
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-bottom: var(--space-6); }

/* ---------- Landing page ---------- */
.nav-public { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) 0; }
.hero { padding: var(--space-8) 0 var(--space-7); text-align: center; }
.hero h1 { font-size: clamp(32px, 5vw, 56px); max-width: 780px; margin: 0 auto var(--space-5); }
.hero .lead { font-size: 19px; max-width: 620px; margin: 0 auto var(--space-6); }
.hero-actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; margin-bottom: var(--space-7); }
.badge-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--color-muted); color: var(--color-primary); padding: 6px 16px; border-radius: var(--radius-full); font-weight: 600; font-size: 13px; margin-bottom: var(--space-5); }
.feature-card { display: flex; flex-direction: column; gap: var(--space-3); }
.section { padding: var(--space-7) 0; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto var(--space-6); }
footer.site-footer { border-top: 1px solid var(--color-border); padding: var(--space-6) 0; text-align: center; color: var(--color-muted-fg); font-size: 14px; }

/* ---------- Narration preview (edu video) ---------- */
.narration-stage {
    aspect-ratio: 16/9; border-radius: var(--radius-lg); background: linear-gradient(135deg, #1B1230, #3B1F63);
    position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: var(--space-5); color: #fff;
}
.narration-avatar {
    position: absolute; bottom: var(--space-5); right: var(--space-5); width: 96px; height: 96px; border-radius: 50%;
    background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.3); display: flex; align-items: center; justify-content: center;
}
.narration-avatar.speaking { animation: speak 900ms ease-in-out infinite; }
@keyframes speak { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.narration-caption { background: rgba(0,0,0,0.45); backdrop-filter: blur(4px); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); max-width: 80%; font-size: 15px; }

/* ---------- Ken burns (image-to-video preview) ---------- */
.kenburns-stage { aspect-ratio: 16/9; border-radius: var(--radius-lg); overflow: hidden; background: var(--color-muted); position: relative; }
.kenburns-stage img { width: 100%; height: 100%; object-fit: cover; animation: kenburns 8s ease-in-out infinite alternate; }
@keyframes kenburns { from { transform: scale(1) translate(0,0); } to { transform: scale(1.12) translate(-1.5%, -1.5%); } }

.dropzone {
    border: 2px dashed var(--color-border); border-radius: var(--radius-lg); padding: var(--space-7) var(--space-5);
    text-align: center; cursor: pointer; transition: border-color 150ms ease, background 150ms ease;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--color-primary); background: var(--color-muted); }
.dropzone input { display: none; }

.alert { padding: var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-5); font-size: 14px; font-weight: 500; }
.alert-error { background: var(--color-destructive-bg); color: var(--color-destructive); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
