/* Audio → Video Generator — UI styles (no external dependencies) */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #1a1f2b;
  --muted: #5f6b7d;
  --faint: #8a94a6;
  --border: #e3e7ee;
  --primary: #3b5bdb;
  --primary-strong: #2f4ac0;
  --primary-soft: #eef2ff;
  --success: #2b8a3e;
  --success-soft: #ebfbee;
  --warning: #c77700;
  --warning-soft: #fff4e0;
  --danger: #d6336c;
  --danger-strong: #c2255c;
  --danger-soft: #fff0f6;
  --info-soft: #e7f5ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 236px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a22;
    --surface-2: #1b202a;
    --text: #e6e9ef;
    --muted: #a0a9b8;
    --faint: #7b8494;
    --border: #2a303c;
    --primary: #6b8afd;
    --primary-strong: #8aa2ff;
    --primary-soft: #1d2640;
    --success: #51cf66;
    --success-soft: #16281c;
    --warning: #fcc419;
    --warning-soft: #2c2410;
    --danger: #ff6b9a;
    --danger-strong: #ff8fb1;
    --danger-soft: #2e1620;
    --info-soft: #152331;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; font-size: 15px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), #7048e8);
  display: grid; place-items: center; color: #fff; }
.brand small { display: block; font-weight: 500; color: var(--faint); font-size: 11.5px; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted);
  font-weight: 550; font-size: 13.5px; letter-spacing: .01em; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: 0 0 18px; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.worker-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 6px; }
.worker-dot.busy { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.content { max-width: 1120px; margin: 0 auto; padding: 26px 28px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }

@media (max-width: 900px) {
  .app { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30; font-weight: 700; }
  .content { padding: 18px 16px 48px; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
}
@media (min-width: 901px) and (max-width: 1100px) { .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ----------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.tight { padding: 14px 16px; }
.card h2 + p, .card h3 + p { margin-top: 4px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; letter-spacing: -.02em; }
.stat .sub { color: var(--faint); font-size: 12.5px; }

/* --------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 14px;
  border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-strong); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.big { padding: 14px 28px; font-size: 16px; border-radius: 10px; letter-spacing: .02em; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { padding: 6px; }

/* ----------------------------------------------------------------- forms */
label.field { display: block; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field .hint { color: var(--faint); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font: inherit; font-size: 14px; }
textarea { min-height: 70px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--primary); flex: 0 0 17px; }
.check .t { font-weight: 550; }
.check .d { display: block; color: var(--faint); font-size: 12px; font-weight: 400; }
.options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; }
@media (max-width: 700px) { .options-grid { grid-template-columns: 1fr; } }
.input-row { display: flex; gap: 8px; }
.input-row > input { flex: 1; }

/* ------------------------------------------------------------- dropzone */
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px; text-align: center; background: var(--surface-2);
  transition: border-color .15s, background .15s; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop .big-icon { width: 38px; height: 38px; color: var(--primary); margin-bottom: 6px; }
.drop strong { display: block; font-size: 15px; }
.file-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.file-chip .name { font-weight: 600; word-break: break-all; }
.file-chip svg { width: 22px; height: 22px; color: var(--primary); flex: 0 0 22px; }

/* ------------------------------------------------------------- progress */
.progress { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), #7048e8); border-radius: 999px; transition: width .6s ease; }
.progress.big { height: 16px; }
.progress.done > div { background: var(--success); }
.progress.fail > div { background: var(--danger); }
.progress.indet > div { width: 30% !important; animation: indet 1.3s infinite ease-in-out; }
@keyframes indet { from { margin-left: -30%; } to { margin-left: 100%; } }
.pct { font-size: 34px; font-weight: 750; letter-spacing: -.03em; }

.stages { list-style: none; margin: 0; padding: 0; }
.stages li { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--border); }
.stages li:last-child { border-bottom: 0; }
.stages .st-icon { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; font-size: 12px; }
.st-done { background: var(--success-soft); color: var(--success); }
.st-running { color: var(--primary); }
.st-pending { background: var(--surface-2); color: var(--faint); border: 1px solid var(--border); }
.st-failed { background: var(--danger-soft); color: var(--danger); }
.stages .count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); font-weight: 550; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* --------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.running, .badge.queued { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge.completed, .badge.ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.failed, .badge.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.paused, .badge.waiting, .badge.interrupted, .badge.warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.chip { display: inline-block; padding: 2px 9px; margin: 2px 4px 2px 0; border-radius: 6px; background: var(--primary-soft); color: var(--primary); font-size: 12.5px; font-weight: 550; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-soft); font-size: 13.5px; }
.notice svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }
.notice.warning { background: var(--warning-soft); }
.notice.warning svg { color: var(--warning); }
.notice.danger { background: var(--danger-soft); }
.notice.danger svg { color: var(--danger); }
.notice.success { background: var(--success-soft); }
.notice.success svg { color: var(--success); }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650;
  padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.mini-progress { width: 120px; }

