/* Стиль интерфейса «Мессенджер» (Настройки → Внешний вид → Стиль интерфейса).
   Включается классом body.ui-msgr и только переопределяет оформление обычного интерфейса. */

/* ---------- Карточка выбора стиля ---------- */
.ui-style-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.ui-style { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 12px; border-radius: 14px; border: 2px solid var(--border); background: var(--bg3); color: var(--text); font: inherit; cursor: pointer; transition: border-color .15s, transform .1s; }
.ui-style:hover { transform: translateY(-1px); }
.ui-style.sel { border-color: var(--accent); }
.ui-style span { font-size: 12px; color: var(--muted); }
.ui-prev { height: 90px; border-radius: 10px; background: var(--bg); display: flex; gap: 4px; padding: 6px; margin-bottom: 4px; }
.ui-prev i { display: block; border-radius: 6px; background: var(--bg4); }
.ui-prev .r { width: 14px; }
.ui-prev .s { width: 34%; }
.ui-prev .m { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 6px; background: var(--bg2); }
.ui-prev .m b { display: block; height: 9px; border-radius: 5px; background: var(--bg4); width: 80%; }
.ui-prev.msg .m b { width: 45%; height: 12px; border-radius: 8px; }
.ui-prev.msg .m b.me { align-self: flex-end; background: var(--accent); }

