/* ============================================================
   RESET & BASE
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hover: rgba(255, 255, 255, 0.12);
  --glass-active: rgba(255, 255, 255, 0.16);
  --red: #e53e3e;
  --red-dark: #c0392b;
  --red-glow: rgba(229, 62, 62, 0.35);
  --text-primary: #f0f0f0;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.35);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-full: 9999px;
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.5);
  --transition: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --green: #4caf50;
  --green-glow: rgba(39, 174, 96, 0.5);
}

/* ============================================================
   LIGHT THEME OVERRIDES
   ============================================================ */
html[data-theme="light"] {
  --bg-primary: #f0f2f5;
  --bg-secondary: #e4e6eb;
  --glass-bg: rgba(0, 0, 0, 0.04);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-hover: rgba(0, 0, 0, 0.08);
  --glass-active: rgba(0, 0, 0, 0.12);
  --text-primary: #0a0a0a;
  --text-secondary: rgba(0, 0, 0, 0.6);
  --text-muted: rgba(0, 0, 0, 0.35);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.1);
}
html[data-theme="light"] .app {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(229, 62, 62, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(229, 62, 62, 0.04) 0%, transparent 50%),
    var(--bg-primary);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  user-select: none;
  transition: background 0.3s, color 0.3s;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--red); border-radius: 10px; }

/* ============================================================
   APP CONTAINER
   ============================================================ */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 16px 12px 16px;
  position: relative;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(229, 62, 62, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(229, 62, 62, 0.06) 0%, transparent 50%),
    var(--bg-primary);
}

/* ============================================================
   TOP BAR
   ============================================================ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  height: 68px;
  position: relative;
  z-index: 10;
  transition: all var(--transition);
}
.top-bar:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}
html[data-theme="light"] .top-bar:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.12);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform var(--transition);
}
.logo-area:hover { transform: scale(1.02); }

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 16px var(--red-glow);
  transition: all var(--transition);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.logo-icon img,
.logo-icon svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.logo-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 60%, rgba(255, 255, 255, 0.7));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: none;
}
html[data-theme="light"] .logo-text {
  background: linear-gradient(135deg, #0a0a0a 60%, rgba(0, 0, 0, 0.7));
  -webkit-background-clip: text;
  background-clip: text;
}
@media (min-width: 600px) { .logo-text { display: block; } }

/* ---- Поиск ---- */
.search-wrap {
  flex: 1;
  max-width: 480px;
  margin: 0 20px;
  position: relative;
  display: none;
}
@media (min-width: 768px) { .search-wrap { display: block; } }

.search-wrap .search-input {
  width: 100%;
  padding: 10px 18px 10px 44px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
}
html[data-theme="light"] .search-wrap .search-input {
  background: rgba(0, 0, 0, 0.03);
}
.search-wrap .search-input::placeholder { color: var(--text-muted); }
.search-wrap .search-input:focus {
  border-color: var(--red);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 4px var(--red-glow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: scale(1.01);
}
html[data-theme="light"] .search-wrap .search-input:focus {
  background: rgba(255, 255, 255, 0.9);
}
.search-wrap .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
  transition: color var(--transition);
}
.search-wrap .search-input:focus + .search-icon { color: var(--red); }

