/* Размеры и движение — общие для всех тем. --dock-h и --dock-gap держат на одной линии
   кнопку «+» в столбце каналов, свою панель внизу слева и поле ввода */
:root {
  --radius: 8px;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;
  --r-xl: 18px;
  --dock-h: 56px;
  --dock-gap: 8px;
  --rail-tile: 46px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --fast: .12s;
  --mid: .2s;
  --slow: .32s;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
a { color: color-mix(in srgb, var(--accent) 70%, var(--text)); text-decoration: none; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; justify-content: center; }
.spacer { flex: 1; }
.pad { padding: 0 14px; }
.grow { flex: 1; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; gap: 10px; align-items: center; }
.error { color: var(--danger); min-height: 1em; margin: 0; font-size: 13px; }
.error:empty { display: none; }

/* ---------- Кнопки и поля ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 36px; padding: 0 16px;
  border: 0; border-radius: var(--r-m);
  background: var(--bg-4); color: var(--text); cursor: pointer;
  font-weight: 600; transition: background var(--fast), box-shadow var(--mid) var(--ease), transform var(--fast) var(--ease), filter var(--fast);
}
.btn:hover { background: var(--bg-5); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(100deg, color-mix(in srgb, var(--accent) 70%, var(--accent-2)), var(--accent));
  color: var(--on-accent); box-shadow: 0 6px 18px var(--glow);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 10px 26px var(--glow); }
.btn.success { background: var(--ok); color: #fff; }
.btn.success:hover { filter: brightness(1.1); background: var(--ok); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-hover); }
.btn.danger-outline { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.btn.danger-outline:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.wide { width: 100%; height: 42px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border: 0; border-radius: var(--r-s); background: transparent;
  color: var(--muted); cursor: pointer;
  transition: background var(--fast), color var(--fast), transform var(--fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-4); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.off { color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field > span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
input:not([type=checkbox]):not([type=range]), select {
  height: 40px; padding: 0 12px;
  background: var(--bg-deep); border: 1px solid var(--line); border-radius: var(--r-m);
  outline: none; transition: border-color var(--fast), box-shadow var(--mid) var(--ease);
}
input:not([type=checkbox]):not([type=range]):focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.check { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Аватары ---------- */

.avatar {
  position: relative; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.3);
  user-select: none;
}
.avatar.big { width: 88px; height: 88px; font-size: 34px; }
.avatar.huge { width: 104px; height: 104px; font-size: 40px; }
.avatar .status {
  position: absolute; right: -2px; bottom: -2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #80848e; border: 3px solid var(--bg-2);
}
.avatar .status.online { background: var(--ok); }
.avatar.has-image { background-size: cover; background-position: center; }
.avatar-edit { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.avatar-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.avatar-actions .btn { height: 32px; }
.avatar.speaking { box-shadow: 0 0 0 3px var(--bg-2), 0 0 0 6px var(--accent); }
.avatar.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
  100% { box-shadow: 0 0 0 26px transparent; }
}

/* ---------- Экран входа ---------- */

/* Полоса окна вместо системной (высота — TITLEBAR_H в main.js); экраны занимают всё под ней */
body { display: flex; flex-direction: column; }
.titlebar {
  height: 32px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--bg-deep); color: var(--muted); font-size: 12px; user-select: none; -webkit-app-region: drag;
}
.titlebar img { opacity: .9; }
/* Сообщение, к которому перешли (закреп, цитата ответа), коротко подсвечено */
.msg-flash { animation: msg-flash 2s ease-out; }
@keyframes msg-flash { from { background: color-mix(in srgb, var(--accent) 28%, transparent); } to { background: transparent; } }
/* «Назад» и «Вперёд» — как в браузере; на экране входа их не видно */
.nav-btn { -webkit-app-region: no-drag; width: 26px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--text-2); cursor: pointer; padding: 0; }
.nav-btn:hover:not(:disabled) { background: var(--bg-3); color: var(--text); }
.nav-btn:disabled { opacity: .35; cursor: default; }
.nav-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body:has(#auth:not(.hidden)) .nav-btn { visibility: hidden; }
.screen { flex: 1; min-height: 0; }

/* Вход: слева — рассказ о приложении, справа — форма.
   Цвета берутся из темы, поэтому светлая тема тоже остаётся опрятной. */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(410px, 0.86fr);
  overflow: hidden;
  background:
    radial-gradient(120% 85% at 4% -12%, color-mix(in srgb, var(--accent) 30%, transparent) 0%, transparent 52%),
    radial-gradient(90% 70% at 24% 112%, color-mix(in srgb, var(--accent) 18%, transparent) 0%, transparent 60%),
    var(--bg-deep);
}

.auth-hero {
  position: relative;
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0; padding: 30px clamp(24px, 3.6vw, 52px);
}

/* Еле заметная сетка, растворяющаяся к краям */
.auth-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px);
  background-size: 58px 58px;
  -webkit-mask-image: radial-gradient(58% 52% at 34% 46%, #000 0%, transparent 78%);
  mask-image: radial-gradient(58% 52% at 34% 46%, #000 0%, transparent 78%);
}
.auth-hero > * { position: relative; }

.auth-brand { display: flex; align-items: center; gap: 11px; }
.auth-word { font-size: 20px; font-weight: 800; letter-spacing: .06em; }
.auth-word .dot { color: color-mix(in srgb, var(--accent) 55%, #a855f7); }

.auth-pill {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 16px; padding: 6px 12px 6px 10px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 70%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-2) 45%, transparent);
  font-size: 12px; color: var(--text-2);
}
.auth-pill svg { width: 14px; height: 14px; fill: color-mix(in srgb, var(--accent) 45%, var(--text-2)); stroke: none; }

.auth-headline {
  margin: 16px 0 0;
  font-size: clamp(30px, 3.2vw, 46px);
  line-height: 1.03; letter-spacing: -.035em; font-weight: 800;
}
.auth-headline span { display: block; }
.auth-headline .soft { color: color-mix(in srgb, var(--text) 72%, var(--muted)); }
.auth-headline .grad {
  background: linear-gradient(96deg,
    color-mix(in srgb, var(--accent) 45%, #7cc4ff),
    color-mix(in srgb, var(--accent) 50%, #a855f7));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.auth-lead { max-width: 470px; margin: 14px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }

.auth-features {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px;
  max-width: 520px; margin: 16px 0 0; padding: 0; list-style: none;
}
.auth-features li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 55%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-2) 40%, transparent);
  font-size: 11.5px; color: var(--muted);
}
.auth-feature-icon {
  display: grid; place-items: center;
  width: 28px; height: 28px; margin-bottom: 7px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}
.auth-feature-icon svg { width: 16px; height: 16px; stroke: color-mix(in srgb, var(--accent) 45%, var(--text)); stroke-width: 1.7; }
.auth-features b { font-size: 12.5px; font-weight: 600; color: var(--text); }

.auth-preview {
  width: min(100%, 430px); margin-top: 16px; padding: 12px 14px 10px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 55%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-2) 42%, transparent);
}
.auth-preview-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 9px; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.auth-preview .channel { font-size: 12.5px; font-weight: 600; }
.auth-preview .online { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.auth-preview .online i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px color-mix(in srgb, var(--ok) 70%, transparent); }

.auth-message { display: flex; gap: 9px; padding-top: 9px; }
.auth-avatar { flex: none; display: grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; color: #fff; font-size: 11.5px; font-weight: 600; }
.auth-avatar.avatar-m { background: linear-gradient(145deg, #f472b6, #a855f7); }
.auth-avatar.avatar-n { background: linear-gradient(145deg, #a78bfa, #6366f1); }
.auth-meta { display: flex; align-items: baseline; gap: 7px; }
.auth-meta b { font-size: 12px; font-weight: 600; }
.auth-meta span { font-size: 10.5px; color: var(--muted); }
.auth-message p { margin: 1px 0 0; font-size: 12px; line-height: 1.4; color: var(--text-2); }

.auth-typing { display: flex; align-items: center; gap: 7px; padding-top: 8px; font-size: 11px; color: var(--muted); }
.auth-typing .dots { display: inline-flex; gap: 3px; }
.auth-typing .dots i { width: 4px; height: 4px; border-radius: 50%; background: color-mix(in srgb, var(--muted) 80%, transparent); animation: auth-blink 1.2s infinite; }
.auth-typing .dots i:nth-child(2) { animation-delay: .18s; }
.auth-typing .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes auth-blink { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }

.auth-stat { display: flex; align-items: center; gap: 7px; margin: 13px 0 0; font-size: 11px; color: var(--muted); }
.auth-stat svg { width: 15px; height: 15px; stroke-width: 1.5; }

/* Правая половина: карточка формы */
.auth-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  border-left: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  overflow-y: auto;
}

.auth-card {
  width: 100%; max-width: 386px; margin: auto;
  padding: 24px 24px 17px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 65%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-2) 94%, transparent);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .4), 0 0 60px color-mix(in srgb, var(--accent) 10%, transparent);
}

.auth-eyebrow { margin: 0 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: color-mix(in srgb, var(--accent) 45%, var(--text)); }
.auth-title { font-size: 23px; line-height: 1.15; letter-spacing: -.02em; }
.auth-sub { margin: 5px 0 16px; font-size: 12.5px; }

#auth .field { margin-bottom: 12px; }
#auth .field > span { font-size: 11.5px; font-weight: 600; text-transform: none; letter-spacing: 0; color: color-mix(in srgb, var(--muted) 80%, var(--text)); }
#auth .field input {
  height: 42px; padding: 0 12px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 60%, transparent);
  background: color-mix(in srgb, var(--bg-deep) 55%, transparent);
}
#auth .field input::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }
#auth .field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
#auth .code-row .btn { height: 42px; }

.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 10px; }
.auth-check { margin: 0; font-size: 12.5px; color: var(--text-2); }
.auth-row a { font-size: 12.5px; }

#auth .error { margin: 0 0 8px; }

