/* ============================================================
   NEXORA v10.0 — единый style.css
   База + этап 1 + этап 2 + этап 4 + этап 5 + v10 кастомизации:
   - animated badges (SVG / GIF / PNG)
   - custom name color, title, avatar pulse
   - msg text effects, bubble styles, chat bg patterns
   - call overlay + voice community stage
   - SVG catalog modal
   - 5 new base themes hook classes
   - compact sidebar mode, profile music, animated activity
   ============================================================ */

:root {
  --bg-0: #0a0a0f;
  --bg-1: #12121a;
  --bg-2: #1a1a24;
  --bg-3: #23232f;
  --border: #2a2a38;
  --border-l: #35354a;
  --text-0: #ffffff;
  --text-1: #c9c9d6;
  --text-2: #8a8a9c;
  --text-3: #5a5a70;
  --accent: #7c5cff;
  --accent-h: #9375ff;
  --accent-dim: rgba(124, 92, 255, 0.15);
  --success: #3ddc84;
  --error: #ff5a6e;
  --warning: #ffb547;
  --info: #4da6ff;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 30px rgba(124,92,255,0.35);
  --t: 0.2s cubic-bezier(.4,0,.2,1);
  --msg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bubble-radius: 16px;
  --bubble-tail: 4px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-0);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background 0.25s, color 0.25s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

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

input, textarea, select {
  font-family: inherit; font-size: 14px;
  color: var(--text-0);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none; width: 100%;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-l); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.screen {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  opacity: 0; transition: opacity 0.25s;
}
.screen.active { display: flex; opacity: 1; }
.hidden { display: none !important; }

/* ---------- Boot ---------- */
#screen-boot {
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, rgba(124,92,255,0.15), transparent 60%), var(--bg-0);
}
.boot-logo {
  font-size: 56px; font-weight: 800; letter-spacing: 8px;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 60%, #4da6ff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: bootGlow 2s ease-in-out infinite;
}
@keyframes bootGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}
.boot-tagline { color: var(--text-3); font-size: 14px; letter-spacing: 2px; margin-top: 6px; }

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border-l);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  transition: all var(--t); white-space: nowrap; user-select: none;
  border: 1px solid transparent;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.35) 0%, transparent 70%);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.btn:active::after { opacity: 1; transition: opacity 0s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-1); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--border-l); color: var(--text-0); }
.btn-danger { background: transparent; color: var(--error); border-color: rgba(255,90,110,0.4); }
.btn-danger:hover { background: rgba(255,90,110,0.1); }
.btn-block { width: 100%; }
.btn-full { width: 100%; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 16px;
  transition: all var(--t);
  position: relative;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text-0); transform: scale(1.06); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg {
  width: 20px; height: 20px; display: block; pointer-events: none;
}
.send-btn svg { width: 20px; height: 20px; display: block; }
.quick-action-btn .qa-icon svg { width: 18px; height: 18px; display: block; }
.quick-action-btn .qa-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
}

/* ---------- Auth ---------- */
#screen-auth {
  align-items: center; justify-content: center; overflow-y: auto;
  background: radial-gradient(ellipse at top, rgba(124,92,255,0.15), transparent 60%), var(--bg-0);
  padding: 20px;
}
.auth-wrap { width: 100%; max-width: 420px; position: relative; z-index: 1; }
.auth-card {
  background: var(--bg-1);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow);
  animation: scaleIn 0.35s cubic-bezier(.4,0,.2,1);
}
.auth-logo {
  text-align: center; font-size: 34px; font-weight: 800; letter-spacing: 4px;
  background: linear-gradient(135deg, var(--text-0) 0%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-tagline {
  text-align: center; color: var(--text-2); font-size: 13px;
  letter-spacing: 0.5px; margin: 6px 0 28px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label {
  font-size: 11px; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 1px;
}
.form-group small { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.form-error {
  display: none;
  background: rgba(255,90,110,0.1);
  border: 1px solid rgba(255,90,110,0.3);
  color: var(--error);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}
.form-error.show { display: block; animation: shake 0.4s; }
.auth-row { display: flex; gap: 10px; margin-top: 14px; }
.auth-row .btn { flex: 1; }
.mfa-input {
  font-size: 24px; letter-spacing: 8px; text-align: center;
  font-family: ui-monospace, monospace; padding: 14px;
}
.muted { color: var(--text-2); font-size: 13px; text-align: center; margin-bottom: 18px; }

@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 320px 1fr; height: 100%; background: var(--bg-0); }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.header-actions { display: flex; gap: 4px; align-items: center; }
.brand {
  font-size: 18px; font-weight: 800; letter-spacing: 3px;
  background: linear-gradient(135deg, var(--text-0) 0%, var(--accent) 60%, #4da6ff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex; align-items: center;
}
.brand-logo-svg { animation: brandFloat 3s ease-in-out infinite; }
@keyframes brandFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(3deg); }
}
.sidebar-search { padding: 12px 16px; border-bottom: 1px solid var(--border); }

.sidebar-tabs {
  display: flex; padding: 8px 12px 0; gap: 4px;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 10px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all var(--t); position: relative;
}
.tab:hover { color: var(--text-0); background: var(--bg-2); }
.tab.active { color: var(--accent); }
.tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 10%; right: 10%;
  height: 2px; background: var(--accent); border-radius: 2px;
  animation: tabSlide 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes tabSlide { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.sidebar-list { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }

.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t), transform 0.15s;
  position: relative;
}
.list-item:hover { background: var(--bg-2); transform: translateX(2px); }
.list-item.active { background: var(--accent-dim); box-shadow: inset 0 0 0 1px var(--accent); }
.list-item[data-saved="1"] .avatar {
  background: linear-gradient(135deg, #ffb547, #ff8a3d) !important;
}
.list-item[data-notif="1"] .avatar {
  background: linear-gradient(135deg, #4da6ff, #7c5cff) !important;
}
.list-item-body { flex: 1; min-width: 0; }
.list-item-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--text-0);
}
.list-item-title .time { font-size: 11px; color: var(--text-3); font-weight: 400; }
.list-item-sub {
  font-size: 13px; color: var(--text-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item-sub em { color: var(--accent); font-style: italic; font-weight: 500; }

/* Компактный список */
.sidebar-list.compact .list-item { padding: 6px 10px; }
.sidebar-list.compact .list-item-title { font-size: 13px; }
.sidebar-list.compact .list-item-sub { font-size: 11px; }
.sidebar-list.compact .avatar-md { width: 32px; height: 32px; font-size: 12px; }

.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-3); font-size: 13px; line-height: 1.6;
}

.sidebar-quick-actions {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px 4px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  flex-shrink: 0;
  max-height: 200px;
  overflow-y: auto;
}
.quick-action-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  background: transparent; color: var(--text-1);
  font-size: 13px; font-weight: 600;
  text-align: left; transition: background 0.15s, color 0.15s, transform 0.15s;
  border: none; cursor: pointer;
}
.quick-action-btn:hover { background: var(--accent-dim); color: var(--text-0); transform: translateX(3px); }
.quick-action-btn:hover .qa-icon svg { animation: qaWiggle 0.5s ease; }
@keyframes qaWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-1);
}
.sidebar-footer-body { flex: 1; min-width: 0; }
.sidebar-footer-name { font-size: 13px; font-weight: 600; color: var(--text-0); display: flex; align-items: center; gap: 6px; }
.sidebar-footer-id { font-size: 11px; color: var(--text-3); font-family: ui-monospace, monospace; }

