/* ═══════════════════════════════════════════════════════
   TubeForge AI — Design System
   Palette: Volcanic Glass + Electric Orange
   Fonts: Clash Display + Outfit + Space Mono
═══════════════════════════════════════════════════════ */

:root {
  --bg-base:       #0F0F0F;
  --bg-surface:    #1A1A1A;
  --bg-elevated:   #242424;
  --bg-card:       #1E1E1E;
  --bg-hover:      #2A2A2A;
  --border:        #2E2E2E;
  --border-bright: #3D3D3D;

  --orange:        #FF6B2B;
  --orange-light:  #FFB088;
  --orange-dim:    rgba(255,107,43,0.15);
  --orange-glow:   rgba(255,107,43,0.3);

  --text-primary:  #F0EDE8;
  --text-secondary:#A0998F;
  --text-muted:    #5A5550;

  --green:         #4ADE80;
  --blue:          #60A5FA;
  --purple:        #A78BFA;
  --red:           #F87171;
  --yellow:        #FBBF24;

  --sidebar-w:     260px;
  --topbar-h:      64px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;

  --font-display:  'Clash Display', sans-serif;
  --font-body:     'Outfit', sans-serif;
  --font-mono:     'Space Mono', monospace;

  --shadow-card:   0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:   0 0 40px rgba(255,107,43,0.15);
  --transition:    0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Particle Canvas ── */
#particleCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.logo-ai {
  color: var(--orange);
  margin-left: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--orange-dim);
  color: var(--orange);
  border: 1px solid rgba(255,107,43,0.2);
}
.nav-item.active .nav-icon { stroke: var(--orange); }
.nav-icon {
  width: 18px; height: 18px;
  stroke: currentColor;
  flex-shrink: 0;
}
.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.agent-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 8px var(--green); }
  50% { box-shadow: 0 0 16px var(--green), 0 0 24px rgba(74,222,128,0.3); }
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), #FF3CAC);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-plan { font-size: 0.72rem; color: var(--orange); }

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: rgba(15,15,15,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  z-index: 50;
}
.sidebar-toggle {
  display: none;
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
}
.sidebar-toggle svg { width: 20px; height: 20px; }
.topbar-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ai-pulse-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  position: relative;
}
.pulse-ring {
  position: absolute;
  left: -2px; top: -2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--orange);
  animation: pulse-ring 2s infinite;
}
.pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--orange);
  margin-left: 2px;
}
@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

.btn-run-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--orange);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-run-agent svg { width: 14px; height: 14px; }
.btn-run-agent:hover {
  background: #FF8C5A;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--orange-glow);
}
.btn-run-agent:active { transform: translateY(0); }

/* ══════════════════════════════════════
   PANELS
══════════════════════════════════════ */
.panel {
  display: none;
  padding: 32px 28px;
  animation: fadeSlideIn 0.3s ease;
}
.panel.active { display: block; }

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

.panel-header { margin-bottom: 28px; }
.panel-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.panel-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 6px;
}

/* ══════════════════════════════════════
   CARDS
══════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-bright); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ══════════════════════════════════════
   STATS GRID
══════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
  animation: statReveal 0.5s ease both;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
@keyframes statReveal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stat-card:hover {
  border-color: var(--orange);
  box-shadow: 0 0 24px var(--orange-dim);
  transform: translateY(-2px);
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.orange { background: var(--orange-dim); }
.stat-icon.orange svg { stroke: var(--orange); }
.stat-icon.blue { background: rgba(96,165,250,0.12); }
.stat-icon.blue svg { stroke: var(--blue); }
.stat-icon.green { background: rgba(74,222,128,0.12); }
.stat-icon.green svg { stroke: var(--green); }
.stat-icon.purple { background: rgba(167,139,250,0.12); }
.stat-icon.purple svg { stroke: var(--purple); }

.stat-info { flex: 1; }
.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.stat-trend {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.stat-trend.up { background: rgba(74,222,128,0.12); color: var(--green); }
.stat-trend.down { background: rgba(248,113,113,0.12); color: var(--red); }

/* ══════════════════════════════════════
   PIPELINE
══════════════════════════════════════ */
.pipeline-section {
  margin-bottom: 28px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}
.pipeline-track {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
}
.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  flex-shrink: 0;
}
.step-node {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  transition: all var(--transition);
}
.step-node svg { width: 22px; height: 22px; stroke: var(--text-muted); }

.pipeline-step.completed .step-node {
  border-color: var(--green);
  background: rgba(74,222,128,0.1);
}
.pipeline-step.completed .step-node svg { stroke: var(--green); }
.pipeline-step.completed .step-status { color: var(--green); }

