:root {
  --bg: #0b0e14;
  --panel: #12161f;
  --panel-2: #181d29;
  --border: #232a3a;
  --text: #e6e9f2;
  --dim: #8a93a8;
  --accent: #7c88ff;
  --accent-2: #4e5be0;
  --ok: #34d399;
  --run: #fbbf24;
  --err: #f87171;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.dim { color: var(--dim); font-size: 13px; }
.err { color: var(--err); font-size: 13px; margin-top: 10px; }

/* ---------- login ---------- */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  width: 340px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px; text-align: center;
}
.login-box .logo { font-size: 34px; }
.login-box h1 { font-size: 20px; margin: 10px 0 4px; }
.login-box input { width: 100%; margin-top: 16px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #0e1220, #0b0e14);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { color: var(--accent); font-size: 24px; }
h1 { margin: 0; font-size: 19px; }
.sub { margin: 2px 0 0; color: var(--dim); font-size: 12px; }

main { max-width: 960px; margin: 0 auto; padding: 24px 28px 60px; }

/* ---------- buttons / inputs ---------- */
.btn {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 14px; cursor: pointer; transition: .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.del { color: var(--err); }

input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: #0a0d13; color: var(--text); font-size: 14px; font-family: inherit;
}
textarea { resize: vertical; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 6px; }

/* ---------- library ---------- */
.lib-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.lib-head h2 { margin: 0; font-size: 22px; }
.new-form { display: flex; gap: 10px; margin-bottom: 18px; padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.new-form input { flex: 1; }
.new-form select { width: 90px; }

.videos { display: flex; flex-direction: column; gap: 12px; }
.vcard {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.vcard-main { flex: 1; }
.vcard-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.vcard-stage { color: var(--dim); font-size: 13px; margin-bottom: 8px; }
.vcard-actions { display: flex; gap: 8px; }
.bar { height: 6px; background: #0a0d13; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); transition: width .3s; }
.empty { color: var(--dim); text-align: center; padding: 40px 0; }

/* ---------- builder ---------- */
.stepper { display: flex; gap: 6px; margin-bottom: 22px; overflow-x: auto; padding-bottom: 4px; }
.step {
  flex: 1; min-width: 110px; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 10px; background: var(--panel);
  border: 1px solid var(--border); color: var(--dim); font-size: 13px; white-space: nowrap;
}
.step-icon { font-size: 16px; }
.step.done { border-color: rgba(52,211,153,.4); color: var(--ok); }
.step.current { border-color: var(--accent); color: var(--text); background: var(--panel-2); }

.stage-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.stage-head h2 { margin: 0; font-size: 20px; }
.stage-body { max-width: 720px; }

.topic-selected { margin-bottom: 14px; color: var(--dim); font-size: 14px; }

/* topics */
.topics { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.topic { padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.topic-title { font-weight: 600; margin-bottom: 4px; }
.topic-hook { color: var(--text); font-size: 14px; margin-bottom: 4px; }
.topic-angle { color: var(--dim); font-size: 12px; margin-bottom: 10px; }
.topic .pick { margin-top: 4px; }
.custom-topic { display: flex; gap: 8px; margin: 14px 0; }

/* script editor */
.sc-title { margin-bottom: 12px; font-weight: 600; }
.sc-vo { margin-bottom: 16px; }
.segs { display: flex; flex-direction: column; gap: 12px; }
.seg { padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.seg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.seg-head b { font-size: 13px; }
.seg-head select { width: 130px; }
.seg-head input { flex: 1; }
.seg textarea, .seg input { margin-bottom: 8px; }

/* job / result */
.job { margin-top: 16px; color: var(--dim); font-size: 13px; }
.log {
  background: #0a0d13; border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 10px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5;
  max-height: 220px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; color: #c6cde0;
}
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; vertical-align: -2px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result { margin-top: 16px; }
audio { width: 100%; }

.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stock-thumb { width: 100%; aspect-ratio: 9/16; object-fit: cover; border-radius: 10px; background: #000; }

.final { width: 100%; max-width: 360px; aspect-ratio: 9/16; background: #000; border-radius: 12px; display: block; margin-bottom: 14px; }
.dl { display: inline-block; text-decoration: none; margin-right: 10px; }
.done-box { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }

/* ---------- voices ---------- */
.voices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.voice {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; cursor: pointer;
}
.voice input { width: auto; }
.voice span { flex: 1; }
.btn.mini { padding: 4px 9px; font-size: 12px; }
.voice .play { flex: 0 0 auto; }

/* ---------- clean status list (вместо бегущего кода) ---------- */
.status-list { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.status-line { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--dim); }
.status-line .st-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex: 0 0 auto; }
.status-line.ok { color: var(--ok); }
.status-line.err { color: var(--err); }

/* ---------- progress bar (монтаж) ---------- */
.pbar { position: relative; height: 14px; background: #0a0d13; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.pbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .4s; }
.pbar-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }

/* ---------- actions row ---------- */
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  main { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
  h1 { font-size: 16px; }
  .sub { font-size: 11px; }
  .brand .logo { font-size: 20px; }
  #back { padding: 8px 10px; font-size: 12px; }
  .step { min-width: 84px; padding: 8px 9px; font-size: 12px; gap: 5px; }
  .step-icon { font-size: 14px; }
  .stage-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .lib-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .vcard { flex-direction: column; align-items: stretch; gap: 10px; }
  .vcard-actions { justify-content: flex-start; }
  .final { max-width: 100%; }
  .btn { padding: 12px 14px; font-size: 14px; }
  .stock-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .voice { width: 100%; }
  .custom-topic { flex-direction: column; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
}
