/* ==========================================================================
   Mg edits AI Video Studio — Design System v2
   Clean, modern, intuitive. Single source of truth for all pages.
   ========================================================================== */

/* --- Design Tokens -------------------------------------------------------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  --space-section: 80px;

  --container-max: 1200px;
  --container-narrow: 800px;
  --nav-height: 64px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-base: 220ms;
  --duration-slow: 350ms;

  --z-sticky: 100;
  --z-nav: 300;
  --z-drawer: 310;
  --z-modal: 350;
  --z-toast: 400;
}

/* --- Theme Tokens --------------------------------------------------------- */
:root, [data-theme="dark"] {
  --bg: #0a0a12;
  --bg-surface: #12121e;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222240;
  --bg-input: #16162a;
  --bg-overlay: rgba(10, 10, 18, 0.92);

  --text: #f0f0f5;
  --text-secondary: #9898b0;
  --text-muted: #6a6a82;
  --text-inverse: #0a0a12;

  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(139, 92, 246, 0.5);

  --brand: #8b5cf6;
  --brand-hover: #7c3aed;
  --brand-text: #a78bfa;
  --brand-wash: rgba(139, 92, 246, 0.12);
  --brand-glow: 0 0 20px rgba(139, 92, 246, 0.2);

  --success: #34d399;
  --success-wash: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-wash: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-wash: rgba(248, 113, 113, 0.12);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.5);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f5f5fa;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f8fc;
  --bg-input: #f0f0f5;
  --bg-overlay: rgba(255, 255, 255, 0.95);

  --text: #1a1a2e;
  --text-secondary: #555570;
  --text-muted: #8888a0;
  --text-inverse: #ffffff;

  --border: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --brand: #6366f1;
  --brand-hover: #4f46e5;
  --brand-text: #4f46e5;
  --brand-wash: rgba(99, 102, 241, 0.08);

  --success: #16a36a;
  --success-wash: rgba(22, 163, 106, 0.08);
  --warning: #c58a20;
  --warning-wash: rgba(197, 138, 32, 0.08);
  --danger: #dc5363;
  --danger-wash: rgba(220, 83, 99, 0.08);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);

  color-scheme: light;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--duration-base), color var(--duration-base);
}

body.app-page { background: var(--bg-surface); }

a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

.hidden { display: none !important; }

/* --- Skip Link ----------------------------------------------------------- */
.skip-link {
  position: absolute; top: -100%; left: var(--space-md);
  background: var(--brand); color: #fff; padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm); z-index: 9999; font-weight: 600;
}
.skip-link:focus { top: var(--space-xs); }

/* --- Container ----------------------------------------------------------- */
.container { max-width: var(--container-max); margin: 0 auto; padding: 0 var(--space-lg); width: 100%; }
.container-narrow { max-width: var(--container-narrow); }

/* ==========================================================================
   NAVIGATION
   ========================================================================== */
.global-nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  background: var(--bg-overlay);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
}

.global-nav > .container {
  display: flex; align-items: center; height: 100%; gap: var(--space-lg);
}

.brand-group {
  display: flex; align-items: center; gap: var(--space-xs);
  flex-shrink: 0;
}

.brand {
  display: flex; align-items: center; gap: var(--space-xs);
  font-weight: 700; font-size: 17px; color: var(--text);
  text-decoration: none;
}
.brand svg { width: 28px; height: 28px; fill: var(--brand); }

.brand-sub {
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  padding: 2px 8px; background: var(--brand-wash);
  border-radius: var(--radius-pill);
}

/* Desktop nav links */
.nav-links {
  display: flex; align-items: center; gap: var(--space-xxs);
  margin-left: auto;
}

.global-nav-link {
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  text-decoration: none; transition: all var(--duration-fast);
  white-space: nowrap;
}
.global-nav-link:hover { color: var(--text); background: var(--brand-wash); text-decoration: none; }
.global-nav-link.active { color: var(--brand); background: var(--brand-wash); }