#auth .btn.primary.wide {
  height: 44px; margin-top: 2px; border-radius: 10px;
  background: linear-gradient(96deg, color-mix(in srgb, var(--accent) 55%, #a855f7), var(--accent));
  box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 32%, transparent);
}
#auth .btn.primary.wide:hover { box-shadow: 0 14px 32px color-mix(in srgb, var(--accent) 40%, transparent); filter: brightness(1.04); }
#auth .btn.primary.wide::after { content: "→"; font-size: 15px; line-height: 1; }

.auth-switch { margin: 13px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }
.auth-switch a { margin-left: 4px; }
.auth-version { margin-top: 9px; font-size: 11px; }

.divider { display: flex; align-items: center; gap: 10px; margin: 14px 0 12px; color: var(--muted); font-size: 11.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--line) 80%, transparent); }

.oauth-buttons { display: flex; flex-direction: column; gap: 8px; }
.oauth-btn {
  width: 100%; height: 48px; justify-content: flex-start; gap: 10px;
  padding: 0 12px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--bg-3) 70%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line-strong) 60%, transparent);
}
.oauth-btn:hover { background: color-mix(in srgb, var(--accent) 12%, var(--bg-3)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.oauth-btn span:last-child { flex: 1; text-align: left; margin: 0; }
.oauth-btn .provider-badge { width: 30px; height: 30px; min-width: 30px; border-radius: 8px; font-size: 15px; }

.provider-badge {
  flex: none; display: grid; place-items: center;
  min-width: 26px; height: 26px; padding: 0 4px; border-radius: 6px;
  font-size: 13px; font-weight: 800; line-height: 1;
}

/* На узком окне и низком экране прячем декоративные части, но оставляем карточку */
@media (max-width: 1000px), (max-height: 660px) {
  .auth-preview { display: none; }
}
@media (max-width: 900px), (max-height: 600px) {
  .auth-features, .auth-stat { display: none; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
  .auth-panel { border-left: 0; }
}

.identity-list { display: flex; flex-direction: column; gap: 8px; }
.identity-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-3); }
.identity-row > div { flex: 1; min-width: 0; }
.identity-row .btn { height: 30px; padding: 0 12px; font-size: 13px; }

/* ---------- Основной экран ---------- */

/* Окно: тёмная подложка со свечением акцента, на ней столбец каналов и «лист» —
   боковая панель, чат и участники, со скруглённым углом у столбца */
.main {
  display: flex;
  background:
    radial-gradient(70% 55% at 0% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg-deep);
}

.sidebar {
  width: var(--sidebar-w, 248px); flex: none; position: relative;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-top-left-radius: var(--r-xl);
  border: 1px solid var(--line); border-width: 1px 1px 0 1px;
}
.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 12px 0 16px; flex: none; position: relative; z-index: 2;
  font-weight: 700; font-size: 16px;
  border-bottom: 1px solid var(--line);
}
.conn-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
/* Шапка узкой панели: значок и кнопки не сжимаются, название обрезается, а совсем узко — остаётся только логотип */
.sidebar { container: sidebar / inline-size; }
.sidebar-head > .icon-btn { flex: none; }
.head-home > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-home img { flex: none; }
@container sidebar (max-width: 236px) { .head-home > span { display: none; } }
.sidebar-head .icon-btn { width: 28px; height: 28px; margin-right: -6px; }
.conn-dot.ok { background: var(--ok); }

.list-title { padding: 10px 16px 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 8px; }
.contact-list { list-style: none; margin: 0; padding: 0 8px; }
.contact {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; margin: 1px 0; border-radius: var(--r-m); cursor: pointer; color: var(--muted);
  transition: background var(--fast), color var(--fast);
}
.contact .name > div:first-child { color: var(--text-2); }
.contact:hover { background: color-mix(in srgb, var(--bg-4) 60%, transparent); }
.contact:hover .name > div:first-child, .contact.active .name > div:first-child { color: var(--text); }
.contact.active { background: var(--bg-4); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line-strong) 50%, transparent); }
.contact .name { flex: 1; min-width: 0; }
.contact .name .muted { font-size: 12px; }
.contact.offline .name > div:first-child { color: var(--muted); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
.in-call-tag { color: var(--accent); }

.update-bar {
  position: fixed; left: 80px; bottom: 64px; z-index: 5;
  width: 224px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-deep)); color: var(--text);
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  font-size: 13px; font-weight: 600;
}
body.has-update .sidebar-scroll { padding-bottom: 56px; }
body.has-voice .update-bar { bottom: 124px; }

.update-card { width: min(520px, calc(100% - 32px)); }
.update-card h3 { font-size: 20px; }
.update-card h4 { margin: 16px 0 8px; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.update-notes {
  max-height: 260px; overflow-y: auto;
  padding: 12px 14px; border-radius: 8px; background: var(--bg);
  white-space: pre-wrap; line-height: 1.55;
}
.update-progress { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.progress-track { flex: 1; height: 8px; border-radius: 4px; background: var(--bg-4); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.update-card .row { margin-top: 16px; }
.update-bar span { flex: 1; min-width: 0; }
.update-bar .btn { height: 28px; padding: 0 10px; font-size: 12px; }
.update-bar .icon-btn { width: 24px; height: 24px; margin-left: -4px; }
.update-bar .icon-btn svg { width: 14px; height: 14px; }
/* Точка на кнопке обновлений: вышла новая версия */
#sidebar-update-check { position: relative; }
#sidebar-update-check.has-dot { color: var(--ok); }
#sidebar-update-check.has-dot::after {
  content: ''; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 2px var(--bg-2);
}

.me-panel {
  display: flex; align-items: center; gap: 4px; flex: none;
  height: var(--dock-h); margin: 0 var(--dock-gap) var(--dock-gap); padding: 0 6px 0 8px;
  border-radius: var(--r-l); background: color-mix(in srgb, var(--bg-deep) 70%, var(--bg-2));
  box-shadow: inset 0 0 0 1px var(--line);
}
.me-panel .icon-btn { width: 30px; height: 30px; }
.me-info { flex: 1; min-width: 0; margin-left: 4px; }
.me-info > div:first-child { font-weight: 600; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); border-top: 1px solid var(--line); }

.empty { margin: auto; text-align: center; padding: 24px; }
.empty h2 { margin: 16px 0 8px; }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px; flex: none; position: relative; z-index: 1;
  border-bottom: 1px solid var(--line);
}
.peer-meta { min-width: 0; }
.peer-name { font-weight: 700; }

/* ---------- Панель разговора ---------- */

/* Разговор занимает большую часть места, чат — остаток снизу. Плитки прокручиваются внутри,
   а строка состояния и кнопки всегда видны, при любом размере окна */
.call-panel {
  flex: 1 1 calc(var(--call-share, .75) * 100%); min-height: 230px; overflow: hidden; position: relative;
  padding: 12px 16px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.chat:has(> .call-panel:not(.hidden)) > .messages { flex: 1 1 calc((1 - var(--call-share, .75)) * 100%); min-height: 90px; }
.call-status-row { flex: none; align-self: center; display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 4px 8px; min-height: 20px; text-align: center; }
.call-status { color: var(--muted); font-variant-numeric: tabular-nums; }
/* Код шифрования: замок, смайлики и цифры — у всех участников одинаковые */
.call-code {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border: 0; border-radius: 999px; cursor: pointer; font: inherit; font-size: 12px;
  background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 30%, transparent);
  animation: fade var(--slow) var(--ease);
}
.call-code svg { width: 13px; height: 13px; }
.call-code .code-emoji { font-size: 14px; letter-spacing: 1px; }
.call-code .code-digits { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-2); }
.call-controls { flex: none; align-self: center; display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 10px; }
.round-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--bg-4); cursor: pointer; color: var(--text);
}
.round-btn svg { width: 22px; height: 22px; }
.round-btn:hover { background: var(--bg-5); }
.round-btn.off { background: #fff; color: var(--danger); }
.round-btn.on { background: var(--accent); color: var(--on-accent); }
.round-btn.hangup { background: var(--danger); color: #fff; }
.round-btn.hangup:hover { background: var(--danger-hover); }

/* Плитки участников: аватар, камера или экран */
.stage {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px;
  display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 10px;
}
.tile {
  position: relative; overflow: hidden; cursor: pointer; flex: none;
  width: min(190px, 100%); aspect-ratio: 16 / 10;
  display: grid; place-items: center;
  border-radius: 12px; background: var(--bg-3);
  transition: box-shadow .1s;
}
.stage.has-video .tile { width: min(260px, 100%); }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--ok); }
.tile.connecting { opacity: .55; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; }
.tile.has-video video { display: block; }
.tile.has-video .tile-avatar { display: none; }
.tile.screen video { object-fit: contain; }
video.mirror { transform: scaleX(-1); }
.tile-label {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  display: flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .55); font-size: 12px; font-weight: 600;
}
.tile-icons { display: inline-flex; align-items: center; gap: 4px; }
.tile-icons svg { width: 14px; height: 14px; color: var(--danger); }
.live { padding: 1px 5px; border-radius: 4px; background: var(--danger); color: #fff; font-size: 10px; letter-spacing: .03em; }
.tile-tools {
  position: absolute; right: 6px; top: 6px;
  display: flex; align-items: center; gap: 4px;
  opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-tools, .tile.screen .tile-tools, .tile:fullscreen .tile-tools { opacity: 1; }
.tile-volume, .tile-btn {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px;
  border: 0; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer;
}
.tile-volume svg, .tile-btn svg { width: 15px; height: 15px; }
/* Чужая трансляция, которую пока не смотрим: карточка с кнопкой «Смотреть» (как в Discord) */
.tile-watch { display: none; }
.tile.not-watching .tile-watch {
  display: inline-flex; align-items: center; gap: 8px; position: relative; z-index: 1;
  padding: 9px 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; font-size: 13px;
  box-shadow: 0 6px 18px var(--glow); transition: transform var(--fast) var(--ease), background var(--fast);
}
.tile.not-watching .tile-watch:hover { background: var(--accent-hover); transform: translateY(-1px); }
.tile-watch svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.tile.not-watching .tile-avatar { display: none; }
.tile.not-watching .tile-unwatch { display: none; }
/* Сколько кадров доходит, размер, кодек — на плитке трансляции */
.tile-stats:empty { display: none; }
.tile-stats {
  position: absolute; left: 8px; top: 8px; max-width: calc(100% - 120px);
  padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, .55); color: #e8e8f0;
  font: 11px/1.5 ui-monospace, Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-volume input { width: 70px; accent-color: var(--accent); }
/* Развёрнутая плитка (чужой экран или по клику) занимает всё свободное место, остальные — рядами снизу */
.stage.has-focus {
  display: grid; align-content: stretch;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  grid-template-rows: minmax(120px, 1fr); grid-auto-rows: auto;
}
.stage.has-focus .tile { width: 100%; max-width: 160px; justify-self: center; }
.stage.has-focus .tile.focused { order: -1; grid-column: 1 / -1; max-width: none; height: 100%; aspect-ratio: auto; }
.stage.has-focus .tile:not(.focused) .avatar.big { width: 52px; height: 52px; font-size: 22px; }
.tile:fullscreen { border-radius: 0; box-shadow: none; cursor: default; }
.tile:fullscreen video { object-fit: contain; }

@media (max-height: 640px) {
  .call-panel { padding: 8px 12px; gap: 8px; }
  .round-btn { width: 40px; height: 40px; }
  .round-btn svg { width: 19px; height: 19px; }
}
@media (max-width: 1000px) {
  .round-btn { width: 42px; height: 42px; }
  .call-controls { gap: 8px; }
}

/* Значок качества связи: три столбика */
.q-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; flex: none; }
.q-bars i { width: 3px; border-radius: 1px; background: rgba(255, 255, 255, .25); }
.q-bars i:nth-child(1) { height: 5px; }
.q-bars i:nth-child(2) { height: 8px; }
.q-bars i:nth-child(3) { height: 12px; }
.q-bars.q3 i { background: var(--ok); }
.q-bars.q2 i:nth-child(-n+2) { background: var(--warn); }
.q-bars.q1 i:nth-child(1) { background: var(--danger); }

/* «На связи» над профилем */
.voice-panel {
  display: flex; align-items: center; gap: 2px; flex: none;
  margin: 0 var(--dock-gap) 6px; padding: 8px 6px 8px 12px; border-radius: var(--r-l);
  background: color-mix(in srgb, var(--ok) 9%, var(--bg-deep));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 22%, transparent);
  animation: rise var(--slow) var(--ease-out);
}
.voice-info { flex: 1; min-width: 0; }
.voice-state-row { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: var(--warn); }
#voice-state.ok { color: var(--ok); }
#voice-where { display: block; color: var(--muted); }
.voice-panel .icon-btn.on { color: var(--accent); }
.voice-panel .icon-btn.leave:hover { color: var(--danger); }