/* ---- Верхние кнопки ---- */
.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.top-actions .action-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
html[data-theme="light"] .top-actions .action-btn {
  background: rgba(0, 0, 0, 0.03);
}
.top-actions .action-btn:hover {
  background: var(--glass-hover);
  border-color: var(--glass-border);
  color: var(--text-primary);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.top-actions .action-btn:active { transform: scale(0.92); }
.top-actions .action-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top-actions .avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.10);
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  cursor: pointer;
  transition: all var(--transition);
  overflow: hidden;
  flex-shrink: 0;
}
.top-actions .avatar-btn:hover {
  transform: scale(1.08) rotate(2deg);
  border-color: var(--red);
  box-shadow: 0 0 28px var(--red-glow);
}
.top-actions .avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-layout {
  display: flex;
  flex: 1;
  gap: 14px;
  margin-top: 14px;
  min-height: 0;
  position: relative;
  z-index: 5;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 72px;
  flex-shrink: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  overflow-y: auto;
}
.sidebar:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
.sidebar .nav-item {
  width: 100%;
  aspect-ratio: 1/1;
  max-width: 52px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
  padding: 4px;
}
.sidebar .nav-item .nav-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.6;
  transition: all var(--transition);
}
.sidebar .nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar .nav-item:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: var(--glass-border);
  transform: translateY(-2px) scale(1.04);
}
.sidebar .nav-item:active { transform: scale(0.92); }
.sidebar .nav-item.active {
  background: var(--glass-active);
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 24px var(--red-glow);
  transform: scale(1.02);
}
.sidebar .nav-item.active .nav-label {
  color: var(--red);
  opacity: 1;
}
.sidebar .nav-spacer { flex: 1; min-height: 8px; }
.sidebar .nav-item.bottom { margin-top: auto; }
.sidebar .nav-item .nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 0 12px var(--red-glow);
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.75; }
}

/* ============================================================
   CONTENT
   ============================================================ */
.content {
  flex: 1;
  min-width: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: all var(--transition);
  overflow: hidden;
  position: relative;
}
.content:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.content::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 60%;
  height: 70%;
  background: radial-gradient(ellipse, rgba(229, 62, 62, 0.08), transparent 70%);
  pointer-events: none;
  border-radius: 50%;
}
.content::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -20%;
  width: 50%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(229, 62, 62, 0.05), transparent 70%);
  pointer-events: none;
  border-radius: 50%;
}

/* ============================================================
   CHAT LAYOUT
   ============================================================ */
.chat-layout {
  display: flex;
  flex: 1;
  height: 100%;
  position: relative;
  z-index: 2;
}

.chat-list-panel {
  width: 340px;
  flex-shrink: 0;
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(8px);
  transition: width var(--transition);
  overflow: hidden;
}
html[data-theme="light"] .chat-list-panel {
  background: rgba(255, 255, 255, 0.3);
}
.chat-list-panel .panel-header {
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chat-list-panel .panel-header svg {
  width: 20px;
  height: 20px;
  stroke: var(--red);
  fill: none;
  stroke-width: 2;
}
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.chat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  position: relative;
}
html[data-theme="light"] .chat-item {
  border-bottom-color: rgba(0,0,0,0.03);
}
.chat-item:hover { background: var(--glass-hover); }
.chat-item.active {
  background: var(--glass-active);
  border-left: 3px solid var(--red);
}
.chat-item .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 12px var(--red-glow);
  overflow: hidden;
}
.chat-item .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.chat-item .info { flex: 1; min-width: 0; }
.chat-item .info .name {
  font-weight: 500;
  font-size: 15px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-item .info .last-msg {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item .info .last-msg .file-preview {
  color: var(--red);
  font-weight: 500;
}
.chat-item .time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chat-item .unread-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 0 12px var(--red-glow);
  margin-left: 6px;
}

/* ---- Chat window ---- */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.1);
  backdrop-filter: blur(4px);
  min-width: 0;
}
html[data-theme="light"] .chat-window {
  background: rgba(255, 255, 255, 0.2);
}
.chat-window .window-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}
html[data-theme="light"] .chat-window .window-header {
  background: rgba(255, 255, 255, 0.4);
}
.chat-window .window-header .back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}
.chat-window .window-header .back-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.chat-window .window-header .partner-name {
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-window .window-header .partner-username {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 6px;
}
.chat-window .window-header .partner-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.chat-window .window-header .partner-status .call-mini-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.chat-window .window-header .partner-status .call-mini-btn:hover {
  background: rgba(39, 174, 96, 0.2);
  border-color: var(--green);
  color: #7ddfa8;
  transform: scale(1.1);
}
.chat-window .window-header .partner-status .call-mini-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-window .messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ==================== СООБЩЕНИЯ (без анимации) ==================== */

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 6px;
  max-width: 100%;
  animation: none !important;
}
.msg-row.incoming { justify-content: flex-start; }
.msg-row.outgoing { justify-content: flex-end; }

