/* Voice — тёмная тема в духе Discord */
:root {
  --bg: #313338;
  --bg-deep: #1e1f22;
  --panel: #2b2d31;
  --panel-2: #232428;
  --text: #dbdee1;
  --text-dim: #949ba4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #23a55a;
  --red: #f23f43;
  --yellow: #f0b232;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; }
input {
  font: inherit; color: var(--text);
  background: var(--bg-deep); border: 1px solid #111214; border-radius: 6px;
  padding: 10px 12px; outline: none; width: 100%;
}
input:focus { border-color: var(--accent); }

/* ---------- Экран входа ---------- */
#view-auth {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #2b2d31 0%, #1e1f22 100%);
}
.auth-card {
  width: 400px; max-width: 92vw;
  background: var(--panel); border-radius: var(--radius);
  padding: 32px; box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.auth-card h1 { margin: 0 0 4px; text-align: center; letter-spacing: 1px; }
.tagline { margin: 0 0 20px; text-align: center; color: var(--text-dim); font-size: 13px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--bg-deep); border-radius: 8px; padding: 4px; }
.tab { flex: 1; padding: 8px; border-radius: 6px; color: var(--text-dim); }
.tab.active { background: var(--accent); color: #fff; }
form label { display: block; margin-bottom: 14px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
form input { margin-top: 6px; }
.primary {
  background: var(--accent); color: #fff; border-radius: 6px;
  padding: 11px 16px; width: 100%; font-weight: 600; transition: background .15s;
}
.primary:hover { background: var(--accent-hover); }
.error { margin-top: 12px; color: var(--red); font-size: 13px; text-align: center; }

/* ---------- Каркас приложения ---------- */
#view-app { height: 100%; display: flex; }
.sidebar {
  width: 260px; flex: none; background: var(--panel-2);
  display: flex; flex-direction: column; padding: 14px; gap: 14px;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: 1px; padding: 2px 4px 10px; border-bottom: 1px solid #1a1b1e; }
.panel { display: flex; flex-direction: column; gap: 10px; }
.wide { width: 100%; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 2px; }
.join-row button {
  background: var(--bg-deep); border-radius: 6px; padding: 0 16px; color: var(--text);
}
.join-row button:hover { background: #101113; }
.spacer { flex: 1; }
.self-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-deep); border-radius: 8px; padding: 8px 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.self-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost { color: var(--text-dim); font-size: 16px; } .ghost:hover { color: var(--text); }

.main { flex: 1; display: flex; flex-direction: column; position: relative; overflow: hidden; }

/* ---------- Лобби ---------- */
.lobby { margin: auto; text-align: center; color: var(--text-dim); max-width: 460px; padding: 20px; }
.lobby h2 { color: var(--text); }
.hint { font-size: 13px; border: 1px solid #3f4147; border-radius: 8px; padding: 10px 14px; background: var(--panel); }

/* ---------- Комната ---------- */
.room { flex: 1; display: flex; flex-direction: row; padding: 18px; gap: 16px; min-height: 0; }
.room-main { flex: 1; display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; }
.room-head { display: flex; justify-content: space-between; align-items: center; }
.room-label { color: var(--text-dim); margin-right: 8px; }
.room-code {
  font-family: Consolas, monospace; font-size: 20px; letter-spacing: 4px;
  background: var(--panel); border-radius: 6px; padding: 4px 12px; cursor: pointer;
}
.room-code:hover { background: var(--panel-2); }
.sas {
  font-size: 13px; color: var(--text-dim);
  background: var(--panel); padding: 6px 12px; border-radius: 6px; cursor: help;
}
.sas span { font-family: Consolas, monospace; color: var(--green); letter-spacing: 1px; }

.stage {
  flex: none; background: #000; border-radius: var(--radius); position: relative;
  max-height: 55vh; display: flex; justify-content: center;
}
.stage video { width: 100%; max-height: 55vh; border-radius: var(--radius); object-fit: contain; }
.stage video.mirror, .feed video.mirror { transform: scaleX(-1); } /* своя камера — зеркалим */
.stage-label {
  position: absolute; left: 10px; bottom: 10px; font-size: 12px;
  background: rgba(0,0,0,.6); padding: 3px 10px; border-radius: 5px;
}

/* полоса превью всех видео-потоков (экраны + камеры) для переключения */
.feeds { display: flex; gap: 10px; flex: none; overflow-x: auto; padding: 2px; }
.feed {
  position: relative; flex: none; width: 150px; height: 86px; cursor: pointer;
  background: #000; border-radius: 8px; overflow: hidden;
  border: 2px solid transparent; transition: border-color .12s;
}
.feed:hover { border-color: #4b4d54; }
.feed.selected { border-color: var(--accent); }
.feed video { width: 100%; height: 100%; object-fit: cover; }
.feed-label {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px;
  background: rgba(0,0,0,.65); padding: 2px 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.members {
  display: flex; flex-wrap: wrap; gap: 14px; align-content: flex-start;
  flex: 1; overflow-y: auto;
}
.member {
  width: 160px; height: 120px; background: var(--panel); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid transparent; transition: border-color .12s; position: relative;
}
.member.speaking { border-color: var(--green); }
.member .avatar { width: 48px; height: 48px; font-size: 18px; }
.member .name { font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .badges { position: absolute; top: 8px; right: 10px; font-size: 12px; opacity: .9; }

/* ---------- Панель управления ---------- */
.controls { display: flex; justify-content: center; gap: 14px; padding: 6px 0 2px; }
.ctl {
  width: 52px; height: 52px; border-radius: 50%; font-size: 20px;
  background: var(--panel); transition: background .15s, transform .05s;
}
.ctl:hover { background: #3a3c42; }
.ctl:active { transform: scale(.94); }
.ctl.off { background: var(--red); }
.ctl.on { background: var(--green); }
.ctl.danger { background: var(--red); }
.ctl.danger:hover { background: #d83336; }

/* ---------- Тост ---------- */
.toast {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-deep); border: 1px solid #3f4147; color: var(--text);
  border-radius: 8px; padding: 10px 18px; font-size: 14px; z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: 80%;
}
.toast.err { border-color: var(--red); }

#audio-sink { display: none; }

/* ---------- Чат ---------- */
.chat {
  width: 320px; flex: none; background: var(--panel); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0;
}
.chat-head {
  padding: 12px 14px; font-weight: 600; border-bottom: 1px solid #26272b;
  display: flex; justify-content: space-between; align-items: center;
}
.chat-e2ee { font-size: 11px; color: var(--green); cursor: help; font-weight: 400; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { font-size: 14px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .who { font-weight: 600; color: #fff; margin-right: 6px; }
.msg.mine .who { color: #a5b2ff; }
.msg .when { font-size: 11px; color: var(--text-dim); }
.msg .body { margin-top: 2px; white-space: pre-wrap; }
.msg img { max-width: 100%; max-height: 240px; border-radius: 8px; display: block; margin-top: 4px; cursor: zoom-in; }
.msg .file-link {
  display: inline-flex; gap: 8px; align-items: center; margin-top: 4px;
  background: var(--bg-deep); border-radius: 8px; padding: 8px 12px;
  color: var(--text); text-decoration: none; max-width: 100%;
}
.msg .file-link:hover { background: #17181a; }
.msg .file-size { color: var(--text-dim); font-size: 12px; flex: none; }
.msg .progress { color: var(--yellow); font-size: 12px; margin-top: 3px; }
.chat-form {
  display: flex; gap: 6px; padding: 10px; border-top: 1px solid #26272b; align-items: center;
}
.chat-form input[type="text"] { flex: 1; padding: 9px 11px; }
.chat-form button { font-size: 17px; padding: 6px 9px; border-radius: 6px; color: var(--text-dim); }
.chat-form button:hover { color: var(--text); background: var(--bg-deep); }

/* ---------- Контекстное меню громкости ---------- */
.ctx-menu {
  position: fixed; z-index: 100; width: 230px;
  background: var(--bg-deep); border: 1px solid #3f4147; border-radius: 8px;
  padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.55);
}
.ctx-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.ctx-menu input[type="range"] { width: 100%; accent-color: var(--accent); }
.ctx-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.ctx-row span { font-family: Consolas, monospace; font-size: 13px; color: var(--green); }
.ctx-row button {
  font-size: 12px; color: var(--text-dim); background: var(--panel);
  border-radius: 5px; padding: 4px 10px;
}
.ctx-row button:hover { color: var(--text); }
