/* ============================================================
   Rebind SaaS — Forest & Gold Design System
   ============================================================ */

/* === CSS VARIABLES (DESIGN TOKENS) === */
:root {
  /* Brand — Forest & Gold */
  --brand-50: #ECFDF5;
  --brand-100: #D1FAE5;
  --brand-200: #A7F3D0;
  --brand-300: #6EE7B7;
  --brand-400: #34D399;
  --brand-500: #059669;
  --brand-600: #059669;
  --brand-700: #047857;
  --brand-800: #065F46;
  --brand-900: #064E3B;

  /* Accent — Gold */
  --accent-400: #FACC15;
  --accent-500: #EAB308;
  --accent-600: #CA8A04;
  --accent-700: #A16207;

  /* Neutral */
  --neutral-50: #F8FAFC;
  --neutral-100: #F1F5F9;
  --neutral-200: #E2E8F0;
  --neutral-300: #CBD5E1;
  --neutral-400: #94A3B8;
  --neutral-500: #64748B;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1E293B;
  --neutral-900: #0F172A;
  --neutral-950: #020617;

  /* Semantic */
  --destructive-50: #FEF2F2;
  --destructive-500: #EF4444;
  --destructive-700: #B91C1C;
  --warning-50: #FFFBEB;
  --warning-500: #F59E0B;
  --warning-700: #B45309;
  --success-50: #F0FDF4;
  --success-500: #22C55E;
  --success-700: #15803D;
  --info-50: #EFF6FF;
  --info-500: #3B82F6;
  --info-700: #1D4ED8;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  /* Sidebar */
  --sidebar-width: 260px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Light mode (default variables) */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --bg-elevated: #FFFFFF;
  --bg-sidebar: #0D1117;
  --text-primary: #1E293B;
  --text-secondary: #64748B;
  --text-tertiary: #94A3B8;
  --text-inverse: #FFFFFF;
  --border-primary: #E2E8F0;
  --border-secondary: #F1F5F9;
}

/* === DARK MODE === */
[data-theme="dark"] {
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-elevated: #161B22;
  --bg-sidebar: #0D1117;
  --text-primary: #F0F6FC;
  --text-secondary: #7C8B9E;
  --text-tertiary: #7C8B9E;
  --text-inverse: #0D1117;
  --border-primary: rgba(255,255,255,0.08);
  --border-secondary: #161B22;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

/* === RESET & BASE === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: var(--brand-500);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--brand-700);
}

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

code, pre {
  font-family: var(--font-mono);
}

::selection {
  background: var(--brand-500);
  color: white;
}

/* === SCROLLBAR (dark mode) === */
[data-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--neutral-700);
  border-radius: var(--radius-full);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-600);
}


/* ============================================================
   SIDEBAR LAYOUT
   ============================================================ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: #0D1117;
  color: #F0F6FC;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow);
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

.sidebar-logo-icon svg {
  width: 40px;
  height: 40px;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: #F0F6FC;
  line-height: 1.2;
}
.sidebar-logo-text small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #7C8B9E;
  margin-top: 2px;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: #7C8B9E;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  text-decoration: none;
  border-left: 3px solid transparent;
  margin-left: -3px;
}

.sidebar-nav a:hover {
  color: #F0F6FC;
  background: rgba(255,255,255,0.05);
}

.sidebar-nav a.active {
  color: #F0F6FC;
  background: rgba(5, 150, 105, 0.1);
  border-left-color: var(--brand-500);
}

.sidebar-nav a .nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-nav a .nav-icon svg {
  width: 20px;
  height: 20px;
}

.sidebar-nav a .nav-label {
  white-space: nowrap;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 16px;
}

/* Sidebar User */
.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #F0F6FC;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-plan {
  font-size: 11px;
  color: #7C8B9E;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-primary);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  line-height: 0;
}
.theme-toggle svg {
  width: 20px;
  height: 20px;
}
.theme-toggle:hover {
  border-color: var(--brand-500);
  color: var(--brand-500);
}