/* ---------- Avatars ---------- */
.avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4d3fbf);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; overflow: hidden; flex-shrink: 0; user-select: none;
  background-size: cover; background-position: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.avatar:hover { transform: scale(1.06); }
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-md { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg { width: 72px; height: 72px; font-size: 26px; }
.avatar-xl { width: 110px; height: 110px; font-size: 40px; }

.avatar-wrap { position: relative; display: inline-block; }
.avatar-wrap .online-dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg-1);
  box-shadow: 0 0 8px rgba(61,220,132,0.7);
}
.avatar.online-glow {
  box-shadow: 0 0 0 2px rgba(61,220,132,0.4), 0 0 16px rgba(61,220,132,0.5);
  animation: onlinePulse 2.4s ease-in-out infinite;
}
@keyframes onlinePulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(61,220,132,0.4), 0 0 12px rgba(61,220,132,0.35); }
  50%      { box-shadow: 0 0 0 3px rgba(61,220,132,0.6), 0 0 22px rgba(61,220,132,0.55); }
}

/* Пульсация аватара (для пользователя) */
.avatar-pulse { animation: avatarPulse 1.8s ease-in-out infinite; }
@keyframes avatarPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(124,92,255,0.6); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 8px rgba(124,92,255,0); }
}

/* ---------- Значок рядом с именем ---------- */
.name-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 6px;
  vertical-align: -3px;
  flex-shrink: 0;
  animation: badgeFloat 2s ease-in-out infinite;
}
.name-badge img,
.name-badge svg {
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 4px;
}
@keyframes badgeFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(4deg); }
}

/* ---------- Кастомный цвет имени и титул ---------- */
.name-colored { font-weight: 700; }
.name-title {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; margin-left: 6px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #4da6ff);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  animation: titleShine 3s linear infinite;
  background-size: 200% 100%;
}
@keyframes titleShine {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ---------- Main ---------- */
.main { position: relative; display: flex; flex-direction: column; overflow: hidden; }

.welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px;
}
.welcome-logo {
  font-size: 64px; font-weight: 800; letter-spacing: 8px;
  background: linear-gradient(135deg, var(--text-0) 0%, var(--accent) 50%, #4da6ff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
  animation: welcomeGlow 4s ease-in-out infinite;
}
@keyframes welcomeGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}
.welcome-tagline {
  font-size: 14px; color: var(--text-3); letter-spacing: 2px; text-transform: uppercase;
}
.welcome-hint { margin-top: 24px; font-size: 13px; color: var(--text-3); }

/* ---------- Chat ---------- */
.chat-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}
.chat-header-body { flex: 1; min-width: 0; cursor: pointer; }
.chat-header-name {
  font-size: 15px; font-weight: 700; color: var(--text-0);
  display: flex; align-items: center; gap: 8px;
}
.chat-header-sub {
  font-size: 12px; color: var(--text-3);
  font-family: ui-monospace, monospace; margin-top: 2px;
}
.chat-header-sub.typing {
  color: var(--accent); font-style: italic;
  animation: typingBlink 1.4s ease-in-out infinite;
}
@keyframes typingBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
.online-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--text-3);
}
.online-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(61,220,132,0.6); }

/* Кнопки звонка в шапке */
#btn-call-audio:hover { color: var(--success); }
#btn-call-video:hover { color: var(--accent); }

.messages {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
  scroll-behavior: smooth;
  position: relative;
}

/* Фон под сообщениями */
.messages-bg-dots {
  background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 18px 18px;
}
.messages-bg-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}
.messages-bg-stripes {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255,255,255,0.02) 0 10px,
    transparent 10px 20px
  );
}
.messages-bg-hearts {
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,90,110,0.06) 2px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(255,90,110,0.06) 2px, transparent 2px),
    radial-gradient(circle at 40% 80%, rgba(255,90,110,0.06) 2px, transparent 2px);
  background-size: 60px 60px;
}

.msg-row {
  display: flex; gap: 10px; max-width: 68%;
  animation: msgPop 0.22s cubic-bezier(.4,0,.2,1);
  font-family: var(--msg-font);
}
.msg-row.own { margin-left: auto; flex-direction: row-reverse; }
@keyframes msgPop {
  from { transform: translateY(8px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.msg-bubble {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--bubble-radius);
  padding: 10px 14px;
  font-size: 14px; line-height: 1.5; color: var(--text-0);
  word-wrap: break-word; overflow-wrap: break-word; word-break: break-word;
  position: relative; min-width: 70px;
  font-family: var(--msg-font);
}
.msg-row.own .msg-bubble {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000));
  border-color: transparent; color: #fff;
  border-bottom-right-radius: var(--bubble-tail);
}
.msg-row:not(.own) .msg-bubble { border-bottom-left-radius: var(--bubble-tail); }