/* ---------- Комнаты ---------- */

.list-title.with-action { display: flex; align-items: center; justify-content: space-between; padding-right: 10px; }
.list-title .icon-btn { width: 24px; height: 24px; }
.list-title .icon-btn svg { width: 16px; height: 16px; }
.room-item { list-style: none; }
.room-row { padding: 6px 8px; }
.room-icon { display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.room-icon.big { width: 36px; height: 36px; border-radius: 10px; background: var(--bg-3); color: var(--text); }
.room-row.active .room-icon { color: var(--text); }
.voice-users { list-style: none; margin: 3px 0 5px; padding: 5px 0 0; border-top: 1px solid var(--line); }
.voice-users li {
  display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 6px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.voice-users li:hover { background: var(--bg-4); }
.voice-users li > span { flex: 1; min-width: 0; }
.voice-users svg { width: 14px; height: 14px; color: var(--muted); }
.voice-users li.speaking .avatar { box-shadow: 0 0 0 2px var(--ok); }
.voice-users li.speaking { color: var(--text); }
.avatar.tiny { width: 22px; height: 22px; font-size: 11px; }
.avatar.small { width: 28px; height: 28px; font-size: 13px; }

.room-lobby {
  flex: none; padding: 14px 16px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.lobby-people { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.lobby-people:empty { display: none; }
.lobby-person { display: flex; align-items: center; gap: 8px; max-width: 180px; padding: 4px 10px 4px 4px; border-radius: 20px; background: var(--bg-3); }
.lobby-person.speaking .avatar { box-shadow: 0 0 0 2px var(--ok); }

.room-card { width: min(520px, calc(100% - 32px)); }
.room-card h3 { font-size: 20px; margin-bottom: 16px; }
.room-card h4 { margin: 18px 0 10px; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.room-card > .row:last-child { margin-top: 18px; }
.kind-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.kind input { position: absolute; opacity: 0; }
.kind-body {
  display: flex; flex-direction: column; gap: 4px; height: 100%;
  padding: 12px; border-radius: 10px; cursor: pointer;
  background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--line);
}
.kind-body svg { width: 22px; height: 22px; color: var(--muted); margin-bottom: 2px; }
.kind input:checked + .kind-body { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-3)); }
.kind input:checked + .kind-body svg { color: var(--accent); }
.friend-list { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.friend-check { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.friend-check:hover { background: var(--bg-3); }
.friend-check input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.friend-check > span:first-of-type { flex: 1; min-width: 0; }
#rm-add { margin-top: 8px; }
.rename-row { align-items: flex-end; }
.rename-row .field { margin-bottom: 0; }
.rename-row .btn { height: 40px; }
.member-list { display: flex; flex-direction: column; gap: 6px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; background: var(--bg-3); }
.member-row .grow { min-width: 0; }
.member-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; flex: none; max-width: 70%; }
.member-actions:empty { display: none; }
.member-row .btn { height: 30px; padding: 0 10px; font-size: 13px; }
.role-select { height: 30px; padding: 0 6px; font-size: 13px; max-width: 150px; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.btn.on { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }

/* ---------- Выбор экрана ---------- */

.screen-card { width: min(760px, calc(100% - 32px)); }
.screen-card h3 { font-size: 20px; margin-bottom: 8px; }
.screen-card h4 { margin: 14px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.screen-sources { max-height: 46vh; overflow-y: auto; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.source {
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  border: 0; border-radius: 10px; background: var(--bg-3); cursor: pointer; text-align: left;
}
.source:hover { background: var(--bg-4); }
.source.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.screen-options { margin-top: 16px; }
/* Режимы трансляции — три карточки: разрешение, кадры и сколько нужно интернета */
.screen-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.screen-mode {
  position: relative; display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; cursor: pointer;
  border-radius: var(--r-m); background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--fast), background var(--fast);
}
.screen-mode input { position: absolute; opacity: 0; pointer-events: none; }
.screen-mode b { font-size: 16px; }
.screen-mode span { font-size: 13px; color: var(--text-2); }
.screen-mode em { font-style: normal; font-size: 11px; color: var(--muted); }
.screen-mode:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.screen-mode:has(input:checked) { background: color-mix(in srgb, var(--accent) 14%, var(--bg-3)); box-shadow: inset 0 0 0 2px var(--accent); }
.screen-options .check { margin-bottom: 8px; }
.screen-card .row { margin-top: 12px; }

/* ---------- Трансляция во весь экран ---------- */

.fullview { position: fixed; inset: 0; z-index: 30; background: #000; }
.fullview video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.fullview-bar {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,.75), rgba(0,0,0,0));
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.fullview.show-bar .fullview-bar { opacity: 1; pointer-events: auto; }
.fullview.show-bar { cursor: default; }
.fullview:not(.show-bar) { cursor: none; }
.fullview-bar .btn { height: 32px; font-size: 13px; }

/* Выбор экрана: превью, значок и название окна */
.source-preview { width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #000; display: grid; place-items: center; }
.source-preview img { width: 100%; height: 100%; object-fit: contain; }
.source-preview.empty { color: var(--muted); font-size: 12px; text-align: center; padding: 8px; background: var(--bg-2); }
.source-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; }
.source-icon { width: 16px; height: 16px; flex: none; }
#screen-tabs { align-items: center; }
#screen-tabs .icon-btn { width: 30px; height: 30px; }
.tile:not(.has-video) .tile-btn { display: none; }

/* ---------- Проверка звука и камеры ---------- */

.meter { height: 8px; border-radius: 4px; background: var(--bg-4); overflow: hidden; margin: 2px 0 6px; }
.meter-fill { height: 100%; width: 0; background: var(--accent); transition: width .06s linear; }
.meter-fill.loud { background: var(--warn); }
.row.wrap { flex-wrap: wrap; }
.hint-text, .field > .hint-text { font-size: 12px; font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; }
.cam-test { margin-top: 6px; }
.cam-preview { width: 100%; max-height: 220px; margin-top: 12px; border-radius: 10px; background: #000; object-fit: cover; }

/* ---------- Сообщения ---------- */

.messages { flex: 1; min-height: 110px; overflow-y: auto; padding: 8px 16px 12px; display: flex; flex-direction: column; }
.messages .day { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; font-size: 11.5px; color: var(--muted); }
.messages .day::before, .messages .day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.msg { position: relative; display: flex; gap: 16px; padding: 2px 16px; margin: 0 -16px; border-radius: var(--r-s); transition: background var(--fast); }
.msg:not(.cont) { margin-top: 14px; }
.msg:hover { background: color-mix(in srgb, var(--bg-deep) 35%, transparent); }
.msg.cont { padding-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg-body { min-width: 0; flex: 1; }
/* Кнопки у сообщения — появляются при наведении в правом верхнем углу */
.msg-tools {
  position: absolute; right: 12px; top: -14px; display: flex; gap: 2px; padding: 2px;
  border-radius: var(--r-s); background: var(--bg-2); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity var(--fast), transform var(--mid) var(--ease-out);
}
.msg:hover .msg-tools { opacity: 1; transform: none; pointer-events: auto; }
.msg-tool { width: 30px; height: 28px; display: grid; place-items: center; border: 0; border-radius: var(--r-s); background: none; color: var(--muted); cursor: pointer; }
.msg-tool svg { width: 16px; height: 16px; }
.msg-tool:hover { background: var(--bg-4); color: var(--text); }
.msg-tool.danger:hover { color: var(--danger); }
.msg-head { display: flex; gap: 8px; align-items: baseline; }
.msg-head b { font-weight: 600; }
.msg-head time { font-size: 11px; color: var(--muted); }
/* Текст сообщения с разметкой */
.msg-text { overflow-wrap: anywhere; line-height: 1.45; }
.msg-text p { margin: 0; white-space: pre-wrap; }
.msg-text p + p, .msg-text p + *, .msg-text * + p { margin-top: 6px; }
.msg-text a { color: var(--link); text-decoration: none; }
.msg-text a:hover { text-decoration: underline; }
.msg-text code { padding: 1px 5px; border-radius: 4px; background: var(--bg-3); font-family: Consolas, 'Cascadia Mono', monospace; font-size: .92em; }
.msg-text pre { margin: 6px 0; padding: 10px 12px; border-radius: 8px; background: var(--bg-deep); border: 1px solid var(--line); overflow-x: auto; max-width: 100%; }
.msg-text pre code { padding: 0; background: none; white-space: pre; }
.msg-text blockquote { margin: 4px 0; padding: 2px 0 2px 10px; border-left: 4px solid var(--line-strong); color: var(--text-2); }
.msg-text ul, .msg-text ol { margin: 4px 0; padding-left: 22px; }
.msg-text h4, .msg-text h5, .msg-text h6 { margin: 6px 0 2px; }
.msg-text h4 { font-size: 18px; } .msg-text h5 { font-size: 16px; } .msg-text h6 { font-size: 14px; }
.msg-text .spoiler { padding: 0 3px; border-radius: 4px; background: var(--bg-deep); color: transparent; cursor: pointer; transition: color .15s; }
.msg-text .spoiler.open { color: inherit; background: var(--bg-3); cursor: text; }

/* ---------- Ответ, реакции, закреп (2.4) ---------- */
.msg-reply { position: relative; display: flex; align-items: center; gap: 8px; max-width: min(100%, 480px); margin: 2px 0 3px; padding: 1px 0 1px 10px; border-left: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 2px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.msg-reply::before { content: ''; position: absolute; left: -2px; top: -5px; width: 9px; height: 9px; border-left: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-top: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-top-left-radius: 7px; }
.msg-reply:hover { border-left-color: var(--accent); }
.msg-reply b { color: color-mix(in srgb, var(--accent) 80%, var(--text)); font-weight: 600; white-space: nowrap; padding-left: 2px; }
.msg-reply span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-edited { margin-left: 6px; font-size: 11px; color: var(--muted); }
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction-chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg-3); color: var(--text-2); font-size: 12px; cursor: pointer; }
.reaction-chip:hover { border-color: var(--line-strong); }
.reaction-chip.mine { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 16%, var(--bg-3)); color: var(--text); }
.reaction-pop { position: fixed; z-index: 60; display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; padding: 4px; max-height: 200px; overflow-y: auto; scrollbar-width: thin; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); box-shadow: var(--shadow); }
.reaction-pop button { width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; font-size: 18px; cursor: pointer; }
.reaction-pop button:hover { background: var(--bg-4); }
.reply-bar { display: flex; align-items: center; gap: 8px; margin: 0 12px 6px; padding: 5px 12px; border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--accent) 7%, transparent); font-size: 12px; }
.reply-bar b { color: color-mix(in srgb, var(--accent) 80%, var(--text)); font-weight: 600; white-space: nowrap; }
.reply-bar span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.reply-bar button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.reply-bar button:hover { color: var(--danger); }
.pinned-bar { display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 7px 8px 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); font-size: 12.5px; cursor: pointer; }
.pinned-bar:hover { background: var(--bg-3); }
.pinned-bar b { color: var(--accent); font-weight: 600; white-space: nowrap; }
.pinned-bar .pin-text { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-bar .unpin { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.pinned-bar .unpin:hover { background: var(--bg-4); color: var(--danger); }
.edit-card { width: min(520px, calc(100% - 32px)); }
.edit-card textarea { width: 100%; min-height: 110px; margin: 10px 0 14px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg-deep); color: var(--text); font: inherit; font-size: 13.5px; line-height: 1.45; resize: vertical; outline: none; }
.edit-card textarea:focus { border-color: var(--accent); }
.edit-card .row { align-items: center; }

/* Пересылка */
.forward-card { width: min(420px, calc(100% - 32px)); }
.forward-search { width: 100%; height: 34px; margin: 10px 0 8px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg-deep); color: var(--text); font: inherit; font-size: 13px; outline: none; }
.forward-search:focus { border-color: var(--accent); }
.forward-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.forward-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 0; border-radius: 8px; background: var(--bg-3); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.forward-item:hover { background: var(--bg-4); }
.forward-sub { color: var(--muted); font-size: 11.5px; }
.msg-text table { border-collapse: collapse; margin: 6px 0; font-size: 13px; display: block; max-width: 100%; overflow-x: auto; }
.msg-text th, .msg-text td { border: 1px solid var(--line); padding: 4px 9px; text-align: left; }
.msg-text th { background: var(--bg-3); font-weight: 600; }
.msg-text tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-3) 45%, transparent); }
.code-block { position: relative; margin: 6px 0; }
.code-lang { position: absolute; top: 5px; right: 8px; font-size: 10px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.tok-keyword { color: #569cd6; }
.tok-func { color: #dcdcaa; }
.tok-prop { color: #9cdcfe; }
.tok-string { color: #ce9178; }
.tok-number { color: #b5cea8; }
.tok-type { color: #4ec9b0; }
.tok-comment { color: #6a9955; font-style: italic; }
.msg-text.emoji-only { font-size: 40px; line-height: 1.2; }
.messages .hint { margin: auto; color: var(--muted); text-align: center; }
.jump-bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 16px -4px; padding: 6px 14px 10px; border: 0; border-radius: var(--r-m) var(--r-m) 0 0;
  background: var(--bg-4); color: var(--text-2); font-size: 13px; cursor: pointer; animation: jump-in var(--mid) var(--ease-out);
}
.jump-bar b { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.jump-bar svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.jump-bar:hover { background: var(--bg-5); }
.jump-bar.fresh { background: var(--accent); color: var(--on-accent); }
.jump-bar.fresh:hover { background: var(--accent-hover); }
@keyframes jump-in { from { opacity: 0; transform: translateY(6px); } }



/* ---------- Окна ---------- */

.modal {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg-deep) 70%, transparent); backdrop-filter: blur(6px);
  animation: fade var(--mid) var(--ease);
}
.modal-card {
  width: min(460px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto;
  padding: 24px; border-radius: var(--r-xl); background: var(--bg-2);
  box-shadow: var(--shadow), 0 0 80px color-mix(in srgb, var(--accent) 8%, transparent);
  animation: pop var(--slow) var(--ease-out);
}
/* Настройки: как настройки комнаты — разделы слева, содержимое справа; крестик сверху, кнопки внизу всегда видны */
.modal-card.set-card { width: min(860px, calc(100% - 32px)); height: min(680px, calc(100% - 32px)); padding: 0; display: flex; overflow: hidden; }
.set-body { padding-top: 4px; }
.set-pane { display: flex; flex-direction: column; gap: 12px; }
.set-block { padding: 16px; border-radius: var(--r-l); background: color-mix(in srgb, var(--bg-3) 55%, transparent); box-shadow: inset 0 0 0 1px var(--line); }
.set-block > :last-child { margin-bottom: 0; }
.set-block h4 { margin: 0 0 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: color-mix(in srgb, var(--accent) 55%, var(--text)); }
.set-block .field:last-child { margin-bottom: 0; }
.settings-card .row .field { margin-bottom: 0; }
.set-foot {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 12px 28px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg-deep) 35%, var(--bg-2));
}
.set-foot .error { flex: 1; }
.ptt-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; }
kbd {
  min-width: 34px; padding: 4px 10px; border-radius: var(--r-s); text-align: center;
  background: var(--bg-deep); box-shadow: inset 0 -2px 0 var(--line-strong), inset 0 0 0 1px var(--line);
  font: 600 13px/1.3 inherit; color: var(--text);
}
.incoming-card { width: 320px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 24px; }
.incoming-card h3 { margin-top: 18px; font-size: 20px; }
.incoming-card .row { margin-top: 16px; }

.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.color {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.2);
}
.color.selected { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--text); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: var(--r-m);
  background: var(--bg-deep); box-shadow: var(--shadow);
  animation: toast-in var(--slow) var(--ease-out);
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }

/* Код из письма: поле и кнопка «Отправить код» в одной строке */
.code-row { gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.code-row input:not(:placeholder-shown) { letter-spacing: .2em; }
.code-row .btn { flex: none; }
.email-link { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* ---------- Статусы ---------- */

.avatar .status.s-online { background: var(--ok); }
.avatar .status.s-idle { background: var(--idle); }
.avatar .status.s-dnd { background: var(--danger); }
.avatar .status.s-invisible { background: var(--bg-2); box-shadow: inset 0 0 0 2px #80848e; }
.me-status-btn { padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; flex: none; }
.me-status-btn:hover .avatar { filter: brightness(1.12); }
.status-menu {
  position: absolute; left: 10px; bottom: calc(var(--dock-h) + var(--dock-gap) + 8px); z-index: 15; width: 260px;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  border-radius: var(--r-l); background: var(--bg-deep); box-shadow: var(--shadow);
  transform-origin: bottom left; animation: pop-up var(--mid) var(--ease-out);
}
.status-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.status-item:hover { background: var(--bg-3); }
.status-item.active { background: var(--bg-4); }
.status-text { display: flex; flex-direction: column; min-width: 0; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: #80848e; }
.status-dot.s-online { background: var(--ok); }
.status-dot.s-idle { background: var(--idle); }
.status-dot.s-dnd { background: var(--danger); }
.status-dot.s-invisible { background: none; box-shadow: inset 0 0 0 2px #80848e; }

/* ---------- Центр уведомлений ---------- */

.notif-btn { position: relative; margin-left: 4px; }
.sidebar-head .notif-btn { margin-right: 0; }
.notif-badge {
  position: absolute; top: -3px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.notif-panel {
  position: absolute; left: 10px; top: 60px; z-index: 15; width: 340px; max-height: 70vh;
  display: flex; flex-direction: column; border-radius: var(--r-l); background: var(--bg-deep);
  box-shadow: var(--shadow); overflow: hidden;
  transform-origin: top left; animation: pop-down var(--mid) var(--ease-out);
}
.notif-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-head .btn { height: 28px; padding: 0 10px; font-size: 12px; }
.notif-list { overflow-y: auto; display: flex; flex-direction: column; padding: 6px; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.notif-item:hover { background: var(--bg-3); }
.notif-item.unread { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.notif-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--bg-3); font-size: 14px; }
.notif-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item time { flex: none; }

/* ---------- Выбор темы ---------- */

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-bottom: 8px; }
.theme-card {
  display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 0; border-radius: 8px;
  background: none; cursor: pointer; text-align: left; color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.theme-card:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.theme-card.selected { box-shadow: inset 0 0 0 2px var(--accent); color: var(--text); }
.theme-name { font-size: 13px; font-weight: 600; padding: 0 2px 2px; }
/* Схема окна в цветах темы карточки: data-theme на карточке включает её переменные */
.theme-preview { display: flex; height: 64px; border-radius: 5px; overflow: hidden; background: var(--bg); }
.tp-side { width: 34%; padding: 6px 5px; display: flex; flex-direction: column; gap: 4px; background: var(--bg-2); }
.tp-side i { height: 6px; border-radius: 3px; background: var(--bg-4); }
.tp-side i:first-child { background: var(--accent); }
.tp-main { flex: 1; padding: 8px 7px; display: flex; flex-direction: column; gap: 5px; }
.tp-main i { height: 5px; width: 80%; border-radius: 3px; background: var(--muted); opacity: .6; }
.tp-main i.short { width: 55%; }
.tp-main b { margin-top: auto; height: 10px; border-radius: 3px; background: var(--bg-3); }

/* ---------- Поле ввода: файлы, превью ссылки, строка с «+», текстом, смайликами и отправкой ---------- */

.composer { flex: none; position: relative; display: flex; flex-direction: column; gap: 8px; padding: 0 16px var(--dock-gap); }
.composer-bar {
  display: flex; align-items: flex-end; gap: 2px; padding: 0 6px; min-height: var(--dock-h);
  border-radius: var(--r-l); background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--mid) var(--ease);
}
.composer-bar:focus-within { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent), 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
.composer textarea {
  flex: 1; min-height: var(--dock-h); max-height: 40vh; padding: 17px 6px; resize: none; overflow-y: auto;
  border: 0; background: none; color: var(--text); font: inherit; line-height: 1.4; outline: none;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-btn {
  width: 38px; height: var(--dock-h); flex: none; display: grid; place-items: center;
  border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: var(--r-s);
  transition: color var(--fast), transform var(--fast) var(--ease);
}
.composer-btn:active:not(:disabled) { transform: scale(.88); }
.composer-btn svg { width: 22px; height: 22px; }
.composer-btn:hover:not(:disabled) { color: var(--text); }
.composer-btn.send { color: var(--accent); }
.composer-btn:disabled { opacity: .4; cursor: default; }
.composer-files { display: flex; gap: 8px; overflow-x: auto; padding: 8px; border-radius: 8px; background: var(--bg-3); }
.file-chip {
  position: relative; width: 168px; flex: none; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto;
  column-gap: 8px; align-items: center; padding: 8px; border-radius: 6px; background: var(--bg-2); overflow: hidden;
}
.file-chip.error { box-shadow: inset 0 0 0 1px var(--danger); }
.file-thumb { grid-row: span 2; width: 40px; height: 40px; border-radius: 4px; background: var(--bg-4) center / cover; display: grid; place-items: center; color: var(--muted); }
.file-name { font-size: 13px; font-weight: 600; padding-right: 18px; }
.file-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transition: width .2s; }
.file-remove {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; display: grid; place-items: center;
  border: 0; border-radius: 4px; background: var(--bg-deep); color: var(--muted); cursor: pointer;
}
.file-remove:hover { color: var(--danger); }
.file-remove svg { width: 14px; height: 14px; }
.composer-preview { position: relative; padding: 8px 36px 8px 8px; border-radius: 8px; background: var(--bg-3); }
.composer-preview .link-card { margin: 0; max-width: none; }
.drop-target { outline: 2px dashed var(--accent); outline-offset: -8px; }

.emoji-popover {
  position: fixed; z-index: 40; width: 340px; height: 320px; display: flex; flex-direction: column;
  border-radius: var(--r-l); background: var(--bg-2); box-shadow: var(--shadow); overflow: hidden;
  transform-origin: bottom right; animation: pop-up var(--mid) var(--ease-out);
}
.emoji-tabs { display: flex; gap: 2px; padding: 6px; background: var(--bg-deep); }
.emoji-tab { flex: 1; height: 30px; border: 0; border-radius: var(--r-s); background: none; font-size: 16px; cursor: pointer; filter: grayscale(1); opacity: .7; transition: background var(--fast), opacity var(--fast), filter var(--fast); }
.emoji-tab:hover, .emoji-tab.active { background: var(--bg-4); filter: none; opacity: 1; }
.emoji-grid { flex: 1; overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); align-content: start; gap: 2px; padding: 8px; }
.emoji-grid .emoji {
  height: 36px; min-width: 0; padding: 0; border: 0; border-radius: var(--r-s); background: none;
  font-size: 22px; line-height: 36px; cursor: pointer; overflow: hidden;
  transition: background var(--fast), transform var(--fast) var(--spring);
}
.emoji-grid .emoji:hover { background: var(--bg-4); transform: scale(1.18); }

/* ---------- Вложения и превью в сообщении ---------- */

.msg-content { min-width: 0; }
.msg-images { display: grid; gap: 4px; margin-top: 4px; max-width: 420px; }
.msg-images.n2, .msg-images.n4 { grid-template-columns: 1fr 1fr; }
.msg-images.n3 { grid-template-columns: 1fr 1fr 1fr; }
.msg-images img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 6px; cursor: zoom-in; background: var(--bg-3); }
.msg-images.n1 img { width: auto; max-width: 100%; object-fit: contain; }
.msg-video { display: block; margin-top: 4px; max-width: min(480px, 100%); max-height: 320px; border-radius: 6px; background: #000; }
.file-card { margin-top: 4px; max-width: 420px; padding: 10px 12px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); }
.file-card-row { display: flex; align-items: center; gap: 10px; }
.file-card-icon { color: var(--muted); }
.file-card-icon svg { width: 30px; height: 30px; }
.file-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-card-info a { color: var(--link); font-weight: 600; }
.file-card audio { width: 100%; margin-top: 8px; height: 36px; }
.link-card {
  display: flex; gap: 12px; margin-top: 6px; max-width: 520px; padding: 10px 12px;
  border-radius: 4px; border-left: 4px solid var(--accent); background: var(--bg-2);
}
.link-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.link-card-site { color: var(--muted); }
.link-card-title { color: var(--link); font-weight: 600; }
.link-card-desc { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.link-card-image { width: 80px; height: 80px; flex: none; object-fit: cover; border-radius: 4px; }

.image-viewer { position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; background: rgba(0, 0, 0, .85); cursor: zoom-out; }
.image-viewer img { max-width: 100%; max-height: calc(100% - 40px); object-fit: contain; border-radius: 4px; }
.image-viewer-bar { display: flex; gap: 16px; align-items: center; max-width: 100%; color: #fff; font-size: 13px; }
.image-viewer-bar a { color: #fff; text-decoration: underline; cursor: pointer; }

/* ---------- Карточка профиля ---------- */

[data-profile] { cursor: pointer; }
.msg-head b[data-profile]:hover, .peer-name[data-profile]:hover, .me-info:hover > div:first-child { text-decoration: underline; }
.profile-card {
  position: fixed; z-index: 60; width: 300px; max-height: calc(100vh - 16px); overflow-y: auto;
  border-radius: 8px; background: var(--bg-deep); box-shadow: var(--shadow), 0 0 0 1px var(--line);
}
.pc-banner { height: 92px; border-radius: 8px 8px 0 0; background: var(--banner); }
.profile-card .pc-avatar.avatar { position: absolute; top: 44px; left: 16px; width: 88px; height: 88px; font-size: 34px; box-shadow: 0 0 0 6px var(--bg-deep); }
.profile-card .pc-avatar .status { width: 28px; height: 28px; right: -2px; bottom: -2px; border: 5px solid var(--bg-deep); }
.pc-edit { position: absolute; top: 100px; right: 12px; }
.pc-edit svg { width: 18px; height: 18px; }
.pc-body { margin: 52px 12px 12px; padding: 12px; border-radius: 8px; background: var(--bg-2); }
.pc-name { font-size: 20px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.pc-login { color: var(--text-2); font-size: 14px; }
.pc-status { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--text-2); font-size: 13px; }
.pc-status .status-dot { width: 10px; height: 10px; }
.pc-voice {
  display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 10px; padding: 6px 8px;
  border: 0; border-radius: 4px; background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left;
}
.pc-voice:hover { background: color-mix(in srgb, var(--ok) 26%, transparent); }
.pc-voice svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; }
.pc-divider { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.pc-section + .pc-section { margin-top: 12px; }
.pc-section h5 { margin: 0 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--text); }
.pc-text, .pc-bio { font-size: 14px; color: var(--text-2); }
.pc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pc-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 4px;
  background: var(--bg-4); font-size: 12px; font-weight: 500;
}
.pc-chip::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--chip, var(--muted)); }
.pc-chip.link { cursor: pointer; }
.pc-chip.link:hover { background: var(--bg-5); }
.pc-keycode { display: grid; gap: 4px; }
.pc-keycode-value { font: 600 15px ui-monospace, Consolas, monospace; letter-spacing: .06em; user-select: all; }
.pc-keycode.changed .pc-keycode-value { color: var(--warn); }
.pc-keycode-warn { color: var(--warn); }
.pc-keycode .btn { justify-self: start; margin-top: 4px; }
.pc-note {
  width: 100%; resize: vertical; min-height: 36px; padding: 6px 8px; border: 0; border-radius: 4px;
  background: transparent; color: var(--text); font: inherit; font-size: 13px;
}
.pc-note:hover, .pc-note:focus { background: var(--bg-deep); outline: none; }
.pc-actions { display: flex; gap: 8px; margin-top: 12px; }
.pc-actions .btn { flex: 1; }
.color.auto { position: relative; }
.color.auto::after { content: 'A'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
#set-bio { width: 100%; padding: 8px 12px; resize: vertical; border: 1px solid transparent; border-radius: 4px; background: var(--bg-deep); color: var(--text); font: inherit; outline: none; }
#set-bio:focus { border-color: var(--accent); }
.field > span em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ---------- Раздел «Друзья» ---------- */

.friends-nav { width: calc(100% - 16px); margin: 8px 8px 0; border: 0; background: none; font: inherit; text-align: left; }
.friends-nav .room-icon svg { width: 20px; height: 20px; }
.friends-nav .name { color: var(--text-2); font-weight: 600; }
.friends-nav.active .name, .friends-nav:hover .name { color: var(--text); }
.friends-nav .badge, .friend-tabs .badge { background: var(--danger); }
.friends-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.friends-head { gap: 8px; }
.friends-title { display: inline-flex; align-items: center; gap: 8px; color: var(--text); flex: none; }
.friends-title svg { width: 22px; height: 22px; color: var(--muted); }
.head-divider { width: 1px; height: 24px; background: var(--line-strong); margin: 0 8px; flex: none; }
.friend-tabs { display: flex; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.friend-tabs button {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 26px; padding: 0 9px; border: 0; border-radius: 4px; background: none;
  color: var(--text-2); font-weight: 500; cursor: pointer;
}
.friend-tabs button:hover { background: var(--bg-4); color: var(--text); }
.friend-tabs button.active { background: var(--bg-5); color: var(--text); }
.friend-tabs .add-tab { background: var(--ok); color: #fff; font-weight: 600; }
.friend-tabs .add-tab:hover { background: var(--ok); filter: brightness(1.1); color: #fff; }
.friend-tabs .add-tab.active { background: none; color: var(--ok); }
.friend-tabs .badge { min-width: 18px; height: 18px; font-size: 11px; }
.friends-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 20px 30px; }
.friends-body .list-title { padding: 16px 0 8px; }
.friend-search { width: 100%; height: 34px !important; }
.friends-empty { text-align: center; margin: 32px auto; max-width: 380px; }
/* Совон в пустых местах: покачивается и моргает */
.mascot { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 380px; text-align: center; padding: 16px; }
.mascot p { margin: 0; line-height: 1.5; }
.mascot-title { font-size: 16px; color: var(--text); margin-top: 4px; }
.sovon { width: 150px; height: 150px; overflow: visible; }
.mascot.small .sovon { width: 96px; height: 96px; }
.mascot-art .sovon { width: 170px; height: 170px; margin-bottom: 6px; }
.sovon-bob { animation: sovon-bob 3.2s ease-in-out infinite; }
.sovon-shadow { animation: sovon-shadow 3.2s ease-in-out infinite; transform-origin: 80px 150px; }
.sovon-lids rect { animation: sovon-blink 5s infinite; }
@keyframes sovon-bob { 50% { transform: translateY(-5px); } }
@keyframes sovon-shadow { 50% { transform: scaleX(.86); opacity: .18; } }
@keyframes sovon-blink { 0%, 92%, 100% { height: 0; } 95% { height: 38px; } }
@media (prefers-reduced-motion: reduce) { .sovon-bob, .sovon-shadow, .sovon-lids rect { animation: none; } }
.friend-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px; margin: 0 -10px;
  border-top: 1px solid var(--line); border-radius: 8px;
}
.friend-row:hover { background: var(--bg-3); border-top-color: transparent; }
.friend-row:hover + .friend-row { border-top-color: transparent; }
.friend-row.clickable { cursor: pointer; }
.friend-info { flex: 1; min-width: 0; }
.friend-name { font-weight: 600; color: var(--text); }
.friend-login { font-weight: 400; color: var(--muted); font-size: 13px; opacity: 0; transition: opacity .1s; }
.friend-row:hover .friend-login { opacity: 1; }
.friend-actions { display: flex; gap: 8px; flex: none; }
.friend-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--bg-2); color: var(--text-2); cursor: pointer;
}
.friend-row:hover .friend-btn { background: var(--bg-deep); }
.friend-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.friend-btn:hover:not(:disabled) { color: var(--text); }
.friend-btn.ok:hover:not(:disabled) { color: var(--ok); }
.friend-btn.danger:hover:not(:disabled) { color: var(--danger); }
.friend-btn:disabled { opacity: .4; cursor: default; }
.friend-add { max-width: 640px; }
.friend-add h3 { margin: 4px 0 8px; font-size: 16px; text-transform: uppercase; letter-spacing: .02em; }
.friend-add-row {
  display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; padding: 4px 4px 4px 12px;
  border-radius: 8px; background: var(--bg-deep); border: 1px solid var(--line);
}
/* Подсвечивается вся строка, а не поле внутри неё */
.friend-add-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.friend-add-row input { flex: 1; min-width: 0; border: 0 !important; background: none !important; padding: 0 !important; box-shadow: none !important; outline: none !important; }
.ok-text { color: var(--ok); }

/* ---------- Комнаты: кнопки в списке ---------- */

.room-tools { display: inline-flex; gap: 2px; flex: none; width: 46px; }
.room-tool {
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; display: grid; place-items: center;
  background: none; color: var(--muted); cursor: pointer; opacity: .55; transition: opacity .1s, background .1s;
}
.room-tool svg { width: 15px; height: 15px; }
.room-row:hover .room-tool, .room-row.active .room-tool { opacity: 1; }
.room-tool:hover { background: var(--bg-5); color: var(--text); }

/* ---------- Настройки комнаты ---------- */

.modal-card.rs-card { width: min(920px, calc(100% - 32px)); height: min(640px, calc(100% - 32px)); padding: 0; display: flex; overflow: hidden; }
.rs-nav { width: 210px; flex: none; display: flex; flex-direction: column; gap: 2px; padding: 20px 10px; background: var(--bg-deep); overflow-y: auto; }
.rs-room { padding: 0 10px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.rs-nav button {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 0; border-radius: 4px;
  background: none; color: var(--text-2); font: inherit; font-weight: 500; text-align: left; cursor: pointer;
}
.rs-nav button:hover { background: var(--bg-3); color: var(--text); }
.rs-nav button.active { background: var(--bg-4); color: var(--text); }
.rs-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.rs-sep { height: 1px; margin: 8px 10px; background: var(--line); }
.rs-nav .rs-danger { color: var(--danger); }
.rs-nav .rs-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.rs-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rs-head { display: flex; align-items: center; padding: 20px 20px 8px 28px; }
.rs-head h3 { flex: 1; margin: 0; font-size: 20px; }
.rs-main > .error { padding: 0 28px; }
.rs-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 28px 24px; }
.rs-body h4 { margin: 20px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.rs-row { display: flex; align-items: flex-end; gap: 10px; }
.rs-row .field { margin-bottom: 0; }
.rs-row .btn { height: 40px; flex: none; }
.rs-row > .friend-search { flex: 1; height: 36px !important; }
.rs-row > .btn.primary { height: 36px; }
/* Свой фон комнаты: картинка, приглушённая цветом темы, чтобы переписка читалась */
#room-view.has-bg {
  background:
    linear-gradient(color-mix(in srgb, var(--bg) 74%, transparent), color-mix(in srgb, var(--bg) 86%, transparent)),
    var(--room-bg) center / cover no-repeat, var(--bg);
}
#room-view.has-bg .call-panel { background: color-mix(in srgb, var(--bg-deep) 72%, transparent); }
/* Светлая тема: белый слой той же плотности закрывал картинку целиком — делаем его прозрачнее */
[data-theme='light'] #room-view.has-bg {
  background:
    linear-gradient(color-mix(in srgb, var(--bg) 40%, transparent), color-mix(in srgb, var(--bg) 58%, transparent)),
    var(--room-bg) center / cover no-repeat, var(--bg);
}
/* Перенос ключа: поле не прилипает к кнопкам, «Создать новый ключ» — в одну строку */
.e2ee-card .row { margin-top: 14px; }
.e2ee-card .row .btn { white-space: nowrap; }
.rs-bg { display: grid; gap: 10px; margin-bottom: 8px; }
.rs-bg-preview {
  height: 120px; border-radius: var(--r-m); background: var(--bg-3) center / cover no-repeat;
  box-shadow: inset 0 0 0 1px var(--line); display: grid; place-items: center; color: var(--muted); font-size: 13px;
}
.rs-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 18px; }
.rs-facts > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; background: var(--bg-3); }
.rs-my-perms { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; font-size: 13px; }
.rs-my-perms li::before { display: inline-block; width: 18px; font-weight: 700; }
.rs-my-perms li.yes::before { content: '✓'; color: var(--ok); }
.rs-my-perms li.no { color: var(--muted); }
.rs-my-perms li.no::before { content: '✕'; color: var(--danger); }

.rs-roles { display: flex; gap: 16px; align-items: flex-start; margin-top: 12px; }
.rs-role-list { width: 200px; flex: none; display: flex; flex-direction: column; gap: 2px; }
.rs-role-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 0; border-radius: 4px;
  background: none; color: var(--text-2); font: inherit; text-align: left; cursor: pointer;
}
.rs-role-item:hover { background: var(--bg-3); color: var(--text); }
.rs-role-item.active { background: var(--bg-4); color: var(--text); }
.role-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.rs-role-list .rs-create { margin-top: 6px; height: 32px; }
.rs-role-editor { flex: 1; min-width: 0; padding: 16px; border-radius: 8px; background: var(--bg-3); }
.rs-role-editor h4:first-child { margin-top: 0; }
.rs-role-editor input[type=color] { width: 48px; height: 40px; padding: 2px; border: 0; border-radius: 4px; background: var(--bg-deep); cursor: pointer; }
.perm-list { display: flex; flex-direction: column; }
.perm-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.perm-item:last-child { border-bottom: 0; }
.perm-item.dim { opacity: .45; }
.switch {
  appearance: none; width: 40px; height: 24px; flex: none; margin: 0; border-radius: 12px; position: relative;
  background: var(--muted); cursor: pointer; transition: background .15s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(16px); }