/* Page content area */
.page-content {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.active {
  display: block;
}


/* ============================================================
   AUTH PAGES (Login / Register)
   ============================================================ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0D1117 0%, #161B22 100%);
  padding: 16px;
}

.auth-container {
  width: 100%;
  max-width: 440px;
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  box-shadow: var(--shadow-xl);
}

[data-theme="dark"] .auth-card {
  background: #161B22;
  border-color: rgba(255,255,255,0.08);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 8px;
}

.auth-logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.auth-logo-icon svg {
  width: 48px;
  height: 48px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-error {
  background: var(--destructive-50);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--destructive-500);
  font-size: 13px;
  margin-bottom: 16px;
}

[data-theme="dark"] .auth-error {
  background: rgba(239, 68, 68, 0.1);
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}
.auth-link a {
  color: var(--brand-500);
  font-weight: 500;
}
.auth-link a:hover {
  text-decoration: underline;
}

.plan-info {
  margin-top: 24px;
  padding: 16px;
  background: var(--brand-50);
  border: 1px solid rgba(5, 150, 105, 0.15);
  border-radius: var(--radius-md);
}

[data-theme="dark"] .plan-info {
  background: rgba(5, 150, 105, 0.05);
  border-color: rgba(5, 150, 105, 0.15);
}

.plan-info p {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-weight: 600;
}

.plan-info ul {
  margin-left: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.plan-info li {
  margin-bottom: 4px;
}


/* ============================================================
   FORM COMPONENTS
   ============================================================ */

.form-group {
  margin-bottom: 20px;
}

.form-group label,
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #0D1117;
  border-color: rgba(255,255,255,0.08);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

.input-with-icon {
  position: relative;
}
.input-with-icon .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.input-with-icon .input-icon svg {
  width: 18px;
  height: 18px;
}
.input-with-icon input {
  padding-left: 40px;
}

.field {
  margin-bottom: 16px;
}

.field-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.field-row .field {
  flex: 1;
  min-width: 140px;
}

/* Checkbox */
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px 0;
}
.checkbox input[type="checkbox"] {
  accent-color: var(--brand-500);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Color input */
.color-input {
  display: flex;
  gap: 8px;
  align-items: center;
}
.color-input input[type="color"] {
  width: 40px;
  height: 36px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
  background: var(--bg-primary);
}
.color-input input[type="text"] {
  width: 90px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 13px;
}

/* Search bar */
.search-bar {
  position: relative;
}
.search-bar input {
  padding-left: 40px;
  padding-right: 16px;
}
.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
  align-items: center;
  width: 18px;
  height: 18px;
}
.search-bar .search-icon svg {
  width: 18px;
  height: 18px;
}


/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary,
button.btn-primary,
a.btn-primary {
  background: var(--brand-500);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-family: var(--font-sans);
}
.btn-primary:hover {
  background: var(--brand-700);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
  color: #fff;
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary,
button.btn-secondary,
a.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-family: var(--font-sans);
}
.btn-secondary:hover {
  border-color: var(--brand-500);
  color: var(--brand-500);
}

[data-theme="dark"] .btn-secondary {
  background: #161B22;
  border-color: rgba(255,255,255,0.08);
  color: #F0F6FC;
}
[data-theme="dark"] .btn-secondary:hover {
  border-color: var(--brand-500);
  color: var(--brand-500);
}

.btn-danger,
button.btn-danger {
  background: #DC2626;
  color: #fff;
  border: 1px solid #DC2626;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-danger:hover {
  background: #B91C1C;
  border-color: #B91C1C;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.btn-destructive {
  background: var(--destructive-500);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}
.btn-destructive:hover {
  background: var(--destructive-700);
}

.btn-link {
  background: none;
  border: none;
  color: var(--brand-500);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-sans);
  padding: 4px 0;
}
.btn-link:hover {
  text-decoration: underline;
}

/* AI Button (accent gold gradient) */
.btn-ai {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  color: #1E293B;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.btn-ai:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(234, 179, 8, 0.4);
}
.btn-ai:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.ai-icon {
  display: inline-flex;
  align-items: center;
  width: 18px;
  height: 18px;
}
.ai-icon svg {
  width: 18px;
  height: 18px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
}

.full-width {
  width: 100%;
}


/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success,
.status-badge.status-done {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success-500);
}
.badge-info,
.status-badge.status-ready {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info-500);
}
.badge-warning,
.status-badge.status-processing,
.status-badge.status-queued {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning-500);
}
.badge-destructive,
.status-badge.status-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive-500);
}
.badge-neutral {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.badge-brand {
  background: rgba(5, 150, 105, 0.1);
  color: var(--brand-500);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}


/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

[data-theme="dark"] .card {
  background: #161B22;
  border-color: rgba(255,255,255,0.06);
}

.card:hover {
  border-color: var(--neutral-300);
}
[data-theme="dark"] .card:hover {
  border-color: rgba(255,255,255,0.12);
}

.card-clickable {
  cursor: pointer;
}
.card-clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--brand-500);
}


