:root {
  --bg: #0b0c0e;
  --panel: #131418;
  --panel-2: #1a1c21;
  --line: #262931;
  --text: #e8e9ec;
  --muted: #8a8f9a;
  --accent: #ff5a1f;
  --accent-soft: rgba(255, 90, 31, .12);
  --green: #3ccf91;
  --red: #ff4d5e;
  --yellow: #ffc145;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Inter Tight", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
a { color: inherit; }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
h2 { font-size: 18px; margin: 28px 0 12px; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.hint { font-size: 13px; max-width: 820px; margin-top: 0; }

/* top */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: rgba(11,12,14,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.logo { font: 600 14px var(--mono); letter-spacing: .14em; display: flex; align-items: center; gap: 10px; }
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.status { flex: 1; font: 12px var(--mono); color: var(--muted); }
.status .live { color: var(--accent); }
.status .live::before { content: "● "; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.top-actions { display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; color: var(--muted); font: 500 14px var(--sans); padding: 14px 14px 12px;
  border-bottom: 2px solid transparent; cursor: pointer; }
.tab.active { color: var(--text); border-color: var(--accent); }
main { padding: 20px 24px 80px; max-width: 1400px; margin: 0 auto; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font: 500 13px var(--sans); padding: 8px 14px; border-radius: 8px; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: #3a3e48; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #ff6f3c; border-color: #ff6f3c; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 8px 7px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; font-weight: 500; font-size: 14px; }
.chip.active { border-color: var(--accent); background: var(--accent-soft); }
.chip .badge { font: 600 11px var(--mono); background: var(--panel-2); padding: 2px 7px; border-radius: 999px; color: var(--muted); }
.chip.active .badge { background: var(--accent); color: #fff; }
.chip .run { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 50%; }
.chip .run:hover { color: var(--accent); }
.chip.no-run { padding-right: 14px; }

.filters { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); font: 500 13px var(--sans); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button.active { background: var(--panel-2); color: var(--text); }
.sort label { font-size: 13px; color: var(--muted); display: flex; flex-direction: row; gap: 8px; align-items: center; }

/* form controls */
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font: 14px var(--sans); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.45; }
select { width: auto; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label small { font-size: 11px; }
.switch-row { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* feed */
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card.hot { border-color: rgba(255, 90, 31, .55); box-shadow: 0 0 0 1px rgba(255,90,31,.15), 0 8px 30px -12px rgba(255,90,31,.35); }
.card-top { display: grid; grid-template-columns: 200px 1fr; gap: 14px; padding: 14px; }
.thumb { position: relative; display: block; aspect-ratio: 16/10; border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dur { position: absolute; right: 6px; bottom: 6px; font: 600 11px var(--mono); background: rgba(0,0,0,.75); padding: 2px 6px; border-radius: 4px; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; color: #fff; opacity: 0; transition: opacity .15s; background: rgba(0,0,0,.3); }
.thumb:hover .play { opacity: 1; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.tag { font: 600 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 3px 7px; border-radius: 4px; background: var(--panel-2); color: var(--muted); }
.tag.hot { background: var(--accent); color: #fff; }
.tag.acc { color: var(--text); }
.author { font-weight: 600; font-size: 14px; }
.author span { color: var(--muted); font-weight: 400; }
.src-text { font-size: 13px; color: #c4c7ce; margin: 6px 0 10px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.metric { background: var(--panel-2); border-radius: 6px; padding: 6px 8px; }
.metric b { display: block; font: 600 14px var(--mono); }
.metric small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.metric.vel b { color: var(--accent); }

.posts { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.post { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.post textarea { border: 0; padding: 0; background: transparent; min-height: 64px; font-size: 14px; }
.post-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.post-actions .count { margin-right: auto; font: 11px var(--mono); color: var(--muted); }
.post-actions .count.over { color: var(--red); }
.card-foot { display: flex; gap: 8px; padding: 0 14px 14px; align-items: center; }
.card-foot input { flex: 1; padding: 7px 10px; font-size: 13px; }

.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* accounts */
.section-head { display: flex; justify-content: space-between; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.acc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.acc-head h3 { margin: 0; font-size: 16px; }
.acc-head .cost { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: end; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-top: 14px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; grid-column: 1 / -1; }
.form-actions .spacer { flex: 1; }

/* runs */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num { font-family: var(--mono); }
td.err { color: var(--red); white-space: normal; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 9px; font-size: 14px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.5); }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(360px, 90vw); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login-card .logo { margin-bottom: 4px; }
.login-card .muted { margin: 0 0 8px; font-size: 13px; }
.err { color: var(--red); font-size: 13px; margin: 0; }

/* studio */
.studio { display: grid; grid-template-columns: 420px 1fr; gap: 18px; align-items: start; }
.studio-form { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 76px; }
.studio-form select { width: 100%; }
.grid-3.tight { gap: 10px; }
.source-note { font-size: 12px; color: var(--muted); background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.source-note button { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
.jobs { display: flex; flex-direction: column; gap: 14px; }
.job { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 16px; padding: 14px; }
.job video { width: 100%; border-radius: 8px; background: #000; display: block; max-height: 520px; }
.job-wait { aspect-ratio: 1; border-radius: 8px; background: var(--panel-2); display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); font-size: 13px; }
.job-wait b { display: block; color: var(--text); font-size: 15px; margin-bottom: 6px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 12px; width: 180px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.job-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.job-brief { font-size: 13px; color: #c4c7ce; white-space: pre-wrap; max-height: 80px; overflow: auto; }
.job-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.job details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.job details textarea { font-family: var(--mono); font-size: 12px; margin-top: 8px; min-height: 220px; }
.job .err-box { color: var(--red); font-size: 13px; background: rgba(255,77,94,.08); border-radius: 8px; padding: 8px 10px; }

@media (max-width: 1100px) { .studio { grid-template-columns: 1fr; } .studio-form { position: static; } }
@media (max-width: 760px) { .job { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .status { order: 3; flex-basis: 100%; }
  main, .tabs { padding-left: 16px; padding-right: 16px; }
  .feed { grid-template-columns: 1fr; }
  .card-top { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-6 { grid-template-columns: repeat(2, 1fr); }
}
