/* ───────────────────────── Тема ─────────────────────────
   Всё оформление собрано в переменных: поменяйте цвета, радиусы
   и размеры колонок здесь — интерфейс перекрасится целиком. */
:root {
  --accent: #6d5efc;
  --accent-hover: #5a4be0;
  --green: #2fb67c;
  --red: #e5484d;

  --bg-rail: #1a1b1e;
  --bg-side: #232428;
  --bg-main: #2b2d31;
  --bg-input: #383a40;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.11);
  --bg-stage: #1e1f22;

  --text: #e3e5e8;
  --text-strong: #ffffff;
  --muted: #a0a5ad;
  --faint: #6b7078;
  --line: rgba(255, 255, 255, 0.06);

  --radius: 10px;
  --radius-lg: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --w-rail: 72px;
  --w-sidebar: 248px;
  --w-members: 240px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-main);
  color: var(--text);
  font: 15px/1.4 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

svg { width: 20px; height: 20px; display: block; flex: none; }

/* ───────────────────────── Раскладка ───────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--w-rail) var(--w-sidebar) minmax(0, 1fr) var(--w-members);
  height: 100vh;
  height: 100dvh;
}

/* Колонка серверов */
.rail {
  background: var(--bg-rail);
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 12px 0;
}
.rail-logo {
  width: 48px; height: 48px; border-radius: 16px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px;
  transition: border-radius .15s;
}
.rail-logo:hover { border-radius: 14px; }
.rail-sep { width: 32px; height: 2px; background: var(--line); border-radius: 1px; }

/* Боковая колонка с каналами */
.sidebar {
  background: var(--bg-side);
  display: flex; flex-direction: column; min-height: 0;
}
.server-head {
  height: 52px; padding: 0 16px;
  display: flex; align-items: center;
  font-weight: 700; font-size: 16px; color: var(--text-strong);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.channel-scroll { flex: 1; overflow-y: auto; padding: 12px 0; }

.cat {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 4px 16px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--faint);
}
.cat:first-child { padding-top: 0; }
.cat .icon-btn { width: 22px; height: 22px; padding: 2px; }
.cat .icon-btn svg { width: 16px; height: 16px; }

.ch {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  margin: 1px 8px; padding: 7px 10px;
  border-radius: 8px; color: var(--muted);
  cursor: pointer; user-select: none;
}
.ch svg { width: 18px; height: 18px; color: var(--faint); }
.ch:hover { background: var(--bg-hover); color: var(--text); }
.ch.active { background: var(--bg-active); color: var(--text-strong); }
.ch.unread { color: var(--text-strong); font-weight: 600; }
.ch.unread::before {
  content: ""; position: absolute; left: -8px; top: 50%;
  width: 4px; height: 8px; margin-top: -4px;
  background: var(--text-strong); border-radius: 0 4px 4px 0;
}
.ch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.vusers { margin: 0 8px 4px 34px; }
.vuser {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 8px; border-radius: 6px; color: var(--muted); font-size: 14px;
}
.vuser .avatar { width: 22px; height: 22px; font-size: 11px; }
.vuser .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vuser .flags { display: flex; gap: 4px; color: var(--faint); }
.vuser .flags svg { width: 14px; height: 14px; }

/* Панель «голос подключён» */
.voice-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; margin: 0 8px 8px;
  background: rgba(47, 182, 124, .1);
  border: 1px solid rgba(47, 182, 124, .25);
  border-radius: var(--radius);
}
.voice-bar-info { flex: 1; min-width: 0; cursor: pointer; }
.voice-bar-status { display: flex; align-items: center; gap: 6px; color: var(--green); font-weight: 600; font-size: 13px; }
.voice-bar-name { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Панель пользователя */
.user-panel {
  display: flex; align-items: center; gap: 2px;
  padding: 8px; background: #1e1f22;
}
.user-info {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px; border-radius: 8px; text-align: left;
}
.user-info:hover { background: var(--bg-hover); }
.user-text { min-width: 0; }
.user-name { font-weight: 600; font-size: 14px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-status { font-size: 12px; color: var(--muted); }

.icon-btn {
  width: 32px; height: 32px; padding: 6px;
  display: grid; place-items: center;
  color: var(--muted); border-radius: 8px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-strong); }
.icon-btn.off { color: var(--red); }

/* Аватар */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: 14px;
  background: var(--accent);
  transition: box-shadow .1s;
}
.speaking > .avatar, .avatar.speaking, .speaking .avatar.big { box-shadow: 0 0 0 2px var(--bg-side), 0 0 0 4px var(--green); }

/* ───────────────────────── Главная область ───────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-main); }
.topbar {
  height: 52px; flex: none;
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-strong); }
.top-icon { color: var(--faint); display: grid; }
.conn { margin-left: auto; font-size: 12.5px; color: #e8a33d; }

/* Чат */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; }
.empty { padding: 40px 24px; color: var(--muted); }
.empty h3 { margin: 0 0 6px; color: var(--text-strong); font-size: 22px; }