/* ============================================================
   DASHBOARD -- STAT CARDS
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .stat-card {
  background: #161B22;
  border-color: rgba(255,255,255,0.06);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-bar {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  margin-top: 16px;
  overflow: hidden;
}

[data-theme="dark"] .stat-bar {
  background: rgba(255,255,255,0.06);
}

.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.stat-icon {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg {
  width: 28px;
  height: 28px;
  color: var(--accent-500);
}

/* Section headings */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Recent activity list */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
[data-theme="dark"] .activity-item {
  border-color: rgba(255,255,255,0.06);
}

.activity-item:hover {
  border-color: var(--brand-500);
  transform: translateX(4px);
}

.activity-item .item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}
.activity-item .item-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}


/* ============================================================
   LIBRARY -- BOOK GRID
   ============================================================ */

.library-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.library-filters .search-bar {
  flex: 1;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-fast);
  cursor: pointer;
}
[data-theme="dark"] .book-card {
  border-color: rgba(255,255,255,0.06);
}

.book-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-xl);
  border-color: var(--brand-500);
}

.book-cover {
  width: 100%;
  height: 220px;
  background: linear-gradient(135deg, #161B22, #0D1117);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7C8B9E;
  position: relative;
  overflow: hidden;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.book-card:hover .book-cover img {
  transform: scale(1.04);
}

.book-cover-placeholder {
  background: linear-gradient(135deg, var(--brand-800), var(--brand-600), var(--brand-500));
  color: rgba(255,255,255,0.25);
  flex-direction: column;
  gap: 8px;
}

.book-cover-placeholder svg {
  width: 48px;
  height: 48px;
}

.book-cover-placeholder .cover-title-overlay {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  padding: 0 16px;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.book-info {
  padding: 16px;
}

.book-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-tertiary);
}

.book-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Book detail modal */
.book-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.book-detail-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

[data-theme="dark"] .book-detail-card {
  background: #161B22;
  border-color: rgba(255,255,255,0.08);
}

.book-detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.book-detail-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-right: 40px;
}

.book-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-secondary);
}

.book-detail-meta .meta-row {
  display: flex;
  gap: 8px;
}
.book-detail-meta .meta-label {
  font-weight: 600;
  color: var(--text-tertiary);
  min-width: 80px;
}

.book-detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 32px;
  color: var(--text-tertiary);
}
.empty-state-icon {
  margin-bottom: 16px;
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state-icon svg {
  width: 64px;
  height: 64px;
  color: #7C8B9E;
}
.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-state-text {
  font-size: 14px;
  margin-bottom: 24px;
}


/* ============================================================
   WORKBENCH -- STEP WIZARD
   ============================================================ */

/* Step indicator */
.steps {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
}

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: all var(--transition-slow);
}

[data-theme="dark"] .step {
  background: #161B22;
  border-color: rgba(255,255,255,0.06);
}

.step-number {
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

[data-theme="dark"] .step-number {
  background: rgba(255,255,255,0.06);
}

.step.active {
  border-color: var(--brand-500);
  color: var(--brand-500);
}
.step.active .step-number {
  background: var(--brand-500);
  color: #fff;
}

.step.done {
  border-color: var(--success-500);
  color: var(--success-500);
}
.step.done .step-number {
  background: var(--success-500);
  color: #fff;
}

/* Step content */
.step-content {
  display: none;
  animation: fadeIn 0.3s ease;
}
.step-content.active {
  display: block;
}

/* Input tabs */
.input-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tab-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
}
.tab-btn.active {
  border-color: var(--brand-500);
  color: var(--brand-500);
  background: rgba(5, 150, 105, 0.05);
}
[data-theme="dark"] .tab-btn {
  background: #161B22;
  border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .tab-btn.active {
  background: rgba(5, 150, 105, 0.1);
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-slow);
  margin-bottom: 16px;
}

