/* ============================================================
   SupaChat — MD3 dark, палитра Desktop5 (purple #9461E8 / lime #C6FF34)
   ============================================================ */

[data-theme="dark"] {
  --bg: #151515;
  --bg-2: #19191c;
  --bg-3: #1F1E20;
  --surface: rgba(255,255,255,0.04);
  --surface-2: rgba(255,255,255,0.06);
  --surface-3: rgba(255,255,255,0.10);
  --border: rgba(255,255,255,0.08);
  --border-hi: rgba(198,255,52,0.2);
  --fg: #ffffff;
  --fg-dim: rgba(255,255,255,0.66);
  --fg-faint: rgba(255,255,255,0.38);
  --primary: #9461E8;
  --primary-2: #a67cff;
  --primary-3: #7c4dff;
  --secondary: #C6FF34;
  --tertiary: #ffb4a2;
  --success: #88e8b3;
  --danger: #ff6b81;
  --warning: #ffcc66;
  --shadow: 0 24px 60px -24px rgba(0,0,0,0.7);
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
[data-theme="light"] {
  --bg: #f6f6fb;
  --bg-2: #ffffff;
  --bg-3: #f0f0fa;
  --surface: rgba(255,255,255,0.7);
  --surface-2: rgba(0,0,0,0.03);
  --surface-3: rgba(0,0,0,0.06);
  --border: rgba(0,0,0,0.08);
  --border-hi: rgba(0,0,0,0.14);
  --fg: #14151c;
  --fg-dim: rgba(20,21,28,0.6);
  --fg-faint: rgba(20,21,28,0.35);
  --primary: #5e3bff;
  --primary-2: #7c4dff;
  --primary-3: #4a2bd9;
  --secondary: #0078d4;
  --tertiary: #c2410c;
  --success: #047857;
  --danger: #d11a47;
  --warning: #b85c00;
  --shadow: 0 24px 60px -24px rgba(20,21,28,0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background:
    radial-gradient(1100px 500px at 12% -8%, rgba(148,97,232,0.10), transparent 60%),
    radial-gradient(900px 480px at 110% 30%, rgba(198,255,52,0.05), transparent 60%),
    var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; background: none; border: 0; outline: 0; }
a { color: var(--primary); text-decoration: none; }

/* Material Symbols */
.material-symbols-rounded { font-size: 22px; vertical-align: middle; user-select: none; }
.material-symbols-rounded.filled { font-variation-settings: 'FILL' 1; }

/* ===== AUTH SCREEN ===== */
/* body.auth-mode ставится JS: на экранах входа/сброса разрешаем скролл страницы */
body.auth-mode { overflow-y: auto; }
body.auth-mode #root { height: auto; min-height: 100%; }

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-card {
  margin: auto;
  width: 100%; max-width: 420px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px 32px;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  box-shadow: var(--shadow);
  position: relative;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 1.05rem;
  margin-bottom: 28px;
}
.auth-logo .dot { color: var(--primary); }
.auth-logo .tld { opacity: 0.55; font-weight: 500; }

.auth h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px; font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}
.auth p.sub { color: var(--fg-dim); margin-bottom: 28px; font-size: 14px; }

.field {
  position: relative;
  margin-bottom: 14px;
}
.field input {
  width: 100%;
  padding: 18px 16px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  transition: all 0.2s var(--ease);
}
.field input:focus {
  border-color: var(--primary);
  background: var(--surface-2);
  box-shadow: 0 0 0 4px rgba(148,97,232,0.14);
}
.field label {
  position: absolute; left: 16px; top: 16px;
  font-size: 15px; color: var(--fg-dim);
  transition: all 0.2s var(--ease);
  pointer-events: none;
  background: transparent;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  top: 6px; font-size: 11px; color: var(--primary);
  letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600;
}

.btn {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-pill);
  font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  border: 0;
}
.btn-primary {
  background: var(--primary);
  color: #1b1026;
}
.btn-primary:hover { background: var(--primary-2); color: #fff; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-text { background: transparent; color: var(--primary); padding: 8px 12px; }

.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

.alt-link {
  text-align: center; font-size: 13px; color: var(--fg-dim);
  margin-top: 16px; cursor: pointer;
}
.alt-link a { color: var(--primary); font-weight: 600; }
.alt-link a:hover { text-decoration: underline; }

.code-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
  margin: 16px 0 20px;
}
.code-grid input {
  aspect-ratio: 1;
  text-align: center;
  font-size: 22px; font-weight: 700;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
}
.code-grid input:focus { border-color: var(--primary); background: var(--surface-2); }