.switch:disabled { opacity: .5; cursor: default; }
.rs-holders { margin-bottom: 8px; }
.chip-x { margin-left: 2px; padding: 0 2px; border: 0; background: none; color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; }
.chip-x:hover { color: var(--danger); }
.rs-actions { margin-top: 16px; }

.member-info { display: flex; flex-direction: column; gap: 3px; }
.member-name { font-weight: 600; }
.member-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tag { padding: 0 6px; border-radius: 4px; background: var(--bg-5); font-size: 11px; font-weight: 600; line-height: 18px; color: var(--text-2); }
.tag.owner { background: color-mix(in srgb, #f0b232 22%, transparent); color: #f0b232; }
.tag.live { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.tag.kicked { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.btn.warn-outline { background: transparent; color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); }
.btn.warn-outline:hover { background: color-mix(in srgb, var(--warn) 12%, transparent); }

/* ---------- Пригласить и кикнуть ---------- */

.invite-card h3, .kick-card h3 { font-size: 18px; margin-bottom: 12px; }
.dialog-card { width: min(420px, calc(100% - 32px)); }
.dialog-card h3 { font-size: 18px; margin-bottom: 8px; }
.dialog-card p { margin: 0 0 18px; line-height: 1.5; }
.e2ee-card p { margin-bottom: 8px; }
.e2ee-steps { margin: 0 0 14px; padding-left: 20px; line-height: 1.5; }
.e2ee-card input { width: 100%; font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }
.e2ee-card .error { margin: 6px 0 4px; }
.e2ee-share-code { font: 600 16px ui-monospace, Consolas, monospace; letter-spacing: .1em; padding: 6px 10px; border-radius: var(--r-s); background: var(--bg-3); user-select: all; }
.msg-locked { color: var(--muted); font-style: italic; }
/* Окно проверки обновлений: «последняя версия» — только «Что нового» и «Понятно» */
#update-close, #update-modal.latest #update-skip, #update-modal.latest #update-later, #update-modal.latest #update-now { display: none; }
#update-modal.latest #update-close { display: inline-flex; }
/* Мои гифки: кнопка у поля ввода, панель, «В мои гифки» на гифке в сообщении */
.composer-btn.gif b { font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 1px 4px; border: 1.5px solid currentColor; border-radius: 4px; }
.gif-popover { position: fixed; z-index: 60; width: 360px; max-height: 420px; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--r-l); background: var(--bg-deep); box-shadow: var(--shadow); }
.gif-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.gif-grid { overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gif-item, .gif-add { aspect-ratio: 1; border: 0; border-radius: var(--r-m); background: var(--bg-3); cursor: pointer; overflow: hidden; padding: 0; color: var(--text-2); font: inherit; font-size: 13px; }
.gif-add { border: 1.5px dashed var(--line-strong); background: none; }
.gif-add:hover { color: var(--text); border-color: var(--accent); }
.gif-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-item:hover { box-shadow: 0 0 0 2px var(--accent); }
.gif-cell { position: relative; }
.gif-cell img { display: block; }
.gif-save { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; opacity: 0; transition: opacity var(--fast); }
.gif-cell:hover .gif-save { opacity: 1; }
.gif-save svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
/* Настройки → свои звуки */
.custom-sounds { display: grid; gap: 6px; margin-top: 10px; }
.sound-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r-m); background: var(--bg-3); }
.sound-name { flex: 1; min-width: 0; display: grid; }
.sound-row .btn { height: 30px; padding: 0 12px; font-size: 13px; }
/* Тема личного чата: свой фон переписки и свой акцентный цвет */
#chat[data-chat-theme] { background: var(--chat-bg); }
#chat[data-chat-theme] .messages { background: transparent; }
#chat[data-chat-theme='sunset'] { --accent: #ff7a59; --accent-2: #e8467c; --accent-hover: #f0663f; --chat-bg: radial-gradient(120% 80% at 100% 0%, rgba(255, 122, 89, .22), transparent 60%), radial-gradient(90% 70% at 0% 100%, rgba(232, 70, 124, .18), transparent 60%), var(--bg); }
#chat[data-chat-theme='ocean'] { --accent: #2ea7ff; --accent-2: #2860d8; --accent-hover: #1f8fe6; --chat-bg: radial-gradient(120% 80% at 100% 0%, rgba(46, 197, 255, .2), transparent 60%), radial-gradient(90% 70% at 0% 100%, rgba(40, 96, 216, .22), transparent 60%), var(--bg); }
#chat[data-chat-theme='forest'] { --accent: #3fbf7a; --accent-2: #1d7a55; --accent-hover: #33a96a; --chat-bg: radial-gradient(120% 80% at 100% 0%, rgba(95, 211, 141, .18), transparent 60%), radial-gradient(90% 70% at 0% 100%, rgba(29, 122, 85, .24), transparent 60%), var(--bg); }
#chat[data-chat-theme='night'] { --accent: #7c83ff; --accent-2: #3a3f8f; --accent-hover: #6a71f0; --chat-bg: radial-gradient(120% 80% at 50% 0%, rgba(58, 63, 143, .35), transparent 65%), linear-gradient(#0b0d24, var(--bg)); }
#chat[data-chat-theme='candy'] { --accent: #ff7ac6; --accent-2: #a77bff; --accent-hover: #f065b5; --chat-bg: radial-gradient(120% 80% at 100% 0%, rgba(255, 154, 213, .2), transparent 60%), radial-gradient(90% 70% at 0% 100%, rgba(167, 123, 255, .2), transparent 60%), var(--bg); }
#chat[data-chat-theme='lava'] { --accent: #ff8a3d; --accent-2: #d72f2f; --accent-hover: #f0772a; --chat-bg: radial-gradient(120% 80% at 100% 0%, rgba(255, 179, 65, .18), transparent 60%), radial-gradient(90% 70% at 0% 100%, rgba(215, 47, 47, .22), transparent 60%), var(--bg); }
#chat[data-chat-theme='mint'] { --accent: #3fc9b3; --accent-2: #3aa6a0; --accent-hover: #33b5a0; --chat-bg: radial-gradient(120% 80% at 100% 0%, rgba(142, 240, 211, .18), transparent 60%), radial-gradient(90% 70% at 0% 100%, rgba(58, 166, 160, .2), transparent 60%), var(--bg); }
.chat-theme-pop {
  position: fixed; z-index: 60; width: 300px; padding: 14px; border-radius: var(--r-l);
  background: var(--bg-deep); box-shadow: var(--shadow); display: grid; gap: 10px;
}
.chat-theme-scope { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
.chat-theme-scope label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.chat-theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chat-theme-item { display: grid; justify-items: center; gap: 4px; padding: 6px 2px; border: 0; border-radius: var(--r-m); background: none; color: var(--text-2); font: inherit; font-size: 11px; cursor: pointer; }
.chat-theme-item:hover { background: var(--bg-4); }
.chat-theme-swatch { width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chat-theme-item.selected .chat-theme-swatch { box-shadow: 0 0 0 2px var(--bg-deep), 0 0 0 4px var(--accent); }
/* Упоминания: метка с именем; сообщение, где упомянули меня, — подсвечено */
.mention { padding: 0 3px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: color-mix(in srgb, var(--accent) 60%, var(--text)); font-weight: 600; cursor: pointer; }
.mention:hover { background: color-mix(in srgb, var(--accent) 36%, transparent); }
.mention.me { background: color-mix(in srgb, var(--warn) 26%, transparent); color: var(--text); }
.msg.mentions-me { background: color-mix(in srgb, var(--warn) 9%, transparent); box-shadow: inset 2px 0 0 var(--warn); }
.mention-popup {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 5; max-height: 280px; overflow-y: auto;
  padding: 6px; border-radius: var(--r-m); background: var(--bg-deep); box-shadow: var(--shadow);
}
.mention-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-s); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.mention-item .avatar { width: 24px; height: 24px; font-size: 11px; }
.mention-item.active, .mention-item:hover { background: var(--bg-4); }
.invite-card .friend-search { margin-bottom: 10px; }
.invite-list { max-height: 360px; overflow-y: auto; margin-bottom: 14px; }
.error-text { color: var(--danger); }
.kick-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.kick-option { display: flex; align-items: center; justify-content: center; padding: 10px; border-radius: 8px; background: var(--bg-3); cursor: pointer; font-weight: 600; }
.kick-option input { position: absolute; opacity: 0; pointer-events: none; }
.kick-option:has(input:checked) { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); }

@media (max-width: 760px) {
  .rs-nav { width: 160px; }
  .rs-roles { flex-direction: column; }
  .rs-role-list { width: 100%; }
}

/* ---------- Каналы: столбец слева ---------- */

.rail {
  width: 72px; flex: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  /* «+» внизу — по центру нижней полки: (высота полки − высота плитки) / 2 + отступ полки */
  padding: 10px 0 calc(var(--dock-gap) + (var(--dock-h) - var(--rail-tile)) / 2); background: transparent;
}
.rail-list {
  flex: 1; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  overflow-y: auto; scrollbar-width: none; padding: 4px 0 8px;
}
.rail-list::-webkit-scrollbar { display: none; }
.rail-list.drop-end { box-shadow: inset 0 -3px 0 var(--accent); }
.rail-sep { width: 32px; height: 2px; margin: 6px 0; border-radius: 1px; background: var(--line-strong); flex: none; }
.rail-item { position: relative; width: 72px; display: flex; justify-content: center; flex: none; }

/* Полоска слева: точка — есть непрочитанное, короткая — наведение, длинная — открыто */
.rail-item::before {
  content: ''; position: absolute; left: 0; top: 50%;
  width: 4px; height: 0; border-radius: 0 4px 4px 0; background: var(--text);
  transform: translateY(-50%); transition: height var(--mid) var(--spring);
}
.rail-item.unread::before { height: 8px; }
.rail-item:hover::before { height: 18px; }
.rail-item.active::before { height: 36px; }

.rail-tile {
  position: relative; width: var(--rail-tile); height: var(--rail-tile); padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--bg-3); color: var(--text-2); cursor: pointer;
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
  transition: border-radius var(--mid) var(--ease), background var(--mid), box-shadow var(--mid) var(--ease), transform var(--fast) var(--ease);
}
.rail-tile:hover, .rail-item.active .rail-tile { border-radius: 15px; }
.rail-tile:active { transform: scale(.94); }
.rail-item.active .rail-tile { box-shadow: 0 6px 16px color-mix(in srgb, var(--hub-color, var(--accent)) 35%, transparent); }
.rail-home { background: var(--bg-3); }
.rail-home img { display: block; }
.rail-item.active .rail-home, .rail-home:hover { background: var(--accent); }
.rail-add { flex: none; color: var(--ok); }
.rail-add:hover { background: var(--ok); color: var(--bg-deep); }
.rail-add svg { width: 22px; height: 22px; }

