/* ────────────────────────────────────────────────────────────────
   Rubedo Discussion — ruby pixel design system
   Тёмная «алхимия»: рубиновый акцент, жёсткие радиусы, решётка,
   моно-метки, pixelated-иконки. Акцент/темы/анимации — рантайм:
   --accent, html[data-theme], html[data-anim], --anim-scale.
   ──────────────────────────────────────────────────────────────── */

:root {
  /* accent: рубин (перекрывается рантаймом через html style) */
  --accent: #d62839;
  --accent-hover: #e0294a;
  --accent-deep: #8f1622;
  --accent-rgb: 214, 40, 57;

  /* surfaces: тёмная тема (по умолчанию) */
  --bg-primary: #0b0709;
  --bg-secondary: #120c10;
  --bg-tertiary: #1a1116;
  --surface: rgba(18, 12, 16, 0.72);
  --surface-solid: #120c10;
  --surface-input: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(255, 255, 255, 0.06);

  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-primary: #f3e9ec;
  --text-secondary: #d8ccd1;
  --text-muted: #9b8d94;
  --error: #ef4444;
  --ok: #34d399;
  --warn: #f59e0b;

  --r-sm: 2px;
  --r-md: 3px;
  --r-panel: 4px;

  --shadow-sm: 0 2px 0 rgba(0, 0, 0, 0.45);
  --shadow-panel: 0 4px 0 rgba(0, 0, 0, 0.35), 0 14px 34px rgba(0, 0, 0, 0.45);
  --shadow-accent: 0 3px 0 var(--accent-deep), 0 8px 24px rgba(var(--accent-rgb), 0.3);

  --font-ui: 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Consolas', 'Cascadia Mono', 'Courier New', monospace;

  --focus-ring: 0 0 0 2px var(--bg-primary), 0 0 0 4px rgba(var(--accent-rgb), 0.6);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* множитель скорости анимаций (настройки: 0.5..2); 0 при anim=off не нужен —
     html[data-anim="off"] глушит всё глобально */
  --anim-scale: 1;

  --rail-w: 64px;
  --sidebar-w: 232px;
  --members-w: 240px;
}

/* ── Светлая тема ── */
html[data-theme='light'] {
  --bg-primary: #f6eff2;
  --bg-secondary: #efe4e8;
  --bg-tertiary: #e7d9de;
  --surface: rgba(255, 252, 253, 0.78);
  --surface-solid: #fbf6f8;
  --surface-input: rgba(20, 8, 12, 0.05);
  --surface-hover: rgba(20, 8, 12, 0.07);

  --border: rgba(60, 20, 30, 0.14);
  --border-strong: rgba(60, 20, 30, 0.28);
  --text-primary: #241318;
  --text-secondary: #4b333b;
  --text-muted: #8b7078;

  --shadow-sm: 0 2px 0 rgba(80, 30, 40, 0.18);
  --shadow-panel: 0 4px 0 rgba(80, 30, 40, 0.1), 0 14px 34px rgba(80, 30, 40, 0.16);
  color-scheme: light;
}
html[data-theme='dark'] { color-scheme: dark; }

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }
.hidden { display: none !important; }

html { height: 100%; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1000px 640px at 50% -12%, rgba(var(--accent-rgb), 0.12), transparent 62%),
    radial-gradient(760px 520px at 96% 112%, rgba(var(--accent-rgb), 0.08), transparent 62%),
    var(--bg-primary);
  background-attachment: fixed;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

input, textarea { user-select: text; -webkit-user-select: text; }

h1, h2 { text-wrap: balance; }
::selection { background: rgba(var(--accent-rgb), 0.4); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(var(--accent-rgb), 0.25);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(var(--accent-rgb), 0.5); background-clip: padding-box; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-sm);
}

.muted { color: var(--text-muted); }
.small { font-size: 0.75rem; }
.mono { font-family: var(--font-mono); }

/* ── Анимации: глобальные duration-множители и полный выкл ── */
html[data-anim='off'] * {
  animation: none !important;
  transition: none !important;
}

/* ── Тосты ── */
#toasts {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  max-width: 340px;
  font-size: 0.8125rem;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-panel);
  animation: toast-in 0.3s var(--ease) backwards;
}
.toast.err { border-left-color: var(--error); }
.toast.ok { border-left-color: var(--ok); }
.toast.gone { opacity: 0; transform: translateY(-6px); transition: opacity 0.3s var(--ease), transform 0.3s var(--ease); }

/* ── Кнопки ── */
button {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 10px 18px;
  color: var(--text-primary);
  background: none;
  transition:
    background calc(0.15s * var(--anim-scale)) var(--ease),
    border-color calc(0.15s * var(--anim-scale)) var(--ease),
    color calc(0.15s * var(--anim-scale)) var(--ease),
    box-shadow calc(0.15s * var(--anim-scale)) var(--ease),
    transform calc(0.1s * var(--anim-scale)) var(--ease);
}

button.primary {
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: var(--shadow-accent);
}
button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--accent-deep), 0 12px 28px rgba(var(--accent-rgb), 0.42);
}
button.primary:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--accent-deep);
}

button.secondary {
  background: var(--surface-input);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
button.secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: #fff;
  background: rgba(var(--accent-rgb), 0.14);
}
html[data-theme='light'] button.secondary:hover:not(:disabled) { color: var(--text-primary); }

button.ghost {
  padding: 7px 13px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-color: var(--border);
  box-shadow: none;
}
button.ghost:hover:not(:disabled) {
  color: #fff;
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}
html[data-theme='light'] button.ghost:hover:not(:disabled) { color: var(--accent-deep); }

button.danger:hover:not(:disabled) {
  color: #fff;
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.2);
}

button:disabled { opacity: 0.45; cursor: default; }

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-secondary);
  border-radius: var(--r-md);
}
.icon-btn:hover:not(:disabled) { color: #fff; background: rgba(var(--accent-rgb), 0.3); }
html[data-theme='light'] .icon-btn:hover:not(:disabled) { color: var(--accent-deep); background: rgba(var(--accent-rgb), 0.15); }
.icon-btn.active { color: #fff; background: rgba(var(--accent-rgb), 0.55); }

/* ── Поля ── */
input[type='text'], input[type='password'], select, textarea {
  padding: 10px 13px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition:
    border-color calc(0.15s * var(--anim-scale)) var(--ease),
    background calc(0.15s * var(--anim-scale)) var(--ease),
    box-shadow calc(0.15s * var(--anim-scale)) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14);
}
input[type='color'] {
  width: 44px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-input);
  cursor: pointer;
}

/* метка-надзаголовок: моноширинная, с рубиновым ромбом */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
}
.eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.7);
}

/* панель: жёсткие углы, тёмное стекло */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 18px 20px;
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* пиксельная рамка: светящиеся рубиновые уголки */
.pixel-corners { position: relative; }
.pixel-corners::before,
.pixel-corners::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.85);
  pointer-events: none;
  z-index: 2;
}
.pixel-corners::before { top: -3px; left: -3px; }
.pixel-corners::after { bottom: -3px; right: -3px; }

/* ════════════════════════════════════════════════
   401-ЭКРАН: кристалл + «нужен вход»
   ════════════════════════════════════════════════ */
.auth-gate {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(400px, 100%);
  text-align: center;
  padding: 34px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: rise-in calc(0.5s * var(--anim-scale)) var(--ease) backwards;
}
.crystal-scene {
  width: 96px;
  height: 104px;
  perspective: 480px;
  position: relative;
}
.crystal {
  position: absolute;
  left: 50%; top: 4px;
  width: 34px; height: 68px;
  margin-left: -17px;
  transform-style: preserve-3d;
  animation: crystal-spin calc(9s * var(--anim-scale)) linear infinite;
}
.crystal i {
  position: absolute;
  left: 2px; top: 0;
  width: 30px; height: 68px;
  clip-path: polygon(50% 0, 100% 26%, 50% 100%, 0 26%);
  background: linear-gradient(165deg, rgba(255, 105, 122, 0.85), rgba(190, 32, 50, 0.78) 45%, rgba(88, 8, 20, 0.9));
  box-shadow: inset 0 0 12px rgba(255, 160, 170, 0.35);
}
.crystal i:nth-child(1) { transform: rotateY(0deg) translateZ(14px); }
.crystal i:nth-child(2) { transform: rotateY(60deg) translateZ(14px); }
.crystal i:nth-child(3) { transform: rotateY(120deg) translateZ(14px); }
.crystal i:nth-child(4) { transform: rotateY(180deg) translateZ(14px); }
.crystal i:nth-child(5) { transform: rotateY(240deg) translateZ(14px); }
.crystal i:nth-child(6) { transform: rotateY(300deg) translateZ(14px); }
.crystal i:nth-child(2n) { filter: brightness(1.3); }
.crystal-shadow {
  position: absolute;
  left: 50%; bottom: 4px;
  width: 70px; height: 16px;
  margin-left: -35px;
  background: radial-gradient(ellipse at center, rgba(var(--accent-rgb), 0.55), transparent 70%);
  filter: blur(3px);
  animation: crystal-glow calc(3.2s * var(--anim-scale)) ease-in-out infinite alternate;
}
.auth-card h1 { font-size: 1.5rem; }
.auth-card p { color: var(--text-secondary); font-size: 0.875rem; max-width: 34ch; }