/* Стиль бабблов */
.messages.bubbles-square .msg-bubble { border-radius: 6px; }
.messages.bubbles-minimal .msg-bubble {
  border-radius: 12px;
  border: none;
  background: var(--bg-1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.messages.bubbles-minimal .msg-row.own .msg-bubble {
  box-shadow: 0 2px 8px var(--accent-dim);
}

.msg-sender { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.msg-meta { display: flex; justify-content: flex-end; gap: 6px; font-size: 11px; margin-top: 4px; opacity: 0.75; }
.msg-edited { font-style: italic; }

.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble del { text-decoration: line-through; opacity: 0.85; }
.msg-bubble code {
  background: rgba(0,0,0,0.3); padding: 1px 6px; border-radius: 6px;
  font-family: ui-monospace, monospace; font-size: 12.5px;
}
.msg-row:not(.own) .msg-bubble code { background: rgba(255,255,255,0.08); }
.msg-bubble blockquote {
  border-left: 3px solid currentColor; padding-left: 10px;
  margin: 4px 0; opacity: 0.9;
}
.msg-bubble a { color: inherit; text-decoration: underline; }

/* Эффекты текста в сообщениях */
.msg-effect-glow {
  text-shadow: 0 0 6px currentColor, 0 0 12px currentColor;
}
.msg-effect-rainbow {
  background: linear-gradient(90deg, #ff5a6e, #ffb547, #3ddc84, #4da6ff, #7c5cff, #ff5a6e);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbowShift 3s linear infinite;
}
@keyframes rainbowShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.msg-effect-shimmer {
  background: linear-gradient(90deg, #fff 0%, #fff 40%, #7c5cff 50%, #fff 60%, #fff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmerMove 3s linear infinite;
}
@keyframes shimmerMove {
  0% { background-position: 200% 50%; }
  100% { background-position: -200% 50%; }
}

.msg-image { max-width: 320px; max-height: 320px; border-radius: 12px; display: block; margin-bottom: 6px; cursor: zoom-in; }
.msg-video { max-width: 340px; border-radius: 12px; display: block; margin-bottom: 6px; background: #000; }
.msg-sticker { width: 128px; height: 128px; display: block; }
.msg-file {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; background: rgba(0,0,0,0.25);
  text-decoration: none; color: inherit; margin-bottom: 4px;
}
.msg-row:not(.own) .msg-file { background: rgba(255,255,255,0.05); }
.msg-file-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #4d3fbf);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.msg-file-name { font-weight: 600; font-size: 13px; }
.msg-file-size { font-size: 11px; opacity: 0.75; }

.date-sep {
  align-self: center; font-size: 11px; color: var(--text-3);
  background: var(--bg-1); border: 1px solid var(--border);
  padding: 4px 12px; border-radius: 20px; margin: 12px 0 8px;
}

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px;
  background: rgba(255,255,255,0.08);
  font-size: 12px; cursor: pointer;
  transition: all var(--t);
}
.reaction-chip:hover { transform: translateY(-2px) scale(1.08); }
.reaction-chip.mine { background: rgba(255,255,255,0.2); }
.reaction-chip.bounce { animation: chipBounce 0.4s cubic-bezier(.4,1.6,.6,1); }
@keyframes chipBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.35) translateY(-3px); }
  100% { transform: scale(1); }
}

.msg-bubble.pinned { box-shadow: 0 0 0 2px var(--accent); }
.pinned-bar {
  position: sticky; top: 0; align-self: center;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--bg-1);
  backdrop-filter: blur(10px);
  border: 1px solid var(--accent);
  border-radius: 20px;
  color: var(--text-1); font-size: 12px;
  margin-bottom: 10px; cursor: pointer;
  z-index: 5; max-width: 80%;
  box-shadow: 0 4px 20px var(--accent-dim);
}
.pinned-bar:hover { border-color: var(--accent-h); }

.msg-reply {
  border-left: 3px solid rgba(255,255,255,0.35);
  padding: 4px 10px; margin-bottom: 6px; border-radius: 6px;
  background: rgba(0,0,0,0.18); cursor: pointer;
}
.msg-row.own .msg-reply { background: rgba(255,255,255,0.12); }
.msg-reply-name { font-size: 11px; font-weight: 700; color: var(--accent); }
.msg-row.own .msg-reply-name { color: #fff; }
.msg-reply-text {
  font-size: 12px; opacity: 0.85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 240px;
}

.msg-row.search-hit .msg-bubble { box-shadow: 0 0 0 2px var(--warning); }

.msg-row.system {
  justify-content: center;
  max-width: 90%;
  margin: 6px auto;
}
.msg-row.system .msg-bubble {
  background: var(--bg-2);
  border-color: transparent;
  color: var(--text-3);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 14px;
  text-align: center;
}

/* Удалённые сообщения */
.msg-bubble .msg-deleted {
  font-style: italic; opacity: 0.6; font-size: 13px;
}
.msg-row.deleted .msg-bubble {
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.15);
  box-shadow: none;
}
.msg-row.own.deleted .msg-bubble {
  background: rgba(255,255,255,0.06);
  color: var(--text-3);
}
.msg-removing {
  animation: msgRemove 0.22s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes msgRemove {
  to { opacity: 0; transform: scale(0.96); max-height: 0; margin: 0; padding: 0; }
}

/* Skeleton shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-msg { height: 44px; margin-bottom: 8px; max-width: 60%; }
.skeleton-msg.own { margin-left: auto; }

/* Typing dots */
.typing-dots {
  display: inline-flex; gap: 3px; align-items: center;
}
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  animation: dotBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(1); opacity: 0.5; }
  40% { transform: scale(1.4); opacity: 1; }
}

/* ---------- Reply / Attach / Voice bars ---------- */
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--accent-dim);
  border-top: 1px solid var(--accent);
  border-left: 3px solid var(--accent);
  color: var(--text-0);
  animation: slideUp 0.2s;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.reply-bar-body { flex: 1; min-width: 0; }
.reply-bar-name { font-size: 12px; color: var(--accent); font-weight: 700; }
.reply-bar-text {
  font-size: 12px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.attach-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--accent-dim);
  border-top: 1px solid var(--accent);
  color: var(--text-0); font-size: 13px;
}
.attach-bar span { flex: 1; }

.voice-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(255,90,110,0.12);
  border-top: 1px solid rgba(255,90,110,0.35);
  color: var(--text-0);
}
.voice-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--error);
  animation: pulseRec 1s ease-in-out infinite;
}
@keyframes pulseRec {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.6; }
}
.voice-time {
  font-family: ui-monospace, monospace;
  font-size: 13px;
}
.voice-bar .voice-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.voice-wave {
  flex: 1;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  min-width: 60px;
}
.voice-wave span {
  display: block;
  flex: 1;
  min-width: 2px;
  height: 4%;
  background: linear-gradient(180deg, var(--error), rgba(255,90,110,0.5));
  border-radius: 2px;
  transition: height 0.08s linear;
}

/* ---------- Stranger banner ---------- */
#stranger-bar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 16px;
  background: rgba(255,181,71,0.10);
  border-bottom: 1px solid rgba(255,181,71,0.35);
  color: var(--text-0);
  animation: slideDown 0.3s;
}
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.stranger-info { display: flex; gap: 12px; align-items: flex-start; }
.stranger-icon { font-size: 22px; line-height: 1; }
.stranger-title { font-size: 13px; font-weight: 700; color: var(--warning); }
.stranger-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.stranger-actions { display: flex; gap: 8px; }
.stranger-actions .btn { padding: 8px 14px; font-size: 13px; }

/* ---------- Composer ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  padding: 12px 14px;
}
.composer textarea {
  flex: 1; resize: none; max-height: 160px;
  border-radius: var(--radius); padding: 10px 14px;
  line-height: 1.45;
  font-family: var(--msg-font);
}
.send-btn { height: 42px; padding: 0 16px; font-size: 16px; }

/* ---------- Settings sections ---------- */
.settings-section {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
}
.settings-section h3 {
  font-size: 14px; font-weight: 700; color: var(--text-0);
  margin-bottom: 16px;
}
.settings-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-info { flex: 1; min-width: 0; }
.settings-row-label { font-size: 14px; font-weight: 600; color: var(--text-0); }
.settings-row-desc { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.badge {
  display: inline-flex; padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge.success { background: rgba(61,220,132,0.15); color: var(--success); }
.badge.muted { background: var(--bg-3); color: var(--text-2); }

.bot-badge {
  display: inline-block;
  background: linear-gradient(135deg, #4da6ff, #7c5cff);
  color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: 8px;
  letter-spacing: 0.5px; vertical-align: middle;
}

.switch {
  position: relative; width: 44px; height: 24px;
  background: var(--bg-3); border-radius: 12px;
  cursor: pointer; transition: background var(--t); flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; background: #fff;
  border-radius: 50%; transition: transform var(--t);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }

/* ---------- Profile ---------- */
.profile-hero {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 20px 0 24px;
}
.profile-hero .avatar { box-shadow: 0 8px 40px var(--accent-dim); }
.profile-hero-name { font-size: 22px; font-weight: 800; color: var(--text-0); }
.profile-hero-id {
  font-family: ui-monospace, monospace; font-size: 13px; color: var(--text-2);
  background: var(--bg-2); padding: 4px 12px; border-radius: 12px;
  border: 1px solid var(--border); cursor: pointer;
}
.profile-hero-id:hover { border-color: var(--accent); color: var(--accent); }

.profile-cover {
  height: 120px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(135deg, var(--accent-dim), rgba(77,166,255,0.25));
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
  margin: -22px -24px 0 -24px;
}
.profile-cover.with-image::after { background: none; }

.profile-card {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 18px;
  padding: 0 0 8px;
  margin-bottom: 8px;
}
.profile-avatar-wrap {
  display: flex; justify-content: center;
  margin-top: -55px;
  position: relative; z-index: 2;
}
.profile-avatar-clickable {
  cursor: zoom-in;
  transition: transform 0.2s;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 0 4px var(--bg-1);
}
.profile-avatar-clickable:hover { transform: scale(1.04); }

.profile-name { text-align: center; font-size: 22px; font-weight: 800; color: var(--text-0); margin-top: 14px; }
.profile-nickname { text-align: center; font-size: 13px; color: var(--accent); margin-top: 2px; }
.profile-id-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 10px auto 0; padding: 5px 14px;
  border-radius: 14px;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-2);
  font-family: ui-monospace, monospace; font-size: 13px;
  cursor: pointer; transition: all 0.2s;
  width: fit-content;
}
.profile-id-badge:hover { border-color: var(--accent); color: var(--accent); }

.profile-status {
  display: flex; justify-content: center; gap: 8px;
  margin-top: 10px; font-size: 12px; color: var(--text-2);
}
.profile-status .dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--text-3);
  margin-right: 4px;
}
.profile-status .dot.online { background: var(--success); box-shadow: 0 0 8px rgba(61,220,132,0.6); }

