/* ============================================================
   DARK THEME — Telegram-style messenger
   ============================================================ */
:root {
    --bg-base:        #0e1621;
    --bg-rail:        #111c28;
    --bg-sidebar:     #17212b;
    --bg-surface:     #182533;
    --bg-elevated:    #1f3040;
    --bg-input:       #0d1823;
    --bg-bubble-in:   #182533;
    --bg-bubble-out:  #2B5278;
    --bg-hover:       #1e2d3d;
    --bg-active:      #2b5278;

    --accent:         #4082bc;
    --accent-dim:     #2b5278;
    --danger:         #f87171;

    --text-primary:   #e8eaed;
    --text-secondary: #8a9bb0;
    --text-muted:     #526070;
	
    --border:         rgba(255,255,255,0.055);

    --rail-w:    56px;
    --sidebar-w: 250px;
    --header-h:  54px;
    --send-h:    62px;
    --attach-w:  480px; /* = абсолютная часть формулы X у .msgItem (max-width: min(72%, 480px));
                            файлы/аудио всегда целятся в это значение, картинки/видео используют
                            его только как потолок, реальный размер — по своим пропорциям */	

	--status-dot-size: 10px;     /* Размер самой точки */
	--status-cutout-gap: 2px;    /* Ширина прозрачного зазора */							

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --tr: 0.14s ease;

    /* ── Safe-area (вырезы/жест-панели в WebView-обёртках) ─────
       Приоритет: значения, которые пробрасывает нативная часть
       Kotlin-приложения (--native-safe-*, точные и учитывают
       клавиатуру) → иначе CSS env() как запасной вариант в обычном
       браузере → иначе 0px. */
    --safe-top:    var(--native-safe-top, env(safe-area-inset-top, 0px));
    --safe-bottom: var(--native-safe-bottom, env(safe-area-inset-bottom, 0px));
    --safe-left:   var(--native-safe-left, env(safe-area-inset-left, 0px));
    --safe-right:  var(--native-safe-right, env(safe-area-inset-right, 0px));
}

*,*::before,*::after 
{ 
	outline: none;

	box-sizing: border-box; 
	-webkit-tap-highlight-color: transparent; 
	
	-webkit-user-select: none; /* для Safari, Chrome, Opera, Edge */
	-ms-user-select: none;     /* для старого IE/Edge */
	user-select: none;         /* стандарт */
}

html, body {
    height: 100%; margin: 0; padding: 0;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

.can-copy {
  /* Объёмный эффект */
  border-radius: 8px;
  padding: 3px;
  cursor: pointer;
}

.can-copy:hover {
	box-shadow: 
		0 4px 6px rgba(255, 255, 255, 0.3),   /* мягкое белое свечение снизу */
		0 1px 3px rgba(255, 255, 255, 0.4);  /* более плотное свечение сверху */
}

/* ── WS CONNECTING OVERLAY ──────────────────────────────── */
#wsOverlay {
    position: absolute;
    inset: 0;
    z-index: 300;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}
.ws-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.ws-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(92,124,250,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}
.ws-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── AUTH OVERLAY ───────────────────────────────────────── */
#authOverlay {
    position: absolute;
    inset: 0;
    z-index: 200;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(40px + var(--safe-top)) 20px calc(40px + var(--safe-bottom));
    /* плавное появление/скрытие */
    transition: opacity 0.2s ease;
}
#authOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px 28px;
}
.auth-card h2 {
    font-size: 20px; font-weight: 600; color: var(--text-primary);
    margin: 0 0 22px; text-align: center;
}
.auth-card input {
    display: block; width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 14px; color: var(--text-primary);
    outline: none; margin-bottom: 10px;
    transition: border-color var(--tr);
}
.auth-card input:focus { border-color: var(--accent); }
.auth-card input::placeholder { color: var(--text-muted); }

/* основная кнопка действия */
.auth-card button:not(.auth-switch) {
	height: 44px;
    width: 100%; background: var(--accent); border: none;
    border-radius: 8px; padding: 12px;
    font-size: 14px; font-weight: 600; color: #fff;
    cursor: pointer; margin-top: 4px;
    margin-left: auto;
	margin-right: auto;
    display: block;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    transition: opacity var(--tr),
                width 0.15s cubic-bezier(0.65, 0, 0.35, 1),
                height 0.15s cubic-bezier(0.65, 0, 0.35, 1),
                border-radius 0.15s cubic-bezier(0.65, 0, 0.35, 1),
                padding 0.15s cubic-bezier(0.65, 0, 0.35, 1),
                margin 0.15s cubic-bezier(0.65, 0, 0.35, 1);
}
.auth-card button:not(.auth-switch):hover { opacity: 0.86; }

/* ── Спиннер загрузки на кнопках логина/регистрации ────────── */
.auth-card button .btn-spinner {
    position: absolute;
    left: 50%; top: 50%;
    width: 20px; height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    opacity: 0;
    animation: spin 0.7s linear infinite;
    transition: opacity var(--tr); /* появляется чуть позже, когда форма уже сжалась */
}
.auth-card button.btn-loading {
    pointer-events: none;
    opacity: 0.85;
    opacity: 1;
    /* морфинг в квадрат */
    width: 44px;
    height: 44px;
    padding: 0;
    margin-left: auto;
    margin-right: auto;
    border-radius: 22px;
}
.auth-card button.btn-loading:hover { opacity: 1; }
.auth-card button.btn-loading .btn-text {
    opacity: 0;
    transition: opacity var(--tr);
}
.auth-card button.btn-loading .btn-spinner {
    opacity: 1;
}
/* кнопка переключения login ↔ register */
.auth-switch {
    width: 100%; background: transparent; border: none;
    padding: 10px; margin-top: 8px;
    font-size: 13px; color: var(--text-muted);
    cursor: pointer; text-align: center;
    border-radius: 8px;
    transition: color var(--tr), background var(--tr);
    display: block;
}
.auth-switch:hover { color: var(--accent); background: rgba(92,124,250,0.07); }

/* ── APP SHELL ──────────────────────────────────────────── */
#chatUI {
    display: flex;
    height: 100%;                     /* фоллбек до первого JS-тика */
    height: var(--app-height, 100%);
    flex-direction: row;
    position: relative;
}

/* ── NAV RAIL ───────────────────────────────────────────── */
#navRail {
    width: var(--rail-w);
    flex-shrink: 0;
    background: var(--bg-rail);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: calc(10px + var(--safe-top)) 0 calc(12px + var(--safe-bottom));
}
.nav-top    { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nav-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nav-sep    { flex: 1; }

.nav-btn {
    width: 40px; height: 40px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    transition: background var(--tr), color var(--tr);
    padding: 0;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn:hover { background: rgba(255,255,255,0.07); color: var(--text-secondary); }
.nav-btn.active { background: var(--accent-dim); color: var(--accent); }

.nav-badge {
    display: none;
    position: absolute;
    top: 6px; right: 6px;
    width: 7px; height: 7px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--bg-rail);
}
.nav-badge.visible { display: block; }

.nav-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--accent-dim);
    background-size: cover;
    background-position: center;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; color: var(--accent);
    pointer-events: none;
}