/* ════════════════════════════════════════════════
   КАРКАС: рейл | сайдбар | чат | дравер
   ════════════════════════════════════════════════ */
#app {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-w) var(--sidebar-w) minmax(0, 1fr) auto;
}

/* ── Рейл серверов ── */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  animation: rise-in calc(0.5s * var(--anim-scale)) var(--ease) backwards;
}
.rail::-webkit-scrollbar { width: 0; }
.srv-dot {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-secondary);
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition:
    border-color calc(0.15s * var(--anim-scale)) var(--ease),
    color calc(0.15s * var(--anim-scale)) var(--ease),
    transform calc(0.15s * var(--anim-scale)) var(--ease),
    border-radius calc(0.15s * var(--anim-scale)) var(--ease);
}
.srv-dot:hover { transform: translateY(-2px); border-color: rgba(var(--accent-rgb), 0.55); color: #fff; }
html[data-theme='light'] .srv-dot:hover { color: var(--accent-deep); }
.srv-dot img { width: 40px; height: 40px; image-rendering: pixelated; border-radius: var(--r-sm); }
.srv-dot.active {
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.4);
}
.srv-dot.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.7);
}
.srv-dot.unread::after {
  content: '';
  position: absolute;
  right: -3px;
  top: -3px;
  width: 10px;
  height: 10px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.8);
}
.rail-add {
  width: 44px; height: 44px;
  flex-shrink: 0;
  font-size: 1.4rem;
  color: var(--ok);
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: none;
}
.rail-add:hover:not(:disabled) { border-color: var(--ok); background: rgba(52, 211, 153, 0.12); color: var(--ok); transform: none; }

/* ── Сайдбар каналов ── */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  animation: rise-in calc(0.5s * var(--anim-scale)) var(--ease) backwards;
}
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 14px 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
}
.side-title { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 8px 4px;
}
.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px 8px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  width: 100%;
  box-shadow: none;
  background: none;
  text-transform: none;
}
.nav-btn .ch-icon { flex-shrink: 0; opacity: 0.7; font-size: 0.95rem; width: 16px; text-align: center; }
.nav-btn:hover:not(:disabled) { color: var(--text-primary); background: var(--surface-hover); border-color: transparent; transform: none; box-shadow: none; }
.nav-btn.active {
  color: #fff;
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: none;
}
html[data-theme='light'] .nav-btn.active { color: var(--accent-deep); }
.nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.7);
}
.nav-btn .unread-badge {
  margin-left: auto;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 6px;
  color: #fff;
  background: var(--accent);
  border-radius: var(--r-sm);
}
.nav-btn .ch-admin {
  margin-left: auto;
  opacity: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.nav-btn:hover .ch-admin { opacity: 1; }
.nav-btn .ch-admin:hover { color: var(--error); }
.side-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.side-foot img { width: 30px; height: 30px; image-rendering: pixelated; border: 1px solid var(--border-strong); border-radius: var(--r-sm); }
.side-foot .me-name { font-size: 0.8125rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .me-rmx {
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-foot .me-box { min-width: 0; flex: 1; }

/* ── Чат ── */
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(10px);
}
.chat-head h2 { font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.chat-head .h-badge {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.1);
  padding: 2px 8px;
  border-radius: var(--r-sm);
}
.chat-head .h-desc { margin-left: auto; font-size: 0.75rem; color: var(--text-muted); }
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.day-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 6px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.day-sep::before, .day-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.msg { display: flex; gap: 12px; padding: 5px 8px; border-radius: var(--r-md); position: relative; }
.msg:hover { background: var(--surface-hover); }
.msg.mine { cursor: pointer; }
.msg-avatar { width: 36px; height: 36px; flex-shrink: 0; image-rendering: pixelated; border-radius: var(--r-sm); border: 1px solid var(--border-strong); }
.msg-spacer { width: 36px; flex-shrink: 0; }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 10px; }
.msg-author { font-weight: 700; font-size: 0.875rem; color: var(--text-primary); }
.msg-time { font-family: var(--font-mono); font-size: 0.625rem; color: var(--text-muted); }
.msg-content {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-content a { color: var(--accent-hover); }
.msg-content code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
}
.msg-edited { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-muted); }
.msg-att { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.msg-att img {
  max-width: min(420px, 100%);
  max-height: 300px;
  image-rendering: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: zoom-in;
}
.msg-att .att-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-decoration: none;
}
.msg-att .att-file:hover { border-color: var(--accent); color: #fff; }
html[data-theme='light'] .msg-att .att-file:hover { color: var(--accent-deep); }
.msg-actions {
  position: absolute;
  display: none;
}
.msg:hover .msg-actions { display: flex; }

.typing-line {
  min-height: 22px;
  padding: 2px 28px 8px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
}
.typing-line .dots::after {
  content: '…';
  animation: blink calc(1.2s * var(--anim-scale)) infinite;
}

.chat-input-wrap { padding: 0 20px 16px; }
.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color calc(0.15s * var(--anim-scale)) var(--ease);
}
.chat-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14); }
.chat-input textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  max-height: 160px;
  min-height: 24px;
  padding: 6px 4px;
  box-shadow: none;
}
.chat-input textarea:focus { box-shadow: none; border: none; }
.chat-input .icon-btn { flex-shrink: 0; }
.chat-hint { padding: 6px 28px 0; font-size: 0.7rem; color: var(--text-muted); }

/* ════════════════════════════════════════════════
   ГОЛОС: капсула + ростеры
   ════════════════════════════════════════════════ */
.voice-cap {
  /* в потоке сайдбара, прямо над профилем (не floating слева) */
  position: static;
  margin: 6px 8px 0;
  display: flex;
  flex-wrap: nowrap;      /* одна строка: канал/статус + кнопки */
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  background: rgba(12, 8, 10, 0.82);
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  border-radius: var(--r-md);
  animation: rise-in calc(0.4s * var(--anim-scale)) var(--ease) backwards;
}
.voice-cap .vc-info {
  display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto;
  margin-right: 4px; overflow: hidden;
}
.voice-cap .vc-ch, .voice-cap .vc-ms {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.voice-cap .icon-btn { flex: none; width: 26px; height: 26px; font-size: 13px; }
/* заголовок группы каналов с плюсиком создания справа */
.nav-group { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.nav-plus {
  width: 18px; height: 18px; padding: 0; border: none; border-radius: 4px;
  background: transparent; color: var(--text-muted); font-size: 0.95rem;
  line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.nav-group:hover .nav-plus { opacity: 1; }
.nav-plus:hover { background: var(--surface-hover); color: var(--text-primary); }
html[data-theme='light'] .voice-cap { background: rgba(255, 252, 253, 0.9); }
.voice-cap .vc-ch { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ok); }
.voice-cap .vc-ms { font-size: 0.7rem; color: var(--text-muted); }
.voice-cap .vc-ping { font-family: var(--font-mono); font-size: 0.65rem; color: var(--text-muted); }

/* участник в ростере голосового канала */
.voice-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 24px;
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.voice-slot img { width: 22px; height: 22px; image-rendering: pixelated; border-radius: var(--r-sm); }
.voice-slot .vs-status { margin-left: auto; display: flex; gap: 4px; font-size: 0.75rem; color: var(--text-muted); }
.voice-slot.speaking {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--text-primary);
  box-shadow: inset 2px 0 0 var(--accent);
}
.voice-slot.streaming .vs-status .st-live { color: var(--accent); font-weight: 700; }

/* сцена голосового канала: один контейнер #voice-stage, перерендер по месту */
.voice-stage .voice-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(340px, 90%);
  margin: 14px auto 0;
  text-align: left;
}
.voice-stage .voice-slot { padding: 6px 10px; background: rgba(255, 255, 255, 0.03); }
html[data-theme='light'] .voice-stage .voice-slot { background: rgba(0, 0, 0, 0.04); }
.voice-stage .voice-slot.speaking { background: rgba(var(--accent-rgb), 0.14); }
.voice-stage .vs-name { color: var(--text-secondary); }
.voice-stage .vs-dot { width: 22px; text-align: center; color: var(--text-muted); }
.voice-stage .vs-status .st-live { color: var(--accent); font-weight: 700; }
.voice-stage button { margin-top: 16px; }