.profile-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-top: 16px;
}
.profile-stat {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px; text-align: center;
}
.profile-stat-value { font-size: 20px; font-weight: 800; color: var(--text-0); }
.profile-stat-label {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px;
}

.profile-actions {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-top: 18px;
}
.profile-actions .btn {
  width: 100%; justify-content: center;
  padding: 12px 14px; font-size: 13px;
}
.profile-actions .btn-full { grid-column: 1 / -1; }

/* Музыка в профиле */
.profile-music {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(29,185,84,0.10), rgba(77,166,255,0.08));
  border: 1px solid rgba(29,185,84,0.3);
  border-radius: 14px;
  margin-top: 12px;
}
.profile-music-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #1db954;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px;
  animation: musicPulse 1.8s ease-in-out infinite;
}
@keyframes musicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29,185,84,0.5); }
  50% { box-shadow: 0 0 0 8px rgba(29,185,84,0); }
}
.profile-music-body { flex: 1; min-width: 0; }
.profile-music-title { font-size: 13px; font-weight: 700; color: var(--text-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-music-artist { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Анимированная activity line */
.activity-line {
  font-size: 12px;
  color: var(--accent);
  font-style: italic;
  margin-top: 4px;
  text-align: center;
}
.activity-line.animated {
  animation: activityFloat 3s ease-in-out infinite;
}
@keyframes activityFloat {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(-2px); opacity: 0.8; }
}

/* ---------- Theme picker ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.theme-tile {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: 12px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  padding: 6px;
  display: flex; flex-direction: column; gap: 3px;
}
.theme-tile:hover { transform: translateY(-3px) scale(1.02); border-color: var(--accent); }
.theme-tile.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.theme-tile .tt-dot {
  width: 100%; height: 6px; border-radius: 3px;
}
.theme-tile .tt-body {
  flex: 1; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #fff; font-weight: 700;
}

/* ---------- Cover picker ---------- */
.cover-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.cover-grid button {
  aspect-ratio: 2/1; border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer; transition: all 0.2s;
  padding: 0; overflow: hidden;
}
.cover-grid button:hover { transform: scale(1.06); border-color: var(--accent); }
.cover-grid button.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.cover-gradient-1 { background: linear-gradient(135deg, #7c5cff, #4da6ff, #3ddc84); }
.cover-gradient-2 { background: linear-gradient(135deg, #ff5a6e, #ffb547, #ff6ad5); }
.cover-gradient-3 { background: linear-gradient(135deg, #3ddc84, #5ce1e6, #4da6ff); }
.cover-gradient-4 { background: linear-gradient(135deg, #a78bfa, #ff6ad5, #ffb547); }
.cover-gradient-5 { background: linear-gradient(135deg, #0a0a0f, #4d3fbf, #7c5cff); }

@keyframes coverShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.profile-cover.preset {
  background-size: 200% 200%;
  animation: coverShift 14s ease infinite;
}
.profile-cover.preset.particles { position: relative; }
.profile-cover.preset.particles::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.5) 1.5px, transparent 2px),
    radial-gradient(circle at 60% 70%, rgba(255,255,255,0.35) 1px, transparent 2px),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.5) 1.5px, transparent 2px);
  background-size: 100px 100px, 120px 120px, 80px 80px;
  animation: particlesMove 20s linear infinite;
  pointer-events: none;
}
@keyframes particlesMove {
  from { background-position: 0 0, 0 0, 0 0; }
  to   { background-position: 100px 100px, -120px 120px, 80px -80px; }
}
.profile-cover.preset.waves {
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.08) 0 8px, transparent 8px 16px),
    linear-gradient(135deg, #7c5cff, #4da6ff, #5ce1e6);
}

/* ---------- User card ---------- */
.user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 8px;
  transition: border-color var(--t), transform 0.15s;
}
.user-card:hover { border-color: var(--accent); transform: translateX(3px); }
.user-card-body { flex: 1; min-width: 0; }
.user-card-name { font-weight: 700; color: var(--text-0); font-size: 14px; }
.user-card-id { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-3); }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 10000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 360px;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-l);
  border-left: 3px solid var(--accent);
  padding: 14px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px; color: var(--text-0);
  animation: slideInRight 0.3s cubic-bezier(.4,0,.2,1);
  display: flex; gap: 12px; align-items: flex-start;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast-title { font-weight: 700; margin-bottom: 2px; }
.toast-msg { color: var(--text-2); font-size: 13px; }
.toast-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
@keyframes slideInRight { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Context menu ---------- */
.ctx-menu {
  position: fixed;
  background: var(--bg-2);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
  min-width: 180px;
  z-index: 8000;
  animation: scaleIn 0.15s;
}
.ctx-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  border-radius: 6px; font-size: 13px;
  color: var(--text-1); text-align: left;
  transition: background var(--t);
}
.ctx-menu button:hover { background: var(--bg-3); color: var(--text-0); }
.ctx-menu button.danger { color: var(--error); }
.ctx-menu .reactions-row {
  display: flex; gap: 2px; padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.ctx-menu .reactions-row button { font-size: 20px; padding: 4px 6px; border-radius: 50%; }

.reaction-bar {
  display: flex; gap: 4px;
  padding: 6px 8px;
  background: var(--bg-2);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-l);
  border-radius: 28px;
  box-shadow: var(--shadow), 0 0 24px var(--accent-dim);
  animation: scaleIn 0.15s;
  z-index: 8000;
}
.reaction-bar button {
  font-size: 22px; padding: 4px 8px; border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.reaction-bar button:hover { transform: scale(1.35); background: var(--accent-dim); }

/* ---------- Picker ---------- */
.picker {
  position: absolute; bottom: 100%; left: 14px; right: 14px;
  max-width: 480px; height: 420px;
  background: var(--bg-1);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  display: flex; flex-direction: column; overflow: hidden;
  animation: scaleIn 0.2s; z-index: 100;
}
.picker-tabs {
  display: flex; gap: 4px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}
.picker-tab {
  padding: 8px 10px; font-size: 12px; font-weight: 600;
  color: var(--text-2); border-radius: 8px 8px 0 0;
  white-space: nowrap; flex-shrink: 0;
}
.picker-tab:hover { color: var(--text-0); background: var(--bg-2); }
.picker-tab.active { color: var(--accent); }
.picker-search { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.picker-search input { padding: 8px 12px; font-size: 13px; }
.picker-body {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.picker-body.stickers {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  align-content: start;
}
.rp-title {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 4px 4px;
}
.rp-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.rp-emoji {
  font-size: 22px; padding: 6px; border-radius: 8px;
  cursor: pointer; text-align: center; line-height: 1;
  transition: all 0.15s;
}
.rp-emoji:hover { background: var(--accent-dim); transform: scale(1.2); }
.picker-sticker {
  aspect-ratio: 1; padding: 8px; border-radius: 10px;
  cursor: pointer; background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.picker-sticker:hover { background: var(--accent-dim); transform: translateY(-3px) scale(1.04); }
.picker-sticker img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Reaction picker ---------- */
.reaction-picker {
  position: fixed;
  width: 340px; max-height: 400px;
  background: var(--bg-1);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 0 30px var(--accent-dim);
  display: flex; flex-direction: column; overflow: hidden;
  z-index: 8000;
  animation: scaleIn 0.18s;
}
.reaction-picker .rp-search { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.reaction-picker .rp-search input { padding: 8px 12px; font-size: 13px; }
.reaction-picker .rp-recent { max-height: 120px; overflow-y: auto; padding: 4px 8px 0; }
.reaction-picker .rp-body { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 9500; padding: 40px;
  animation: fadeIn 0.2s; cursor: zoom-out;
}
.lightbox img, .lightbox video {
  max-width: 90vw; max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.8);
  animation: lightboxZoom 0.3s cubic-bezier(.4,0,.2,1);
}
@keyframes lightboxZoom { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Parallax ---------- */
.parallax-bg {
  position: fixed; inset: -80px;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(800px 600px at calc(20% + var(--parallax-x, 0px)) calc(20% + var(--parallax-y, 0px)),
      var(--accent-dim), transparent 60%),
    radial-gradient(700px 500px at calc(80% - var(--parallax-x, 0px)) calc(80% - var(--parallax-y, 0px)),
      rgba(77,166,255,0.12), transparent 60%);
}
.app, .auth-wrap { position: relative; z-index: 1; }

/* ---------- Unread badge ---------- */
.list-item-badge {
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 12px var(--accent-dim);
  animation: badgeIn 0.3s cubic-bezier(.4,0,.2,1);
}
@keyframes badgeIn { from { transform: scale(0); } to { transform: scale(1); } }

.list-item-badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  color: var(--text-2);
}
.list-item-badge-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* ---------- Опросы ---------- */
.poll-card { min-width: 260px; max-width: 360px; }
.poll-question {
  font-weight: 700; font-size: 14px;
  margin-bottom: 10px; color: var(--text-0);
}
.poll-option {
  position: relative;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
}
.msg-row.own .poll-option {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
}
.poll-option:hover { border-color: var(--accent); transform: translateX(2px); }
.poll-option.voted { border-color: var(--accent); }
.poll-option.correct { border-color: var(--success); background: rgba(61,220,132,0.15); }
.poll-option.incorrect { border-color: var(--error); background: rgba(255,90,110,0.15); }
.poll-option-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent-dim);
  transition: width 0.4s ease;
  z-index: 0;
}
.msg-row.own .poll-option-bar { background: rgba(255,255,255,0.18); }
.poll-option-text {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-0);
}
.poll-option-pct { font-weight: 700; font-size: 12px; opacity: 0.85; flex-shrink: 0; }
.poll-meta { font-size: 11px; color: var(--text-3); margin-top: 8px; }
.poll-checkbox {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 4px; border: 2px solid currentColor;
  margin-right: 8px; vertical-align: -2px; opacity: 0.6;
}
.poll-option.voted .poll-checkbox { background: var(--accent); border-color: var(--accent); opacity: 1; }
.poll-voters {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  padding-left: 22px;
  line-height: 1.3;
}

/* ---------- Read receipts ---------- */
.msg-status { display: inline-flex; align-items: center; margin-left: 4px; font-size: 11px; line-height: 1; }
.msg-status .check { color: rgba(255,255,255,0.6); transition: color 0.2s; }
.msg-status.read .check { color: #7fffd4; animation: checkPop 0.3s cubic-bezier(.4,1.6,.6,1); }
@keyframes checkPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ---------- Channel badge ---------- */
.channel-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 6px;
  margin-left: 6px; vertical-align: middle;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.channel-badge.public { background: rgba(61,220,132,0.15); color: var(--success); }
.channel-badge.private { background: rgba(255,181,71,0.15); color: var(--warning); }

/* ---------- Input with prefix ---------- */
.input-prefix {
  display: flex; align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.input-prefix:focus-within { border-color: var(--accent); }
.input-prefix .prefix {
  padding: 0 10px;
  color: var(--text-3);
  font-weight: 700; font-size: 14px;
  user-select: none;
}
.input-prefix input { border: none; background: transparent; border-radius: 0; }
.input-prefix input:focus { box-shadow: none; }

/* ---------- Share row ---------- */
.share-row {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 8px;
}
.share-row .share-link {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 12px; color: var(--accent);
  user-select: all;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.share-row .share-link:hover { text-decoration: underline; }

/* ---------- Sessions ---------- */
.session-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.session-row:last-child { border-bottom: none; }
.session-info { flex: 1; min-width: 0; }
.session-ua { font-size: 13px; color: var(--text-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-date { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ---------- Accounts ---------- */
.account-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  cursor: pointer; transition: background 0.15s;
  border: 1px solid var(--border); margin-bottom: 8px;
}
.account-row:hover { background: var(--bg-2); transform: translateX(2px); }
.account-row.current { background: var(--accent-dim); border-color: var(--accent); }
.account-info { flex: 1; min-width: 0; }
.account-name { font-weight: 700; color: var(--text-0); font-size: 14px; }
.account-id { font-family: ui-monospace, monospace; font-size: 11px; color: var(--text-3); margin-top: 2px; }
.account-badge {
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 8px;
  background: var(--success); color: #fff;
  text-transform: uppercase;
}

/* ---------- Local rooms ---------- */
.local-room-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px; cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.local-room-card:hover { border-color: var(--accent); transform: translateX(3px); }
.local-room-icon { font-size: 28px; flex-shrink: 0; }
.local-room-body { flex: 1; min-width: 0; }
.local-room-title { font-weight: 700; color: var(--text-0); font-size: 14px; }
.local-room-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ---------- Ephemeral ---------- */
.ephemeral-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px;
  background: rgba(255,181,71,0.15); color: var(--warning);
  font-size: 11px; font-weight: 600;
  margin-left: 8px;
}

/* ---------- Catalog ---------- */
.catalog-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.catalog-card:hover { border-color: var(--accent); background: var(--bg-2); transform: translateX(3px); }
.catalog-avatar {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4da6ff, #7c5cff);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0; color: #fff;
}
.catalog-avatar svg, .avatar-lg svg { width: 26px; height: 26px; display: block; color: var(--text-0); }
.avatar-lg svg { width: 32px; height: 32px; }
.catalog-body { flex: 1; min-width: 0; }
.catalog-title { font-weight: 700; color: var(--text-0); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.catalog-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ---------- Comments ---------- */
.comments-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 12px;
  background: rgba(255,255,255,0.06);
  color: var(--text-1);
  font-size: 12px; cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  margin-top: 6px; border: none;
}
.comments-btn:hover { background: var(--accent-dim); color: var(--text-0); transform: translateY(-1px); }

.comment-row { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.comment-row:last-child { border-bottom: none; }
.comment-author {
  font-size: 12px; font-weight: 700; color: var(--accent);
  display: flex; gap: 8px; align-items: center;
}
.comment-time { color: var(--text-3); font-weight: 400; font-size: 11px; }
.comment-body { font-size: 13px; color: var(--text-0); margin-top: 4px; line-height: 1.45; }
.comment-row.deleted .comment-body { opacity: 0.5; font-style: italic; }

/* ---------- Message link ---------- */
.msg-link-highlight { animation: msgHighlight 2.4s ease-out; }
@keyframes msgHighlight {
  0%   { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

/* ---------- Custom emoji ---------- */
.custom-emoji { width: 24px; height: 24px; vertical-align: -6px; margin: 0 1px; display: inline-block; }
.custom-emoji-big { width: 44px; height: 44px; vertical-align: -12px; }

/* ---------- Language grid ---------- */
.language-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 10px;
}
.language-grid button {
  padding: 10px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text-1);
  cursor: pointer; font-size: 13px;
  transition: all 0.15s;
}
.language-grid button:hover { border-color: var(--accent); color: var(--text-0); transform: translateY(-2px); }
.language-grid button.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Social links ---------- */
.social-list { display: flex; flex-direction: column; gap: 6px; }
.social-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--bg-2);
  color: var(--text-0); text-decoration: none;
  font-size: 13px; font-weight: 600;
  transition: background 0.15s, transform 0.15s;
}
.social-item:hover { background: var(--bg-3); color: var(--text-0); transform: translateX(3px); }
.social-icon { width: 20px; text-align: center; font-size: 15px; }

.profile-name span, .chat-header-name span, .list-item-title span { vertical-align: middle; }

/* ---------- Voters list ---------- */
.voters-list { display: flex; flex-direction: column; gap: 4px; }
.voter-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--bg-2);
  transition: background 0.15s;
}
.voter-row:hover { background: var(--bg-3); }
.voter-name { font-size: 14px; color: var(--text-0); font-weight: 600; }

/* ---------- Audio player (голосовые / mp3) ---------- */
.ap {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,0.20);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 8px 12px;
  min-width: 240px;
  max-width: 360px;
}
.msg-row.own .ap {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.18);
}
.ap-play {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
}
.ap-play:hover { transform: scale(1.08); background: var(--accent-h); }
.ap-play svg { width: 18px; height: 18px; }
.ap-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.ap-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 26px;
  cursor: pointer;
}
.ap-waveform span {
  flex: 1;
  min-width: 1.5px;
  height: 40%;
  background: rgba(255,255,255,0.30);
  border-radius: 2px;
  transition: background 0.12s, transform 0.12s;
}
.ap-waveform span.active {
  background: var(--accent);
  transform: scaleY(1.08);
}
.msg-row.own .ap-waveform span { background: rgba(255,255,255,0.45); }
.msg-row.own .ap-waveform span.active { background: #fff; }
.ap-meta {
  display: flex; gap: 4px; align-items: center;
  font-size: 11px; color: var(--text-3);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.ap-meta .ap-sep { opacity: 0.5; }
.ap-meta .ap-name { overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.ap-speed {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--text-2);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.ap-speed:hover { background: rgba(255,255,255,0.12); color: var(--text-0); }
.ap.ap-compact {
  min-width: 200px;
  padding: 6px 10px;
}
.ap.ap-compact .ap-play { width: 30px; height: 30px; }
.ap.ap-compact .ap-play svg { width: 14px; height: 14px; }
.ap.ap-compact .ap-waveform { height: 22px; }
.ap.ap-compact .ap-meta { font-size: 10px; }

/* ---------- Video player ---------- */
.vp {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  max-width: 420px;
  margin-bottom: 6px;
}
.vp video {
  display: block;
  width: 100%;
  max-height: 420px;
  background: #000;
  cursor: pointer;
}
.vp-controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.78));
  opacity: 0.85;
  transition: opacity 0.15s;
}
.vp:hover .vp-controls { opacity: 1; }
.vp-controls button,
.vp-controls a {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: #fff;
  background: transparent;
  transition: background 0.15s;
}
.vp-controls button:hover,
.vp-controls a:hover { background: rgba(255,255,255,0.15); }
.vp-controls svg { width: 16px; height: 16px; }
.vp-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.22);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.vp-progress {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}
.vp-time {
  font-size: 11px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}
.vp-mute.muted svg { opacity: 0.5; }

/* ============================================================
   Модальные окна
   ============================================================ */
.nx-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000; padding: 24px;
  animation: nxFadeIn 0.2s ease;
}
.nx-modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  width: 100%; max-width: 560px;
  max-height: 82vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: nxScaleIn 0.24s cubic-bezier(.4,0,.2,1);
}
.nx-modal-wide { max-width: 720px; }
.nx-modal-narrow { max-width: 420px; }
.nx-modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent-dim), transparent);
  flex-shrink: 0;
}
.nx-modal-title {
  flex: 1; font-size: 17px; font-weight: 800;
  color: var(--text-0); letter-spacing: 0.2px;
}
.nx-modal-close {
  width: 36px; height: 36px;
  border-radius: 10px;
  color: var(--text-2); font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.nx-modal-close:hover { background: var(--bg-2); color: var(--text-0); transform: rotate(90deg); }
.nx-modal-body {
  flex: 1; overflow-y: auto;
  padding: 22px 24px;
  overscroll-behavior: contain;
  min-height: 0;
}
.nx-modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  flex-shrink: 0;
  position: sticky; bottom: 0; z-index: 5;
}
.nx-modal-footer:empty { display: none; }
.nx-modal-body .settings-section {
  background: var(--bg-2);
  border-color: var(--border);
  margin-bottom: 14px;
}
.nx-modal-body .settings-section:last-child { margin-bottom: 0; }
.nx-modal-body .profile-card { margin: 0; border: none; background: transparent; padding: 0; }
.nx-modal-body::-webkit-scrollbar { width: 8px; }
.nx-modal-body::-webkit-scrollbar-thumb { background: var(--border-l); border-radius: 4px; }