/* Nav actions */
.nav-actions {
  display: flex; align-items: center; gap: var(--space-xs);
  flex-shrink: 0;
}

/* Language selector */
.lang-selector-select {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 5px 8px;
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
  outline: none;
}
.lang-selector-select:focus { border-color: var(--border-focus); }

/* Theme toggle */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-secondary);
  cursor: pointer; transition: all var(--duration-fast);
}
.icon-btn:hover { background: var(--brand-wash); color: var(--text); }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 32px; height: 32px; }
.icon-sprite { display: none; }

/* Mobile nav button */
.mobile-only { display: none; }

/* Mobile drawer */
.mobile-nav {
  position: fixed; top: var(--nav-height); left: 0; right: 0; bottom: 0;
  background: var(--bg-overlay); backdrop-filter: blur(20px);
  z-index: var(--z-drawer); padding: var(--space-lg);
  transform: translateX(-100%); transition: transform var(--duration-slow) var(--ease-out);
  overflow-y: auto;
}
.mobile-nav.is-open { transform: translateX(0); }

.mobile-nav-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-muted);
  padding: var(--space-xs) 0; margin-top: var(--space-md);
}

.mobile-nav-link {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 10px var(--space-sm); border-radius: var(--radius-sm);
  font-size: 15px; color: var(--text-secondary); text-decoration: none;
  transition: all var(--duration-fast);
}
.mobile-nav-link:hover, .mobile-nav-link.active {
  color: var(--text); background: var(--brand-wash); text-decoration: none;
}

.mobile-nav-divider { height: 1px; background: var(--border); margin: var(--space-md) 0; }

.mobile-nav-cta { padding: var(--space-md) 0; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; line-height: 1;
  border: none; cursor: pointer; transition: all var(--duration-fast);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn-primary {
  background: var(--brand); color: #fff;
  box-shadow: var(--brand-glow);
}
.btn-primary:hover { background: var(--brand-hover); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

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

.btn-block { width: 100%; }

.btn .icon { width: 16px; height: 16px; }

/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: all var(--duration-base);
}

.card:hover { border-color: rgba(139, 92, 246, 0.15); }

.card-title {
  font-size: 17px; font-weight: 600; color: var(--text);
  margin-bottom: var(--space-xs);
}

.card-link { cursor: pointer; text-decoration: none; color: inherit; display: block; }
.card-link:hover { text-decoration: none; }

/* ==========================================================================
   BADGES & STATUS
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
}
.badge-solid { background: var(--brand); color: #fff; }
.badge-outline { background: var(--brand-wash); color: var(--brand-text); border: 1px solid var(--border); }
.badge-success { background: var(--success-wash); color: var(--success); }
.badge-warning { background: var(--warning-wash); color: var(--warning); }
.badge-danger { background: var(--danger-wash); color: var(--danger); }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500;
}
.status-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); animation: pulse-dot 2s infinite;
}
.status-badge.is-ready .dot { background: var(--success); }
.status-badge.is-running .dot { background: var(--warning); }
.status-badge.is-error .dot { background: var(--danger); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==========================================================================
   FORMS
   ========================================================================== */
.field { margin-bottom: var(--space-md); }

.label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: var(--space-xxs);
}

.input, .select, .textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; outline: none;
  transition: border-color var(--duration-fast);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
.input[readonly] { opacity: 0.7; cursor: not-allowed; }

.textarea { resize: vertical; min-height: 120px; line-height: 1.6; }

.select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}

.hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: var(--space-xxs); }

/* ==========================================================================
   DROPZONE
   ========================================================================== */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-xs); padding: var(--space-xl) var(--space-lg);
  border: 2px dashed var(--border); border-radius: var(--radius-md);
  background: var(--bg-input); color: var(--text-secondary);
  cursor: pointer; transition: all var(--duration-base);
  text-align: center; min-height: 100px;
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-wash); }
.dropzone.is-active { border-color: var(--brand); background: var(--brand-wash); }
.dropzone-sm { padding: var(--space-md); min-height: 80px; }

