/* ============================================================
   KRAZZ — dark navy / deep emerald design system
   ============================================================ */
:root {
  --accent-rgb: 11, 138, 106;
  --bg: #050b17;
  --bg-2: #071326;
  --bg-3: #0a1a30;
  --panel: rgba(10, 22, 41, 0.82);
  --panel-solid: #0b172b;
  --line: rgba(64, 98, 150, 0.22);
  --line-strong: rgba(80, 120, 180, 0.38);
  --text: #e9f1ff;
  --muted: #90a7c9;
  --dim: #607a9f;
  --emerald: #0b8a6a;
  --emerald-bright: #23b08c;
  --emerald-deep: #065a48;
  --emerald-soft: rgba(11, 138, 106, 0.14);
  --emerald-glow: rgba(11, 138, 106, 0.32);
  --danger: #ff6b81;
  --danger-soft: rgba(255, 107, 129, 0.12);
  --warn: #f3b562;
  --violet: #a78bfa;
  --blue: #6cb8ff;
  --radius: 14px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Consolas, monospace;
}

/* Тёмно-фиолетовая тема: те же компоненты, другой акцент и фон. */
html[data-theme="violet"] {
  --accent-rgb: 139, 92, 246;
  --bg: #080512;
  --bg-2: #0d0819;
  --bg-3: #140c24;
  --panel: rgba(19, 12, 34, 0.84);
  --panel-solid: #120b22;
  --line: rgba(139, 92, 246, 0.18);
  --line-strong: rgba(167, 139, 250, 0.36);
  --emerald: #8b5cf6;
  --emerald-bright: #c4b5fd;
  --emerald-deep: #5b21b6;
  --emerald-soft: rgba(139, 92, 246, 0.14);
  --emerald-glow: rgba(139, 92, 246, 0.34);
  --violet: #c4b5fd;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 8% -8%, rgba(var(--accent-rgb), 0.13), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(56, 110, 255, 0.12), transparent 55%),
    radial-gradient(700px 700px at 50% 120%, rgba(9, 60, 90, 0.35), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
body.auth-body { overflow: auto; }

button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--emerald); text-decoration: none; }
a:hover { color: var(--emerald-bright); }
input, textarea, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(70, 100, 150, 0.35); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(90, 130, 180, 0.5); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- auth ---------------- */
.auth-body {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100%;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 40px 24px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.auth-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(80, 120, 180, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 120, 180, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 78%);
  pointer-events: none;
  z-index: 0;
}
.auth-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 56px;
  align-items: center;
}
.auth-brand { padding: 12px 0; }
.brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 40px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px; color: #04140f;
  background: linear-gradient(145deg, var(--emerald-bright), var(--emerald) 55%, var(--emerald-deep));
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.35), 0 18px 40px -12px var(--emerald-glow);
}
.brand-name { font-weight: 700; letter-spacing: 0.32em; font-size: 14px; }
.brand-tag { color: var(--dim); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; margin-top: 3px; }
.auth-brand h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 700;
}
.auth-brand h1 span {
  background: linear-gradient(100deg, var(--emerald-bright), #7ff0d2 40%, #4ba8ff 110%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { color: var(--muted); max-width: 480px; font-size: 16px; line-height: 1.65; margin: 0 0 30px; }
.feature-list { list-style: none; margin: 28px 0 32px; padding: 0; display: grid; gap: 12px; }
.feature-list li { display: flex; gap: 12px; align-items: baseline; color: #b9cbe6; font-size: 14.5px; }
.feature-list i { color: var(--emerald); font-style: normal; font-size: 10px; transform: translateY(-2px); }
.brand-foot { color: var(--dim); font-size: 12px; display: flex; align-items: center; gap: 8px; letter-spacing: 0.04em; }

.equalizer { display: flex; align-items: flex-end; gap: 4px; height: 44px; margin: 26px 0 0; opacity: 0.9; }
.equalizer span {
  width: 4px; border-radius: 3px;
  background: linear-gradient(180deg, var(--emerald-bright), rgba(var(--accent-rgb), 0.15));
  animation: eq 1.6s ease-in-out infinite;
  height: 20%;
}
.equalizer span:nth-child(3n) { animation-duration: 1.1s; }
.equalizer span:nth-child(3n+1) { animation-duration: 2.1s; }
.equalizer span:nth-child(4n) { animation-duration: 1.35s; }
.equalizer span:nth-child(5n) { animation-duration: 2.6s; }
@keyframes eq {
  0%, 100% { height: 14%; opacity: 0.45; }
  50% { height: 92%; opacity: 1; }
}

.auth-card {
  background: linear-gradient(180deg, rgba(16, 31, 55, 0.9), rgba(9, 19, 36, 0.92));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 32px 26px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
}
.auth-card-head h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.auth-card-head p { margin: 0 0 24px; color: var(--dim); font-size: 13.5px; }
.auth-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 4px; margin-bottom: 22px;
  background: rgba(5, 12, 24, 0.7); border: 1px solid var(--line); border-radius: 12px;
}
.auth-tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 9px 6px; border-radius: 9px; font-size: 13px; font-weight: 500;
  transition: 0.18s ease;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.is-active { background: var(--emerald-soft); color: var(--emerald-bright); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.28); }

.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 7px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.auth-form input {
  background: rgba(4, 10, 20, 0.65);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 14.5px;
  color: var(--text);
  outline: none;
  transition: 0.18s ease;
}
.auth-form input::placeholder { color: #45597a; }
.auth-form input:focus { border-color: rgba(var(--accent-rgb), 0.55); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12); }
.form-hint { color: var(--dim); font-size: 13px; margin: 0 0 2px; line-height: 1.55; }
.btn-primary {
  margin-top: 4px;
  border: 0; border-radius: 11px;
  padding: 13px 18px;
  background: linear-gradient(180deg, var(--emerald-bright), var(--emerald));
  color: #04140f; font-weight: 700; font-size: 14.5px;
  box-shadow: 0 14px 28px -12px var(--emerald-glow);
  transition: 0.18s ease;
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; transform: none; cursor: progress; }
.btn-ghost {
  width: 100%;
  background: transparent; border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 11px; padding: 12px 16px; font-size: 13.5px; font-weight: 500;
  transition: 0.18s ease;
}
.btn-ghost:hover { border-color: rgba(var(--accent-rgb), 0.5); color: var(--emerald-bright); background: rgba(var(--accent-rgb), 0.06); }
.auth-msg { margin: 16px 0 0; font-size: 13px; padding: 11px 13px; border-radius: 10px; background: var(--danger-soft); color: #ffb3be; border: 1px solid rgba(255, 107, 129, 0.25); }
.auth-msg.is-ok { background: var(--emerald-soft); color: var(--emerald-bright); border-color: rgba(var(--accent-rgb), 0.3); }
.dev-link { margin-top: 10px; font-size: 12px; color: var(--muted); word-break: break-all; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.dev-link a { font-family: var(--mono); font-size: 11.5px; }
.auth-sep { display: flex; align-items: center; gap: 12px; margin: 22px 0 16px; color: var(--dim); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-fine { margin: 16px 0 0; color: #4d6283; font-size: 11px; text-align: center; line-height: 1.5; }

.form-error { background: var(--danger-soft); border: 1px solid rgba(255, 107, 129, 0.25); color: #ffb3be; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.auth-foot { color: var(--dim); font-size: 13px; margin-top: 18px; }

/* ---------------- app shell ---------------- */
.app {
  display: grid;
  grid-template-columns: 72px 264px minmax(0, 1fr) 244px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

/* rail */
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 16px 0 14px;
  background: rgba(4, 9, 19, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.rail-logo {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  font-weight: 800; color: #04140f;
  background: linear-gradient(145deg, var(--emerald-bright), var(--emerald));
  box-shadow: 0 10px 24px -10px var(--emerald-glow);
  margin-bottom: 4px;
}
.rail-sep { width: 26px; height: 1px; background: var(--line); }
.rail-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid transparent; background: transparent; color: var(--dim);
  display: grid; place-items: center;
  transition: 0.18s ease;
}
.rail-btn:hover { color: var(--text); background: rgba(90, 130, 180, 0.1); }
.rail-btn.is-active { color: var(--emerald-bright); background: var(--emerald-soft); border-color: rgba(var(--accent-rgb), 0.22); }
.rail-grow { flex: 1; }
.rail-avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: 0; color: #dce8f7;
  background: linear-gradient(145deg, #2a3f55, #172536);
  border: 1px solid rgba(120, 150, 190, 0.28);
  overflow: hidden;
}

/* sidebar */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  z-index: 20;
}
.server-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.server-head-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.back-btn { width: 32px; height: 32px; margin-left: -6px; }
.members-title { display: flex; align-items: center; gap: 6px; }
.server-name { font-weight: 700; letter-spacing: 0.2em; font-size: 12.5px; }
.server-sub { color: var(--dim); font-size: 11px; display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 0 var(--emerald-glow); animation: pulse 2.4s infinite; }
.pulse-dot.small { width: 6px; height: 6px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: 0.16s ease; flex: none;
}
.icon-btn:hover { background: rgba(90, 130, 180, 0.12); color: var(--text); }
.icon-btn.is-on { color: var(--emerald-bright); background: var(--emerald-soft); border-color: rgba(var(--accent-rgb), 0.25); }
.channels-scroll { flex: 1; overflow-y: auto; padding: 14px 10px 20px; }
.chan-group { margin-bottom: 22px; }
.chan-label {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--dim); padding: 0 8px 8px;
}
.chan-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 9px;
  color: var(--muted); font-size: 14px; cursor: pointer;
  border: 1px solid transparent;
  transition: 0.14s ease;
  width: 100%; background: transparent; text-align: left;
}
.chan-row:hover { background: rgba(90, 130, 180, 0.1); color: var(--text); }
.chan-row.is-active { background: var(--emerald-soft); border-color: rgba(var(--accent-rgb), 0.2); color: var(--emerald-bright); }
.chan-row .chan-ico { width: 18px; height: 18px; color: currentColor; opacity: 0.75; flex: none; }
.chan-row .chan-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-row .chan-count {
  font-size: 10.5px; color: var(--emerald-bright); background: rgba(var(--accent-rgb), 0.14);
  padding: 1px 6px; border-radius: 20px; border: 1px solid rgba(var(--accent-rgb), 0.2);
}
.voice-avatars { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 9px 2px 36px; }
.mini-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 9px; font-weight: 600; letter-spacing: 0;
  color: #dce8f7; border: 1px solid rgba(0, 0, 0, 0.25); overflow: hidden;
}
.add-channel {
  width: 100%; margin: 4px 0 0; padding: 9px; border-radius: 9px;
  border: 1px dashed var(--line-strong); background: transparent; color: var(--dim); font-size: 12.5px;
}
.add-channel:hover { color: var(--emerald-bright); border-color: rgba(var(--accent-rgb), 0.4); }

.me-bar {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(4, 10, 20, 0.55);
}
.me-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 11.5px; letter-spacing: 0; color: #dce8f7;
  background: linear-gradient(145deg, #2a3f55, #172536);
  overflow: hidden;
}
.me-info { flex: 1; min-width: 0; }
.me-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 10.5px; color: var(--dim); }
.me-btn {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  border: 1px solid transparent; background: transparent; color: var(--muted); flex: none;
}
.me-btn:hover { background: rgba(90, 130, 180, 0.12); color: var(--text); }
.me-btn svg { width: 18px; height: 18px; }
.me-btn.is-off { color: var(--danger); }
.me-btn.is-off:hover { background: var(--danger-soft); }

/* main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar {
  height: 62px; flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 14, 27, 0.55);
  backdrop-filter: blur(10px);
}
.channel-head { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.chan-hash { color: var(--emerald); font-weight: 600; font-size: 20px; }
.channel-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.chan-topic { color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; padding-left: 6px; border-left: 1px solid var(--line); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.codec-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  color: var(--muted); background: rgba(var(--accent-rgb), 0.07);
  border: 1px solid rgba(var(--accent-rgb), 0.18); border-radius: 20px; padding: 4px 10px;
  white-space: nowrap;
}
.codec-badge i { width: 5px; height: 5px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 6px var(--emerald); }
.codec-badge.is-live { color: var(--emerald-bright); border-color: rgba(var(--accent-rgb), 0.4); }
.btn-soft {
  border: 1px solid var(--line-strong); background: rgba(90, 130, 180, 0.08);
  color: var(--text); border-radius: 9px; padding: 7px 12px; font-size: 12.5px;
}
.btn-soft:hover { border-color: rgba(var(--accent-rgb), 0.45); color: var(--emerald-bright); }
.mobile-only { display: none; }
.rail-avatar, .mini-avatar, .me-avatar, .msg-avatar, .vp-avatar, .m-avatar, .profile-avatar {
  font-family: var(--font); line-height: 1; text-align: center; font-variant-numeric: tabular-nums;
}

/* messages */
.messages { flex: 1; overflow-y: auto; padding: 26px 26px 10px; scroll-behavior: smooth; min-height: 0; }
.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 7px 10px; border-radius: 10px; position: relative; }
.msg:hover { background: rgba(90, 130, 180, 0.055); }
.msg.grouped { margin-top: -4px; }
.msg-avatar {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 600; font-size: 13px; letter-spacing: 0; color: #dce8f7;
  background: linear-gradient(145deg, #2a3f55, #172536);
  overflow: hidden;
}
.msg.grouped .msg-avatar { background: transparent; color: var(--dim); font-size: 10px; opacity: 0; }
.msg:hover.grouped .msg-avatar { opacity: 1; }
.msg-main { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-author { font-size: 14px; font-weight: 600; }
.msg-author.role-owner { color: var(--emerald-bright); }
.msg-author.role-admin { color: var(--blue); }
.msg-author.role-mod { color: var(--violet); }
.role-chip {
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); color: var(--muted);
}
.role-chip.role-owner { color: var(--emerald-bright); border-color: rgba(var(--accent-rgb), 0.35); background: rgba(var(--accent-rgb), 0.08); }
.role-chip.role-admin { color: var(--blue); border-color: rgba(108, 184, 255, 0.3); background: rgba(108, 184, 255, 0.07); }
.role-chip.role-mod { color: var(--violet); border-color: rgba(167, 139, 250, 0.3); background: rgba(167, 139, 250, 0.07); }
.msg-time { color: var(--dim); font-size: 10.5px; font-family: var(--mono); }
.msg-body { color: #d6e3f7; font-size: 14.5px; line-height: 1.62; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-body code { font-family: var(--mono); font-size: 12.5px; background: rgba(4, 10, 20, 0.7); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.msg-body code.block { display: block; padding: 10px 12px; margin: 6px 0; border-radius: 8px; white-space: pre-wrap; color: #b9e8d8; }
.msg-body .mention { color: var(--emerald-bright); background: rgba(var(--accent-rgb), 0.1); border-radius: 4px; padding: 0 3px; }
.msg-body a { color: var(--blue); }
.msg-actions { position: absolute; top: -8px; right: 12px; display: none; gap: 4px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 8px; padding: 3px; box-shadow: 0 8px 22px -10px #000; }
.msg:hover .msg-actions { display: flex; }
.msg-act { width: 26px; height: 26px; border-radius: 6px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.msg-act:hover { background: rgba(255, 107, 129, 0.12); color: var(--danger); }
.msg-act svg { width: 15px; height: 15px; }
.msg.deleted .msg-body { color: var(--dim); font-style: italic; }
.msg.deleted .msg-avatar { opacity: 0.3; }
.msg-system { padding: 6px 16px; color: var(--dim); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.msg-system b { color: var(--muted); font-weight: 600; }
.messages-empty { display: grid; place-items: center; height: 100%; text-align: center; color: var(--dim); }
.messages-empty h3 { color: var(--text); font-size: 17px; margin: 0 0 6px; }
.messages-empty p { margin: 0; font-size: 13px; max-width: 320px; line-height: 1.6; }

/* composer */
.composer { flex: none; padding: 8px 22px 16px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: rgba(9, 20, 37, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 9px 9px 14px;
  transition: 0.18s ease;
}
.composer-box:focus-within { border-color: rgba(var(--accent-rgb), 0.4); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.07); }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent;
  font-size: 14.5px; line-height: 1.5; max-height: 160px; padding: 7px 0; color: var(--text);
}
.composer textarea::placeholder { color: #4b6080; }
.send-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 0; flex: none;
  display: grid; place-items: center; color: #04140f;
  background: linear-gradient(145deg, var(--emerald-bright), var(--emerald));
  transition: 0.18s ease;
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }
.composer-hint { display: flex; justify-content: space-between; color: #4a5f80; font-size: 10.5px; padding: 6px 4px 0; font-family: var(--mono); }

/* voice dock */
.voice-dock {
  flex: none; margin: 0 22px 6px;
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  background: linear-gradient(180deg, rgba(13, 38, 41, 0.75), rgba(8, 24, 34, 0.85));
  border-radius: 14px;
  padding: 10px 12px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.05), 0 18px 40px -28px var(--emerald-glow);
}
.voice-dock-head { display: flex; flex-direction: column; gap: 3px; min-width: 130px; }
.voice-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--emerald-bright); }
.voice-quality { font-size: 10px; color: var(--dim); font-family: var(--mono); }
.voice-people { display: flex; gap: 7px; flex-wrap: wrap; flex: 1; }
.voice-person {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(4, 12, 22, 0.6); border: 1px solid var(--line);
  border-radius: 24px; padding: 3px 10px 3px 3px; font-size: 12px;
}
.voice-person .vp-avatar { position: relative; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 9.5px; font-weight: 600; letter-spacing: 0; color: #dce8f7; }
.voice-person.is-speaking { border-color: rgba(var(--accent-rgb), 0.5); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.12); }
.voice-person.is-speaking .vp-avatar::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--emerald); opacity: 0.7; animation: speak 1s infinite;
}
@keyframes speak { 0%,100% { transform: scale(0.94); opacity: 0.75; } 50% { transform: scale(1.08); opacity: 0.25; } }
.voice-person .vp-muted { color: var(--danger); display: inline-flex; }
.voice-person .vp-muted svg { width: 13px; height: 13px; }
.voice-person .vp-screen { color: var(--blue); display: inline-flex; }
.voice-person .vp-screen svg { width: 13px; height: 13px; }
.voice-controls { display: flex; gap: 6px; }
.dock-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-strong); background: rgba(4, 12, 22, 0.5); color: var(--muted); display: grid; place-items: center; }
.dock-btn:hover { color: var(--text); border-color: var(--line-strong); background: rgba(90, 130, 180, 0.12); }
.dock-btn.is-off { color: var(--danger); border-color: rgba(255, 107, 129, 0.3); background: var(--danger-soft); }
.dock-btn.is-on { color: var(--emerald-bright); border-color: rgba(var(--accent-rgb), 0.4); background: var(--emerald-soft); }
.dock-btn.danger:hover { color: #fff; background: rgba(255, 107, 129, 0.6); border-color: transparent; }
.dock-btn svg { width: 17px; height: 17px; }

/* screen stage */
.screen-stage {
  flex: none; margin: 14px 22px 0;
  border: 1px solid rgba(108, 184, 255, 0.25);
  background: #03070f;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 50px -30px rgba(0, 0, 0, 0.9);
}
.screen-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: rgba(10, 22, 41, 0.9); border-bottom: 1px solid var(--line); }
.screen-head #screen-title { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.screen-tabs { display: flex; gap: 4px; margin-left: auto; }
.screen-tab { border: 1px solid var(--line); background: transparent; color: var(--dim); font-size: 11px; padding: 3px 8px; border-radius: 6px; }
.screen-tab.is-active { color: var(--emerald-bright); border-color: rgba(var(--accent-rgb), 0.35); }
.member-card-head { display: flex; align-items: center; gap: 14px; }
.screen-body { position: relative; aspect-ratio: 16 / 9; max-height: 46vh; background: #02060d; }
.screen-body video { width: 100%; height: 100%; object-fit: contain; display: block; }
.screen-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-size: 12px; }