@keyframes nxFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes nxScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   COMMUNITIES
   ============================================================ */
.community-screen {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: 72px 240px 1fr;
  background: var(--bg-0);
  z-index: 7000;
  animation: nxFadeIn 0.2s;
}
.community-rail {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0;
  gap: 10px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.community-rail-btn {
  width: 48px; height: 48px;
  border-radius: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.community-rail-btn:hover { border-color: var(--accent); background: var(--accent-dim); transform: translateY(-2px) scale(1.05); }
.community-rail-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent);
}
.community-rail-btn.active::before {
  content: '';
  position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 26px;
  background: var(--accent); border-radius: 0 3px 3px 0;
  animation: railSlide 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes railSlide { from { height: 0; } to { height: 26px; } }
.community-rail-btn img { width: 100%; height: 100%; object-fit: cover; }
.community-rail-btn.plus {
  background: transparent;
  border: 2px dashed var(--border-l);
  color: var(--success);
  font-size: 22px;
}
.community-rail-btn.plus:hover { border-style: solid; background: rgba(61,220,132,0.1); }

.community-sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.community-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.community-sidebar-name {
  font-size: 15px; font-weight: 800; color: var(--text-0);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
}
.community-sidebar-body {
  flex: 1; overflow-y: auto;
  padding: 8px 6px;
  min-height: 0;
}
.community-category {
  padding: 8px 10px 4px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-3);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
}
.community-category:hover { color: var(--text-1); }
.community-category-add {
  font-size: 14px; color: var(--text-3);
  padding: 0 4px;
}
.community-category-add:hover { color: var(--accent); }
.community-channel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  margin: 0 4px;
  overflow: hidden;
}
.community-channel-item:hover { background: var(--bg-2); color: var(--text-0); transform: translateX(3px); }
.community-channel-item.active { background: var(--accent-dim); color: var(--text-0); }
.community-channel-item .ch-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  color: var(--text-3);
}
.community-channel-item.active .ch-icon,
.community-channel-item:hover .ch-icon { color: var(--accent); }
.community-channel-item .ch-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.community-channel-item.voice .ch-icon { color: var(--text-2); }

