:root {
  --bg: #0b0d12;
  --panel: #14171f;
  --panel-2: #1b1f29;
  --line: #262b37;
  --text: #e7eaf0;
  --muted: #8b93a7;
  --accent: #6ce5b1;
  --accent-2: #7aa2ff;
  --danger: #ff6b6b;
  --warn: #ffd166;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* beat element display rules like flex/grid */
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  min-height: 100vh;
  position: relative;
}
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(122,162,255,.10), transparent 60%),
    radial-gradient(700px 400px at 0% 10%, rgba(108,229,177,.08), transparent 55%);
}

.topbar {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 16px var(--accent);
}
.brand h1 {
  font-family: "Space Grotesk", sans-serif; font-size: 20px; margin: 0; letter-spacing: .3px;
}
.brand h1 span { color: var(--muted); font-weight: 500; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel);
}
.chip.ok { color: var(--accent); border-color: rgba(108,229,177,.4); }
.chip.bad { color: var(--danger); border-color: rgba(255,107,107,.4); }

.layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(360px, 460px) 1fr; gap: 22px;
  padding: 26px; max-width: 1300px; margin: 0 auto;
}
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
}
.panel h2 { font-family: "Space Grotesk", sans-serif; margin: 0 0 4px; font-size: 18px; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
form input, form textarea, form select {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 14px; font-family: inherit;
}
form textarea { resize: vertical; }
form input:focus, form textarea:focus, form select:focus {
  outline: none; border-color: var(--accent-2);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button {
  cursor: pointer; font-family: inherit; font-weight: 600;
  border-radius: 10px; border: none; transition: transform .05s, filter .15s;
}
button:active { transform: translateY(1px); }
#submitBtn {
  width: 100%; padding: 13px; font-size: 15px; margin-top: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #07120d;
}
#submitBtn:disabled { filter: grayscale(.6) opacity(.6); cursor: progress; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 7px 12px; font-size: 13px;
}
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; }

.jobs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.job-list { display: flex; flex-direction: column; gap: 14px; }

.job {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.job-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.job-title { font-weight: 600; font-size: 15px; }
.job-sub { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.badge.queued { background: rgba(255,209,102,.15); color: var(--warn); }
.badge.running { background: rgba(122,162,255,.15); color: var(--accent-2); }
.badge.done { background: rgba(108,229,177,.15); color: var(--accent); }
.badge.error { background: rgba(255,107,107,.15); color: var(--danger); }

.progress { height: 8px; background: #0e1118; border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.progress > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.stage { font-size: 12px; color: var(--muted); }

.logs {
  margin-top: 12px; max-height: 150px; overflow-y: auto; font-size: 12px;
  background: #0e1118; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #aab3c5; white-space: pre-wrap;
}
.logs .err { color: var(--danger); }

.result { margin-top: 14px; }
.result video { width: 100%; border-radius: 10px; background: #000; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.actions a, .actions button {
  font-size: 13px; padding: 9px 14px; border-radius: 9px; text-decoration: none;
  border: 1px solid var(--line); color: var(--text); background: var(--panel);
  display: inline-flex; align-items: center; gap: 6px;
}
.actions a.primary { background: var(--accent); color: #07120d; border-color: transparent; font-weight: 600; }
.meta { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.meta code { background: #0e1118; padding: 1px 6px; border-radius: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tags span { font-size: 11px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px; }
.copy-area { width: 100%; margin-top: 10px; font-size: 12px; min-height: 80px; }

.tagline { color: var(--muted); font-size: 12px; margin-left: 4px; align-self: center; }

.hg-controls { display: grid; grid-template-columns: 1fr 130px; gap: 8px; margin-top: 6px; }
#heygenAvatar { margin-top: 8px; }
.hg-preview { margin: 10px 0 14px; }
.hg-preview img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px; background: #0e1118; border: 1px solid var(--line); }
.muted-inline { color: var(--muted); font-weight: 400; }

.avatar-preview {
  display: flex; gap: 12px; align-items: center; margin-bottom: 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.avatar-preview img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #000; }
.link-danger {
  background: none; border: none; color: var(--danger); font-size: 12px; padding: 2px 0; cursor: pointer;
}

.upload-block {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
  background: var(--panel-2);
}
.upload-block summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.upload-block label { margin-top: 10px; }
.upload-block input[type=file] { margin-top: 8px; color: var(--muted); font-size: 12px; }

.cost-preview {
  font-size: 13px; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px;
}
.cost-preview strong { color: var(--accent); }

.cost-box {
  margin-top: 12px; background: #0e1118; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
.cost-total { font-size: 14px; }
.cost-total strong { color: var(--accent); }
.cost-rows { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; font-size: 12px; color: var(--muted); }
