/* Lusta — design tokens + тема. Чистый современный UI, умеренные акценты. */
:root {
  --accent: #5b8def;
  --accent-strong: #3f74e0;
  --bg: #ffffff;
  --bg-elevated: #f4f6fa;
  --bg-panel: #ffffff;
  --bg-hover: #eef1f6;
  --bg-active: #e4ebfb;
  --bubble-out: #d9e6ff;
  --bubble-in: #f1f3f7;
  --text: #12151c;
  --text-muted: #6b7280;
  --text-faint: #9aa1ac;
  --border: #e6e8ee;
  --danger: #e0575b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgba(20, 25, 40, 0.10);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, system-ui, sans-serif;
  --header-h: 60px;
}
[data-theme='dark'] {
  --accent: #6d9bff;
  --accent-strong: #5b8def;
  --bg: #0f1319;
  --bg-elevated: #161b23;
  --bg-panel: #12161d;
  --bg-hover: #1c222c;
  --bg-active: #232c3b;
  --bubble-out: #2b4a80;
  --bubble-in: #1c222c;
  --text: #e8ebf0;
  --text-muted: #97a0ad;
  --text-faint: #6a7382;
  --border: #232a34;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.icon { width: 22px; height: 22px; display: inline-block; vertical-align: middle; flex: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ------------------- Экран авторизации ------------------- */
.auth {
  height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; }
.brand .icon { width: 30px; height: 30px; color: var(--accent); }
.brand h1 { font-size: 26px; letter-spacing: -0.5px; }
.auth-sub { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 13.5px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-elevated); outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.btn {
  width: 100%; padding: 12px; border-radius: var(--radius-sm); font-weight: 600;
  background: var(--accent); color: #fff; transition: background .15s; font-size: 15px;
}
.btn:hover { background: var(--accent-strong); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: var(--bg-elevated); color: var(--text); }
.btn-ghost:hover { background: var(--bg-hover); }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--text-muted); }
.auth-switch a { color: var(--accent); cursor: pointer; text-decoration: none; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0 2px; min-height: 18px; }

.seed-box {
  background: var(--bg-elevated); border: 1px dashed var(--accent);
  border-radius: var(--radius-sm); padding: 16px; margin: 14px 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.seed-word { font-size: 13px; }
.seed-word b { color: var(--text-faint); font-weight: 500; margin-right: 4px; }
.warn { background: rgba(224,145,58,.12); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; color: var(--text); margin-bottom: 14px; }

/* ------------------- Основной layout ------------------- */
.app { height: 100dvh; display: grid; grid-template-columns: 340px 1fr; }
.sidebar { background: var(--bg-panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.sidebar-head {
  height: var(--header-h); display: flex; align-items: center; gap: 8px;
  padding: 0 12px; border-bottom: 1px solid var(--border);
}
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; padding: 6px; border-radius: var(--radius-sm); }
.me:hover { background: var(--bg-hover); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex: none; font-size: 15px; overflow: hidden; background-size: cover; background-position: center; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.me-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--text-muted); flex: none; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.search-wrap { padding: 10px 12px; position: relative; }
.search-wrap .icon { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--text-faint); width: 18px; height: 18px; }
.search-wrap input {
  width: 100%; padding: 10px 12px 10px 40px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg-elevated); outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }

.chat-list { flex: 1; overflow-y: auto; }
.list-label { padding: 8px 18px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 9px 14px; cursor: pointer; }
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }
.chat-avatar-wrap { position: relative; flex: none; }
.presence-dot { position: absolute; bottom: 0; right: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--text-faint); border: 2px solid var(--bg-panel); }
.presence-dot.on { background: #2fb37a; }
.chat-item.active .presence-dot { border-color: var(--bg-active); }
.chat-main { flex: 1; min-width: 0; }
.chat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { font-size: 11.5px; color: var(--text-faint); flex: none; }
.chat-preview { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.result-item { display: flex; align-items: center; gap: 12px; padding: 9px 14px; cursor: pointer; }
.result-item:hover { background: var(--bg-hover); }

/* ------------------- Область чата ------------------- */
.conversation { display: flex; flex-direction: column; background: var(--bg-elevated); min-width: 0; }
.conv-empty { display: grid; place-items: center; height: 100%; color: var(--text-faint); text-align: center; }
.conv-empty .icon { width: 60px; height: 60px; opacity: .4; margin-bottom: 12px; }
.conv-head {
  height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--bg-panel); border-bottom: 1px solid var(--border); flex: none;
}
.conv-head .back { display: none; }
.conv-title { flex: 1; min-width: 0; }
.conv-title .name { font-weight: 600; font-size: 15px; }
.conv-title .status { font-size: 12.5px; color: var(--text-muted); }
.conv-title .status.typing { color: var(--accent); }

.messages { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 3px; }
.msg-row { display: flex; max-width: 72%; }
.msg-row.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.in { align-self: flex-start; }
.bubble {
  background: var(--bubble-in); padding: 8px 12px 6px; border-radius: var(--radius);
  position: relative; word-wrap: break-word; overflow-wrap: anywhere; min-width: 64px;
}
.msg-row.out .bubble { background: var(--bubble-out); }
.bubble .reply-quote {
  border-left: 3px solid var(--accent); padding: 2px 8px; margin-bottom: 4px;
  background: rgba(91,141,239,.08); border-radius: 5px; font-size: 12.5px;
}
.reply-quote .q-name { color: var(--accent); font-weight: 600; display: block; }
.reply-quote .q-text { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.bubble .text { white-space: pre-wrap; }
.bubble .text.deleted { color: var(--text-faint); font-style: italic; }
.msg-meta { display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.msg-meta .edited { font-style: italic; }
.msg-meta .icon { width: 15px; height: 15px; }
.msg-meta .read { color: var(--accent); }
.msg-actions { display: flex; align-items: center; gap: 2px; align-self: center; margin: 0 4px; opacity: 0; transition: opacity .12s; }
.msg-row:hover .msg-actions { opacity: 1; }
.msg-actions button { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--text-faint); }
.msg-actions button:hover { background: var(--bg-hover); color: var(--text); }
.msg-actions .icon { width: 16px; height: 16px; }
.day-sep { align-self: center; font-size: 12px; color: var(--text-muted); background: var(--bg-panel); padding: 3px 12px; border-radius: 12px; margin: 10px 0; }

.compose { padding: 12px 16px; background: var(--bg-panel); border-top: 1px solid var(--border); flex: none; }
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 6px 10px 8px; margin-bottom: 6px; border-left: 3px solid var(--accent); }
.reply-bar .rb-main { flex: 1; min-width: 0; font-size: 13px; }
.reply-bar .q-name { color: var(--accent); font-weight: 600; }
.reply-bar .q-text { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-row { display: flex; align-items: flex-end; gap: 8px; }
.input-wrap {
  flex: 1; display: flex; align-items: flex-end; gap: 2px;
  background: var(--bg-elevated); border: 1.5px solid var(--border); border-radius: 24px;
  padding: 3px 6px 3px 4px; transition: border-color .18s ease, box-shadow .18s ease;
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,141,239,.12); }
.compose textarea {
  flex: 1; resize: none; max-height: 140px; padding: 9px 6px 9px 4px;
  border: none; background: transparent; outline: none; line-height: 1.45;
}
.send-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; transition: background .15s, transform .12s cubic-bezier(.34,1.56,.64,1); }
.send-btn:hover { background: var(--accent-strong); }
.send-btn:active { transform: scale(.88); }
.send-btn.pop { animation: btn-pop .25s cubic-bezier(.34,1.56,.64,1); }
@keyframes btn-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.compose .tool { color: var(--text-faint); align-self: flex-end; }
.compose .tool:hover { color: var(--accent); }

