/* ChadSpeak — оформление. Базовые темы — тёмная (по умолчанию) и светлая.
   Цвета заданы переменными; цветные темы (синяя, красная, …) переопределяют их из theme.js. */

/* ---------- темы ---------- */

:root,
[data-theme='dark'] {
  --bg-app: #111214;
  --bg-guilds: #1a1b1e;
  --bg-sidebar: #232428;
  --bg-main: #2b2d31;
  --bg-elevated: #313338;
  --bg-input: #1e1f22;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(255, 255, 255, 0.09);
  --bg-floating: #18191c;
  --bg-modal: #2b2d31;
  --bg-stage: #0e0f11;
  --bg-tile: #1f2024;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #dbdee1;
  --text-muted: #949ba4;
  --text-faint: #6d6f78;
  --header: #f2f3f5;
  --accent: #5865f2;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(88, 101, 242, 0.16);
  --accent-text: #ffffff;
  --link: #00a8fc;
  --green: #23a55a;
  --red: #f23f43;
  --yellow: #f0b232;
  --mention-bg: rgba(240, 178, 50, 0.1);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.5);
  --login-bg: radial-gradient(1200px 600px at 20% 10%, #2c2f7a 0%, transparent 60%), radial-gradient(900px 500px at 90% 90%, #4a1f6e 0%, transparent 55%), #0b0c10;
  --scroll: rgba(255, 255, 255, 0.12);
  color-scheme: dark;
}

[data-theme='light'] {
  --bg-app: #e3e5e8;
  --bg-guilds: #e3e5e8;
  --bg-sidebar: #f2f3f5;
  --bg-main: #ffffff;
  --bg-elevated: #ffffff;
  --bg-input: #ebedef;
  --bg-hover: rgba(6, 6, 7, 0.05);
  --bg-active: rgba(6, 6, 7, 0.09);
  --bg-floating: #ffffff;
  --bg-modal: #ffffff;
  --bg-stage: #1e1f22;
  --bg-tile: #2b2d31;
  --border: rgba(6, 6, 7, 0.08);
  --border-strong: rgba(6, 6, 7, 0.14);
  --text: #313338;
  --text-muted: #5c5e66;
  --text-faint: #8a8d94;
  --header: #060607;
  --accent: #5865f2;
  --accent-2: #7c3aed;
  --accent-soft: rgba(88, 101, 242, 0.12);
  --accent-text: #ffffff;
  --link: #006ce7;
  --green: #1f9d55;
  --red: #da373c;
  --yellow: #c78b00;
  --mention-bg: rgba(240, 178, 50, 0.16);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.2);
  --login-bg: radial-gradient(1200px 600px at 20% 10%, #c7ccff 0%, transparent 60%), radial-gradient(900px 500px at 90% 90%, #e5d4ff 0%, transparent 55%), #eef0f6;
  --scroll: rgba(6, 6, 7, 0.18);
  color-scheme: light;
}

:root {
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --font: 'Segoe UI Variable Text', 'Segoe UI', 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* ---------- основа ---------- */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

body,
.sidebar,
.main,
.members,
.guilds,
.modal,
.context-menu {
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  user-select: text;
}

.ico {
  flex-shrink: 0;
  display: block;
}

a.link {
  color: var(--link);
  text-decoration: none;
  cursor: pointer;
}

a.link:hover {
  text-decoration: underline;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted {
  color: var(--text-muted);
}

.small-text {
  font-size: 13px;
}

.center {
  text-align: center;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.center-row {
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-weight: 600;
  min-height: 38px;
  transition: transform 0.12s var(--ease), filter 0.15s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--grad);
  color: var(--accent-text);
  box-shadow: 0 4px 14px var(--accent-soft);
}

.btn.secondary {
  background: var(--bg-active);
  color: var(--header);
}

.btn.danger {
  background: var(--red);
  color: #fff;
}

.btn.success {
  background: var(--green);
  color: #fff;
}

.btn.link {
  background: none;
  color: var(--link);
  padding: 4px;
  min-height: 0;
  font-weight: 500;
}

.btn.link:hover {
  text-decoration: underline;
  transform: none;
}

.btn.small {
  padding: 5px 12px;
  min-height: 30px;
  font-size: 13px;
}

.btn.block {
  width: 100%;
}

.icon-btn {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-active);
  color: var(--header);
}

.icon-btn.off {
  color: var(--red);
}

.icon-btn.active {
  color: var(--green);
}

/* ---------- поля ---------- */

.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select.input {
  cursor: pointer;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -6px 0 12px;
}

.form-error {
  color: var(--red);
  font-size: 14px;
  margin-bottom: 10px;
}

.form-success {
  color: var(--green);
  font-size: 14px;
  margin-bottom: 10px;
}

.form-error:empty,
.form-success:empty {
  display: none;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  line-height: 1.35;
}

.checkbox input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

input[type='range'] {
  accent-color: var(--accent);
}

.range {
  width: 100%;
}

/* ---------- аватары, бейджи ---------- */

.avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  transition: box-shadow 0.15s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 38%;
  height: 38%;
  min-width: 10px;
  min-height: 10px;
  border-radius: 50%;
  border: 3px solid var(--bg-sidebar);
}

.status-dot.online {
  background: var(--green);
}

.status-dot.offline {
  background: #80848e;
}

.badge {
  background: var(--red);
  color: #fff;
  border-radius: 9px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- экраны входа и подключения ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--login-bg);
  overflow-y: auto;
  padding: 24px;
}

.comets {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.login-lang {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--bg-main) 70%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
}

.login-lang-select {
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

.login-lang-select option {
  background: var(--bg-main);
  color: var(--text);
}

.login-card,
.connecting-card {
  position: relative;
  z-index: 1;
  background: color-mix(in srgb, var(--bg-main) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 440px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  margin: auto;
  animation: card-in 0.5s var(--ease);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
}

.login-card h1 {
  text-align: center;
  color: var(--header);
  margin: 10px 0 4px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.login-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto;
  border-radius: 22px;
  background: var(--grad);
  color: #fff;
  font-size: 36px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px var(--accent-soft);
}

.notice {
  background: color-mix(in srgb, var(--yellow) 15%, transparent);
  border-left: 3px solid var(--yellow);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 14px;
}

.server-status {
  font-size: 13px;
  color: var(--text-muted);
  margin: -8px 0 14px;
}

.server-status.ok {
  color: var(--green);
}

.server-status.bad {
  color: var(--red);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg-input);
  border-radius: var(--radius);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 8px 12px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--header);
}

.tab.active {
  background: var(--bg-elevated);
  color: var(--header);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.connecting-card {
  text-align: center;
  width: 360px;
}

.connecting-card > div {
  margin-bottom: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 4px solid var(--bg-active);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- раскладка ---------- */

.app {
  display: flex;
  height: 100vh;
}

.guilds {
  width: 72px;
  background: var(--bg-guilds);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  flex-shrink: 0;
  overflow-y: auto;
}

.guild-icon {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: none;
  color: var(--header);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-radius 0.2s var(--ease), background 0.2s, transform 0.15s;
}

.guild-icon:hover {
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
}

.guild-icon.active {
  border-radius: 16px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-soft);
}

.guild-icon .badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  border: 3px solid var(--bg-guilds);
  height: 22px;
  border-radius: 11px;
}

.guild-pill {
  position: absolute;
  left: -16px;
  width: 8px;
  border-radius: 0 4px 4px 0;
  background: var(--header);
  height: 0;
  transition: height 0.2s var(--ease);
}

.guild-icon:hover .guild-pill {
  height: 20px;
}

.guild-icon.active .guild-pill {
  height: 40px;
}

.guild-icon.unread:not(.active) .guild-pill {
  height: 8px;
}

.guild-separator {
  width: 32px;
  height: 2px;
  background: var(--border-strong);
  border-radius: 1px;
}

.sidebar {
  width: 248px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-top-left-radius: var(--radius-lg);
}

.sidebar-header {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-weight: 700;
  color: var(--header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.server-menu-btn {
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--header);
  text-align: left;
  padding: 0;
}

.server-menu-btn .channel-name {
  flex: 1;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-main);
  position: relative;
}

.topbar {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar .topbar-icon {
  color: var(--text-muted);
  font-size: 20px;
  display: flex;
}

.topbar .topbar-sub {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 6px;
}

.topbar .spacer {
  flex: 1;
}

.topbar-btn {
  width: 36px;
  height: 36px;
}

.topbar-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.offline-banner {
  background: var(--red);
  color: #fff;
  text-align: center;
  font-size: 13px;
  padding: 5px;
  font-weight: 600;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  max-width: 460px;
  line-height: 1.55;
}

.empty-state .big {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--accent);
}

.empty-state h2 {
  color: var(--header);
  margin: 0 0 8px;
}

.empty-state b {
  color: var(--header);
  user-select: text;
}

.empty-state.small {
  padding: 16px;
  font-size: 14px;
}

/* ---------- каналы и ЛС ---------- */

.channel-group {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 18px 8px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-group:first-child {
  padding-top: 8px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  margin-bottom: 2px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  text-align: left;
  font-weight: 500;
  min-height: 36px;
  transition: background 0.12s, color 0.12s;
}

.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.channel-item.active {
  background: var(--bg-active);
  color: var(--header);
}

.channel-item.unread {
  color: var(--header);
  font-weight: 700;
}

.channel-item .channel-icon {
  width: 20px;
  display: flex;
  justify-content: center;
  color: var(--text-faint);
  flex-shrink: 0;
}

.channel-item.active .channel-icon {
  color: var(--accent);
}

.channel-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-sub {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-call-dot {
  color: var(--green);
  display: flex;
}

.dm-call-dot svg {
  width: 15px;
  height: 15px;
}

.voice-users {
  margin: 0 0 6px 26px;
}

.voice-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-muted);
}