.msg-row .msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  align-self: flex-end;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.msg-row .msg-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.msg-row.outgoing .msg-avatar { display: none; }

.msg-bubble {
  max-width: 65%;
  min-width: 80px;
  padding: 9px 14px 22px 14px;
  border-radius: 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  position: relative;
  word-wrap: break-word;
  font-size: 14.5px;
  line-height: 1.42;
  color: var(--text-primary);
}

.msg-row.incoming .msg-bubble {
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 18px;
}

.msg-row.outgoing .msg-bubble {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  border-color: transparent;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 12px var(--red-glow);
}

.msg-row.incoming .msg-bubble::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -6px;
  width: 12px;
  height: 12px;
  background: var(--glass-bg);
  border-left: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  border-bottom-left-radius: 16px 14px;
  clip-path: path('M 12 0 Q 0 0 0 12 L 12 12 Z');
}
.msg-row.outgoing .msg-bubble::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -6px;
  width: 12px;
  height: 12px;
  background: var(--red-dark);
  border-bottom-right-radius: 16px 14px;
  clip-path: path('M 0 0 Q 12 0 12 12 L 0 12 Z');
}

.msg-bubble .msg-meta {
  position: absolute;
  right: 10px;
  bottom: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}
.msg-row.outgoing .msg-bubble .msg-meta {
  color: rgba(255, 255, 255, 0.75);
}

.msg-bubble .msg-status {
  font-size: 12px;
  letter-spacing: -1px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.msg-bubble .msg-status.read {
  color: #7fd1ff;
}
.msg-bubble .msg-status.delivered {
  color: rgba(255, 255, 255, 0.85);
}
.msg-bubble .msg-status.sent {
  color: rgba(255, 255, 255, 0.6);
}
.msg-row.incoming .msg-bubble .msg-status {
  color: var(--text-muted);
}

.msg-bubble .msg-text {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-bubble.edited .msg-meta::before {
  content: '(изм.)';
  font-size: 10px;
  opacity: 0.7;
  margin-right: 2px;
}

/* === ФОТО В СООБЩЕНИЯХ === */

.msg-bubble.has-image-only {
  padding: 3px;
  min-width: 0;
}
.msg-bubble.has-image-only .msg-meta {
  right: 10px;
  bottom: 8px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  padding: 2px 6px;
  border-radius: 8px;
  backdrop-filter: blur(6px);
}
.msg-bubble.has-image-only .msg-status { color: #fff !important; }

.msg-image-wrap {
  position: relative;
  display: block;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0,0,0,0.15);
  cursor: zoom-in;
  max-width: 320px;
  min-height: 60px;
  line-height: 0;
}
.msg-image-wrap.is-loaded {
  min-height: 0;
  background: transparent;
}
.msg-image-wrap.is-error {
  display: none;
}
.msg-bubble:not(.has-image-only) .msg-image-wrap { margin-bottom: 6px; }

.msg-image-wrap .msg-image {
  display: block;
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  opacity: 1;
}
.msg-image-wrap.is-loaded .msg-image { opacity: 1; }

.msg-image-wrap .img-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.10) 50%,
    rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
}
.msg-image-wrap.is-loaded .img-shimmer { display: none; }

/* === ОБЫЧНЫЕ ФАЙЛЫ === */