/* ==========================================================================
   PROGRESS BAR
   ========================================================================== */
.progress {
  height: 8px; background: var(--bg-input);
  border-radius: var(--radius-pill); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand), #4f8cff);
  transition: width var(--duration-slow) var(--ease-out);
}

/* ==========================================================================
   TABS
   ========================================================================== */
.tab-bar {
  display: flex; gap: var(--space-xs);
  padding: var(--space-xs) 0; margin-bottom: var(--space-lg);
  overflow-x: auto;
}

/* ==========================================================================
   PANELS & INSETS
   ========================================================================== */
.panel {
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}
.panel-body { flex: 1; overflow-y: auto; padding: var(--space-sm); }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
}

.inset-panel {
  padding: var(--space-md); border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border);
}

.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 2px; }

/* ==========================================================================
   SCENE LIST (Script Editor)
   ========================================================================== */
.scene-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--duration-fast); text-align: left;
  width: 100%; background: transparent;
}
.scene-item:hover { background: var(--bg-card-hover); border-color: var(--border); }
.scene-item.is-active { background: var(--brand-wash); border-color: var(--brand); }
.scene-item-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); }
.scene-item-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* ==========================================================================
   TERMINAL / LOG
   ========================================================================== */
.terminal {
  background: #0a0a14; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-md);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.8;
  color: #b0b0c0; max-height: 300px; overflow-y: auto;
}

/* ==========================================================================
   GRID LAYOUTS
   ========================================================================== */
.card-grid { display: grid; gap: var(--space-md); }
.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.split { display: grid; gap: var(--space-lg); }
.split-4-8 { grid-template-columns: 1fr 2fr; }

.stack { display: flex; flex-direction: column; gap: var(--space-md); }
.stack-sm { gap: var(--space-xs); }

.row { display: flex; align-items: center; gap: var(--space-sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.row-center { display: flex; align-items: center; justify-content: center; }
.row-end { display: flex; align-items: center; justify-content: flex-end; }
.row-wrap { flex-wrap: wrap; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-xxl { margin-bottom: var(--space-xxl); }

.mx-auto { margin-left: auto; margin-right: auto; }

.grow { flex: 1; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.full { width: 100%; }

/* ==========================================================================
   PAGE SECTIONS
   ========================================================================== */
.page-section {
  padding: var(--space-xxl) 0;
}

.page-header {
  margin-bottom: var(--space-xl);
}
.page-header h1 {
  font-size: 28px; font-weight: 700; color: var(--text);
  margin-bottom: var(--space-xs);
}
.page-header p {
  font-size: 15px; color: var(--text-secondary);
}

/* ==========================================================================
   MEDIA
   ========================================================================== */
.media {
  position: relative; overflow: hidden; border-radius: var(--radius-sm);
  background: var(--bg-input);
}
.media img { width: 100%; height: 100%; object-fit: cover; }
.media.ratio-16-9 { aspect-ratio: 16/9; }
.media.ratio-1-1 { aspect-ratio: 1; }
.media.ratio-9-16 { aspect-ratio: 9/16; }
.media-tag {
  position: absolute; bottom: 8px; left: 8px;
  padding: 2px 8px; border-radius: var(--radius-pill);
  background: rgba(0,0,0,0.7); color: #fff;
  font-size: 11px; font-weight: 600;
}
.media-tag.is-danger { background: var(--danger); }

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--space-xxl) var(--space-lg); text-align: center;
  grid-column: 1 / -1;
}
.empty-state-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: var(--space-xs); }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
  margin-top: auto; padding: var(--space-xl) 0;
  border-top: 1px solid var(--border);
}
.footer-legal {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--text-muted);
}
.footer-legal-links { display: flex; gap: var(--space-md); }
.footer-link { color: var(--text-muted); font-size: 13px; }
.footer-link:hover { color: var(--text); }