[data-theme="dark"] .upload-zone {
  border-color: rgba(255,255,255,0.08);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--brand-500);
  background: rgba(5, 150, 105, 0.03);
}
.upload-icon {
  color: var(--brand-500);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-icon svg {
  width: 48px;
  height: 48px;
}
.upload-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* Processing card */
.processing-card {
  text-align: center;
  padding: 64px 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
}
[data-theme="dark"] .processing-card {
  border-color: rgba(255,255,255,0.06);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-primary);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
}
[data-theme="dark"] .spinner {
  border-color: rgba(255,255,255,0.08);
  border-top-color: var(--brand-500);
}

.proc-step {
  color: var(--brand-500);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 16px;
}

.progress-bar {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  margin: 0 auto 16px;
  overflow: hidden;
}
[data-theme="dark"] .progress-bar {
  background: rgba(255,255,255,0.06);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.5s ease;
}

.proc-stats {
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Editor */
.editor-header {
  margin-bottom: 16px;
}
.editor-header p {
  color: var(--text-secondary);
  font-size: 14px;
}
.editor-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* AI Status */
.ai-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(5, 150, 105, 0.05);
  border: 1px solid rgba(5, 150, 105, 0.2);
  border-radius: var(--radius-md);
  margin-top: 12px;
  font-size: 13px;
  color: var(--brand-500);
}

.spinner-small {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(5, 150, 105, 0.3);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Config grid (Customization) */
.config-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

fieldset {
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: var(--bg-elevated);
}
[data-theme="dark"] fieldset {
  border-color: rgba(255,255,255,0.06);
}

legend {
  color: var(--brand-500);
  font-weight: 600;
  font-size: 14px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Cover preview */
.preview-box {
  text-align: center;
}
.cover-preview {
  width: 280px;
  height: 380px;
  margin: 12px auto;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  position: relative;
  transition: all var(--transition-slow);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.cover-rule {
  width: 60%;
  height: 3px;
  border-radius: 2px;
}
.cover-title {
  font-size: 22px;
  font-weight: 700;
  padding: 0 20px;
  text-align: center;
  word-break: break-word;
}
.cover-author {
  font-size: 14px;
  opacity: 0.8;
}
.cover-date {
  font-size: 12px;
  opacity: 0.6;
  position: absolute;
  bottom: 20px;
}

/* Done card */
.done-card {
  text-align: center;
  padding: 64px 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--success-500);
  border-radius: var(--radius-xl);
}
.done-icon {
  width: 64px;
  height: 64px;
  background: var(--success-500);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: #fff;
}
.done-icon svg {
  width: 32px;
  height: 32px;
}
.done-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}
.done-actions a {
  text-decoration: none;
}
#done-info {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Image preview row */
.img-preview-row {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}
.img-preview-item {
  flex: 1;
  text-align: center;
}
.img-preview-item p {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.img-preview-item img {
  max-width: 100%;
  max-height: 250px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  object-fit: contain;
}


/* ============================================================
   PROFILE PAGE
   ============================================================ */

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.profile-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
}
[data-theme="dark"] .profile-card {
  border-color: rgba(255,255,255,0.06);
}

.profile-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.profile-field {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-secondary);
  font-size: 14px;
}
.profile-field:last-child {
  border-bottom: none;
}
.profile-field-label {
  color: var(--text-tertiary);
  font-weight: 500;
}
.profile-field-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* Plan comparison table */
.plan-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 14px;
}

.plan-table th,
.plan-table td {
  padding: 12px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border-primary);
}

.plan-table th {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 15px;
}

.plan-table td {
  color: var(--text-secondary);
}

.plan-table .plan-header-free { color: var(--text-secondary); }
.plan-table .plan-header-pro { color: var(--brand-500); }
.plan-table .plan-header-business { color: var(--accent-500); }

.plan-table .feature-name {
  text-align: left;
  font-weight: 500;
  color: var(--text-primary);
}

.plan-table .plan-current {
  background: rgba(5, 150, 105, 0.05);
}

[data-theme="dark"] .plan-table th,
[data-theme="dark"] .plan-table td {
  border-color: rgba(255,255,255,0.06);
}


/* ============================================================
   EasyMDE DARK MODE STYLING
   ============================================================ */

[data-theme="dark"] .EasyMDEContainer .CodeMirror {
  background: #0D1117 !important;
  color: #F0F6FC !important;
  border-color: rgba(255,255,255,0.08) !important;
  min-height: 400px;
  border-radius: var(--radius-md);
}

[data-theme="dark"] .EasyMDEContainer .CodeMirror-cursor {
  border-left-color: var(--brand-500) !important;
}