/* ── SIDE PANEL ─────────────────────────────────────────── */
#sidePanel {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.panel { display: flex; flex-direction: column; height: 100%; }

.panel-header {
    height: calc(var(--header-h) + var(--safe-top));
    padding: var(--safe-top) 14px 0 18px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    font-size: 17px; font-weight: 600; color: var(--text-primary);
    box-sizing: border-box;
}

.panel-body {
    flex: 1; overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 20px;
}

/* кнопка-иконка (круглая) */
.icon-btn {
    width: 32px; height: 32px;
    border-radius: 50%; border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: background var(--tr), color var(--tr);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: rgba(255,255,255,0.07); color: var(--text-primary); }

/* ── CHAT LIST ──────────────────────────────────────────── */
#chatList { flex: 1; overflow-y: auto; padding: 4px 0; }

.chatItem {
    display: flex; align-items: center;
    padding: 8px 10px; gap: 12px;
    cursor: pointer;
    transition: background var(--tr);
    overflow: hidden;
	height: var(--send-h);
}
.chatItem:hover  { background: var(--bg-hover); }
.chatItem.active { background: var(--bg-active); }

.chatRow { display: flex; align-items: center; gap: 12px; min-width: 0; width: 100%; height: 100%; }

.chatAvatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    overflow: hidden;
    object-fit: cover;
    flex-shrink: 0;
}
.chatAvatarEmpty {
    background: var(--bg-elevated);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 600; color: var(--text-secondary);
}

/* ── Аватарки через <use> на общий SVG-ресурс ─────────────── */
/* Базовый вид: просто блочный элемент, без своих размеров —
   когда avatarUse ЕСТЬ сама .chatAvatar/.msgAvatar, размер уже
   задан этими классами (px). Явные 100% нужны только когда
   avatarUse — дочерний элемент контейнера-обёртки (профиль, рейл). */
.avatarUse { display: block; }

#profileAvatar > .avatarUse,
#privateAvatar > .avatarUse,
#navAvatar > .avatarUse,
#mobNavAvatar > .avatarUse {
    width: 100%;
    height: 100%;
}

/* ── Правая часть строки чата: 2 строки, в каждой свои собственные
   "лево растягивается / право не сжимается" колонки — как в Telegram.
   Раньше это были ДВЕ ЖЁСТКИЕ колонки на всю высоту (имя+сообщение слева,
   время+бейдж справа), из-за чего текст сообщения обрезался по границе
   своей колонки ещё до того, как реально упирался в время/бейдж — особенно
   заметно, когда бейджа непрочитанных нет вообще, но место под него всё
   равно резервировалось. Теперь ширина, которую "съедает" правая часть,
   зависит только от содержимого СВОЕЙ строки (время — своей, бейдж — своей),
   а не от соседней. ────────────────────────────────────────────────── */
.chatMain {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.chatLine {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chatName {
    flex: 1;
    min-width: 0;
    font-size: 14px; font-weight: 500;
    color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chatMessage {
    flex: 1;
    min-width: 0;
    font-size: 12px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.chatItem.active .chatMessage {
    color: var(--text-primary);
}

.chatTime {
    flex-shrink: 0;
    font-size: 12px; 
	color: var(--text-secondary);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Иконка статуса последнего своего сообщения слева от времени — тот же
   цвет, что и в самом чате (accent/danger), не наследует приглушённый
   цвет времени в списке чатов. */
.chatListStatusIcon {
    color: var(--accent) !important;
    flex-shrink: 0;
}
.chatItem.active .chatListStatusIcon {
    color: var(--text-primary) !important;
}
.chatListStatusIcon.failed { color: var(--danger) !important; }
.chatItem.active .chatListStatusIcon.failed { color: var(--danger) !important; }

.chatUnread {
  flex-shrink: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 15px;
  min-width: 15px;
  padding: 5px 3px 5.5px 3px;
  border-radius: 7.5px;
  background-color: var(--accent);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
}

.chatItem.active .chatTime {
    color: var(--text-primary);
}

.chatItem.active .chatUnread {
    color: var(--bg-active);
    background-color: var(--text-primary);
}

/* Размеры иконки статуса */
.msg-status {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
  color: var(--accent);
}

/* Анимация вращения часов */
.msg-status.sending { animation: spin 2s linear infinite; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── FORM GROUPS (contacts / profile panels) ─────────────── */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

.panel-body input,
.panel-body select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 13px;
    font-size: 14px; color: var(--text-primary);
    outline: none; width: 100%;
    transition: border-color var(--tr);
}
.panel-body input:focus { border-color: var(--accent); }
.panel-body input::placeholder { color: var(--text-muted); }

.panel-body button, .input-row button {
    background: var(--accent);
    border: none; border-radius: 8px;
    padding: 9px 14px;
    font-size: 13px; font-weight: 500; color: #fff;
    cursor: pointer; white-space: nowrap;
    transition: opacity var(--tr);
}
.panel-body button:hover, .input-row button:hover { opacity: 0.86; }

.fileLabel {
    display: inline-block;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 14px; color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--tr), color var(--tr);
}
.fileLabel:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── SETTINGS ───────────────────────────────────────────── */
.settings-section { display: flex; flex-direction: column; gap: 2px; }
.settings-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.settings-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--bg-surface);
    font-size: 14px; color: var(--text-primary);
    cursor: default;
}
.settings-item .settings-value { margin-left: auto; color: var(--text-secondary); font-size: 13px; }
.settings-item.danger { color: var(--danger); cursor: pointer; transition: background var(--tr); }
.settings-item.danger:hover { background: rgba(248,113,113,0.08); }

/* ── PROFILE HERO ───────────────────────────────────────── */
.profile-hero {
    display: flex; flex-direction: column; align-items: center;
    gap: 8px; padding: 10px 0 20px;
}
.profile-avatar-big {
    width: 80px; height: 80px; border-radius: 50%;
    overflow: hidden;
    background: var(--accent-dim);
    background-size: cover; background-position: center;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 600; color: var(--accent);
}
.profile-name { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.profile-meta { font-size: 12px; color: var(--text-muted); }

/* ── MESSAGES CONTAINER ─────────────────────────────────── */
#messagesContainer {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
	position: relative;				   
    background: var(--bg-base);
	#background-image: url('https://i.pinimg.com/originals/91/da/1d/91da1d736657fa11b9b529a0a6ac84b7.jpg');
	#background-image: url('https://i.pinimg.com/736x/1a/6f/d0/1a6fd082b2f93cdfc17a6b337d5a438d.jpg');
	#background-image: url('https://i.pinimg.com/736x/6a/0b/d1/6a0bd1a083263f84c0ec5b40299cecea.jpg');
	background-image: url('https://i.pinimg.com/originals/54/83/bb/5483bb592c24f186c634e5d953694ed4.jpg');
	background-repeat: no-repeat;
	background-position: center center;
	background-size: cover; /* cover или contain */
}

/* ── CHAT HEADER ─────────────────────────────────────────── */
#chatTitleHeader {
    height: calc(var(--header-h) + var(--safe-top));
    padding: var(--safe-top) 16px 0;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: none; align-items: center; gap: 12px;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* ── Единый мини-плеер аудио (под заголовком чата) ─────────── */
.global-audio-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    animation: gaBarIn 0.2s ease-out both;
}
@keyframes gaBarIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ga-play-btn {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.ga-play-btn svg { width: 14px; height: 14px; }

.ga-info { flex: 1; min-width: 0; }
.ga-title {
    font-size: 12px; font-weight: 500; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-bottom: 4px;
}
.ga-progress {
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.12);
    cursor: pointer;
    position: relative;
}
.ga-progress-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
}

