:root {
  --bg: #0f1416; --card: #182024; --card2: #1f292e; --line: #2b383e;
  --txt: #e8eef0; --muted: #8fa2a9; --acc: #19b39b; --acc2: #0e8f7b; --warn: #f0b429; --err: #ef5350;
  --r: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--txt); font-size: 14px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); background: #11191c; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 12px var(--acc); }
.top-right { display: flex; gap: 10px; align-items: center; }
.pill { padding: 4px 10px; border-radius: 99px; background: var(--card2); color: var(--muted); font-size: 12px; }
.pill.ok { color: var(--acc); } .pill.busy { color: var(--warn); }
.muted { color: var(--muted); } .small-text { font-size: 12px; }

.grid { display: grid; grid-template-columns: 300px minmax(380px, 1fr) 360px; gap: 14px; padding: 14px; height: calc(100vh - 53px); }
.col { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.card.grow { flex: 1; min-height: 200px; display: flex; flex-direction: column; }
.card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
h2 { font-size: 14px; margin: 0; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

button, .btn { background: var(--card2); color: var(--txt); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; font: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--acc); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--acc); border-color: var(--acc); color: #04201b; font-weight: 700; }
.primary:hover { background: #22c9ae; }
.danger { background: transparent; border-color: var(--err); color: var(--err); }
.ghost { background: transparent; }
.small { padding: 4px 10px; font-size: 12px; }
select, input[type=text], input[type=password], textarea { background: var(--card2); color: var(--txt); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }
textarea { resize: vertical; width: 100%; }

.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.drop.over { border-color: var(--acc); color: var(--acc); }
.media-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.media-list li { display: flex; gap: 8px; align-items: center; background: var(--card2); border-radius: 8px; padding: 6px; cursor: pointer; border: 1px solid transparent; }
.media-list li:hover { border-color: var(--line); }
.media-list img, .media-list .ph { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: #0b0f10; flex: none; display: grid; place-items: center; font-size: 22px; }
.media-list .meta { flex: 1; min-width: 0; }
.media-list .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.media-list .sub { font-size: 11px; color: var(--muted); }
.media-list .x { background: transparent; border: none; color: var(--muted); padding: 4px; }
.media-list li.brand-strip { display: block; cursor: default; }
.brand-title { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.brand-row { display: flex; flex-wrap: wrap; gap: 5px; }
.brand-row .sw { width: 76px; height: 30px; border-radius: 6px; background: repeating-conic-gradient(#3a474d 0 25%, #2a3438 0 50%) 0 0 / 10px 10px; display: grid; place-items: center; overflow: hidden; }
.brand-row .sw img { width: 68px; height: auto; object-fit: contain; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 99px; background: #0b0f10; margin-right: 4px; }
.tag.ok { color: var(--acc); } .tag.wait { color: var(--warn); } .tag.err { color: var(--err); }

.tr-box { flex: 1; overflow: auto; line-height: 1.7; font-size: 13px; }
.tr-seg { margin-bottom: 6px; }
.tr-seg .t { color: var(--muted); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.tr-seg .tx { outline: none; border-radius: 4px; padding: 1px 2px; }
.tr-seg .tx:focus { background: var(--card2); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs button { padding: 4px 10px; font-size: 12px; }
.tabs button.on { border-color: var(--acc); color: var(--acc); }
.player-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; height: min(56vh, 620px); display: grid; place-items: center; }
video { max-width: 100%; max-height: 100%; display: block; }
.player-empty { position: absolute; color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.progress { height: 6px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; width: 0; background: var(--acc); transition: width .2s; }
.log-line { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 14px; }

.quick { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; font-size: 13px; }
.quick label { display: flex; align-items: center; gap: 6px; }
.chk { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.plan-view { font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.out-card { background: var(--card2); border-radius: 8px; padding: 8px 10px; }
.out-card b { color: var(--acc); }
.seg-row { font-size: 12px; color: var(--muted); }
.warn { color: var(--warn); font-size: 12px; }
.adv summary { cursor: pointer; color: var(--muted); margin-top: 10px; font-size: 12px; }
.adv textarea { height: 220px; font-family: ui-monospace, monospace; font-size: 11px; margin: 8px 0; }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 400px; }
.chat-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.msg { padding: 8px 11px; border-radius: 10px; max-width: 92%; white-space: pre-wrap; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--acc2); }
.msg.ai { align-self: flex-start; background: var(--card2); }
.msg.sys { align-self: center; color: var(--muted); font-size: 12px; background: transparent; text-align: center; }
.msg.err { align-self: flex-start; background: #3a1d1d; color: #ffb4b4; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chips button { font-size: 12px; padding: 4px 9px; border-radius: 99px; }
.chat-form { display: flex; gap: 8px; align-items: stretch; }
.chat-form textarea { flex: 1; }

dialog { background: var(--card); color: var(--txt); border: 1px solid var(--line); border-radius: 14px; width: min(520px, 94vw); padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.settings { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.settings label { display: flex; flex-direction: column; gap: 6px; }
.settings label.chk { flex-direction: row; }
.hint { font-size: 11px; color: var(--muted); }
.row-end { display: flex; justify-content: flex-end; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; height: auto; }
  .col { overflow: visible; }
  .player-wrap { height: 60vh; }
}