[data-theme="dark"] .EasyMDEContainer .editor-toolbar {
  background: #161B22 !important;
  border-color: rgba(255,255,255,0.08) !important;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

[data-theme="dark"] .EasyMDEContainer .editor-toolbar button {
  color: #7C8B9E !important;
  border: none !important;
}

[data-theme="dark"] .EasyMDEContainer .editor-toolbar button:hover {
  background: rgba(255,255,255,0.06) !important;
  color: var(--brand-500) !important;
}

[data-theme="dark"] .EasyMDEContainer .editor-toolbar button.active {
  background: rgba(255,255,255,0.06) !important;
  color: var(--brand-500) !important;
}

[data-theme="dark"] .EasyMDEContainer .CodeMirror .CodeMirror-selected {
  background: rgba(5, 150, 105, 0.2) !important;
}

[data-theme="dark"] .EasyMDEContainer .editor-statusbar {
  color: #7C8B9E !important;
  border-color: rgba(255,255,255,0.08) !important;
}

[data-theme="dark"] .EasyMDEContainer .CodeMirror .cm-header {
  color: var(--brand-400) !important;
}
[data-theme="dark"] .EasyMDEContainer .CodeMirror .cm-link {
  color: var(--info-500) !important;
}
[data-theme="dark"] .EasyMDEContainer .CodeMirror .cm-string {
  color: var(--success-500) !important;
}

/* Light mode EasyMDE */
.EasyMDEContainer .CodeMirror {
  min-height: 400px;
  border-radius: var(--radius-md);
}
.EasyMDEContainer .editor-toolbar {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}


/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.animate-fadeIn {
  animation: fadeIn 0.3s ease;
}

.animate-slideUp {
  animation: slideUp 0.4s ease;
}


/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Tablet */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .page-content {
    padding: 24px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  /* Sidebar collapses */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: flex;
  }

  /* Topbar */
  .topbar {
    padding: 12px 16px;
  }
  .topbar-title {
    font-size: 16px;
  }

  /* Content */
  .page-content {
    padding: 16px;
  }

  /* Stats */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  /* Steps */
  .steps {
    flex-wrap: wrap;
  }
  .step {
    padding: 8px 12px;
    font-size: 12px;
  }
  .step .step-label {
    display: none;
  }

  /* Book grid */
  .book-grid {
    grid-template-columns: 1fr;
  }

  /* Library filters */
  .library-filters {
    flex-direction: column;
  }

  /* Profile */
  .profile-grid {
    grid-template-columns: 1fr;
  }

  /* Buttons */
  .editor-actions {
    flex-direction: column;
  }

  /* Field rows */
  .field-row {
    flex-direction: column;
  }

  /* Plan table */
  .plan-table {
    font-size: 12px;
  }
  .plan-table th,
  .plan-table td {
    padding: 8px 6px;
  }

  /* Auth */
  .auth-card {
    padding: 28px 20px;
  }

  /* Done card */
  .done-card {
    padding: 40px 20px;
  }
  .done-actions {
    flex-direction: column;
    align-items: center;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .steps {
    gap: 2px;
  }
  .step {
    flex-direction: column;
    text-align: center;
    gap: 4px;
    padding: 8px 6px;
    font-size: 11px;
  }

  .upload-zone {
    padding: 32px 16px;
  }
}


/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.text-brand { color: var(--brand-500); }
.text-accent { color: var(--accent-500); }
.text-success { color: var(--success-500); }
.text-warning { color: var(--warning-500); }
.text-destructive { color: var(--destructive-500); }
.text-info { color: var(--info-500); }
.text-muted { color: var(--text-tertiary); }

.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.hidden { display: none !important; }
.block { display: block; }

.w-full { width: 100%; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }


/* ============================================================
   ONBOARDING OVERLAY
   ============================================================ */

.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.onboarding-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  max-width: 500px;
  width: 100%;
  padding: 40px 32px 32px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.4s ease;
}

[data-theme="dark"] .onboarding-card {
  background: #161B22;
  border-color: rgba(255,255,255,0.08);
}

.onboarding-step {
  display: none;
  animation: fadeIn 0.3s ease;
}

.onboarding-step.active {
  display: block;
}

.onboarding-illustration {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: rgba(5, 150, 105, 0.1);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-500);
}

.onboarding-illustration svg {
  width: 40px;
  height: 40px;
}