/* ════════════════════════════════════════════════
   ПЛЕЕР СТРИМА (PiP)
   ════════════════════════════════════════════════ */
.stream-pop {
  position: fixed;
  right: 20px;
  bottom: 90px;
  z-index: 50;
  width: min(520px, 45vw);
  padding: 0;
  overflow: hidden;
  animation: pop-in calc(0.2s * var(--anim-scale)) var(--ease);
}
.stream-pop canvas {
  display: block;
  width: 100%;
  max-height: 62vh;
  background: #000;
}
.stream-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-solid);
}
.stream-head .st-name { font-weight: 700; font-size: 0.8125rem; }
.stream-head .st-count { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); margin-left: auto; }
.stream-head .icon-btn { width: 28px; height: 28px; font-size: 0.85rem; }

/* LIVE-плашка на канале стримера */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  background: var(--accent);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  margin-left: auto;
}
.live-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  background: #fff;
  border-radius: 50%;
  animation: blink calc(1s * var(--anim-scale)) infinite;
}

/* ════════════════════════════════════════════════
   ДРАВЕР УЧАСТНИКОВ
   ════════════════════════════════════════════════ */
.members {
  width: var(--members-w);
  border-left: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-y: auto;
  padding: 16px 10px;
  display: flex;             /* колонка: список участников, затем индикатор прижат к низу */
  flex-direction: column;
  animation: rise-in calc(0.4s * var(--anim-scale)) var(--ease) backwards;
}
.members h3 {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 8px 4px;
}
.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); position: relative; }
.member-row img { width: 28px; height: 28px; image-rendering: pixelated; border-radius: var(--r-sm); border: 1px solid var(--border); }
.member-row .mr-name { font-size: 0.8125rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .mr-role { margin-left: auto; font-family: var(--font-mono); font-size: 0.5625rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.member-row.online::after {
  content: '';
  position: absolute;
  left: 28px;
  bottom: 8px;
  width: 9px;
  height: 9px;
  background: var(--ok);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}
.member-row .mr-kick { margin-left: auto; display: none; font-size: 0.75rem; color: var(--error); background: none; border: none; padding: 2px 6px; box-shadow: none; }
.member-row:hover .mr-kick { display: inline; }
.member-row .mr-role + .mr-kick { margin-left: 0; }

/* ════════════════════════════════════════════════
   МОДАЛКИ / ДРАВЕР НАСТРОЕК
   ════════════════════════════════════════════════ */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 3, 4, 0.6);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  animation: fade-in calc(0.2s * var(--anim-scale)) var(--ease);
}
html[data-theme='light'] .modal-back { background: rgba(120, 90, 100, 0.3); }
.modal {
  width: min(460px, calc(100vw - 40px));
  max-height: min(600px, calc(100vh - 60px));
  display: flex;
  flex-direction: column;
  animation: pop-in calc(0.22s * var(--anim-scale)) var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-row label.check { display: flex; align-items: center; gap: 7px; font-size: 0.8125rem; color: var(--text-secondary); cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 500; }
.field-row input[type='checkbox'] { accent-color: var(--accent); width: 16px; height: 16px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px;
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.swatch.active { border-color: var(--text-primary); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6); }
.preset-seg { display: flex; gap: 6px; }
.preset-seg button {
  flex: 1;
  padding: 8px 6px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface-input);
  box-shadow: none;
}
.preset-seg button.active {
  border-color: var(--accent);
  color: #fff;
  background: rgba(var(--accent-rgb), 0.2);
}
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type='range'] { flex: 1; accent-color: var(--accent); }
.range-row .rv { font-family: var(--font-mono); font-size: 0.75rem; width: 44px; text-align: right; }
.danger-zone { border-top: 1px solid rgba(239, 68, 68, 0.35); padding-top: 12px; margin-top: 4px; }

/* настройки приглашения — код крупным моно */
.invite-code {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  background: var(--surface-input);
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  border-radius: var(--r-sm);
  user-select: text;
  -webkit-user-select: text;
}

/* ════════════════════════════════════════════════
   ЛАЙТБОКС
   ════════════════════════════════════════════════ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(5, 3, 4, 0.88);
  display: grid;
  place-items: center;
  padding: 30px;
  cursor: zoom-out;
  animation: fade-in calc(0.2s * var(--anim-scale)) var(--ease);
}
.lightbox img { max-width: 100%; max-height: 100%; box-shadow: var(--shadow-panel); }

/* ════════════════════════════════════════════════
   ЗАГЛУШКИ / ПУСТОТА
   ════════════════════════════════════════════════ */
.empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-muted);
  padding: 30px;
}
.empty .eyebrow { justify-content: center; }
.empty h2 { color: var(--text-primary); font-size: 1.3rem; margin-top: 8px; }
.empty p { max-width: 40ch; margin-top: 8px; font-size: 0.875rem; }

/* выбор решёткой поля под чатом (лёгкая текстура) */
.grid-field {
  background-image:
    linear-gradient(rgba(var(--accent-rgb), 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: center;
}

/* индикатор связи — тихая пилюля в правом нижнем углу (fade, без полосы) */
#conn-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  left: auto;
  top: auto;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 12px;
  border-radius: 999px;
  background: var(--surface-input, rgba(24, 24, 28, 0.94));
  border: 1px solid var(--border-strong, var(--border));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.78rem;
  color: var(--text-secondary);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition: opacity calc(0.22s * var(--anim-scale)) var(--ease),
              transform calc(0.22s * var(--anim-scale)) var(--ease);
}
#conn-banner.show { opacity: 1; transform: none; }
.conn-ic {
  display: inline-block;
  font-size: 1rem;
  line-height: 1;
  color: var(--accent);
  animation: conn-spin 1.1s linear infinite;
}
@keyframes conn-spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════
   АНИМАЦИИ
   ════════════════════════════════════════════════ */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes crystal-spin {
  from { transform: rotateX(-12deg) rotateY(0deg); }
  to { transform: rotateX(-12deg) rotateY(360deg); }
}
@keyframes crystal-glow {
  from { opacity: 0.55; transform: scaleX(0.9); }
  to { opacity: 1; transform: scaleX(1.1); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* ════════════════════════════════════════════════
   АДАПТИВ
   ════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  :root { --members-w: 200px; }
}
@media (max-width: 980px) {
  :root { --sidebar-w: 200px; }
  .members { display: none; }
}
@media (max-width: 760px) {
  :root { --rail-w: 52px; }
  .srv-dot, .rail-add { width: 38px; height: 38px; }
  .srv-dot img { width: 34px; height: 34px; }
  .voice-cap { left: 10px; }
}

/* ════════════════════════════════════════════════
   НАСТРОЙКИ ПРИЛОЖЕНИЯ — на весь экран (как в Discord)
   ════════════════════════════════════════════════ */
#settings-ov {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  background: var(--bg-primary);
  animation: rise-in calc(0.25s * var(--anim-scale)) var(--ease);
}
.set-nav {
  width: 250px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 10px 20px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.set-nav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 14px; }
.set-nav-head h2 { font-size: 1rem; margin: 0; letter-spacing: 0.02em; }
.set-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background calc(0.12s * var(--anim-scale)) var(--ease), color calc(0.12s * var(--anim-scale)) var(--ease);
}
.set-nav-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.set-nav-btn.active {
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--text-primary);
  border-color: rgba(var(--accent-rgb), 0.3);
}
.sn-ic { width: 22px; text-align: center; font-size: 1rem; }
/* бейдж BETA на вкладке настроек (маркет — экспериментальный раздел) */
.sn-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 4px;
  padding: 1px 5px;
  opacity: 0.9;
}
.set-content { flex: 1; overflow-y: auto; padding: 34px 44px 70px; }
.set-page {
  max-width: 620px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise-in calc(0.2s * var(--anim-scale)) var(--ease);
}
.set-page h3 {
  margin: 10px 0 -6px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.set-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 10px;
}
.acc-me {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-secondary);
}
.acc-avatar { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; border: 1px solid var(--border-strong); image-rendering: pixelated; }
.acc-login { font-weight: 800; font-size: 1.05rem; }
.acc-rid { font-size: 0.72rem; color: var(--text-muted); }

