/* ============ Link — оформление ============
 * Раскладка: полоса слева, список личных сообщений, панель голосовой связи под
 * ним и звонок над лентой переписки.
 *
 * Палитра — тёмно-фиолетовая: почти чёрный фон с лёгким сиреневым подмесом,
 * панели чуть светлее фона, а всё главное (кнопка входа, выбранный чат,
 * отправка) подсвечено одним градиентом от фиолетового к пурпурному. Цвет в
 * интерфейсе означает «сюда смотреть», поэтому его немного и он везде один.
 */

:root {
  --void: #08060e;
  --rail: #0e0b16;
  --side: #131020;
  --main: #171326;
  --card: #1c1730;
  --input: #221c38;
  --hover: #241e3c;
  --active: #2e2650;
  --line: rgba(255, 255, 255, 0.07);
  --text: #d8d4e6;
  --text-bright: #f4f2fb;
  --muted: #948db0;
  --faint: #6f6890;
  --accent: #7c5cff;
  --accent-2: #b14aff;
  --accent-hover: #6a4af0;
  --accent-soft: rgba(124, 92, 255, 0.16);
  --grad: linear-gradient(135deg, #7c5cff, #b14aff);
  --glow: 0 8px 24px rgba(124, 92, 255, 0.32);
  --green: #2fd07a;
  --yellow: #f2b544;
  --red: #f04455;
  --red-hover: #c22b3c;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--main); color: var(--text);
  font: 15px/1.45 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a2342; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3160; }
::-webkit-scrollbar-track { background: transparent; }

.icon {
  width: 20px; height: 20px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--muted);
  transition: color .12s var(--ease), background .12s var(--ease);
}
.icon-btn:hover { color: var(--text-bright); background: var(--hover); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn.sm { width: 24px; height: 24px; }
.icon-btn.sm .icon { width: 16px; height: 16px; }
.icon-btn.off { color: var(--red); }
.icon-btn.danger:hover { color: #fff; background: var(--red); }

.btn-primary {
  width: 100%; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--grad); color: #fff; font-weight: 600; font-size: 15px;
  box-shadow: var(--glow);
  transition: filter .15s var(--ease), transform .1s var(--ease);
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:active { transform: scale(.99); }

.btn-ghost {
  padding: 9px 14px; border-radius: var(--r-sm); font-size: 14px;
  background: var(--input); color: var(--text-bright); border: 1px solid var(--line);
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.btn-ghost:hover { background: var(--active); border-color: rgba(124,92,255,.35); }
.btn-ghost.danger { color: #ff8095; }
.btn-ghost.danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-ghost.wide { width: 100%; }

/* Знак программы. Без подложки: он лежит прямо на панели, как на макете,
 * а собственное свечение нарисовано внутри самой разметки. */
.brand-mark {
  width: 84px; height: 84px; margin: 0 auto;
  background: url('/mark.svg') center/contain no-repeat;
}
.brand-mark.sm { width: 64px; height: 64px; }

/* ---------- Вход ----------
 * Две половины: слева — образ программы, справа — форма. Слева намеренно нет
 * ни одного поля: первое, что видит человек, — куда он попал, а не выбор.
 */
.login {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 20px; overflow: auto;
  background:
    radial-gradient(820px 460px at 18% 0%, rgba(124, 92, 255, .28), transparent 68%),
    radial-gradient(620px 420px at 96% 100%, rgba(192, 38, 211, .20), transparent 70%),
    var(--void);
}
.login-shell {
  display: flex; width: 100%; max-width: 880px; min-height: 520px;
  border-radius: 22px; overflow: hidden; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(30, 24, 56, .92), rgba(20, 16, 38, .96));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}

.login-art {
  position: relative; flex: 1 1 42%; min-width: 0; display: grid; place-items: center;
  background: linear-gradient(160deg, #1a1233, #0f0a1f 60%, #170d2b);
  overflow: hidden;
}
.art-wave { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9; }
/* Свечение из-под волны: без него градиентные линии выглядят наклейкой. */
.login-art::after {
  content: ""; position: absolute; left: -20%; bottom: -30%; width: 140%; height: 80%;
  background: radial-gradient(closest-side, rgba(168, 85, 247, .35), transparent);
  pointer-events: none;
}
.art-body { position: relative; z-index: 1; text-align: center; padding: 24px; }
.art-name {
  margin: 20px 0 6px; font-size: 34px; font-weight: 600; letter-spacing: -.02em;
  background: linear-gradient(120deg, #fff, #d9c6ff 60%, #f0abfc);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.art-tagline { margin: 0; font-size: 14px; color: rgba(216, 212, 230, .65); }

.login-card {
  flex: 1 1 58%; min-width: 0; padding: 40px 38px;
  display: flex; flex-direction: column; justify-content: center;
  background: rgba(23, 19, 38, .55);
}
.login-card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; color: var(--text-bright); }
.login-card > .muted { margin: 0 0 22px; font-size: 14px; }

.field-label {
  display: block; text-align: left; font-size: 12.5px; font-weight: 500;
  color: var(--muted); margin-bottom: 7px;
}
.login-card input[type=text], .login-card input:not([type]), .login-card input[type=password] {
  width: 100%; padding: 12px 14px; margin-bottom: 16px; border-radius: 10px;
  background: rgba(8, 6, 14, .55); border: 1px solid var(--line);
  outline: none; color: var(--text-bright); font-size: 14.5px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.login-card input::placeholder { color: var(--faint); }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .field-label { margin-top: 2px; }

/* Поле пароля с кнопкой «показать» */
.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px !important; }
.eye {
  position: absolute; right: 6px; top: 6px; width: 32px; height: 32px;
  border-radius: 8px; display: grid; place-items: center; color: var(--faint);
  transition: color .12s var(--ease), background .12s var(--ease);
}
.eye:hover { color: var(--text-bright); background: rgba(255, 255, 255, .06); }
.eye .icon { width: 18px; height: 18px; }

#login-form .btn-primary { margin-top: 10px; }
.form-error { color: #ff8095; font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }
.hint { color: var(--faint); font-size: 12px; margin-top: 20px; text-align: center; line-height: 1.6; }

.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 20px; background: rgba(8, 6, 14, .5); border-radius: 12px; }
.tab {
  flex: 1; padding: 9px; border-radius: 9px; font-size: 14px;
  color: var(--muted); transition: background .15s var(--ease), color .15s var(--ease);
}
.tab:hover { color: var(--text-bright); }
.tab.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: var(--glow); }

.known-accounts { text-align: left; margin-bottom: 18px; }
.known-label { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.known-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; margin-bottom: 6px; border-radius: 10px;
  background: var(--input); border: 1px solid var(--line);
  color: var(--text-bright); font-size: 14.5px; text-align: left;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.known-item:hover { background: var(--active); border-color: rgba(124, 92, 255, .35); }

/* На узком окне половины встают друг над другом: образ ужимается в шапку,
 * но не исчезает — иначе непонятно, куда вообще попал. */
@media (max-width: 780px) {
  .login-shell { flex-direction: column; max-width: 420px; min-height: 0; }
  .login-art { flex: 0 0 auto; padding: 26px 0 22px; }
  .login-art .brand-mark { width: 52px; height: 52px; border-radius: 17px; }
  .art-name { margin: 14px 0 4px; font-size: 26px; }
  .login-card { padding: 28px 26px 32px; }
}

/* ---------- Каркас ---------- */
.app { display: flex; height: 100%; }

/* Полоса серверов */
.rail {
  width: 72px; flex-shrink: 0; background: var(--rail);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 8px; position: relative;
}
.rail-btn {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: 16px;
  background: url('/icon.png') center/cover no-repeat;
  color: #fff; display: grid; place-items: center; overflow: hidden;
  transition: border-radius .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
.rail-btn .icon { display: none; }
.rail-btn.ghost .icon { display: block; width: 24px; height: 24px; }
.rail-btn:hover { border-radius: 14px; }
.rail-btn.active { box-shadow: 0 0 0 2px var(--accent), 0 6px 18px rgba(124, 92, 255, .4); }
.rail-btn.ghost { background: var(--side); color: var(--accent); border: 1px solid var(--line); }
.rail-btn.ghost:hover { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--glow); }
.rail-sep { width: 32px; height: 2px; background: rgba(255, 255, 255, .09); border-radius: 1px; flex-shrink: 0; }
.rail-dms { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; overflow-y: auto; }
.rail-dms::-webkit-scrollbar { width: 0; }
.rail-dm {
  position: relative; width: 48px; height: 48px; flex-shrink: 0;
  border-radius: 50%; transition: border-radius .15s var(--ease);
}
.rail-dm:hover, .rail-dm.active { border-radius: 16px; }
.rail-dm .avatar { width: 48px; height: 48px; font-size: 16px; }
.rail-dm .badge {
  position: absolute; right: -2px; bottom: -2px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 3px solid var(--rail);
}
.conn-dot {
  position: absolute; left: 8px; top: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--green); transition: background .2s var(--ease);
}
.conn-dot.off { background: var(--red); }

/* Список личных сообщений */
.sidebar { width: 248px; flex-shrink: 0; background: var(--side); display: flex; flex-direction: column; }
.side-search { padding: 12px 10px; }
#search {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(8, 6, 14, .5); color: var(--text); font-size: 13.5px; outline: none;
  transition: border-color .15s var(--ease);
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--faint); }

.side-nav { padding: 0 10px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 10px; color: var(--muted); font-size: 14.5px;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.nav-item:hover { background: var(--hover); color: var(--text-bright); }
.nav-item.active { background: var(--accent-soft); color: var(--text-bright); box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .3); }

.side-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 12px 8px 14px; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; color: var(--faint); letter-spacing: .06em;
}
.side-label button { color: var(--muted); }
.side-label button:hover { color: var(--text-bright); background: none; }

.dm-list { flex: 1; overflow-y: auto; padding: 0 10px 8px; }
.list-empty { padding: 14px 12px; color: var(--faint); font-size: 13px; line-height: 1.5; }
.dm-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  border-radius: 10px; margin-bottom: 3px; cursor: pointer;
  transition: background .12s var(--ease);
}
.dm-item:hover { background: var(--hover); }
.dm-item.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .3); }
.dm-item .nm {
  flex: 1; min-width: 0; font-size: 14.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-item:hover .nm, .dm-item.active .nm { color: var(--text-bright); }
.dm-item .badge {
  min-width: 16px; height: 16px; padding: 0 5px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.in-call { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

.avatar {
  border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-weight: 600; color: #fff; position: relative;
  background-size: cover; background-position: center; user-select: none;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.xl { width: 90px; height: 90px; font-size: 32px; }
.avatar .dot {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--faint); border: 3px solid var(--side);
}
.avatar .dot.online { background: var(--green); }
.avatar .dot.idle { background: var(--yellow); }
.avatar .dot.dnd { background: var(--red); }

/* Панель голосовой связи */
.voice-panel { background: var(--card); border-top: 1px solid var(--line); padding: 10px; }
.voice-head { display: flex; align-items: center; gap: 8px; }
.voice-signal { color: var(--green); width: 18px; height: 18px; flex-shrink: 0; }
.voice-info { flex: 1; min-width: 0; }
.voice-state { font-size: 13px; font-weight: 600; color: var(--green); }
.voice-peer { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-actions { display: flex; gap: 4px; margin-top: 8px; }
.voice-btn {
  flex: 1; height: 32px; border-radius: var(--r-sm); background: var(--input);
  color: var(--text); display: grid; place-items: center;
  transition: background .12s var(--ease);
}
.voice-btn:hover { background: var(--active); }
.voice-btn.on { background: var(--text-bright); color: var(--rail); }
.voice-btn .icon { width: 18px; height: 18px; }

/* Панель пользователя */
.me-bar { height: 56px; background: var(--card); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 2px; padding: 0 8px; }
.me-card {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 4px; border-radius: var(--r-sm); text-align: left;
  transition: background .12s var(--ease);
}
.me-card:hover { background: var(--hover); }
.me-info { min-width: 0; }
.me-name { font-size: 14px; font-weight: 600; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-status { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Основная область ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--main); }

.chat-head {
  height: 48px; flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; border-bottom: 1px solid var(--line); z-index: 2;
}
.chat-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
#peer-name { font-size: 16px; font-weight: 600; color: var(--text-bright); }
.peer-status { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-actions { display: flex; align-items: center; gap: 4px; }
.head-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.head-search { position: relative; }
.head-search input {
  width: 150px; padding: 5px 26px 5px 8px; border-radius: var(--r-sm); border: 0;
  background: var(--rail); color: var(--text); font-size: 13px; outline: none;
  transition: width .18s var(--ease);
}
.head-search input:focus { width: 220px; }
.head-search .icon { position: absolute; right: 6px; top: 5px; width: 15px; height: 15px; color: var(--muted); }
.only-mobile { display: none; }

/* ---------- Экран друзей ---------- */
.friends-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.friends-tabs { display: flex; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ftab {
  display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--r-sm);
  color: var(--muted); font-size: 14px; transition: background .12s var(--ease), color .12s var(--ease);
}
.ftab:hover { background: var(--hover); color: var(--text-bright); }
.ftab.active { background: var(--accent-soft); color: var(--text-bright); box-shadow: inset 0 0 0 1px rgba(124,92,255,.35); }
.friends-body { flex: 1; overflow-y: auto; padding: 16px 16px 24px; }
.ftab-pane > .muted { font-size: 14px; margin: 0 0 12px; }
.search-row { margin-bottom: 16px; }
.search-row input {
  width: 100%; padding: 10px 12px; border-radius: var(--r-sm); border: 0;
  background: var(--rail); color: var(--text-bright); outline: none; font-size: 15px;
}

.people-list { display: flex; flex-direction: column; }
.person {
  display: flex; align-items: center; gap: 12px; padding: 12px 8px;
  border-top: 1px solid var(--line);
}
.person:hover { background: rgba(255,255,255,.02); border-radius: var(--r-sm); }
.person-info { flex: 1; min-width: 0; }
.person-name { font-size: 15px; font-weight: 600; color: var(--text-bright); }
.person-sub { font-size: 12.5px; color: var(--muted); }
.person-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.person-actions .btn-ghost { padding: 6px 12px; font-size: 13px; }
.person-actions .btn-ghost.primary { background: var(--accent); color: #fff; }
.person-actions .btn-ghost.primary:hover { background: var(--accent-hover); }
.person-actions .btn-ghost:disabled { opacity: .5; pointer-events: none; }
.people-list.compact .person { padding: 8px; }
.people-list.compact input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.avatar.group { border-radius: 30%; }
.nav-item .badge { margin-left: auto; }

/* ---------- Лента сообщений ---------- */
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; }
.empty-state {
  height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; color: var(--muted); text-align: center;
}
.empty-state h2 { margin: 8px 0 0; font-size: 18px; color: var(--text-bright); }
.empty-state p { margin: 0; font-size: 14px; }

.day-sep {
  display: flex; align-items: center; gap: 10px; margin: 18px 16px 8px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.08); }

.sys-msg {
  display: flex; align-items: center; gap: 10px; padding: 4px 16px 4px 72px;
  font-size: 14px; color: var(--muted);
}
.sys-msg .icon { width: 18px; height: 18px; color: var(--green); flex-shrink: 0; }
.sys-msg.missed .icon { color: var(--red); }

.row { position: relative; display: flex; gap: 16px; padding: 2px 48px 2px 16px; }
.row:hover { background: rgba(255,255,255,.028); }
.row.first { margin-top: 14px; }
.row .avatar { width: 40px; height: 40px; font-size: 15px; margin-top: 2px; }
.row:not(.first) .avatar { visibility: hidden; height: 0; margin: 0; }
.row-body { flex: 1; min-width: 0; }
.row-head { display: flex; align-items: baseline; gap: 8px; }
.row-head .author { font-size: 15px; font-weight: 600; color: var(--text-bright); }
.row-head .time { font-size: 12px; color: var(--faint); }
.row .text {
  font-size: 15px; line-height: 1.375; color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.row .text a { color: #a78bfa; text-decoration: none; }
.row .text a:hover { text-decoration: underline; }
.row .text code {
  background: #0d0a18; padding: 1px 4px; border-radius: 3px;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px;
}
.row .text pre {
  background: #0d0a18; border: 1px solid rgba(255,255,255,.07); border-radius: var(--r-sm);
  padding: 10px 12px; overflow-x: auto; margin: 4px 0;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px;
}
.row .text .spoiler { background: #141024; border-radius: 3px; color: transparent; cursor: pointer; }
.row .text .spoiler.shown { background: rgba(255,255,255,.1); color: inherit; }
.row .big-emoji { font-size: 40px; line-height: 1.2; }
.row .edited { font-size: 10px; color: var(--faint); margin-left: 4px; }
.row .inline-time {
  position: absolute; left: 16px; width: 40px; text-align: center;
  font-size: 11px; color: var(--faint); opacity: 0; line-height: 22px;
}
.row:hover .inline-time { opacity: 1; }

.quote {
  display: flex; align-items: center; gap: 6px; margin-bottom: 3px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.quote::before {
  content: ""; width: 28px; height: 8px; margin-left: -44px; flex-shrink: 0;
  border-left: 2px solid #332a52; border-top: 2px solid #332a52; border-top-left-radius: 6px;
}
.quote b { color: #b9b1d6; font-weight: 600; }
.quote i { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.attachments img, .attachments video { max-width: 400px; max-height: 320px; border-radius: var(--r-md); cursor: zoom-in; display: block; }
.file-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; max-width: 400px;
  background: var(--side); border: 1px solid var(--line); border-radius: var(--r-md);
}
.file-card a { color: #a78bfa; text-decoration: none; font-size: 14px; display: block; }
.file-card .sz { font-size: 12px; color: var(--muted); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction {
  display: flex; align-items: center; gap: 5px; padding: 2px 7px;
  background: var(--input); border: 1px solid transparent; border-radius: var(--r-md);
  font-size: 13px; cursor: pointer;
}
.reaction.mine { background: rgba(88,101,242,.16); border-color: var(--accent); }

.actions {
  position: absolute; top: -14px; right: 16px; display: flex; padding: 2px;
  background: var(--side); border: 1px solid var(--line); border-radius: var(--r-md);
  opacity: 0; pointer-events: none; transition: opacity .12s var(--ease);
}
.row:hover .actions { opacity: 1; pointer-events: auto; }
.actions button {
  width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--muted); font-size: 14px;
}
.actions button:hover { background: var(--hover); color: var(--text-bright); }
.actions .icon { width: 16px; height: 16px; }

.edit-area {
  width: 100%; background: var(--input); border: 0; border-radius: var(--r-md);
  padding: 10px; resize: vertical; outline: none; font-size: 15px; color: var(--text-bright);
}
.edit-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.typing-row { height: 22px; padding: 0 18px; font-size: 13px; color: var(--muted); flex-shrink: 0; }

/* ---------- Поле ввода ---------- */
.composer-wrap { padding: 0 16px 22px; flex-shrink: 0; }
.reply-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--side); border-radius: var(--r-md) var(--r-md) 0 0;
  font-size: 13px; color: var(--muted);
}
.reply-bar .icon { width: 16px; height: 16px; flex-shrink: 0; }
.reply-text { flex: 1; min-width: 0; }
.reply-text b { display: block; font-size: 12px; color: var(--text-bright); }
.reply-text i { font-style: normal; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attach-preview {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 10px;
  background: var(--input); border-radius: var(--r-md) var(--r-md) 0 0;
}
.chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--side); border-radius: var(--r-sm); font-size: 12px;
}
.chip img { width: 36px; height: 36px; object-fit: cover; border-radius: var(--r-sm); }
.chip button { color: var(--muted); display: grid; place-items: center; }
.chip button:hover { color: var(--red); }
.chip .icon { width: 14px; height: 14px; }

.composer {
  display: flex; align-items: flex-end; gap: 4px; padding: 0 8px 0 0;
  background: var(--input); border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: border-color .15s var(--ease);
}
.composer:focus-within { border-color: rgba(124, 92, 255, .45); }
.reply-bar:not(.hidden) ~ .composer,
.attach-preview:not(.hidden) ~ .composer { border-radius: 0 0 var(--r-md) var(--r-md); }
.composer-add {
  width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center;
  color: var(--muted); transition: color .12s var(--ease);
}
.composer-add:hover { color: var(--text-bright); }
.composer-add .icon { width: 22px; height: 22px; }
#composer-input {
  flex: 1; background: none; border: 0; outline: none; resize: none;
  padding: 12px 0; max-height: 180px; font-size: 15px; line-height: 1.375; color: var(--text-bright);
}
#composer-input::placeholder { color: var(--faint); }
.composer .icon-btn { margin-bottom: 6px; }
.send-btn {
  width: 32px; height: 32px; margin-bottom: 6px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; background: var(--grad); color: #fff;
  transform: scale(.8); opacity: 0; pointer-events: none;
  transition: transform .15s var(--ease), opacity .15s var(--ease);
}
.send-btn.ready { transform: scale(1); opacity: 1; pointer-events: auto; }
.send-btn:hover { filter: brightness(1.12); }
.send-btn .icon { width: 18px; height: 18px; }

/* ---------- Звонок ---------- */
.call-panel {
  flex-shrink: 0; height: 46vh; min-height: 260px; display: flex;
  background: var(--void); border-bottom: 1px solid var(--line);
}
.call-panel.fullscreen { position: fixed; inset: 0; z-index: 60; height: 100vh; }
.call-body { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
/* Сетка подстраивается под число участников: от одного до девяти. */
.call-stage {
  flex: 1; min-height: 0; display: grid; gap: 8px; padding: 12px;
  grid-template-columns: 1fr 1fr; background: #0a0812;
}
.call-stage.solo, .call-stage[data-count="1"] { grid-template-columns: 1fr; }
.call-stage[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.call-stage[data-count="3"], .call-stage[data-count="4"] { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 1fr; }
.call-stage[data-count="5"], .call-stage[data-count="6"] { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; }
.call-stage[data-count="7"], .call-stage[data-count="8"], .call-stage[data-count="9"] {
  grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr;
}
.tile {
  position: relative; background: #191333; border-radius: var(--r-md);
  overflow: hidden; display: grid; place-items: center; min-height: 0;
}
.tile.speaking { box-shadow: inset 0 0 0 2px var(--green); }
.tile video, .tile canvas { width: 100%; height: 100%; object-fit: contain; }
.tile video.hidden-video, .tile canvas.hidden-video { display: none; }
.tile-avatar {
  position: absolute; width: 88px; height: 88px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 32px; font-weight: 600;
}
.tile-label {
  position: absolute; left: 12px; bottom: 10px; display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 14px; font-size: 13px; color: #fff;
  background: rgba(0,0,0,.6);
}
.tile-label .mic-off { width: 15px; height: 15px; color: var(--red); }

.tile-tune {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: rgba(0,0,0,.55); opacity: 0; transition: opacity .15s var(--ease);
}
.tile:hover .tile-tune { opacity: 1; }
.tile-tune:hover { background: rgba(60,60,70,.9); }
.tile-tune .icon { width: 17px; height: 17px; }

.peer-panel {
  position: absolute; top: 50px; right: 10px; width: 258px; padding: 14px; z-index: 5;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.peer-panel-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--text-bright); margin-bottom: 12px; }
.tune-row { display: block; margin-bottom: 14px; }
.tune-row > span { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.tune-row b { color: var(--text-bright); }
.tune-row input[type=range] { width: 100%; accent-color: var(--accent); }
.tune-meter { height: 4px; background: var(--rail); border-radius: 2px; overflow: hidden; margin: -4px 0 14px; }
#tune-mic-fill { height: 100%; width: 0; background: var(--green); transition: width .07s linear; }

.call-status {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 5px 14px;
  background: rgba(0,0,0,.6); border-radius: 16px; font-size: 12px;
  color: var(--muted); white-space: nowrap; transition: opacity .2s var(--ease);
}
.call-timer { color: #fff; font-variant-numeric: tabular-nums; }
.call-mode { font-weight: 600; }
.call-quality { display: flex; align-items: center; gap: 5px; }

.call-dock {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
/* Кнопки прячутся только в полноэкранном режиме — в обычном они всегда на виду. */
.call-panel.fullscreen.idle .call-dock { opacity: 0; transform: translate(-50%, 10px); pointer-events: none; }
.call-panel.fullscreen.idle .call-status { opacity: 0; }
.call-panel.fullscreen.idle .tile-tune { opacity: 0; }
.dock-group { display: flex; gap: 8px; padding: 6px; background: rgba(30,31,34,.75); border-radius: 26px; }
.dock-btn {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; background: #332a52; color: #fff;
  transition: background .12s var(--ease), transform .1s var(--ease);
}
.dock-btn:hover { background: #463a72; }
.dock-btn:active { transform: scale(.94); }
.dock-btn .icon { width: 21px; height: 21px; }
.dock-btn.on { background: #fff; color: #0d0a18; }
.dock-btn.off { background: #fff; color: var(--red); }
.dock-btn.hangup { background: var(--red); width: 58px; border-radius: 22px; }
.dock-btn.hangup:hover { background: var(--red-hover); }
.dock-badge {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid #0a0812;
}

/* Свёрнутый звонок: полоса с аватарами, всё остальное окно отдано переписке. */
.call-panel.compact { height: 76px; min-height: 76px; }
.call-panel.compact .call-stage { padding: 8px 12px; gap: 8px; grid-template-columns: none; grid-auto-flow: column; justify-content: start; }
.call-panel.compact .tile { width: 60px; border-radius: 50%; background: transparent; }
.call-panel.compact .tile.speaking { box-shadow: 0 0 0 2px var(--green); }
.call-panel.compact .tile video, .call-panel.compact .tile canvas { border-radius: 50%; object-fit: cover; }
.call-panel.compact .tile-avatar { width: 56px; height: 56px; font-size: 20px; }
.call-panel.compact .tile-label, .call-panel.compact .tile-tune, .call-panel.compact .peer-panel { display: none; }
.call-panel.compact .call-status {
  top: 50%; left: auto; right: 300px; transform: translateY(-50%);
  background: none; padding: 0; max-width: 40vw; overflow: hidden;
}
/* В свёрнутой полосе показываем только суть: состояние, время и режим. */
.call-panel.compact .call-quality { display: none; }
.call-panel.compact .call-dock { bottom: 50%; left: auto; right: 16px; transform: translateY(50%); gap: 6px; }
.call-panel.compact .dock-group { padding: 0; background: none; gap: 6px; }
.call-panel.compact .dock-btn { width: 36px; height: 36px; }
.call-panel.compact .dock-btn .icon { width: 17px; height: 17px; }
.call-panel.compact .dock-btn.hangup { width: 44px; border-radius: 18px; }
.call-panel.compact .voice-menu { bottom: auto; top: 70px; }

/* Меню изменения голоса */
.voice-menu {
  position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%);
  width: 260px; max-height: 320px; overflow-y: auto; padding: 8px; z-index: 6;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
}
.menu-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--muted); padding: 4px 8px 8px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); font-size: 14px; color: var(--text);
  transition: background .12s var(--ease);
}
.menu-item:hover { background: var(--hover); color: var(--text-bright); }
.menu-item.active { background: var(--accent); color: #fff; }
.menu-emoji { font-size: 17px; width: 22px; text-align: center; }
.menu-note { padding: 8px 10px 4px; font-size: 11px; line-height: 1.5; color: var(--faint); }
.dock-emoji { font-size: 20px; line-height: 1; }

.call-chat {
  width: 360px; flex-shrink: 0; background: var(--main);
  border-left: 1px solid var(--line); display: flex; flex-direction: column;
}
.call-chat-head {
  height: 48px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 0 16px; border-bottom: 1px solid var(--line);
  font-size: 14px; color: var(--muted);
}
.call-chat-head b { color: var(--text-bright); }
.call-chat-slot { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.call-chat-slot .row { padding: 2px 12px; }
.call-chat-slot .composer-wrap { padding: 0 12px 14px; }

/* ---------- Модалки ---------- */
.modal {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  /* Размытие подложки тут не годится: Chrome вытаскивает содержимое страницы
   * поверх окна настроек, и сквозь него просвечивает лента переписки. */
  padding: 20px; background: rgba(6, 4, 12, .78);
  animation: fade .15s var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.incoming-card {
  padding: 34px 42px 30px; border-radius: var(--r-lg);
  background: linear-gradient(180deg, #221a40, var(--main));
  border: 1px solid var(--line); text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.6); animation: pop .2s var(--ease);
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } }
.incoming-card .avatar { margin: 0 auto 16px; animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.incoming-card h2 { margin: 0 0 4px; font-size: 20px; color: var(--text-bright); }
.incoming-card p { margin: 0 0 24px; font-size: 14px; }
.inc-actions { display: flex; gap: 20px; justify-content: center; }
.round {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  transition: filter .15s var(--ease), transform .1s var(--ease);
}
.round:hover { filter: brightness(1.12); }
.round:active { transform: scale(.95); }
.round .icon { width: 24px; height: 24px; }
.round.accept { background: var(--green); }
.round.decline { background: var(--red); }

.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #1c1734, var(--main) 40%);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  overflow: hidden; animation: pop .2s var(--ease);
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 14px 16px 22px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 17px; color: var(--text-bright); }
/* Настройки собраны карточками — так видно, где кончается одна тема и
 * начинается другая, а длинный список не выглядит сплошной простынёй. */
.sheet-body { overflow-y: auto; padding: 16px 20px 20px; }
.group {
  padding: 16px 18px; margin-bottom: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
}
.group:last-child { margin-bottom: 0; }
.group h3 { margin: 0 0 14px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.field { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.field > span { width: 120px; flex-shrink: 0; font-size: 13px; color: var(--muted); }
.field input:not([type=color]):not([type=range]), .field select {
  flex: 1; min-width: 0; padding: 9px 11px; border-radius: 10px;
  background: rgba(8, 6, 14, .5); border: 1px solid var(--line);
  outline: none; font-size: 14px; color: var(--text-bright);
  transition: border-color .15s var(--ease);
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input[type=color] { width: 44px; height: 32px; padding: 2px; background: var(--rail); border: 0; border-radius: var(--r-sm); }
.field input[type=range] { flex: 1; accent-color: var(--accent); }
.toggles { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.meter { height: 6px; background: var(--rail); border-radius: 3px; overflow: hidden; margin-top: 12px; }
#mic-meter-fill { height: 100%; width: 0; background: var(--green); transition: width .07s linear; }
/* Настройка микрофона */
.mic-live { margin-bottom: 14px; }
.mic-scale { position: relative; padding: 2px 0; }
.mic-bar { position: relative; height: 10px; background: var(--rail); border-radius: 5px; margin-bottom: 5px; overflow: hidden; }
.mic-bar .lvl {
  height: 100%; width: 0; border-radius: 5px;
  background: linear-gradient(90deg, var(--green), var(--yellow) 78%, var(--red));
  transition: width .05s linear;
}
.mic-bar .lvl.out { background: linear-gradient(90deg, #2fd07a, #7c5cff); }
.mic-cap {
  position: absolute; right: 6px; top: -1px; font-size: 9px;
  color: var(--faint); line-height: 12px; pointer-events: none;
}
.gate-mark {
  position: absolute; top: 0; bottom: 5px; width: 2px; background: var(--text-bright);
  border-radius: 1px; transition: left .1s var(--ease);
}
.gate-mark::after {
  content: "порог"; position: absolute; top: -14px; left: -14px;
  font-size: 9px; color: var(--muted); white-space: nowrap;
}
.mic-live-info { display: flex; justify-content: space-between; font-size: 12px; margin-top: 6px; }
.gate-state { color: var(--muted); }
.gate-state.open { color: var(--green); font-weight: 600; }
.lvl-db { color: var(--faint); font-variant-numeric: tabular-nums; }

/* Большая кнопка автоматической настройки */
.auto-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 16px 18px; margin-bottom: 14px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--accent), #b14aff);
  color: #fff; text-align: left;
  transition: filter .15s var(--ease), transform .1s var(--ease);
}
.auto-btn:hover { filter: brightness(1.08); }
.auto-btn:active { transform: scale(.995); }
.auto-btn:disabled { opacity: .6; pointer-events: none; }
.auto-spark { font-size: 26px; line-height: 1; }
.auto-text b { display: block; font-size: 15px; font-weight: 600; }
.auto-text i { display: block; font-style: normal; font-size: 12.5px; opacity: .85; margin-top: 2px; }

.wizard {
  padding: 16px; margin-bottom: 14px; border-radius: var(--r-md);
  background: var(--rail); border: 1px solid var(--line); text-align: center;
}
.wizard-step { font-size: 16px; font-weight: 600; color: var(--text-bright); }
.wizard-hint { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.wizard-bar { height: 4px; background: #1b1630; border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
#wizard-fill { height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.wizard-level { height: 8px; background: #1b1630; border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
#wizard-level-fill {
  height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, var(--green), var(--yellow) 80%, var(--red));
  transition: width .06s linear;
}

.mic-report {
  padding: 14px 16px; margin-bottom: 14px; border-radius: var(--r-md);
  background: var(--rail); border-left: 3px solid var(--green);
}
.mic-report h4 { margin: 0 0 8px; font-size: 14px; color: var(--text-bright); }
.mic-report ul { margin: 0; padding-left: 18px; }
.mic-report li { font-size: 13px; color: var(--text); line-height: 1.7; }
.mic-report.warn { border-left-color: var(--yellow); }
.mic-report .report-actions { margin-top: 12px; display: flex; gap: 8px; }

.slider { display: block; margin-bottom: 12px; }
.slider > span { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.slider b { color: var(--text-bright); font-weight: 600; font-variant-numeric: tabular-nums; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); }
.slider input[type=range]:disabled { opacity: .4; }
.eq-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.btn-ghost.active { background: var(--accent); color: #fff; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.net-report { background: var(--rail); border-radius: var(--r-sm); padding: 12px 14px; font-size: 13px; line-height: 1.8; margin-bottom: 12px; }
.net-report i { color: var(--muted); font-size: 12px; }

.emoji-panel {
  position: fixed; z-index: 80; display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 8px; max-height: 250px; overflow-y: auto;
  background: var(--side); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.emoji-panel button { width: 32px; height: 32px; border-radius: var(--r-sm); font-size: 20px; }
.emoji-panel button:hover { background: var(--hover); }

.ctx-menu {
  position: fixed; z-index: 85; min-width: 180px; padding: 6px;
  background: #120e22; border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.ctx-menu button { display: block; width: 100%; text-align: left; padding: 7px 9px; border-radius: var(--r-sm); font-size: 14px; }
.ctx-menu button:hover { background: var(--accent); color: #fff; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 95; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; border-radius: var(--r-sm); font-size: 14px;
  background: var(--side); border-left: 3px solid var(--accent); color: var(--text-bright);
  box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: slide .2s var(--ease); transition: opacity .3s;
}
@keyframes slide { from { transform: translateX(16px); opacity: 0; } }
.toast.err { border-left-color: var(--red); }

.lightbox { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; background: rgba(0,0,0,.9); cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: var(--r-sm); }

/* ---------- Мобильные ---------- */
@media (max-width: 760px) {
  .rail { display: none; }
  .sidebar { width: 100%; }
  .app.chat-open .sidebar { display: none; }
  .app:not(.chat-open) .main { display: none; }
  .only-mobile { display: grid; }
  .head-search { display: none; }
  .row { padding: 2px 12px; gap: 12px; }
  .composer-wrap { padding: 0 12px 14px; }
  .call-panel { height: 52vh; }
  .call-stage { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; padding: 8px; }
  .call-stage.solo { grid-template-rows: 1fr; }
  .call-chat { position: absolute; inset: 0; width: 100%; z-index: 3; }
  .tile-tune { opacity: 1; }
  .dock-btn { width: 40px; height: 40px; }
  .dock-btn.hangup { width: 52px; }
}