.hub-tile {
  background-color: var(--hub-color); background-size: cover; background-position: center;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); user-select: none;
}
.hub-tile.big { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; font-size: 26px; font-weight: 700; flex: none; }
.hub-tile.huge { width: 96px; height: 96px; border-radius: 28px; display: grid; place-items: center; font-size: 34px; font-weight: 700; flex: none; }

.rail-badge {
  position: absolute; right: 6px; bottom: -2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; box-shadow: 0 0 0 3px var(--bg-deep);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; pointer-events: none;
}
.rail-voice {
  position: absolute; right: 8px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ok); color: #fff; box-shadow: 0 0 0 3px var(--bg-deep); pointer-events: none;
}
.rail-voice svg { width: 11px; height: 11px; }
/* Идущий личный звонок: аватарка с зелёной пульсацией */
.rail-call .rail-tile { color: #fff; font-size: 17px; background-size: cover; background-position: center; animation: call-pulse 2s var(--ease) infinite; }
.rail-call .rail-tile .status { display: none; }
.rail-call-more {
  position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--ok); color: #fff; box-shadow: 0 0 0 3px var(--bg-deep); font-size: 11px; font-weight: 700; line-height: 20px;
}
@keyframes call-pulse {
  0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 90%, transparent), 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); }
  50% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 90%, transparent), 0 0 0 8px transparent; }
}