.pipeline-step.active .step-node {
  border-color: var(--orange);
  background: var(--orange-dim);
  box-shadow: 0 0 20px var(--orange-glow);
  animation: nodeGlow 2s infinite;
}
.pipeline-step.active .step-node svg { stroke: var(--orange); }
.pipeline-step.active .step-status { color: var(--orange); }
@keyframes nodeGlow {
  0%,100% { box-shadow: 0 0 20px var(--orange-glow); }
  50% { box-shadow: 0 0 35px rgba(255,107,43,0.5); }
}

.step-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}
.step-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.pipeline-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 30px;
  position: relative;
  overflow: hidden;
}
.pipeline-connector.active::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--orange), transparent);
  animation: connectorFlow 1.5s infinite;
}
@keyframes connectorFlow {
  to { left: 100%; }
}

/* ══════════════════════════════════════
   TWO COL GRID
══════════════════════════════════════ */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ══════════════════════════════════════
   VIDEO LIST
══════════════════════════════════════ */
.video-list { display: flex; flex-direction: column; gap: 12px; }
.video-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.video-item:hover { background: var(--bg-hover); }
.video-thumb {
  width: 52px; height: 36px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.video-meta { flex: 1; min-width: 0; }
.video-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-stats {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.video-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.video-badge.published { background: rgba(74,222,128,0.12); color: var(--green); }
.video-badge.scheduled { background: rgba(96,165,250,0.12); color: var(--blue); }
.video-badge.generating { background: var(--orange-dim); color: var(--orange); }

/* ══════════════════════════════════════
   ACTIVITY LOG
══════════════════════════════════════ */
.activity-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.activity-log::-webkit-scrollbar { width: 4px; }
.activity-log::-webkit-scrollbar-track { background: transparent; }
.activity-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.log-entry {
  display: flex;
  gap: 10px;
  font-size: 0.78rem;
  padding: 6px 8px;
  border-radius: 6px;
  border-left: 2px solid transparent;
}
.log-entry.success { border-left-color: var(--green); background: rgba(74,222,128,0.04); }
.log-entry.info { border-left-color: var(--blue); background: rgba(96,165,250,0.04); }
.log-entry.warning { border-left-color: var(--yellow); background: rgba(251,191,36,0.04); }
.log-time { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.7rem; flex-shrink: 0; }
.log-msg { color: var(--text-secondary); }

.live-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 0.05em;
  animation: blink 1.5s infinite;
}
@keyframes blink {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ══════════════════════════════════════
   FORMS
══════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 10px 14px;
  transition: all var(--transition);
  outline: none;
}
.form-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-dim);
}
.form-input::placeholder { color: var(--text-muted); }
select.form-input { cursor: pointer; }
select.form-input option { background: var(--bg-elevated); }

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}
.form-textarea.tall { min-height: 180px; }

.input-with-icon { position: relative; }
.input-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  stroke: var(--text-muted);
  pointer-events: none;
}
.input-with-icon .form-input { padding-left: 38px; }

.form-row { display: flex; gap: 14px; }
.form-group.half { flex: 1; }

.ai-badge {
  background: var(--orange-dim);
  color: var(--orange);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--orange);
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:hover {
  background: #FF8C5A;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--orange-glow);
}
.btn-primary.full-width { width: 100%; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--border-bright); background: var(--bg-hover); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition);
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-ghost-orange {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--orange-dim);
  border: 1px solid rgba(255,107,43,0.2);
  color: var(--orange);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  margin-bottom: 14px;
}
.btn-ghost-orange svg { width: 14px; height: 14px; }
.btn-ghost-orange:hover { background: rgba(255,107,43,0.25); }

/* ══════════════════════════════════════
   CHANNEL SETUP
══════════════════════════════════════ */
.setup-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
}
.setup-form-col, .setup-preview-col { display: flex; flex-direction: column; gap: 20px; }

.frequency-grid, .tone-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.freq-btn, .tone-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.freq-btn:hover, .tone-btn:hover { border-color: var(--orange); color: var(--orange); }
.freq-btn.active, .tone-btn.active {
  background: var(--orange-dim);
  border-color: var(--orange);
  color: var(--orange);
}