/* проверка микрофона */
.mic-test { display: flex; align-items: center; gap: 12px; flex: 1; }
.meter-wrap {
  flex: 1; height: 10px; border-radius: 6px;
  background: var(--surface-input); border: 1px solid var(--border);
  overflow: hidden;
}
.meter {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #3ba55d, #faa81a 70%, #ed4245);
  transition: width calc(0.06s * var(--anim-scale)) linear;
}
.meter.hot { box-shadow: 0 0 10px rgba(237, 66, 69, 0.65); }

/* меню настроек сервера */
.srv-chlist { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.srv-chrow { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--r-sm); background: var(--surface-input); }
.srv-chname { flex: 1; font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-chrole { font-size: 0.7rem; color: var(--text-muted); }
.mini-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: var(--r-sm); padding: 2px 8px; font-size: 0.7rem; cursor: pointer; flex: none;
}
.mini-btn:hover { color: var(--text-primary); border-color: var(--accent); }
.mini-btn.danger:hover { color: var(--error); border-color: var(--error); }

/* ════════════════════════════════════════════════
   ДОМАШНИЙ ЭКРАН: друзья и личные сообщения
   ════════════════════════════════════════════════ */
.nav-home { font-size: 1.15rem; }
.nav-home.active::before { content: ''; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; background: var(--accent); border-radius: 2px; }
.rail-badge { position: absolute; top: -3px; right: -3px; }
.nav-empty { font-size: 0.75rem; color: var(--text-muted); padding: 2px 10px 6px; }
.dm-av { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.home-view { display: flex; flex-direction: column; gap: 6px; padding: 10px 8px; max-width: 720px; margin: 0 auto; width: 100%; }
.home-view h3 {
  margin: 14px 0 2px; font-size: 0.6875rem; font-family: var(--font-mono); font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted);
}
.fr-add { margin-bottom: 6px; }
.fr-add input { flex: 1; min-width: 200px; }
.fr-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--r-sm); background: var(--surface-input);
  transition: background calc(0.15s * var(--anim-scale)) var(--ease);
}
.fr-row:hover { background: rgba(var(--accent-rgb), 0.08); }
.fr-av { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-strong); }
.fr-info { flex: 1; min-width: 0; }
.fr-name { font-weight: 600; font-size: 0.9rem; }
.fr-status { font-size: 0.72rem; color: var(--text-muted); }
.fr-actions { display: flex; gap: 6px; }
.fr-empty { text-align: center; padding: 26px 0 8px; color: var(--text-secondary); }

/* точки статуса */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #3ba55d; flex: none; }
.status-dot.st-online { background: #3ba55d; }
.status-dot.st-idle { background: #faa81a; }
.status-dot.st-dnd { background: #ed4245; }
.status-dot.st-invisible, .status-dot.st-offline { background: #747f8d; }
.me-avwrap { position: relative; flex: none; cursor: pointer; border-radius: var(--r-sm); }
.me-avwrap img { display: block; }
.me-avwrap .status-dot {
  position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px;
  border: 2px solid var(--bg-secondary, #16171d); border-radius: 50%;
}
.profile-menu { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.st-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; color: var(--text-primary);
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: 0.875rem;
}
.st-opt:hover { background: rgba(var(--accent-rgb), 0.1); border-color: var(--border); }
.st-opt.danger { color: var(--error); }
.st-opt.danger:hover { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.4); }
.st-check { margin-left: auto; color: var(--accent); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

/* продолжения сообщений (аватар/имя только у первого в серии) */
.msg.cont { padding-top: 1px; padding-left: 56px; }
.msg-hover-time {
  display: none; position: absolute; left: 2px; top: 3px; width: 38px;
  text-align: right; font-size: 0.65rem; color: var(--text-muted);
}
.msg.cont:hover .msg-hover-time { display: block; }

/* ════════════════════════════════════════════════
   ИНЛАЙН-СТРИМ В СЦЕНЕ ГОЛОСОВОГО КАНАЛА
   ════════════════════════════════════════════════ */
#stage-stream-box {
  width: 100%; aspect-ratio: 16 / 9; border-radius: var(--r-panel); overflow: hidden;
  background: #000; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
#stage-stream-box #stream-video-holder, #stream-video-holder #stream-video { width: 100%; height: 100%; }
#stage-stream-box #stream-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }

/* ════════════════════════════════════════════════
   ПОПОВЕР ПРОФИЛЯ (статус/выход) — над панелью профиля
   ════════════════════════════════════════════════ */
#profile-pop {
  position: fixed;
  z-index: 80;
  min-width: 250px;
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  animation: rise-in calc(0.15s * var(--anim-scale)) var(--ease);
}
.pp-head { display: flex; align-items: center; gap: 10px; padding: 4px 4px 10px; }
.pp-av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-strong); }
.pp-login { font-weight: 800; font-size: 0.95rem; }
.pp-rid { font-size: 0.7rem; color: var(--text-muted); }
.st-opt.cur { background: rgba(var(--accent-rgb), 0.1); border-color: rgba(var(--accent-rgb), 0.25); }

/* ════════════════════════════════════════════════
   КАРТОЧКА ПРОФИЛЯ ДРУГОГО ПОЛЬЗОВАТЕЛЯ
   ════════════════════════════════════════════════ */
.uprof { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; min-width: 320px; padding: 10px 6px 2px; }
.up-av { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-strong); }
.up-name { font-size: 1.2rem; font-weight: 800; }
.up-rid { color: var(--text-muted); font-size: 0.75rem; }
.up-status { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 0.85rem; }
.up-role {
  padding: 2px 12px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
}
.up-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }

/* участники: точка статуса на аватарке, кликабельные строки */
.member-row { cursor: pointer; }
.member-row:hover { background: var(--surface-hover); }
.member-row.online::after { content: none; } /* точка теперь внутри mr-avwrap */
.mr-avwrap { position: relative; flex: none; display: block; }
.mr-avwrap .status-dot {
  position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px;
  border: 2px solid var(--bg-secondary, #16171d); border-radius: 50%;
}

/* сцена голосового канала: слот стримера кликабелен */
.voice-slot { cursor: pointer; }
.voice-slot.streaming { border-color: rgba(var(--accent-rgb), 0.4); }

/* ── Большой экран звонка (театр) ── */
#voice-theater {
  position: fixed; inset: 0; z-index: 70;
  background: var(--bg-primary);
  display: flex; flex-direction: column;
  animation: rise-in .18s ease;
}
.vt-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg-secondary); flex: 0 0 auto;
}
.vt-title { display: flex; align-items: baseline; gap: 8px; font-size: 18px; }
.vt-sub { color: var(--muted-foreground); font-size: 12px; margin-left: 6px; }
.vt-actions { display: flex; gap: 8px; align-items: center; }
.vt-grid {
  flex: 1; overflow: auto; padding: 24px;
  display: grid; gap: 16px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.vt-card {
  position: relative; border-radius: var(--r-panel); overflow: hidden;
  background: var(--bg-secondary); border: 1px solid var(--border);
  min-height: 120px; display: flex; flex-direction: column; gap: 6px;
  padding: 14px; color: var(--foreground); font: inherit; text-align: left;
}
.vt-card.vt-stream { min-height: 220px; grid-column: span 2; padding: 0; }
.vt-card.vt-stream .ss-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--bg-tertiary, var(--bg-secondary));
  border-bottom: 1px solid var(--border);
}
.vt-card.vt-stream video, .vt-card.vt-stream .ss-video { flex: 1; width: 100%; min-height: 170px; background: #000; }
.vt-card.vt-stream .ss-video video { width: 100%; height: 100%; object-fit: contain; display: block; }
.vt-user { cursor: pointer; transition: border-color .12s, transform .12s; }
.vt-user:hover { border-color: var(--accent); transform: translateY(-2px); }
.vt-user.streaming { border-color: var(--accent); }
.vt-av { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.vt-av.vt-dot { display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary, var(--bg-secondary)); color: var(--muted-foreground); }
.vt-name { font-weight: 600; font-size: 15px; }
.vt-status { color: var(--muted-foreground); font-size: 12px; }
.vt-empty { grid-column: 1 / -1; color: var(--muted-foreground); padding: 40px; text-align: center; }
.stage-watch { cursor: pointer; }

/* ── Плавающее превью своего стрима ── */
#self-preview {
  position: fixed; right: 16px; bottom: 110px; z-index: 60;
  width: 220px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-secondary);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