.voice-user:hover {
  background: var(--bg-hover);
}

.voice-user.speaking .avatar,
.user-panel .avatar.speaking {
  box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 4px var(--green);
}

.voice-user .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-icons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
}

.state-icons svg {
  width: 14px;
  height: 14px;
}

.live {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---------- панель звонка и пользователя ---------- */

.voice-panel {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-sidebar) 70%, var(--bg-app));
  padding: 10px;
}

.voice-panel-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.voice-panel-title {
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-panel-title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.voice-panel-title.connecting {
  color: var(--yellow);
}

.voice-panel-sub {
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}

.voice-panel-sub:hover {
  text-decoration: underline;
}

.voice-panel-actions {
  display: flex;
  gap: 6px;
}

.voice-panel-actions .icon-btn {
  flex: 1;
  height: 34px;
  background: var(--bg-active);
  color: var(--text);
}

.voice-panel-actions .icon-btn:hover {
  filter: brightness(1.2);
}

.voice-panel-actions .icon-btn.active {
  background: var(--green);
  color: #fff;
}

.voice-panel-actions .icon-btn.danger:hover {
  background: var(--red);
  color: #fff;
}

.user-panel {
  height: 56px;
  background: color-mix(in srgb, var(--bg-sidebar) 70%, var(--bg-app));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  flex-shrink: 0;
}

.user-panel .avatar {
  margin-right: 6px;
}

.user-panel .avatar .status-dot {
  border-color: color-mix(in srgb, var(--bg-sidebar) 70%, var(--bg-app));
}

.user-panel-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 14px;
  color: var(--header);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: text;
}

.user-panel-name small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
}

.btn-group {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
}

.btn-group:hover {
  background: var(--bg-hover);
}

.user-panel .icon-btn {
  width: 30px;
}

.user-panel .icon-btn.arrow {
  width: 14px;
  margin-left: -3px;
}

/* ---------- чат ---------- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 8px;
  user-select: text;
}

.messages-start {
  padding: 16px;
  color: var(--text-muted);
}

.messages-start h2 {
  color: var(--header);
  margin: 0 0 4px;
}

.history-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px;
}

.date-divider {
  display: flex;
  align-items: center;
  margin: 18px 16px 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.date-divider::before,
.date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}

.date-divider span {
  padding: 2px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
}

.message {
  position: relative;
  padding: 2px 48px 2px 72px;
  min-height: 24px;
  line-height: 1.4;
  transition: background 0.1s;
}

.message.first {
  margin-top: 14px;
  min-height: 44px;
}

.message:hover {
  background: var(--bg-hover);
}

.message.mentioned {
  background: var(--mention-bg);
  box-shadow: inset 3px 0 0 var(--yellow);
}

.message .avatar {
  position: absolute;
  left: 16px;
  top: 3px;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.message-author {
  font-weight: 700;
  color: var(--header);
}

.message-time {
  font-size: 12px;
  color: var(--text-faint);
}

.message-side-time {
  position: absolute;
  left: 0;
  width: 72px;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  top: 5px;
  visibility: hidden;
}

.message:hover .message-side-time {
  visibility: visible;
}

.message-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.message-edited {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: 4px;
}

.mention {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border-radius: 4px;
  padding: 0 3px;
}

.message-actions {
  position: absolute;
  right: 16px;
  top: -16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: none;
  padding: 2px;
  box-shadow: var(--shadow);
}

.message:hover .message-actions {
  display: flex;
}

.message-actions .icon-btn {
  width: 30px;
  height: 30px;
}

.message-edit textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  resize: none;
  outline: none;
  line-height: 1.4;
}

.message-edit-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.new-messages-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 96px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 7px 18px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 2;
}

.composer {
  padding: 0 16px 4px;
  flex-shrink: 0;
}

.composer-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-end;
  padding: 0 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 0;
  max-height: 40vh;
  line-height: 1.4;
}

.composer-plus {
  width: 28px;
  height: 28px;
  margin: 9px 10px 9px -4px;
  border: none;
  border-radius: 50%;
  background: var(--bg-active);
  color: var(--text);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}

.composer-plus:hover {
  background: var(--accent);
  color: #fff;
  transform: rotate(90deg);
}

.composer-disabled {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text-muted);
  text-align: center;
}

.typing-line {
  height: 22px;
  font-size: 13px;
  color: var(--text);
  padding: 0 16px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.typing-dots {
  display: inline-block;
  margin-right: 4px;
}

.typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 2px;
  border-radius: 50%;
  background: var(--text);
  animation: blink 1.2s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

/* ---------- вложения ---------- */

.upload-queue {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 12px 8px;
}

.upload-queue + .composer-box {
  border-radius: 0 0 var(--radius) var(--radius);
}

.upload-item {
  position: relative;
  width: 160px;
  flex-shrink: 0;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.upload-item.error {
  outline: 1px solid var(--red);
}

.upload-thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-hover);
  display: block;
}

.upload-thumb.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.upload-name {
  margin-top: 6px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.upload-progress {
  height: 3px;
  background: var(--bg-hover);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.upload-progress div {
  height: 100%;
  background: var(--grad);
}

.upload-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-hint {
  position: absolute;
  inset: 10px;
  background: color-mix(in srgb, var(--accent) 80%, transparent);
  border: 3px dashed #fff;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  z-index: 5;
  pointer-events: none;
}

.drop-hint svg {
  margin: 0 auto 8px;
}

.attachments {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 4px;
}

.att {
  position: relative;
  max-width: min(480px, 100%);
}

.att-media {
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  background: var(--bg-hover);
}

.att-image {
  display: block;
  max-width: 100%;
  max-height: 320px;
  min-width: 40px;
  min-height: 40px;
}

.att-video {
  display: block;
  max-width: 100%;
  max-height: 360px;
  background: #000;
}

.att-file {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 420px;
}

.att-file audio {
  width: 100%;
  margin-top: 8px;
}

.att-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.att-icon {
  color: var(--accent);
  display: flex;
}

.att-info {
  flex: 1;
  min-width: 0;
}

.att-name {
  color: var(--link);
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.att-name:hover {
  text-decoration: underline;
}

.att-size {
  font-size: 12px;
  color: var(--text-muted);
}

.att-download {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}

.att:hover .att-download {
  display: flex;
}

.att-download.static {
  position: static;
  display: flex;
  background: none;
  color: var(--text-muted);
}

.att-download.static:hover {
  color: var(--header);
}

.lightbox-modal {
  width: auto !important;
  max-width: 95vw;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
}

.lightbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 80vh;
  border-radius: var(--radius);
  cursor: zoom-out;
  box-shadow: var(--shadow-lg);
}

.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-floating);
  padding: 8px 12px;
  border-radius: var(--radius);
}

.lightbox-name {
  color: var(--text-muted);
  font-size: 13px;
  margin-right: 8px;
}

/* ---------- участники ---------- */

.members {
  width: 248px;
  background: var(--bg-sidebar);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 8px;
}

.members .add-member {
  width: 100%;
  margin: 8px 0;
}

.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}

.member:hover {
  background: var(--bg-hover);
}

.member.offline {
  opacity: 0.45;
}

.member .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.member .crown {
  color: var(--yellow);
  display: flex;
}

.member .crown svg {
  width: 15px;
  height: 15px;
}

/* ---------- друзья ---------- */

.friends-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.friends-tab {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  color: var(--text-muted);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, color 0.12s;
}

.friends-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.friends-tab.active {
  background: var(--bg-active);
  color: var(--header);
}

.friends-tab.add {
  background: var(--green);
  color: #fff;
}

.friends-tab.add.active {
  background: none;
  color: var(--green);
}

.friends-page {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.friends-section-title {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 8px 0;
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-top: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}

.friend-row:hover {
  background: var(--bg-hover);
}

.friend-row .info {
  flex: 1;
  min-width: 0;
}

.friend-row .name {
  font-weight: 700;
  color: var(--header);
}

.friend-row .sub {
  font-size: 13px;
  color: var(--text-muted);
}

.friend-row .actions {
  display: flex;
  gap: 8px;
}

.round-action {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s, transform 0.12s;
}

.round-action:hover {
  color: var(--header);
  transform: scale(1.06);
}

.round-action.ok:hover {
  color: var(--green);
}

.round-action.no:hover {
  color: var(--red);
}

.add-friend-form {
  display: flex;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 8px 8px 14px;
  margin: 12px 0 8px;
}

.add-friend-form:focus-within {
  border-color: var(--accent);
}

.add-friend-form input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
}

/* ---------- голосовой вид ---------- */

.voice-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-stage);
}

.voice-lobby {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-main);
  padding: 24px;
  text-align: center;
}

.lobby-icon {
  width: 96px;
  height: 96px;
  border-radius: 32px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-lobby h2 {
  margin: 0;
  color: var(--header);
}

.voice-lobby.compact {
  flex: none;
  gap: 10px;
  padding: 16px;
  background: var(--bg-stage);
  color: #dbdee1;
}

.voice-lobby-users {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.voice-lobby-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* сцена с плитками */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
}

.stage-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
}

.stage.focus .stage-main {
  flex: 1;
  min-height: 0;
  display: flex;
}

.stage.focus .stage-main .tile {
  flex: 1;
  width: auto !important;
  height: auto !important;
}

.stage-strip {
  height: 112px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
}

.stage-strip .tile {
  width: 199px !important;
  height: 112px !important;
  flex-shrink: 0;
}

.stage-strip .tile-avatar .avatar {
  width: 44px !important;
  height: 44px !important;
  font-size: 20px !important;
}

