:root {
  --bg: #0d0f14;
  --bg-2: #141720;
  --card: #191d28;
  --card-2: #1f2432;
  --line: #2a3042;
  --text: #eef0f6;
  --muted: #8b93a7;
  --accent: #ff4d2e;
  --accent-2: #ffb02e;
  --ok: #2ed47a;
  --info: #4da3ff;
  --violet: #a77bff;
  --danger: #ff5c7a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(255, 77, 46, .10), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(167, 123, 255, .08), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, sans-serif;
}
h1, h2, h3, .logo { font-family: 'Space Grotesk', Inter, sans-serif; letter-spacing: -.01em; }
h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; margin: 0; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  background: rgba(20, 23, 32, .8); backdrop-filter: blur(12px);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 24px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo.big { font-size: 26px; justify-content: center; }
.logo-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; font-size: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 6px 18px rgba(255, 77, 46, .4);
}
nav { display: flex; flex-direction: column; gap: 4px; }
nav a {
  display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-weight: 500; transition: .15s;
}
nav a span { width: 18px; text-align: center; }
nav a:hover { background: var(--card); color: var(--text); }
nav a.active { background: linear-gradient(90deg, rgba(255, 77, 46, .18), transparent); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.auto-pill { font-size: 12px; padding: 8px 10px; border-radius: 10px; background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.auto-pill.on { color: var(--ok); border-color: rgba(46, 212, 122, .4); }
.auto-pill.on::before { content: '● '; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.view { padding: 32px clamp(16px, 4vw, 48px); max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }

/* ---------- controls ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card-2); color: var(--text); font: inherit; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #3a4259; transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ff7a2e); border-color: transparent; box-shadow: 0 6px 18px rgba(255, 77, 46, .3); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12px; }
input, textarea, select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  font: inherit; padding: 10px 12px; border-radius: 10px; outline: none; transition: .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 77, 46, .15); }
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.field { margin-bottom: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; background: var(--card-2); color: var(--muted); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-idea { color: var(--muted); }
.s-scripting, .s-rendering, .s-running, .s-queued, .s-publishing { color: var(--accent-2); }
.s-scripted { color: var(--info); }
.s-rendered { color: var(--violet); }
.s-published, .s-done { color: var(--ok); }
.s-failed { color: var(--danger); }

/* ---------- overview ---------- */
.hero {
  position: relative; overflow: hidden; padding: 28px; border-radius: 20px; margin-bottom: 24px;
  background: linear-gradient(135deg, rgba(255, 77, 46, .22), rgba(167, 123, 255, .12) 60%, transparent), var(--card);
  border: 1px solid var(--line);
}
.hero::after {
  content: '?'; position: absolute; right: 30px; top: -40px; font: 700 220px/1 'Space Grotesk'; color: rgba(255, 255, 255, .04);
}
.hero p { max-width: 560px; margin: 6px 0 18px; }
.quick-add { display: flex; gap: 10px; max-width: 640px; }
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 24px; }
.flow-step {
  position: relative; padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  text-decoration: none; transition: .15s;
}
.flow-step:hover { border-color: #3a4259; transform: translateY(-2px); }
.flow-step:not(:last-child)::after {
  content: '→'; position: absolute; right: -12px; top: 50%; transform: translateY(-50%); color: var(--muted); z-index: 1;
}
.flow-step .num { font: 700 34px/1 'Space Grotesk'; }
.flow-step .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.flow-step .icon { font-size: 20px; margin-bottom: 10px; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.progress { height: 4px; background: var(--bg-2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: center; }
.checklist .tick { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--card-2); border: 1px solid var(--line); }
.checklist .done .tick { background: var(--ok); border-color: var(--ok); color: #062; }

/* ---------- pipeline board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.column { background: rgba(25, 29, 40, .6); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 300px; }
.column-head { display: flex; justify-content: space-between; align-items: center; margin: 2px 4px 12px; font-weight: 700; font-size: 13px; }
.column-head .count { color: var(--muted); font-weight: 600; }
.topic-card {
  display: block; text-decoration: none; padding: 14px; margin-bottom: 10px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line); transition: .15s;
}
.topic-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.topic-card .t { font-weight: 600; margin-bottom: 6px; }
.topic-card .meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }

/* ---------- topic detail ---------- */
.detail { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.scene {
  display: grid; grid-template-columns: 40px 1fr 140px; gap: 14px; padding: 16px; margin-bottom: 12px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
}
.scene-no { font: 700 20px 'Space Grotesk'; color: var(--accent); }
.scene textarea { min-height: 90px; margin-bottom: 8px; }
.scene-media {
  width: 140px; height: 90px; border-radius: 10px; border: 1px dashed var(--line); background: var(--bg-2) center/cover;
  display: grid; place-items: center; color: var(--muted); font-size: 12px; cursor: pointer; text-align: center; overflow: hidden;
}
.scene-media:hover { border-color: var(--accent); color: var(--text); }
.scene-media video { width: 100%; height: 100%; object-fit: cover; }
.side-stack { display: grid; gap: 16px; position: sticky; top: 24px; }
.stat-line { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); }
.stat-line b { color: var(--text); }

/* ---------- media ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: 18px; padding: 34px; text-align: center; cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 77, 46, .04), transparent); transition: .15s; margin-bottom: 20px;
}
.dropzone.drag, .dropzone:hover { border-color: var(--accent); background: rgba(255, 77, 46, .08); }
.dropzone .big-icon { font-size: 36px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: .15s; }
.media-item:hover { border-color: #3a4259; }
.media-item.pickable { cursor: pointer; }
.media-item.pickable:hover { border-color: var(--accent); }
.media-thumb { aspect-ratio: 16/9; background: var(--bg-2) center/cover; position: relative; }
.media-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .kind { position: absolute; top: 8px; left: 8px; }
.media-info { padding: 10px 12px; }
.media-info .name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-info input { padding: 6px 8px; font-size: 12px; margin-top: 6px; }

/* ---------- videos ---------- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.video-card video { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 10px; margin-bottom: 12px; }

/* ---------- empty / modal / toast ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .big-icon { font-size: 40px; margin-bottom: 8px; }
.modal { position: fixed; inset: 0; background: rgba(5, 6, 10, .7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(900px, 100%); max-height: 85vh; overflow: auto; box-shadow: var(--shadow); }
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 60; padding: 12px 18px; border-radius: 12px; max-width: 380px;
  background: var(--card-2); border: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateY(150%); transition: .25s; font-weight: 500;
}
.toast.show { transform: none; }
.toast.err { border-color: var(--danger); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); text-align: center; display: grid; gap: 14px; padding: 36px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .two-col, .detail { grid-template-columns: 1fr; }
  .flow { grid-template-columns: repeat(2, 1fr); }
  .flow-step::after { display: none; }
  .side-stack { position: static; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 12px; }
  nav { flex-direction: row; overflow-x: auto; width: 100%; }
  nav a { padding: 8px 10px; }
  .sidebar-foot { flex-direction: row; margin: 0 0 0 auto; }
  .view { padding: 20px 16px; }
  .quick-add { flex-direction: column; }
  .scene { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(5, 240px); }
}

/* ---------- agents ---------- */
.angle { white-space: pre-line; max-width: 900px; margin: -12px 0 20px; }
.job-banner { margin-bottom: 20px; border-left: 3px solid currentColor; }
.job-banner > * { color: var(--text); }
.job-banner .muted { color: var(--muted); }
.img-prompt { margin-top: 8px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.img-prompt summary { cursor: pointer; font-size: 12px; font-weight: 600; }
.img-prompt p { font-size: 13px; color: var(--muted); margin: 8px 0; }

/* ---------- Google credit ---------- */
.credit { padding: 12px 14px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 16px; }
.credit .progress > div { background: var(--ok); }
.credit-warn .progress > div { background: var(--accent-2); }
.credit-critical .progress > div, .credit-stopped .progress > div { background: var(--danger); }
.credit-warn { border-color: rgba(255, 176, 46, .5); }
.credit-critical, .credit-stopped { border-color: rgba(255, 92, 122, .6); }
.credit-banner { font-size: 12px; line-height: 1.4; padding: 10px 12px; border-radius: 10px; border: 1px solid; }
.credit-banner.credit-warn { color: var(--accent-2); background: rgba(255, 176, 46, .08); }
.credit-banner.credit-critical, .credit-banner.credit-stopped { color: var(--danger); background: rgba(255, 92, 122, .08); }
.credit-banner div { color: var(--text); margin-top: 4px; }

/* ---------- shots ---------- */
.shots { display: grid; gap: 6px; margin-top: 8px; }
.shot { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: center; font-size: 12px; padding: 6px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); }
.shot-thumb { width: 72px; height: 40px; border-radius: 6px; background: var(--card) center/cover; overflow: hidden; }
.shot-thumb video { width: 100%; height: 100%; object-fit: cover; }
.shot .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