#self-preview video { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #000; }
#self-preview .sp-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; }

/* ── Кнопка звонка в ЛС и кликабельный заголовок ── */
.call-btn { flex: 0 0 auto; }
.chat-head h2.clickable { cursor: pointer; }
.chat-head h2.clickable:hover { color: var(--accent); }

/* ── Выделенный голосовой канал: большой экран звонка внутри панели ── */
#chat-pane { position: relative; }
#voice-view {
  position: absolute; inset: 0; z-index: 30;
  background: var(--bg-primary);
  display: flex; flex-direction: column;
}
/* ЛС-звонок: не оверлей — панель сверху (40%), история чата снизу (60%) */
#voice-view.dm-call {
  position: static; inset: auto; z-index: auto;
  order: -1; margin: 8px 8px 0;
  height: 40%; min-height: 180px;
  border: 1px solid var(--border); border-radius: var(--r-panel);
  overflow: hidden;
  animation: rise-in calc(0.3s * var(--anim-scale)) var(--ease) backwards;
}
#chat-pane.has-dm-call { display: flex; flex-direction: column; }
#chat-pane.has-dm-call #chat-scroll { flex: 1 1 60%; min-height: 0; }
#voice-view.dm-call .vv-grid { padding: 12px; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.vv-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-secondary); flex: 0 0 auto;
}
.vv-grid {
  flex: 1; overflow: auto; padding: 20px;
  display: grid; gap: 14px; align-content: start;
  /* как в Discord: карточки тянутся на ВСЮ ширину панели и держат 16:9;
     узко — одна колонка, шире — две/три */
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  grid-auto-rows: auto;
}
.vv-card {
  position: relative; border-radius: var(--r-panel); overflow: hidden;
  /* без статичной обводки: рамка только у говорящего/стримящего */
  background: color-mix(in srgb, var(--bg-secondary) 78%, white 10%);
  border: none;
  aspect-ratio: 16 / 9;
  min-height: 220px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  padding: 18px; color: var(--foreground); font: inherit; text-align: center;
}
.vv-user {
  cursor: pointer; transition: transform .1s, box-shadow .15s;
  /* светлее на 6% поверх среднего цвета аватара — без «тяжёлой» подложки */
  background: linear-gradient(0deg, rgba(255,255,255,.06), rgba(255,255,255,.06)), var(--avc, var(--bg-secondary));
}
.vv-user:hover { transform: translateY(-2px); }
.vv-user.speaking { box-shadow: 0 0 0 2px rgba(59,165,93,.55); }
.vv-user.streaming { box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .55); }
.vv-user.vv-main { grid-column: 1 / -1; aspect-ratio: 16 / 9; min-height: 320px; }
.vv-user.vv-main .vv-av { width: 168px; height: 168px; }
.vv-av { width: 120px; height: 120px; border-radius: var(--r-sm); object-fit: cover; image-rendering: pixelated; }
.vv-av.vv-dot { display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); color: rgba(255,255,255,.8); font-size: 40px; }
.vv-name { font-weight: 700; font-size: 16px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
/* стрим — такая же 16:9-карточка в общей сетке (не на всю ширину: полотно
   ломало раскладку и вылезало за пределы панели) */
.vv-card.vv-stream { aspect-ratio: 16 / 9; min-height: 220px; padding: 0; justify-content: flex-start; }
.vv-card.vv-stream.vv-main { grid-column: 1 / -1; cursor: pointer; }

/* ── режим «сцена» (как в Discord): главный участник крупно сверху,
   остальные — полоса мелких плиток снизу. Главный выбирается автоматически
   (активный говорящий / стрим) или вручную (клик). ── */
.vv-grid:has(.vv-main) {
  display: flex; flex-direction: column; gap: 12px;
  overflow: auto; align-content: start;
}
.vv-grid:has(.vv-main) > .vv-main {
  flex: 1 1 auto; min-height: 220px; width: 100%;
  aspect-ratio: auto;
}
.vv-grid:has(.vv-main) > .vv-main.vv-user .vv-av { width: 180px; height: 180px; }
.vv-grid:has(.vv-main) > .vv-main.vv-user .vv-name { font-size: 1.4rem; }
.vv-grid:has(.vv-main) > .vv-main.vv-user .vt-status { font-size: 0.9rem; }
/* полоса остальных: мелкие плитки в ряд, по центру */
.vv-strip {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center;
}
.vv-strip .vv-card {
  flex: 0 0 auto; width: 128px;
  aspect-ratio: 16 / 10; min-height: 0;
  flex-direction: column; justify-content: center; gap: 6px;
  padding: 8px; text-align: center;
}
.vv-strip .vv-user .vv-av { width: 50px; height: 50px; }
.vv-strip .vv-card .vv-name { font-size: 12.5px; }
.vv-strip .vv-card .vt-status { font-size: 11px; }
/* чужой стрим в полосе — видео прячем, плитка становится кнопкой «Смотреть» */
.vv-strip .vv-card.vv-stream .ss-video { display: none; }
.vv-strip .vv-card.vv-stream { min-height: 0; aspect-ratio: 16 / 10; }
.vv-card.vv-stream .ss-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: rgba(0,0,0,.5); border-bottom: 1px solid var(--border);
}
.vv-card.vv-stream video, .vv-card.vv-stream .ss-video { flex: 1; width: 100%; min-height: 190px; background: #000; }
.vv-card.vv-stream .ss-video video { width: 100%; height: 100%; object-fit: contain; display: block; }

/* участники под голосовым каналом в сайдбаре */
.ch-voices { display: flex; flex-direction: column; margin: 2px 0 6px 22px; gap: 1px; }
.ch-vrow {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px;
  border: 0; background: none; color: var(--muted-foreground);
  font-size: 12.5px; cursor: pointer; border-radius: 6px; text-align: left;
}
.ch-vrow:hover { background: var(--bg-tertiary, rgba(255,255,255,.06)); color: var(--foreground); }
.ch-vrow img, .ch-vrow .ch-vdot { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }
.ch-vdot { background: var(--accent); display: inline-block; }
.ch-vmute { font-size: 11px; }

/* пикер источника стрима (свой, без системных диалогов) */
.src-pick { display: flex; flex-direction: column; gap: 6px; min-width: 380px; max-height: 60vh; overflow-y: auto; }
.src-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 0.875rem; text-align: left; cursor: pointer;
}
.src-row:hover { background: var(--surface-hover); }
.src-row.primary { border-color: rgba(var(--accent-rgb), 0.4); }
.src-row .src-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* входящий ЛС-звонок */
.incoming-call { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 260px; }
.incoming-call .ic-av { width: 76px; height: 76px; border-radius: 50%; border: 2px solid rgba(var(--accent-rgb), 0.5); }
.incoming-call .ic-name { font-weight: 700; font-size: 1.05rem; }
.incoming-call .ic-actions { display: flex; gap: 10px; margin-top: 10px; width: 100%; }
.incoming-call .ic-actions button { flex: 1; }

/* сетка источников стрима с превью (как в Discord) */
.src-pick { display: flex; flex-direction: column; gap: 8px; min-width: 440px; max-width: 640px; max-height: 62vh; overflow-y: auto; }
.src-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.src-tile {
  display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-primary); cursor: pointer; text-align: left;
}
.src-tile:hover { background: var(--surface-hover); border-color: rgba(var(--accent-rgb), 0.5); }
.src-tile.primary { border-color: rgba(var(--accent-rgb), 0.55); }
.src-thumb {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16 / 9; overflow: hidden; border-radius: 4px; background: #000;
}
.src-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.src-tile .src-title { font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.create-ch { display: flex; flex-direction: column; gap: 10px; min-width: 320px; }

/* canvas стрима: размеры от контейнера во ВСЕХ местах (theater/сцена/попап);
   раньше правила были для <video>, и canvas оставался без размеров — кадры
   рисовались, а зритель видел чёрный прямоугольник */
#stream-video-holder { width: 100%; height: 100%; min-height: 0; }
#stream-video {
  display: block; width: 100%; height: 100%;
  object-fit: contain; background: #000;
}
.vv-card.vv-stream .ss-video #stream-video-holder,
.vt-card.vt-stream .ss-video #stream-video-holder { width: 100%; height: 100%; }
/* полноэкранная демка */
.ss-fs {
  position: fixed !important; inset: 0; z-index: 200 !important;
  margin: 0 !important; border-radius: 0 !important; background: #000;
}
.ss-fs #stream-video { object-fit: contain; }
/* превью своего стрима внутри контейнера */
#stage-preview { width: 100%; height: 100%; min-height: 0; display: block; }
#stage-preview img, #stage-preview video {
  width: 100%; height: 100%; object-fit: contain; display: block; background: #000;
}