.stage-strip .tile-volume,
.stage-strip .tile-actions .tile-btn:not(:first-child) {
  display: none !important;
}

.tile {
  position: relative;
  background: var(--bg-tile);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: outline-color 0.12s, box-shadow 0.15s, transform 0.15s;
  color: #fff;
}

.tile:hover {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.tile.speaking {
  outline-color: var(--green);
  box-shadow: 0 0 18px color-mix(in srgb, var(--green) 45%, transparent);
}

.tile.pinned {
  cursor: zoom-out;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.tile.cam-tile video {
  object-fit: cover;
}

.stage.focus .stage-main .tile.cam-tile video {
  object-fit: contain;
}

.tile.self.cam-tile video {
  transform: scaleX(-1);
}

.tile.screen-tile {
  background: #000;
}

.tile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
}

.tile-label .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-label .state-icons {
  color: #fff;
}

.muted-for-me {
  color: #ff8a8a;
  display: flex;
}

.tile-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.tile:hover .tile-actions,
.tile.pinned .tile-actions {
  opacity: 1;
}

.tile-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

.tile-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.tile-btn.active {
  background: var(--accent);
}

.tile-volume {
  position: absolute;
  left: 8px;
  top: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  cursor: default;
}

.tile:hover .tile-volume {
  opacity: 1;
  pointer-events: auto;
}

.tile-volume input {
  width: 110px;
}

.vol-value {
  min-width: 36px;
  text-align: right;
}

.voice-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 12px 14px;
  flex-shrink: 0;
}

.round-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
}

.round-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}

.round-btn.off {
  background: #fff;
  color: #e5484d;
}

.round-btn.active {
  background: var(--green);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--green) 45%, transparent);
}

.round-btn.danger {
  background: var(--red);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--red) 40%, transparent);
}

.round-btn.accept {
  background: var(--green);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--green) 45%, transparent);
}

.voice-warning {
  background: color-mix(in srgb, var(--yellow) 18%, transparent);
  color: var(--yellow);
  text-align: center;
  padding: 6px;
  font-size: 13px;
}

.voice-calling {
  text-align: center;
  color: #fff;
  padding: 6px;
  font-size: 13px;
  background: color-mix(in srgb, var(--green) 25%, transparent);
}

/* ЛС со звонком */

.dm-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dm-call-area {
  flex-shrink: 0;
  background: var(--bg-stage);
  display: flex;
  flex-direction: column;
  max-height: 58%;
}

.dm-call-area.in-call {
  height: 58%;
}

.dm-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.voice-view.embedded .round-btn {
  width: 44px;
  height: 44px;
}

.voice-view.embedded .stage-strip {
  height: 84px;
}

.voice-view.embedded .stage-strip .tile {
  width: 150px !important;
  height: 84px !important;
}

/* ---------- модальные окна ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  width: 460px;
  max-width: 100%;
  max-height: 100%;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.2s var(--ease);
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
}

.modal.wide {
  width: 760px;
}

.modal-title {
  margin: 0 0 14px;
  color: var(--header);
  font-size: 20px;
  letter-spacing: -0.01em;
}

.modal-text {
  color: var(--text);
  line-height: 1.45;
  white-space: pre-line;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* настройки */

.settings-section {
  margin-bottom: 22px;
}

.settings-section h3 {
  color: var(--header);
  font-size: 15px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-section h3 svg {
  color: var(--accent);
}

.mic-meter {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.mic-meter-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  transition: width 0.05s linear;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.theme-card {
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px;
  background: none;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

.theme-card:hover {
  transform: translateY(-2px);
}

.theme-card.active {
  border-color: var(--accent);
}

.theme-preview {
  height: 54px;
  border-radius: var(--radius-sm);
  display: flex;
  overflow: hidden;
  margin-bottom: 6px;
}

.theme-preview span {
  display: block;
}

.theme-preview span:nth-child(1) {
  width: 18%;
}

.theme-preview span:nth-child(2) {
  width: 28%;
}

.theme-preview span:nth-child(3) {
  flex: 1;
  position: relative;
}

.theme-preview span:nth-child(3)::after {
  content: '';
  position: absolute;
  left: 10%;
  right: 30%;
  bottom: 10px;
  height: 8px;
  border-radius: 4px;
  background: var(--swatch-accent);
}

/* выбор экрана */

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  margin: 12px 0;
}

.picker-item {
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 8px;
  text-align: left;
  transition: border-color 0.12s, transform 0.12s;
}

.picker-item:hover {
  transform: translateY(-2px);
}

.picker-item.selected {
  border-color: var(--accent);
}

.picker-item img,
.picker-item .no-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius-sm);
  display: block;
}

.picker-name {
  margin-top: 6px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-audio {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 10px 12px;
}

/* добавление участников */

.candidate-list {
  margin: 12px 0;
  max-height: 46vh;
  overflow-y: auto;
}

.candidate {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.candidate:hover {
  background: var(--bg-hover);
}

.candidate .avatar .status-dot {
  border-color: var(--bg-modal);
}

.candidate-info {
  flex: 1;
  min-width: 0;
}

.candidate-name {
  font-weight: 700;
  color: var(--header);
}

.candidate-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.invite-box {
  border-top: 1px solid var(--border-strong);
  padding-top: 12px;
}

/* входящий звонок */

.incoming-modal {
  width: 330px !important;
  text-align: center;
  padding: 30px 24px !important;
}

.incoming-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.incoming-avatar .avatar {
  animation: ring-pulse 1.4s infinite;
}

@keyframes ring-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 70%, transparent);
  }
  70% {
    box-shadow: 0 0 0 20px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.incoming-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--header);
}

.incoming-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 22px;
}

/* ---------- меню и подсказки ---------- */

.context-menu {
  position: fixed;
  z-index: 200;
  background: var(--bg-floating);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 200px;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s var(--ease);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item:hover {
  background: var(--accent);
  color: #fff;
}

.menu-item.danger {
  color: var(--red);
}

.menu-item.danger:hover {
  background: var(--red);
  color: #fff;
}

.menu-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 8px 4px;
}

.menu-separator {
  height: 1px;
  background: var(--border-strong);
  margin: 4px 6px;
}

.menu-check {
  display: inline-flex;
  width: 18px;
  color: var(--green);
}

.menu-icon {
  display: inline-flex;
  color: var(--text-muted);
}

.menu-item:hover .menu-check,
.menu-item:hover .menu-icon {
  color: #fff;
}

.menu-range {
  padding: 6px 8px;
}

.menu-range-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.menu-range input {
  width: 100%;
}

.toast-root {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  background: var(--bg-floating);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  transition: opacity 0.3s, transform 0.3s;
  border-left: 4px solid var(--accent);
  max-width: 480px;
  animation: toast-in 0.25s var(--ease);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.toast.success {
  border-left-color: var(--green);
}

.toast.error {
  border-left-color: var(--red);
}

.toast.hide {
  opacity: 0;
  transform: translateY(6px);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* переключатель-«таблетка» */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-input);
  border-radius: var(--radius);
}