.ga-progress-buffered {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: rgba(255,255,255,0.28);
    border-radius: 2px;
    transition: width 0.15s ease;
}

.ga-time {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    min-width: 34px;
}

.ga-speed-btn {
    flex-shrink: 0;
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px; font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--tr), color var(--tr);
}
.ga-speed-btn:hover { background: rgba(255,255,255,0.15); color: var(--text-primary); }

.ga-volume {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}
.ga-volume svg { width: 15px; height: 15px; flex-shrink: 0; }
.ga-volume input[type="range"] {
    width: 56px;
    accent-color: var(--accent);
    cursor: pointer;
}

.ga-close-btn {
    flex-shrink: 0;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: background var(--tr), color var(--tr);
}
.ga-close-btn svg { width: 13px; height: 13px; }
.ga-close-btn:hover { background: rgba(248,113,113,0.12); color: var(--danger); }

/* На мобильном громкость прячем (мышью там всё равно не покрутить,
   у телефона есть аппаратные кнопки громкости) — экономим место */
body.mobile .ga-volume { display: none; }
body.mobile .global-audio-bar { padding: 8px 10px; }
#privateAvatar {
    width: 36px; height: 36px; border-radius: 50%;
    background-size: cover; background-position: center;
    background-color: var(--bg-elevated);
    display: none; flex-shrink: 0;
    /* инициал если нет фото */
    font-size: 14px; font-weight: 600; color: var(--text-secondary);
}
#privateAvatar.shown {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#chatTitleColumn { display: flex; flex-direction: column; justify-content: center; flex: 1; min-width: 0; }
#chatTitleText {
    font-size: 15px; font-weight: 600; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

#chatToken { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

#chatState { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
#chatState.online { color: var(--accent); }

/* 1. Обёртка аватарки */
.avatar-wrapper {
  position: relative;
  display: inline-flex;
  width: fit-content;
  height: fit-content;
}

/* 2. Делаем прозрачный вырез в аватарке (SVG или DIV), если есть класс .online */
.chatItem.online .avatar-wrapper .chatAvatar {
  /* Формула маски: вырезаем круг в правом нижнем углу */
  -webkit-mask-image: radial-gradient(
    circle at calc(100% - (var(--status-dot-size) / 2)) calc(100% - (var(--status-dot-size) / 2)),
    transparent calc((var(--status-dot-size) / 2) + var(--status-cutout-gap)),
    black calc((var(--status-dot-size) / 2) + var(--status-cutout-gap) + 0.5px)
  );
  mask-image: radial-gradient(
    circle at calc(100% - (var(--status-dot-size) / 2)) calc(100% - (var(--status-dot-size) / 2)),
    transparent calc((var(--status-dot-size) / 2) + var(--status-cutout-gap)),
    black calc((var(--status-dot-size) / 2) + var(--status-cutout-gap) + 0.5px)
  );
}

.avatar-wrapper::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: var(--status-dot-size);
  height: var(--status-dot-size);
  border-radius: 50%;
  background-color: var(--accent);
  z-index: 2;

  /* НАСТРОЙКИ АНИМАЦИИ */
  transform-origin: center center;
  
  /* Если класса .online НЕТ -> точка сжата в 0 и прозрачна */
  transform: scale(0);
  opacity: 0;

  /* Плавность перехода для scale и opacity */
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              opacity 0.3s ease-out;
}

/* Когда добавляем класс .online -> точка становится нормальной */
.chatItem.online .avatar-wrapper::after {
  transform: scale(1);
  opacity: 1;
}

.chatItem.online.active .avatar-wrapper::after {
  background-color: var(--text-primary);
}

/* ── MESSAGES ────────────────────────────────────────────── */
/* Обёртка для position:relative — нужна для floating date */
#messagesWrap {
    flex: 1; min-height: 0;
    position: relative;
    display: flex; flex-direction: column;
    overflow: hidden;
}

#messages {
    flex: 1; overflow-y: auto;
    padding: 6px 12px 8px;
    display: block;
}

/* ── Плавающая дата ──────────────────────────────────────── */
#floatingDate {
    position: absolute;
    top: 8px; left: 0; right: 4px;
    text-align: center;
    pointer-events: none;
    z-index: 15;
    visibility: hidden;
}
#floatingDate span {
	position: absolute;
	top: 8px;
    left: 50%;
	transform: translateX(-50%);
    display: inline-block;
    background: var(--bg-sidebar);
    color: var(--text-secondary);
    font-size: 12px; font-weight: 500;
    padding: 4px 14px;
    border-radius: 999px;
    white-space: nowrap;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
	opacity: 1;
}