/* Channel Preview Card */
.channel-preview-card { padding: 0; overflow: hidden; }
.channel-preview-header { position: relative; }
.channel-banner {
  height: 80px;
  background: linear-gradient(135deg, #FF6B2B 0%, #FF3CAC 50%, #7B68EE 100%);
}
.channel-avatar-wrap {
  position: absolute;
  bottom: -24px;
  left: 20px;
}
.channel-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), #FF3CAC);
  border: 3px solid var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem; color: white;
}
.channel-preview-body { padding: 36px 20px 20px; }
.channel-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}
.channel-handle { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }
.channel-stats-row {
  display: flex;
  gap: 20px;
  margin: 16px 0;
}
.ch-stat { display: flex; flex-direction: column; gap: 2px; }
.ch-stat strong { font-size: 1rem; font-weight: 700; }
.ch-stat span { font-size: 0.72rem; color: var(--text-muted); }

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.conn-dot.disconnected { background: var(--text-muted); }
.conn-dot.connected { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* Permissions */
.permission-list { display: flex; flex-direction: column; gap: 12px; }
.permission-item { display: flex; align-items: center; gap: 12px; }
.perm-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.perm-icon svg { width: 14px; height: 14px; }
.perm-icon.granted { background: rgba(74,222,128,0.12); }
.perm-icon.granted svg { stroke: var(--green); }
.perm-icon.pending { background: rgba(251,191,36,0.12); }
.perm-icon.pending svg { stroke: var(--yellow); }
.perm-info { display: flex; flex-direction: column; }
.perm-info strong { font-size: 0.85rem; font-weight: 600; }
.perm-info span { font-size: 0.75rem; color: var(--text-muted); }

/* ══════════════════════════════════════
   VIDEO GENERATOR
══════════════════════════════════════ */
.generator-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.generator-controls, .generator-preview { display: flex; flex-direction: column; gap: 20px; }

.trending-topics {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  animation: fadeSlideIn 0.3s ease;
}
.topic-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.topic-chip:hover {
  border-color: var(--orange);
  color: var(--text-primary);
  background: var(--orange-dim);
}

.voice-selector {
  display: flex;
  gap: 10px;
}
.voice-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.voice-option:hover { border-color: var(--border-bright); }
.voice-option.active {
  border-color: var(--orange);
  background: var(--orange-dim);
}
.voice-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: white;
}
.voice-option span { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }
.voice-option.active span { color: var(--orange); }

.generate-btn { margin-top: 4px; }

.script-preview {
  min-height: 200px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  overflow-y: auto;
  max-height: 320px;
}
.script-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}
.script-placeholder svg { stroke: var(--text-muted); opacity: 0.5; }
.script-placeholder p { font-size: 0.82rem; font-family: var(--font-body); }

.thumbnail-preview {
  height: 160px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.thumb-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.thumb-placeholder svg { stroke: var(--text-muted); opacity: 0.5; }
.thumb-placeholder p { font-size: 0.78rem; font-family: var(--font-body); }
.thumb-controls {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Generation Progress */
.generation-progress { margin-top: 20px; }
.progress-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.prog-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: all var(--transition);
}
.prog-step.active-step {
  border-color: var(--orange);
  background: var(--orange-dim);
}
.prog-step.done-step {
  border-color: rgba(74,222,128,0.3);
  background: rgba(74,222,128,0.05);
}
.prog-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.prog-icon svg { width: 20px; height: 20px; stroke: var(--text-muted); }
.prog-step.active-step .prog-icon svg { stroke: var(--orange); }
.prog-step.done-step .prog-icon svg { stroke: var(--green); }
.prog-info { flex: 1; }
.prog-info strong { display: block; font-size: 0.85rem; font-weight: 600; }
.prog-info span { font-size: 0.75rem; color: var(--text-muted); }
.prog-status {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
}
.prog-status.pending { background: var(--bg-hover); color: var(--text-muted); }
.prog-status.processing { background: var(--orange-dim); color: var(--orange); }
.prog-status.done { background: rgba(74,222,128,0.12); color: var(--green); }

.master-progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.master-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #FF3CAC);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-align: center;
}

/* ══════════════════════════════════════
   UPLOAD MANAGER
══════════════════════════════════════ */
.upload-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
}
.upload-form-col, .upload-queue-col { display: flex; flex-direction: column; gap: 20px; }

.title-score {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.score-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}
.score-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--green));
  border-radius: 2px;
}
.score-num { color: var(--green); font-weight: 700; }

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 44px;
  align-items: center;
  transition: border-color var(--transition);
}
.tags-container:focus-within { border-color: var(--orange); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--orange-dim);
  border: 1px solid rgba(255,107,43,0.2);
  color: var(--orange);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
}
.tag-remove {
  background: none; border: none;
  color: var(--orange); cursor: pointer;
  font-size: 0.9rem; line-height: 1;
  padding: 0; margin-left: 2px;
}
.tag-input {
  background: none; border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
  min-width: 80px;
  flex: 1;
}
.tag-input::placeholder { color: var(--text-muted); }

