:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2129;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4f8cff;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
button, input, select {
  font: inherit; color: var(--text);
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--red); }
button.small { padding: 3px 9px; font-size: 13px; }
input:disabled, select:disabled { opacity: .5; }

/* ---------- каркас ---------- */
.wrap { display: flex; flex-direction: column; height: 100vh; }
header {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
}
header h1 { font-size: 17px; margin: 0; font-weight: 600; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--panel2); border: 1px solid var(--border);
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.live { color: var(--red); border-color: var(--red); }
.badge.live .dot { background: var(--red); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.spacer { flex: 1; }
main { display: grid; grid-template-columns: 420px 1fr; gap: 16px; padding: 16px 18px; min-height: 0; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; overflow-y: auto; } }
.col { display: flex; flex-direction: column; gap: 16px; min-height: 0; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.panel h2 { font-size: 14px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- цели ---------- */
.target {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel2); margin-bottom: 8px;
}
.target .name { font-weight: 600; }
.target .url { color: var(--muted); font-size: 12px; word-break: break-all; }
.target .grow { flex: 1; min-width: 0; }
.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.chip.run { color: var(--green); border-color: var(--green); }
.chip.err { color: var(--red); border-color: var(--red); }
.chip.warn { color: var(--yellow); border-color: var(--yellow); }
.chip.off { opacity: .6; }
.err-text { color: var(--red); font-size: 12px; margin-top: 4px; word-break: break-all; }

form.stack { display: flex; flex-direction: column; gap: 8px; }
form.stack label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- превью ---------- */
/* без фиксированных пропорций: стрим бывает и 16:9, и вертикальный 9:16 */
video.preview { width: 100%; max-height: 460px; object-fit: contain; border-radius: 10px; background: #000; }

/* ---------- чат ---------- */
.chat-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filters button.on { border-color: var(--accent); color: var(--accent); }
#feed {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; min-height: 200px;
}
.msg { display: flex; gap: 8px; align-items: baseline; padding: 3px 6px; border-radius: 6px; }
.msg:hover { background: var(--panel2); }
.msg .who { font-weight: 700; white-space: nowrap; }
.msg .txt { word-break: break-word; }
.emote { height: 1.6em; vertical-align: -0.35em; margin: 0 .05em; }
.msg .tm { color: var(--muted); font-size: 11px; margin-left: auto; white-space: nowrap; }
.pl {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  color: #000; text-transform: uppercase; flex-shrink: 0;
}
.pl.twitch { background: #9146ff; color: #fff; }
.pl.kick { background: #53fc18; }
.pl.youtube { background: #f00; color: #fff; }
.pl.tiktok { background: #fe2c55; color: #fff; }
.pl.vk { background: #0077ff; color: #fff; }
.pl.custom { background: #8b949e; }

/* ---------- логин ---------- */
#login {
  position: fixed; inset: 0; background: rgba(0,0,0,.8); display: flex;
  align-items: center; justify-content: center; z-index: 10;
}
#login .box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: 300px; display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 12px; }
a { color: var(--accent); }