.dateHeader {
    text-align: center;
    padding: 10px 0 8px;
    pointer-events: none;
    position: relative;
    z-index: 5;
}
.dateHeader span {
    background: var(--bg-sidebar);
    color: var(--text-secondary);
    font-size: 12px; font-weight: 500;
    padding: 4px 14px;
    border-radius: 999px;
    display: inline-block;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Разделитель "Непрочитанные" ───────────────────────────── */
.unreadDivider {
    text-align: center;
    padding: 10px 0 8px;
    pointer-events: none;
    position: relative;
    z-index: 6;
    animation: msgAppear 0.2s ease-out both;
}
.unreadDivider::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--bg-sidebar) 20%, var(--bg-sidebar) 80%, transparent);
    z-index: -1;
}
.unreadDivider span {
    background: var(--bg-sidebar);
    color: var(--text-secondary);
    font-size: 12px; font-weight: 600;
    letter-spacing: .3px;
    padding: 4px 14px;
    border-radius: 999px;
    display: inline-block;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Группа чужих сообщений (с sticky-аватаркой) ─────────── */
/*
   .msgGroup — display:flex, прямой ребёнок #messages (display:block, overflow-y:auto)
   Аватарка — flex-item, position:sticky bottom:0 → прилипает к низу viewport'а #messages
   пока группа видна на экране.
*/
.msgGroup {
    display: flex;
    align-items: stretch;   /* оба flex-item растягиваются на всю высоту группы */
    gap: 8px;
}
.msgGroup.chain-start { margin-top: 6px; }

/* Колонка пузырьков */
.msgBubbleCol {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

/* Аватарка: занимает всю высоту группы, содержимое прилипает к низу через sticky */
.msgGroup > .msgAvatar {
    position: sticky;
    bottom: 0;              /* прилипает к низу скролл-контейнера #messages */
    align-self: flex-end;   /* внутри stretch — прижата к низу своего flex-track */
    flex-shrink: 0;
}

.msgRow { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 1px; }
.msgRow.chain-once { margin-top: 6px; margin-right: auto; }
.msgRow.chain-start { margin-top: 6px; border-bottom-right-radius: 4px; margin-right: auto;  }
.msgRow.chain-mid { border-bottom-right-radius: 4px; border-top-right-radius: 4px; margin-right: auto; }
.msgRow.chain-end {  border-top-right-radius: 4px; margin-right: auto;  }
.msgRow.mine { flex-direction: row-reverse; }

.msgAvatar {
    width: 28px; height: 28px; border-radius: 50%;
    overflow: hidden;
    object-fit: cover; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: var(--text-secondary);
}
.msgAvatar.mine { display: none; }
.msgAvatarEmpty { background: var(--bg-elevated); }
.msgAvatarSpacer { width: 28px; flex-shrink: 0; }

.msgItem {
	position: relative;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 14px; line-height: 1.45;
    max-width: min(72%, 480px);
    min-width: 0;
    word-wrap: break-word; word-break: break-word;
    animation: msgAppear 0.15s ease-out both;
    cursor: pointer;
}

.msgItem.mine.chain-once { margin-top: 6px; border-bottom-right-radius: 0px; }
.msgItem.mine.chain-start { margin-top: 6px; border-bottom-right-radius: 4px; }
.msgItem.mine.chain-mid { border-bottom-right-radius: 4px; border-top-right-radius: 4px; }
.msgItem.mine.chain-end { border-top-right-radius: 4px; border-bottom-right-radius: 0px; }

.msgItem.theirs.chain-once { margin-top: 6px; border-bottom-left-radius: 0px; }
.msgItem.theirs.chain-start { margin-top: 6px; border-bottom-left-radius: 4px; }
.msgItem.theirs.chain-mid { border-bottom-left-radius: 4px; border-top-left-radius: 4px; }
.msgItem.theirs.chain-end { border-top-left-radius: 4px; border-bottom-left-radius: 0px; }

.msgItem.theirs {
    background: var(--bg-bubble-in); color: var(--text-primary);
    margin-right: auto;
}
.msgItem.mine {
    background: var(--bg-bubble-out); color: var(--text-primary);
    margin-left: auto;
}


.msgItem .bubble-tail { display: none; }

.msgItem.mine.chain-once .bubble-tail,
.msgItem.mine.chain-end .bubble-tail {
    display: block;
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 11px;
    height: 20px;
    fill: var(--bg-bubble-out);
    transform: translateY(1px) scaleX(-1);
}

.msgItem.theirs.chain-once .bubble-tail,
.msgItem.theirs.chain-end .bubble-tail {
    display: block;
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 11px;
    height: 20px;
    fill: var(--bg-bubble-in);
    transform: translateY(1px) scaleX(1);
}

.msgUsername { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.msgUsername.un-color-0 { color: #5c7cfa; }
.msgUsername.un-color-1 { color: #20c997; }
.msgUsername.un-color-2 { color: #f79e07; }
.msgUsername.un-color-3 { color: #e03131; }
.msgUsername.un-color-4 { color: #9775fa; }
.msgUsername.un-color-5 { color: #4dabf7; }

.msgTime {
    font-size: 11px; color: var(--text-muted);
    margin-top: 5px; text-align: right;
    display: flex; align-items: center; justify-content: flex-end; gap: 3px;
}
.msgItem.mine .msgTime { color: var(--accent); }
.msgItem.mine .msgAttachmentFileSize { color: var(--accent); }
.msgItem.mine .msgAudioWaveBar { color: var(--accent); }															

/* ── Статус доставки своих сообщений: часы → одна галочка → две ──────── */
/* Все состояния — var(--accent) (наследуется от .msgItem.mine .msgTime),
   без приглушения/отбеливания. Исключение — ошибка отправки: те же часы,
   но неподвижные и красные. */
.msgStatusIcon {
    width: 14px; height: 14px;
    flex-shrink: 0;
    color: currentColor;
}
.msgStatusIcon.msgStatusSending {
    animation: spin 1.4s linear infinite;
    transform-origin: center;
}
.msgStatusIcon.failed {
    color: var(--danger);
    /* часы стоят — анимация не применяется (класс msgStatusSending отсутствует) */
}
/* Неотправленное сообщение — приглушено, курсор-пойнтер (клик = повтор) */
.msgItem.msgFailed {
    opacity: 0.72;
    cursor: pointer;
}
.msgItem.msgFailed:hover { opacity: 0.9; }

/* ── Прогресс загрузки вложения (кружок с процентом поверх картинки/видео) ── */
.msgAttachmentMediaWrap {
    position: relative;
    line-height: 0;
    display: block;
}
.msgAttachmentGallery.single .msgAttachmentMediaWrap {
    display: inline-block;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
}
.attUploadOverlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0,0,0,0.45);
    color: #fff;
    border-radius: inherit;
    pointer-events: none;
}
.attUploadRing {
    --att-progress: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: conic-gradient(#fff calc(var(--att-progress, 0) * 360deg), rgba(255,255,255,0.25) 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
}
.attUploadPct {
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.msgAttachmentUploading .attUploadPct {
    color: var(--text-secondary);
    font-weight: 500;
}
.msgItem.mine .msgAttachmentUploading .attUploadPct { color: var(--accent); }
.msgAttachmentUploading .msgAttachmentFileIcon { opacity: 0.75; }

/* ── SEND BOX ────────────────────────────────────────────── */
#sendBox {
    flex-shrink: 0; height: var(--send-h);
    padding: 0 12px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    display: none; align-items: center; gap: 10px;
}
#msg {
    flex: 1;
	min-width: 0;  
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px; color: var(--text-primary);
    outline: none; font-family: var(--font);
    transition: border-color var(--tr);
}
#msg:focus { border-color: var(--accent); }
#msg::placeholder { color: var(--text-muted); }
#btnSend {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--accent); border: none;
    cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; padding: 0;
    transition: opacity var(--tr), transform 0.1s;
}
#btnSend:hover { opacity: 0.86; }
#btnSend:active { transform: scale(0.92); }

/* ── BACK BUTTON ─────────────────────────────────────────── */
#backButton {
    width: 32px; height: 32px; min-width: 32px;
    display: none; align-items: center; justify-content: center;
    border-radius: 8px;
    background: transparent; border: none;
    color: var(--text-secondary);
    cursor: pointer; padding: 0;
    transition: color var(--tr);
    flex-shrink: 0;
}
#backButton svg { width: 22px; height: 22px; }
#backButton:hover { color: var(--text-primary); }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.modal {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 380px; max-width: calc(100vw - 32px);
    overflow: hidden;
    animation: modalIn 0.18s ease-out;
}
.modal-header {
    height: var(--header-h); padding: 0 14px 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    font-size: 16px; font-weight: 600; color: var(--text-primary);
}
.modal-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
.modal-body input {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 8px; padding: 9px 13px;
    font-size: 14px; color: var(--text-primary); outline: none; width: 100%;
    transition: border-color var(--tr);
}
.modal-body input:focus { border-color: var(--accent); }
.modal-body input::placeholder { color: var(--text-muted); }
.modal-body button {
    background: var(--accent); border: none; border-radius: 8px;
    padding: 9px 14px; font-size: 13px; font-weight: 500; color: #fff;
    cursor: pointer; white-space: nowrap; transition: opacity var(--tr);
}
.modal-body button:hover { opacity: 0.86; }

/* ── ANIMATIONS ──────────────────────────────────────────── */
@keyframes msgAppear {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── MOBILE (управляется JS-классом body.mobile) ─────────── */

/* По умолчанию мобильный навбар скрыт */
#mobileNav { display: none; }

/* .mob-nav-btn базовые стили (нужны до media) */
.mob-nav-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px; font-weight: 500;
    transition: color var(--tr);
    padding: 0;
    position: relative;
}
.mob-nav-btn svg { width: 22px; height: 22px; }
.mob-nav-btn.active { color: var(--accent); }
.mob-nav-btn .mob-badge {
    display: none;
    position: absolute; top: 6px; right: calc(50% - 14px);
    width: 7px; height: 7px;
    background: var(--accent); border-radius: 50%;
    border: 2px solid var(--bg-sidebar);
}
.mob-nav-btn .mob-badge.visible { display: block; }
.mob-nav-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    overflow: hidden;
    background: var(--accent-dim);
    background-size: cover; background-position: center;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: var(--accent);
}

body.mobile #navRail { display: none; }

body.mobile #mobileNav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    /* 56px — реальная высота контента навбара, safe-bottom добавляется
       СВЕРХ неё как отдельная зона, а не откусывает место у кнопок */
    height: calc(56px + var(--safe-bottom));
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    z-index: 50;
    align-items: stretch;
    padding: 0 calc(8px + var(--safe-right)) var(--safe-bottom) calc(8px + var(--safe-left));
    box-sizing: border-box;
}

body.mobile #chatUI { flex-direction: column; }

body.mobile #sidePanel {
    width: 100%; border-right: none;
    flex: 1; min-height: 0;
    padding-bottom: calc(56px + var(--safe-bottom));
}

/* Чат — слайд справа */
body.mobile #messagesContainer {
    position: fixed;
    inset: 0;
    z-index: 60;
	background-image: url('https://i.pinimg.com/originals/fe/ae/c3/feaec36f3e7ca487b05a7472ed1055d4.png');
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    display: flex !important;
}
body.mobile #messagesContainer.open {
    transform: translateX(0);
}