.msg-attachment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.08);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  cursor: pointer;
  max-width: 100%;
  min-width: 220px;
  margin-top: 4px;
}
.msg-row.outgoing .msg-attachment {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.18);
}
.msg-attachment:hover {
  background: rgba(255,255,255,0.10);
}
.msg-row.outgoing .msg-attachment:hover {
  background: rgba(255,255,255,0.22);
}
.msg-attachment .file-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.msg-row.outgoing .msg-attachment .file-icon {
  background: rgba(255,255,255,0.22);
}
.msg-attachment .file-info { flex: 1; min-width: 0; }
.msg-attachment .file-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-attachment .file-size {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.msg-row.outgoing .msg-attachment .file-size {
  color: rgba(255,255,255,0.75);
}

/* ==================== ПОСТЫ КАНАЛОВ (без анимации) ==================== */

.channel-post {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  margin-bottom: 14px;
  overflow: hidden;
  max-width: 480px;
  width: 100%;
  animation: none !important;
}
.channel-post:hover {
  border-color: rgba(255,255,255,0.14);
}

.post-author {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
}
.post-author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.post-author-avatar img { width: 100%; height: 100%; object-fit: cover; }
.post-author-info { flex: 1; min-width: 0; }
.post-author-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-author-username {
  font-size: 12px;
  color: var(--text-muted);
}
.post-delete-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  flex-shrink: 0;
}
.channel-post:hover .post-delete-btn { opacity: 1; }
.post-delete-btn:hover {
  background: rgba(229, 62, 62, 0.15);
  border-color: rgba(229, 62, 62, 0.4);
  color: #f8a5a5;
}
.post-delete-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.post-content {
  padding: 0;
}
.post-content .msg-text {
  display: block;
  padding: 0 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  line-height: 1.45;
}
.post-content .msg-attachment {
  margin: 8px 14px 12px;
  min-width: 0;
  width: calc(100% - 28px);
}

/* === ФОТО В ПОСТАХ === */

.post-image-wrap {
  position: relative;
  display: block;
  background: rgba(0,0,0,0.15);
  cursor: zoom-in;
  overflow: hidden;
  min-height: 100px;
  margin: 0 0 10px;
  line-height: 0;
}
.post-image-wrap.is-loaded {
  min-height: 0;
  background: transparent;
}
.post-image-wrap.is-error {
  display: none;
}

.post-image-wrap .post-image {
  display: block;
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  opacity: 1;
}
.post-image-wrap.is-loaded .post-image { opacity: 1; }

.post-image-wrap .img-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.10) 50%,
    rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
}
.post-image-wrap.is-loaded .img-shimmer { display: none; }

.post-time {
  padding: 8px 14px 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

/* ==================== LIGHTBOX ==================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.visible { display: flex; }

.lightbox-inner {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lightbox-inner img {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
  user-select: none;
}

.lightbox-caption {
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  text-align: center;
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10000;
}
.lightbox-close:hover {
  background: rgba(255,255,255,0.18);
  transform: scale(1.08);
}
.lightbox-close svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lightbox-download {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
  backdrop-filter: blur(10px);
}
.lightbox-download:hover {
  background: rgba(255,255,255,0.2);
}
.lightbox-download svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Прогресс загрузки ---- */
.upload-progress {
  display: none;
  padding: 10px 16px;
  background: var(--glass-bg);
  border-top: 1px solid var(--glass-border);
  font-size: 12px;
  color: var(--text-secondary);
}
.upload-progress.visible { display: block; }
.upload-progress .progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.upload-progress .file-name-preview {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}
.upload-progress .bar {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.upload-progress .bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--red), var(--red-dark));
  transition: width 0.2s;
}

/* ---- Кнопка прикрепления ---- */
.attach-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
html[data-theme="light"] .attach-btn {
  background: rgba(0,0,0,0.03);
}
.attach-btn:hover {
  background: var(--glass-hover);
  color: var(--red);
  border-color: var(--red);
  transform: scale(1.08);
}
.attach-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================================
   CHAT INPUT AREA
   ============================================================ */
.chat-input-area {
  padding: 12px 24px 16px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}
html[data-theme="light"] .chat-input-area {
  background: rgba(255, 255, 255, 0.4);
}
.chat-input-area input[type="text"] {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
html[data-theme="light"] .chat-input-area input[type="text"] {
  background: rgba(0,0,0,0.03);
}
.chat-input-area input[type="text"]:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-glow);
}
.chat-input-area .send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px var(--red-glow);
  flex-shrink: 0;
}
.chat-input-area .send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px var(--red-glow);
}
.chat-input-area .send-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Empty state ---- */
.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
}
.empty-chat svg {
  width: 64px;
  height: 64px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 1.5;
  opacity: 0.3;
}