.seg {
  border: none;
  background: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.seg:hover {
  color: var(--header);
}

.seg.active {
  background: var(--grad);
  color: var(--accent-text);
}

.picker-options {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* =====================================================================
   Реакции, ответы, эмодзи, форматирование, статусы, анимации
   ===================================================================== */

/* ---------- форматирование текста ---------- */

.message-text strong {
  color: var(--header);
}

.inline-code {
  font-family: Consolas, 'Cascadia Mono', 'Courier New', monospace;
  font-size: 0.88em;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.code-block {
  margin: 6px 0;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  max-width: 100%;
  white-space: pre;
}

.code-block code {
  font-family: Consolas, 'Cascadia Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.45;
}

.spoiler {
  background: var(--text-faint);
  color: transparent;
  border-radius: 4px;
  padding: 0 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.spoiler:hover {
  background: var(--text-muted);
}

.spoiler.revealed {
  background: var(--bg-active);
  color: inherit;
  cursor: text;
}

.spoiler * {
  visibility: hidden;
}

.spoiler.revealed * {
  visibility: visible;
}

.message-text.jumbo {
  font-size: 42px;
  line-height: 1.2;
}

/* ---------- ответы ---------- */

.reply-quote {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 2px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  min-width: 0;
}

.reply-quote:hover .reply-text {
  color: var(--header);
}

.reply-line {
  position: absolute;
  left: -38px;
  top: 9px;
  width: 30px;
  height: 12px;
  border-left: 2px solid var(--border-strong);
  border-top: 2px solid var(--border-strong);
  border-top-left-radius: 6px;
}

.message .reply-quote .avatar {
  position: relative; /* не static: от аватарки считается её рамка */
  font-size: 9px !important;
  flex-shrink: 0;
}

.reply-quote b {
  color: var(--header);
  font-weight: 600;
  flex-shrink: 0;
}

.reply-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.message:has(> .reply-quote) > .avatar {
  top: 25px;
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
  animation: slide-up 0.18s var(--ease);
}

.reply-bar b {
  color: var(--header);
}

.reply-bar-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-bar-close {
  border: none;
  background: var(--bg-active);
  color: var(--text);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reply-bar + div + .composer-box,
.reply-bar + .composer-box {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.reply-bar:not([hidden]) + div .upload-queue {
  border-radius: 0;
}

/* ---------- реакции ---------- */

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px;
  border-radius: 13px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}

.reaction:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.reaction.mine {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--header);
}

.reaction-emoji {
  font-size: 15px;
}

.reaction.add {
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s;
}

.message:hover .reaction.add {
  opacity: 1;
}

.reaction.pop {
  animation: reaction-pop 0.35s var(--ease);
}

@keyframes reaction-pop {
  0% {
    transform: scale(0.6);
  }
  60% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- эмодзи ---------- */

.composer-emoji {
  border: none;
  background: none;
  color: var(--text-muted);
  margin: 10px -2px 10px 8px;
  padding: 0;
  display: flex;
  transition: color 0.15s, transform 0.15s;
}

.composer-emoji:hover {
  color: var(--yellow);
  transform: scale(1.15) rotate(-8deg);
}

.emoji-picker {
  position: fixed;
  z-index: 210;
  width: 352px;
  background: var(--bg-floating);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop-in 0.15s var(--ease);
}

.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.emoji-tab {
  border: none;
  background: none;
  font-size: 18px;
  width: 34px;
  height: 32px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  filter: grayscale(0.7);
  transition: background 0.12s, filter 0.12s;
}

.emoji-tab:hover,
.emoji-tab.active {
  background: var(--bg-active);
  filter: none;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.emoji-cat-name {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 2px 4px 6px;
}

.emoji-btn {
  border: none;
  background: none;
  font-size: 24px;
  height: 38px;
  border-radius: var(--radius-sm);
  transition: background 0.1s, transform 0.1s;
}

.emoji-btn:hover {
  background: var(--bg-active);
  transform: scale(1.18);
}

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

.status-dot.idle {
  background: var(--yellow);
}

.status-dot.dnd {
  background: var(--red);
}

.status-dot.dnd::after {
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--bg-sidebar);
  border-radius: 1px;
}

.status-dot.invisible {
  background: var(--bg-sidebar);
  box-shadow: inset 0 0 0 2px #80848e;
}

.menu-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 4px 0 2px;
  flex-shrink: 0;
}

.menu-dot.online {
  background: var(--green);
}

.menu-dot.idle {
  background: var(--yellow);
}

.menu-dot.dnd {
  background: var(--red);
}

.menu-dot.invisible {
  box-shadow: inset 0 0 0 2px #80848e;
}

.user-panel-me {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  border: none;
  background: none;
  padding: 4px;
  margin-left: -4px;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 0.12s;
}

.user-panel-me:hover {
  background: var(--bg-hover);
}

/* ---------- анимации ---------- */

/* новое сообщение */
.message.msg-in {
  animation: msg-in 0.35s var(--ease);
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* прыжок к сообщению по ответу */
.message.flash {
  animation: flash 1.4s ease;
}

@keyframes flash {
  0%,
  30% {
    background: var(--accent-soft);
  }
}

/* смена канала/раздела */
.content > * {
  animation: view-in 0.25s var(--ease);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* «волна» на кнопках */
.btn,
.round-btn,
.seg,
.tab,
.friends-tab {
  position: relative;
  overflow: hidden;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.25;
  transform: scale(0);
  pointer-events: none;
  animation: ripple 0.6s ease-out forwards;
}

@keyframes ripple {
  to {
    transform: scale(1);
    opacity: 0;
  }
}

/* блик на главной кнопке */
.btn.primary::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg);
  pointer-events: none;
}

.btn.primary:hover::after {
  animation: shine 0.8s ease;
}

@keyframes shine {
  to {
    left: 130%;
  }
}

/* говорящий — мягкая пульсация */
.tile.speaking {
  animation: speak-pulse 1.2s ease-in-out infinite;
}

@keyframes speak-pulse {
  50% {
    box-shadow: 0 0 26px color-mix(in srgb, var(--green) 60%, transparent);
  }
}

.voice-user.speaking .avatar {
  animation: speak-ring 1.2s ease-in-out infinite;
}

@keyframes speak-ring {
  50% {
    box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 5px color-mix(in srgb, var(--green) 70%, transparent);
  }
}

/* новая плитка в звонке */
.tile.tile-in {
  animation: tile-in 0.35s var(--ease);
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
}

/* иконка сервера при наведении */
.guild-icon:hover {
  transform: translateY(-1px);
}

/* конфетти */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 400;
}

/* логотип на экране входа мягко «дышит» */
.login-logo {
  animation: logo-float 4s ease-in-out infinite;
}

@keyframes logo-float {
  50% {
    transform: translateY(-4px);
    box-shadow: 0 16px 36px var(--accent-soft);
  }
}

/* ---------- обновление ---------- */

.update-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--grad);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 14px;
  animation: slide-down 0.3s var(--ease);
}

.update-banner span {
  flex: 1;
}

.update-banner .btn.primary {
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  box-shadow: none;
}

.update-banner-close {
  border: none;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
}

/* ---------- аватарки ---------- */

.avatar {
  overflow: visible;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--bg-elevated);
}