/* Full footer for landing/help/legal */
.footer-cols {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xl); padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border); margin-bottom: var(--space-lg);
}
.footer-heading {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-secondary);
  margin-bottom: var(--space-md);
}
.footer-list { list-style: none; }
.footer-list li { margin-bottom: var(--space-xs); }
.footer-note { font-size: 12px; color: var(--text-muted); margin-bottom: var(--space-lg); line-height: 1.7; }
.footer-muted { font-size: 13px; color: var(--text-muted); }

/* ==========================================================================
   TOASTS
   ========================================================================== */
#toast-container {
  position: fixed; bottom: var(--space-lg); right: var(--space-lg);
  z-index: var(--z-toast); display: flex; flex-direction: column-reverse;
  gap: var(--space-xs);
}

.toast {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-sm); padding: var(--space-sm) var(--space-md);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: 14px; color: var(--text);
  transform: translateX(120%); opacity: 0;
  transition: all var(--duration-slow) var(--ease-out);
  min-width: 280px; max-width: 420px;
}
.toast.is-visible { transform: translateX(0); opacity: 1; }
.toast.is-leaving { transform: translateX(120%); opacity: 0; }
.toast.is-success { border-left: 3px solid var(--success); }
.toast.is-error { border-left: 3px solid var(--danger); }
.toast.is-warning { border-left: 3px solid var(--warning); }
.toast.is-info { border-left: 3px solid var(--brand); }

.toast .row { display: flex; align-items: center; gap: var(--space-xs); }
.toast .icon-state { width: 18px; height: 18px; flex-shrink: 0; }
.toast .icon-state use { fill: none; stroke: currentColor; stroke-width: 2; }
.toast.is-success .icon-state { color: var(--success); }
.toast.is-error .icon-state { color: var(--danger); }
.toast.is-warning .icon-state { color: var(--warning); }
.toast.is-info .icon-state { color: var(--brand); }

.toast-close {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer; border-radius: var(--radius-xs);
  flex-shrink: 0;
}
.toast-close:hover { background: var(--bg-card-hover); color: var(--text); }

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: var(--z-modal); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-base);
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }

.modal-dialog {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-xl);
  max-width: 480px; width: 90%; box-shadow: var(--shadow-xl);
  transform: scale(0.95); transition: transform var(--duration-base) var(--ease-out);
}
.modal-backdrop.is-open .modal-dialog { transform: scale(1); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-md);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-body { margin-bottom: var(--space-lg); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-xs); }

/* ==========================================================================
   WIZARD STEPPER
   ========================================================================== */
.wizard-stepper {
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-md); padding: var(--space-lg) 0;
}

.wizard-step {
  display: flex; align-items: center; gap: var(--space-xs);
  font-size: 14px; font-weight: 500; color: var(--text-muted);
}
.wizard-step-num {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  background: var(--bg-input); color: var(--text-muted);
  border: 2px solid var(--border);
  transition: all var(--duration-base);
}
.wizard-step.is-active .wizard-step-num {
  background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: var(--brand-glow);
}
.wizard-step.is-active { color: var(--text); font-weight: 600; }
.wizard-step.is-done .wizard-step-num {
  background: var(--success); color: #fff; border-color: var(--success);
}
.wizard-step.is-done { color: var(--text-secondary); }

.wizard-connector {
  width: 40px; height: 2px; background: var(--border);
  border-radius: 1px;
}
.wizard-connector.is-done { background: var(--success); }

/* ==========================================================================
   WIZARD CARD
   ========================================================================== */
.wizard-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-xl);
  max-width: 640px; margin: 0 auto;
}
.wizard-card-title {
  font-size: 22px; font-weight: 700; margin-bottom: var(--space-xs);
}
.wizard-card-desc {
  font-size: 15px; color: var(--text-secondary); margin-bottom: var(--space-xl);
}
.wizard-actions {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: var(--space-lg); border-top: 1px solid var(--border);
  margin-top: var(--space-xl);
}