/* ============================================================
   BOTTOM NAV (Mobile)
   ============================================================ */
.bottom-nav {
  display: none;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
  padding: 8px 12px;
  flex-shrink: 0;
  margin-top: 14px;
  justify-content: space-around;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
}
.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  flex: 1;
  max-width: 72px;
  position: relative;
}
.bottom-nav .nav-item .nav-label {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  opacity: 0.5;
  transition: all var(--transition);
}
.bottom-nav .nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bottom-nav .nav-item:hover {
  color: var(--text-primary);
  background: var(--glass-hover);
  transform: translateY(-2px);
}
.bottom-nav .nav-item.active {
  color: var(--red);
  background: var(--glass-active);
  border-color: var(--red);
  box-shadow: 0 0 24px var(--red-glow);
  transform: translateY(-2px);
}
.bottom-nav .nav-item.active .nav-label {
  color: var(--red);
  opacity: 1;
}
.bottom-nav .nav-item .nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 0 12px var(--red-glow);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .app { padding: 10px 12px; }
  .content { padding: 0; }
}

@media (max-width: 768px) {
  .app { padding: 8px 10px; }
  .top-bar {
    padding: 8px 14px;
    height: 60px;
    border-radius: var(--radius-sm);
  }
  .logo-icon { width: 36px; height: 36px; }
  .logo-text { font-size: 18px; }
  .top-actions .action-btn { width: 36px; height: 36px; font-size: 16px; }
  .top-actions .avatar-btn { width: 36px; height: 36px; font-size: 14px; }

  .sidebar { display: none; }
  .bottom-nav { display: flex; }

  .content { border-radius: var(--radius-sm); margin-bottom: 0; }
  .chat-list-panel {
    width: 100%;
    border-right: none;
  }
  .chat-window .window-header .back-btn { display: flex; }
  .chat-window { display: none; }
  .chat-window.visible-mobile { display: flex; }
  .chat-list-panel.hidden-mobile { display: none; }
  .search-wrap { display: none; }
  .main-layout { gap: 10px; margin-top: 10px; }

  .chat-input-area { padding: 10px 14px 12px; gap: 8px; }
  .attach-btn { width: 40px; height: 40px; }
  .chat-input-area .send-btn { width: 40px; height: 40px; }

  .messages-area { padding: 14px 12px; }
  .msg-bubble { max-width: 80%; font-size: 14px; }
  .msg-image-wrap { max-width: 260px; }
  .msg-image-wrap .msg-image { max-height: 320px; }
  .channel-post { max-width: 100%; border-radius: 14px; }
  .post-image-wrap .post-image { max-height: 380px; }
  .lightbox-close { top: 12px; right: 12px; width: 40px; height: 40px; }
  .lightbox-download { bottom: 16px; }
}

@media (max-width: 420px) {
  .app { padding: 6px; }
  .top-bar { padding: 6px 10px; height: 54px; border-radius: 10px; }
  .logo-icon { width: 32px; height: 32px; }
  .logo-text { font-size: 16px; }
  .top-actions .action-btn { width: 32px; height: 32px; font-size: 14px; }
  .top-actions .avatar-btn { width: 32px; height: 32px; font-size: 12px; }
  .content { border-radius: 10px; }
  .chat-item { padding: 10px 14px; }
  .chat-item .avatar { width: 36px; height: 36px; font-size: 14px; }
  .messages-area { padding: 12px 16px; }
  .chat-input-area { padding: 8px 12px 10px; }
  .bottom-nav { padding: 6px 8px; border-radius: 10px; gap: 2px; margin-top: 10px; }
  .bottom-nav .nav-item { padding: 6px 8px; max-width: 60px; }
  .bottom-nav .nav-item .nav-label { font-size: 8px; }
}

/* ============================================================
   CONTACTS PANEL
   ============================================================ */
.contacts-panel {
  display: none;
  flex-direction: column;
  padding: 20px;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}