/* ------------------------------------------------------------ media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.media-card .thumb { aspect-ratio: 16 / 9; background: var(--surface-2); display: grid; place-items: center; position: relative; overflow: hidden; cursor: pointer; }
.media-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card .thumb .kind { position: absolute; top: 6px; left: 6px; }
.media-card .meta { padding: 8px 10px; font-size: 12.5px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.media-card .meta .title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.media-card.selected { outline: 2px solid var(--primary); }
.kind { background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 5px; letter-spacing: .03em; }

/* ---------------------------------------------------------------- review */
.scene { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; }
.scene-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.scene-head .time { font-family: var(--mono); color: var(--muted); font-size: 12.5px; }
.scene .narration { margin: 8px 0 10px; color: var(--text); font-size: 13.5px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.slot { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); display: flex; flex-direction: column; }
.slot .thumb { aspect-ratio: 16/9; background: #000; position: relative; cursor: pointer; }
.slot .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot .thumb .kind { position: absolute; top: 6px; left: 6px; }
.slot .thumb .lock { position: absolute; top: 6px; right: 6px; }
.slot .body { padding: 8px 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.slot .actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 10px 10px; }
.panel { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 12px; }

/* ----------------------------------------------------------------- logs */
.log { background: #0b0d12; color: #d8dee9; border-radius: var(--radius-sm); padding: 12px 14px; height: 460px; overflow: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.log .l-err { color: #ff8787; }
.log .l-warn { color: #ffd43b; }
.log .l-dim { color: #7d8595; }

/* -------------------------------------------------------- modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(10, 12, 18, .55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px; }
.modal.wide { width: min(980px, 100%); }
.modal h2 { margin-bottom: 8px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); box-shadow: var(--shadow-lg);
  padding: 11px 14px; border-radius: 10px; min-width: 260px; max-width: 420px; font-size: 13.5px; animation: slidein .2s ease; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }
video.preview { width: 100%; border-radius: var(--radius-sm); background: #000; max-height: 480px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--faint); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }
details.adv > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; padding: 6px 0; }
.precheck { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 800px) { .precheck { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.precheck .box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.precheck .box .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.precheck .box .v { font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.precheck .box.ready .v { color: var(--success); }
.precheck .box.tight .v { color: var(--warning); }
.precheck .box.insufficient .v { color: var(--danger); }
.live { display: grid; grid-template-columns: 1fr; gap: 2px 22px; }
.live div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border); padding: 5px 0; font-size: 13.5px; }
.live span:first-child { color: var(--muted); }
.live span:last-child { font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 65%; }

/* ------------------------------------------------------ accounts & queue */
.auth { min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); padding: 28px; }
.auth-card h1 { margin: 6px 0 4px; }
.auth-card > p { margin: 0 0 18px; }
.auth-brand { padding: 0 0 14px; }
.auth-brand .logo svg { width: 16px; height: 16px; }
.user-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.user-box:empty { display: none; }
.user-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.user-name { font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .pos { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary); font-size: 12px; font-weight: 700; }
.job-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; display: inline-block; vertical-align: bottom; }
.job.failed { border-color: var(--danger-soft); }
.fail-text { color: var(--danger); }
.badge.draft { background: var(--surface-2); color: var(--muted); }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-list .file-chip .progress { margin-top: 6px; }
.file-chip.error { border-color: var(--danger); }