/* о приложении (версия/обновления) в настройках */
.set-about { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.set-about .about-row { display: flex; align-items: baseline; gap: 6px; }

/* контекстное меню громкости участника */
.vol-menu {
  position: fixed; z-index: 300; width: 210px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-secondary); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-panel);
}
.vol-menu .vm-name { font-weight: 700; font-size: 0.85rem; }
.vol-menu .vm-row { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); }
.vol-menu input[type='range'] { width: 100%; }
.vol-menu .vm-mute { font-size: 0.82rem; }
.ss-quality { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; }

/* ── кастомный топбар окна (exe) ── */
.app-tb {
  position: fixed; inset: 0 0 auto 0; height: 36px; z-index: 500;
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 12px;
  /* SOLID: непрозрачный фон; тень убрана — в тёмной теме выглядела грязным
     пятном под полосой */
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  isolation: isolate;
  user-select: none; -webkit-user-select: none;
}
.app-tb[hidden] { display: none; }
.tb-brand { font-weight: 700; font-size: 0.8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.tb-actions { display: flex; align-items: stretch; height: 100%; }
.tb-btn {
  width: 44px; border: none; background: transparent; color: var(--foreground);
  font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.tb-btn:hover { background: var(--surface-hover, rgba(255,255,255,.07)); }
.tb-x:hover { background: #c0392b; color: #fff; }
.tb-upd {
  width: auto; padding: 0 12px; gap: 6px; font-size: 0.78rem; font-weight: 600;
  background: var(--accent); color: #14100f;
}
.tb-upd:hover { filter: brightness(1.1); }
body.has-tb .auth-gate { top: 36px; }
/* тосты и настройки не должны залезать ПОД топбар */
body.has-tb #toasts { top: 50px; }
body.has-tb #settings-ov { top: 36px; }
/* окно без системной рамки: топбар занимает свои 36px, приложение — остаток
   высоты. Раньше padding-top на main при height:100% обрезал низ и «сдвигал»
   раскладку — теперь сжимаем сам контейнер. */
body.has-tb { padding-top: 36px; box-sizing: border-box; }
body.has-tb main#app { height: 100%; min-height: 0; }
body.has-tb .auth-gate { top: 36px; }

/* ════════════════════════════════════════════════
   ПРОФИЛЬ: display name, свой статус, уведомления
   ════════════════════════════════════════════════ */
.pp-handle, .up-handle, .acc-handle {
  font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono);
}
.pp-custom {
  margin: -2px 4px 8px; padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--surface-input); border: 1px solid var(--border);
  font-size: 0.78rem; color: var(--text-secondary); overflow-wrap: anywhere;
}
.up-custom {
  max-width: 300px; font-size: 0.82rem; color: var(--text-secondary);
  overflow-wrap: anywhere;
}
/* строка участника: имя + статус под ним, роль/кик прижаты вправо */
.member-row .mr-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.member-row .mr-sub {
  font-size: 0.68rem; line-height: 1.25; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.member-row .mr-role { margin-left: auto; }
.notify-list { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.st-ic { width: 1.1em; text-align: center; opacity: 0.85; }

/* ════════════════════════════════════════════════
   ПЛАВНОСТЬ: настройки, сообщения, композер, действия
   ════════════════════════════════════════════════ */
/* Стиль анимаций (Настройки → Интерфейс): slide | fade | pop.
   Класс .anim-in — единая точка входа для сообщений, страниц настроек,
   модалок и поповеров. */
.anim-in {
  animation-duration: calc(0.22s * var(--anim-scale));
  animation-timing-function: var(--ease);
  animation-fill-mode: both;
}
html[data-anim-style='slide'] .anim-in { animation-name: kf-anim-slide; }
html[data-anim-style='fade'] .anim-in { animation-name: kf-anim-fade; }
html[data-anim-style='pop'] .anim-in { animation-name: kf-anim-pop; }
@keyframes kf-anim-slide {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes kf-anim-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kf-anim-pop {
  from { opacity: 0; transform: scale(0.965); }
  to   { opacity: 1; transform: none; }
}
/* сообщения «выезжают» сбоку — заметнее, чем сдвиг по вертикали */
html[data-anim-style='slide'] .msg.anim-in { animation-name: kf-anim-slide-x; }
@keyframes kf-anim-slide-x {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}
/* смена вкладки настроек */
.set-nav-btn { transition: background calc(0.15s * var(--anim-scale)) var(--ease), color calc(0.15s * var(--anim-scale)) var(--ease), border-color calc(0.15s * var(--anim-scale)) var(--ease); }

/* поле ввода растёт плавно (никаких скачков высоты при переносе строки) */
#msg-input { transition: height calc(0.12s * var(--anim-scale)) var(--ease); }

/* ── Плавный текстовый курсор композера ──────────────────────────
   Нативный каретка мигает и «телепортируется» по строке. Рисуем свою:
   позиция считается зеркальным div'ом, движение — CSS-transform. */
.chat-input { position: relative; }
#msg-input.custom-caret { caret-color: transparent; }
.msg-caret {
  position: absolute;
  left: 0; top: 0;
  width: 2px;
  border-radius: 1px;
  background: var(--text-primary);
  pointer-events: none;
  opacity: 1;
  will-change: transform;
  transition: transform calc(0.09s * var(--anim-scale)) var(--ease), height calc(0.09s * var(--anim-scale)) var(--ease), opacity 0.15s linear;
  animation: caret-blink 1.06s steps(1, end) infinite;
}
.msg-caret.typing { animation: none; opacity: 1; }
.msg-caret[hidden] { display: none; }
@keyframes caret-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* компактные действия у сообщения: иконки не должны быть «больше» сообщения */
.msg-actions { align-items: center; }
.msg-actions .icon-btn {
  width: 24px; height: 24px; font-size: 0.72rem; border-radius: 6px;
}

/* панель инлайн-редактирования над композером */
.edit-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  padding: 6px 8px 6px 12px;
  border-radius: var(--r-sm);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-left: 3px solid var(--accent);
  font-size: 0.78rem;
  color: var(--text-secondary);
  animation: edit-bar-in calc(0.16s * var(--anim-scale)) var(--ease);
}
@keyframes edit-bar-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.edit-bar[hidden] { display: none !important; }
.edit-bar .eb-ic { color: var(--accent); font-size: 0.95rem; }
.edit-bar .eb-hint { margin-left: auto; font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-muted); }
.edit-bar .icon-btn { width: 24px; height: 24px; font-size: 0.7rem; }

/* кнопки «на весь экран» (⛶) скрыты, пока не включены в настройках → Интерфейс */
body:not(.fs-buttons) #tb-fs,
body:not(.fs-buttons) #stream-full,
body:not(.fs-buttons) .ss-fs-btn { display: none !important; }

/* ── Действия у сообщения: SVG-иконки по центру, панель с тенью ── */
/* «Продолжение» (cont) ниже обычного сообщения (padding-top: 1px), поэтому
   top:4px вылезал за hover-подсветку — такие строки центрируем по вертикали. */
.msg-actions { top: 4px; }
.msg.cont .msg-actions { top: 50%; transform: translateY(-50%); }
.msg-actions .icon-btn { display: grid; place-items: center; padding: 0; line-height: 1; }
.msg-actions .icon-btn svg { display: block; pointer-events: none; }
.msg-actions .icon-btn:hover svg { color: var(--accent); }

/* ── Настройки v2: карточки и тумблеры вместо галочек ── */
.set-page { gap: 12px; }
.set-page > .field {
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.set-page > .field > label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.set-card {
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.set-section-title {
  margin: 6px 2px -2px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.set-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.set-row:hover { background: var(--surface-hover); }
.notify-card .set-row + .set-row { border-top: 1px solid var(--border); }
.sr-text { flex: 1; min-width: 0; }
.sr-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.sr-ic { font-size: 0.95rem; opacity: 0.9; }
.sr-desc { margin-top: 3px; font-size: 0.73rem; line-height: 1.35; color: var(--text-muted); }
.switch { position: relative; flex: none; width: 40px; height: 22px; }
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.switch-knob {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-hover);
  border: 1px solid var(--border-strong);
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.switch-knob::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}
.switch input:checked + .switch-knob {
  background: rgba(var(--accent-rgb), 0.28);
  border-color: var(--accent);
}
.switch input:checked + .switch-knob::after {
  transform: translateX(18px);
  background: var(--accent);
}
.switch input:focus-visible + .switch-knob {
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.22);
}
.switch input:disabled + .switch-knob { opacity: 0.4; }
.set-row:has(input:disabled) { cursor: default; opacity: 0.55; }

/* ── Плавное выделение текста в чате (Ctrl+A / перетаскивание) ── */
/* В чате user-select:none (чтобы не выделялось при скролле), но текст сообщений
   должен выделяться и копироваться — иначе Ctrl+A даёт пустое выделение. */
#chat-scroll .msg,
#chat-scroll .msg * { user-select: text; -webkit-user-select: text; }
.soft-sel-layer { position: fixed; inset: 0; pointer-events: none; z-index: 55; }
.soft-sel-rect {
  position: absolute;
  background: rgba(var(--accent-rgb), 0.4);
  border-radius: 3px;
  transform-origin: left center;
  will-change: transform, opacity;
  transition: left 0.1s linear, top 0.1s linear, width 0.1s linear, height 0.1s linear;
}
/* световой «скан» сверху вниз — продаёт эффект плавности */
.soft-sel-sweep {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(180deg, transparent, rgba(var(--accent-rgb), 0.22), transparent);
  filter: blur(2px);
  pointer-events: none;
  opacity: 0;
}
#chat-scroll.soft-selecting ::selection { background: transparent; }
#msg-input.soft-selecting::selection { background: transparent; }
html[data-anim='off'] .soft-sel-rect { animation: none; }
@media (prefers-reduced-motion: reduce) { .soft-sel-rect { animation: none; } }

/* ── Индикатор нагрузки: правый сайдбар участников, полоски ЦП/ОЗУ ──────────── */
#perf-chip {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: none;
  pointer-events: none;
  user-select: none;
}
/* обёртка в сайдбаре прижимает чип к низу панели участников */
#members-perf { margin-top: auto; padding-top: 10px; }
/* fixed-режим: панель участников скрыта (дом/ЛС) — чип-пилюля в правом нижнем углу */
#perf-chip.fixed-mode {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: 184px;
  margin-top: 0;
  z-index: 200;
  background: rgba(12, 8, 10, 0.78);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm);
}
html[data-theme='light'] #perf-chip.fixed-mode { background: rgba(255, 252, 253, 0.85); }
#perf-chip .perf-head { font-family: var(--font-mono); font-size: 0.625rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; }
html[data-theme='light'] #perf-chip { background: rgba(255, 252, 253, 0.85); }
#perf-chip .perf-row { display: flex; align-items: center; gap: 6px; }
#perf-chip .perf-lbl { width: 26px; flex: 0 0 auto; font-weight: 600; color: var(--text-muted); letter-spacing: 0.02em; }
#perf-chip .perf-bar {
  flex: 1 1 auto; height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--surface-input);
}
#perf-chip .perf-fill {
  display: block; height: 100%; width: 0%;
  border-radius: 3px; background: var(--ok);
  transition: width 0.5s var(--ease, ease), background 0.5s;
}
#perf-chip .perf-val { width: 52px; flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
#perf-chip .perf-joke { font-size: 9px; opacity: 0.65; font-style: italic; text-align: right; margin-top: 1px; }