.contacts-panel.visible { display: flex; }
.contacts-panel .contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: all var(--transition);
  cursor: pointer;
}
.contacts-panel .contact-item:hover { background: var(--glass-hover); }
.contacts-panel .contact-item .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.contacts-panel .contact-item .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.contacts-panel .contact-item .info { flex: 1; }
.contacts-panel .contact-item .info .name {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.contacts-panel .contact-item .info .username {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   SEARCH RESULTS
   ============================================================ */
#searchResults {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: var(--shadow-glass);
}
#searchResults .contact-item {
  padding: 8px 16px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background var(--transition);
}
#searchResults .contact-item:hover { background: var(--glass-hover); }
#searchResults .contact-item .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
#searchResults .contact-item .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
#searchResults .contact-item .info { flex: 1; min-width: 0; }
#searchResults .contact-item .info .name {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
#searchResults .contact-item .info .username {
  font-size: 12px;
  color: var(--text-muted);
}
#searchResults .no-results {
  padding: 12px;
  color: var(--text-muted);
  text-align: center;
}

.search-section-label {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-top: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.15);
}
.search-section-label:first-child {
  border-top: none;
}

/* ============================================================
   ONLINE DOT & LOCK
   ============================================================ */
.online-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background-color: var(--green);
  flex-shrink: 0;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
  margin-left: 8px;
}
.online-dot.offline {
  background-color: #888;
  box-shadow: none;
}
.chat-item .online-dot,
.contact-item .online-dot { margin-left: auto; }
.lock-icon {
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}
.lock-icon svg {
  width: 16px; height: 16px;
  stroke: var(--text-secondary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================================
   CONTEXT MENU
   ============================================================ */
#contextMenu {
  display: none;
  position: fixed;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-glass);
  padding: 6px 0;
  min-width: 180px;
  z-index: 1000;
}
#contextMenu .context-item {
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
  transition: background var(--transition);
}
#contextMenu .context-item:hover { background: var(--glass-hover); }
#contextMenu .context-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 4px 12px;
}

/* ============================================================
   MESSAGE STATUS (legacy, оставлено для совместимости)
   ============================================================ */
.msg-status {
  font-size: 11px;
  letter-spacing: 1px;
  margin-left: 4px;
}
.msg-status.delivered { color: rgba(255,255,255,0.7); }
.msg-status.read { color: #6dd5ff; }

/* ============================================================
   INCOMING CALL MODAL
   ============================================================ */
.incoming-call-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  align-items: center;
  justify-content: center;
}
.incoming-call-overlay.visible { display: flex; }

.incoming-call-box {
  width: 100%;
  max-width: 380px;
  padding: 36px 28px 28px;
  background: var(--glass-bg);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.incoming-call-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 8px 40px var(--red-glow);
  position: relative;
}
.incoming-call-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.incoming-call-avatar::after {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 3px solid var(--red);
  pointer-events: none;
}

.incoming-call-name {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.incoming-call-username {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: -12px;
}
.incoming-call-type {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: rgba(229, 62, 62, 0.15);
  color: #f8a5a5;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(229, 62, 62, 0.3);
}
.incoming-call-type svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.incoming-call-actions {
  display: flex;
  gap: 30px;
  margin-top: 12px;
  justify-content: center;
}
.incoming-call-actions button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all var(--transition);
}
.incoming-call-actions button:hover { transform: scale(1.08); }
.incoming-call-actions button:active { transform: scale(0.94); }
.incoming-call-actions button svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.incoming-call-actions button.btn-reject {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  box-shadow: 0 4px 24px var(--red-glow);
}
.incoming-call-actions button.btn-accept {
  background: linear-gradient(135deg, var(--green), #1e8449);
  box-shadow: 0 4px 24px var(--green-glow);
}

/* ============================================================
   WS STATUS INDICATOR
   ============================================================ */
.ws-indicator {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 500;
  transition: opacity 0.5s;
}
.ws-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
  transition: background 0.3s;
}
.ws-indicator.connected .dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.ws-indicator.connecting .dot {
  background: #f39c12;
}
@keyframes blinkDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============================================================
   MESSAGE TOAST
   ============================================================ */
