:root {
  --bg: #101114;
  --panel: #1b1d22;
  --line: #2c2f36;
  --text: #eceef2;
  --muted: #9aa0ab;
  --accent: #3d8bfd;
  --danger: #e5484d;
  --ok: #3fb950;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
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;
}
a { color: var(--accent); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.topbar nav { display: flex; gap: 16px; align-items: center; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }

main { padding: 16px; max-width: 1280px; margin: 0 auto; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin: 40px auto; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 12px; }

label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
label input, label select { margin-top: 4px; }
input[type=text], input[type=password], select {
  width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #0c0d10; color: var(--text); font-size: 15px;
}
button {
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #262931; color: var(--text); font-size: 14px; cursor: pointer;
}
button:hover { border-color: #444a55; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.big { width: 100%; padding: 12px; font-size: 16px; margin-top: 8px; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button.off { background: #3a1d1f; border-color: #6b2a2d; }
form.inline { display: inline; margin: 0; }

.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #ff8589; margin-top: 8px; }
.messages { max-width: 1280px; margin: 12px auto 0; padding: 0 16px; }
.msg { padding: 8px 12px; border-radius: 8px; background: #17301f; border: 1px solid #245b33; margin-bottom: 8px; }
.msg.error { background: #3a1d1f; border-color: #6b2a2d; color: var(--text); }

.room-list { list-style: none; padding: 0; margin: 0; }
.room-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.room-list li:last-child { border-bottom: none; }

/* --- приглашение --- */
.invite { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.invite > div { flex: 1; min-width: 260px; }
.invite strong { display: block; margin-bottom: 6px; }

/* --- предпросмотр --- */
.prejoin-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
@media (max-width: 760px) { .prejoin-grid { grid-template-columns: 1fr; } }
.preview { position: relative; background: #000; border-radius: var(--radius); aspect-ratio: 16 / 9; overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.meter { height: 6px; background: #0c0d10; border-radius: 3px; overflow: hidden; margin: 4px 0 12px; }
#meter-bar { height: 100%; width: 0; background: var(--ok); transition: width 60ms linear; }

/* --- студия --- */
.room-page main { max-width: none; }
.call { position: relative; }
.banner { background: #3a2f12; border: 1px solid #6b5a1f; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.grid {
  display: grid; gap: 8px; height: calc(100vh - 190px); min-height: 280px;
  grid-template-columns: 1fr; grid-auto-rows: 1fr;
}
.grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.grid[data-count="3"], .grid[data-count="4"] { grid-template-columns: 1fr 1fr; }
.grid[data-count="3"] .tile:first-child { grid-column: span 2; }
@media (max-width: 700px) and (orientation: portrait) {
  .grid[data-count="2"] { grid-template-columns: 1fr; }
}
.tile { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; border: 2px solid transparent; transition: border-color .15s; min-height: 0; }
.tile.speaking { border-color: var(--ok); }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile.local video { transform: scaleX(-1); }
.tile .avatar {
  display: none; position: absolute; inset: 0; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 600; color: var(--muted); background: #15171b;
}
.tile.no-video video { display: none; }
.tile.no-video .avatar { display: flex; }
.tile .label {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .6);
  padding: 3px 8px; border-radius: 6px; font-size: 13px; display: flex; gap: 6px; align-items: center;
}
.controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 12px 0; }
.controls select { width: auto; max-width: 200px; }
.overlay-btn { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); width: auto; z-index: 5; }
.ended { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }

/* --- зал ожидания (участник) --- */
.waiting { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 0 4px; text-align: center; }
.waiting p { margin: 0; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- панель ведущего --- */
.call-layout { display: flex; gap: 12px; align-items: flex-start; }
.stage { flex: 1; min-width: 0; }
.mod-panel {
  width: 320px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; max-height: calc(100vh - 130px); overflow: auto;
}
.mod-panel h2 { font-size: 15px; margin: 12px 0 8px; display: flex; align-items: center; gap: 8px; }
.mod-panel h2:first-child { margin-top: 0; }
@media (max-width: 999px) {
  .call-layout { flex-direction: column; }
  .mod-panel { width: 100%; max-height: none; }
  .grid { height: 56vh; }
}
.badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; line-height: 18px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.check input { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item-name { display: block; margin-bottom: 6px; word-break: break-word; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.small-btn { padding: 5px 9px; font-size: 13px; }
button.attention { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(61, 139, 253, .35); }

/* --- Эфир (микшер) --- */
.badge.live { background: #d33; letter-spacing: .04em; animation: livepulse 1.6s ease-in-out infinite; }
@keyframes livepulse { 50% { opacity: .55; } }
.monitor { margin-top: 10px; }
.monitor video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; display: block; margin-bottom: 8px; }
.item.vol { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.item.vol .item-name { margin: 0; }
.item.vol .vol-pct { font-size: 12px; opacity: .7; }
.item.vol input[type=range] { grid-column: 1 / -1; width: 100%; }

/* --- Платформы рестрима --- */
.dest-state { margin: 2px 0 6px; }
.dest-state.off { opacity: .6; }
.dest-state.ok { color: #2a9d4b; }
.dest-state.wait { color: #c58a00; }
.dest-state.bad { color: #d33; }
.dest-form { display: grid; gap: 6px; margin-top: 8px; }
.dest-form input { width: 100%; box-sizing: border-box; }

/* --- Запись --- */
.rec-ok { color: #d33; }
.rec-warn { color: #c58a00; font-weight: 600; }
.rec-bad { color: #d33; font-weight: 600; }

/* --- Страница записей --- */
.rec-card { margin-bottom: 14px; }
.rec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rec-head h2 { margin: 0 0 6px; font-size: 17px; }
.rec-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rec-row:last-child { border-bottom: none; }
.rec-player { padding: 8px 0; }
.rec-player video { width: 100%; max-height: 70vh; background: #000; border-radius: 6px; }
.rec-tracks { margin-top: 8px; }
.rec-tracks summary { cursor: pointer; padding: 6px 0; }
.rec-delete { margin-top: 10px; }
a.small-btn { display: inline-block; text-decoration: none; }