body.mobile #backButton {
    display: flex !important;
}

body.mobile #sendBox {
    height: auto;
    min-height: calc(var(--send-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    box-sizing: border-box;
}

/* ── WIDE: пузыри слева ──────────────────────────────────── */
@media (min-width: 1100px) {
 	.msgItem.mine.chain-once { border-bottom-right-radius: 14px !important; border-bottom-left-radius: 0px !important; }
 	.msgItem.mine.chain-start { border-bottom-right-radius: 14px !important; border-bottom-left-radius: 4px !important; }
 	.msgItem.mine.chain-mid { border-bottom-right-radius: 14px !important; border-top-right-radius: 14px !important; border-bottom-left-radius: 4px !important; border-top-left-radius: 4px !important; }
 	.msgItem.mine.chain-end { border-top-right-radius: 14px !important; border-top-left-radius: 4px !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 14px !important; }
    .msgItem.mine { margin-left: 0 !important; margin-right: auto !important; }
	
	.msgItem.mine.chain-once .bubble-tail,
	.msgItem.mine.chain-end .bubble-tail {
		transform: translateY(1px) scaleX(1) !important;
		left: -8px !important;
	}
	
	.msgAvatar.mine { display: flex !important; }
}

/* ── ПАГИНАЦИЯ СООБЩЕНИЙ: лоадеры и кнопка "к последним" ──── */

/* Верхний/нижний лоадер — компактная пилюля со спиннером,
   всплывает при подгрузке старых/новых сообщений */
.msgEdgeLoader {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) translateY(-8px) scale(0.9);
    z-index: 20;
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(24,37,51,0.92);
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.34,1.3,0.64,1);
}
.msgEdgeLoader.top    { top: 42px; left: calc(50% - 2px); }

.msgEdgeLoader.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.msgEdgeSpinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(92,124,250,0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Кнопка "к последним сообщениям" */
.jump-bottom-btn {
    position: absolute;
    right: 18px;
    bottom: 14px;
    z-index: 15;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(0,0,0,0.32);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    padding: 0;

    opacity: 0;
    transform: translateY(12px) scale(0.85);
    pointer-events: none;
    transition: opacity 0.2s ease,
                transform 0.24s cubic-bezier(0.34, 1.3, 0.64, 1),
                background var(--tr), color var(--tr);
}
.jump-bottom-btn svg { width: 19px; height: 19px; }
.jump-bottom-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.jump-bottom-btn.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.jump-bottom-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 17px; height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.34,1.5,0.64,1);
}
.jump-bottom-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* ── TOASTS ──────────────────────────────────────────────── */
#toastContainer {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;           /* поверх всего, включая модалки */
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;    /* клики проходят сквозь пустое пространство */
    max-width: calc(100vw - 32px);
    padding: 4px 8px;        /* запас чтобы тень не подрезалась краем viewport */
}