.error {
  background: rgba(255,107,129,0.10);
  border: 1px solid rgba(255,107,129,0.30);
  color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 12px;
}
.info {
  background: rgba(127,184,255,0.10);
  border: 1px solid rgba(127,184,255,0.30);
  color: var(--secondary);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 12px;
}
.success {
  background: rgba(136,232,179,0.10);
  border: 1px solid rgba(136,232,179,0.30);
  color: var(--success);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 12px;
}

/* ===== APP LAYOUT (Telegram Web style) ===== */
.app {
  display: grid;
  grid-template-columns: 380px 1fr 0;
  height: 100%;
  transition: grid-template-columns 0.3s var(--ease);
}
.app.has-side { grid-template-columns: 380px 1fr 320px; }

@media (max-width: 900px) {
  .app, .app.has-side { grid-template-columns: 0 1fr 0; }
  .sidebar { position: absolute; inset: 0; z-index: 10; transform: translateX(-100%); transition: transform 0.3s var(--ease); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 80px rgba(0,0,0,0.5); }
  .sidebar.hidden-mobile { display: none; }
  /* iOS не зумит страницу при фокусе поля, если font-size >= 16px */
  input, textarea { font-size: 16px; }
  /* кнопка-меню (гамбургер) видна только на мобильных */
  .m-header .mobile-menu, .empty .mobile-menu { display: inline-flex; }
}

@media (max-width: 480px) {
  .auth { padding: 16px; }
  .auth-card { padding: 24px 20px 20px; }
  .code-grid { gap: 6px; }
  .code-grid input { font-size: 16px; border-radius: 14px; }
  .modal-bg { padding: 16px; }
  .modal { max-width: 100%; max-height: calc(100dvh - 32px); overflow-y: auto; }
}

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0;
}

.sb-header {
  height: 64px;
  display: flex; align-items: center; padding: 0 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.sb-header .icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-dim);
  transition: 0.2s;
}
.sb-header .icon-btn:hover { background: var(--surface); color: var(--fg); }

.sb-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.sb-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 14px;
}
.sb-search-wrap { position: relative; }
.sb-search-wrap .material-symbols-rounded {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 18px; color: var(--fg-faint);
}

.sb-list {
  flex: 1; overflow-y: auto;
  padding: 6px 0;
}
.sb-list::-webkit-scrollbar { width: 6px; }
.sb-list::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

