:root {
  --bg: #0f1115; --card: #181b22; --line: #2a2f3a; --text: #e8eaf0; --muted: #8a91a3;
  --acc: #9b6bff; --acc2: #7c4dff; --ok: #3ecf8e; --bad: #ff5d6c; --warn: #ffb547;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.hidden { display: none !important; }
header { position: sticky; top: 0; z-index: 5; background: #12141aee; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; gap: 16px; align-items: center; padding: 10px 16px; flex-wrap: wrap; }
.logo { font-size: 17px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
nav button.on { background: var(--card); color: var(--text); }
main { max-width: 1280px; margin: 0 auto; padding: 16px 16px 120px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
h1, h2 { margin: 0 0 12px; } h2 { font-size: 17px; }
label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
input, select, textarea { width: 100%; margin-top: 4px; background: #0f1218; color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; font: inherit; }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; }
textarea { min-height: 60px; resize: vertical; }
button { background: #252a35; color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 13px; font: inherit; cursor: pointer; }
button:hover { border-color: var(--acc); }
button.primary { background: var(--acc2); border-color: var(--acc2); color: #fff; font-weight: 600; }
button.big { width: 100%; padding: 12px; font-size: 16px; margin-top: 6px; }
button.small { padding: 4px 9px; font-size: 13px; }
button.danger { color: var(--bad); }
.row { display: flex; gap: 10px; align-items: flex-end; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 160px; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: var(--bad); margin-top: 8px; }
code { background: #0f1218; padding: 1px 5px; border-radius: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip { background: #232836; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.chip.on { border-color: var(--acc); color: #cdb8ff; }
.login { max-width: 340px; margin: 18vh auto; }
.login input { margin-bottom: 10px; }

.src { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.src .info { flex: 1; min-width: 220px; }
.src .title { font-weight: 600; word-break: break-word; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #2a2f3a; color: var(--muted); }
.badge.watching, .badge.analyzing, .badge.rendering, .badge.queued { background: #3a2f12; color: var(--warn); }
.badge.done, .badge.ready, .badge.approved { background: #12352a; color: var(--ok); }
.badge.error, .badge.rejected { background: #3a1820; color: var(--bad); }
.badge.live { background: #4a1020; color: #ff6b81; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.clip { background: var(--card); border: 2px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.clip.sel { border-color: var(--acc); }
.clip.rejected { opacity: .55; }
.clip video, .clip .ph { width: 100%; aspect-ratio: 9/16; background: #000; display: block; object-fit: contain; }
.clip .ph { display: flex; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 20px; }
.clip .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.clip .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.clip .top label { margin: 0; color: var(--text); font-size: 14px; display: flex; align-items: center; cursor: pointer; }
.clip input, .clip textarea { margin-top: 0; padding: 7px 9px; font-size: 14px; }
.clip .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.clip .ups { font-size: 12px; }
.trim { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.trim button { padding: 2px 7px; font-size: 12px; }

.bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 6; background: #1d2130; border: 1px solid var(--acc);
  border-radius: 14px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: 0 10px 40px #0009;
  max-width: calc(100vw - 24px); }
.bar label { margin: 0; color: var(--text); display: flex; align-items: center; }

.modal { position: fixed; inset: 0; background: #000b; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-body { max-width: 1200px; width: 100%; max-height: 92vh; overflow: auto; }
.camwrap { position: relative; user-select: none; touch-action: none; }
.camwrap img { width: 100%; display: block; border-radius: 8px; -webkit-user-drag: none; pointer-events: none; }
.camrect { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px #0008; pointer-events: none; cursor: move; }
.camwrap { overflow: hidden; border-radius: 8px; outline: none; cursor: crosshair; }
.hdl { position: absolute; width: 16px; height: 16px; background: #fff; border: 2px solid var(--acc2); border-radius: 50%; pointer-events: auto; transform: translate(-50%, -50%); }
.hdl.nw { left: 0; top: 0; cursor: nwse-resize; } .hdl.n { left: 50%; top: 0; cursor: ns-resize; } .hdl.ne { left: 100%; top: 0; cursor: nesw-resize; }
.hdl.e { left: 100%; top: 50%; cursor: ew-resize; } .hdl.se { left: 100%; top: 100%; cursor: nwse-resize; } .hdl.s { left: 50%; top: 100%; cursor: ns-resize; }
.hdl.sw { left: 0; top: 100%; cursor: nesw-resize; } .hdl.w { left: 0; top: 50%; cursor: ew-resize; }
@media (pointer: coarse) { .hdl { width: 20px; height: 20px; } .hdl.n, .hdl.s, .hdl.e, .hdl.w { display: none; } }
.camgrid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; align-items: start; }
.campanel { display: flex; flex-direction: column; gap: 8px; }
.campanel canvas { width: 100%; border-radius: 8px; background: #000; }
.campanel label.inline { display: flex; align-items: center; color: var(--text); font-size: 14px; margin: 0; }
@media (max-width: 760px) { .camgrid { grid-template-columns: 1fr; } }
.tpl-opts label.inline { display: flex; align-items: center; color: var(--text); font-size: 14px; }
@media (max-width: 600px) { main { padding: 12px 12px 160px; } .grid { grid-template-columns: 1fr; } }

.inline-radio { display: flex; align-items: center; color: var(--text); font-size: 14px; margin: 0 14px 0 0; }
.inline-radio input { width: auto; margin: 0 6px 0 0; }