/* Приглашение: пунктир и «!» — ждёт ответа */
.rail-item.invite .rail-tile { opacity: .75; outline: 2px dashed var(--accent); outline-offset: 2px; }
.rail-item.invite::after {
  content: '!'; position: absolute; right: 8px; top: -4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 800; line-height: 16px; text-align: center;
}

/* Группа: свёрнутая — мозаика из каналов, развёрнутая — подложка цвета группы */
.rail-folder { width: 56px; display: flex; flex-direction: column; align-items: center; gap: 6px; border-radius: 16px; flex: none; }
.rail-folder.open { padding-bottom: 6px; background: color-mix(in srgb, var(--folder-color) 18%, var(--bg-2)); }
.rail-folder .rail-item { width: 72px; }
.folder-tile { background: color-mix(in srgb, var(--folder-color) 30%, var(--bg-3)); color: var(--folder-color); }
.rail-folder.open .folder-tile { background: transparent; }
.folder-tile svg { width: 22px; height: 22px; fill: color-mix(in srgb, var(--folder-color) 35%, transparent); }
.folder-tile:has(.mini) { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 5px; grid-template-rows: 1fr 1fr; place-items: stretch; }
.folder-tile .mini {
  border-radius: 5px; display: grid; place-items: center;
  font-size: 7px; font-weight: 700; text-shadow: none; overflow: hidden;
}

