:root {
  --bg: #0d0f14; --panel: #151821; --panel2: #1b1f2a; --line: #262b38; --text: #e9ecf3; --muted: #8b93a7;
  --accent: #ffd400; --accent2: #00e5a8; --danger: #ff4d6d; --radius: 14px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; }
button:hover { border-color: #3a4154; background: #222736; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #141414; border-color: transparent; font-weight: 700; }
button.primary:hover { background: #ffe14d; }
button.big { padding: 10px 18px; font-size: 15px; }
button.ghost { background: transparent; }
button.link { background: none; border: none; color: var(--muted); padding: 0; text-decoration: underline; font-size: 12px; }
button.round { width: 42px; height: 42px; border-radius: 50%; padding: 0; font-size: 16px; background: var(--accent); color: #111; border: none; }
select, input[type=text], input:not([type]), textarea { background: #0f1218; border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; width: 100%; }
textarea { resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; } .row.center { justify-content: center; } .row.end { justify-content: flex-end; } .row.wrap { flex-wrap: wrap; }

/* ---------- top bar ---------- */
.topbar { height: 56px; display: flex; align-items: center; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #12151d, #0f1218); }
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }
.logo { width: 24px; height: 24px; border-radius: 50%; background: conic-gradient(from 200deg, var(--accent), #ff5ec4, var(--accent2), var(--accent)); box-shadow: 0 0 18px #ffd40055; }
.seg { display: inline-flex; background: #0f1218; border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: none; background: transparent; border-radius: 9px; padding: 6px 14px; color: var(--muted); }
.seg button.on { background: var(--accent); color: #111; font-weight: 700; }
.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--accent2); border-color: #00e5a844; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 310px minmax(380px, 1fr) 330px; height: calc(100% - 56px - 26px); }
.panel { background: var(--panel); border-right: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.panel.right { border-right: none; border-left: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: none; border-radius: 9px 9px 0 0; background: transparent; color: var(--muted); padding: 8px 6px; font-size: 13px; }
.tabs button.on { background: var(--panel2); color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.tabbody { padding: 12px; overflow-y: auto; flex: 1; min-height: 0; }
.list-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; margin: 12px 0 6px; }

/* ---------- media bin ---------- */
.drop { border: 1.5px dashed #3a4154; border-radius: var(--radius); padding: 16px; text-align: center; background: #10131a; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: #1a1a10; }
.drop-icon { font-size: 26px; color: var(--accent); }
.media-list { display: flex; flex-direction: column; gap: 6px; }
.mitem { display: grid; grid-template-columns: 22px 64px 1fr auto; gap: 8px; align-items: center; padding: 6px; border-radius: 11px; background: var(--panel2); border: 1px solid transparent; }
.mitem.active { border-color: var(--accent); }
.mitem img, .mitem .ph { width: 64px; height: 40px; object-fit: cover; border-radius: 7px; background: #0b0d12; display: grid; place-items: center; font-size: 18px; }
.mitem .meta { min-width: 0; }
.mitem .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.mitem .sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mitem .x { padding: 2px 7px; font-size: 12px; background: transparent; border: none; color: var(--muted); }
.badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 99px; background: #262b38; color: #c8cede; margin-right: 4px; }
.badge.g { background: #00e5a822; color: var(--accent2); } .badge.y { background: #ffd40022; color: var(--accent); }
.search { display: grid; grid-template-columns: 1fr 96px auto; gap: 6px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 8px; }
.card { position: relative; border-radius: 10px; overflow: hidden; background: #0b0d12; aspect-ratio: 16/10; cursor: pointer; border: 2px solid transparent; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.on { border-color: var(--accent); }
.card .lbl { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: 10.5px; background: linear-gradient(transparent, #000c); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .chk { position: absolute; top: 5px; left: 5px; width: 20px; height: 20px; border-radius: 6px; background: #000a; display: grid; place-items: center; font-size: 13px; }
.card.on .chk { background: var(--accent); color: #111; }
.card .dur { position: absolute; top: 5px; right: 5px; font-size: 10px; background: #000a; padding: 1px 5px; border-radius: 5px; }
.montage { margin-top: 14px; background: var(--panel2); border-radius: var(--radius); padding: 10px; }
.montage summary { cursor: pointer; font-weight: 600; }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 16px; gap: 10px; overflow-y: auto; }
.stage-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.chip { font-size: 11.5px; color: #111; background: var(--accent); padding: 2px 9px; border-radius: 99px; margin-left: 6px; }
.chip:empty { display: none; }
.viewer { position: relative; flex: 1 1 auto; min-height: 340px; display: grid; place-items: center; background: radial-gradient(ellipse at center, #1a1e29, #0b0d12 70%); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.viewer canvas { max-width: 100%; max-height: 62vh; border-radius: 10px; box-shadow: 0 18px 50px #000a; background: #000; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: left; padding: 30px; background: #0d0f14ee; }
.empty h2 { margin: 0 0 10px; font-size: 22px; }
.empty ol { color: var(--muted); line-height: 1.9; }
.transport { display: flex; align-items: center; gap: 12px; }
.timeline { position: relative; flex: 1; height: 54px; background: #0f1218; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; overflow: hidden; }
.timeline .lanes { position: absolute; inset: 0; }
.timeline .mk { position: absolute; height: 9px; border-radius: 4px; opacity: .9; }
.timeline .mk.cap { background: #4b5268; top: 6px; } .timeline .mk.zoom { background: #4cc9f0; top: 18px; }
.timeline .mk.ins { background: var(--accent2); top: 30px; } .timeline .mk.img { background: #a78bfa; top: 30px; }
.timeline .mk.sfx { background: #ff8a00; top: 42px; width: 3px !important; } .timeline .mk.emo { background: var(--accent); top: 42px; width: 6px !important; border-radius: 50%; }
.timeline .playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 8px #fff; pointer-events: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.clip-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.clip { flex: 0 0 200px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; }
.clip.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.clip .t { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip .s { font-size: 11px; color: var(--muted); }
.score { float: right; font-weight: 800; font-size: 12px; color: #111; background: var(--accent2); border-radius: 8px; padding: 0 6px; }
.log { font-family: "JetBrains Mono", Consolas, monospace; font-size: 11.5px; color: var(--muted); max-height: 110px; overflow-y: auto; background: #0b0d12; border-radius: 10px; padding: 6px 10px; border: 1px solid var(--line); }
.log div.err { color: var(--danger); } .log div.ok { color: var(--accent2); }
.log:empty { display: none; }

/* ---------- right panel ---------- */
.field { margin-bottom: 12px; }
.field > label, .field .two label, fieldset label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
output { color: var(--text); float: right; font-size: 12px; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 6px 0 14px; font-size: 13px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 4px; margin: 6px 0 12px; }
legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.style-grid button { padding: 10px 6px; text-align: center; font-size: 15px; background: #0f1218; line-height: 1.1; }
.style-grid button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.style-grid button small { display: block; font: 600 10px var(--font); color: var(--muted); margin-top: 4px; }
.transcript { display: flex; flex-direction: column; gap: 4px; }
.tline { display: grid; grid-template-columns: 46px 1fr; gap: 6px; align-items: start; }
.tline .tt { font-size: 11px; color: var(--muted); padding-top: 6px; cursor: pointer; }
.tline [contenteditable] { background: #0f1218; border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px; outline: none; font-size: 13px; }
.tline [contenteditable]:focus { border-color: var(--accent); }
.tline b { color: var(--accent); }
.events { display: flex; flex-direction: column; gap: 4px; }
.ev { display: grid; grid-template-columns: 54px 1fr auto; gap: 6px; align-items: center; background: var(--panel2); border-radius: 9px; padding: 4px 6px; font-size: 12.5px; }
.ev .tt { color: var(--muted); font-size: 11px; cursor: pointer; }
.ev button { padding: 1px 7px; font-size: 12px; }
.ev .k { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- progress + dialogs ---------- */
.progress { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); width: min(560px, 92vw); background: #1b1f2aee; backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; box-shadow: 0 20px 60px #000c; z-index: 30; }
.progress .pmsg { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.progress .pmsg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress .bar { grid-column: 1 / 2; height: 6px; background: #0f1218; border-radius: 99px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .2s; }
.progress button { grid-row: 1 / 3; grid-column: 2; align-self: center; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(520px, 94vw); }
dialog::backdrop { background: #000a; }
.dlg { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.dlg h3 { margin: 0 0 6px; }
.foot { height: 26px; display: flex; align-items: center; justify-content: center; border-top: 1px solid var(--line); background: #0b0d12; }
#hiddenMedia { position: fixed; left: -10px; top: -10px; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
#hiddenMedia video, #hiddenMedia audio { width: 1px; height: 1px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .panel { border: none; border-bottom: 1px solid var(--line); max-height: none; }
  .tabbody { max-height: 60vh; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px; }
}
select.role { width: auto; padding: 1px 4px; font-size: 11px; margin-top: 3px; border-radius: 6px; }