.onboarding-step h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.onboarding-step p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.onboarding-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.onboarding-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--border-primary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

[data-theme="dark"] .onboarding-dots .dot {
  background: rgba(255,255,255,0.12);
}

.onboarding-dots .dot.active {
  background: var(--brand-500);
  width: 28px;
}

.onboarding-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
}


/* ============================================================
   STYLE TEMPLATES
   ============================================================ */

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.template-card {
  background: var(--bg-primary);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .template-card {
  background: #0D1117;
  border-color: rgba(255,255,255,0.08);
}

.template-card:hover {
  border-color: var(--brand-400);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.template-card.active {
  border-color: var(--brand-500);
  background: rgba(5, 150, 105, 0.05);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

[data-theme="dark"] .template-card.active {
  background: rgba(5, 150, 105, 0.1);
}

.template-card-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  background: rgba(5, 150, 105, 0.1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-500);
}

.template-card-icon svg {
  width: 20px;
  height: 20px;
}

.template-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.template-card-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

@media (max-width: 768px) {
  .template-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .template-grid {
    grid-template-columns: 1fr;
  }
}


/* ============================================================
   COVER TEMPLATE SELECTOR
   ============================================================ */

.cover-template-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.cover-tpl-card {
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-primary);
}

[data-theme="dark"] .cover-tpl-card {
  background: #0D1117;
  border-color: rgba(255,255,255,0.08);
}

.cover-tpl-card:hover {
  border-color: var(--brand-400);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cover-tpl-card.active {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.cover-tpl-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Mini previews inside cards */
.cover-tpl-mini {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  overflow: hidden;
}

.cover-tpl-mini .mini-title {
  font-size: 8px;
  font-weight: 700;
  color: #fff;
}

.cover-tpl-mini .mini-author {
  font-size: 6px;
  color: rgba(255,255,255,0.7);
}

/* Classico */
.cover-mini-classico {
  background: #0d1117;
}
.cover-mini-classico .mini-rule {
  width: 50%;
  height: 2px;
  background: #059669;
  margin-bottom: 2px;
}

/* Gradiente */
.cover-mini-gradiente {
  background: linear-gradient(135deg, #0d1117 0%, #059669 100%);
}
.cover-mini-gradiente .mini-divider {
  width: 30%;
  height: 1px;
  background: rgba(255,255,255,0.4);
  margin: 2px 0;
}

/* Moldura */
.cover-mini-moldura {
  background: #0d1117;
}
.cover-mini-moldura .mini-frame {
  position: absolute;
  inset: 4px;
  border: 1px solid #059669;
  border-radius: 2px;
  pointer-events: none;
}

/* Diagonal */
.cover-mini-diagonal {
  background: #0d1117;
  overflow: hidden;
}
.cover-mini-diagonal::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -30%;
  width: 80%;
  height: 80%;
  background: #059669;
  transform: rotate(25deg);
  opacity: 0.3;
}

/* Minimalista */
.cover-mini-minimal {
  background: #f5f5f5;
}
.cover-mini-minimal .mini-title {
  color: #1a1a1a;
}
.cover-mini-minimal .mini-author {
  color: rgba(0,0,0,0.5);
}
.cover-mini-minimal .mini-line {
  width: 25%;
  height: 2px;
  background: #059669;
  margin: 2px 0;
}

/* Color picker row */
.cover-colors-row {
  display: flex;
  gap: 12px;
}
.cover-colors-row .field {
  flex: 1;
}
.cover-colors-row input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 2px;
  background: var(--bg-elevated);
}

/* ============================================================
   COVER LIVE PREVIEW
   ============================================================ */

.cover-live-preview {
  width: 280px;
  height: 400px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #0d1117;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  transition: all 0.4s ease;
}

.clp-accent-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: #059669;
  transition: background 0.3s;
}

.clp-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 28px;
  z-index: 1;
}

.clp-rule {
  width: 80px;
  height: 3px;
  background: #059669;
  border-radius: 2px;
  transition: background 0.3s;
}

.clp-title {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
  margin: 0;
  transition: color 0.3s;
}

.clp-author {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  margin: 0;
  transition: color 0.3s;
}

.clp-date {
  position: absolute;
  bottom: 16px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin: 0;
  transition: color 0.3s;
}