/* Обёртка каждого тоста — именно она анимирует схлопывание высоты,
   когда тост уходит, чтобы нижние тосты плавно поднимались, а не скакали.
   overflow:visible по умолчанию — не обрезает тень и bounce-эффект тоста.
   overflow:hidden включается только на момент схлопывания (.collapsing). */
.toast-wrap {
    max-height: 100px;   /* с запасом на любой реальный размер тоста */
    margin-bottom: 8px;
    overflow: visible;
    transition: max-height 0.26s cubic-bezier(0.4, 0, 0.2, 1),
                margin-bottom 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast-wrap.collapsing {
    overflow: hidden;
}
.toast-wrap.collapsed {
    max-height: 0;
    margin-bottom: 0;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 260px;
    max-width: 380px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.4;

    /* Стартовая позиция — над экраном, невидим */
    transform: translateY(-140%);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.34, 1.3, 0.64, 1),
                opacity   0.22s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* При закрытии/истечении — уезжает обратно вверх */
.toast.leaving {
    transform: translateY(-140%);
    opacity: 0;
    transition: transform 0.26s cubic-bezier(0.4, 0, 1, 1),
                opacity   0.2s ease;
}

.toast-icon {
    width: 20px; height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-top: 1px;
}
.toast-icon svg { width: 12px; height: 12px; }

.toast-body { flex: 1; min-width: 0; word-break: break-word; }

.toast-close {
    flex-shrink: 0;
    width: 20px; height: 20px;
    border: none; background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    border-radius: 6px;
    transition: background var(--tr), color var(--tr);
    margin: -2px -2px 0 0;
}
.toast-close:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.toast-close svg { width: 13px; height: 13px; }

/* Цветные варианты — левая полоса + цвет иконки */
.toast.info {
    border-left: 3px solid var(--accent);
}
.toast.info .toast-icon { background: rgba(92,124,250,0.15); color: var(--accent); }

.toast.success {
    border-left: 3px solid #2fb344;
}
.toast.success .toast-icon { background: rgba(47,179,68,0.15); color: #3ecf5e; }

.toast.warning {
    border-left: 3px solid #f2a93b;
}
.toast.warning .toast-icon { background: rgba(242,169,59,0.15); color: #f2a93b; }

.toast.error {
    border-left: 3px solid var(--danger);
}
.toast.error .toast-icon { background: rgba(248,113,113,0.15); color: var(--danger); }

/* Мобильный — чуть уже отступы */
body.mobile #toastContainer {
    top: calc(12px + var(--safe-top));
    width: calc(100vw - 24px);
}
body.mobile .toast { min-width: 0; width: 100%; }

/* ── МЕДИА: кнопки в sendBox, превью вложения, пикер эмодзи ── */

.send-icon-btn {
    flex-shrink: 0;
    color: var(--text-secondary);
}
.send-icon-btn:hover {
    color: var(--accent);
}

/* ── Превью вложений перед отправкой (несколько чипов) ────── */
.attach-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 18px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.attach-chip {
    position: relative;
    flex-shrink: 0;
    animation: attachChipIn 0.18s cubic-bezier(0.34,1.3,0.64,1) both;
}
@keyframes attachChipIn {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

.attach-chip-thumb {
    width: 56px; height: 56px;
    border-radius: 10px;
    background: var(--bg-elevated);
    background-size: cover;
    background-position: center;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    overflow: hidden;
}
.attach-chip-thumb svg { width: 22px; height: 22px; }
.attach-chip-thumb { position: relative; }
.attach-chip-video-badge {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    border-radius: 10px;
}
.attach-chip-video-badge svg { width: 16px; height: 16px; margin-left: 1px; }

.attach-chip-remove {
    position: absolute;
    top: -6px; right: -6px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--bg-sidebar);
    color: #fff;
    cursor: pointer;
    padding: 0;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.12s ease;
}
.attach-chip-remove svg { width: 11px; height: 11px; }
.attach-chip-remove:hover { transform: scale(1.12); }

.attach-chip-name {
    position: absolute;
    left: 0; right: 0; bottom: -4px;
    transform: translateY(100%);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attach-chip-cap {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 6px;
    white-space: nowrap;
}

/* ── Пикер эмодзи ─────────────────────────────────────────── */
.emoji-picker {
    position: absolute;
    bottom: calc(var(--send-h) + var(--safe-bottom) + 8px);
    right: 12px;
    width: 300px;
    max-height: 320px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    z-index: 60;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: emojiPickerIn 0.16s cubic-bezier(0.34,1.2,0.64,1) both;
}
@keyframes emojiPickerIn {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.emoji-picker-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    padding: 4px;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.emoji-picker-tab {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    background: transparent; border: none;
    border-radius: 8px;
    padding: 0;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--tr);
    display: flex; align-items: center; justify-content: center;
}
.emoji-picker-tab:hover { background: rgba(255,255,255,0.06); }
.emoji-picker-tab.active { background: var(--accent-dim); }

.emoji-picker-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 8px;
}
.emoji-picker-item {
    background: transparent; border: none;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    padding: 6px 0;
    cursor: pointer;
    transition: background var(--tr), transform 0.1s;
}
.emoji-picker-item:hover { background: rgba(255,255,255,0.08); transform: scale(1.15); }

/* ── Дропдаун выбора типа вложения ─────────────────────────── */
.attach-menu {
    position: absolute;
    bottom: calc(var(--send-h) + var(--safe-bottom) + 8px);
    left: 12px;
    min-width: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    z-index: 60;
    flex-direction: column;
    padding: 6px;
    gap: 2px;
    animation: emojiPickerIn 0.16s cubic-bezier(0.34,1.2,0.64,1) both;
}
.attach-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: background var(--tr);
}
.attach-menu-item:hover { background: rgba(255,255,255,0.07); }

.attach-menu-icon {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.attach-menu-icon svg { width: 16px; height: 16px; }
.attach-menu-icon.photo { background: linear-gradient(135deg, #5c7cfa, #4263eb); }
.attach-menu-icon.audio { background: linear-gradient(135deg, #f2a93b, #e8590c); }
.attach-menu-icon.file  { background: linear-gradient(135deg, #51cf66, #2f9e44); }
/* ── Вложения в сообщениях ────────────────────────────────── */
.msgAttachmentGallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
    max-width: min(var(--attach-w), 100%);
    margin-bottom: 4px;
    border-radius: 12px;
    overflow: hidden;
}
.msgAttachmentGallery.single {
    display: block;
}

.msgAttachmentImage {
    display: block;
    width: 100%;
    height: 128px;
    cursor: pointer;
    object-fit: cover;
    transition: opacity 0.12s ease;
}
.msgAttachmentGallery.single .msgAttachmentImage {
    width: auto;
    max-width: min(var(--attach-w), 100%) !important;
    max-height: 320px !important;
    height: auto;
    border-radius: 12px;
}
.msgAttachmentImage:hover { opacity: 0.92; }

.msgAttachmentFile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    margin-bottom: 4px;
    text-decoration: none;
    color: inherit;
    transition: background var(--tr);
    width: min(var(--attach-w), 100%) !important;
    max-width: min(var(--attach-w), 100%) !important;
    min-width: 0 !important;
}
.msgAttachmentFile:hover { background: rgba(255,255,255,0.1); }

.msgAttachmentFileIcon {
    width: 36px; height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.msgAttachmentFileIcon svg { width: 18px; height: 18px; }

.msgAttachmentFileInfo { flex: 1; min-width: 0; }
.msgAttachmentFileName {
    font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msgAttachmentFileSize {
    font-size: 11px; color: var(--text-muted); margin-top: 1px;
}

/* ── Видео в галерее вложений (превью + плей + длительность) ── */
/* .msgAttachmentVideoThumb несёт класс .msgAttachmentImage — размер
   пропорционален контенту так же, как у обычной картинки (см. правила выше) */
.msgAttachmentVideoCell {
    position: relative;
    cursor: pointer;
    background-color: var(--bg-elevated);
    line-height: 0; /* убирает паразитный зазор снизу у inline img */
}
.msgAttachmentGallery.single .msgAttachmentVideoCell {
    display: block !important;
    max-width: min(var(--attach-w), 100%) !important;
    max-height: 320px !important;
    width: fit-content !important;
    border-radius: 12px;
    overflow: hidden;
}
.msgAttachmentPlayBadge {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    pointer-events: none;
}
.msgAttachmentPlayBadge svg { width: 18px; height: 18px; margin-left: 2px; }
.msgAttachmentDuration {
    position: absolute;
    right: 6px; bottom: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 10px; font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    pointer-events: none;
}

/* ── Инлайн-плеер аудио-сообщений ─────────────────────────── */
.msgAudioPlayer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 14px;
    background: rgba(255,255,255,0.06);
    margin-bottom: 4px;
    width: min(var(--attach-w), 100%) !important;
    max-width: min(var(--attach-w), 100%) !important;
    min-width: 0 !important;
}
.msgAudioPlayBtn {
    flex-shrink: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: opacity var(--tr);
}
.msgAudioPlayBtn svg { width: 15px; height: 15px; }
.msgAudioPlayBtn:hover { opacity: 0.86; }
.msgAudioPlayBtn.playing { background: var(--accent-dim); color: var(--accent); }

.msgAudioBody { flex: 1; min-width: 0; }
.msgAudioWave {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 30px;
    cursor: pointer;
    padding: 2px 0;
    min-width: 0;
}
.msgAudioWaveBar {
    flex: 1;
    min-width: 1px;
    max-width: 3px;
    background: var(--accent-dim);
    border-radius: 2px;
    opacity: 0.55;
    transition: background var(--tr), opacity var(--tr);
}
.msgAudioWaveBar.played {
    background: var(--accent);
    opacity: 1;
}
.msgAudioTime {
    font-size: 11px;
    color: var(--accent);
    margin-top: 3px;
}

/* ── Медиа-вьюер: изображения и видео, листание, скачивание ── */
.media-viewer {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0,0,0,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    animation: lightboxFadeIn 0.18s ease-out both;
}
@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.media-viewer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

.media-viewer-image {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: lightboxImageIn 0.22s cubic-bezier(0.34,1.2,0.64,1) both;
    -webkit-user-select: none; user-select: none;
}
@keyframes lightboxImageIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

.media-viewer-counter {
    position: absolute;
    top: 20px; left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.85);
    font-size: 13px; font-weight: 500;
    background: rgba(255,255,255,0.1);
    padding: 4px 12px;
    border-radius: 999px;
    display: none;
}

.media-viewer-action {
    position: absolute;
    top: 20px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--tr);
    z-index: 2;
}
.media-viewer-action:hover { background: rgba(255,255,255,0.2); }
.media-viewer-action svg { width: 19px; height: 19px; }
.media-viewer-close   { right: 20px; }
.media-viewer-download{ right: 70px; }

.media-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px; height: 46px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: background var(--tr), opacity var(--tr);
    z-index: 2;
}
.media-viewer-nav.visible { opacity: 1; pointer-events: auto; }
.media-viewer-nav:hover { background: rgba(255,255,255,0.22); }
.media-viewer-nav svg { width: 22px; height: 22px; }
.media-viewer-nav.prev { left: 20px; }
.media-viewer-nav.next { right: 20px; }

/* ── Кастомный видео-плеер внутри медиа-вьюера ───────────────── */
.media-viewer-video-wrap {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: lightboxImageIn 0.22s cubic-bezier(0.34,1.2,0.64,1) both;
}
.media-viewer-video {
    max-width: 100%;
    max-height: 82vh;
    display: block;
    cursor: pointer;
}

.spin-icon { animation: spin 0.8s linear infinite; }

.video-player-big-play {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 64px; height: 64px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.video-player-big-play svg { width: 26px; height: 26px; margin-left: 3px; }
.video-player-big-play.hidden { opacity: 0; pointer-events: none; transform: translate(-50%, -50%) scale(0.8); }

.video-player-controls {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
}
.video-player-play {
    flex-shrink: 0;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.video-player-play svg { width: 13px; height: 13px; }
.video-player-seek {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.25);
    cursor: pointer;
    position: relative;
}
.video-player-seek-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
}

.video-player-seek-buffered {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    transition: width 0.15s ease;
}

.video-player-buffering {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 48px; height: 48px;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.video-player-buffering.visible { display: flex; }
.video-player-buffering-ring {
    width: 34px; height: 34px;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.video-player-time {
    flex-shrink: 0;
    color: rgba(255,255,255,0.85);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.video-player-speed {
    flex-shrink: 0;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px; font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: background var(--tr);
}
.video-player-speed:hover { background: rgba(255,255,255,0.28); }

.video-player-volume {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #fff;
}
.video-player-volume svg { width: 15px; height: 15px; flex-shrink: 0; }
.video-player-volume input[type="range"] {
    width: 56px;
    accent-color: var(--accent);
    cursor: pointer;
}
body.mobile .video-player-volume { display: none; }
/* ── Мобильный ────────────────────────────────────────────── */
body.mobile .emoji-picker {
    right: 8px;
    left: 8px;
    width: auto;
}

/* На мобильном картинка/видео должны занимать всю ширину экрана,
   без обрезающих отступов — раньше padding:40px душил контент */
body.mobile .media-viewer {
    padding: 0;
}
body.mobile .media-viewer-image,
body.mobile .media-viewer-video-wrap {
    max-width: 100%;
    border-radius: 0;
}
body.mobile .media-viewer-image { box-shadow: none; }
body.mobile .media-viewer-video-wrap { box-shadow: none; }
/* Стрелки листания прячем на мобильном — там свайп */
body.mobile .media-viewer-nav { display: none; }
body.mobile .media-viewer-action { top: calc(16px + var(--safe-top)); }
body.mobile .media-viewer-counter { top: calc(16px + var(--safe-top)); }
body.mobile .video-player-controls { padding-bottom: calc(10px + var(--safe-bottom)); }

/* ── Контекстное меню (ПКМ / долгое удержание / тап) ──────────── */
.context-menu {
    position: fixed;
    min-width: 190px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    z-index: 999;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: emojiPickerIn 0.14s cubic-bezier(0.34,1.2,0.64,1) both;
}
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: background var(--tr);
}
.context-menu-item:hover { background: rgba(255,255,255,0.07); }
.context-menu-item.danger { color: var(--danger); }
.context-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Прозрачная подложка — клик/тап мимо меню его закрывает */
.context-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 998;
    background: transparent;
}

/* ── Запись голосовых / видео-сообщений (жест "удержать") ─────────────── */
#sendBox { position: relative; }

.rec-btn { touch-action: none; } /* не даём тачу скроллить страницу во время свайпа */

/* Полоса, которая замещает attach/input/emoji, пока зажата кнопка записи */
.rec-slide-bar {
    display: none;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.recording-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--danger);
    animation: recPulse 1.1s ease-in-out infinite;
}
@keyframes recPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}
#recordingTime {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    min-width: 40px;
}

.rec-slide-hint {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    pointer-events: none;
    will-change: transform, opacity;
}
.rec-slide-hint svg { width: 16px; height: 16px; flex-shrink: 0; }

.rec-locked-actions {
    display: none;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}
.recording-cancel { color: var(--danger); flex-shrink: 0; }
.recording-cancel:hover { background: rgba(248,113,113,0.12); color: var(--danger); }
.recording-send {
    flex-shrink: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
}
.recording-send:hover { background: var(--accent); opacity: 0.86; color: #fff; }

/* Блокиратор ("свайп вверх, чтобы зафиксировать") — висит над зажатой кнопкой */
.rec-lock-hint {
    position: absolute;
    right: 6px;
    bottom: calc(100% + 10px);
    width: 34px; height: 34px;
    border-radius: 17px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    box-shadow: 0 6px 16px rgba(0,0,0,0.32);
    transition: background var(--tr), color var(--tr);
    pointer-events: none;
    will-change: transform;
}
.rec-lock-hint svg { width: 16px; height: 16px; }
.rec-lock-hint.locked { background: var(--accent); color: #fff; }

/* Большой круглый live-превью записи видео-кружка — над чатом, не на весь экран */
.video-record-overlay {
    position: absolute;
    left: 0; right: 0;
    bottom: calc(var(--send-h) + var(--safe-bottom) + 14px);
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 40;
    animation: msgAppear 0.18s ease-out both;
}
.video-record-preview-big {
    width: min(72vw, 300px);
    height: min(72vw, 300px);
    border-radius: 50%;
    object-fit: cover;
    background: #000;
    box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 6px rgba(0,0,0,0.22);
    transform: scaleX(-1); /* зеркалим фронталку — привычный "селфи" вид */
}
body.mobile .video-record-preview-big { width: min(80vw, 280px); height: min(80vw, 280px); }

/* ── Обрезка и предпросмотр готовой записи (после блокировки жестом) ──── */
.rec-editor-overlay {
    position: absolute;
    left: 0; right: 0;
    bottom: calc(var(--send-h) + var(--safe-bottom) + 14px);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 45;
    animation: msgAppear 0.18s ease-out both;
}

.rec-editor-video {
    position: relative;
    width: min(72vw, 300px);
    height: min(72vw, 300px);
    flex-shrink: 0;
}
.rec-editor-video-el {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #000;
    box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 6px rgba(0,0,0,0.22);
}
.rec-editor-play-btn {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 52px; height: 52px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    border: none;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    padding: 0;
}
.rec-editor-play-btn svg { width: 22px; height: 22px; margin-left: 2px; }

.rec-editor-audio {
    width: min(86vw, 380px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.rec-editor-audio-play {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    padding: 0;
}
.rec-editor-audio-play svg { width: 15px; height: 15px; margin-left: 1px; }
.rec-editor-wave {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    gap: 1.5px;
    height: 36px;
}
.rec-editor-wave-bar {
    flex: 1;
    min-width: 1px;
    max-width: 3px;
    background: var(--accent-dim);
    border-radius: 2px;
    opacity: 0.5;
    transition: background var(--tr), opacity var(--tr);
}
.rec-editor-wave-bar.selected { background: var(--accent); opacity: 1; }

.rec-editor-trim {
    width: min(86vw, 320px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    flex-shrink: 0;
}
.rec-trim-track {
    position: relative;
    height: 34px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
}
.rec-trim-selected {
    position: absolute;
    top: 0; bottom: 0;
    background: rgba(64,130,188,0.28);
    border-top: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    pointer-events: none;
}
.rec-trim-handle {
    position: absolute;
    top: 0; bottom: 0;
    width: 14px;
    background: var(--accent);
    cursor: ew-resize;
    touch-action: none;
}
.rec-trim-handle::after {
    content: "";
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 2px; height: 14px;
    background: rgba(255,255,255,0.75);
    border-radius: 1px;
}
.rec-trim-handle.start { border-radius: 8px 3px 3px 8px; }
.rec-trim-handle.end   { border-radius: 3px 8px 8px 3px; }
.rec-trim-times {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.rec-editor-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}
.recording-send-big {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 8px 24px rgba(64,130,188,0.4);
    transition: opacity var(--tr);
}
.recording-send-big svg { width: 22px; height: 22px; }
.recording-send-big:hover { opacity: 0.88; }


/* ── Круглые видео-сообщения (как кружки в Telegram) ──────────────────── */
.msgAttachmentGallery.single .msgAttachmentVideoCell.msgVideoRound,
.msgAttachmentVideoCell.msgVideoRound {
    width: 200px !important;
    height: 200px !important;
    max-width: 200px !important;
    max-height: 200px !important;
    border-radius: 50% !important;
    overflow: hidden;
}
.msgVideoRound .msgAttachmentImage,
.msgVideoRound .msgAttachmentVideoThumb {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: 50%;
}
.msgVideoRound .msgAttachmentPlayBadge {
    width: 52px; height: 52px;
}
.msgVideoRound .msgAttachmentDuration {
    right: 50%;
    bottom: 14px;
    transform: translateX(50%);
}