/* ==========================================================================
   DASHBOARD
   ========================================================================== */
.dash-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md); margin-bottom: var(--space-xl);
}

.dash-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-lg);
  display: flex; flex-direction: column; gap: var(--space-xs);
  transition: all var(--duration-base); cursor: pointer; text-decoration: none; color: inherit;
}
.dash-stat:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); }

.dash-stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-wash); color: var(--brand);
}

.dash-stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.dash-stat-value { font-size: 22px; font-weight: 700; color: var(--text); }

/* ==========================================================================
   GENERATOR - PROGRESSIVE
   ========================================================================== */
.gen-layout { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }

.gen-option-group { margin-bottom: var(--space-lg); }
.gen-option-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-xs); }

.gen-chips { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.gen-chip {
  display: flex; align-items: center; gap: var(--space-xs);
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border);
  cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: all var(--duration-fast);
}
.gen-chip:hover { border-color: var(--brand); color: var(--text); }
.gen-chip.selected {
  background: var(--brand-wash); border-color: var(--brand);
  color: var(--brand-text); font-weight: 600;
}
.gen-chip-sub { font-size: 12px; color: var(--text-muted); display: block; }

.gen-duration-chips { display: flex; gap: var(--space-xs); }
.gen-duration-chip {
  padding: 6px 14px; border-radius: var(--radius-xs);
  background: var(--bg-input); border: 1px solid var(--border);
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-secondary);
  transition: all var(--duration-fast);
}
.gen-duration-chip:hover { border-color: var(--brand); color: var(--text); }
.gen-duration-chip.selected {
  background: var(--brand-wash); border-color: var(--brand); color: var(--brand-text);
}

/* Pre-flight check */
.preflight {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-md);
  margin-bottom: var(--space-lg);
}
.preflight-item {
  display: flex; align-items: center; gap: var(--space-xs);
  font-size: 13px; color: var(--text-secondary); padding: 4px 0;
}
.preflight-item .icon { width: 16px; height: 16px; flex-shrink: 0; }
.preflight-ok .icon { color: var(--success); }
.preflight-warn .icon { color: var(--warning); }

/* Advanced toggle */
.advanced-toggle {
  display: flex; align-items: center; gap: var(--space-xs);
  padding: var(--space-md); cursor: pointer; font-size: 14px;
  font-weight: 600; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); transition: all var(--duration-fast);
  width: 100%; text-align: left;
}
.advanced-toggle:hover { border-color: var(--brand); color: var(--text); }
.advanced-toggle.is-open { border-color: var(--brand); color: var(--brand-text); background: var(--brand-wash); }

.advanced-panel {
  max-height: 0; overflow: hidden;
  transition: max-height var(--duration-slow) var(--ease-out);
}
.advanced-panel.is-open { max-height: 1000px; }
.advanced-panel-inner { padding-top: var(--space-md); }

/* Style influence slider */
.style-slider {
  -webkit-appearance: none; width: 100%; height: 6px;
  background: var(--bg-input); border-radius: 3px; outline: none;
}
.style-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  background: var(--brand); border-radius: 50%; cursor: pointer;
}

/* ==========================================================================
   LANDING PAGE
   ========================================================================== */
.hero-section {
  padding: var(--space-section) 0;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--brand-text);
  margin-bottom: var(--space-md);
}

.hero-display {
  font-size: clamp(36px, 5vw, 56px); font-weight: 800;
  line-height: 1.1; letter-spacing: -0.03em;
  margin-bottom: var(--space-md);
}

.lead {
  font-size: 18px; line-height: 1.7; color: var(--text-secondary);
  max-width: 600px; margin: 0 auto;
}

.measure { max-width: 600px; }

/* ==========================================================================
   AUTH PAGES
   ========================================================================== */
