/* ==========================================================================
   Telegram Messenger - Multi-Theme Design System (UI/UX Pro Max)
   ========================================================================== */

/* 1. Default: Telegram Dark Theme */
:root, [data-theme="telegram-dark"] {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-active: rgba(2, 132, 199, 0.2);
  --bg-hover: rgba(30, 41, 59, 0.7);
  --hover-overlay: rgba(30, 41, 59, 0.7);

  --accent-blue: #0284c7;
  --accent-blue-hover: #0369a1;
  --accent-blue-light: #38bdf8;
  --accent-ring: rgba(56, 189, 248, 0.4);

  --bubble-in: #1E293B;
  --bubble-out: #2563EB;
  --bubble-in-hover: #26354a;
  --bubble-out-hover: #1d4ed8;

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-out-time: #bfdbfe;

  --online-green: #10B981;
  --danger-red: #ef4444;
  --danger-red-hover: #dc2626;
  --warning-amber: #f59e0b;

  --border-color: #334155;
  --border-subtle: rgba(51, 65, 85, 0.6);
  --modal-bg: #0F172A;
  --input-bg: #1E293B;
  --shadow-card: 0 20px 45px rgba(0, 0, 0, 0.65);
}

/* 2. Midnight OLED (Deep Black) */
[data-theme="midnight"] {
  --bg-primary: #000000;
  --bg-secondary: #0f0f10;
  --bg-active: #1c1c1e;
  --bg-hover: rgba(255, 255, 255, 0.08);
  --hover-overlay: rgba(255, 255, 255, 0.08);

  --accent-blue: #2481cc;
  --accent-blue-hover: #1e6eb0;
  --accent-blue-light: #52a9ea;
  --accent-ring: rgba(36, 129, 204, 0.4);

  --bubble-in: #18181a;
  --bubble-out: #24466b;
  --bubble-in-hover: #222226;
  --bubble-out-hover: #2c5480;

  --text-primary: #ffffff;
  --text-secondary: #8e8e93;
  --text-muted: #636366;
  --text-out-time: #8bb2d4;

  --online-green: #30d158;
  --danger-red: #ff453a;
  --danger-red-hover: #d9382f;
  --warning-amber: #ffd60a;

  --border-color: #1a1a1c;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --modal-bg: #121214;
  --input-bg: #070708;
  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.85);
}

/* 3. Telegram Day / Light */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f4f6f8;
  --bg-active: #e3e8ed;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --hover-overlay: rgba(0, 0, 0, 0.04);

  --accent-blue: #2481cc;
  --accent-blue-hover: #1b6cae;
  --accent-blue-light: #2481cc;
  --accent-ring: rgba(36, 129, 204, 0.25);

  --bubble-in: #ffffff;
  --bubble-out: #e3f2fd;
  --bubble-in-hover: #f8fafc;
  --bubble-out-hover: #d4eafc;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-out-time: #1e6eb0;

  --online-green: #22c55e;
  --danger-red: #ef4444;
  --danger-red-hover: #dc2626;
  --warning-amber: #f59e0b;

  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;
  --modal-bg: #ffffff;
  --input-bg: #f8fafc;
  --shadow-card: 0 16px 40px rgba(15, 23, 42, 0.15);
}

/* 4. Emerald Forest */
[data-theme="emerald"] {
  --bg-primary: #091712;
  --bg-secondary: #10241d;
  --bg-active: #18362b;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --hover-overlay: rgba(255, 255, 255, 0.06);

  --accent-blue: #10b981;
  --accent-blue-hover: #059669;
  --accent-blue-light: #34d399;
  --accent-ring: rgba(16, 185, 129, 0.4);

  --bubble-in: #142a22;
  --bubble-out: #1b4938;
  --bubble-in-hover: #1a382d;
  --bubble-out-hover: #225c47;

  --text-primary: #f0fdf4;
  --text-secondary: #86efac;
  --text-muted: #4b8b73;
  --text-out-time: #a7f3d0;

  --online-green: #34d399;
  --danger-red: #f87171;
  --danger-red-hover: #ef4444;
  --warning-amber: #fbbf24;

  --border-color: #0d221a;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --modal-bg: #122820;
  --input-bg: #091712;
  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.7);
}