/* ── Экран отключения: ASCII-волна «сигнал угасает» + карточка ────────────── */
#conn-lost {
  position: fixed;
  inset: 0;
  z-index: 900;
  /* радиальная виньетка + базовое затемнение — «мертвый ЭЛТ» */
  background:
    radial-gradient(ellipse at center, rgba(20, 8, 12, 0.82) 0%, rgba(6, 4, 5, 0.96) 100%);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
#conn-lost.hidden { display: none; }
/* ASCII-волна: нижняя половина экрана, живая анимация (перерисовка из JS);
   градиент цвета через background-clip:text — волна «гаснет» к правому краю */
#conn-lost .cl-wave {
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  margin: 0;
  z-index: 0;
  font-family: 'Cascadia Mono', 'Consolas', 'Courier New', monospace;
  font-size: 16px;
  line-height: 16px;
  letter-spacing: 0;             /* моно-шаг ~9.6px = 0.6em — под расчёт cols в JS */
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  color: transparent;
  background: linear-gradient(90deg,
    var(--accent) 0%, var(--accent) 38%,
    rgba(var(--accent-rgb), 0.4) 70%,
    rgba(var(--accent-rgb), 0.05) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 16px rgba(var(--accent-rgb), 0.3));
}
/* карточка: верхняя зона, тонкое стекло (миганий нет — статичное стекло) */
#conn-lost .cl-card {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 44px 24px;
  background: rgba(10, 6, 9, 0.55);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  max-width: calc(100% - 40px);
}
#conn-lost .cl-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.42em;
  text-indent: 0.42em; /* компенсация хвостового letter-spacing */
  color: var(--text-primary);
  text-shadow: 0 0 18px rgba(var(--accent-rgb), 0.45);
  user-select: none;
  white-space: nowrap;
}
#conn-lost .cl-status {
  font-size: 12.5px;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}
#conn-lost .cl-dots span { opacity: 0.15; }
#conn-lost .cl-info {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Cascadia Mono', 'Consolas', monospace;
  letter-spacing: 0.03em;
}
#conn-lost .cl-retry {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-primary);
  background: var(--surface-input);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 8px 20px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
#conn-lost .cl-retry:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}
#conn-lost .cl-retry:active { transform: scale(0.97); }
#conn-lost .cl-retry-ic { font-size: 14px; color: var(--accent); }

/* ════════════════════════════════════════════════════════════════════════
   МАРКЕТ: карточки стилей + темы оформления (data-style на <html>)
   ════════════════════════════════════════════════════════════════════════ */
.style-grid {
  display: grid; gap: 14px; margin-top: 6px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.style-card {
  border: 1px solid var(--border); border-radius: var(--r-panel);
  background: var(--surface-solid); overflow: hidden; cursor: pointer;
  transition: border-color .15s, transform .12s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.style-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-panel); }
.style-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-panel); }
.style-prev {
  height: 92px; display: flex; align-items: center; justify-content: center;
  position: relative;
}
.style-ic { font-size: 38px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.5)); }
.style-body { padding: 12px 14px 6px; }
.style-name { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.style-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.45; }
.style-state {
  padding: 8px 14px 12px; font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
}
.style-card.active .style-state { color: var(--accent); }

/* ── ASCII / Терминал: зелёный фосфор, моноширина, сканлайны ─────────────── */
html[data-style="ascii"] {
  --bg-primary: #020a04;
  --bg-secondary: #05140a;
  --bg-tertiary: #0a2014;
  --surface: rgba(5, 20, 10, 0.85);
  --surface-solid: #05140a;
  --surface-input: rgba(51, 255, 102, 0.06);
  --surface-hover: rgba(51, 255, 102, 0.12);
  --border: rgba(51, 255, 102, 0.26);
  --border-strong: rgba(51, 255, 102, 0.5);
  --text-primary: #c9ffd8;
  --text-secondary: #8fe8a8;
  --text-muted: #4f9968;
  --accent: #33ff66;
  --accent-hover: #5cff85;
  --accent-deep: #1a8038;
  --accent-rgb: 51, 255, 102;
  --r-sm: 0; --r-md: 0; --r-panel: 0;
  --shadow-sm: none;
  --shadow-panel: 0 0 28px rgba(51, 255, 102, 0.14);
}
html[data-style="ascii"] body,
html[data-style="ascii"] input,
html[data-style="ascii"] textarea,
html[data-style="ascii"] button,
html[data-style="ascii"] .vv-name,
html[data-style="ascii"] .msg-text {
  font-family: 'Cascadia Mono', 'Consolas', 'Courier New', monospace !important;
}
/* фосфорное свечение */
html[data-style="ascii"] b,
html[data-style="ascii"] strong,
html[data-style="ascii"] .accent { text-shadow: 0 0 8px rgba(51, 255, 102, 0.55); }
html[data-style="ascii"] .srv-dot.active,
html[data-style="ascii"] .nav-btn.active { box-shadow: 0 0 12px rgba(51, 255, 102, 0.5); }
/* сканлайны поверх всего приложения */
html[data-style="ascii"] body::after {
  content: ''; position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.16) 2px 4px);
  opacity: 0.55;
}