.community-sidebar-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
}
.community-me-body { flex: 1; min-width: 0; }
.community-me-name { font-size: 13px; font-weight: 700; color: var(--text-0); }
.community-me-status { font-size: 11px; color: var(--text-3); }

.community-main {
  display: grid;
  grid-template-columns: 1fr 240px;
  overflow: hidden;
  position: relative;
}
.community-empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-3); text-align: center; padding: 40px;
}
.community-empty-title { font-size: 20px; font-weight: 700; color: var(--text-1); }
.community-empty-sub { font-size: 13px; margin-top: 8px; }

.community-channel {
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.community-channel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}
.community-channel-hash {
  font-size: 22px; color: var(--text-3); font-weight: 800;
}
.community-channel-title {
  font-size: 15px; font-weight: 700; color: var(--text-0);
}
.community-channel-topic {
  flex: 1;
  font-size: 12px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 10px; margin-left: 10px;
  border-left: 1px solid var(--border);
}

.community-text {
  display: flex; flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.community-messages {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.community-composer { padding: 12px 14px; }

/* Голосовой канал в Communities */
.community-voice {
  flex: 1;
  overflow: hidden;
  padding: 20px;
  display: flex; align-items: center; justify-content: center;
}
.voice-stage {
  display: flex; flex-direction: column;
  align-items: center; gap: 24px;
  width: 100%;
}
.voice-stage-participants {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 720px;
}
.voice-stage-participant {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  padding: 20px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 18px;
  position: relative;
  transition: border-color 0.2s;
}
.voice-stage-participant.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 2px rgba(61,220,132,0.3), 0 0 20px rgba(61,220,132,0.4);
  animation: speakingPulse 1.4s ease-in-out infinite;
}
@keyframes speakingPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(61,220,132,0.3), 0 0 12px rgba(61,220,132,0.35); }
  50% { box-shadow: 0 0 0 3px rgba(61,220,132,0.5), 0 0 24px rgba(61,220,132,0.55); }
}
.voice-stage-participant .vp-avatar {
  position: relative;
}
.voice-stage-participant .vp-avatar::before {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid transparent;
  animation: avatarRing 2s linear infinite;
}
.voice-stage-participant.speaking .vp-avatar::before {
  border-color: var(--success);
}
@keyframes avatarRing {
  from { transform: rotate(0deg); border-color: rgba(61,220,132,0.4) rgba(61,220,132,0.4) transparent transparent; }
  to { transform: rotate(360deg); border-color: rgba(61,220,132,0.4) rgba(61,220,132,0.4) transparent transparent; }
}
.voice-stage-participant .vp-name {
  font-size: 13px; font-weight: 700; color: var(--text-0);
  text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}