.upload-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.upload-actions .btn-primary { flex: 1; }

/* Queue */
.queue-count {
  font-size: 0.75rem;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 20px;
}
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.queue-item.uploading { border-color: var(--orange); }
.queue-thumb {
  width: 44px; height: 30px;
  border-radius: 4px;
  flex-shrink: 0;
}
.queue-meta { flex: 1; min-width: 0; }
.queue-title {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-progress-bar {
  height: 3px;
  background: var(--bg-hover);
  border-radius: 2px;
  margin: 4px 0;
  overflow: hidden;
}
.queue-progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 2px;
  animation: progressPulse 1.5s ease-in-out infinite;
}
@keyframes progressPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.queue-status { font-size: 0.7rem; color: var(--text-muted); }
.queue-action {
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

/* Upload Times */
.upload-times-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.time-slot {
  text-align: center;
  padding: 8px 4px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.4;
}
.time-slot.best { background: rgba(74,222,128,0.15); color: var(--green); }
.time-slot.good { background: rgba(96,165,250,0.12); color: var(--blue); }
.time-slot.ok { background: var(--bg-elevated); color: var(--text-muted); }
.time-legend { display: flex; gap: 12px; }
.legend-item {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.legend-item.best { background: rgba(74,222,128,0.15); color: var(--green); }
.legend-item.good { background: rgba(96,165,250,0.12); color: var(--blue); }
.legend-item.ok { background: var(--bg-elevated); color: var(--text-muted); }

/* ══════════════════════════════════════
   ANALYTICS
══════════════════════════════════════ */
.analytics-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.filter-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 16px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--border-bright); color: var(--text-primary); }
.filter-btn.active {
  background: var(--orange-dim);
  border-color: var(--orange);
  color: var(--orange);
}

.analytics-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
}
.analytics-card:hover { border-color: var(--border-bright); transform: translateY(-2px); }
.an-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.an-value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.an-change { font-size: 0.72rem; margin-top: 4px; font-weight: 600; }
.an-change.up { color: var(--green); }
.an-change.down { color: var(--red); }

/* Top Videos Table */
.top-videos-table { overflow-x: auto; }
.table-header, .table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 10px 12px;
  font-size: 0.8rem;
  align-items: center;
}
.table-header {
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
}
.table-row {
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background var(--transition);
}
.table-row:last-child { border-bottom: none; }
.table-row:hover { background: var(--bg-hover); }
.tv-title { color: var(--text-primary); font-weight: 500; }
.ctr-good { color: var(--green); font-weight: 600; }
.ctr-avg { color: var(--yellow); font-weight: 600; }

/* ══════════════════════════════════════
   AUTOMATION RULES
══════════════════════════════════════ */
.automation-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.automation-rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
}
.automation-rule-card:hover { border-color: var(--border-bright); }
.automation-rule-card.active-rule { border-color: rgba(255,107,43,0.3); }

.rule-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.rule-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--orange-dim);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rule-icon svg { width: 18px; height: 18px; stroke: var(--orange); }
.rule-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}
.rule-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}
.rule-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-tag {
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Toggle Switch */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 22px;
  transition: all var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--orange-dim); border-color: var(--orange); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--orange); }

.add-rule-card {
  border-style: dashed;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}
.add-rule-card:hover { border-color: var(--orange); background: var(--orange-dim); }
.add-rule-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.add-rule-card:hover .add-rule-inner { color: var(--orange); }
.add-rule-inner svg { stroke: currentColor; }
.add-rule-inner span { font-size: 0.85rem; font-weight: 600; }

/* ══════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: all;
  animation: toastIn 0.3s ease;
  max-width: 340px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--orange); }
.toast.warning { border-left: 3px solid var(--yellow); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ══════════════════════════════════════
   CANVAS CHARTS (placeholder)
══════════════════════════════════════ */
canvas { display: block; width: 100% !important; }

/* ══════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-stats { grid-template-columns: repeat(3, 1fr); }
  .automation-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .setup-layout { grid-template-columns: 1fr; }
  .generator-layout { grid-template-columns: 1fr; }
  .upload-layout { grid-template-columns: 1fr; }
  .two-col-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .panel { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .analytics-stats { grid-template-columns: repeat(2, 1fr); }
  .automation-grid { grid-template-columns: 1fr; }
  .pipeline-track { gap: 8px; }
  .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .analytics-stats { grid-template-columns: 1fr 1fr; }
  .panel-title { font-size: 1.5rem; }
}