/* Cover template: gradiente */
.cover-live-preview.tpl-gradiente .clp-accent-bar { display: none; }
.cover-live-preview.tpl-gradiente .clp-rule { display: none; }
.cover-live-preview.tpl-gradiente .clp-content { gap: 14px; }
.cover-live-preview.tpl-gradiente .clp-title { font-size: 24px; letter-spacing: -0.5px; }
.cover-live-preview.tpl-gradiente::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, var(--clp-accent, #059669) 100%);
  opacity: 0.5;
  pointer-events: none;
}

/* Cover template: moldura */
.cover-live-preview.tpl-moldura .clp-accent-bar { display: none; }
.cover-live-preview.tpl-moldura::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 2px solid var(--clp-accent, #059669);
  border-radius: 6px;
  pointer-events: none;
  z-index: 0;
}

/* Cover template: diagonal */
.cover-live-preview.tpl-diagonal .clp-accent-bar { display: none; }
.cover-live-preview.tpl-diagonal .clp-rule { display: none; }
.cover-live-preview.tpl-diagonal::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -40%;
  width: 100%;
  height: 100%;
  background: var(--clp-accent, #059669);
  transform: rotate(25deg);
  opacity: 0.2;
  pointer-events: none;
}
.cover-live-preview.tpl-diagonal::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--clp-accent, #059669);
  pointer-events: none;
}
.cover-live-preview.tpl-diagonal .clp-content { align-items: flex-start; padding: 0 32px; }

/* Cover template: minimalista */
.cover-live-preview.tpl-minimalista .clp-accent-bar { display: none; }
.cover-live-preview.tpl-minimalista .clp-rule:first-child { display: none; }
.cover-live-preview.tpl-minimalista .clp-title { font-size: 20px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.cover-live-preview.tpl-minimalista .clp-content { gap: 16px; }

@media (max-width: 768px) {
  .cover-template-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .cover-colors-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .cover-template-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .cover-live-preview {
    width: 220px;
    height: 310px;
  }
  .clp-title {
    font-size: 18px;
  }
}


/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 280px;
  max-width: 420px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease forwards;
}

[data-theme="dark"] .toast {
  background: #1E293B;
  border-color: rgba(255,255,255,0.1);
}

.toast.toast-removing {
  animation: toastSlideOut 0.3s ease forwards;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-icon svg {
  width: 20px;
  height: 20px;
}

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
}

.toast-success {
  border-left: 4px solid var(--success-500);
}
.toast-success .toast-icon { color: var(--success-500); }

.toast-error {
  border-left: 4px solid var(--destructive-500);
}
.toast-error .toast-icon { color: var(--destructive-500); }

.toast-info {
  border-left: 4px solid var(--info-500);
}
.toast-info .toast-icon { color: var(--info-500); }

.toast-warning {
  border-left: 4px solid var(--warning-500);
}
.toast-warning .toast-icon { color: var(--warning-500); }

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(80px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(80px);
  }
}


/* ============================================================
   SKELETON LOADING
   ============================================================ */

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--bg-secondary) 25%,
    var(--border-primary) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 800px 100%;
}

.skeleton-text {
  height: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-text:nth-child(even) {
  width: 60%;
}

.skeleton-title {
  height: 28px;
  width: 60%;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.skeleton-card {
  height: 100px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-primary);
}

[data-theme="dark"] .skeleton-card {
  border-color: rgba(255,255,255,0.06);
}

.skeleton-stat {
  height: 120px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-primary);
}

[data-theme="dark"] .skeleton-stat {
  border-color: rgba(255,255,255,0.06);
}

.skeleton-row {
  height: 56px;
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  border: 1px solid var(--border-primary);
}

[data-theme="dark"] .skeleton-row {
  border-color: rgba(255,255,255,0.06);
}

.skeleton-book-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-primary);
}

[data-theme="dark"] .skeleton-book-card {
  border-color: rgba(255,255,255,0.06);
}

.skeleton-book-cover {
  height: 180px;
}

.skeleton-book-info {
  padding: 16px;
}

.skeleton-book-title {
  height: 18px;
  width: 70%;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.skeleton-book-meta {
  height: 12px;
  width: 50%;
  border-radius: var(--radius-sm);
}


/* ============================================================
   PROGRESS ETA
   ============================================================ */

.proc-eta {
  display: inline-block;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  margin-top: 8px;
}


/* ============================================================
   MINUTAGEM (chapter index with timestamps)
   ============================================================ */

.minutagem-panel {
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: var(--radius-md, 10px);
  padding: 16px 18px;
  margin: 16px 0 20px;
  background: var(--surface-2, rgba(255,255,255,0.02));
}

.minutagem-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.minutagem-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.minutagem-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.minutagem-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chapters-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.chapter-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 8px;
  border-radius: var(--radius-sm, 6px);
  transition: background 0.15s ease;
}