.avatar-current {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.avatar-current b {
  color: var(--header);
  font-size: 16px;
}

.crop-box {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.crop-frame {
  position: relative;
  width: 280px;
  height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  background: repeating-conic-gradient(var(--bg-input) 0 25%, var(--bg-elevated) 0 50%) 0 0 / 20px 20px;
}

/* затемнение вокруг круга */
.crop-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 200px rgba(0, 0, 0, 0.55);
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: -2px;
  pointer-events: none;
}

.crop-canvas {
  display: block;
  cursor: grab;
  touch-action: none;
}

.crop-canvas:active {
  cursor: grabbing;
}

.crop-zoom {
  width: 280px;
  color: var(--text-muted);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.preset {
  border: 2px solid transparent;
  background: none;
  padding: 2px;
  border-radius: 50%;
  aspect-ratio: 1;
  transition: transform 0.12s, border-color 0.12s;
}

.preset canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
}

.preset:hover {
  transform: scale(1.07);
}

.preset.selected {
  border-color: var(--accent);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 14px;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-name {
  font-weight: 800;
  font-size: 17px;
  color: var(--header);
}

/* ---------- роли и права, создание каналов ---------- */

.channel-group .group-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.channel-group .group-add:hover {
  background: var(--bg-hover);
  color: var(--header);
  transform: rotate(90deg);
}

.modal-title:has(svg) {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title svg {
  color: var(--accent);
  flex-shrink: 0;
}

.roles-editor {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 16px;
  min-height: 420px;
}

.roles-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid var(--border);
  padding-right: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.roles-list .btn {
  margin-bottom: 8px;
  gap: 6px;
}

.role-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.role-item:hover {
  background: var(--bg-hover);
}

.role-item.active {
  background: var(--bg-active);
  color: var(--header);
  font-weight: 600;
}

.role-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-count {
  font-size: 12px;
  color: var(--text-faint);
}

.role-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 10%, transparent);
}

.role-dot.everyone {
  background: conic-gradient(#e5484d, #f5a524, #22c55e, #3b82f6, #a855f7, #e5484d);
}

.role-pane {
  min-width: 0;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}

.role-pane-title {
  margin: 0 0 4px;
  color: var(--header);
  font-size: 16px;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}

.swatch:hover:not(:disabled) {
  transform: scale(1.12);
}

.swatch.active {
  border-color: var(--header);
  box-shadow: 0 0 0 2px var(--bg-modal) inset;
}

.swatch.none {
  background: repeating-linear-gradient(45deg, var(--bg-input) 0 4px, var(--bg-elevated) 4px 8px);
  border-color: var(--border-strong);
}

.swatch:disabled {
  cursor: default;
  opacity: 0.5;
}

.perm-list {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.perm {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.perm:last-child {
  border-bottom: none;
}

.perm:hover {
  background: var(--bg-hover);
}

.perm.disabled {
  cursor: default;
  opacity: 0.55;
}

.perm-text {
  flex: 1;
  min-width: 0;
}

.perm-label {
  color: var(--header);
  font-size: 14px;
  font-weight: 500;
}

.perm-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

/* Переключатель-«тумблер» вместо галочки */
input.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  transition: background 0.2s;
}

input.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s var(--ease), background 0.2s;
}

input.switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}

input.switch:checked::after {
  transform: translateX(16px);
  background: #fff;
}

input.switch:disabled {
  cursor: default;
}

.role-holders {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.holder-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 4px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 13px;
}

.holder-chip .avatar {
  position: relative;
}

.chip-x {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.chip-x:hover {
  background: var(--red);
  color: #fff;
}

.role-holders select.input.small {
  width: auto;
  min-width: 180px;
  padding: 4px 8px;
  min-height: 28px;
  font-size: 13px;
}

.role-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.role-actions .btn {
  gap: 6px;
}

.role-checklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.role-check {
  align-items: center;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
}

.role-check:hover {
  background: var(--bg-hover);
}

.role-check.disabled {
  opacity: 0.5;
  cursor: default;
}

.member .member-muted,
.state-icons .server-muted {
  color: var(--red);
  display: flex;
}

.member .member-muted svg {
  width: 15px;
  height: 15px;
}

.range-value {
  min-width: 64px;
  text-align: right;
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .roles-editor {
    grid-template-columns: 1fr;
  }

  .roles-list {
    border-right: none;
    padding-right: 0;
    max-height: 180px;
  }
}

/* ---------- права канала: запретить / как обычно / разрешить ---------- */

.tri-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.tri {
  width: 34px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}

.tri + .tri {
  border-left: 1px solid var(--border-strong);
}

.tri:hover {
  background: var(--bg-hover);
}

.tri.deny.active {
  background: var(--red);
  color: #fff;
}

.tri.inherit.active {
  background: var(--bg-active);
  color: var(--header);
}

.tri.allow.active {
  background: var(--green);
  color: #fff;
}

.private-toggle {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.roles-list > select.input.small {
  padding: 6px 8px;
  min-height: 32px;
  font-size: 13px;
  margin-bottom: 8px;
}

/* ---------- звуки в настройках, значки каналов ---------- */

.sound-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sound-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.sound-row:last-child {
  border-bottom: none;
}

.sound-info {
  flex: 1;
  min-width: 0;
}

.sound-label {
  color: var(--header);
  font-size: 14px;
}

.sound-file {
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sound-row .btn {
  gap: 4px;
}

.channel-flags {
  display: inline-flex;
  gap: 4px;
  color: var(--text-faint);
  margin-left: auto;
}

.channel-item .channel-flags + .badge {
  margin-left: 6px;
}

.guild-icon .guild-muted {
  position: absolute;
  left: -2px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-guilds);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- профиль: карточка и личный кабинет ---------- */

.profile-link {
  cursor: pointer;
}

.message-author.profile-link:hover {
  text-decoration: underline;
}

.profile-pop {
  width: 300px;
  background: var(--bg-floating);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.profile-pop.floating {
  position: fixed;
  z-index: 1000;
  animation: pop-in 0.18s var(--ease);
}

.profile-banner {
  height: 70px;
}

.profile-pop-avatar {
  position: absolute;
  top: 26px;
  left: 16px;
  padding: 5px;
  border-radius: 50%;
  background: var(--bg-floating);
}

.profile-pop-avatar .avatar {
  position: relative;
}

.profile-pop-body {
  padding: 46px 16px 16px;
}

.profile-pop-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--header);
  word-break: break-word;
}

.profile-pop-status {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.profile-pop-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.profile-pop-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.profile-pop-bio {
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  line-height: 1.4;
}

.profile-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.profile-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-input);
  font-size: 12px;
}

.profile-role .role-dot {
  width: 9px;
  height: 9px;
}

.profile-pop-actions {
  margin-top: 14px;
}

.profile-pop-actions .btn {
  gap: 6px;
}

.profile-editor {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 22px;
  align-items: start;
}

.profile-preview-col {
  position: sticky;
  top: 0;
}

.profile-preview .profile-pop {
  box-shadow: var(--shadow);
}

.bio-input {
  resize: vertical;
  min-height: 84px;
  font: inherit;
  line-height: 1.4;
}

.bio-counter {
  float: right;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.password-form {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.password-form h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--header);
  font-size: 16px;
}

.password-form .row .field {
  flex: 1;
}

.profile-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-card-actions .btn {
  gap: 6px;
}

@media (max-width: 760px) {
  .profile-editor {
    grid-template-columns: 1fr;
  }
}

.private-toggle .perm-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.role-pane-title + .field-hint {
  margin-top: 4px;
}

/* ---------- музыкальный бот ---------- */

.bot-avatar {
  background: linear-gradient(135deg, #a855f7, #ec4899 55%, #f59e0b);
  color: #fff;
}

.bot-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 5px;
  margin-left: 6px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.4;
  vertical-align: 2px;
  flex-shrink: 0;
}

.member .bot-badge,
.voice-user .bot-badge {
  margin-left: 0;
}

.bot-tile {
  background: linear-gradient(160deg, color-mix(in srgb, #a855f7 22%, var(--bg-tile)), var(--bg-tile));
}

.bot-tile .bot-cover {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(18px) brightness(0.55);
  transform: scale(1.15);
}

.bot-tile .tile-avatar {
  position: relative;
}

.bot-tile .bot-now {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
  font-weight: 500;
}

.equalizer {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
  opacity: 0;
  transition: opacity 0.3s;
}

.bot-tile.playing .equalizer {
  opacity: 1;
}

.equalizer span {
  width: 4px;
  height: 30%;
  border-radius: 2px;
  background: #fff;
  animation: eq 0.9s ease-in-out infinite;
}

.equalizer span:nth-child(2) {
  animation-delay: -0.3s;
}

.equalizer span:nth-child(3) {
  animation-delay: -0.6s;
}

.equalizer span:nth-child(4) {
  animation-delay: -0.15s;
}

@keyframes eq {
  0%,
  100% {
    height: 25%;
  }
  50% {
    height: 100%;
  }
}

.music-bar {
  margin: 0 16px 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.voice-lobby .music-bar {
  margin: 14px auto 0;
  max-width: 560px;
  width: 100%;
  text-align: left;
}

.music-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.music-cover {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.music-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
}

.music-bar.playing .music-cover {
  box-shadow: 0 0 0 2px color-mix(in srgb, #ec4899 60%, transparent);
}

.music-info {
  flex: 1;
  min-width: 0;
}

.music-title {
  color: var(--header);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-title.link {
  cursor: pointer;
}

.music-title.link:hover {
  text-decoration: underline;
}

.music-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 1px;
}

.music-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.music-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
}

.music-time:last-child {
  text-align: right;
}

.music-progress {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  overflow: hidden;
}

.music-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #ec4899);
  transition: width 0.5s linear;
}

.music-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.music-btn.active {
  color: var(--accent);
}

.music-vol {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  color: var(--text-muted);
}

.music-volume {
  width: 80px;
}

.music-add {
  margin-top: 8px;
}

.music-queue {
  margin: 8px 0 0;
  padding: 6px 8px 6px 30px;
  max-height: 160px;
  overflow-y: auto;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.music-queue li {
  padding: 3px 0;
}

.music-queue li > * {
  vertical-align: middle;
}

.music-queue .q-title {
  display: inline-block;
  max-width: calc(100% - 80px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-queue .q-time {
  color: var(--text-muted);
  margin: 0 6px;
  font-size: 12px;
}

.music-queue .chip-x {
  display: inline-flex;
}

.bot-help {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bot-help-row {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 10px;
  font-size: 14px;
}

.bot-help-row code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  align-self: start;
}

@media (max-width: 900px) {
  .music-volume {
    width: 50px;
  }
}

.music-vol-value {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 30px;
  font-variant-numeric: tabular-nums;
}

.music-vol.bot-vol {
  color: var(--accent);
}

/* ---------- горячие клавиши ---------- */

.hotkey-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hotkey-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hotkey-label {
  flex: 1;
  font-size: 14px;
}

.hotkey-key {
  min-width: 170px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--header);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.hotkey-key:hover {
  border-color: var(--accent);
}

.hotkey-key.empty {
  color: var(--text-faint);
  font-weight: 400;
}

.hotkey-key.recording {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  color: var(--accent);
  animation: pulse-border 1.2s ease-in-out infinite;
}

@keyframes pulse-border {
  50% {
    box-shadow: 0 0 0 5px var(--accent-soft);
  }
}

/* ---------- звонок: сворачивание участников и плеера, «перестать смотреть» ---------- */

.strip-toggle {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.strip-toggle:hover {
  color: var(--header);
  border-color: var(--border-strong);
}

.stage.focus .strip-toggle {
  margin: -4px 0;
}

.music-bar.collapsed {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 12px;
}

.music-mini-icon {
  display: flex;
  color: #ec4899;
}

.music-bar.collapsed.playing .music-mini-icon {
  animation: mini-note 1.2s ease-in-out infinite;
}

@keyframes mini-note {
  50% {
    transform: translateY(-2px) rotate(-8deg);
  }
}

.music-mini-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--header);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unwatched-streams {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px 0;
}

.unwatched-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.unwatched-chip .live {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
}

.unwatched-chip .chip-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

/* Настройки отдельной демонстрации: «заполнить плитку» и «только звук» */
.tile.screen-tile.fit-cover video {
  object-fit: cover;
}

.tile.screen-tile.audio-only {
  background: var(--bg-input);
}

.tile.screen-tile.audio-only .tile-avatar {
  flex-direction: column;
  gap: 10px;
  width: 100%;
  height: 100%;
}

.audio-only-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 12px;
  text-align: center;
}

/* ---------- рамки аватарок (ui/frames.js) ---------- */
.avatar-frame {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  pointer-events: none;
  overflow: visible;
}

/* только у анимированных частей (у остальных transform-атрибут считается от центра рамки) */
.avatar-frame [class^='fr-'],
.avatar-frame [class*=' fr-'] {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

/* маленькие аватарки в списках оживают при наведении */
.avatar-frame.still * {
  animation-play-state: paused !important;
}

:hover > .avatar > .avatar-frame.still *,
:hover > * > .avatar > .avatar-frame.still * {
  animation-play-state: running !important;
}

.fr-pulse { animation: fr-pulse 2.4s ease-in-out infinite; }
.fr-spin { animation: fr-spin 4s linear infinite; }
.fr-spin-slow { animation: fr-spin 18s linear infinite; }
.fr-spin-rev { animation: fr-spin 12s linear infinite reverse; }
.fr-orbit { animation: fr-spin 9s linear infinite; }
.fr-orbit-rev { animation: fr-spin 14s linear infinite reverse; }
.fr-shine { animation: fr-spin 3.2s linear infinite; }
.fr-flicker { animation: fr-flicker 0.45s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.fr-twinkle { animation: fr-twinkle 2s ease-in-out infinite; }
.fr-drip { animation: fr-drip 2.2s ease-in infinite; transform-origin: 50% 0; }
.fr-flash { animation: fr-flash 2.6s steps(1) infinite; }
.fr-bob { animation: fr-bob 1.8s ease-in-out infinite alternate; }
.fr-glitch { animation: fr-glitch 3s steps(1) infinite; }
.fr-sway { animation: fr-sway 2.4s ease-in-out infinite alternate; }
.fr-beat { animation: fr-beat 1.1s ease-in-out infinite; }
.fr-jaw-top { animation: fr-jaw-top 0.35s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.fr-jaw-bottom { animation: fr-jaw-bottom 0.35s ease-in-out infinite alternate; transform-origin: 50% 0; }

@keyframes fr-pulse { 50% { opacity: 0.55; } }
@keyframes fr-spin { to { transform: rotate(360deg); } }
@keyframes fr-flicker { from { transform: scale(0.85, 0.75); } to { transform: scale(1.1, 1.15); } }
@keyframes fr-twinkle { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.25; transform: scale(0.6); } }
@keyframes fr-drip { 0% { transform: translateY(0) scaleY(0.4); opacity: 1; } 80% { transform: translateY(4px) scaleY(1); opacity: 1; } 100% { transform: translateY(7px) scaleY(1); opacity: 0; } }
@keyframes fr-flash { 0%, 100% { opacity: 1; } 8% { opacity: 0.2; } 12% { opacity: 1; } 16% { opacity: 0.3; } 20% { opacity: 1; } }
@keyframes fr-bob { from { transform: translateY(-1.5px); } to { transform: translateY(1.5px); } }
@keyframes fr-glitch { 0%, 100% { transform: none; } 30% { transform: translate(1.5px, -1px); } 32% { transform: translate(-1.5px, 1px); } 34% { transform: none; } 70% { transform: rotate(8deg); } 72% { transform: none; } }
@keyframes fr-sway { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
@keyframes fr-beat { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.3); } }
@keyframes fr-jaw-top { from { transform: rotate(0deg); } to { transform: rotate(-30deg); } }
@keyframes fr-jaw-bottom { from { transform: rotate(0deg); } to { transform: rotate(30deg); } }

/* ---------- баннер «панельки» (можно гифку): строка в голосовом, в списке участников, панель внизу слева ---------- */
.has-panel-banner {
  background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.35) 70%, rgba(0, 0, 0, 0.15)), var(--panel-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-origin: border-box; /* картинка — точно по краю строки, без зазора */
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.has-panel-banner small,
.has-panel-banner .name,
.has-panel-banner .user-panel-name {
  color: #fff;
}

.has-panel-banner .icon-btn {
  color: #fff;
}

/* Наведение: общие правила :hover задают фон сокращённо (background: …) и сбрасывали размер и позицию
   картинки — она «улетала» в угол. Здесь всё задано полностью, а плавно меняется только затемнение. */
.voice-user.has-panel-banner,
.member.has-panel-banner {
  transition: none;
}

.voice-user.has-panel-banner:hover,
.member.has-panel-banner:hover,
.voice-user.has-panel-banner:active,
.member.has-panel-banner:active {
  background-color: transparent;
  background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.2) 70%, rgba(0, 0, 0, 0)), var(--panel-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Кнопки микрофона и звука на фоне-баннере: выключенное состояние хорошо видно на любой картинке */
.has-panel-banner .icon-btn.off {
  color: #fff;
  background: rgba(218, 55, 60, 0.9);
}

.has-panel-banner .icon-btn {
  background: rgba(0, 0, 0, 0.35);
}

.has-panel-banner .btn-group {
  border-radius: var(--radius-sm);
}

.has-panel-banner .state-icons {
  background: rgba(0, 0, 0, 0.45);
  border-radius: 999px;
  padding: 1px 4px;
  color: #fff;
}

.has-panel-banner .state-icons .server-muted,
.has-panel-banner .member-muted {
  color: #ff6b6e;
}

/* ---------- профили: тема, баннеры-картинки, чипы, полный профиль, личный кабинет ---------- */
.row.wrap {
  flex-wrap: wrap;
  margin: 8px 0 6px;
}

.profile-banner,
.profile-full-banner {
  background-size: cover;
  background-position: center;
}

.profile-pop .profile-banner {
  height: 96px;
}

.profile-pop .profile-pop-avatar {
  top: 52px;
}

.profile-pop .clickable,
.profile-full .clickable {
  cursor: pointer;
}

.profile-pop-name.clickable:hover {
  text-decoration: underline;
}

.profile-pop-avatar.clickable:hover .avatar {
  filter: brightness(1.08);
}

.profile-pop-bio.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-input);
  font-size: 12.5px;
  line-height: 1.3;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.profile-chip svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.profile-chip.more {
  color: var(--text-muted);
}

.profile-chip.editable {
  padding-right: 4px;
}

.profile-pop-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Тема профиля: градиент из двух цветов, содержимое — на тёмной подложке, текст светлый */
.profile-pop.themed,
.profile-full.themed {
  --header: #fff;
  --text: #eef0f3;
  --text-muted: rgba(255, 255, 255, 0.72);
  --border: rgba(255, 255, 255, 0.16);
  --bg-input: rgba(0, 0, 0, 0.32);
  color: var(--text);
  background: var(--pt-bg);
  border-color: color-mix(in srgb, var(--pt1) 60%, transparent);
}

/* «переливание»: градиент туда-обратно в два раза больше карточки плавно едет */
.profile-pop.themed.flowing,
.profile-full.themed.flowing {
  background-size: 200% 200%;
  animation: theme-flow 7s ease-in-out infinite alternate;
}

@keyframes theme-flow {
  from {
    background-position: 0% 0%;
  }
  to {
    background-position: 100% 100%;
  }
}

.profile-pop.themed .profile-pop-body {
  background: rgba(0, 0, 0, 0.42);
  margin: 0 8px 8px;
  border-radius: var(--radius);
  padding-top: 42px;
}

.profile-pop.themed .profile-pop-avatar,
.profile-full.themed .profile-full-avatar {
  background: color-mix(in srgb, var(--pt1) 80%, #000);
}

.profile-pop.themed .btn.secondary,
.profile-full.themed .btn.secondary {
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}

/* полный профиль */
.modal.profile-modal {
  width: 640px;
  padding: 0;
  position: relative;
  overflow-x: hidden;
}

.profile-full {
  background: var(--bg-modal);
  min-height: 100%;
  display: flow-root; /* отступ последнего блока не «выпадает» за градиент темы */
}

.profile-full-banner {
  height: 220px;
}

.profile-full-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  margin-top: -72px;
}

.profile-full-avatar {
  padding: 7px;
  border-radius: 50%;
  background: var(--bg-modal);
  display: flex;
}

.profile-full-actions {
  min-width: 190px;
  padding-bottom: 6px;
}

.profile-full-body {
  padding: 10px 24px 24px;
}

.profile-full.themed .profile-full-body {
  background: rgba(0, 0, 0, 0.42);
  margin: 12px 14px 14px;
  border-radius: var(--radius-lg);
  padding-top: 16px;
}

.profile-full-name {
  font-size: 26px;
  font-weight: 800;
  color: var(--header);
  display: flex;
  align-items: center;
  gap: 8px;
  word-break: break-word;
}

.profile-full-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 4px 22px;
  margin-top: 6px;
}

.profile-empty {
  margin-top: 16px;
  color: var(--text-muted);
  font-style: italic;
}

.profile-full-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

.profile-full-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

@media (max-width: 640px) {
  .profile-full-grid {
    grid-template-columns: 1fr;
  }
  .profile-full-head {
    flex-wrap: wrap;
  }
}

/* личный кабинет */
.profile-tab-body {
  min-height: 300px;
}

.profile-tab .field {
  margin-bottom: 16px;
}

.chips-field .chips-edit:not(:empty) {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.chips-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chips-counter {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.theme-swatch {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid transparent;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}

.theme-swatch:hover {
  transform: scale(1.08);
}

.theme-swatch.active {
  border-color: var(--header);
  box-shadow: 0 0 0 2px var(--accent);
}

.theme-swatch.none {
  background: repeating-linear-gradient(45deg, var(--bg-input), var(--bg-input) 5px, var(--bg-elevated) 5px, var(--bg-elevated) 10px);
}

.theme-custom {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-input);
}

.color-input {
  width: 30px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.panel-preview {
  max-width: 260px;
  border-radius: var(--radius);
  background: var(--bg-sidebar);
  padding: 6px;
}

.frame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.frame-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 4px 8px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--bg-input);
  font-size: 12px;
  color: var(--text-muted);
  transition: border-color 0.15s, background 0.15s;
}

.frame-option:hover {
  background: var(--bg-hover);
  color: var(--header);
}

.frame-option.active {
  border-color: var(--accent);
  color: var(--header);
}

/* редактор «Баннер и тема профиля» */
.look-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.look-editor > .segmented {
  align-self: flex-start;
}

.look-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-input);
}

.color-slots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-slot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

.color-slot.active {
  border-color: var(--accent);
}

.color-slot-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, 26px);
  gap: 6px;
}

.palette .swatch.custom {
  position: relative;
  background: conic-gradient(#ef4444, #facc15, #22c55e, #06b6d4, #3b82f6, #a855f7, #ec4899, #ef4444);
  overflow: hidden;
}

.custom-color-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

.look-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.look-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  min-width: 96px;
}

.look-value {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 70px;
}

.balance-range {
  flex: 1;
  min-width: 120px;
  height: 8px;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

.balance-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.balance-end {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.look-image {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.look-image .row.wrap {
  margin-top: 4px;
}

/* ---------- своя тема: анимированный фон под интерфейсом (ui/theme.js) ---------- */
html[data-theme-id='custom'] body,
html[data-theme-id='beach'] body {
  background: transparent; /* фон рисует html и слои под интерфейсом */
}

#theme-fx {
  position: fixed;
  inset: 0;
  z-index: -2; /* эффекты фона (#bg-effects, z-index: -1) — поверх него */
  overflow: hidden;
  pointer-events: none;
  background: var(--fx-c1);
}

#theme-fx > div {
  position: absolute;
  display: none;
}

#theme-fx .fx-base {
  display: block;
  inset: 0;
  background: var(--fx-grad);
}

/* когда окно не в фокусе (игра поверх) — всё замирает */
.fx-paused #theme-fx *,
.fx-paused #theme-fx,
.fx-paused #bg-effects * {
  animation-play-state: paused !important;
}