/* ---------- Раскладка: без панели серверов ---------- */
body.ui-msgr #rail { display: none !important; }
body.ui-msgr #sidebar { width: 340px; background: var(--bg2); border-right: 1px solid var(--border); }
body.ui-msgr .side-head { gap: 8px; padding: 10px 10px 8px; height: auto; min-height: 56px; border-bottom: 0; box-shadow: none; }
body.ui-msgr .msgr-search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 19px; background: var(--input); color: var(--muted); cursor: text; font-size: 14px; }
body.ui-msgr .msgr-search svg { width: 17px; height: 17px; }
body.ui-msgr .side-list { padding: 0 6px; }
body.ui-msgr .side-cat { padding: 14px 10px 6px; }
body.ui-msgr .side-item { padding: 8px 10px; gap: 12px; border-radius: 12px; color: var(--text); }
body.ui-msgr .side-item:has(> .avatar) { min-height: 60px; }
body.ui-msgr .side-item .avatar.sm { width: 48px; height: 48px; font-size: 18px; flex-shrink: 0; }
body.ui-msgr .side-item .name { display: flex; flex-direction: column; gap: 2px; }
body.ui-msgr .side-item .nm { font-weight: 600; font-size: 15px; }
body.ui-msgr .side-item .sub { font-size: 13.5px; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
body.ui-msgr .side-item.active { background: var(--accent); color: #fff; }
body.ui-msgr .side-item.active .sub, body.ui-msgr .side-item.active .draft-mark { color: rgba(255,255,255,.85); }
body.ui-msgr .side-item.unread .sub { color: var(--text); }
body.ui-msgr .side-item .count { background: var(--accent); border-radius: 12px; min-width: 22px; height: 22px; display: grid; place-items: center; font-weight: 700; }
body.ui-msgr .side-item.active .count { background: #fff; color: var(--accent); }
body.ui-msgr .srv-av { border-radius: 14px !important; font-weight: 700; }
body.ui-msgr .srv-av img { border-radius: 14px; }
body.ui-msgr .side-item[data-act="add-server"] { min-height: 44px; color: var(--accent); }
body.ui-msgr .side-item[data-act="add-server"] svg { width: 22px; height: 22px; margin: 0 13px; }

/* ---------- Шапка чата ---------- */
body.ui-msgr .main-head { height: 58px; background: var(--bg2); }
body.ui-msgr .main-head .title { gap: 12px; cursor: pointer; }
body.ui-msgr .main-head .title .avatar.sm { width: 42px; height: 42px; }
body.ui-msgr .msgr-ht { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
body.ui-msgr .msgr-ht b { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ui-msgr .msgr-ht small { font-size: 13px; color: var(--muted); font-weight: 400; }
body.ui-msgr .msgr-ht small.on { color: var(--accent); }

/* ---------- Сообщения пузырями ---------- */
body.ui-msgr #messages { padding: 12px 0 10px; background: color-mix(in srgb, var(--bg) 70%, transparent); }
body.ui-msgr .msg { padding: 1px 16px; gap: 8px; align-items: flex-end; }
body.ui-msgr .msg:hover { background: transparent; }
body.ui-msgr .msg.first { margin-top: 8px; }
body.ui-msgr .msg > div:first-child .avatar { width: 34px; height: 34px; }
body.ui-msgr .msg.cont > div:first-child .avatar { visibility: hidden; height: 0; width: 34px; }
body.ui-msgr .msg .body { flex: 0 1 auto; max-width: min(560px, 72%); background: var(--bg3); border-radius: 16px 16px 16px 6px; padding: 6px 12px 7px; box-shadow: 0 1px 1px rgba(0,0,0,.12); position: relative; }
body.ui-msgr .msg.cont .body { border-radius: 16px 16px 16px 6px; }
body.ui-msgr .msg .meta { gap: 6px; }
body.ui-msgr .msg .author { font-size: 13.5px; color: var(--accent); }
body.ui-msgr .msg .meta .time { display: none; }
/* время — внизу справа внутри пузыря */
body.ui-msgr .msg .text { display: inline; }
body.ui-msgr .msg .msgr-time { float: right; margin: 6px 0 -4px 10px; font-size: 11px; color: var(--faint); user-select: none; }
body.ui-msgr .msg .attach img, body.ui-msgr .msg .attach video { border-radius: 12px; }
/* свои — справа, цветом акцента */
body.ui-msgr .msg.mine { flex-direction: row-reverse; }
body.ui-msgr .msg.mine > div:first-child { display: none; }
body.ui-msgr .msg.mine .body { background: var(--accent); color: #fff; border-radius: 16px 16px 6px 16px; }
body.ui-msgr .msg.mine .meta .author, body.ui-msgr .msg.mine .meta .badge { display: none; }
body.ui-msgr .msg.mine .meta:not(:has(.pin-flag)) { display: none; }
body.ui-msgr .msg.mine .msgr-time, body.ui-msgr .msg.mine .edited { color: rgba(255,255,255,.75); }
body.ui-msgr .msg.mine a { color: #fff; text-decoration: underline; }
body.ui-msgr .msg.mine .reply { color: rgba(255,255,255,.85); border-left: 2px solid rgba(255,255,255,.7); padding-left: 6px; }
body.ui-msgr .msg.mine .reaction { background: rgba(255,255,255,.2); border-color: transparent; color: #fff; }
body.ui-msgr .msg .reply { border-left: 2px solid var(--accent); padding-left: 6px; margin-bottom: 4px; }
body.ui-msgr .msg .reply::before { content: none; }
/* в личке имя собеседника над каждым пузырём не нужно */
body.ui-msgr.in-dm .msg .meta .author, body.ui-msgr.in-dm .msg .meta .badge { display: none; }
body.ui-msgr.in-dm .msg .meta:not(:has(.pin-flag)) { display: none; }
body.ui-msgr.in-dm .msg > div:first-child { display: none; }
body.ui-msgr .msg .actions { top: -16px; right: auto; left: 60px; border-radius: 12px; }
body.ui-msgr .msg.mine .actions { left: auto; right: 16px; }
body.ui-msgr .day-sep { display: flex; justify-content: center; border: 0; margin: 12px 0 4px; }
body.ui-msgr .day-sep, body.ui-msgr .day-sep span { color: var(--text); font-size: 12.5px; font-weight: 600; }
body.ui-msgr .day-sep::before, body.ui-msgr .day-sep::after { display: none; }
body.ui-msgr .poll, body.ui-msgr .lp { background: rgba(0,0,0,.12); }
body.ui-msgr .msg.mine .poll-opt { color: #fff; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); }

/* ---------- Поле ввода ---------- */
body.ui-msgr .composer { padding: 8px 14px 12px; }
body.ui-msgr .composer .inner { padding: 4px 6px; min-height: 48px; align-items: center; }

/* ---------- Настройки списком ---------- */
body.ui-msgr #settings nav .side-item { min-height: 46px; padding: 10px 14px; border-radius: 12px; gap: 16px; font-size: 15px; }
body.ui-msgr #settings nav .side-item svg { width: 22px; height: 22px; padding: 4px; border-radius: 8px; background: var(--accent); color: #fff; opacity: 1; }
body.ui-msgr #settings nav .side-item.active { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
body.ui-msgr #settings .card { border-radius: 16px; }

/* ---------- Звонок на весь экран ---------- */
body.ui-msgr #call { position: fixed; inset: 0; z-index: 80; height: auto !important; min-height: 0; border: 0; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--accent) 45%, #0d0e11) 0%, #0d0e11 75%); }
body.ui-msgr #call .grid { align-content: center; }
body.ui-msgr #call .bar { padding: 18px 18px 28px; gap: 16px; }
body.ui-msgr #call .call-btn { width: 58px; height: 58px; border-radius: 50%; }
body.ui-msgr #call .call-btn svg { width: 24px; height: 24px; }
body.ui-msgr #call .call-btn.hang { background: #e5484d; }

/* ---------- Телефон ---------- */
@media (max-width: 640px) {
  body.ui-msgr #sidebar { width: auto !important; border-right: 0; }
  body.ui-msgr .msg .body { max-width: 82%; }
  body.ui-msgr .side-item:has(> .avatar) { min-height: 66px; }
  body.ui-msgr #call .bar { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
}
.msgr-time { display: none; } body.ui-msgr .msg .msgr-time { display: inline; }
body.ui-msgr .msg.mine .lp { color: #fff; border-left-color: #fff !important; } body.ui-msgr .msg.mine .lp-title { color: #fff; } body.ui-msgr .msg.mine .lp-site, body.ui-msgr .msg.mine .lp-desc, body.ui-msgr .msg.mine .poll-foot { color: rgba(255,255,255,.8); }

/* ---------- «Мессенджер» v2: папки, список, меню, окна. Скругления небольшие ---------- */
body.ui-msgr { --r: 6px; }
body.ui-msgr .btn { border-radius: var(--r); padding: 9px 16px; }
body.ui-msgr .btn.small { border-radius: 5px; }
body.ui-msgr .icon-btn { border-radius: 50%; }
body.ui-msgr .input, body.ui-msgr textarea.input, body.ui-msgr select.input { border-radius: var(--r); }
body.ui-msgr .modal { border-radius: 10px; }
body.ui-msgr .card { border-radius: 8px; }
body.ui-msgr .menu { border-radius: 8px; }
body.ui-msgr .menu button { border-radius: 4px; }
body.ui-msgr .toast { border-radius: 8px; }
body.ui-msgr .composer .inner { border-radius: 8px; }
body.ui-msgr .msg .body { border-radius: 12px 12px 12px 4px; }
body.ui-msgr .msg.mine .body { border-radius: 12px 12px 4px 12px; }
body.ui-msgr .ui-style, body.ui-msgr .frame-opt { border-radius: 8px; }

body.ui-msgr #sidebar.tg-side { width: 470px; display: grid; grid-template-columns: 72px 1fr; grid-template-rows: auto 1fr auto; grid-auto-rows: auto; padding-bottom: 0; }
body.ui-msgr #tg-folders { grid-row: 1 / span 3 !important; }
body.ui-msgr #sidebar.tg-side.tg-in-srv { grid-template-columns: 1fr; width: 400px; }
body.ui-msgr #tg-folders { grid-row: 1 / -1; grid-column: 1; display: flex; flex-direction: column; align-items: stretch; background: var(--bg); padding: 6px 0; overflow-y: auto; }
body.ui-msgr .tg-burger { position: relative; height: 52px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
body.ui-msgr .tg-burger svg { width: 22px; height: 22px; }
body.ui-msgr .tg-burger .dot { position: absolute; top: 14px; right: 22px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
body.ui-msgr .tg-folder { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; border: 0; background: none; color: var(--muted); font: 600 11.5px/1.1 inherit; cursor: pointer; }
body.ui-msgr .tg-folder svg { width: 26px; height: 26px; }
body.ui-msgr .tg-folder.sel { color: var(--accent); background: var(--bg2); }
body.ui-msgr .tg-folder.sel::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
body.ui-msgr .tg-fbadge { position: absolute; top: 4px; left: 38px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; display: grid; place-items: center; border: 2px solid var(--bg); }
body.ui-msgr .tg-side .side-head { grid-column: 2; padding: 8px 10px; min-height: 56px; }
body.ui-msgr .tg-side.tg-in-srv .side-head, body.ui-msgr .tg-side.tg-in-srv .side-list, body.ui-msgr .tg-side.tg-in-srv #voicebar, body.ui-msgr .tg-side.tg-in-srv #userbar { grid-column: 1; }
body.ui-msgr .tg-side .side-list { grid-column: 2; padding: 0; }
body.ui-msgr .tg-side #voicebar, body.ui-msgr .tg-side #userbar { grid-column: 2; }
body.ui-msgr .tg-side #userbar { display: none; }
body.ui-msgr .tg-search { flex: 1; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 14px; border-radius: 19px; background: var(--input); color: var(--muted); }
body.ui-msgr .tg-search svg { width: 17px; height: 17px; flex-shrink: 0; }
body.ui-msgr .tg-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); font: inherit; font-size: 14.5px; }
body.ui-msgr .tg-search.on { box-shadow: 0 0 0 2px var(--accent) inset; }
body.ui-msgr .tg-search .icon-btn { width: 28px; height: 28px; }

body.ui-msgr .tg-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; cursor: pointer; user-select: none; }
body.ui-msgr .tg-row:hover { background: var(--bg3); }
body.ui-msgr .tg-row.active { background: var(--accent); color: #fff; }
body.ui-msgr .tg-row .avatar.lg { width: 54px; height: 54px; font-size: 20px; flex-shrink: 0; }
body.ui-msgr .tg-row .srv-av { border-radius: 16px !important; }
body.ui-msgr .tg-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
body.ui-msgr .tg-top, body.ui-msgr .tg-bot { display: flex; align-items: center; gap: 8px; min-width: 0; }
body.ui-msgr .tg-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; display: flex; align-items: center; gap: 4px; }
body.ui-msgr .tg-kind { width: 16px; height: 16px; flex-shrink: 0; }
body.ui-msgr .tg-time { font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
body.ui-msgr .tg-prev { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--muted); }
body.ui-msgr .tg-who { color: var(--accent); }
body.ui-msgr .tg-badge { flex-shrink: 0; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: #fff; font: 600 12.5px/22px inherit; text-align: center; font-style: normal; }
body.ui-msgr .tg-badge.muted { background: var(--faint); }
body.ui-msgr .tg-badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; }
body.ui-msgr .tg-pin { width: 15px; height: 15px; color: var(--faint); }
body.ui-msgr .tg-row.active .tg-time, body.ui-msgr .tg-row.active .tg-prev, body.ui-msgr .tg-row.active .tg-who, body.ui-msgr .tg-row.active .draft-mark { color: rgba(255,255,255,.85); }
body.ui-msgr .tg-row.active .tg-badge { background: #fff; color: var(--accent); }
body.ui-msgr .tg-sec { padding: 10px 14px 6px; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--bg); }
body.ui-msgr .tg-freq { display: flex; gap: 4px; padding: 8px 8px 10px; overflow-x: auto; }
body.ui-msgr .tg-freq button { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 66px; border: 0; background: none; color: var(--text); font: 12px inherit; cursor: pointer; padding: 4px 0; border-radius: 6px; }
body.ui-msgr .tg-freq button:hover { background: var(--bg3); }
body.ui-msgr .tg-freq span { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ui-msgr .tg-empty { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 14px; }
body.ui-msgr .tg-placeholder { flex: 1; display: grid; place-items: center; height: 100%; }
body.ui-msgr .tg-placeholder span { padding: 5px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg4) 70%, transparent); font-size: 14px; font-weight: 600; }
body.ui-msgr .tg-srvh { display: flex; flex-direction: column; line-height: 1.25; cursor: pointer; min-width: 0; }
body.ui-msgr .tg-srvh small { color: var(--muted); font-size: 13px; }
body.ui-msgr .tg-in-srv .side-item { min-height: 0; padding: 10px 14px; border-radius: 0; }
body.ui-msgr .tg-in-srv .side-item .name { font-size: 15px; }

/* боковое меню */
#tg-drawer { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.5); animation: tg-fade .2s ease; }
#tg-drawer.closing { animation: tg-fade .2s ease reverse forwards; }
#tg-drawer.closing .tg-dr { animation: tg-slide .2s ease reverse forwards; }
.tg-dr { position: absolute; inset: 0 auto 0 0; width: 280px; background: var(--bg2); display: flex; flex-direction: column; animation: tg-slide .22s cubic-bezier(.2,.8,.2,1); box-shadow: 4px 0 20px rgba(0,0,0,.35); }
.tg-dr-head { padding: 20px 22px 14px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--border); }
.tg-dr-head .avatar.xl { width: 58px; height: 58px; font-size: 22px; margin-bottom: 8px; }
.tg-link { border: 0; background: none; color: var(--accent); padding: 0; text-align: left; font: inherit; font-size: 13.5px; cursor: pointer; }
.tg-dr-list { padding: 6px 0; display: flex; flex-direction: column; overflow-y: auto; }
.tg-dr-list hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.tg-dr-list button, .tg-night { display: flex; align-items: center; gap: 22px; padding: 11px 24px; border: 0; background: none; color: var(--text); font: inherit; font-size: 14.5px; font-weight: 500; text-align: left; cursor: pointer; }
.tg-dr-list button:hover, .tg-night:hover { background: var(--bg3); }
.tg-dr-list svg { width: 22px; height: 22px; color: var(--muted); flex-shrink: 0; }
.tg-dr-list span { flex: 1; }
.tg-dr-foot { margin-top: auto; padding: 16px 24px; font-size: 13px; color: var(--muted); }
.tg-dr-foot span { font-size: 12px; color: var(--faint); }
@keyframes tg-fade { from { opacity: 0; } }
@keyframes tg-slide { from { transform: translateX(-100%); } }

/* окна профиля и настроек */
.tg-modal .modal { width: min(400px, 100%); padding: 0; overflow: hidden; border-radius: 10px; max-height: 90vh; overflow-y: auto; }
.tg-prof-top { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 20px 18px; background: var(--bg3); }
.tg-prof-top .avatar.xl, .tg-set-me .avatar.xl { width: 84px; height: 84px; font-size: 30px; margin-bottom: 8px; }
.tg-prof-top b { font-size: 17px; }
.tg-prof-top small { color: var(--muted); }
.tg-prof-top small.on, .tg-set-me small.on { color: var(--accent); }
.tg-x { position: absolute; top: 12px; right: 12px; }
.tg-edit { position: absolute; top: 12px; right: 52px; }
.tg-prof-status { padding: 10px 20px; text-align: center; font-size: 14px; border-bottom: 1px solid var(--border); }
.tg-prof-list { padding: 8px 0; }
.tg-prof-list > div { display: flex; flex-direction: column; padding: 9px 22px; }
.tg-prof-list span { font-size: 14.5px; word-break: break-word; }
.tg-prof-list small { font-size: 13px; color: var(--muted); }
.tg-acc { color: var(--accent); }
.tg-prof-acts { display: flex; gap: 8px; padding: 6px 20px 20px; }
.tg-prof-acts .btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 6px; }
.tg-prof-acts svg { width: 17px; height: 17px; }
.tg-set-h { display: flex; align-items: center; padding: 16px 16px 12px 22px; }
.tg-set-h b { flex: 1; font-size: 17px; }
.tg-set-me { display: flex; align-items: center; gap: 16px; padding: 6px 22px 18px; cursor: pointer; border-bottom: 8px solid var(--bg); }
.tg-set-me .avatar.xl { width: 72px; height: 72px; margin: 0; }
.tg-set-me div { display: flex; flex-direction: column; }
.tg-set-me b { font-size: 16px; }
.tg-set-me small { color: var(--muted); font-size: 13.5px; }
.tg-set-list { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 8px solid var(--bg); }
.tg-set-list:last-child { border-bottom: 0; }
.tg-set-list button { display: flex; align-items: center; gap: 22px; padding: 11px 22px; border: 0; background: none; color: var(--text); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer; }
.tg-set-list button:hover { background: var(--bg3); }
.tg-set-list svg { width: 21px; height: 21px; color: var(--muted); }
.tg-set-list .danger, .tg-set-list .danger svg { color: var(--danger); }

@media (max-width: 640px) {
  body.ui-msgr #sidebar.tg-side { width: auto !important; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; }
  body.ui-msgr #tg-folders { grid-row: 2 !important; grid-column: 1; flex-direction: row; padding: 0 6px; overflow-x: auto; background: var(--bg2); border-bottom: 1px solid var(--border); }
  body.ui-msgr .tg-folder { flex-direction: row; gap: 6px; padding: 10px 12px; white-space: nowrap; }
  body.ui-msgr .tg-folder svg { width: 18px; height: 18px; }
  body.ui-msgr .tg-folder.sel { background: none; }
  body.ui-msgr .tg-folder.sel::before { left: 8px; right: 8px; top: auto; bottom: 0; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  body.ui-msgr .tg-fbadge { position: static; border: 0; }
  body.ui-msgr .tg-burger { order: -1; width: 44px; height: 44px; }
  body.ui-msgr .tg-side .side-head, body.ui-msgr .tg-side .side-list, body.ui-msgr .tg-side #voicebar { grid-column: 1; }
  body.ui-msgr .tg-side .side-head { grid-row: 1; }
  body.ui-msgr .tg-side .side-list { grid-row: 3; }
}
/* окна трансляций и всплывающие окна — поверх звонка на весь экран */
body.ui-msgr #pip { z-index: 95; }
body.ui-msgr .popout { z-index: 150; }
/* частые контакты в поиске */
body.ui-msgr .tg-freq .avatar.lg { width: 52px; height: 52px; font-size: 19px; }
/* баннер профиля сверху окна */
.tg-prof-top.has-banner { padding-top: 0; }
.tg-prof-banner { align-self: stretch; height: 120px; margin: 0 -20px -42px; background-size: cover; background-position: center; }
.tg-prof-top.has-banner .avatar.xl { box-shadow: 0 0 0 5px var(--bg3); position: relative; }
.tg-prof-top.has-banner .icon-btn { background: rgba(0,0,0,.45); color: #fff; z-index: 1; }

/* ---------- Переписка v2: все сообщения слева, свои — цветом ---------- */
body.ui-msgr .msg.mine { flex-direction: row; }
body.ui-msgr .msg.mine > div:first-child { display: block; }
body.ui-msgr.in-dm .msg > div:first-child { display: block; }
body.ui-msgr .msg { padding: 1px 16px 1px 14px; }
body.ui-msgr .msg > div:first-child .avatar { width: 40px; height: 40px; }
body.ui-msgr .msg.cont > div:first-child .avatar { width: 40px; }
body.ui-msgr .msg .body { max-width: min(620px, 78%); padding: 6px 10px 6px 12px; }
body.ui-msgr .msg.mine .body { background: color-mix(in srgb, var(--accent) 78%, #1a2a40); }
body.ui-msgr .msg.mine .actions { left: 70px; right: auto; }
body.ui-msgr .msg .msgr-time { font-size: 11.5px; margin: 8px 0 -3px 14px; }
body.ui-msgr .msg .reply { background: color-mix(in srgb, var(--accent) 16%, transparent); border-left: 3px solid var(--accent); border-radius: 4px; padding: 4px 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
body.ui-msgr .msg .reply b { color: var(--accent); }
body.ui-msgr .msg.mine .reply { background: rgba(255,255,255,.12); border-left-color: #fff; }
body.ui-msgr .msg.mine .reply b { color: #fff; }
/* дата — плашкой по центру */
body.ui-msgr .day-sep { width: fit-content; margin: 14px auto 8px; padding: 5px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg4) 75%, transparent); font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.2; }
body.ui-msgr .day-sep::before, body.ui-msgr .day-sep::after { content: none; display: none; }
/* строка ввода — плоская, на всю ширину */
body.ui-msgr .composer { padding: 0; border-top: 1px solid var(--border); background: var(--bg2); }
body.ui-msgr .composer .inner { border-radius: 0; background: transparent; min-height: 52px; padding: 2px 10px; box-shadow: none; border: 0; }
body.ui-msgr .composer textarea { font-size: 15px; }
body.ui-msgr .composer .replybar { padding: 8px 16px; gap: 10px; border-left: 0; background: var(--bg2); }
body.ui-msgr .composer .replybar svg { color: var(--accent); width: 22px; height: 22px; }
body.ui-msgr .composer .replybar b { color: var(--accent); }
body.ui-msgr #typing { padding: 0 16px; }
body.ui-msgr .replybar .rb-text { display: block; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replybar .rb-text { display: none; }
body.ui-msgr .replybar .rb-col { display: flex; flex-direction: column; min-width: 0; flex: 1; }