/* 5. Neon Violet / Cyberpunk */
[data-theme="violet"] {
  --bg-primary: #0d071a;
  --bg-secondary: #170d2b;
  --bg-active: #261647;
  --bg-hover: rgba(255, 255, 255, 0.07);
  --hover-overlay: rgba(255, 255, 255, 0.07);

  --accent-blue: #8b5cf6;
  --accent-blue-hover: #7c3aed;
  --accent-blue-light: #a78bfa;
  --accent-ring: rgba(139, 92, 246, 0.4);

  --bubble-in: #1e1138;
  --bubble-out: #4c2889;
  --bubble-in-hover: #271747;
  --bubble-out-hover: #5d32a6;

  --text-primary: #faf5ff;
  --text-secondary: #c4b5fd;
  --text-muted: #8b7ab8;
  --text-out-time: #ddd6fe;

  --online-green: #4ade80;
  --danger-red: #f43f5e;
  --danger-red-hover: #e11d48;
  --warning-amber: #facc15;

  --border-color: #170d2b;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --modal-bg: #190e30;
  --input-bg: #0d071a;
  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.75);
}

/* ==========================================================================
   Base
   ========================================================================== */
:root {
  --font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --rail-w: 64px;
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }

html, body { height: 100%; }
body {
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.4;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font-family: inherit; color: inherit; }
ul { list-style: none; }
:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120, 140, 160, 0.28); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 140, 160, 0.5); }

/* Icons */
.icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  display: block;
}
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 40px; height: 40px; }

/* Generic icon button */
.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast), transform 0.12s ease;
}
.icon-btn:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.accent-btn { background-color: var(--accent-blue); color: #fff; border-radius: var(--radius-md); box-shadow: 0 4px 12px var(--accent-ring); }
.icon-btn.accent-btn:hover { background-color: var(--accent-blue-hover); color: #fff; }

/* Avatars */
.avatar {
  width: 50px; height: 50px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px; font-weight: 600; line-height: 1;
  color: #fff; letter-spacing: 0;
  background-color: var(--accent-blue);
  background-size: cover; background-position: center; background-repeat: no-repeat;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.avatar-md { width: 44px; height: 44px; font-size: 16px; }
.avatar-xl { width: 88px; height: 88px; font-size: 30px; }
.avatar-wrapper { position: relative; width: 50px; height: 50px; flex-shrink: 0; }
.header-avatar-wrapper { width: 44px; height: 44px; }

.online-indicator, .status-dot {
  position: absolute; bottom: 0; right: 0;
  width: 13px; height: 13px;
  background-color: var(--online-green);
  border: 2px solid var(--bg-primary);
  border-radius: var(--radius-full);
}
.chat-item.active .online-indicator { border-color: var(--bg-active); }

/* ==========================================================================
   App shell
   ========================================================================== */
.app-shell { display: flex; height: 100%; width: 100%; overflow: hidden; position: relative; }

/* ---- Rail ---- */
.rail {
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 12px 0;
  z-index: 30;
  overflow: hidden;
}
.rail-group { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail-btn {
  position: relative;
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.rail-btn:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.rail-btn.active { background-color: var(--bg-active); color: var(--accent-blue-light); }
.rail-profile { position: relative; cursor: pointer; margin-top: 4px; }
.rail-profile .status-dot { border-color: var(--bg-secondary); }
.rail-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-full);
  background-color: var(--accent-blue); color: #fff;
  border: 2px solid var(--bg-secondary);
  font-size: 10px; font-weight: 700; line-height: 14px;
  align-items: center; justify-content: center; text-align: center;
  box-sizing: content-box; width: auto;
}

/* ---- Sidebar (chat list) ---- */
.sidebar {
  width: 360px; flex: 0 0 360px;
  background-color: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  height: 100%; min-width: 0;
  position: relative; z-index: 20;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), flex-basis 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease;
}
.sidebar.collapsed {
  width: 0; flex-basis: 0; min-width: 0; opacity: 0; overflow: hidden;
  border-right: none; pointer-events: none;
}
.sidebar-top { flex-shrink: 0; border-bottom: 1px solid var(--border-subtle); }
.sidebar-header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }

.search-container { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 13px; color: var(--text-muted); pointer-events: none; display: flex; }
.search-input {
  width: 100%; height: 40px;
  background-color: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 0 38px;
  font-size: 14.5px; color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-ring); }
