:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a; --text: #e6e8ee; --muted: #8b92a3;
  --accent: #5b8cff; --accent2: #3f6fe0; --danger: #e5484d; --ok: #30a46c; --warn: #f5a524;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--accent); border: 0; border-radius: 6px; padding: 7px 12px; cursor: pointer; color: #fff; }
button:hover { background: var(--accent2); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.ghost:hover { background: var(--panel2); }
button.danger { color: var(--danger); }
button.primary { background: var(--ok); }
button.primary:hover { background: #278a5b; }
select, input[type=number], input[type=text], input[type=password], input:not([type]) {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0;
}
.muted { color: var(--muted); }
.mono { font-family: Consolas, ui-monospace, monospace; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0; }

header { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 700; margin-right: 10px; }
.brand span { color: var(--accent); }
header select { min-width: 200px; }

main { flex: 1; display: grid; grid-template-columns: 300px 1fr 320px; min-height: 0; }
main.empty > *:not(.empty-note) { display: none; }
.empty-note { display: none; }
main.empty { display: flex; align-items: center; justify-content: center; }
main.empty .empty-note { display: block; color: var(--muted); }

aside { background: var(--panel); display: flex; flex-direction: column; min-height: 0; overflow: auto; }
aside section { padding: 14px; border-bottom: 1px solid var(--line); }
aside section.grow { flex: 1; }
.library { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }

.drop { display: block; border: 1.5px dashed var(--line); border-radius: 8px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.small { padding: 10px; }
.drop.over, .drop:hover { border-color: var(--accent); color: var(--text); }
.drop.has { border-style: solid; text-align: left; color: var(--text); }

.clip { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--panel2); cursor: pointer; }
.clip.armed { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.clip .thumb { width: 64px; height: 40px; object-fit: cover; border-radius: 4px; background: #000; border-left: 4px solid var(--c); }
.clip .name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip .meta { font-size: 11px; color: var(--muted); }
.clip input { width: 100%; font-size: 12px; padding: 4px 6px; margin-top: 4px; grid-column: 1 / -1; }
.clip .x { background: none; color: var(--muted); padding: 0 4px; font-size: 16px; line-height: 1; }
.clip .x:hover { color: var(--danger); background: none; }

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px; gap: 10px; }
.canvas-wrap { flex: 1; min-height: 160px; display: flex; align-items: center; justify-content: center; container-type: size; }
.canvas { display: flex; background: #000; border-radius: 6px; overflow: hidden; box-shadow: 0 8px 30px #0008;
  aspect-ratio: 16 / 9; width: min(100cqw, 100cqh * 16 / 9); }
.canvas.vertical { flex-direction: column; aspect-ratio: 9 / 16; width: min(100cqw, 100cqh * 9 / 16); }
.panel { position: relative; overflow: hidden; background: #050505; flex: 0 0 auto; }
.canvas:not(.vertical) .panel { height: 100%; }
.canvas.vertical .panel { width: 100%; }
.panel video, .panel img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.panel .clipmedia { visibility: hidden; }
.panel .clipmedia.on { visibility: visible; }
.panel .label { position: absolute; left: 6px; top: 6px; z-index: 2; font-size: 11px; background: #000a; padding: 2px 6px; border-radius: 4px; color: #fff; pointer-events: none; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.transport { display: flex; align-items: center; gap: 12px; }
.round { width: 36px; height: 36px; border-radius: 50%; padding: 0; }
.caption { color: var(--muted); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 50%; }

.timeline { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; overflow-y: hidden; flex: 0 0 auto; }
.tl-inner { position: relative; height: 112px; min-width: 100%; }
.ruler { position: absolute; left: 0; right: 0; top: 0; height: 20px; border-bottom: 1px solid var(--line); cursor: pointer; overflow: hidden; }
.ruler .tick { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line); font-size: 10px; color: var(--muted); padding-left: 3px; }
.track { position: absolute; left: 0; right: 0; }
.speech { top: 24px; height: 28px; }
.clipsTrack { top: 58px; height: 46px; }
.block { position: absolute; top: 0; bottom: 0; border-radius: 4px; overflow: hidden; font-size: 11px; padding: 3px 6px; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.speech .block { background: #2b3242; color: #c5cad6; border: 1px solid #353d50; }
.speech .block:hover { background: #343d52; }
.clipsTrack .block { background: color-mix(in srgb, var(--c) 45%, #111); border: 1px solid var(--c); color: #fff; }
.clipsTrack .block.sel { outline: 2px solid #fff; z-index: 2; }
.clipsTrack .block small { display: block; opacity: .7; }
.handle { position: absolute; top: 0; bottom: 0; width: 9px; margin-left: -4px; cursor: ew-resize; z-index: 3; }
.handle:hover, .handle.drag { background: #fff6; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #ff5d5d; pointer-events: none; z-index: 5; }

.seg-editor { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.seg-editor[hidden] { display: none; }
.seg-editor input { width: 80px; }
.seg-editor label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 4px; }

.seg-buttons { display: flex; gap: 6px; margin-bottom: 8px; }
.seg-buttons button { flex: 1; background: var(--panel2); border: 1px solid var(--line); font-size: 12px; padding: 6px; }
.seg-buttons button.on { background: var(--accent); border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.field input, .field select { color: var(--text); }
.field.check { flex-direction: row; align-items: center; gap: 6px; padding-top: 18px; color: var(--text); }
.clip select { width: 100%; font-size: 12px; padding: 3px 6px; margin-top: 4px; grid-column: 1 / -1; }
.spk { display: inline-block; min-width: 18px; padding: 0 5px; margin-right: 6px; border-radius: 4px; font-size: 11px; font-weight: 600; color: #111; background: var(--spk, #8b92a3); text-align: center; }
.speech .block.spkb { background: color-mix(in srgb, var(--spk) 30%, #1a1d24); border-color: var(--spk); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { flex: 1; }
.status { margin-top: 10px; font-size: 12px; color: var(--muted); min-height: 16px; white-space: pre-wrap; }
.status.err { color: var(--danger); }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar div { height: 100%; background: var(--ok); transition: width .3s; }
#renderResult a { display: inline-block; margin-top: 8px; color: var(--ok); }

.transcript { font-size: 13px; line-height: 1.6; }
.transcript .s { display: block; padding: 3px 6px; border-radius: 4px; cursor: pointer; margin-bottom: 2px; }
.transcript .s:hover { background: var(--panel2); }
.transcript .s.now { background: #263354; }
.transcript .s time { color: var(--muted); font-size: 11px; margin-right: 6px; }
body.arming .transcript .s:hover { outline: 1px dashed var(--accent); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; width: 420px; }
dialog::backdrop { background: #0009; }