.msg-toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  max-width: 320px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  z-index: 3000;
  display: none;
  cursor: pointer;
}
.msg-toast.visible { display: block; }
.msg-toast .toast-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.msg-toast .toast-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.msg-toast .toast-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.msg-toast .toast-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.msg-toast .toast-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   VERIFIED BADGE (красная галочка)
   ============================================================ */
.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  box-shadow: 0 0 6px var(--red-glow);
  flex-shrink: 0;
  margin-left: 4px;
  vertical-align: middle;
}
.verified-badge svg {
  width: 9px;
  height: 9px;
  stroke: #fff;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-window .window-header .partner-name .verified-badge {
  width: 18px;
  height: 18px;
  margin-left: 6px;
}
.chat-window .window-header .partner-name .verified-badge svg {
  width: 11px;
  height: 11px;
}
.chat-item .info .name .verified-badge {
  width: 14px;
  height: 14px;
}
.contact-item .info .name .verified-badge {
  width: 14px;
  height: 14px;
}
.msg-toast .toast-name .verified-badge {
  width: 13px;
  height: 13px;
  margin-left: 4px;
}
.msg-toast .toast-name .verified-badge svg {
  width: 8px;
  height: 8px;
}
.incoming-call-name .verified-badge {
  width: 20px;
  height: 20px;
  margin-left: 8px;
}
.incoming-call-name .verified-badge svg {
  width: 12px;
  height: 12px;
}

/* ============================================================
   BOTS
   ============================================================ */
.bot-badge-inline {
  display: inline-block;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(229, 62, 62, 0.15);
  color: #f8a5a5;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid rgba(229, 62, 62, 0.3);
  margin-left: 8px;
  vertical-align: middle;
}
.bot-badge-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: rgba(229, 62, 62, 0.15);
  border: 1px solid rgba(229, 62, 62, 0.3);
  font-size: 11px;
  flex-shrink: 0;
  margin-left: auto;
}

.bot-start-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 24px;
  text-align: center;
}
.bot-start-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  color: #fff;
  box-shadow: 0 8px 40px var(--red-glow);
  margin-bottom: 12px;
  overflow: hidden;
}
.bot-start-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bot-start-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.bot-start-username {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.bot-start-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.55;
  margin-bottom: 20px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bot-start-btn {
  padding: 13px 52px;
  border-radius: var(--radius-full);
  border: none;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 24px var(--red-glow);
  letter-spacing: 0.3px;
}
.bot-start-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--red-glow);
}
.bot-start-btn:active:not(:disabled) {
  transform: scale(0.97);
}
.bot-start-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bot-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  padding: 12px 18px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  margin: 4px 0;
}
.bot-typing .dot-anim {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* ============================================================
   CHANNELS
   ============================================================ */
.channel-badge-inline {
  display: inline-block;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(229, 62, 62, 0.15);
  color: #f8a5a5;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid rgba(229, 62, 62, 0.3);
  margin-left: 8px;
  vertical-align: middle;
}
.channel-badge-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: rgba(229, 62, 62, 0.15);
  border: 1px solid rgba(229, 62, 62, 0.3);
  font-size: 11px;
  flex-shrink: 0;
  margin-left: auto;
}

.channel-readonly-notice {
  padding: 14px 20px;
  background: rgba(255,255,255,0.03);
  border-top: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  flex-shrink: 0;
  font-weight: 500;
  letter-spacing: 0.2px;
}
html[data-theme="light"] .channel-readonly-notice {
  background: rgba(0,0,0,0.03);
}