.search-clear {
  position: absolute; right: 8px;
  width: 24px; height: 24px; border-radius: var(--radius-full);
  display: none; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.search-clear:hover { color: var(--text-primary); background: var(--bg-hover); }
.search-clear.visible { display: flex; }

.chat-tabs { display: flex; gap: 6px; padding: 4px 12px 10px; overflow-x: auto; scrollbar-width: none; }
.chat-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0; white-space: nowrap;
  padding: 6px 14px; border-radius: var(--radius-full);
  font-size: 13.5px; font-weight: 500;
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.tab-btn:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.tab-btn.active { background-color: var(--bg-active); color: var(--accent-blue-light); font-weight: 600; }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 0; }
.chat-empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 56px 24px; text-align: center; color: var(--text-muted); font-size: 14px;
}
.chat-empty-state svg { opacity: 0.5; }

.chat-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  margin: 2px 8px; padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.chat-item:hover { background-color: var(--bg-hover); }
.chat-item.active { background-color: var(--bg-active); }
.chat-item .avatar { width: 50px; height: 50px; }
.chat-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-info-top, .chat-info-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.chat-title-group { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.chat-title { font-size: 15px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-type-icon { color: var(--text-muted); flex-shrink: 0; }
.chat-time { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; white-space: nowrap; }
.chat-snippet { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-snippet.typing { color: var(--accent-blue-light); font-style: italic; font-weight: 500; }
.unread-badge {
  flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-full);
  background-color: var(--accent-blue); color: #fff;
  font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
}
.chat-item-delete {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: var(--radius-full);
  display: none; align-items: center; justify-content: center;
  background-color: var(--danger-red); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.chat-item-delete:hover { background-color: var(--danger-red-hover); }
@media (hover: hover) {
  .chat-item:hover .chat-item-delete { display: flex; }
  .chat-item:hover .chat-time, .chat-item:hover .unread-badge { visibility: hidden; }
}

.sidebar-footer {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
}
.sidebar-user-name { font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.user-status-text { display: inline-flex; align-items: center; gap: 6px; color: var(--online-green); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.status-dot-inline { width: 8px; height: 8px; border-radius: 50%; background: var(--online-green); }

/* ---- Chat window ---- */
.chat-window {
  flex: 1; min-width: 0; height: 100%;
  position: relative; display: flex; flex-direction: column;
  background-color: var(--bg-primary); overflow: hidden;
}
.chat-wallpaper {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-color: var(--bg-primary);
  background-size: cover; background-position: center; background-repeat: no-repeat;
}
.chat-wallpaper.pattern-default {
  background-image:
    radial-gradient(circle at 50% 40%, rgba(120,140,160,0.07) 0%, transparent 65%),
    radial-gradient(rgba(120, 140, 160, 0.16) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px;
  opacity: 0.9;
}
.chat-placeholder-view {
  flex: 1; z-index: 3; padding: 32px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
}
.placeholder-icon {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-active); color: var(--accent-blue-light);
  margin-bottom: 4px;
}
.placeholder-title { font-size: 20px; font-weight: 700; }
.placeholder-text { max-width: 340px; font-size: 14px; color: var(--text-secondary); line-height: 1.55; margin-bottom: 8px; }

.chat-active { flex: 1; min-height: 0; flex-direction: column; position: relative; z-index: 3; }

.chat-header {
  flex-shrink: 0; height: 64px; padding: 0 16px;
  display: flex; align-items: center; gap: 8px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 5;
}
.chat-header-user {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 4px 10px 4px 4px; margin-right: 4px;
  border-radius: var(--radius-md); cursor: pointer;
  transition: background-color var(--transition-fast);
}
.chat-header-user:hover { background-color: var(--bg-hover); }
.header-details { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.header-name { font-size: 16px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-status { font-size: 13px; line-height: 1.2; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-status.online { color: var(--online-green); }
.header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.call-btn:hover { background-color: var(--accent-blue); color: #fff; }
.delete-btn-header:hover { background-color: rgba(239, 68, 68, 0.15); color: var(--danger-red); }

/* Messages */
.messages-container {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px clamp(12px, 5vw, 56px);
  display: flex; flex-direction: column; gap: 6px;
}
.messages-container > :first-child { margin-top: auto; }
.date-divider {
  align-self: center; margin: 10px 0 6px;
  padding: 4px 14px; border-radius: var(--radius-full);
  background-color: rgba(0, 0, 0, 0.35); backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.88); font-size: 12px; font-weight: 600;
}
[data-theme="light"] .date-divider { background-color: rgba(0,0,0,0.12); color: var(--text-secondary); }

.message-bubble {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  max-width: min(70%, 560px); min-width: 72px;
  padding: 8px 12px 6px;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  line-height: 1.45;
  overflow-wrap: anywhere; word-break: break-word;
  user-select: text;
  animation: slideUpFade 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUpFade { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.message-bubble.incoming { align-self: flex-start; background-color: var(--bubble-in); border: 1px solid var(--border-subtle); border-bottom-left-radius: 4px; }
.message-bubble.outgoing { align-self: flex-end; background-color: var(--bubble-out); border-bottom-right-radius: 4px; }
.message-sender-name { font-size: 12px; font-weight: 700; color: var(--accent-blue-light); user-select: none; }
.message-text { font-size: 14.5px; white-space: pre-wrap; }
/* Время — отдельной строкой справа, не накладывается на текст */
.message-meta {
  align-self: flex-end;
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; line-height: 1; color: var(--text-secondary);
  user-select: none; white-space: nowrap;
}
.message-bubble.outgoing .message-meta { color: var(--text-out-time); }
.status-icon { display: inline-flex; align-items: center; }
.status-icon svg { display: block; }

.message-media-container { border-radius: var(--radius-md); overflow: hidden; }
.message-media-img { display: block; max-width: 100%; max-height: 340px; width: auto; height: auto; object-fit: cover; border-radius: var(--radius-md); cursor: pointer; }
.message-media-video { display: block; max-width: 100%; max-height: 340px; border-radius: var(--radius-md); background: #000; }
.message-media-audio { width: 100%; max-width: 280px; }
.message-file-chip {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: rgba(0,0,0,0.15); border-radius: var(--radius-md);
  text-decoration: none; color: inherit;
}
.message-file-chip:hover { background: rgba(0,0,0,0.25); }
.file-chip-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-blue); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-chip-info { display: flex; flex-direction: column; min-width: 0; }
.file-chip-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip-action { font-size: 11.5px; color: var(--accent-blue-light); }

.chat-typing-bar {
  display: none; align-items: center; gap: 8px;
  align-self: flex-start; margin: 0 clamp(12px, 5vw, 56px) 6px;
  padding: 5px 14px; border-radius: var(--radius-full);
  background: var(--bg-secondary); border: 1px solid var(--border-subtle);
  font-size: 13px; color: var(--accent-blue-light);
}
.chat-typing-bar.active { display: flex; }
.typing-dots { display: flex; gap: 4px; }
.typing-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-blue-light); animation: typingPulse 1.2s infinite ease-in-out; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingPulse { 0%,100% { transform: scale(0.6); opacity: 0.4; } 50% { transform: scale(1.1); opacity: 1; } }

/* Attachment preview */
.attachment-preview-bar {
  align-items: center; gap: 12px;
  width: calc(100% - 32px); max-width: 900px; margin: 0 auto;
  padding: 8px 12px;
  background: var(--bg-secondary); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); z-index: 6;
}
.attachment-preview-thumb-container {
  width: 42px; height: 42px; border-radius: var(--radius-md); overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--input-bg); border: 1px solid var(--border-subtle);
}
.attachment-preview-img { width: 100%; height: 100%; object-fit: cover; }
.attachment-preview-icon { color: var(--accent-blue-light); display: flex; align-items: center; justify-content: center; }
.attachment-preview-info { flex: 1; min-width: 0; }
.attachment-preview-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-preview-size { font-size: 11.5px; color: var(--text-muted); }
.attachment-remove-btn { width: 32px; height: 32px; }

/* Input */
.input-panel-wrapper {
  flex-shrink: 0; position: relative; z-index: 5;
  display: flex; justify-content: center;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg-secondary); border-top: 1px solid var(--border-color);
}
.input-panel { width: 100%; max-width: 900px; display: flex; align-items: flex-end; gap: 10px; }
.input-box-wrapper {
  flex: 1; min-width: 0; min-height: 46px;
  display: flex; align-items: flex-end; gap: 2px;
  padding: 3px 6px;
  background: var(--input-bg); border: 1px solid var(--border-subtle);
  border-radius: 23px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-box-wrapper:focus-within { border-color: var(--accent-blue); box-shadow: 0 0 0 2px var(--accent-ring); }
.input-action-btn {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.input-action-btn:hover { color: var(--accent-blue-light); background: var(--bg-hover); }
.message-textarea {
  flex: 1; min-width: 0; align-self: center;
  background: transparent; border: none; outline: none; resize: none;
  font-size: 15px; line-height: 22px;
  height: 22px; min-height: 22px; max-height: 140px;
  padding: 0 6px; margin: 8px 0;
  user-select: text;
}
.message-textarea::placeholder { color: var(--text-muted); }
.send-btn {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-blue); color: #fff;
  box-shadow: 0 2px 8px var(--accent-ring);
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}
.send-btn:hover { background: var(--accent-blue-hover); transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }
.send-btn .icon { margin: 0 2px 0 -2px; }

/* Popovers */
.popover {
  position: absolute; bottom: 76px; left: 16px; z-index: 40;
  min-width: 220px; padding: 6px;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  animation: popIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
.popover-item {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; text-align: left;
}
.popover-item:hover { background: var(--bg-hover); }
.popover-item-icon { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.tone-sky { background: rgba(56,189,248,0.18); color: #38bdf8; }
.tone-violet { background: rgba(167,139,250,0.18); color: #a78bfa; }

.emoji-picker-popover {
  position: absolute; bottom: 76px; right: 16px; z-index: 50;
  width: 340px; max-width: calc(100% - 24px); height: 380px;
  flex-direction: column; overflow: hidden;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.emoji-picker-header { padding: 10px 12px 6px; }
.emoji-search-box { display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: var(--input-bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-full); color: var(--text-muted); }
.emoji-search-input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; font-size: 13px; color: var(--text-primary); user-select: text; }
.emoji-categories-bar { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; border-bottom: 1px solid var(--border-subtle); }
.emoji-cat-btn { width: 34px; height: 34px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 17px; line-height: 1; }
.emoji-cat-btn:hover { background: var(--bg-hover); }
.emoji-cat-btn.active { background: var(--bg-hover); box-shadow: inset 0 -2px 0 var(--accent-blue); }
.emoji-grid-container { flex: 1; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; align-content: start; }
.emoji-item { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; cursor: pointer; border-radius: var(--radius-md); }
.emoji-item:hover { background: var(--bg-hover); }

/* ---- Right drawer ---- */
.info-drawer {
  width: 320px; flex: 0 0 320px; height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg-primary); border-left: 1px solid var(--border-color);
  z-index: 30;
}
.drawer-header { flex-shrink: 0; height: 64px; padding: 0 12px 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-subtle); }
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; }
.drawer-profile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 24px 20px; text-align: center; border-bottom: 1px solid var(--border-subtle); }
.drawer-profile .avatar { margin-bottom: 8px; }
.drawer-name { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.drawer-username { font-size: 13px; color: var(--accent-blue-light); font-weight: 500; }
.drawer-status { font-size: 13px; color: var(--text-secondary); }
.drawer-section { padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 14px; }
.drawer-row { flex-direction: row; align-items: center; justify-content: space-between; }
.drawer-row-label { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-primary); }
.drawer-row-label .icon { color: var(--text-secondary); }
.drawer-field { display: flex; flex-direction: column; gap: 2px; }
.drawer-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.drawer-value { font-size: 14px; color: var(--text-primary); line-height: 1.5; overflow-wrap: anywhere; }
.drawer-tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--border-subtle); }
.drawer-tab { padding: 0 0 10px; margin-bottom: -1px; font-size: 13px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid transparent; }
.drawer-tab:hover { color: var(--text-primary); }
.drawer-tab.active { color: var(--accent-blue-light); border-bottom-color: var(--accent-blue); }
.shared-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.shared-media-item { aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: var(--bg-secondary); }
.shared-media-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s; }
.shared-media-item:hover img { transform: scale(1.08); }
.shared-empty { grid-column: 1 / -1; text-align: center; padding: 16px 0; font-size: 13px; color: var(--text-muted); }

/* Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 12px; background: var(--border-color); transition: background-color var(--transition-fast); }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform var(--transition-fast); }
.switch input:checked + .switch-track { background: var(--accent-blue); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

/* ==========================================================================
   Buttons / forms
   ========================================================================== */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap; cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: var(--accent-blue-hover); box-shadow: 0 4px 12px var(--accent-ring); }
.btn-secondary { border: 1px solid var(--border-color); color: var(--text-primary); background: transparent; }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger-red); color: #fff; }
.btn-danger:hover { background: var(--danger-red-hover); }
.btn-ghost-danger { color: var(--danger-red); }
.btn-ghost-danger:hover { background: rgba(239,68,68,0.12); }
.btn-block { width: 100%; }
.btn-grow { flex: 1; }
.btn-small { padding: 7px 14px; font-size: 13px; }
.btn-with-icon .icon { flex-shrink: 0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-input {
  width: 100%; padding: 10px 14px;
  background: var(--input-bg); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14.5px; color: var(--text-primary); outline: none; user-select: text;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
textarea.form-input { resize: none; line-height: 1.45; }
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-ring); }
.input-prefix { position: relative; }
.input-prefix-sign { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-prefix .form-input { padding-left: 30px; }
.hint { display: block; font-size: 12px; color: var(--text-muted); }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  display: none !important; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.62); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.modal-backdrop.active { display: flex !important; opacity: 1; pointer-events: auto; }
.modal-dialog {
  position: relative; width: 440px; max-width: 100%; max-height: 100%; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
  padding: 24px;
  background: var(--modal-bg); border: 1px solid var(--border-subtle);
  border-radius: 22px; box-shadow: var(--shadow-card);
  user-select: text;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalPop { from { transform: scale(0.95) translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-title { font-size: 18px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.modal-subtitle { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.modal-close { position: absolute; top: 12px; right: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.modal-footer-center { justify-content: stretch; }
.modal-footer-split { justify-content: space-between; align-items: center; border-top: 1px solid var(--border-subtle); padding-top: 16px; flex-wrap: wrap; }
.modal-footer-actions { display: flex; gap: 10px; }

.auth-dialog { width: 400px; padding: 28px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.auth-logo { width: 56px; height: 56px; border-radius: 18px; background: var(--accent-blue); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px var(--accent-ring); margin-bottom: 6px; }
.auth-tabs { display: flex; border-bottom: 2px solid var(--border-subtle); }
.auth-tab-btn { flex: 1; padding: 10px; margin-bottom: -2px; font-size: 14.5px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid transparent; transition: color var(--transition-fast), border-color var(--transition-fast); }
.auth-tab-btn:hover { color: var(--text-primary); }
.auth-tab-btn.active { color: var(--accent-blue-light); border-bottom-color: var(--accent-blue); }
.auth-error { display: none; padding: 10px 14px; border-radius: var(--radius-sm); background: rgba(239,68,68,0.14); border: 1px solid var(--danger-red); color: var(--danger-red); font-size: 13px; }
.auth-error.active { display: block; }

.profile-dialog { width: 380px; }
.profile-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding-top: 8px; }
.profile-hero .avatar { margin-bottom: 6px; }
.info-card { padding: 12px 14px; border-radius: var(--radius-md); background: var(--input-bg); display: flex; flex-direction: column; gap: 4px; }
.profile-actions { display: flex; gap: 10px; }

.settings-dialog { width: 480px; }
.settings-profile-section { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--border-subtle); }
.settings-group { display: flex; flex-direction: column; gap: 14px; }
.settings-group-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-card {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; min-width: 0;
  background: var(--input-bg); border: 2px solid var(--border-subtle); border-radius: var(--radius-md);
  text-align: left; color: var(--text-primary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
.theme-card:hover { border-color: var(--accent-blue-light); }
.theme-card.active { border-color: var(--accent-blue); background: var(--bg-hover); }
.theme-preview-circles { display: flex; align-items: center; gap: 3px; flex-shrink: 0; min-width: 31px; color: var(--accent-blue-light); }
.theme-color-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(128,128,128,0.35); }
.theme-card-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--input-bg); cursor: pointer; }
.settings-row-title { display: block; font-size: 14px; font-weight: 600; }

.confirm-dialog { width: 360px; align-items: center; text-align: center; }
.confirm-icon { width: 52px; height: 52px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: rgba(239,68,68,0.16); color: var(--danger-red); }
.confirm-text { display: flex; flex-direction: column; gap: 6px; }
.confirm-dialog .modal-footer { width: 100%; }

.wallpaper-dialog { width: 440px; }
.wallpaper-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wallpaper-thumb { height: 76px; border-radius: var(--radius-md); cursor: pointer; border: 2px solid transparent; background-color: var(--bg-secondary); background-size: cover; background-position: center; transition: transform var(--transition-fast), border-color var(--transition-fast); }
.wallpaper-thumb:hover { transform: scale(1.04); border-color: var(--accent-blue); }
.wallpaper-thumb.pattern-default {
  background-image: radial-gradient(circle at 50% 40%, var(--accent-ring) 0%, transparent 65%), radial-gradient(rgba(120,140,160,0.25) 1px, transparent 1px);
  background-size: 100% 100%, 12px 12px;
}
.upload-wallpaper-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 1px dashed var(--accent-blue); border-radius: var(--radius-md); color: var(--accent-blue-light); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.upload-wallpaper-btn:hover { background: var(--bg-hover); }

/* Lightbox */
.lightbox-backdrop { background: rgba(0,0,0,0.9); z-index: 1000; }
.lightbox-content { position: relative; max-width: 100%; max-height: 100%; display: flex; align-items: center; justify-content: center; }
.lightbox-img { max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: var(--radius-md); box-shadow: 0 16px 48px rgba(0,0,0,0.6); }
.lightbox-close { position: absolute; top: -48px; right: 0; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.15); color: #fff; display: flex; align-items: center; justify-content: center; }
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* Toast */
.toast-notice {
  position: fixed; top: 20px; left: 50%; z-index: 1500;
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 32px); padding: 10px 18px;
  background: var(--modal-bg); color: var(--text-primary);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-full);
  box-shadow: var(--shadow-card); font-size: 14px; font-weight: 500;
  transform: translate(-50%, -140%); opacity: 0; pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
}
.toast-notice.active { transform: translate(-50%, 0); opacity: 1; }
.toast-icon { color: var(--online-green); }

/* ==========================================================================
   Calls
   ========================================================================== */
.call-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none !important; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.call-overlay.active { display: flex !important; opacity: 1; pointer-events: auto; }
.call-modal {
  position: relative; width: 760px; max-width: 100%; height: 560px; max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: #121921; color: #fff;
  border: 1px solid rgba(255,255,255,0.12); border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.call-modal-header { position: absolute; top: 18px; left: 20px; right: 20px; z-index: 10; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.call-title-block { min-width: 0; }
.call-user-title { font-size: 16px; font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,0.6); overflow-wrap: anywhere; }
.call-status-subtitle { font-size: 13px; color: rgba(255,255,255,0.7); margin-top: 2px; }
.call-timer-badge { flex-shrink: 0; padding: 6px 14px; border-radius: var(--radius-full); background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.12); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.call-viewport { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(circle at center, #182533 0%, #0e1621 100%); }
.remote-video { display: none; width: 100%; height: 100%; object-fit: cover; background: #000; }
.remote-video.visible { display: block; }
.local-pip-video { display: none; position: absolute; bottom: 104px; right: 20px; z-index: 5; width: 150px; height: 96px; object-fit: cover; transform: scaleX(-1); background: #000; border: 2px solid rgba(255,255,255,0.25); border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0,0,0,0.6); }
.local-pip-video.visible { display: block; }
.audio-call-center { display: flex; flex-direction: column; align-items: center; gap: 28px; z-index: 2; }
.call-hint { font-size: 12.5px; color: rgba(255,255,255,0.55); text-align: center; padding: 0 16px; }
.pulsing-avatar-container { position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; }
.pulse-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent-blue); opacity: 0.6; animation: pulseRipple 2.4s infinite cubic-bezier(0.215, 0.61, 0.355, 1); }
.pulse-ring:nth-child(2) { animation-delay: 0.8s; }
.pulse-ring:nth-child(3) { animation-delay: 1.6s; }
@keyframes pulseRipple { 0% { transform: scale(0.9); opacity: 0.8; } 100% { transform: scale(1.9); opacity: 0; } }
.call-large-avatar { width: 120px; height: 120px; font-size: 40px; font-weight: 700; z-index: 3; box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.call-controls-bar { position: absolute; bottom: 20px; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: center; gap: 16px; }
.call-action-btn { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.15); color: #fff; backdrop-filter: blur(10px); transition: background-color var(--transition-fast), transform var(--transition-fast); }
.call-action-btn:hover { background: rgba(255,255,255,0.28); transform: translateY(-2px); }
.call-action-btn.active-off { background: #fff; color: #0e1621; }
.call-action-btn.hangup-btn { width: 60px; height: 60px; background: var(--danger-red); }
.call-action-btn.hangup-btn:hover { background: var(--danger-red-hover); transform: scale(1.06); }

.incoming-call-toast {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  width: 340px; max-width: calc(100vw - 32px); padding: 16px;
  display: none; flex-direction: column; gap: 14px;
  background: var(--modal-bg); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  animation: slideInDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.incoming-call-toast.active { display: flex; }
@keyframes slideInDown { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
.incoming-call-header { display: flex; align-items: center; gap: 12px; }
.incoming-info { min-width: 0; }
.incoming-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.incoming-type { font-size: 13px; color: var(--accent-blue-light); }
.incoming-actions { display: flex; gap: 10px; }
.incoming-btn { flex: 1; height: 40px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: #fff; }
.incoming-accept-btn { background: #22c55e; }
.incoming-accept-btn:hover { background: #16a34a; }
.incoming-reject-btn { background: var(--danger-red); }
.incoming-reject-btn:hover { background: var(--danger-red-hover); }

.mesh-video-grid { position: absolute; inset: 0; z-index: 20; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-content: center; padding: 64px 14px 90px; overflow-y: auto; }
.mesh-video-tile { position: relative; aspect-ratio: 16 / 9; min-height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #17212b; border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-lg); }
.mesh-tile-video { display: none; width: 100%; height: 100%; object-fit: cover; background: #0c1219; }
.mesh-tile-video.visible { display: block; }
.mesh-tile-avatar { position: absolute; width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; background: var(--accent-blue); }
.mesh-tile-video.visible ~ .mesh-tile-avatar { display: none; }
.mesh-tile-overlay { position: absolute; left: 8px; bottom: 8px; z-index: 3; padding: 3px 10px; border-radius: var(--radius-full); background: rgba(0,0,0,0.65); }
.mesh-tile-name { font-size: 12.5px; font-weight: 600; color: #fff; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .info-drawer { position: absolute; top: 0; right: 0; bottom: 0; box-shadow: -12px 0 32px rgba(0,0,0,0.35); }
}

@media (max-width: 768px) {
  .mobile-only { display: inline-flex !important; }
  .rail { display: none; }
  .app-shell { display: block; }
  .sidebar, .sidebar.collapsed {
    position: absolute; inset: 0; width: 100%; flex: none; min-width: 0;
    opacity: 1; pointer-events: auto; overflow: visible;
    border-right: none; z-index: 25;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .chat-window { position: absolute; inset: 0; width: 100%; z-index: 24; }
  .app-shell.chat-open .sidebar { transform: translateX(-30%); pointer-events: none; z-index: 20; }
  .chat-window { transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1); }
  .app-shell.chat-open .chat-window { transform: none; }
  .chat-window { visibility: hidden; }
  .app-shell.chat-open .chat-window { visibility: visible; }
  .info-drawer { width: 100%; flex: none; z-index: 40; }
  .chat-header { padding: 0 8px; }
  .chat-header-user { padding-right: 4px; }
  .header-actions .icon-btn { width: 38px; height: 38px; }
  .message-bubble { max-width: 86%; }
  .messages-container { padding: 12px; }
  .chat-typing-bar { margin-left: 12px; }
  .input-panel-wrapper { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .popover { left: 10px; bottom: 70px; }
  .emoji-picker-popover { right: 10px; bottom: 70px; }
  .message-textarea, .search-input, .form-input, .emoji-search-input { font-size: 16px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-dialog { width: 100%; border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-height: 92%; }
  .confirm-dialog { align-items: center; }
  .call-overlay { padding: 0; }
  .call-modal { width: 100%; height: 100%; border-radius: 0; border: none; }
  .local-pip-video { width: 110px; height: 150px; bottom: 110px; right: 12px; }
}

@media (max-width: 380px) {
  .header-actions #delete-chat-btn { display: none; }
  .theme-grid { grid-template-columns: 1fr; }
}

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