.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 16px; padding: 2px 16px 2px 16px; }
.msg:hover { background: rgba(0,0,0,.08); }
.msg.first { margin-top: 16px; }
.msg .avatar { width: 40px; height: 40px; margin-top: 2px; }
.msg .gutter { text-align: center; font-size: 11px; color: transparent; line-height: 22px; user-select: none; }
.msg:hover .gutter { color: var(--faint); }
.msg .head { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 600; color: var(--text-strong); }
.msg .time { font-size: 12px; color: var(--faint); }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .text a { color: #8ab4ff; text-decoration: none; }
.msg .text a:hover { text-decoration: underline; }

.composer { padding: 0 16px 20px; }
.composer textarea {
  width: 100%; resize: none; max-height: 40vh;
  padding: 12px 16px; border: 0; outline: 0;
  background: var(--bg-input); border-radius: var(--radius-lg);
}
.composer textarea::placeholder { color: var(--faint); }

/* ───────────────────────── Голосовая сцена ───────────────────────── */
.stage { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg-stage); }
.stage-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.focus { flex: 1; min-height: 240px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.share-tile { position: relative; background: #000; border-radius: var(--radius-lg); overflow: hidden; min-height: 200px; }
.share-tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.share-tile .label {
  position: absolute; left: 10px; bottom: 10px;
  padding: 3px 10px; border-radius: 6px; font-size: 13px; font-weight: 600;
  background: rgba(0,0,0,.65); color: #fff;
}
.share-tile .fs {
  position: absolute; right: 10px; top: 10px; width: 34px; height: 34px;
  background: rgba(0,0,0,.55); color: #fff; opacity: 0; transition: opacity .15s;
}
.share-tile:hover .fs { opacity: 1; }

.people { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-content: start; }
.has-share .people { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.tile {
  position: relative; aspect-ratio: 16 / 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--bg-side); border-radius: var(--radius-lg);
  outline: 2px solid transparent; transition: outline-color .1s;
}
.tile.speaking { outline-color: var(--green); }
.tile .avatar.big { width: 64px; height: 64px; font-size: 26px; }
.has-share .tile .avatar.big { width: 40px; height: 40px; font-size: 17px; }
.tile .nm { font-weight: 600; color: var(--text-strong); max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .flags { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; color: var(--red); }
.tile .flags svg { width: 16px; height: 16px; }
.tile .live {
  position: absolute; left: 8px; top: 8px; padding: 1px 7px; border-radius: 5px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .04em;
}

.stage-controls { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 14px 16px 6px; }
.round {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: #383a40; color: var(--text-strong);
  transition: background .12s, transform .06s;
}
.round:hover { background: #4a4d55; }
.round:active { transform: scale(.95); }
.round.off { background: #fff; color: #1e1f22; }
.round.share.on { background: var(--green); color: #fff; }
.round.danger { background: var(--red); color: #fff; }
.round.danger:hover { background: #cf3a3f; }

.share-group { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 4px; background: #2b2d31; border-radius: 28px; }
.share-group select {
  background: transparent; border: 0; outline: 0; color: var(--muted);
  padding: 8px 6px 8px 4px; max-width: 190px; font-size: 13px; cursor: pointer;
}
.share-group select option { background: #2b2d31; color: var(--text); }
.share-hint { min-height: 28px; padding: 0 16px 12px; text-align: center; font-size: 12.5px; color: var(--faint); }

/* ───────────────────────── Участники ───────────────────────── */
.members { background: var(--bg-side); overflow-y: auto; padding: 16px 8px; }
.members-title { padding: 0 8px 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.member { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; color: var(--muted); }
.member:hover { background: var(--bg-hover); color: var(--text); }
.member .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .tag { color: var(--green); display: grid; }
.member .tag svg { width: 15px; height: 15px; }

/* ───────────────────────── Модальные окна, тосты ───────────────────────── */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(0,0,0,.65); padding: 16px; }
.card { width: 100%; max-width: 400px; padding: 24px; background: var(--bg-main); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card h2 { margin: 0 0 6px; font-size: 22px; color: var(--text-strong); }
.card p { margin: 0 0 16px; color: var(--muted); }
.card input[type="text"], .card input:not([type]) {
  width: 100%; padding: 11px 14px; border: 0; outline: 2px solid transparent;
  background: #1e1f22; border-radius: 8px; margin-top: 4px;
}
.card input:focus { outline-color: var(--accent); }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.btn { padding: 10px 18px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
.btn:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { text-decoration: underline; background: transparent; }

.kind-pick { display: flex; gap: 8px; margin: 12px 0; }
.kind-pick label { flex: 1; cursor: pointer; }
.kind-pick input { position: absolute; opacity: 0; pointer-events: none; }
.kind-pick span { display: block; text-align: center; padding: 10px; border-radius: 8px; background: #1e1f22; color: var(--muted); }
.kind-pick input:checked + span { background: var(--accent); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  max-width: min(90vw, 460px); padding: 12px 18px; border-radius: 10px;
  background: #111214; color: var(--text); box-shadow: 0 8px 30px rgba(0,0,0,.5);
  border: 1px solid var(--line); text-align: center;
}

/* Скроллбары */
* { scrollbar-width: thin; scrollbar-color: #1a1b1e transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

/* ───────────────────────── Адаптив ───────────────────────── */
@media (max-width: 1000px) {
  .app { grid-template-columns: var(--w-rail) var(--w-sidebar) minmax(0, 1fr); }
  .members { display: none; }
}
@media (max-width: 680px) {
  .app { grid-template-columns: 200px minmax(0, 1fr); }
  .rail { display: none; }
}