.voice-stage-participant .vp-mute-badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 14px;
  opacity: 0.7;
}
.voice-stage-controls {
  display: flex; gap: 14px;
  padding: 14px 22px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 32px;
  box-shadow: var(--shadow);
}

.community-members {
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex; flex-direction: column;
  min-width: 0;
}
.community-members.hidden { display: none; }
.community-members-header {
  padding: 14px 16px;
  font-size: 11px; font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
}
.community-members-body {
  flex: 1; padding: 10px 8px;
}
.community-member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.community-member-row:hover { background: var(--bg-2); transform: translateX(2px); }
.community-member-row .cm-body { flex: 1; min-width: 0; }
.community-member-row .cm-name {
  font-size: 13px; font-weight: 600; color: var(--text-0);
  display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.community-member-row .cm-roles {
  font-size: 11px; color: var(--text-3);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.community-role-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.communities-home {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 8000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: nxFadeIn 0.2s;
}
.communities-home-inner {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 560px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.communities-home-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.communities-home-title {
  font-size: 17px; font-weight: 800; color: var(--text-0);
}
.communities-home-actions {
  display: flex; gap: 8px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}
.communities-home-list {
  flex: 1; overflow-y: auto;
  padding: 12px;
}
.community-list-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.community-list-card:hover { background: var(--bg-2); border-color: var(--accent); transform: translateX(3px); }
.community-list-avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c5cff, #4da6ff);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 16px;
  overflow: hidden;
  flex-shrink: 0;
}
.community-list-avatar img { width: 100%; height: 100%; object-fit: cover; }
.community-list-body { flex: 1; min-width: 0; }
.community-list-title { font-weight: 700; color: var(--text-0); font-size: 14px; }
.community-list-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.perm-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.perm-row:last-child { border-bottom: none; }
.perm-row-label {
  flex: 1;
  font-size: 13px; font-weight: 600; color: var(--text-0);
}
.perm-row-desc { font-size: 11px; color: var(--text-3); }

.community-mini-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4d3fbf);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  overflow: hidden; flex-shrink: 0;
  background-size: cover;
}

.community-mobile-only { display: none; }

/* ============================================================
   CALL OVERLAY
   ============================================================ */
.call-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at top, rgba(124,92,255,0.3), transparent 60%), var(--bg-0);
  z-index: 10000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 40px 20px;
  animation: nxFadeIn 0.3s;
}
.call-bg {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 30%, rgba(124,92,255,0.25), transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(77,166,255,0.2), transparent 50%);
  animation: callBgPulse 4s ease-in-out infinite;
}
@keyframes callBgPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}
.call-content {
  position: relative;
  z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
  margin-top: 40px;
  text-align: center;
  flex: 1;
  justify-content: center;
}
.call-content .avatar-xl {
  box-shadow: 0 0 0 4px rgba(124,92,255,0.3), 0 0 60px rgba(124,92,255,0.6);
  animation: callAvatarPulse 2s ease-in-out infinite;
}
@keyframes callAvatarPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.call-participant-name {
  font-size: 28px; font-weight: 800; color: var(--text-0);
}
.call-status {
  font-size: 14px; color: var(--text-2);
  letter-spacing: 1px;
}
.call-status.ringing {
  animation: callRinging 1.2s ease-in-out infinite;
}
@keyframes callRinging {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.call-timer {
  font-family: ui-monospace, monospace;
  font-size: 16px;
  color: var(--accent);
}

/* Пульсирующие круги */
.call-pulse-rings {
  position: absolute; inset: 0;
  pointer-events: none;
}
.call-pulse-rings::before,
.call-pulse-rings::after {
  content: ''; position: absolute;
  top: 50%; left: 50%;
  width: 200px; height: 200px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: ringExpand 2.4s ease-out infinite;
  opacity: 0;
}
.call-pulse-rings::after { animation-delay: 1.2s; }
@keyframes ringExpand {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0; }
}

.call-controls {
  position: relative;
  z-index: 2;
  display: flex; gap: 20px;
  justify-content: center;
  align-items: center;
  padding: 20px 0 10px;
}
.call-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  transition: all 0.2s cubic-bezier(.4,0,.2,1);
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
}
.call-btn:hover { transform: scale(1.1); background: rgba(255,255,255,0.18); }
.call-btn svg { width: 26px; height: 26px; }
.call-btn.danger { background: var(--error); border-color: var(--error); }
.call-btn.danger:hover { background: #ff3a52; }
.call-btn.accept {
  background: var(--success);
  border-color: var(--success);
  animation: acceptPulse 1.4s ease-in-out infinite;
}
@keyframes acceptPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61,220,132,0.6); }
  50% { box-shadow: 0 0 0 14px rgba(61,220,132,0); }
}
.call-btn.muted {
  background: rgba(255,90,110,0.25);
  color: var(--error);
}
.call-btn.muted svg { opacity: 0.6; }
.call-btn.off {
  background: rgba(255,255,255,0.05);
  color: var(--text-3);
}