/* Переливание: градиент «туда-обратно» вдвое больше экрана медленно едет по направлению */
#theme-fx.fx-flow .fx-base {
  inset: -50%;
  background: var(--fx-grad-mirror);
  animation: fx-flow calc(18s * var(--fx-k)) ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes fx-flow {
  from { transform: translate(calc(var(--fx-dx) * -1), calc(var(--fx-dy) * -1)); }
  to { transform: translate(var(--fx-dx), var(--fx-dy)); }
}

/* Дыхание: цвета плавно меняются местами */
#theme-fx.fx-breathe .fx-a {
  display: block;
  inset: 0;
  background: var(--fx-grad-rev);
  animation: fx-fade calc(9s * var(--fx-k)) ease-in-out infinite alternate;
  will-change: opacity;
}

@keyframes fx-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Радуга: оттенок всего фона идёт по кругу */
#theme-fx.fx-hue .fx-base {
  animation: fx-hue calc(30s * var(--fx-k)) linear infinite;
  will-change: filter;
}

@keyframes fx-hue {
  to { filter: hue-rotate(360deg); }
}

/* Сияние: большие мягкие пятна двух цветов плавают по тёмному фону */
#theme-fx.fx-aurora .fx-base {
  background: linear-gradient(var(--fx-angle), color-mix(in srgb, var(--fx-c1) 30%, #050507), color-mix(in srgb, var(--fx-c2) 30%, #050507));
}

#theme-fx.fx-aurora .fx-a,
#theme-fx.fx-aurora .fx-b,
#theme-fx.fx-aurora .fx-c {
  display: block;
  width: 75vmax;
  height: 75vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--blob), transparent);
  opacity: 0.8;
  will-change: transform;
}