/* members */
.members-panel {
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line);
  background: rgba(6, 14, 27, 0.55);
  backdrop-filter: blur(10px);
}
.members-head { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 16px 10px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.members-count { color: var(--emerald); letter-spacing: 0.04em; font-size: 10.5px; }
.members-list { overflow-y: auto; padding: 0 10px 20px; }
.member-group-label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); padding: 14px 8px 6px; }
.member-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 9px; cursor: default; }
.member-row:hover { background: rgba(90, 130, 180, 0.08); }
.member-row.is-mod { cursor: pointer; }
.m-avatar { position: relative; width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 10.5px; font-weight: 600; letter-spacing: 0; color: #dce8f7; }
.m-avatar .status { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--dim); border: 2px solid #071224; }
.m-avatar .status.online { background: var(--emerald); }
.m-avatar .status.voice { background: var(--blue); }
.m-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-name.offline { color: var(--dim); }
.m-tag { margin-left: auto; font-size: 9px; color: var(--emerald); }
.m-tag svg { width: 13px; height: 13px; }
.member-row .role-chip { margin-left: auto; }

/* toasts / modal / ctx */
.toast-stack { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; width: min(420px, calc(100vw - 32px)); }
.toast {
  background: rgba(10, 26, 40, 0.97); border: 1px solid rgba(var(--accent-rgb), 0.3);
  color: var(--text); border-radius: 11px; padding: 11px 14px; font-size: 13px;
  box-shadow: 0 18px 40px -20px #000; animation: toast-in 0.22s ease;
  display: flex; gap: 9px; align-items: center;
}
.toast.err { border-color: rgba(255, 107, 129, 0.4); }
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--emerald); flex: none; }
.toast.err::before { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.modal-root { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; background: rgba(2, 6, 14, 0.72); backdrop-filter: blur(6px); padding: 20px; }
.modal {
  width: min(620px, 100%); max-height: 86vh; overflow: auto;
  background: linear-gradient(180deg, #0d1b31, #081422);
  border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #0c1930; z-index: 2; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px 18px 20px; }
.modal-tabs { display: flex; gap: 4px; padding: 0 18px 12px; border-bottom: 1px solid var(--line); }
.modal-tab { border: 0; background: transparent; color: var(--dim); padding: 7px 10px; border-radius: 7px; font-size: 12.5px; }
.modal-tab.is-active { color: var(--emerald-bright); background: var(--emerald-soft); }
.mod-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mod-table th { text-align: left; font-weight: 500; color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mod-table td { padding: 9px 8px; border-bottom: 1px solid rgba(64, 98, 150, 0.12); vertical-align: middle; }
.mod-table select { background: #071426; border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; font-size: 12px; }
.mod-btn { border: 1px solid var(--line-strong); background: transparent; color: var(--muted); border-radius: 7px; padding: 4px 8px; font-size: 11.5px; }
.mod-btn:hover { color: var(--text); background: rgba(90, 130, 180, 0.12); }
.mod-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.mod-btn:disabled:hover { color: var(--muted); background: transparent; }
select:disabled { opacity: 0.45; }
.mod-btn.danger { color: var(--danger); border-color: rgba(255, 107, 129, 0.3); }
.mod-btn.danger:hover { background: rgba(255, 107, 129, 0.14); }
.mod-empty { color: var(--dim); font-size: 12.5px; padding: 18px 4px; }
.invite-row { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(64, 98, 150, 0.12); }
.invite-row code { flex: 1; font-family: var(--mono); font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-row { display: grid; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.form-row input, .form-row select, .form-row textarea {
  background: #071426; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 13.5px; outline: none;
}
.form-row input:focus, .form-row select:focus { border-color: rgba(var(--accent-rgb), 0.5); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn-danger { background: linear-gradient(180deg, #ff8398, #e8495f); color: #1a0509; border: 0; border-radius: 9px; padding: 10px 16px; font-weight: 700; font-size: 13px; }

.ctx { position: fixed; z-index: 160; min-width: 190px; background: #0c1930; border: 1px solid var(--line-strong); border-radius: 10px; padding: 5px; box-shadow: 0 22px 44px -18px #000; }
.ctx button { display: flex; width: 100%; align-items: center; gap: 9px; border: 0; background: transparent; color: var(--text); padding: 8px 10px; border-radius: 7px; font-size: 12.5px; text-align: left; }
.ctx button:hover { background: rgba(90, 130, 180, 0.14); }
.ctx button.danger { color: #ff9daa; }
.ctx button.danger:hover { background: rgba(255, 107, 129, 0.16); }
.ctx svg { width: 15px; height: 15px; }
.ctx-title { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); padding: 7px 10px 4px; }

/* ---------------- rooms ---------------- */
.rooms-group .chan-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chan-add {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.chan-add:hover { color: var(--emerald-bright); border-color: rgba(var(--accent-rgb), 0.5); background: var(--emerald-soft); }
.room-card {
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(8, 19, 34, 0.45); padding: 6px; margin-bottom: 6px;
}
.room-card.is-own { border-color: rgba(var(--accent-rgb), 0.2); background: rgba(var(--accent-rgb), 0.05); }
.room-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 4px 7px; }
.room-title { flex: 1; min-width: 0; font-size: 11px; letter-spacing: 0.06em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-badge { font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--emerald-bright); border: 1px solid rgba(var(--accent-rgb), 0.25); border-radius: 4px; padding: 0 4px; }
.room-menu { width: 22px; height: 22px; border: 0; background: transparent; color: var(--dim); border-radius: 5px; display: grid; place-items: center; font-size: 14px; line-height: 1; }
.room-menu:hover { color: var(--text); background: rgba(90, 130, 180, 0.12); }
.room-channels { display: grid; gap: 1px; }
.room-channels .chan-row { padding: 6px 7px; font-size: 13px; }
.room-channels .voice-avatars { padding-left: 30px; }
.rooms-empty { color: var(--dim); font-size: 11.5px; line-height: 1.5; padding: 4px 8px 6px; }

/* ---------------- settings ---------------- */
.settings-section { border: 1px solid var(--line); border-radius: 11px; padding: 13px 14px; margin-bottom: 12px; background: rgba(4, 10, 20, 0.25); }
.settings-title { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--emerald-bright); margin-bottom: 10px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 7px 0; font-size: 13px; color: var(--text); }
.setting-row + .setting-row { border-top: 1px solid rgba(64, 98, 150, 0.1); }
.setting-row label { color: var(--muted); font-size: 12.5px; }
.setting-row select {
  max-width: 62%; min-width: 140px; background: #071426; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; font-size: 12.5px; outline: none;
}
.setting-row select:focus { border-color: rgba(var(--accent-rgb), 0.5); }
.setting-range { display: flex; align-items: center; gap: 9px; min-width: 180px; }
.setting-range input[type=range] { width: 130px; accent-color: var(--emerald); }
.setting-range output { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 38px; text-align: right; }
.check-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; color: var(--muted); font-size: 12.5px; }
.check-row input { accent-color: var(--emerald); width: 15px; height: 15px; }
.level-meter { height: 7px; border-radius: 5px; background: rgba(4, 10, 20, 0.8); border: 1px solid var(--line); overflow: hidden; margin: 5px 0 10px; }
.level-meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--emerald), var(--emerald-bright)); transition: width 0.08s linear; }
.settings-note { color: var(--dim); font-size: 11.5px; line-height: 1.55; margin: 8px 0 0; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-card { border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 8px; text-align: left; color: var(--muted); }
.theme-card:hover { border-color: var(--line-strong); color: var(--text); }
.theme-card.is-active { border-color: rgba(var(--accent-rgb), 0.65); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.12); color: var(--text); }
.theme-swatch { height: 44px; border-radius: 7px; margin-bottom: 7px; border: 1px solid rgba(255, 255, 255, 0.06); }
.theme-swatch.green { background: radial-gradient(120% 100% at 10% 0%, #1b8f70, #071426 65%); }
.theme-swatch.violet { background: radial-gradient(120% 100% at 10% 0%, #6d3fd4, #0b0716 65%); }
.theme-label { font-size: 12px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.profile-card { display: flex; align-items: center; gap: 14px; padding: 6px 0 16px; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.avatar-editor { display: flex; align-items: center; gap: 14px; padding: 4px 0 16px; flex-wrap: wrap; }
.avatar-editor .profile-avatar { flex: none; }
.avatar-editor-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.avatar-upload { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.avatar-upload input { display: none; }
.avatar-remove { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 9px; padding: 8px 11px; font-size: 12px; }
.avatar-remove:hover { color: var(--danger); border-color: rgba(255, 107, 129, 0.35); }
.profile-avatar { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-weight: 600; font-size: 18px; letter-spacing: 0; color: #dce8f7; overflow: hidden; }
.profile-name { font-size: 16px; font-weight: 650; }
.profile-mail { font-size: 12px; color: var(--dim); margin-top: 2px; }
.profile-role { font-size: 11px; color: var(--emerald-bright); margin-top: 4px; }
.btn-logout { border: 1px solid rgba(255, 107, 129, 0.3); color: var(--danger); background: transparent; border-radius: 9px; padding: 9px 14px; font-size: 12.5px; }
.btn-logout:hover { background: var(--danger-soft); }

/* фиолетовая тема: подложки, которые были захардкожены под синий */
html[data-theme="violet"] .rail { background: rgba(7, 4, 14, 0.75); }
html[data-theme="violet"] .rail-avatar { background: linear-gradient(145deg, #3b2760, #1a1030); color: #ede9fe; }
html[data-theme="violet"] .auth-card { background: linear-gradient(180deg, rgba(30, 18, 52, 0.92), rgba(10, 6, 20, 0.94)); }
html[data-theme="violet"] .modal { background: linear-gradient(180deg, #1a1030, #0c0718); }
html[data-theme="violet"] .modal-head,
html[data-theme="violet"] .ctx { background: #170f2b; }
html[data-theme="violet"] .form-row input,
html[data-theme="violet"] .form-row select,
html[data-theme="violet"] .form-row textarea,
html[data-theme="violet"] .setting-row select,
html[data-theme="violet"] .mod-table select { background: #100a1e; }
html[data-theme="violet"] .voice-dock { background: linear-gradient(180deg, rgba(28, 17, 48, 0.78), rgba(10, 6, 20, 0.86)); }
html[data-theme="violet"] .screen-head { background: rgba(23, 15, 43, 0.92); }
html[data-theme="violet"] .sidebar,
html[data-theme="violet"] .members-panel { background: var(--panel); }
html[data-theme="violet"] .room-card { background: rgba(22, 13, 38, 0.5); }
html[data-theme="violet"] .auth-brand h1 span { background: linear-gradient(100deg, var(--emerald-bright), #a78bfa 45%, #6cb8ff 110%); -webkit-background-clip: text; background-clip: text; }
html[data-theme="violet"] .app.members-open .members-panel,
html[data-theme="violet"] .sidebar { background: #120b22; }

/* mobile / narrow */
@media (max-width: 1180px) {
  .app { grid-template-columns: 68px 248px minmax(0, 1fr); }
  .members-panel { display: none; }
  .app.members-open .members-panel {
    display: flex; position: fixed; inset: 0; width: 100%; z-index: 40;
    background: #081426; padding-top: env(safe-area-inset-top);
  }
  .app.members-open .main { visibility: hidden; }
  #members-back { display: grid; }
}
@media (max-width: 900px) {
  .auth-body {
    place-items: start center;
    padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  }
  .auth-shell { grid-template-columns: 1fr; gap: 14px; width: min(520px, 100%); }
  .auth-brand { padding: 0; }
  .auth-brand h1, .brand-sub { display: none; }
  .equalizer, .brand-foot, .feature-list { display: none; }
  .brand-row { margin-bottom: 6px; }
  .auth-card { padding: 24px 20px 20px; }
}
@media (max-width: 780px) {
  body { overflow: hidden; }
  .app { grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
  .rail { display: none; }
  .sidebar {
    display: none; position: fixed; inset: 0; width: 100%; z-index: 45;
    transform: none; background: #081426; border-right: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    overflow: hidden;
  }
  .app.sidebar-open .sidebar { display: flex; }
  .app.sidebar-open .main { visibility: hidden; }
  .app.sidebar-open::after { content: none; }
  .members-panel {
    display: none; position: fixed; inset: 0; width: 100%; z-index: 46;
    background: #081426; padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app.members-open .members-panel { display: flex; }
  .mobile-only { display: grid; }
  .topbar { height: calc(56px + env(safe-area-inset-top)); padding: 0 10px; padding-top: env(safe-area-inset-top); }
  .chan-topic, .codec-badge { display: none; }
  .messages { padding: 14px 10px 6px; }
  .msg { grid-template-columns: 34px minmax(0, 1fr); gap: 9px; padding: 6px; }
  .msg-avatar { width: 32px; height: 32px; border-radius: 10px; font-size: 11px; }
  .composer { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .voice-dock { margin: 0 10px 6px; }
  .screen-stage { margin: 10px 10px 0; }
  .screen-body { max-height: 34vh; }
  .theme-grid { grid-template-columns: 1fr; }
  .setting-row { align-items: flex-start; flex-direction: column; gap: 6px; }
  .setting-row select { max-width: 100%; width: 100%; }
  .setting-range { width: 100%; }
  .setting-range input[type=range] { flex: 1; width: auto; }
  .modal { max-height: 92dvh; }
}
@media (max-width: 600px) {
  .auth-body { padding: max(12px, env(safe-area-inset-top)) 10px max(16px, env(safe-area-inset-bottom)); }
  .auth-card { padding: 20px 16px 16px; border-radius: 18px; }
  .auth-card-head p { margin-bottom: 14px; }
  .auth-tabs { margin-bottom: 14px; }
  .auth-form { gap: 11px; }
  .auth-form input { font-size: 16px; }
  .auth-sep { display: none; }
  .auth-fine { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
