:root {
  --bg: #0e0f12; --panel: #16181d; --panel2: #1d2027; --line: #2a2e37; --text: #e8eaee; --muted: #8b92a1;
  --accent: #e4fe0b; --accent-ink: #14160a; --blue: #2d6cdf; --danger: #d9534f; --radius: 8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand b { letter-spacing: .02em; margin-right: 10px; }
button, select, input { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; }
button { cursor: pointer; } button:hover { border-color: #3a3f4b; background: #232731; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
input[type=text], input[type=number], select { background: #101216; }
input[type=number] { width: 78px; }
main { height: calc(100% - 49px); display: grid; grid-template-columns: minmax(280px, 34%) 1fr; grid-template-rows: 1fr 210px; gap: 0; }
#stage { grid-row: 1; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 0; border-right: 1px solid var(--line); }
#player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; height: calc(100% - 44px); aspect-ratio: 9 / 16; max-width: 100%; }
#vid { width: 100%; height: 100%; object-fit: contain; display: block; }
#ov-caption, #ov-layers { position: absolute; inset: 0; pointer-events: none; }
.cap { position: absolute; left: 50%; transform: translate(-50%, -50%); text-align: center; width: max-content; max-width: 96%; white-space: pre; }
.lay { position: absolute; transform: translate(-50%, -50%); }
.lay-tag { position: absolute; left: 6px; top: 6px; font-size: 11px; background: rgba(0,0,0,.65); border: 1px solid #fff4; padding: 2px 6px; border-radius: 4px; }
.overlay-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; background: #000c; }
.overlay-msg.hide { display: none; }
#transport { display: flex; align-items: center; gap: 10px; }
#panel { grid-row: 1; display: flex; flex-direction: column; min-height: 0; }
#tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
#tabs button { border-radius: 6px 6px 0 0; border-bottom: none; background: transparent; }
#tabs button.on { background: var(--panel2); border-color: var(--line); }
.tab { display: none; overflow: auto; padding: 12px; min-height: 0; flex: 1; }
.tab.on { display: block; }
.row { display: grid; grid-template-columns: 28px 150px 1fr auto; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.row.active { background: #232731; border-radius: 6px; }
.row input[type=text] { width: 100%; }
.row .t { display: flex; gap: 4px; }
.row .t input { width: 70px; padding: 3px 5px; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: #2a2e37; color: var(--muted); }
.badge.manual { background: #3a2f6e; color: #cdbfff; }
.form { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; align-items: center; max-width: 560px; }
.form h4 { grid-column: 1 / -1; margin: 12px 0 0; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.help { color: var(--muted); font-size: 12px; }
#timeline { grid-column: 1 / -1; grid-row: 2; border-top: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-width: 0; }
#tl-tools { display: flex; align-items: center; gap: 8px; padding: 6px 12px; }
#tl-scroll { overflow-x: auto; overflow-y: hidden; flex: 1; padding: 0 12px; }
#tl { display: block; height: 100%; cursor: crosshair; }
#legend { padding: 2px 12px 6px; font-size: 12px; } #legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 12px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #2a2e37; border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 80%; }
#toast.show { opacity: 1; } #toast.err { background: #4a2222; border-color: #7a3030; }
.job { padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; }
.job pre { margin: 6px 0 0; white-space: pre-wrap; color: var(--muted); font-size: 12px; max-height: 120px; overflow: auto; }
#out-video { width: 260px; max-width: 100%; border-radius: var(--radius); background: #000; margin-top: 8px; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; grid-template-rows: 46vh auto 210px; } #stage { border-right: none; } #panel { grid-row: 2; } #timeline { grid-row: 3; } }
dialog#import { width: min(720px, 94vw); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); }
dialog#import::backdrop { background: #000a; }
.im-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.im-tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); }
.im-tabs button { border-radius: 6px 6px 0 0; border-bottom: none; background: transparent; }
.im-tabs button.on { background: var(--panel2); }
.im-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow: auto; max-height: calc(90vh - 110px); }
.im-body textarea { width: 100%; background: #101216; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: inherit; }
.im-drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; cursor: pointer; }
.im-drop:hover, .im-drop.over { border-color: var(--accent); background: #1a1d12; }
.im-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); max-height: 260px; overflow: auto; }
.im-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.im-item > span:first-of-type, .im-item > input + span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-item.dir { cursor: pointer; } .im-item.dir:hover { background: #232731; }
.im-opts { display: flex; flex-wrap: wrap; gap: 10px 16px; padding-top: 4px; border-top: 1px solid var(--line); }
.im-opts label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.im-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dl { color: var(--accent); text-decoration: none; font-size: 12px; white-space: nowrap; }
#h-job { border-color: var(--accent); color: var(--accent); }
.im-step { display: flex; flex-direction: column; gap: 8px; }
.im-step h4 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
button.big { padding: 10px 18px; font-size: 15px; }
.job.queued { border-color: #5b5b2a; } .job.running { border-color: var(--blue); } .job.done { border-color: #2e8b57; } .job.error { border-color: #7a3030; }
.job .help { margin-top: 4px; }
.pg { margin: 8px 0 4px; }
.pg-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; margin-bottom: 4px; }
.pg-top .mono { color: var(--muted); }
progress { height: 10px; accent-color: var(--accent); }
dialog#login { width: min(380px, 92vw); padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); }
dialog#login::backdrop { background: #000c; }
dialog#login h3 { margin: 0 0 6px; } dialog#login input { width: 100%; margin: 12px 0; padding: 10px; font-size: 15px; }
dialog#login button { width: 100%; } .login-err { color: #ff8a85; }
.ot-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 12px 0; background: var(--panel2); }
.ot-card.pending { border-color: #5b5b2a; } .ot-card.removed { border-color: #2e8b57; } .ot-card.kept { border-color: #3a3f4b; opacity: .85; }
.ot-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .ot-state { color: var(--muted); font-size: 12px; }
.ot-text { margin: 8px 0 4px; font-style: italic; } .ot-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ot-none { color: #7fd9a1; }
.auto-form { display: flex; flex-direction: column; gap: 8px; } .auto-field { display: flex; flex-direction: column; gap: 3px; } .auto-field input { width: 100%; }
.auto-row { display: flex; gap: 14px; } ul.checks { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12.5px; } ul.checks li.ok { color: #7fd9a1; } ul.checks li.bad { color: #ff8a85; }