.channel-subscribe-notice {
  padding: 16px 20px;
  background: rgba(255,255,255,0.03);
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.channel-subscribe-notice .notice-text {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}
.channel-subscribe-notice .subscribe-btn {
  padding: 11px 32px;
  border-radius: var(--radius-full);
  border: none;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 20px var(--red-glow);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.channel-subscribe-notice .subscribe-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--red-glow);
}
.channel-subscribe-notice .subscribe-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-window .window-header .channel-avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--transition);
  border: 2px solid transparent;
  display: none;
  flex-shrink: 0;
}
.chat-window .window-header .channel-avatar-btn.visible {
  display: flex;
}
.chat-window .window-header .channel-avatar-btn:hover {
  border-color: var(--red);
  transform: scale(1.05);
}
.chat-window .window-header .channel-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.channel-profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.channel-profile-overlay.visible { display: flex; }

.channel-profile-modal {
  background: var(--glass-bg);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-glass);
  padding: 32px 28px 26px;
  position: relative;
}
.channel-profile-modal .modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.channel-profile-modal .modal-close:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}
.channel-profile-modal .modal-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.channel-profile-modal .channel-big-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 8px 32px var(--red-glow);
  border: 3px solid rgba(255,255,255,0.08);
  margin: 0 auto 16px;
}
.channel-profile-modal .channel-big-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.channel-profile-modal .channel-big-name {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.channel-profile-modal .channel-big-username {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 6px;
}
.channel-profile-modal .channel-big-badge {
  display: block;
  width: fit-content;
  margin: 0 auto 12px;
  font-size: 10px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(229, 62, 62, 0.15);
  color: #f8a5a5;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid rgba(229, 62, 62, 0.3);
}
.channel-profile-modal .channel-big-subs {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 18px;
}
.channel-profile-modal .channel-big-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  padding: 14px 16px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}
.channel-profile-modal .channel-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.channel-profile-modal .channel-action-btn {
  width: 100%;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.channel-profile-modal .channel-action-btn:hover {
  background: var(--glass-hover);
  transform: translateY(-1px);
}
.channel-profile-modal .channel-action-btn.primary {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border: none;
  color: #fff;
  box-shadow: 0 4px 20px var(--red-glow);
}
.channel-profile-modal .channel-action-btn.subscribed {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}
.channel-profile-modal .channel-action-btn.subscribed:hover {
  background: rgba(229, 62, 62, 0.15);
  color: #f8a5a5;
  border-color: rgba(229, 62, 62, 0.3);
}
.channel-profile-modal .channel-action-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-item[data-ischannel="true"] .avatar {
  position: relative;
}
.chat-item[data-ischannel="true"] .avatar::after {
  content: '📢';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  border: 2px solid var(--bg-primary);
}

/* ============================================================
   RESPONSIVE для ботов и каналов
   ============================================================ */
@media (max-width: 768px) {
  .bot-start-icon { width: 80px; height: 80px; font-size: 36px; }
  .bot-start-name { font-size: 19px; }
  .bot-start-btn { padding: 12px 44px; font-size: 14px; }

  .channel-profile-modal {
    padding: 24px 20px 20px;
    max-width: 100%;
  }
  .channel-profile-modal .channel-big-avatar {
    width: 90px;
    height: 90px;
    font-size: 36px;
  }
  .channel-profile-modal .channel-big-name { font-size: 19px; }
}

/* ============================================================
   ГЛОБАЛЬНО ОТКЛЮЧАЕМ АНИМАЦИЮ ПОЯВЛЕНИЯ СООБЩЕНИЙ/ПОСТОВ
   (устраняет дёргание при обновлении и отправке)
   ============================================================ */
.msg-row,
.msg-row.msg-enter,
.channel-post,
.channel-post.msg-enter {
  animation: none !important;
  transform: none !important;
  opacity: 1 !important;
  transition: none !important;
}
.msg-bubble,
.post-image-wrap,
.msg-image-wrap,
.msg-attachment {
  transition: none !important;
}
.msg-bubble:hover,
.channel-post:hover {
  transform: none !important;
}

/* ============================================================
   [FIX] Не даём flex-column сжимать сообщения и посты.
   Без этого при большом количестве контента (фото, длинные
   каналы) они «сворачивались», вместо того чтобы уходить вверх.
   ============================================================ */
.messages-area > * {
  flex-shrink: 0;
}