:root {
  --bg: #050505;
  --bg-card: #0d0d0d;
  --bg-elevated: #141414;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --text: #f8f8f8;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);
  --success: #10b981;
  --warn: #fbbf24;
  --error: #ef4444;
  --violet: #a78bfa;
  --sky: #38bdf8;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --sidebar-w: 240px;
  --nav-h: 56px;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; }

.mesh-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 12% 0%, rgba(59, 130, 246, 0.09) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 80%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
    #050505;
}

.grain::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(5, 5, 5, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.nav-left, .nav-right { display: flex; align-items: center; gap: 12px; }
.nav-logo {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 15px;
}
.nav-logo span { color: var(--accent); }
.nav-meta { color: var(--muted); font-size: 12px; }

.stub-pill {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--warn);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 999px;
  padding: 6px 12px;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, 0.5);
}

.app-layout {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  top: var(--nav-h);
  bottom: 0;
  left: 0;
  background: rgba(13, 13, 13, 0.92);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-brand { padding: 24px 20px 16px; border-bottom: 1px solid var(--border); }
.sa-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  margin-bottom: 12px;
}
.sa-name { font-family: var(--font-display); font-weight: 600; }
.sa-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.sidenav { padding: 16px 0; flex: 1; }
.sidenav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 20px;
}
.sidenav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--muted);
  border-left: 2px solid transparent;
  min-height: 44px;
  font-size: 14px;
  transition: color 0.15s ease, background 0.15s ease;
}
.sidenav-item:hover { color: var(--text); background: var(--bg-elevated); }
.sidenav-item.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
  font-weight: 600;
}
.nav-icon { display: grid; place-items: center; width: 22px; color: inherit; }

.sidebar-foot {
  padding: 16px 20px 24px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 32px 80px;
  max-width: 1180px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}
h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.03em;
  font-weight: 700;
  line-height: 1.1;
}
.lede { color: var(--muted); margin-top: 8px; max-width: 560px; line-height: 1.6; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-val {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}
.stat-lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: rgba(59, 130, 246, 0.28); }
.card-link:hover { transform: translateY(-2px); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.14);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.04); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.banner {
  border: 1px solid rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.06);
  color: #fde68a;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  margin-bottom: 24px;
}

.jobs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.job-row {
  display: grid;
  grid-template-columns: 1.4fr 140px 100px 140px 44px;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  text-align: left;
}
.job-title { font-weight: 600; }
.job-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: fit-content;
}
.badge-done { color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.08); }
.badge-run { color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.35); background: rgba(59, 130, 246, 0.1); }
.badge-err { color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.1); }
.badge-queue { color: var(--muted); border: 1px solid var(--border); }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.note-card h3 { font-family: var(--font-display); font-size: 18px; margin-bottom: 8px; }
.note-card p { color: var(--muted); font-size: 13px; line-height: 1.55; min-height: 60px; }
.note-actions { display: flex; gap: 8px; margin-top: 16px; }

.form-grid { display: grid; gap: 16px; }
label { display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.input, textarea, select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
select:disabled { opacity: 0.7; }

.subnav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.subnav a, .subnav button {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.subnav a.active, .subnav button.active {
  color: var(--text);
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.12);
}

.timeline {
  display: flex;
  gap: 4px;
  margin: 12px 0 28px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.tl-scene { min-width: 72px; }
.tl-bar {
  height: 64px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
}
.tl-scene:nth-child(3n) .tl-bar { background: linear-gradient(135deg, #0ea5e9, #38bdf8); }
.tl-scene:nth-child(3n+2) .tl-bar { background: linear-gradient(135deg, #059669, #34d399); }
.tl-meta {
  font-size: 12px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--muted);
}
.tl-meta strong { color: var(--text); font-weight: 600; }

.script-block { display: grid; gap: 12px; }
.script-block h3 {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.broll-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.clip {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0a0a0a;
}
.clip.selected { border-color: rgba(59, 130, 246, 0.5); }
.clip-poster {
  height: 88px;
  display: grid;
  place-items: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #dbeafe;
}
.clip-body { padding: 10px 12px 12px; }
.clip-body strong { display: block; font-size: 13px; margin-bottom: 4px; }
.clip-body span { color: var(--muted); font-size: 11px; display: block; word-break: break-all; }

.steps {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin: 16px 0 28px;
}
.step {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
}
.step.on { background: var(--accent); }
.step.done { background: var(--success); }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.help { font-size: 12px; color: var(--muted); }

.yt-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  align-items: center;
}
.yt-thumb {
  height: 90px;
  border-radius: 8px;
  background: linear-gradient(135deg, #111827, #1e3a8a);
  display: grid;
  place-items: center;
  color: #93c5fd;
  font-size: 11px;
  letter-spacing: 0.1em;
}

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
}

.empty { color: var(--muted); padding: 32px 0; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 60;
  padding: 12px 18px;
  background: #0d0d0d;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  font-size: 14px;
}
.toast.error { border-color: rgba(239, 68, 68, 0.35); }

.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

@media (max-width: 980px) {
  .stat-grid, .settings-grid, .broll-grid, .split, .yt-card, .job-row { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar {
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    z-index: 30;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; padding: 24px 16px 96px; }
  .nav-meta { display: none; }
}

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