/* Куда бросят: линия — перед, рамка — в группу */
.rail-item.dragging { opacity: .4; }
.rail-item.drop-before::after {
  content: ''; position: absolute; left: 12px; right: 12px; top: -5px; height: 3px; border-radius: 2px; background: var(--accent);
}
.rail-item.drop-group .rail-tile, .rail-item.drop-into .rail-tile { box-shadow: 0 0 0 3px var(--accent); border-radius: 18px; }

.rail-tip {
  position: fixed; z-index: 30; transform: translateY(-50%); pointer-events: none;
  max-width: 240px; padding: 6px 10px; border-radius: 6px;
  background: var(--bg-deep); color: var(--text); box-shadow: var(--shadow);
  font-weight: 600; font-size: 13px;
}

/* ---------- Канал: шапка, комнаты, пусто ---------- */

.head-home { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.hub-menu-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 34px; margin-left: -8px; padding: 0 8px;
  border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-weight: 700; font-size: 15px; text-align: left; cursor: pointer;
}
.hub-menu-btn:hover { background: var(--bg-4); }
.hub-menu-btn svg { margin-left: auto; color: var(--muted); }
.sidebar-head:has(.hub-menu-btn:not(.hidden)) .conn-dot { margin-left: 4px; }
.room-section { list-style: none; padding: 14px 8px 4px; }
.room-section ~ .room-section { margin-top: 10px; border-top: 1px solid var(--line); }
.room-none { list-style: none; padding: 2px 8px 6px; }