#theme-fx.fx-aurora .fx-a { --blob: var(--fx-c1); left: -25vmax; top: -30vmax; animation: fx-drift-a calc(24s * var(--fx-k)) ease-in-out infinite alternate; }
#theme-fx.fx-aurora .fx-b { --blob: var(--fx-c2); right: -30vmax; top: 5vmax; animation: fx-drift-b calc(30s * var(--fx-k)) ease-in-out infinite alternate; }
#theme-fx.fx-aurora .fx-c { --blob: var(--fx-mix); left: 15vmax; bottom: -40vmax; animation: fx-drift-c calc(36s * var(--fx-k)) ease-in-out infinite alternate; }

@keyframes fx-drift-a { to { transform: translate(35vmax, 25vmax) scale(1.25); } }
@keyframes fx-drift-b { to { transform: translate(-40vmax, 20vmax) scale(0.8); } }
@keyframes fx-drift-c { to { transform: translate(20vmax, -35vmax) scale(1.15); } }

/* Вихрь: два цвета крутятся вокруг центра */
#theme-fx.fx-spin .fx-a {
  display: block;
  width: 220vmax;
  height: 220vmax;
  left: 50%;
  top: 50%;
  margin: -110vmax 0 0 -110vmax;
  background: conic-gradient(from 0deg, var(--fx-c1), var(--fx-c2), var(--fx-c1), var(--fx-c2), var(--fx-c1));
  animation: fx-spin calc(45s * var(--fx-k)) linear infinite;
  will-change: transform;
}

#theme-fx.fx-spin .fx-b {
  display: block;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, transparent 0, rgba(0, 0, 0, 0.25) 100%);
}

@keyframes fx-spin {
  to { transform: rotate(360deg); }
}

/* Волны: полупрозрачные полосы второго и первого цвета плывут навстречу */
#theme-fx.fx-waves .fx-a,
#theme-fx.fx-waves .fx-b {
  display: block;
  top: 0;
  bottom: 0;
  left: -50%;
  width: 200%;
  will-change: transform;
}

#theme-fx.fx-waves .fx-a {
  background: repeating-linear-gradient(100deg, transparent 0 80px, color-mix(in srgb, var(--fx-c2) 32%, transparent) 150px, transparent 220px);
  animation: fx-wave calc(14s * var(--fx-k)) ease-in-out infinite alternate;
}

#theme-fx.fx-waves .fx-b {
  background: repeating-linear-gradient(75deg, transparent 0 120px, color-mix(in srgb, var(--fx-c1) 28%, transparent) 200px, transparent 280px);
  animation: fx-wave calc(19s * var(--fx-k)) ease-in-out infinite alternate-reverse;
}

@keyframes fx-wave {
  from { transform: translateX(-12%); }
  to { transform: translateX(12%); }
}

/* Звёзды: мерцающие точки в цветах темы медленно плывут вверх */
#theme-fx.fx-stars .fx-base {
  background: linear-gradient(var(--fx-angle), color-mix(in srgb, var(--fx-c1) 40%, #04040a), color-mix(in srgb, var(--fx-c2) 40%, #04040a));
}

#theme-fx.fx-stars .fx-stars {
  display: block;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  border-radius: 50%;
  will-change: transform, opacity;
}

#theme-fx.fx-stars .s1 { animation: fx-rise-stars calc(120s * var(--fx-k)) linear infinite, fx-twinkle 3s ease-in-out infinite alternate; }
#theme-fx.fx-stars .s2 { animation: fx-rise-stars calc(70s * var(--fx-k)) linear infinite, fx-twinkle 2.2s ease-in-out infinite alternate-reverse; }

@keyframes fx-rise-stars {
  from { transform: translateY(0); }
  to { transform: translateY(-100vh); }
}

@keyframes fx-twinkle {
  from { opacity: 1; }
  to { opacity: 0.35; }
}

/* Пузыри: прозрачные шарики цветов темы всплывают снизу */
#theme-fx.fx-bubbles .fx-bubbles {
  display: block;
  inset: 0;
}

#theme-fx .fx-bubbles span {
  position: absolute;
  bottom: -160px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.55), color-mix(in srgb, var(--bc) 45%, transparent) 45%, color-mix(in srgb, var(--bc) 15%, transparent) 68%, transparent 71%);
  animation: fx-bubble calc(var(--d) * var(--fx-k)) linear infinite;
  animation-delay: var(--delay);
  will-change: transform;
}

@keyframes fx-bubble {
  0% { transform: translate(0, 0); }
  25% { transform: translate(18px, -32vh); }
  50% { transform: translate(-14px, -64vh); }
  75% { transform: translate(14px, -96vh); }
  100% { transform: translate(0, calc(-100vh - 320px)); }
}

/* карточка «Своя» и её настройки */
.theme-preview.custom-preview {
  position: relative;
}

.custom-theme-editor {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
}

.fx-option {
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.fx-option:hover {
  border-color: var(--border-strong);
}

.fx-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- эффекты фона (ui/bg-effects.js) ---------- */
#bg-effects {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* у тем с непрозрачными панелями — поверх окна, приглушённо (ниже окон и меню) */
#bg-effects.over {
  z-index: 50;
  opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
  #bg-effects {
    display: none;
  }
}

#bg-effects span {
  position: absolute;
  display: block;
  will-change: transform, opacity;
}

/* кометы: хвост-градиент и яркая голова, летят по диагонали, потом пауза */
.fx-p-comets span {
  left: var(--x);
  top: var(--y);
  width: var(--len);
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--c) 60%, transparent) 60%, #fff);
  filter: drop-shadow(0 0 4px var(--c));
  opacity: 0;
  animation: fx-comet var(--d) linear infinite var(--delay);
}

.fx-p-comets span::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 14px 5px var(--c), 0 0 4px 1px #fff;
}

@keyframes fx-comet {
  0% { transform: rotate(var(--a)) translateX(0); opacity: 0; }
  2% { opacity: 1; }
  12% { opacity: 1; }
  16% { transform: rotate(var(--a)) translateX(115vmax); opacity: 0; }
  100% { transform: rotate(var(--a)) translateX(115vmax); opacity: 0; }
}

/* снег */
.fx-p-snow span {
  left: var(--x);
  top: -10px;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: #fff;
  opacity: var(--o);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
  animation: fx-fall var(--d) linear infinite var(--delay);
}

@keyframes fx-fall {
  0% { transform: translate(0, -5vh); }
  50% { transform: translate(var(--sway), 50vh); }
  100% { transform: translate(0, 110vh); }
}

/* светлячки: бродят и мерцают */
.fx-p-fireflies span {
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px 3px var(--c);
  animation: fx-wander var(--d) ease-in-out infinite alternate var(--delay), fx-blink var(--blink) ease-in-out infinite alternate var(--delay);
}

@keyframes fx-wander {
  0% { transform: translate(0, 0); }
  33% { transform: translate(var(--dx), calc(var(--dy) * -0.5)); }
  66% { transform: translate(calc(var(--dx) * -0.6), var(--dy)); }
  100% { transform: translate(calc(var(--dx) * 0.4), calc(var(--dy) * -1)); }
}

@keyframes fx-blink {
  from { opacity: 0.15; }
  to { opacity: 1; }
}

/* дождь: косые капли */
.fx-p-rain span {
  left: var(--x);
  top: -40px;
  width: 1.5px;
  height: var(--len);
  background: linear-gradient(transparent, rgba(174, 214, 255, 0.9));
  opacity: var(--o);
  animation: fx-rain var(--d) linear infinite var(--delay);
}

@keyframes fx-rain {
  from { transform: translate(0, 0) rotate(12deg); }
  to { transform: translate(-24vh, 112vh) rotate(12deg); }
}

/* искры: поднимаются снизу и гаснут */
.fx-p-embers span {
  left: var(--x);
  bottom: -10px;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 8px 2px var(--c);
  opacity: 0;
  animation: fx-ember var(--d) ease-out infinite var(--delay);
}

@keyframes fx-ember {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  50% { transform: translate(var(--sway), -50vh); }
  100% { transform: translate(calc(var(--sway) * -0.5), -100vh); opacity: 0; }
}

/* лепестки: кружатся и падают */
.fx-p-petals span {
  left: var(--x);
  top: -20px;
  width: var(--s);
  height: calc(var(--s) * 0.7);
  border-radius: 100% 0 100% 0;
  background: var(--c);
  opacity: 0.9;
  animation: fx-petal var(--d) linear infinite var(--delay);
}