.chapter-item:hover {
  background: rgba(5, 150, 105, 0.08);
}

.chapter-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
  color: var(--success-500, #059669);
  min-width: 64px;
}

.chapter-title {
  flex: 1 1 auto;
  font-size: 14px;
  color: var(--text-primary);
}

.chapters-empty {
  list-style: none;
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 8px 0;
}

.chapter-cut {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  color: var(--text-secondary);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 4px 8px;
}

.chapter-cut:hover {
  border-color: var(--success-500, #059669);
  color: var(--success-500, #059669);
}


/* ============================================================
   EDITOR (legendas e cortes)
   ============================================================ */

.editor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.editor-row > strong {
  font-size: 13px;
  color: var(--text-primary);
  min-width: 110px;
}

.editor-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.editor-inline input,
.editor-row select {
  background: var(--surface-1, rgba(255,255,255,0.04));
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: var(--radius-sm, 6px);
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 13px;
}

.editor-inline input { width: 110px; }
#sub-fontsize { width: 64px; }

.editor-cut {
  border-top: 1px dashed var(--border, rgba(255,255,255,0.1));
  padding-top: 12px;
}

.editor-warn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
  border-radius: var(--radius-sm, 6px);
  font-size: 13px;
  color: var(--text-secondary);
}


/* ============================================================
   VIDEO EDITOR (player + timeline + side panels)
   ============================================================ */

.veditor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 980px) {
  .veditor { grid-template-columns: 1fr; }
}

.veditor-main { min-width: 0; }

.video-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius-md, 10px);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

#editor-video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.caption-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8%;
  margin: 0 auto;
  max-width: 90%;
  text-align: center;
  font-size: clamp(14px, 2.4vw, 22px);
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  padding: 0 12px;
  white-space: pre-wrap;
}

.timeline {
  position: relative;
  height: 22px;
  margin-top: 14px;
  background: var(--surface-1, rgba(255,255,255,0.06));
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
}

.timeline-selection {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(5, 150, 105, 0.30);
  display: none;
}

.timeline-marker {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  display: none;
}
.timeline-in { background: var(--success-500, #059669); }
.timeline-out { background: #f59e0b; }

.timeline-playhead {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  left: 0;
  background: #fff;
  box-shadow: 0 0 4px rgba(0,0,0,0.6);
}

.timeline-times {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.cut-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
}

.audio-bar {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(5, 150, 105, 0.04);
  border: 1px solid rgba(5, 150, 105, 0.18);
  border-radius: var(--radius-md, 10px);
}

.audio-bar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
}

.audio-result {
  border-top: 1px dashed var(--border, rgba(255,255,255,0.1));
  margin-top: 10px;
  padding-top: 6px;
}

.veditor-side {
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: var(--radius-md, 10px);
  background: var(--surface-2, rgba(255,255,255,0.02));
  padding: 14px;
}

.side-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.side-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 8px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}

.side-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  cursor: pointer;
}

.side-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--success-500, #059669);
}

.side-pane {
  max-height: 420px;
  overflow-y: auto;
}

.chapter-item { cursor: pointer; }


/* ============================================================
   GALERIA DE CLIPS (/clips)
   ============================================================ */

.clips-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.clip-card {
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: var(--radius-md, 10px);
  background: var(--surface-2, rgba(255,255,255,0.02));
  overflow: hidden;
}

.clip-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clip-thumb img { width: 100%; height: 100%; object-fit: cover; }
.clip-play {
  position: absolute;
  color: #fff;
  font-size: 28px;
  opacity: 0.85;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  pointer-events: none;
}

.clip-card-body { padding: 10px 12px; }
.clip-sel { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.clip-name { font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-meta { font-size: 12px; color: var(--text-tertiary); margin: 4px 0 8px; }
.clip-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn-xs {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
}

.clip-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.clip-modal-card {
  position: relative;
  background: var(--surface-1, #1a1a1a);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: var(--radius-md, 10px);
  padding: 20px;
  width: min(720px, 100%);
}