/* ============================================================
   SVG CATALOG MODAL (анимированные значки)
   ============================================================ */
.svg-catalog-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 9200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: nxFadeIn 0.2s;
}
.svg-catalog-inner {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 640px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.svg-catalog-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 16px; font-weight: 800; color: var(--text-0);
}
.svg-catalog-body {
  flex: 1; overflow-y: auto;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.svg-catalog-item {
  aspect-ratio: 1;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--bg-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s cubic-bezier(.4,0,.2,1);
}
.svg-catalog-item:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-3px) scale(1.05);
}
.svg-catalog-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.svg-catalog-item svg { width: 100%; height: 100%; }

/* ============================================================
   Кастомный цвет имени (inline style применяется из JS)
   ============================================================ */

/* ============================================================
   Мобильная адаптация
   ============================================================ */
.mobile-only { display: none; }

@media (max-width: 768px) {
  html, body {
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden;
  }
  .app { display: block; height: 100dvh !important; position: relative; }
  .sidebar {
    position: absolute; inset: 0;
    width: 100% !important;
    height: 100dvh !important;
    z-index: 10;
    display: flex; flex-direction: column;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .sidebar.hidden-mobile { transform: translateX(-100%); }
  .sidebar-list { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
  .sidebar-quick-actions {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 4px; padding: 8px;
  }
  .quick-action-btn { padding: 10px 8px; font-size: 12px; }
  .sidebar-footer {
    flex: 0 0 auto;
    background: var(--bg-1);
    border-top: 1px solid var(--border);
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  }
  .main { position: absolute; inset: 0; z-index: 5; }
  .sidebar-header .icon-btn,
  .sidebar-footer .icon-btn,
  .chat-header .icon-btn {
    width: 40px; height: 40px; font-size: 16px;
  }
  .header-actions { gap: 0; flex-wrap: wrap; justify-content: flex-end; }
  .chat-header { padding: 10px 12px; gap: 8px; }
  .chat-header-name { font-size: 14px; }
  .chat-header-sub { font-size: 11px; }
  .avatar-md { width: 38px; height: 38px; font-size: 15px; }
  .mobile-only { display: inline-flex; }
  .messages { padding: 12px 10px; gap: 4px; }
  .msg-row { max-width: 88%; }
  .msg-bubble { padding: 8px 12px; font-size: 14px; }
  .msg-image, .msg-video { max-width: 100%; max-height: 60vh; }
  .composer { padding: 8px; gap: 4px; }
  .composer textarea { font-size: 15px; padding: 10px 12px; }
  .composer .icon-btn { width: 38px; height: 38px; font-size: 17px; }
  .send-btn { width: 44px; height: 44px; font-size: 18px; padding: 0; }
  .sidebar-header { padding: 12px 14px; }
  .brand { font-size: 16px; letter-spacing: 2px; }
  .sidebar-search { padding: 8px 12px; }
  .sidebar-search input { padding: 10px 12px; font-size: 14px; }
  .sidebar-tabs { padding: 6px 8px 0; }
  .tab { padding: 8px 6px; font-size: 12px; }
  .sidebar-list { padding: 6px; }
  .list-item { padding: 10px 12px; }
  .list-item-title { font-size: 14px; }
  .list-item-sub { font-size: 12px; }
  .settings-section { padding: 16px; }
  .settings-row-label { font-size: 13px; }
  .settings-row-desc { font-size: 11px; }
  .profile-hero .avatar-xl { width: 88px; height: 88px; font-size: 32px; }
  .profile-hero-name { font-size: 18px; }
  .poll-card { min-width: 0; max-width: 100%; }
  .picker { left: 6px; right: 6px; height: 360px; }
  .rp-grid { grid-template-columns: repeat(7, 1fr); }
  .picker-body.stickers { grid-template-columns: repeat(3, 1fr); }
  .reaction-picker { width: 92vw; left: 4vw !important; }
  #toast-container { top: 10px; right: 10px; left: 10px; max-width: none; }
  .auth-card { padding: 28px 20px; }
  .auth-logo { font-size: 28px; }
  .profile-cover { margin: -16px -16px 0 -16px; height: 100px; }
  .profile-avatar-wrap { margin-top: -45px; }
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .cover-grid { grid-template-columns: repeat(4, 1fr); }
  .language-grid { grid-template-columns: repeat(2, 1fr); }
  .voice-bar { padding: 8px 10px; flex-wrap: wrap; }
  .voice-wave { min-width: 100%; order: 3; margin-top: 6px; }
  .comments-btn { font-size: 11px; padding: 3px 8px; }

  .vp { max-width: 100%; }
  .vp video { max-height: 55vh; }
  .vp-time { display: none; }
  .vp-controls { padding: 6px 8px; }
  .vp-controls button, .vp-controls a { width: 32px; height: 32px; }
  .ap { min-width: 220px; }
  .ap-meta .ap-name { max-width: 90px; }

  .nx-modal-backdrop { padding: 0; align-items: flex-end; }
  .nx-modal {
    max-width: 100%;
    max-height: 88dvh;
    border-radius: 22px 22px 0 0;
    animation: nxSlideUp 0.28s cubic-bezier(.4,0,.2,1);
  }
  .nx-modal-header { padding: 16px 18px; }
  .nx-modal-body {
    padding: 18px 18px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0));
  }
  .nx-modal-footer {
    padding: 14px 18px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0));
  }
  .nx-modal-footer .btn { flex: 1; }
  @keyframes nxSlideUp {
    from { transform: translateY(100%); opacity: 0.4; }
    to { transform: translateY(0); opacity: 1; }
  }

  .community-screen { grid-template-columns: 1fr; grid-template-areas: "main"; }
  .community-rail {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 64px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    z-index: 7020;
  }
  .community-rail.open { transform: translateX(0); }
  .community-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    z-index: 7010;
  }
  .community-sidebar.open { transform: translateX(0); }
  .community-main { grid-area: main; grid-template-columns: 1fr; }
  .community-members {
    position: fixed; right: 0; top: 0; bottom: 0;
    width: 260px;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    z-index: 7030;
  }
  .community-members.open { transform: translateX(0); }
  .community-mobile-only { display: inline-flex; }
  .community-channel-header { padding: 10px 12px; }
  .community-channel-topic { display: none; }
  .community-messages { padding: 12px 10px; }
  .communities-home-inner {
    max-width: 100%;
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
    align-self: flex-end;
  }
  .communities-home { align-items: flex-end; padding: 0; }

  .call-btn { width: 56px; height: 56px; }
  .call-btn svg { width: 22px; height: 22px; }
  .call-participant-name { font-size: 22px; }

  .svg-catalog-body { grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 14px 16px; }
}

@media (max-width: 380px) {
  .msg-row { max-width: 92%; }
  .chat-header { padding: 8px; }
  .profile-actions { grid-template-columns: 1fr; }
  .community-rail { width: 56px; }
  .community-rail-btn { width: 42px; height: 42px; border-radius: 14px; }
}