/* ── Пиксель / Low-poly: Postal, Voices of the Void, Garry's Mod ──────────── */
html[data-style="pixel"] {
  --bg-primary: #0f0e17;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #232946;
  --surface: rgba(26, 26, 46, 0.92);
  --surface-solid: #1a1a2e;
  --surface-input: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 107, 53, 0.16);
  --border: #2d2d44;
  --border-strong: #ff6b35;
  --text-primary: #fffffe;
  --text-secondary: #e6e6f0;
  --text-muted: #9a9ab0;
  --accent: #ff6b35;
  --accent-hover: #ff8559;
  --accent-deep: #b8431c;
  --accent-rgb: 255, 107, 53;
  --r-sm: 0; --r-md: 0; --r-panel: 0;   /* острые углы — пиксель-арт */
  --shadow-sm: 3px 3px 0 rgba(0, 0, 0, 0.55);
  --shadow-panel: 6px 6px 0 rgba(0, 0, 0, 0.5);
}
/* всё квадратное, аватары пиксельные */
html[data-style="pixel"] .vv-card,
html[data-style="pixel"] .set-card,
html[data-style="pixel"] .style-card,
html[data-style="pixel"] .nav-btn,
html[data-style="pixel"] .msg-row,
html[data-style="pixel"] button,
html[data-style="pixel"] input,
html[data-style="pixel"] textarea,
html[data-style="pixel"] .panel,
html[data-style="pixel"] .toast { border-radius: 0 !important; }
html[data-style="pixel"] .srv-dot { border-radius: 0 !important; }
html[data-style="pixel"] .srv-dot.active { box-shadow: 0 0 0 3px var(--accent); }
html[data-style="pixel"] img { image-rendering: pixelated; }
/* жирная пиксельная обводка панелей */
html[data-style="pixel"] .set-card,
html[data-style="pixel"] .style-card,
html[data-style="pixel"] .vv-card { border-width: 2px; border-style: solid; }
/* заголовки — uppercase, как в ретро-играх */
html[data-style="pixel"] .style-name,
html[data-style="pixel"] .vt-title b,
html[data-style="pixel"] .chat-head h2 { text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Аниме / Сакура: мягкие градиенты, розово-лавандовая палитра ──────────── */
html[data-style="anime"] {
  --bg-primary: #1a1025;
  --bg-secondary: #241536;
  --bg-tertiary: #2e1b45;
  --surface: rgba(46, 27, 69, 0.72);
  --surface-solid: #241536;
  --surface-input: rgba(255, 126, 185, 0.08);
  --surface-hover: rgba(255, 126, 185, 0.16);
  --border: rgba(255, 158, 200, 0.2);
  --border-strong: rgba(255, 158, 200, 0.45);
  --text-primary: #ffeef6;
  --text-secondary: #f0d6e6;
  --text-muted: #b79cc7;
  --accent: #ff7eb9;
  --accent-hover: #ff9ecb;
  --accent-deep: #c44f88;
  --accent-rgb: 255, 126, 185;
  --r-sm: 8px; --r-md: 12px; --r-panel: 18px;   /* мягкие скругления */
  --shadow-sm: 0 4px 16px rgba(255, 126, 185, 0.14);
  --shadow-panel: 0 10px 40px rgba(120, 60, 160, 0.4);
}
/* градиентный фон всей app + лавандовое свечение */
/* обои аниме-темы: сгенерированный арт под тёмной вуалью (читаемость текста);
   базовый градиент — последний слой (fallback, если ассет недоступен) */
html[data-style="anime"] body {
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(255, 126, 185, 0.14), transparent 60%),
    radial-gradient(1000px 600px at 110% 20%, rgba(167, 139, 250, 0.14), transparent 55%),
    linear-gradient(rgba(20, 10, 32, 0.74), rgba(20, 10, 32, 0.82)),
    url('assets/anime-wall.webp') center / cover no-repeat fixed,
    linear-gradient(160deg, #1a1025 0%, #26173a 55%, #1c1130 100%);
}
/* мягкое свечение акцентов */
html[data-style="anime"] .srv-dot.active,
html[data-style="anime"] .nav-btn.active { box-shadow: 0 0 18px rgba(255, 126, 185, 0.45); }
html[data-style="anime"] b,
html[data-style="anime"] strong { text-shadow: 0 0 10px rgba(255, 126, 185, 0.35); }
/* полупрозрачные «стеклянные» панели */
html[data-style="anime"] .set-card,
html[data-style="anime"] .style-card,
html[data-style="anime"] .vv-card { backdrop-filter: blur(8px); }
/* лёгкий узор лепестков сакуры поверх фона (ненавязчиво) */
html[data-style="anime"] body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,182,213,0.05) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgba(255,182,213,0.04) 0 2px, transparent 3px),
    radial-gradient(circle at 45% 85%, rgba(255,182,213,0.05) 0 2px, transparent 3px);
  background-size: 220px 220px, 300px 300px, 260px 260px;
  opacity: 0.7;
}
/* контент приложения — над фоновым узором */
html[data-style="anime"] #app,
html[data-style="anime"] main { position: relative; z-index: 1; }

/* ════════════════════════════════════════════════
   ТЕЛЕФОН — html.m-shell (≤760px + сенсор; класс ставит mobile.js).
   Один экран за раз: рейл скрыт, сайдбар и участники — шторки поверх
   чата, чат во всю ширину. Без mobile.js ничего не меняется.
   Blur'ы сняты: Safari на айфонах считает их на порядок дороже десктопа.
   ════════════════════════════════════════════════ */
.m-only { display: none; } /* вне телефона кнопки-гамбургеры не существуют */

@media (max-width: 760px) and (pointer: coarse) {
  html.m-shell { overflow-x: clip; }
  html.m-shell #app { grid-template-columns: minmax(0, 1fr); }
  html.m-shell .rail { display: none; }

  /* шторки */
  html.m-shell .sidebar,
  html.m-shell .members {
    animation: none; /* rise-in на телефоне вспыхнул бы поверх чата при каждом входе */
  }
  html.m-shell .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(78vw, 320px);
    z-index: 80;
    transform: translateX(-103%);
    transition: transform calc(0.22s * var(--anim-scale)) var(--ease);
  }
  html.m-shell .members {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(72vw, 300px);
    z-index: 80;
    transform: translateX(103%);
    transition: transform calc(0.22s * var(--anim-scale)) var(--ease);
  }
  html.m-shell body.m-drawer-open .sidebar,
  html.m-shell body.m-members-open .members { transform: none; }
  html.m-shell .m-scrim {
    position: fixed;
    inset: 0;
    z-index: 79;
    background: rgba(5, 3, 4, 0.52);
    animation: none;
  }

  /* гамбургер и кнопка участников — только на телефоне */
  html.m-shell .m-only { display: grid; place-items: center; width: 34px; height: 34px; font-size: 1.05rem; }

  /* шапка чата: safe-area сверху, гамбургер слева, участники справа */
  html.m-shell .chat-head {
    padding: max(10px, env(safe-area-inset-top)) 10px 10px 6px;
    min-height: calc(58px + env(safe-area-inset-top));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  html.m-shell .chat-head .h-desc { display: none; }
  html.m-shell .chat-head .call-btn { font-size: 0.75rem; padding: 6px 10px; }

  /* дорогие blur'ы — долой на телефоне (панели, лайтбокс, оверлеи) */
  html.m-shell .panel,
  html.m-shell .lightbox,
  html.m-shell .modal-back,
  html.m-shell #settings-ov,
  html.m-shell #voice-view {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* ввод: 16px против авто-зума iOS, палец-friendly высота, safe-area снизу */
  html.m-shell .chat-input textarea { font-size: 16px; padding: 8px 4px; }
  html.m-shell .chat-input { padding: 8px; }
  html.m-shell .chat-input-wrap { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  html.m-shell .chat-hint { display: none; }

  /* баннер реконнекта — над thumb-зоной */
  html.m-shell #conn-banner { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }

  /* голосовая капсула живёт в шторке сайдбара: не толще шторки */
  html.m-shell .voice-cap { margin: 6px; flex-wrap: wrap; }
  html.m-shell .voice-cap .vc-info { flex-basis: 100%; }

  /* просмотр голоса/стрима: карточки не мельче 132px, главный не гигант */
  html.m-shell .vv-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
  html.m-shell .vv-user.vv-main { min-height: 220px; }
  html.m-shell .vv-user.vv-main .vv-av { width: 120px; height: 120px; }
}