/* ------------------- Модалка профиля ------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,12,18,.5); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { width: 100%; max-width: 380px; background: var(--bg-panel); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px; }
.modal-body .avatar { width: 72px; height: 72px; font-size: 28px; margin: 0 auto 14px; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

/* ------------------- Тосты ------------------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes msg-in-out { from { opacity: 0; transform: translate(14px, 8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes msg-in-in { from { opacity: 0; transform: translate(-14px, 8px) scale(.96); } to { opacity: 1; transform: none; } }
.msg-row.out { animation: msg-in-out .22s cubic-bezier(.22,1,.36,1); }
.msg-row.in { animation: msg-in-in .22s cubic-bezier(.22,1,.36,1); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.hidden { display: none !important; }

/* ------------------- Кликабельные профили ------------------- */
.conv-title { cursor: pointer; }
.chat-avatar-wrap.clickable { cursor: pointer; }

/* ------------------- Вложения в сообщениях ------------------- */
.bubble.media { padding: 4px; }
.att-image { display: block; border-radius: 10px; max-width: 260px; max-height: 320px; width: auto; cursor: zoom-in; }
.att-video { display: block; border-radius: 10px; max-width: 280px; max-height: 340px; background: #000; }
.bubble.media .msg-meta { position: absolute; right: 10px; bottom: 8px; background: rgba(0,0,0,.42); color: #fff; padding: 2px 7px; border-radius: 10px; margin: 0; backdrop-filter: blur(2px); }
.bubble.media .msg-meta .icon { color: #fff; }
.bubble.media .caption { padding: 6px 8px 2px; white-space: pre-wrap; }

.att-file { display: flex; align-items: center; gap: 12px; padding: 8px 10px; min-width: 200px; text-decoration: none; color: inherit; }
.att-file .file-ic { width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.att-file .file-ic .icon { width: 24px; height: 24px; }
.att-file .file-meta { min-width: 0; }
.att-file .file-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.att-file .file-size { font-size: 12px; color: var(--text-muted); }

/* Голосовое сообщение */
.att-voice { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 4px; min-width: 210px; }
.voice-play { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.voice-play .icon { width: 22px; height: 22px; }
.voice-body { flex: 1; min-width: 0; }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 26px; }
.voice-wave i { display: block; width: 3px; border-radius: 2px; background: var(--accent); opacity: .35; }
.voice-wave i.on { opacity: 1; }
.voice-sub { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.voice-speed { border: 1px solid var(--border); border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 600; color: var(--text-muted); }

/* Видеосообщение-кружок */
.att-videonote { position: relative; }
.att-videonote video { width: 200px; height: 200px; border-radius: 50%; object-fit: cover; background: #000; cursor: pointer; }
.att-videonote .vn-play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.att-videonote .vn-play .icon { width: 46px; height: 46px; color: #fff; filter: drop-shadow(0 1px 4px rgba(0,0,0,.5)); }

/* ------------------- Композер: меню вложений и запись ------------------- */
.attach-menu { position: absolute; bottom: 62px; left: 12px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; z-index: 30; min-width: 190px; animation: pop .15s ease; }
.attach-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 16px; font-size: 14.5px; text-align: left; }
.attach-menu button:hover { background: var(--bg-hover); }
.attach-menu .icon { width: 20px; height: 20px; color: var(--accent); }

.recording-bar { display: flex; align-items: center; gap: 12px; padding: 6px 4px; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; flex: none; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text); min-width: 44px; }
.rec-wave { flex: 1; height: 30px; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.rec-wave i { width: 3px; background: var(--accent); border-radius: 2px; flex: none; }
.rec-cancel, .rec-send { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.rec-cancel { color: var(--danger); }
.rec-cancel:hover { background: var(--bg-hover); }
.rec-send { background: var(--accent); color: #fff; }
.rec-send:hover { background: var(--accent-strong); }

/* Модалка записи видео-кружка */
.vn-modal { width: 320px; max-width: 92vw; text-align: center; }
.vn-stage { width: 260px; height: 260px; border-radius: 50%; overflow: hidden; margin: 4px auto 16px; background: #000; position: relative; }
.vn-stage video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.vn-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 4px var(--accent); pointer-events: none; opacity: 0; transition: opacity .2s; }
.vn-stage.rec .vn-ring { opacity: 1; }
.vn-timer { font-variant-numeric: tabular-nums; color: var(--text-muted); margin-bottom: 14px; min-height: 18px; }
.vn-controls { display: flex; gap: 12px; justify-content: center; }
.vn-controls .btn { width: auto; padding: 11px 20px; }

/* ------------------- Лайтбокс ------------------- */
.lightbox { position: fixed; inset: 0; background: rgba(8,10,14,.92); z-index: 90; display: grid; place-items: center; }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 86vh; border-radius: 8px; }
.lb-close, .lb-nav { position: absolute; color: #fff; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.1); }
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-close { top: 20px; right: 20px; }
.lb-nav.prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lb-nav.next { right: 18px; top: 50%; transform: translateY(-50%); }
.lb-nav .icon, .lb-close .icon { width: 26px; height: 26px; }

/* Аватар в профиле — загрузка */
.avatar-edit { position: relative; width: 86px; height: 86px; margin: 0 auto 14px; cursor: pointer; }
.avatar-edit .avatar { width: 86px; height: 86px; font-size: 32px; }
.avatar-edit .cam { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 2px solid var(--bg-panel); }
.avatar-edit .cam .icon { width: 17px; height: 17px; }
.profile-view { text-align: center; }
.profile-view .avatar { width: 96px; height: 96px; font-size: 36px; margin: 0 auto 14px; cursor: zoom-in; }
.profile-view .pv-name { font-size: 20px; font-weight: 700; }
.profile-view .pv-status { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }
.profile-view .pv-bio { margin-top: 14px; padding: 12px 14px; background: var(--bg-elevated); border-radius: var(--radius-sm); text-align: left; font-size: 14px; }
.profile-view .pv-label { font-size: 12px; color: var(--text-faint); margin-bottom: 3px; }
.profile-view .btn { margin-top: 18px; }

/* ------------------- Анимации интерфейса ------------------- */
.modal-overlay { animation: overlay-in .18s ease; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal { animation: modal-in .24s cubic-bezier(.34,1.4,.5,1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.chat-item { transition: background .14s ease; }
.result-item { transition: background .14s ease; }
.btn { transition: background .15s ease, transform .1s ease; }
.btn:active { transform: scale(.98); }
.icon-btn { transition: background .15s ease, color .15s ease, transform .1s ease; }
.icon-btn:active { transform: scale(.9); }
.icon-btn .icon, .send-btn .icon { transition: transform .15s ease; }
.day-sep { animation: fade-in .2s ease; }

/* «печатает…» — три точки */
.typing-dots { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; animation: td 1.1s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes td { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Пульс онлайн-статуса */
.presence-dot.on { animation: pulse-dot 2.4s infinite; }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 rgba(47,179,122,.5); } 70% { box-shadow: 0 0 0 5px rgba(47,179,122,0); } 100% { box-shadow: 0 0 0 0 rgba(47,179,122,0); } }

/* ------------------- Звонки ------------------- */
.conv-actions { display: flex; align-items: center; gap: 2px; }

.call-overlay { position: fixed; inset: 0; z-index: 100; background: #0b0e13; display: flex; flex-direction: column; animation: overlay-in .2s ease; }
.call-stage { flex: 1; position: relative; overflow: hidden; background: radial-gradient(circle at 50% 35%, #1a2130, #0b0e13); display: grid; place-items: center; }
.call-remote { width: 100%; height: 100%; object-fit: cover; background: #0b0e13; }
.call-remote.audio-only { display: none; }
.call-local { position: absolute; right: 18px; top: 18px; width: 150px; height: 200px; object-fit: cover; border-radius: 14px; background: #000; box-shadow: 0 6px 20px rgba(0,0,0,.5); transform: scaleX(-1); border: 1px solid rgba(255,255,255,.08); }
.call-peer { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: #fff; }
.call-peer.hidden { display: none; }
.call-peer .avatar { width: 128px; height: 128px; font-size: 46px; box-shadow: 0 0 0 0 rgba(91,141,239,.5); }
.call-peer.ringing .avatar { animation: ring-pulse 1.6s infinite; }
@keyframes ring-pulse { 0% { box-shadow: 0 0 0 0 rgba(91,141,239,.45); } 70% { box-shadow: 0 0 0 26px rgba(91,141,239,0); } 100% { box-shadow: 0 0 0 0 rgba(91,141,239,0); } }
.call-name { font-size: 24px; font-weight: 700; }
.call-status { color: #97a0ad; font-size: 15px; }
.call-timer { font-variant-numeric: tabular-nums; }

.call-controls { display: flex; gap: 16px; justify-content: center; align-items: center; padding: 24px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); background: rgba(0,0,0,.25); }
.call-btn { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.14); transition: background .15s, transform .1s; }
.call-btn:hover { background: rgba(255,255,255,.24); }
.call-btn:active { transform: scale(.9); }
.call-btn.off { background: #fff; color: #12151c; }
.call-btn.hangup { background: var(--danger); width: 66px; height: 66px; }
.call-btn.hangup:hover { background: #c94a4e; }
.call-btn.accept { background: #2fb37a; width: 66px; height: 66px; }
.call-btn.accept:hover { background: #28a06c; }
.call-btn .icon { width: 26px; height: 26px; }

/* Входящий звонок — компактная карточка */
.incoming { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 105; width: 340px; max-width: 92vw; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; display: flex; align-items: center; gap: 14px; animation: modal-in .25s cubic-bezier(.34,1.4,.5,1); }
.incoming .avatar { width: 52px; height: 52px; font-size: 20px; animation: ring-pulse 1.6s infinite; }
.incoming .inc-main { flex: 1; min-width: 0; }
.incoming .inc-name { font-weight: 700; font-size: 16px; }
.incoming .inc-sub { color: var(--text-muted); font-size: 13px; }
.incoming .inc-actions { display: flex; gap: 8px; }
.incoming .call-btn { width: 46px; height: 46px; }
.incoming .call-btn .icon { width: 21px; height: 21px; }

/* ------------------- Адаптив (мобильный веб) ------------------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { width: 100vw; }
  .conversation { position: fixed; inset: 0; height: 100dvh; z-index: 20; transform: translateX(100%); transition: transform .22s ease; }
  .app.chat-open .conversation { transform: none; }
  .app.chat-open .sidebar { display: none; }
  .conv-head .back { display: grid; }
  .conv-head { padding: 0 8px; padding-top: env(safe-area-inset-top); height: calc(var(--header-h) + env(safe-area-inset-top)); }
  .sidebar-head { padding-top: env(safe-area-inset-top); height: calc(var(--header-h) + env(safe-area-inset-top)); }
  .messages { padding: 12px 10px; }
  .msg-row { max-width: 86%; }
  .compose { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  /* 16px против авто-зума на iOS */
  .compose textarea, .search-wrap input, .field input, .modal-body input { font-size: 16px; }
  .att-image, .att-video { max-width: 72vw; }
  .att-videonote video { width: 62vw; height: 62vw; max-width: 240px; max-height: 240px; }
  .icon-btn { width: 42px; height: 42px; }
  .attach-menu { left: 8px; min-width: 210px; }
  .attach-menu button { padding: 13px 16px; }
  .modal { max-width: 100%; }
}

@media (hover: none) {
  .msg-actions { opacity: 1; } /* на тач-устройствах действия видны сразу */
}