@keyframes fx-petal {
  0% { transform: translate(0, -5vh) rotate(0deg); }
  50% { transform: translate(var(--sway), 50vh) rotate(calc(var(--spin) * 0.5)); }
  100% { transform: translate(calc(var(--sway) * -0.3), 110vh) rotate(var(--spin)); }
}

/* конфетти */
.fx-p-confetti span {
  left: var(--x);
  top: -20px;
  width: var(--s);
  height: calc(var(--s) * 0.45);
  border-radius: 1px;
  background: var(--c);
  animation: fx-confetti var(--d) linear infinite var(--delay);
}

@keyframes fx-confetti {
  0% { transform: translate(0, -5vh) rotate(0deg) scaleX(1); }
  25% { transform: translate(calc(var(--sway) * 0.5), 25vh) rotate(calc(var(--spin) * 0.25)) scaleX(-1); }
  50% { transform: translate(var(--sway), 50vh) rotate(calc(var(--spin) * 0.5)) scaleX(1); }
  75% { transform: translate(calc(var(--sway) * 0.3), 80vh) rotate(calc(var(--spin) * 0.75)) scaleX(-1); }
  100% { transform: translate(0, 110vh) rotate(var(--spin)) scaleX(1); }
}

/* ---------- модерация: категории прав, настройки сервера, баны, журнал, закрепы, перетаскивание ---------- */
.role-pane {
  overflow-anchor: none;
}

.perm-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
}

.perm-group-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--header);
  margin-bottom: 6px;
}

.perm-group .perm-list {
  margin-top: 0;
}

.modal.server-settings {
  width: 860px;
}

.modal.server-settings .tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.server-settings-hint {
  margin: -4px 0 12px;
}

.server-settings-body {
  min-height: 420px;
}

.empty-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 0;
  color: var(--text-muted);
}

.ban-list,
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

.ban-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-input);
}

.ban-info {
  flex: 1;
  min-width: 0;
}

.ban-name {
  font-weight: 700;
  color: var(--header);
}

.ban-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.audit-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-size: 13.5px;
}

.audit-icon {
  display: flex;
  color: var(--accent);
  margin-top: 1px;
}

.audit-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  user-select: text;
}

.audit-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.mute-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  background: var(--bg-input);
  border-radius: var(--radius);
}

.composer-disabled.muted-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--red);
}

.profile-pop-username {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: -2px;
}

.avatar-field {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* закреплённые */
.message.pinned {
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--yellow) 70%, transparent);
}

.message-pinned {
  display: inline-flex;
  color: var(--yellow);
  align-self: center;
}

.message-pinned.side {
  position: absolute;
  left: 6px;
  top: 6px;
}

.pins-panel {
  position: fixed;
  z-index: 1000;
  width: 380px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-floating);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.15s var(--ease);
}

.pins-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-weight: 700;
  color: var(--header);
  border-bottom: 1px solid var(--border);
}

.pins-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pin-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--bg-input);
}

.pin-body {
  flex: 1;
  min-width: 0;
}

.pin-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  color: var(--text-muted);
}

.pin-meta b {
  color: var(--header);
  font-size: 14px;
}

.pin-text {
  font-size: 13.5px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.pin-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

/* перетаскивание участников между голосовыми каналами */
.voice-user.draggable {
  cursor: grab;
}

.voice-user.draggable:active {
  cursor: grabbing;
}

.dragging-member .voice-channel-block {
  border-radius: var(--radius-sm);
  outline: 1px dashed transparent;
  transition: outline-color 0.12s, background 0.12s;
}

.dragging-member .voice-channel-block:not(.drop-target) {
  outline-color: var(--border-strong);
}

.voice-channel-block.drop-target {
  outline: 2px solid var(--accent);
  background: var(--accent-soft);
}

/* где сработает бинд: «везде» (в других программах и играх) или «в окне» */
.hotkey-scope {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg-input);
  color: var(--text-muted);
}

.hotkey-scope.global {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, transparent);
}

.hotkey-scope.busy {
  color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 14%, transparent);
}

/* ---------- аккаунт: логин и ID ---------- */
.id-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 600 12px/1.4 ui-monospace, Consolas, monospace;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  padding: 1px 4px 1px 6px;
  user-select: text;
}
.id-copy {
  display: inline-flex;
  background: none;
  border: 0;
  padding: 2px;
  color: inherit;
  cursor: pointer;
  border-radius: 3px;
}
.id-copy:hover {
  color: var(--header);
  background: rgba(255, 255, 255, 0.08);
}
.profile-id-row {
  margin-top: 2px;
}
.my-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 14px;
}
.account-login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--header);
}
.account-subtitle {
  margin: 18px 0 8px;
  color: var(--header);
}
.link-button {
  background: none;
  border: 0;
  color: var(--text-link, #00a8fc);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  margin-top: 10px;
}
.link-button:hover {
  text-decoration: underline;
}
.login-other-server {
  display: block;
  margin: 12px auto 0;
}

/* ---------- свои серверы и лимиты каналов ---------- */
.guild-create {
  color: var(--green, #23a55a);
}
.guild-create:hover {
  background: var(--green, #23a55a);
  color: #fff;
}
.guild-create.disabled {
  opacity: 0.4;
}
.guild-create.disabled:hover {
  background: var(--bg-elevated);
  color: var(--green, #23a55a);
}
.channel-count {
  margin-left: auto;
  margin-right: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.channel-count.full {
  color: var(--red, #f23f43);
}
.group-add:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.id-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.id-block .id-badge {
  font-size: 15px;
  padding: 4px 6px 4px 10px;
}

/* ---------- пользовательское соглашение ---------- */
.terms-body {
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 12px 4px 0;
  margin: 8px 0 12px;
  font-size: 14px;
  line-height: 1.5;
}
.terms-body h4 {
  margin: 14px 0 4px;
  color: var(--header);
}
.terms-body section:first-child h4 {
  margin-top: 0;
}
.terms-body p {
  margin: 0;
  color: var(--text);
}
.terms-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  margin: 10px 0 4px;
}
.terms-check input {
  margin-top: 3px;
  flex: none;
}
.terms-check .link-button {
  margin: 0;
  font-size: inherit;
}
.login-terms-link {
  display: block;
  margin: 8px auto 0;
  font-size: 12px;
}

/* ======================================================================
   Телефон и узкие окна (веб-версия и приложение для Android)
   ====================================================================== */
.m-btn,
.m-backdrop {
  display: none;
}

/* Сенсорный экран: действия с сообщением — по касанию (класс touch-active), а не при наведении */
.touch .message.touch-active .message-actions {
  display: flex;
}

@media (max-width: 768px) {
  html,
  body {
    overscroll-behavior: none;
  }
  .app {
    height: 100dvh;
    position: relative;
    overflow: hidden;
  }

  /* Колонка серверов + список каналов — выдвижная панель слева */
  .guilds,
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 60;
    transition: transform 0.22s var(--ease);
    padding-top: env(safe-area-inset-top);
  }
  .guilds {
    left: 0;
    transform: translateX(-100%);
  }
  .sidebar {
    left: 72px;
    width: min(300px, calc(100vw - 72px - 40px));
    border-radius: 0;
    transform: translateX(calc(-100% - 72px));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app.nav-open .guilds,
  .app.nav-open .sidebar {
    transform: none;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.35);
  }

  /* Участники — панель справа */
  .members {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: min(300px, 85vw);
    transform: translateX(100%);
    transition: transform 0.22s var(--ease);
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  .app.members-open .members {
    transform: none;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
  }

  .m-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .app.nav-open .m-backdrop,
  .app.members-open .m-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Чат — на весь экран */
  .main {
    width: 100%;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .topbar {
    padding: 0 52px 0 52px;
    overflow: hidden;
    white-space: nowrap;
  }
  .m-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: calc(6px + env(safe-area-inset-top));
    z-index: 5;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--header);
  }
  .m-btn:active {
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
  }
  .m-nav-btn {
    left: 6px;
  }
  .m-members-btn {
    right: 6px;
    display: none;
  }
  .app:has(#members:not([hidden])) .m-members-btn {
    display: flex;
  }
  .app:has(#members[hidden]) .topbar {
    padding-right: 12px;
  }

  /* Крупнее для пальца */
  .channel-item {
    min-height: 40px;
  }
  .composer textarea,
  input.input,
  select.input,
  textarea.input,
  .add-friend-form input {
    font-size: 16px; /* меньше 16px — iPhone увеличивает страницу при вводе */
  }
  .message-actions {
    right: 8px;
  }

  /* Окна — на весь экран */
  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .modal,
  .modal.wide {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: 0;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  }
  .modal-actions {
    flex-wrap: wrap;
  }
  .profile-editor {
    grid-template-columns: 1fr;
  }
  .row {
    flex-wrap: wrap;
  }
  .profile-modal .modal,
  .modal.profile-modal {
    padding: 0;
  }

  /* Контекстные меню (долгое нажатие) — не вылезают за экран */
  .context-menu {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }
  .context-menu button {
    min-height: 40px;
  }

  /* Друзья: вкладки прокручиваются */
  .friends-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  /* Звонок: плитки в одну-две колонки, кнопки крупнее */
  .voice-controls {
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .update-banner {
    flex-wrap: wrap;
  }

  /* Экран входа */
  .login-screen {
    padding: 12px;
    align-items: flex-start;
    overflow-y: auto;
  }
  .login-card {
    width: 100%;
    max-width: 440px;
    margin: 48px auto 24px;
  }
  .login-lang {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
  }
}
#bg-effects .fx-group {
  display: contents;
}