.chat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
  border-radius: 0;
}
.chat-row:hover { background: var(--surface); }
.chat-row.active { background: var(--surface-2); }
.chat-row .avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}
.chat-row .avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-row .meta { flex: 1; min-width: 0; }
.chat-row .name { font-weight: 600; font-size: 15px; margin-bottom: 3px; }
.chat-row .preview { color: var(--fg-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chat-row .time { font-size: 11px; color: var(--fg-faint); }
.chat-row .badge {
  background: var(--primary);
  color: #1b1026;
  font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
}
.chat-row .badge.zero { background: var(--surface-3); color: var(--fg-dim); }

/* ===== MAIN PANE ===== */
.main {
  display: flex; flex-direction: column;
  background: var(--bg);
  min-width: 0;
}
.m-header {
  height: 64px;
  display: flex; align-items: center; padding: 0 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(11,12,18,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.m-header .avatar { width: 40px; height: 40px; }
.m-header .title-block { flex: 1; min-width: 0; }
.m-header .title { font-weight: 600; font-size: 15px; }
.m-header .subtitle { font-size: 12px; color: var(--fg-dim); }
.m-header .actions { display: flex; gap: 4px; }
.m-header .mobile-menu, .empty .mobile-menu { display: none; }
.empty-menu { position: absolute; top: 12px; left: 12px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-dim);
  transition: 0.2s;
  position: relative;
}
.icon-btn:hover { background: var(--surface); color: var(--fg); }
.icon-btn.active { color: var(--primary); background: var(--surface-2); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
}

.messages {
  flex: 1; overflow-y: auto;
  padding: 20px 0;
  display: flex; flex-direction: column;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

.day-sep {
  display: flex; align-items: center; gap: 12px;
  margin: 18px auto;
  color: var(--fg-faint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.day-sep::before, .day-sep::after {
  content: ''; flex: 0 0 60px; height: 1px;
  background: var(--border);
}

.msg-group {
  display: flex; gap: 10px;
  padding: 2px 16px;
  max-width: 75%;
  margin-bottom: 6px;
}
.msg-group.own { margin-left: auto; flex-direction: row-reverse; }
.msg-group .avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 12px;
  flex-shrink: 0;
  align-self: flex-end;
  overflow: hidden;
}
.msg-group .avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.msg-bubbles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg-group.own .msg-bubbles { align-items: flex-end; }

.bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 12px 6px;
  border-radius: 16px;
  max-width: 480px;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-group.own .bubble {
  background: linear-gradient(135deg, rgba(148,97,232,0.22), rgba(124,77,240,0.18));
  border-color: rgba(148,97,232,0.35);
}
.bubble .sender { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 2px; }
.bubble .text { font-size: 15px; line-height: 1.4; white-space: pre-wrap; }
.bubble .meta {
  display: flex; gap: 4px; align-items: center;
  font-size: 10px; color: var(--fg-faint);
  margin-top: 2px;
  float: right;
  margin-left: 8px;
  user-select: none;
}
.bubble .meta .edited { font-style: italic; }
.bubble .meta .read { color: var(--primary); }
.attachment {
  margin-top: 4px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 320px;
}
.attachment img { display: block; max-width: 100%; max-height: 320px; object-fit: cover; }
.attachment.audio { padding: 8px; background: var(--surface-2); }
.attachment.audio audio { width: 100%; }
.attachment.file {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  font-size: 13px;
}
.attachment.file a { color: var(--fg); }
.attachment.file .size { color: var(--fg-dim); font-size: 11px; }

.composer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  background: rgba(11,12,18,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.composer-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 6px 6px 14px;
}
.composer textarea {
  flex: 1; resize: none;
  font-size: 15px; line-height: 1.4;
  padding: 8px 0;
  max-height: 140px;
  min-height: 24px;
}
.composer .send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary);
  color: #1b1026;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: 0.2s;
}
.composer .send-btn:hover:not(:disabled) { background: var(--primary-2); color: #fff; transform: scale(1.05); }
.composer .send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== SIDE PANEL (group info) ===== */
.side {
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.side-header {
  height: 64px;
  display: flex; align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.side-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.side-section h4 {
  padding: 0 18px 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--fg-faint); font-weight: 600;
}
.member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  cursor: pointer;
}
.member-row:hover { background: var(--surface); }
.member-row .avatar { width: 36px; height: 36px; }
.member-row .name { font-size: 14px; font-weight: 500; }
.member-row .role { font-size: 11px; color: var(--fg-dim); }

/* ===== EMPTY STATE ===== */
.empty {
  flex: 1;
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--fg-dim);
}
.empty .big-emoji {
  font-family: 'JetBrains Mono', monospace;
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 12px;
  letter-spacing: -0.04em;
}
.empty h2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  color: var(--fg);
  margin-bottom: 6px;
}
.empty p { font-size: 14px; max-width: 320px; }

/* ===== TOAST ===== */
.toast-host {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000;
}
.toast {
  padding: 12px 18px;
  background: var(--bg-3);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s var(--ease);
}
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
@keyframes slide-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== MODAL ===== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fade-in 0.2s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 420px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal h3 { font-family: 'JetBrains Mono', monospace; margin-bottom: 16px; font-size: 20px; }

/* ===== SETTINGS ===== */
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border);
}
.settings-label {
  font-size: 12px; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.settings-value { font-size: 15px; margin-top: 2px; }
.settings-note { font-size: 13px; color: var(--fg-dim); margin: 14px 0 10px; }
.badge {
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 5px 12px; border-radius: var(--radius-pill);
}
.badge-ok { background: rgba(45,212,191,0.14); color: #2dd4bf; }
.badge-warn { background: rgba(251,191,36,0.14); color: #fbbf24; }

.note-warn {
  margin: 10px 2px 2px; font-size: 13px; color: #fbbf24;
  display: flex; align-items: center; gap: 6px;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px; color: var(--fg);
  font-family: inherit;
  transition: all 0.2s var(--ease);
}
.modal-input:focus {
  border-color: var(--primary);
  background: var(--surface-2);
  outline: none;
  box-shadow: 0 0 0 4px rgba(148,97,232,0.14);
}
textarea.modal-input { resize: vertical; min-height: 80px; }

.profile-avatar {
  display: flex; align-items: center; gap: 14px;
  margin: 4px 0 18px;
}
.profile-avatar .avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 20px;
  overflow: hidden; flex-shrink: 0;
}
.profile-avatar .avatar img { width: 100%; height: 100%; object-fit: cover; }

/* базовый аватар: круг с градиентом, инициалы или фото */
.avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px;
  overflow: hidden; flex-shrink: 0;
}
.avatar img, .avatar-sm img, .member-row .avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

/* ===== CALL OVERLAY ===== */
.call-overlay {
  position: fixed; inset: 0;
  background: rgba(11,12,18,0.95);
  backdrop-filter: blur(20px);
  display: flex; flex-direction: column;
  z-index: 200;
  align-items: center; justify-content: center;
}
.call-overlay.mode-panel {
  inset: auto auto 20px 20px;
  width: 340px; max-width: calc(100vw - 40px);
  min-height: 120px;
  border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  background: rgba(20,22,30,0.92);
  box-shadow: var(--shadow);
  align-items: stretch; justify-content: center;
  padding: 14px 14px 78px;
}
.call-overlay .remote-vid {
  width: 100%; height: 100%;
  object-fit: cover;
  position: absolute; inset: 0;
  border-radius: inherit;
}
.call-overlay.mode-panel .remote-vid,
.call-overlay.mode-panel .local-vid { display: none; }
.call-overlay.mode-panel.has-video .remote-vid {
  display: block; position: static;
  width: 100%; height: 120px;
  border-radius: 10px; object-fit: cover;
  margin-bottom: 10px;
}
.call-overlay.mode-full.mode-novideo .remote-vid { display: none; }
.call-overlay .local-vid {
  position: absolute; bottom: 100px; right: 24px;
  width: 160px; height: 220px;
  border-radius: var(--radius);
  border: 2px solid var(--border-hi);
  object-fit: cover;
  z-index: 1;
  background: #000;
}
.call-overlay .call-info {
  position: absolute; top: 24px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  z-index: 1;
  padding: 0 16px;
  cursor: default;
}
.call-overlay .call-info:hover .call-avatar img { transform: scale(1.05); }
.call-overlay .call-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-2), var(--primary-3));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 20px;
  overflow: hidden; flex-shrink: 0;
  border: 2px solid var(--border-hi);
}
.call-overlay .call-avatar img { width: 100%; height: 100%; object-fit: cover; transition: 0.2s; }
.call-overlay .call-id { text-align: left; min-width: 0; }
.call-overlay .call-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 46vw;
}
.call-overlay .call-status {
  color: var(--fg-dim);
  font-size: 13px;
}
.call-overlay .call-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--fg-dim);
  align-self: flex-start;
  margin-top: 6px;
}
.call-overlay.mode-panel .call-info {
  position: static;
  justify-content: flex-start;
}
.call-overlay.mode-panel .call-name { max-width: 180px; }
.call-overlay .call-controls {
  position: absolute; bottom: 24px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 16px;
  z-index: 1;
}
.call-overlay.mode-panel .call-controls { bottom: 16px; }
.call-overlay .call-controls button {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  transition: 0.2s;
  cursor: pointer;
}
.call-overlay .call-controls button:hover { background: var(--surface-2); transform: scale(1.05); }
.call-overlay .call-controls .end { background: var(--danger); border-color: var(--danger); }
.call-overlay .call-controls .end:hover { background: #ff4775; }
.call-overlay .call-controls .end .material-symbols-rounded { color: #fff; }
.call-overlay .call-controls .answer { background: var(--success, #2ea043); border-color: var(--success, #2ea043); }
.call-overlay .call-controls .answer:hover { background: #3fb950; }
.call-overlay .call-controls .answer .material-symbols-rounded { color: #fff; }
.call-overlay .call-controls button.active {
  background: var(--danger); border-color: var(--danger);
}
.call-overlay .mini-toggle {
  position: absolute; top: 16px; right: 16px;
  z-index: 2;
}
.call-overlay .mini-toggle span { font-size: 22px; }

/* ===== PROFILE MODAL ===== */
.profile-modal { max-width: 320px; text-align: center; }
.profile-modal .avatar {
  border: 2px solid var(--border-hi);
  box-shadow: var(--shadow);
}
.profile-modal h3 { margin: 4px 0 0; font-size: 18px; }

/* Emoji Picker */
.emoji-picker {
  position: absolute; bottom: 80px; right: 16px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-width: 320px;
  box-shadow: var(--shadow);
  z-index: 50;
}
.emoji-picker button {
  width: 32px; height: 32px;
  font-size: 18px;
  border-radius: 8px;
}
.emoji-picker button:hover { background: var(--surface-2); }
.emoji-picker.hidden { display: none; }

/* Loader */
.loader {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ===== КОНТАКТЫ ===== */
.sb-contacts {
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--border);
  max-height: 40%;
  overflow-y: auto;
}
.sb-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-faint); padding: 4px 16px 6px; font-weight: 600;
}
.contact-row .dot-presence {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--fg-faint);
  margin-right: 14px; flex-shrink: 0;
}
.contact-row .dot-presence.on { background: var(--success); box-shadow: 0 0 8px var(--success); }

/* ===== кликабельные аватары/имена → профиль ===== */
.chat-row .avatar, .m-header .avatar, .m-header .title-block,
.avatar-sm, .msg-bubbles .sender, .call-info {
  cursor: pointer;
}
.avatar-sm { transition: transform 0.15s; }
.avatar-sm:hover { transform: scale(1.08); }
.msg-bubbles .sender:hover { color: var(--primary); }

/* ===== кнопки профиля ===== */
.profile-modal .row .btn { padding: 10px 8px; font-size: 13px; }
.profile-modal .row { gap: 8px; margin-top: 14px; }