.auth-card {
  max-width: 420px; margin: var(--space-xxl) auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-xl);
}
.auth-card-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: var(--space-xs); }
.auth-card-desc { font-size: 14px; color: var(--text-secondary); text-align: center; margin-bottom: var(--space-xl); }
.auth-divider {
  display: flex; align-items: center; gap: var(--space-md);
  margin: var(--space-lg) 0; font-size: 13px; color: var(--text-muted);
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ==========================================================================
   LEGAL PAGES
   ========================================================================== */
.legal-container {
  max-width: var(--container-narrow); margin: 0 auto;
  padding: var(--space-xxl) var(--space-lg);
}
.legal-header { margin-bottom: var(--space-xl); }
.legal-section { margin-bottom: var(--space-xl); }
.legal-section h2 {
  font-size: 20px; font-weight: 700; margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs); border-bottom: 1px solid var(--border);
}
.legal-section p, .legal-section li {
  font-size: 15px; line-height: 1.8; color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}
.legal-section ul { padding-left: var(--space-lg); }
.legal-section ul li { list-style: disc; }

/* ==========================================================================
   PRE-FOOTER CTA
   ========================================================================== */
.pre-footer {
  text-align: center; padding: var(--space-xxl) 0;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   404 PAGE
   ========================================================================== */
.error-page {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh; text-align: center;
  padding: var(--space-xxl);
}
.error-code {
  font-size: 96px; font-weight: 800; color: var(--text);
  line-height: 1; margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--brand), #4f8cff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==========================================================================
   HELP / FAQ
   ========================================================================== */
.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs); overflow: hidden;
}
.faq-question {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: var(--space-md);
  background: var(--bg-card); border: none;
  font-size: 15px; font-weight: 600; color: var(--text);
  cursor: pointer; text-align: left;
}
.faq-question:hover { background: var(--bg-card-hover); }
.faq-answer {
  padding: 0 var(--space-md) var(--space-md);
  font-size: 14px; line-height: 1.7; color: var(--text-secondary);
  display: none;
}
.faq-item.is-open .faq-answer { display: block; }
.faq-item.is-open .faq-question .icon { transform: rotate(180deg); }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1068px) {
  .card-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .footer-cols { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 834px) {
  .nav-links, .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }

  .split, .split-4-8 { grid-template-columns: 1fr; }
  .gen-layout { grid-template-columns: 1fr; }

  .card-grid.cols-3 { grid-template-columns: 1fr; }
  .card-grid.cols-2 { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-sm); }

  .dash-stat { padding: var(--space-md); gap: 6px; }
  .dash-stat-icon { width: 36px; height: 36px; }
  .dash-stat-value { font-size: 20px; }

  .footer-cols { grid-template-columns: 1fr; }
  .footer-legal { flex-direction: column; gap: var(--space-xs); text-align: center; }

  .wizard-stepper { gap: var(--space-xs); }
  .wizard-step span:not(.wizard-step-num) { display: none; }
}

@media (max-width: 520px) {
  .container { padding: 0 var(--space-md); }
  h1 { font-size: 24px !important; }
  .card { padding: var(--space-md); }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .row-between .btn-block-mobile,
  .btn-block-mobile { width: 100%; justify-content: center; }
}

@media (max-width: 640px) {
  .container { padding: 0 var(--space-md); }
  .hero-display { font-size: 32px; }
  .card { padding: var(--space-md); }
}

/* ==========================================================================
   SPINNER
   ========================================================================== */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ==========================================================================
   CONSENT BANNER
   ========================================================================== */
.consent-banner {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: var(--space-md) var(--space-lg);
  display: none; align-items: center; justify-content: space-between;
  gap: var(--space-md); z-index: var(--z-toast);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}
.consent-banner.is-visible { display: flex; }
.consent-banner p { font-size: 13px; color: var(--text-secondary); flex: 1; }
.consent-actions { display: flex; gap: var(--space-xs); flex-shrink: 0; }