.hub-empty { display: flex; flex-direction: column; align-items: center; max-width: 440px; }
.hub-empty .hub-tile { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; font-size: 26px; font-weight: 700; }
.hub-empty .row { margin-top: 16px; }

/* ---------- Участники справа ---------- */

.members-panel { position: relative; width: var(--members-w, 240px); flex: none; display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--line); border-width: 1px 0 0 1px; }
.members-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 16px; }
.members-head { display: flex; align-items: center; gap: 6px; height: 52px; margin: 0 -8px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.members-group { padding: 16px 8px 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.member-item { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.member-item:hover { background: color-mix(in srgb, var(--bg-4) 60%, transparent); }
.member-item.offline { opacity: .45; }
.member-item.offline:hover { opacity: 1; }
.member-text { flex: 1; min-width: 0; }
.member-nick { color: var(--text-2); font-weight: 500; }
.member-item .crown { width: 14px; height: 14px; color: var(--idle); fill: currentColor; stroke-width: 1.5; }
.icon-btn.members-toggle.on { color: var(--text); }

/* Ручка на краю боковой панели: тянут мышью, при наведении — тонкая линия акцента */
.panel-resizer { position: absolute; top: 0; bottom: 0; z-index: 3; width: 8px; cursor: col-resize; }
.panel-resizer.right { right: -4px; }
.panel-resizer.left { left: -4px; }
.panel-resizer.bottom { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 8px; cursor: row-resize; }
.panel-resizer.bottom::after { top: auto; bottom: 0; left: 0; right: 0; width: auto; height: 2px; }
body.resizing-rows { cursor: row-resize; }
.panel-resizer::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; border-radius: 1px;
  background: var(--accent); opacity: 0; transition: opacity var(--mid) var(--ease);
}
.panel-resizer:hover::after, body.resizing .panel-resizer::after { opacity: .8; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing * { transition: none !important; }

/* ---------- Всплывающее меню ---------- */

.popup-menu {
  position: fixed; z-index: 25; min-width: 210px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  border-radius: var(--r-l); background: var(--bg-deep); box-shadow: var(--shadow);
  transform-origin: top left; animation: pop-down var(--mid) var(--ease-out);
}
.popup-item {
  padding: 8px 10px; border: 0; border-radius: var(--r-s); background: none;
  color: var(--text-2); font: inherit; font-weight: 500; text-align: left; cursor: pointer;
  transition: background var(--fast), color var(--fast);
}
.popup-item:hover { background: var(--accent); color: var(--on-accent); }
.popup-item.danger { color: var(--danger); }
.popup-item.danger:hover { background: var(--danger); color: #fff; }
.popup-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* ---------- Окна канала ---------- */

.hub-create-top { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.hub-create-top h3 { margin-bottom: 4px; }
.hub-create-top p { margin: 0; }
#hub-join .hub-tile { margin: 0 auto; }
.hs-icon-row { display: flex; align-items: center; gap: 18px; margin: 8px 0 18px; }
.hs-icon-actions { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hs-icon-actions p { margin: 0; }
.hs-icon-actions .btn { height: 32px; font-size: 13px; }
.manager-switch { display: inline-flex; align-items: center; gap: 8px; margin-right: 6px; color: var(--text-2); cursor: pointer; }

/* Узкое окно: всё уже, но список участников по-прежнему рядом с чатом и его ничего не перекрывает */
@media (max-width: 900px) {
  :root { --rail-tile: 42px; }
  .rail { width: 64px; }
  .rail-item, .rail-folder .rail-item { width: 64px; }
  .rail-folder { width: 52px; }
}

/* ---------- Движение ----------
   Появление окон, меню и всплывающих панелей; новые сообщения; подсветка при наведении.
   Для тех, кто попросил систему меньше двигаться, — без анимаций */

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes pop-up { from { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes pop-down { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px) scale(.96); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }

.msg.msg-new { animation: msg-in var(--slow) var(--ease-out); }
.profile-card:not(.hidden) { animation: pop var(--mid) var(--ease-out); }
.rail-tip { animation: fade var(--fast) var(--ease); }
.members-panel:not(.hidden), .update-bar { animation: rise var(--slow) var(--ease-out); }
.tile { animation: pop var(--slow) var(--ease-out); }

/* Смена темы — цвета перетекают, а не перескакивают */
html.theme-switching, html.theme-switching * { transition: background-color var(--slow) var(--ease), color var(--slow) var(--ease), border-color var(--slow) var(--ease) !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
