:root {
  --bg: #0b0f17;
  --bg-elev: #111827;
  --bg-card: #151d2e;
  --bg-input: #0e1422;
  --border: #23304a;
  --border-hi: #33466b;
  --text: #eef2ff;
  --muted: #8b9bb8;
  --primary: #6366f1;
  --primary-hi: #818cf8;
  --accent: #10b981;
  --accent-hi: #34d399;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --cyan: #06b6d4;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  display: grid; place-items: center;
  font-size: 18px;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.35);
}
.brand-title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.nav-btn:hover { background: var(--bg-card); color: var(--text); }
.nav-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.5);
  color: #fff;
}

.pill-count {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}
.status-dot.online { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dep-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
}
.dep-pill.ok { color: var(--accent-hi); border-color: rgba(16, 185, 129, 0.4); }
.dep-pill.err { color: var(--rose); border-color: rgba(244, 63, 94, 0.5); }

/* Badges & Buttons */
.badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; letter-spacing: 0.4px; }
.badge-go { background: rgba(6, 182, 212, 0.2); color: #67e8f9; border: 1px solid rgba(6, 182, 212, 0.4); }
.badge-info { background: rgba(99, 102, 241, 0.2); color: #c7d2fe; border: 1px solid rgba(99, 102, 241, 0.4); }

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-xs { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }
.btn-2xs { padding: 2px 7px; font-size: 11px; border-radius: 6px; }
.btn-block { width: 100%; }

.btn-primary { background: linear-gradient(135deg, var(--primary), #4f46e5); box-shadow: 0 4px 14px rgba(99,102,241,0.3); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-accent { background: linear-gradient(135deg, var(--accent), #059669); box-shadow: 0 4px 16px rgba(16,185,129,0.3); font-size: 14px; padding: 11px 16px; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-secondary { background: #1e293b; border-color: var(--border-hi); color: var(--text); }
.btn-secondary:hover { background: #28354d; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-hi); }
.btn-danger-ghost { background: transparent; border-color: rgba(244,63,94,0.3); color: #fda4af; }
.btn-danger-ghost:hover { background: rgba(244,63,94,0.16); }
.btn-blue { background: rgba(59,130,246,0.2); border-color: rgba(59,130,246,0.5); color: #93c5fd; }
.btn-blue.active { background: #2563eb; color: #fff; }
.btn-green { background: rgba(16,185,129,0.2); border-color: rgba(16,185,129,0.5); color: #6ee7b7; }
.btn-green.active { background: #059669; color: #fff; }

/* Panels & Cards */
.tab-panel { display: none; padding: 16px 20px 36px; max-width: 1580px; width: 100%; margin: 0 auto; }
.tab-panel.active { display: block; }
.hidden { display: none !important; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.head-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Inputs */
.field-label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.input:focus { border-color: var(--primary-hi); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); }
.input-lg { padding: 10px 13px; font-size: 14px; }
.input-sm { padding: 5px 8px; font-size: 12px; }
.textarea { resize: vertical; font-family: inherit; }
label { display: block; font-size: 12px; color: var(--muted); }
label > .input, label > input[type="range"] { margin-top: 4px; }
input[type="range"] { width: 100%; accent-color: var(--primary-hi); }

.check-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--text); cursor: pointer; font-size: 12.5px; }
.check-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

/* Intake */
.intake-row { display: grid; grid-template-columns: 1fr 270px auto; gap: 12px; align-items: end; }
.intake-options-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.recent-projects-wrap { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.recent-projects-wrap select { width: 250px; }

/* Compliance Strip */
.compliance-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(99,102,241,0.12), rgba(16,185,129,0.08));
  border: 1px solid rgba(99,102,241,0.3);
}
.strip-left, .strip-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.strip-tag { font-weight: 700; color: #fff; font-size: 13px; }
.strip-badge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
}
.strip-badge.ok { color: var(--accent-hi); border-color: rgba(16,185,129,0.5); }
.strip-badge.warn { color: #fcd34d; border-color: rgba(245,158,11,0.5); }
.hashtag-preview {
  background: rgba(0,0,0,0.35);
  padding: 4px 8px;
  border-radius: 6px;
  color: #a5b4fc;
  font-size: 11.5px;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status Banner */
.status-banner { display: flex; align-items: center; gap: 14px; border-color: var(--primary); }
.spinner {
  width: 24px; height: 24px;
  border: 3px solid rgba(99,102,241,0.25);
  border-top-color: var(--primary-hi);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty Hero */
.empty-hero { text-align: center; padding: 48px 24px; }
.empty-icon { font-size: 46px; margin-bottom: 10px; }
.empty-hero h2 { margin: 0 0 8px; }
.empty-steps { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 22px; }
.step-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  max-width: 280px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.step-box span {
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary);
  display: grid; place-items: center;
  font-weight: 700;
}

/* Project Meta + Chart */
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.proj-meta { display: flex; gap: 14px; align-items: center; }
.proj-thumb { width: 120px; height: 68px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #000; }
.proj-title { margin: 0 0 4px; font-size: 16px; }
.proj-sub { font-size: 12px; color: var(--muted); }
.signal-pills { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.sig-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 99px;
  background: rgba(16,185,129,0.14); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.35);
}
.sig-pill.off { background: rgba(100,116,139,0.14); color: var(--muted); border-color: var(--border); }

.tuning-panel {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.tuning-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.tuning-footer { margin-top: 10px; text-align: right; }

.chart-wrap { position: relative; }
.chart-legend { display: flex; align-items: center; gap: 14px; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.dot-comb { background: #a855f7; }
.dot-heat { background: #f59e0b; }
.dot-chat { background: #10b981; }
.dot-audio { background: #f43f5e; }
#hypeChart {
  width: 100%;
  height: 175px;
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: crosshair;
  display: block;
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  z-index: 15;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  min-width: 155px;
}

/* Studio 2-Column Grid */
.studio-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 14px; align-items: start; }
.player-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.yt-iframe, .local-video { width: 100%; height: 100%; border: 0; display: block; }

.manual-clip-bar {
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.manual-inputs { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.manual-inputs label { width: 92px; }
.manual-inputs label.grow { flex: 1; width: auto; }

/* Framing & Crop Studio */
.layout-controls-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.crop-studio-row { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.crop-source-col { flex: 1; min-width: 300px; }
.crop-preview-col { width: 170px; flex-shrink: 0; }
.mini-label { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
#cropSourceCanvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #070a12;
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  cursor: move;
  display: block;
}
#cropOutputCanvas {
  width: 162px;
  height: 288px;
  background: #070a12;
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  display: block;
}
.edit-options-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.sub-style-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }

/* Candidates List */
.candidates-card { max-height: 1180px; display: flex; flex-direction: column; }
.batch-bar { margin-bottom: 12px; }
.candidates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 980px;
  padding-right: 4px;
}
.cand-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  transition: border-color 0.15s;
}
.cand-item.active, .cand-item:hover { border-color: var(--primary-hi); }
.cand-top { display: flex; align-items: center; gap: 10px; }
.cand-rank {
  font-weight: 800;
  font-size: 13px;
  background: rgba(99,102,241,0.22);
  color: #c7d2fe;
  padding: 2px 8px;
  border-radius: 6px;
}
.cand-score {
  margin-left: auto;
  font-weight: 800;
  font-size: 13px;
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(16,185,129,0.2);
  color: var(--accent-hi);
}
.cand-score.mid { background: rgba(245,158,11,0.2); color: #fcd34d; }

.cand-reasons { display: flex; gap: 5px; flex-wrap: wrap; margin: 7px 0; }
.reason-chip {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(245,158,11,0.16);
  color: #fde68a;
  border: 1px solid rgba(245,158,11,0.3);
}
.reason-chip.chat { background: rgba(16,185,129,0.15); color: #6ee7b7; border-color: rgba(16,185,129,0.35); }
.reason-chip.viral { background: rgba(168,85,247,0.2); color: #e9d5ff; border-color: rgba(168,85,247,0.45); }

.cand-times { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cand-times input { width: 82px; }
.cand-chats {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chat-bubble {
  font-size: 11px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: #a5f3fc;
  padding: 2px 7px;
  border-radius: 99px;
}
.cand-transcript {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
  background: rgba(255,255,255,0.03);
  padding: 5px 8px;
  border-radius: 6px;
}
.cand-hook { margin-top: 8px; }
.cand-actions { margin-top: 9px; display: flex; gap: 8px; justify-content: space-between; align-items: center; }

/* Campaigns Tab */
.campaigns-layout { display: grid; grid-template-columns: 290px 1fr; gap: 14px; align-items: start; }
.camp-list { display: flex; flex-direction: column; gap: 8px; }
.camp-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
}
.camp-item.active { border-color: var(--primary-hi); background: rgba(99,102,241,0.14); }
.camp-item-name { font-weight: 700; font-size: 13.5px; }
.camp-item-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.input-with-btn { display: flex; gap: 8px; margin-top: 4px; }
.assets-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.asset-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.asset-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.asset-head h4 { margin: 0; font-size: 13.5px; }
.asset-preview-box {
  min-height: 110px;
  background: #070a12;
  border: 1px dashed var(--border-hi);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.asset-preview-box img { max-height: 100px; max-width: 100%; object-fit: contain; }
.asset-preview-box video { max-height: 140px; max-width: 100%; border-radius: 6px; }
.file-input { width: 100%; font-size: 12px; color: var(--muted); }

/* Jobs & Clips Gallery */
.jobs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.job-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.job-title { font-weight: 700; font-size: 14px; }
.job-status { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; text-transform: uppercase; }
.st-done { background: rgba(16,185,129,0.2); color: var(--accent-hi); }
.st-rendering, .st-downloading { background: rgba(99,102,241,0.25); color: #c7d2fe; }
.st-queued { background: rgba(245,158,11,0.2); color: #fcd34d; }
.st-error, .st-canceled { background: rgba(244,63,94,0.2); color: #fda4af; }

.progress-bar { width: 100%; height: 8px; background: #1e293b; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 0.25s; }
.job-video { width: 100%; max-height: 360px; background: #000; border-radius: 8px; }
.compliance-row { display: flex; flex-wrap: wrap; gap: 5px; }
.comp-ok { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: rgba(16,185,129,0.16); color: #6ee7b7; }
.comp-warn { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: rgba(245,158,11,0.16); color: #fcd34d; }
.post-kit-box {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 11.5px;
  white-space: pre-wrap;
  color: #cbd5e1;
  max-height: 95px;
  overflow-y: auto;
}
.job-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Settings & Console */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.deps-list { display: flex; flex-direction: column; gap: 8px; }
.dep-row {
  display: flex; justify-content: space-between; gap: 8px;
  background: var(--bg-input);
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 12px;
}
.live-console {
  background: #060911;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  height: 520px;
  overflow-y: auto;
  font-family: Consolas, monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log-line { word-break: break-word; }
.log-info { color: #94a3b8; }
.log-success { color: #34d399; }
.log-warn { color: #fbbf24; }
.log-error { color: #fb7185; }

/* Toasts */
.toast-box {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #1e293b;
  border: 1px solid var(--border-hi);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  font-size: 13px;
  max-width: 360px;
}
.toast.ok { border-left: 4px solid var(--accent); }
.toast.err { border-left: 4px solid var(--rose); }
.toast.info { border-left: 4px solid var(--primary-hi); }

/* Utilities */
.muted { color: var(--muted); }
.text-xs { font-size: 11.5px; }
.ml-auto { margin-left: auto; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

/* Audio & Video FX Controls */
.fx-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 6px;
}
.bgm-row { display: flex; gap: 8px; align-items: center; }
.bgm-row select { flex: 1; }
.custom-sfx-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.sfx-cue-row {
  display: grid;
  grid-template-columns: 1fr 90px 88px 66px auto;
  gap: 6px;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}
.upload-audio-box {
  background: var(--bg-input);
  border: 1px dashed var(--border-hi);
  border-radius: 10px;
  padding: 12px;
}
.audio-lib-list { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.audio-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
}
.audio-item-meta { font-size: 11.5px; color: var(--muted); }
.audio-item-actions { display: flex; align-items: center; gap: 6px; }

@media (max-width: 1100px) {
  .studio-grid, .campaigns-layout, .settings-grid, .assets-grid { grid-template-columns: 1fr; }
  .intake-row { grid-template-columns: 1fr; }
  .tuning-grid { grid-template-columns: repeat(2, 1fr); }
}
