/* ============================================================ тема */
:root {
  --accent: #3d8bff;
  --accent-2: #5f5cff;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --font-scale: 1;
  --radius: 14px;
  --radius-lg: 20px;
  --success: #34d399;
  --danger: #ff5d6c;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 360px;
  --info-w: 340px;
}

[data-theme="dark"] {
  --bg: #0b0e15;
  --panel: #11151f;
  --panel-2: #151a26;
  --surface: #1a2030;
  --surface-2: #222a3d;
  --hover: rgba(255, 255, 255, .045);
  --active: rgba(255, 255, 255, .07);
  --border: rgba(255, 255, 255, .07);
  --text: #eef1f8;
  --text-2: #a2aabd;
  --text-3: #6c7589;
  --bubble-in: #1c2333;
  --chat-bg: #0d1119;
  --chat-dot: rgba(255, 255, 255, .035);
  --shadow: 0 14px 44px rgba(0, 0, 0, .5);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, .3);
  --glass: rgba(20, 25, 37, .78);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-2: #fbfcfe;
  --surface: #f1f3f8;
  --surface-2: #e5e9f1;
  --hover: rgba(15, 23, 42, .045);
  --active: rgba(15, 23, 42, .075);
  --border: rgba(15, 23, 42, .08);
  --text: #101626;
  --text-2: #586174;
  --text-3: #8b94a6;
  --bubble-in: #ffffff;
  --chat-bg: #e7ebf3;
  --chat-dot: rgba(15, 23, 42, .05);
  --shadow: 0 14px 44px rgba(30, 41, 59, .18);
  --shadow-sm: 0 4px 14px rgba(30, 41, 59, .1);
  --glass: rgba(255, 255, 255, .82);
  color-scheme: light;
}

/* ============================================================ основа */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: calc(14.5px * var(--font-scale));
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#app { height: 100%; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: .5; }
input, textarea, select { user-select: text; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*:hover::-webkit-scrollbar-thumb { background-color: color-mix(in srgb, var(--text-3) 45%, transparent); }
::-webkit-scrollbar-track { background: transparent; }

.icon { flex-shrink: 0; display: block; }
.muted { color: var(--text-2); }
.sm { font-size: .88em; }
.mt { margin-top: 18px; }

.splash { height: 100%; display: grid; place-items: center; color: var(--accent); }

.spinner { animation: spin 1s linear infinite; }
.spinner circle { stroke: currentColor; stroke-linecap: round; stroke-dasharray: 90 150; animation: dash 1.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dash { 0% { stroke-dasharray: 1 150; stroke-dashoffset: 0; } 50% { stroke-dasharray: 90 150; stroke-dashoffset: -35; } 100% { stroke-dasharray: 90 150; stroke-dashoffset: -124; } }

/* ============================================================ кнопки и поля */
.icon-btn {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 12px;
  display: inline-grid; place-items: center;
  color: var(--text-2);
  transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.xs { width: 24px; height: 24px; border-radius: 8px; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.glass { background: rgba(255, 255, 255, .1); color: #fff; backdrop-filter: blur(12px); }
.icon-btn.glass:hover { background: rgba(255, 255, 255, .2); }

.btn {
  height: 42px; padding: 0 20px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600;
  transition: filter .15s, transform .1s, background .15s, box-shadow .2s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: var(--surface); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.big { height: 50px; font-size: 1.05em; border-radius: 14px; width: 100%; }
.btn.sm { height: 34px; padding: 0 14px; font-size: .9em; border-radius: 10px; }

.link-btn { color: var(--text-2); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.link-btn:hover:not(:disabled) { color: var(--text); }
.link-btn.accent { color: var(--accent); font-weight: 600; }
.link-btn.danger { color: var(--danger); }

.toggle {
  width: 44px; height: 26px; border-radius: 20px;
  background: var(--surface-2); position: relative; flex-shrink: 0;
  transition: background .2s;
}
.toggle i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .25s var(--ease); }
.toggle.on { background: var(--grad); }
.toggle.on i { transform: translateX(18px); }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 6px; background: var(--surface-2); flex: 1; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: pointer; }

.badge {
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 11px;
  background: var(--grad); color: #fff;
  font-size: .78em; font-weight: 700;
  display: inline-grid; place-items: center;
}
.badge.muted { background: var(--text-3); }

/* ============================================================ аватар */
.avatar {
  position: relative; flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 600; letter-spacing: .02em;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.online-dot {
  position: absolute; right: 1px; bottom: 1px;
  width: 26%; height: 26%; min-width: 11px; min-height: 11px; max-width: 15px; max-height: 15px;
  border-radius: 50%; background: var(--success);
  border: 2.5px solid var(--panel);
}

/* ============================================================ авторизация */
.auth { height: 100%; display: grid; place-items: center; position: relative; overflow: hidden; background: var(--bg); }
.auth-bg { position: absolute; inset: 0; filter: blur(80px); opacity: .55; }
.blob { position: absolute; border-radius: 50%; animation: float 18s ease-in-out infinite; }
.blob.b1 { width: 520px; height: 520px; background: var(--accent); top: -140px; left: -120px; }
.blob.b2 { width: 460px; height: 460px; background: var(--accent-2); bottom: -160px; right: -80px; animation-delay: -6s; }
.blob.b3 { width: 320px; height: 320px; background: #22d3ee; top: 40%; left: 55%; opacity: .5; animation-delay: -12s; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(60px, 40px) scale(1.08); } 66% { transform: translate(-40px, 30px) scale(.95); } }

.auth-card {
  position: relative; z-index: 1;
  width: 420px; max-width: calc(100% - 32px);
  padding: 36px 36px 26px;
  border-radius: 26px;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: rise .5s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.brand { display: flex; align-items: center; gap: 12px; font-size: 1.45em; font-weight: 800; letter-spacing: -.02em; margin-bottom: 26px; }
.brand-logo { width: 46px; height: 46px; border-radius: 14px; box-shadow: 0 8px 24px rgba(61, 139, 255, .45); }
.auth-download {
  position: absolute; left: 50%; bottom: 46px; z-index: 1; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: .92em;
  backdrop-filter: blur(10px); transition: border-color .15s, color .15s;
}
.auth-download:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.auth-version { position: absolute; left: 0; right: 0; bottom: 18px; z-index: 1; text-align: center; font-size: .78em; color: var(--text-3); letter-spacing: .03em; }
.link-btn.forgot { align-self: flex-end; margin: -4px 4px 2px 0; font-size: .88em; }
.auth-back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); margin-bottom: 10px; font-weight: 500; }
.auth-back:hover { color: var(--text); }
.auth-card h1 { margin: 0 0 6px; font-size: 1.7em; letter-spacing: -.025em; }
.auth-card > p { margin: 0 0 22px; line-height: 1.5; }

.auth-form { display: flex; flex-direction: column; gap: 12px; animation: fadein .3s; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }

.field {
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 8px 0 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px solid transparent;
  color: var(--text-3);
  transition: border-color .15s, background .15s;
}
.field:focus-within { border-color: var(--accent); background: var(--panel); color: var(--accent); }
.field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); }
.field input::placeholder { color: var(--text-3); }
/* браузер красит сохранённые логин/пароль своим светлым фоном — возвращаем цвета поля */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text); caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset; box-shadow: 0 0 0 1000px var(--surface) inset;
  transition: background-color 600000s 0s;
}
.field:focus-within input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px var(--panel) inset; box-shadow: 0 0 0 1000px var(--panel) inset; }

.code-input { display: flex; gap: 8px; justify-content: space-between; margin: 4px 0; }
.code-input input {
  flex: 1; min-width: 0; width: 0; height: 60px; text-align: center;
  font-size: 1.6em; font-weight: 700;
  border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface); outline: 0;
  transition: border-color .15s, transform .15s;
}
.code-input input:focus { border-color: var(--accent); transform: translateY(-2px); }
.code-input input.filled { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.resend { align-self: center; font-size: .9em; }

.form-error, .form-info { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; font-size: .92em; }
.form-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.form-info { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }
.form-error.sm { padding: 6px 10px; margin-top: 8px; }

.auth-links { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 18px; font-size: .93em; color: var(--text-2); }
.server-box { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: .85em; }
.server-box .link-btn { color: var(--text-3); }
.server-edit { display: flex; gap: 8px; margin-top: 10px; }
.server-edit input { flex: 1; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); outline: 0; }
.server-edit input:focus { border-color: var(--accent); }

/* ============================================================ раскладка */
.app { display: flex; height: 100%; position: relative; }
.main { flex: 1; min-width: 0; display: flex; position: relative; }

/* ============================================================ боковая панель */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.sb-resizer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 7px; z-index: 8;
  cursor: col-resize; touch-action: none;
}
.sb-resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 2px;
  background: var(--accent); opacity: 0; transition: opacity .15s;
}
.sb-resizer:hover::after, .sb-resizer.active::after { opacity: .8; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }
.sb-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; }
.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  height: 42px; padding: 0 8px 0 14px;
  border-radius: 21px;
  background: var(--surface);
  color: var(--text-3);
  border: 1.5px solid transparent;
  transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: var(--accent); background: var(--panel); color: var(--accent); }
.search input { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: none; color: var(--text); }
.search input::placeholder { color: var(--text-3); }

.pt-hint { display: block; margin-top: 6px; color: var(--text-3); font-size: .8em; }
.btn.saved:disabled { opacity: 1; color: var(--success); }

/* «потянуть вниз — обновить» над списком чатов */
.ptr { flex: none; height: 0; overflow: hidden; display: grid; place-items: center; color: var(--text-3); transition: height .2s var(--ease); }
.ptr .icon { transition: transform .2s; }
.ptr.pulling { transition: none; }
.ptr.ready { color: var(--accent); }
.ptr.ready .icon { transform: rotate(180deg); }

/* веб-версия на телефоне: предложение добавить на экран «Домой» */
.sb-install {
  flex: none; display: flex; align-items: center; gap: 10px;
  margin: 6px 10px 10px; padding: 10px 8px 10px 10px; border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.sb-install img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.sbi-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sbi-text small { color: var(--text-2); font-size: .82em; }
.ios-guide-layer { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px 70px; }
.ios-guide {
  position: relative; width: min(380px, 100%); padding: 22px 20px 20px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); text-align: center;
}
.ios-guide img { width: 60px; height: 60px; border-radius: 14px; }
.ios-guide h3 { margin: 10px 0 12px; font-size: 1.1em; }
.ios-guide ol { text-align: left; margin: 0 0 16px; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; color: var(--text-2); }
.ios-guide ol b { color: var(--text); }
.ios-guide ol svg { vertical-align: -4px; color: var(--accent); margin: 0 2px; }
.ios-guide .btn { width: 100%; }
.ios-guide-arrow { position: absolute; left: 50%; bottom: -46px; width: 0; height: 0; transform: translateX(-50%);
  border: 14px solid transparent; border-top: 22px solid var(--accent); animation: guide-bounce 1.2s ease-in-out infinite; }
@keyframes guide-bounce { 50% { transform: translate(-50%, 8px); } }

/* как в Telegram: кнопка обновления внизу списка чатов, только когда есть новая версия */
.sb-update {
  position: relative; overflow: hidden; flex: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 6px 12px 12px; height: 44px; border-radius: 14px;
  background: var(--grad); color: #fff; font-weight: 600;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: filter .15s, transform .15s;
}
.sb-update:hover:not(:disabled) { filter: brightness(1.08); }
.sb-update:active:not(:disabled) { transform: scale(.98); }
.sb-update:disabled { opacity: .85; cursor: default; }
.sb-update > :not(.sb-update-fill) { position: relative; }
.sb-update-fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.2); transition: width .2s; }
.conn-banner { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 12px 8px; padding: 7px; border-radius: 10px; font-size: .85em; color: var(--text-2); background: var(--surface); }

.chat-list { flex: 1; overflow-y: auto; padding: 2px 8px 12px; }
.list-label { display: flex; align-items: center; gap: 8px; padding: 12px 10px 6px; font-size: .8em; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.list-empty { padding: 24px 16px; color: var(--text-3); text-align: center; line-height: 1.5; font-size: .92em; }

.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 14px;
  cursor: pointer;
  transition: background .12s;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--grad); color: #fff; }
.chat-item.active .online-dot { border-color: var(--accent); }
.ci-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ci-top, .ci-bottom { display: flex; align-items: center; gap: 6px; }
.ci-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: .8em; color: var(--text-3); }
.ci-checks { color: var(--accent); }
.ci-muted { color: var(--text-3); }
.ci-preview { flex: 1; min-width: 0; color: var(--text-2); font-size: .93em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-preview .you { color: var(--text); }
.ci-preview.typing { color: var(--accent); }
.chat-item.active .ci-time, .chat-item.active .ci-preview, .chat-item.active .ci-preview .you, .chat-item.active .ci-checks, .chat-item.active .ci-muted, .chat-item.active .ci-preview.typing { color: rgba(255,255,255,.85); }
.chat-item.active .badge { background: #fff; color: var(--accent); }

.dots { display: inline-flex; gap: 2px; margin-left: 3px; vertical-align: middle; }
.dots b { width: 3.5px; height: 3.5px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.dots b:nth-child(2) { animation-delay: .2s; }
.dots b:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.sb-empty { text-align: center; padding: 48px 26px; color: var(--text-2); }
.sb-empty-icon { width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 24px; display: grid; place-items: center; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sb-empty h4 { margin: 0 0 8px; color: var(--text); font-size: 1.1em; }
.sb-empty p { margin: 0 0 18px; line-height: 1.5; font-size: .93em; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
.drawer-close { position: absolute; top: 12px; right: 12px; z-index: 1; }
.drawer {
  position: absolute; top: 0; left: 0; bottom: 0; width: min(300px, 100%); z-index: 36;
  background: var(--panel-2); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.drawer-head { padding: 26px 22px 20px; cursor: pointer; background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 22%, transparent), transparent); }
.dh-name { margin-top: 14px; font-weight: 700; font-size: 1.1em; }
.dh-sub { color: var(--text-2); font-size: .9em; margin-top: 2px; }
.drawer-items { padding: 8px; display: flex; flex-direction: column; flex: 1; }
.drawer-items button, .drawer-items .drawer-link { display: flex; align-items: center; gap: 16px; height: 46px; padding: 0 14px; border-radius: 12px; font-weight: 500; color: var(--text); text-align: left; }
.drawer-items button .icon, .drawer-link .icon { color: var(--text-2); }
.drawer-items button:hover, .drawer-link:hover { background: var(--hover); text-decoration: none; }
.drawer-items button.danger, .drawer-items button.danger .icon { color: var(--danger); }
.drawer-items .sep { height: 1px; background: var(--border); margin: 8px 6px; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 16px 22px; color: var(--text-3); font-size: .8em; }
.drawer-foot img { width: 18px; height: 18px; border-radius: 5px; }
.drawer-items button.update-item { height: auto; min-height: 46px; padding-top: 6px; padding-bottom: 6px; position: relative; }
.drawer-items button.update-item:disabled { opacity: .6; cursor: default; }
.drawer-items button.update-item:disabled:hover { background: none; }
.drawer-items button.update-item.ready .icon { color: var(--accent); }
.ui-text { display: flex; flex-direction: column; gap: 1px; }
.ui-text small { font-size: .78em; color: var(--text-3); font-weight: 400; }
.update-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px var(--panel); }
.drawer-items .update-dot { right: 14px; top: 50%; margin-top: -4px; }
.menu-btn { position: relative; }
.menu-btn .update-dot { top: 7px; right: 7px; }
.icon.spinning { animation: spin 1s linear infinite; }

/* ============================================================ чат */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.chat::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 40%),
    radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--accent-2) 9%, transparent), transparent 45%),
    radial-gradient(var(--chat-dot) 1.2px, transparent 1.2px);
  background-size: auto, auto, 22px 22px;
}

.chat-head {
  position: relative; z-index: 2;
  height: 64px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 18px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.ch-peer { display: flex; align-items: center; gap: 12px; cursor: pointer; min-width: 0; }
.ch-text { min-width: 0; }
.ch-name { font-weight: 650; font-size: 1.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-status { font-size: .86em; color: var(--text-3); margin-top: 2px; }
.ch-status.online, .ch-status.typing { color: var(--accent); }
.ch-actions { display: flex; gap: 2px; }

.messages { flex: 1; overflow-y: auto; position: relative; z-index: 1; user-select: text; container-type: inline-size; }
.messages-inner { width: 100%; padding: 14px 24px 10px; min-height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.history-loader { display: flex; justify-content: center; padding: 10px; color: var(--accent); }

.day-chip { display: flex; justify-content: center; margin: 14px 0 10px; position: sticky; top: 8px; z-index: 3; pointer-events: none; }
.day-chip span { padding: 5px 13px; border-radius: 14px; font-size: .82em; font-weight: 600; color: var(--text); background: var(--glass); backdrop-filter: blur(12px); box-shadow: var(--shadow-sm); }

.chat-hello { flex: 1; display: grid; place-items: center; }
.hello-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 34px; border-radius: 22px; background: var(--glass); backdrop-filter: blur(12px); text-align: center; max-width: 300px; }
.hello-card span { color: var(--text-2); font-size: .92em; line-height: 1.45; }
.hello-emoji { font-size: 44px; animation: wave 2s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } }

.empty-chat { align-items: center; justify-content: center; }
.empty-inner { position: relative; z-index: 1; text-align: center; max-width: 320px; color: var(--text-2); }
.empty-orb { display: block; width: 110px; height: 110px; border-radius: 30px; margin: 0 auto 22px; box-shadow: 0 20px 50px rgba(61, 139, 255, .4); animation: bob 5s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }
.empty-inner h3 { color: var(--text); margin: 0 0 8px; font-size: 1.3em; }
.empty-inner p { margin: 0; line-height: 1.55; }

/* ---------- сообщения */
.msg-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 2px; animation: msgin .25s var(--ease); }
.msg-row.first { margin-top: 8px; }
.msg-row.mine { flex-direction: row-reverse; }
@keyframes msgin { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.msg-row.flash .bubble { animation: flash 1.5s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }

.bubble {
  position: relative;
  max-width: min(560px, 76%);
  padding: 5px 10px 5px 11px;
  border-radius: 18px;
  background: var(--bubble-in);
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  line-height: 1.36;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg-row:not(.mine) .bubble { border-bottom-left-radius: 6px; border-top-left-radius: 6px; }
.msg-row:not(.mine).first .bubble { border-top-left-radius: 18px; }
.msg-row:not(.mine).last .bubble { border-bottom-left-radius: 4px; }
.msg-row.mine .bubble { background: var(--grad); color: #fff; border-bottom-right-radius: 6px; border-top-right-radius: 6px; }
.msg-row.mine.first .bubble { border-top-right-radius: 18px; }
.msg-row.mine.last .bubble { border-bottom-right-radius: 4px; }
.msg-row.mine .bubble a { color: #fff; text-decoration: underline; }

/* мои сообщения слева, собеседника справа */
.mine-left .msg-row.mine { flex-direction: row; }
.mine-left .msg-row:not(.mine) { flex-direction: row-reverse; }
.mine-left .msg-row.mine .bubble { border-radius: 6px 18px 18px 6px; }
.mine-left .msg-row.mine.first .bubble { border-top-left-radius: 18px; }
.mine-left .msg-row.mine.last .bubble { border-bottom-left-radius: 4px; }
.mine-left .msg-row:not(.mine) .bubble { border-radius: 18px 6px 6px 18px; }
.mine-left .msg-row:not(.mine).first .bubble { border-top-right-radius: 18px; }
.mine-left .msg-row:not(.mine).last .bubble { border-bottom-right-radius: 4px; }
.mine-left .msg-row.mine.emoji .meta { float: left; }

/* широкое окно: все сообщения у левого края, как в Telegram Desktop */
@container (min-width: 1000px) {
  .messages .msg-row.mine, .messages .msg-row:not(.mine) { flex-direction: row; }
  .messages .msg-row.mine .bubble, .messages .msg-row:not(.mine) .bubble { border-radius: 6px 18px 18px 6px; }
  .messages .msg-row.mine.first .bubble, .messages .msg-row:not(.mine).first .bubble { border-top-left-radius: 18px; border-top-right-radius: 18px; }
  .messages .msg-row.mine.last .bubble, .messages .msg-row:not(.mine).last .bubble { border-bottom-left-radius: 4px; border-bottom-right-radius: 18px; }
  .messages .msg-row.emoji .meta { float: left; }
}
.bubble.failed { opacity: .7; }

.msg-row.emoji .bubble { background: none !important; box-shadow: none; padding: 0 4px; }
.msg-row.emoji .text { font-size: 2.6em; line-height: 1.15; }
.msg-row.emoji .meta { position: static; display: inline-flex; padding: 2px 8px; border-radius: 10px; background: var(--glass); color: var(--text-2) !important; margin-top: 2px; float: right; }

.text { white-space: normal; }
.meta-spacer { display: inline-block; width: 46px; height: 1px; }
.meta-spacer.wide { width: 64px; }
.meta {
  position: absolute; right: 9px; bottom: 4px;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .72em; color: var(--text-3);
  white-space: nowrap; user-select: none;
}
.msg-row.mine .meta { color: rgba(255,255,255,.78); }
.edited { margin-right: 3px; font-style: italic; }
.fail-icon { color: #ffd2d6; }
.retry-btn { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--danger); background: var(--surface); }

.reply-quote {
  display: flex; flex-direction: column;
  margin: 2px 0 6px; padding: 5px 10px;
  border-left: 3px solid var(--accent);
  border-radius: 6px 10px 10px 6px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-size: .9em; cursor: pointer; min-width: 120px;
}
.reply-quote b { color: var(--accent); font-weight: 600; }
.reply-quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; max-width: 380px; }
.msg-row.mine .reply-quote { border-left-color: #fff; background: rgba(255,255,255,.16); }
.msg-row.mine .reply-quote b { color: #fff; }

/* выделение на фоне акцентного пузыря иначе сливается с ним */
.msg-row.mine .bubble ::selection { background: rgba(255,255,255,.42); color: #fff; }

.fwd-from { display: flex; align-items: center; gap: 5px; margin: 1px 0 3px; font-size: .84em; color: var(--accent); }
.fwd-from b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row.mine .fwd-from { color: rgba(255,255,255,.88); }
.t-image .fwd-from, .t-video .fwd-from { padding: 4px 8px 2px; }

.fwd-search { flex: none; margin-bottom: 10px; }
.fwd-list { display: flex; flex-direction: column; gap: 2px; max-height: min(420px, 60vh); overflow-y: auto; margin: 0 -8px; }
.fwd-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; text-align: left; transition: background .12s; }
.fwd-item:hover:not(:disabled) { background: var(--hover); }
.fwd-item:disabled { opacity: 1; }
.fwd-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 600; }
.fwd-name small { font-weight: 400; color: var(--text-3); font-size: .85em; }

/* медиа */
.t-image, .t-video { padding: 4px; }
.t-image .text, .t-video .text { padding: 6px 8px 2px; }
.media-only .bubble { padding: 0; background: none !important; box-shadow: none; }
.media { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface); max-width: 100%; }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.media video { cursor: default; background: #000; object-fit: contain; }
.media-progress { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); color: #fff; cursor: pointer; }
.media-progress > * { grid-area: 1 / 1; }
.meta.overlay { right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 10px; background: rgba(0,0,0,.45); color: #fff !important; backdrop-filter: blur(6px); }

.progress-ring { transform: rotate(-90deg); }
.progress-ring .track { stroke: rgba(255,255,255,.25); }
.progress-ring .bar { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset .2s; }

/* файлы */
.file { display: flex; align-items: center; gap: 10px; padding: 2px 2px 12px 0; min-width: 210px; }
.file-icon {
  position: relative; width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 14px; display: grid; place-items: center;
  background: var(--grad); color: #fff;
}
.file-icon > * { grid-area: 1 / 1; }
.file-icon .ext { font-size: .72em; font-weight: 800; letter-spacing: .03em; transition: opacity .15s; }
.file-icon .dl { opacity: 0; transition: opacity .15s; }
.file-icon:not(.static):hover .ext { opacity: 0; }
.file-icon:not(.static):hover .dl { opacity: 1; }
.msg-row.mine .file-icon { background: rgba(255,255,255,.2); }
.file-info { min-width: 0; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.file-size { font-size: .84em; color: var(--text-3); margin-top: 2px; }
.msg-row.mine .file-size { color: rgba(255,255,255,.75); }

/* голосовые */
.voice { display: flex; align-items: center; gap: 9px; padding: 1px 4px 12px 0; min-width: 240px; }
.voice-btn {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  transition: transform .12s;
}
.voice-btn > * { grid-area: 1 / 1; }
.voice-btn:active { transform: scale(.93); }
.msg-row.mine .voice-btn { background: #fff; color: var(--accent); }
.msg-row.mine .voice-btn .progress-ring .bar { stroke: var(--accent); }
.msg-row.mine .voice-btn .progress-ring .track { stroke: color-mix(in srgb, var(--accent) 25%, transparent); }
.voice-body { flex: 1; min-width: 0; }
.wave { height: 24px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.wave i { flex: 1; min-width: 2px; max-width: 3px; border-radius: 3px; background: color-mix(in srgb, var(--text-3) 55%, transparent); transition: background .1s; }
.wave i.on { background: var(--accent); }
.msg-row.mine .wave i { background: rgba(255,255,255,.4); }
.msg-row.mine .wave i.on { background: #fff; }
.voice-meta { display: flex; align-items: center; gap: 8px; font-size: .78em; color: var(--text-3); margin-top: 2px; }
.msg-row.mine .voice-meta { color: rgba(255,255,255,.8); }
.rate { padding: 1px 6px; border-radius: 6px; font-size: .95em; font-weight: 700; background: color-mix(in srgb, currentColor 18%, transparent); }

/* аудиофайлы */
.audio-file { display: flex; align-items: center; gap: 10px; padding: 1px 4px 12px 0; min-width: 260px; }
.af-body { flex: 1; min-width: 0; }
.af-title { display: flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.af-title .icon { flex-shrink: 0; opacity: .7; }
.af-bar { position: relative; height: 4px; margin: 9px 0 6px; border-radius: 4px; cursor: pointer; background: color-mix(in srgb, var(--text-3) 40%, transparent); }
.af-bar::before { content: ""; position: absolute; inset: -6px 0; }
.af-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.msg-row.mine .af-bar { background: rgba(255,255,255,.35); }
.msg-row.mine .af-bar i { background: #fff; }
.msg-row.mine .audio-file .voice-btn { background: #fff; color: var(--accent); }

/* быстрые действия возле сообщения */
.msg-side-btn {
  align-self: center; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--glass); color: var(--text-2); backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  opacity: 0; transform: scale(.85);
  transition: opacity .15s, transform .15s, color .15s;
}
.msg-row:hover .msg-side-btn { opacity: 1; transform: scale(1); }
.msg-side-btn:hover { color: var(--accent); }

.media-expand {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(0,0,0,.5); color: #fff; backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .15s;
}
.media:hover .media-expand { opacity: 1; }
.media-ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; text-align: center; cursor: pointer;
  background:
    radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 60%),
    radial-gradient(circle at 75% 75%, color-mix(in srgb, var(--accent-2) 30%, transparent), transparent 60%),
    var(--surface-2);
  color: #fff;
}
.media-ph small { font-size: .8em; opacity: .9; max-width: 240px; line-height: 1.4; text-shadow: 0 1px 4px rgba(0,0,0,.35); }
.ph-btn { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.35); backdrop-filter: blur(8px); transition: transform .15s; }
.media-ph:hover .ph-btn { transform: scale(1.06); }
.media-ph.wait { cursor: default; }
.ph-ring { position: relative; display: grid; place-items: center; }
.ph-ring > * { grid-area: 1 / 1; }
.ph-ring span { font-size: .8em; font-weight: 700; }
.p2p-wait { display: inline-flex; align-items: center; gap: 3px; opacity: .85; }
.mg-play.wait { color: var(--text-3); }
.t-video .meta.overlay { top: 8px; left: 8px; right: auto; bottom: auto; }

/* звонки в истории */
.call-msg { display: flex; align-items: center; gap: 10px; padding: 1px 0; min-width: 220px; }
.call-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.call-icon.missed { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.msg-row.mine .call-icon { background: rgba(255,255,255,.2); color: #fff; }
.call-text { flex: 1; }
.call-title { font-weight: 600; }
.call-sub { display: flex; align-items: center; gap: 4px; font-size: .82em; color: var(--text-3); margin-top: 2px; }
.msg-row.mine .call-sub { color: rgba(255,255,255,.75); }
.msg-row.mine .call-back { color: #fff; }
.msg-row.mine .call-back:hover { background: rgba(255,255,255,.15); }

.to-bottom {
  position: absolute; right: 24px; bottom: 78px; z-index: 4;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel); color: var(--text-2); box-shadow: var(--shadow-sm);
}
.to-bottom .badge { position: absolute; top: -6px; right: -4px; }

.drop-zone {
  position: absolute; inset: 70px 14px 14px; z-index: 20;
  border-radius: 24px; border: 2.5px dashed var(--accent);
  background: color-mix(in srgb, var(--panel) 85%, transparent); backdrop-filter: blur(8px);
  display: grid; place-items: center; pointer-events: none;
}
.drop-zone div { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--accent); }
.drop-zone b { font-size: 1.2em; color: var(--text); }
.drop-zone span { color: var(--text-2); }

/* ---------- поле ввода */
.composer {
  position: relative; z-index: 3; width: 100%;
  background: var(--panel); border-top: 1px solid var(--border);
}
.composer-row {
  display: flex; align-items: flex-end; gap: 2px;
  padding: 6px 10px;
}
.composer-row textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: none;
  padding: 10px 6px; max-height: 200px; line-height: 1.4;
}
.composer-row textarea::placeholder { color: var(--text-3); }
.composer-row .icon-btn { color: var(--text-3); }
.composer-row .icon-btn:hover, .composer-row .icon-btn.on { color: var(--accent); background: none; }
.send-btn {
  width: 38px; height: 38px; margin: 1px 0 1px 4px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  transition: transform .12s, filter .15s;
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn:active { transform: scale(.92); }
.send-btn.mic { background: none; color: var(--text-3); }
.send-btn.mic:hover { color: var(--accent); }

.reply-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 4px 16px;
}
.rb-icon { color: var(--accent); }
.rb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 3px solid var(--accent); padding-left: 10px; }
.rb-body b { color: var(--accent); font-size: .9em; }
.rb-body span { font-size: .9em; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.attach-wrap { position: relative; }
.attach-menu {
  position: absolute; bottom: 52px; left: 0; z-index: 10;
  min-width: 200px; padding: 6px; border-radius: 16px;
  background: var(--panel-2); box-shadow: var(--shadow); border: 1px solid var(--border);
}
.attach-menu button { width: 100%; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 10px; font-weight: 500; }
.attach-menu button:hover { background: var(--hover); }
.attach-menu .icon { color: var(--accent); }

.recording { align-items: center; padding-left: 8px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse-dot 1.2s infinite; margin-left: 4px; }
@keyframes pulse-dot { 50% { opacity: .3; transform: scale(.8); } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 44px; margin-left: 6px; }
.live-wave { flex: 1; height: 32px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; padding: 0 10px; }
.live-wave i { width: 3px; flex-shrink: 0; border-radius: 3px; background: var(--accent); transition: height .08s; }

.emoji-picker {
  position: absolute; right: 12px; bottom: calc(100% + 8px); z-index: 10;
  width: 352px; height: 340px;
  display: flex; flex-direction: column;
  border-radius: 20px; overflow: hidden;
  background: var(--panel-2); box-shadow: var(--shadow); border: 1px solid var(--border);
}
.ep-tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--border); }
.ep-tabs button { flex: 1; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; color: var(--text-2); filter: grayscale(.6); }
.ep-tabs button.on, .ep-tabs button:hover { background: var(--hover); filter: none; color: var(--accent); }
.ep-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); padding: 8px; align-content: start; }
.ep-grid button { height: 40px; font-size: 24px; border-radius: 10px; font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif; transition: transform .1s; }
.ep-grid button:hover { background: var(--hover); transform: scale(1.15); }

/* ============================================================ информация */
.info-panel {
  width: var(--info-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--border);
}
.ip-head { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 20px; border-bottom: 1px solid var(--border); font-size: 1.05em; }
.ip-scroll { flex: 1; overflow-y: auto; }
.ip-profile { display: flex; flex-direction: column; align-items: center; padding: 26px 20px 18px; text-align: center; }
.ip-profile h3 { margin: 14px 0 4px; font-size: 1.25em; }
.ip-profile > span { color: var(--text-3); font-size: .9em; }
.ip-profile > span.online { color: var(--accent); }
.ip-actions { display: flex; gap: 8px; margin-top: 18px; width: 100%; }
.ip-actions button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0 10px; border-radius: 14px; background: var(--surface); color: var(--accent); font-size: .82em; font-weight: 600; transition: background .15s; }
.ip-actions button span { color: var(--text-2); }
.ip-actions button:hover { background: var(--surface-2); }
.ip-rows { padding: 4px 10px 10px; border-bottom: 8px solid var(--bg); }
.ip-row { display: flex; align-items: center; gap: 18px; padding: 10px 12px; border-radius: 12px; cursor: pointer; color: var(--text-2); }
.ip-row:hover { background: var(--hover); }
.ip-row > div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ip-row b { color: var(--text); font-weight: 500; }
.ip-row b.bio { white-space: pre-wrap; user-select: text; }
.ip-row small { color: var(--text-3); font-size: .82em; margin-top: 2px; }
.ip-tabs { display: flex; padding: 0 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.ip-tabs button { flex: 1; padding: 14px 0 12px; font-weight: 600; color: var(--text-3); border-bottom: 2.5px solid transparent; }
.ip-tabs button.on { color: var(--accent); border-color: var(--accent); }
.ip-content { padding: 8px; }
.ip-empty, .ip-loading { padding: 40px; text-align: center; color: var(--text-3); }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.mg-item { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 6px; cursor: pointer; background: var(--surface); }
.mg-item img, .mg-item video { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.mg-item:hover img { transform: scale(1.06); }
.mg-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; }
.file-list .file { padding: 8px; border-radius: 12px; cursor: pointer; }
.file-list .file:hover { background: var(--hover); }
.voice-list .vl-item { padding: 8px 10px 4px; border-radius: 12px; }
.voice-list .vl-item small { color: var(--text-3); font-size: .78em; }
.voice-list .voice { padding-bottom: 4px; }

/* ============================================================ модалки */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 8, 14, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center;
}
.modal {
  max-width: calc(100vw - 40px); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  border-radius: 22px; padding: 18px 20px 20px;
  background: var(--panel); box-shadow: var(--shadow); border: 1px solid var(--border);
  animation: rise .25s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 1.15em; }

.attach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; max-height: 50vh; overflow-y: auto; margin-bottom: 12px; }
.attach-item { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface); }
.attach-item.image, .attach-item.video { aspect-ratio: 1; }
.attach-item img, .attach-item video { width: 100%; height: 100%; object-fit: cover; }
.attach-item.file { grid-column: 1 / -1; padding: 8px 12px; }
.attach-item.file .file { padding: 0; }
.attach-item .remove { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.55); color: #fff; }
.attach-foot { display: flex; gap: 10px; margin-top: 8px; }
.attach-foot input { flex: 1; height: 42px; padding: 0 14px; border-radius: 12px; border: 1.5px solid transparent; background: var(--surface); outline: 0; }
.attach-foot input:focus { border-color: var(--accent); }

/* ---------- обрезка аватара */
.cropper-backdrop { z-index: 55; }
.cropper { width: 380px; align-items: center; }
.cropper .modal-head { align-self: stretch; margin-bottom: 4px; }
.cropper-hint { margin: 0 0 14px; text-align: center; line-height: 1.45; }
.crop-stage {
  position: relative; overflow: hidden; flex-shrink: 0;
  border-radius: 18px; background: #000;
  cursor: grab; touch-action: none; user-select: none;
}
.crop-stage.dragging { cursor: grabbing; }
.crop-stage img { position: absolute; top: 0; left: 0; max-width: none; pointer-events: none; transform-origin: 0 0; }
.crop-mask {
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 400px rgba(8, 10, 16, .62);
  outline: 2px solid rgba(255, 255, 255, .85); outline-offset: -2px;
}
.crop-zoom { align-self: stretch; margin-top: 16px; }
.cropper-foot { display: flex; justify-content: flex-end; gap: 10px; align-self: stretch; margin-top: 18px; }

/* ---------- настройки */
.settings {
  width: 860px; height: 600px; max-width: calc(100vw - 40px); max-height: calc(100vh - 40px);
  display: flex; border-radius: 24px; overflow: hidden;
  background: var(--panel); box-shadow: var(--shadow); border: 1px solid var(--border);
  animation: rise .25s var(--ease);
}
.settings-nav { width: 250px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; padding: 20px 12px; background: var(--panel-2); border-right: 1px solid var(--border); }
.settings-nav h3 { margin: 4px 12px 14px; font-size: 1.25em; }
.settings-nav button { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 12px; font-weight: 500; color: var(--text-2); text-align: left; }
.settings-nav button:hover { background: var(--hover); color: var(--text); }
.settings-nav button.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.settings-nav button.danger { color: var(--danger); }
.nav-spacer { flex: 1; }
.settings-body { flex: 1; overflow-y: auto; position: relative; padding: 26px 32px 30px; }
.settings-body .close { position: absolute; top: 14px; right: 14px; }
.pane { max-width: 520px; animation: fadein .25s; }
.pane h2 { margin: 0 0 20px; font-size: 1.4em; letter-spacing: -.02em; }
.pane h4 { margin: 24px 0 10px; color: var(--text-2); font-size: .82em; text-transform: uppercase; letter-spacing: .07em; }

.profile-top { display: flex; align-items: center; gap: 20px; margin-bottom: 22px; }
.pt-name { font-size: 1.2em; font-weight: 700; margin-bottom: 4px; }
.avatar-edit { position: relative; cursor: pointer; border-radius: 50%; }
.ae-hover { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .15s; }
.avatar-edit:hover .ae-hover { opacity: 1; }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row > span { font-size: .86em; font-weight: 600; color: var(--text-2); }
.form-row small { font-size: .8em; color: var(--text-3); }
.form-row input, .form-row textarea, .form-row select, .pw-form input {
  height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid transparent; background: var(--surface); outline: 0;
  transition: border-color .15s;
}
.form-row textarea { height: auto; padding: 10px 14px; resize: none; line-height: 1.45; }
.form-row select { cursor: pointer; }
.form-row select option { background: var(--panel); }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus, .pw-form input:focus { border-color: var(--accent); }
.input-prefix { display: flex; align-items: center; border-radius: 12px; background: var(--surface); border: 1.5px solid transparent; }
.input-prefix:focus-within { border-color: var(--accent); }
.input-prefix i { font-style: normal; padding-left: 14px; color: var(--text-3); }
.input-prefix input { flex: 1; background: none; border: 0 !important; padding-left: 4px; }

.set-card { border-radius: 16px; background: var(--surface); padding: 4px 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; }
.set-row + .set-row { border-top: 1px solid var(--border); }
.set-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-row b { font-weight: 500; }
.set-row small { color: var(--text-3); font-size: .84em; overflow-wrap: anywhere; }
.set-row.compact { padding: 8px 2px; }

.sound-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sound-opt {
  position: relative; display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 12px; border-radius: 14px;
  background: var(--surface); border: 1.5px solid transparent;
  font-weight: 500; text-align: left;
  transition: border-color .15s, background .15s;
}
.sound-opt:hover { background: var(--surface-2); }
.sound-opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.so-play { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--grad); color: #fff; flex-shrink: 0; }
.so-check { margin-left: auto; color: var(--accent); }
.slider-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; color: var(--text-2); }
.slider-row > span { min-width: 40px; font-variant-numeric: tabular-nums; font-size: .9em; }
.aa { font-weight: 700; font-size: 1.3em; }
.aa.sm { font-size: .9em; }

.mic-meter { height: 8px; border-radius: 8px; background: var(--surface); overflow: hidden; margin: -6px 0 6px; }
.mic-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--success), var(--accent)); border-radius: 8px; transition: width .06s; }
.cam-preview { margin: 4px 0 10px; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.cam-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.pane .btn.ghost.sm + .form-row, .pane small + .form-row { margin-top: 16px; }

.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.theme-opt { border-radius: 16px; padding: 10px; background: var(--surface); border: 2px solid transparent; text-align: left; }
.theme-opt.on { border-color: var(--accent); }
.theme-opt i { display: block; height: 84px; border-radius: 10px; margin-bottom: 10px; }
.theme-opt.dark i { background: linear-gradient(135deg, #11151f 40%, #1c2333 40%, #1c2333 60%, var(--accent) 60%); }
.theme-opt.light i { background: linear-gradient(135deg, #ffffff 40%, #e7ebf3 40%, #e7ebf3 60%, var(--accent) 60%); }
.theme-opt span { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.accent-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.accent-opt { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; transition: transform .15s; box-shadow: var(--shadow-sm); }
.accent-opt:hover { transform: scale(1.08); }
.accent-opt.on { outline: 3px solid var(--panel); box-shadow: 0 0 0 5px var(--accent); }

.pw-form { display: flex; flex-direction: column; gap: 10px; }
.pw-form .btn { align-self: flex-start; margin-top: 4px; }

/* ---------- контекстное меню */
.ctx-layer { position: fixed; inset: 0; z-index: 90; }
.ctx-menu {
  position: fixed; min-width: 210px; padding: 6px;
  border-radius: 14px; background: var(--glass); backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
.ctx-menu button { width: 100%; display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 12px; border-radius: 9px; font-weight: 500; text-align: left; }
.ctx-menu button .icon { color: var(--text-2); }
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.danger, .ctx-menu button.danger .icon { color: var(--danger); }

/* ---------- лайтбокс */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(4, 6, 10, .92); display: flex; flex-direction: column; animation: fadein .2s; }
.lb-top { display: flex; align-items: center; gap: 8px; padding: 14px 16px; color: #fff; }
.lb-name { flex: 1; font-weight: 500; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 30px 30px; overflow: auto; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); cursor: zoom-in; animation: rise .25s var(--ease); }
.lb-stage video { width: min(1280px, 100%); max-height: 100%; object-fit: contain; border-radius: 10px; background: #000; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: rise .25s var(--ease); outline: none; }
.lb-stage.zoom { place-items: start center; }
.lb-stage.zoom img { max-width: none; max-height: none; cursor: zoom-out; }

/* ---------- фото профиля */
.avatar.clickable { cursor: zoom-in; transition: transform .15s; }
.avatar.clickable:hover { transform: scale(1.03); }
.pv-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pv-who small { opacity: .7; font-size: .85em; }
.photo-viewer .lb-top .btn.ghost { background: rgba(255,255,255,.12); color: #fff; border: 0; }
.photo-viewer .lb-stage { position: relative; }
.photo-viewer .lb-stage .pv-img {
  max-width: 100%; max-height: 100%; object-fit: contain; cursor: default;
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.55); animation: rise .25s var(--ease);
}
.pv-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.12); color: #fff; backdrop-filter: blur(10px); transition: background .15s;
}
.pv-nav:hover { background: rgba(255,255,255,.22); }
.pv-nav.prev { left: 24px; }
.pv-nav.prev .icon { transform: scaleX(-1); }
.pv-nav.next { right: 24px; }
.pv-thumbs { display: flex; justify-content: center; gap: 8px; padding: 0 20px 20px; overflow-x: auto; }
.pv-thumbs img { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; cursor: pointer; opacity: .5; border: 2px solid transparent; transition: opacity .15s; }
.pv-thumbs img.on { opacity: 1; border-color: #fff; }
.pv-thumbs img:hover { opacity: .85; }
.ae-cam {
  position: absolute; right: 2px; bottom: 2px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--grad); color: #fff;
  border: 3px solid var(--panel); box-shadow: var(--shadow-sm);
}
.avatar-edit:has(.ae-cam) { cursor: zoom-in; }
.pt-links { display: flex; gap: 14px; margin-top: 6px; }

/* ---------- тосты и уведомления */
.toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: 14px;
  background: var(--glass); backdrop-filter: blur(20px);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  font-weight: 500; pointer-events: auto; max-width: 520px;
}
.toast .icon { color: var(--accent); }
.toast.error .icon { color: var(--danger); }
.toast.success .icon { color: var(--success); }

.notifs { position: fixed; top: 14px; right: 14px; z-index: 60; display: flex; flex-direction: column; gap: 10px; width: 330px; }
.notif {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 10px 12px 12px; border-radius: 18px;
  background: var(--glass); backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  cursor: pointer;
}
.notif-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-body span { color: var(--text-2); font-size: .92em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================ звонок */
.call-layer { position: absolute; inset: 0; z-index: 40; animation: call-in .3s var(--ease); }
@keyframes call-in { from { opacity: 0; transform: scale(1.03); } }

/* свёрнутый звонок — по центру области диалога, под шапкой */
#call-bar-slot {
  position: absolute; left: 0; right: 0; top: 10px; z-index: 30;
  display: flex; justify-content: center; padding: 0 16px; pointer-events: none;
}
/* в шапке диалога: по центру, по высоте посередине (шапка 64px, плашка 36px) */
#call-bar-slot.has-chat { top: 14px; padding: 0 190px; }
.chat-head.has-call .ch-peer { max-width: calc(50% - 150px); }
.chat-head.has-call .ch-text { min-width: 0; overflow: hidden; }
.chat-head.has-call .ch-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-bar {
  pointer-events: auto; min-width: 0; max-width: min(420px, 100%);
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 14px; border-radius: 20px; font-size: .9em;
  background: linear-gradient(135deg, #16a34a, #10b981); color: #fff;
  box-shadow: 0 10px 30px rgba(16, 185, 129, .4); cursor: pointer;
  animation: rise .3s var(--ease);
}
.call-bar b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-status { flex-shrink: 0; opacity: .9; font-variant-numeric: tabular-nums; }
.cb-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse-dot 1.4s infinite; }
.cb-actions { flex-shrink: 0; display: flex; gap: 4px; margin-left: 4px; }
.cb-actions .icon-btn.sm { width: 28px; height: 28px; border-radius: 50%; }
.cb-actions .icon-btn { color: #fff; background: rgba(255,255,255,.18); }
.cb-actions .icon-btn.off { background: #fff; color: #16a34a; }
.cb-actions .icon-btn.hang { background: var(--danger); }

.call-screen {
  position: absolute; inset: 0; overflow: hidden; user-select: none; -webkit-user-select: none;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  color: #fff; background: #0a0d14;
}
.call-bg { position: absolute; inset: 0; background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--accent) 55%, #000), transparent 55%), radial-gradient(circle at 75% 85%, color-mix(in srgb, var(--accent-2) 50%, #000), transparent 55%), #0a0d14; }
.call-bg i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(90px); opacity: .35; background: var(--accent); animation: float 16s ease-in-out infinite; top: -20vmax; left: -10vmax; }
.call-bg i + i { background: var(--accent-2); top: auto; left: auto; bottom: -25vmax; right: -15vmax; animation-delay: -8s; }

.call-big { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.call-big.contain, .call-pip video.contain { object-fit: contain; background: #000; }
.call-big.mirror, .call-pip video.mirror { transform: scaleX(-1); }
/* голосовой звонок: размытое фото собеседника на весь экран, как в Telegram */
.call-blur { position: absolute; inset: -60px; background-size: cover; background-position: center; filter: blur(46px) saturate(1.25) brightness(.62); }
.call-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5, 8, 14, .25), rgba(5, 8, 14, .6)); }

.call-top { position: relative; z-index: 4; width: 100%; display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px; transition: opacity .25s, transform .25s; }
.call-spacer { flex: 1; }
.call-top-info { display: flex; flex-direction: column; min-width: 0; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.call-top-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-top-info span { opacity: .85; font-size: .9em; font-variant-numeric: tabular-nums; }
.video-mode .call-top { background: linear-gradient(rgba(0,0,0,.5), transparent); }

.call-chips { position: absolute; z-index: 4; top: calc(70px + env(safe-area-inset-top)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.call-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .84em;
  background: rgba(10, 13, 20, .6); backdrop-filter: blur(12px); max-width: calc(100% - 32px); }
.call-chip.warn { color: #fde68a; }

.call-center { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; margin: auto 0; padding-bottom: 40px; }
.call-center h2 { margin: 26px 0 6px; font-size: 1.9em; letter-spacing: -.02em; }
.call-center p { margin: 0; opacity: .8; font-size: 1.05em; font-variant-numeric: tabular-nums; }
.call-center p.ended { color: #ffb4bc; opacity: 1; }
.call-avatar { position: relative; display: grid; place-items: center; --ring: 1; }
.call-avatar .avatar { position: relative; z-index: 1; box-shadow: 0 20px 60px rgba(0,0,0,.45); font-size: 52px !important; }
.call-avatar .ring { position: absolute; inset: -14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.22); transform: scale(var(--ring)); transition: transform .12s; }
.call-avatar .ring.r2 { inset: -30px; border-color: rgba(255,255,255,.1); }
.call-avatar.pulse .ring { animation: ripple 2s ease-out infinite; }
.call-avatar.pulse .ring.r2 { animation-delay: .6s; }
@keyframes ripple { 0% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.muted-badge { position: absolute; z-index: 2; right: 4px; bottom: 4px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--danger); border: 3px solid #0a0d14; }

.call-pip {
  position: absolute; z-index: 3; width: 220px; aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden;
  background: #000; box-shadow: 0 10px 30px rgba(0,0,0,.5); border: 2px solid rgba(255,255,255,.16);
  touch-action: none; cursor: grab; transition: top .3s var(--ease), bottom .3s var(--ease), left .3s var(--ease), right .3s var(--ease);
}
.call-pip.dragging { cursor: grabbing; }
.call-pip video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.call-pip.c-tr { top: calc(78px + env(safe-area-inset-top)); right: 16px; }
.call-pip.c-tl { top: calc(78px + env(safe-area-inset-top)); left: 16px; }
.call-pip.c-br { bottom: 150px; right: 16px; }
.call-pip.c-bl { bottom: 150px; left: 16px; }
.hide-ui .call-pip.c-tr, .hide-ui .call-pip.c-tl { top: calc(16px + env(safe-area-inset-top)); }
.hide-ui .call-pip.c-br, .hide-ui .call-pip.c-bl { bottom: calc(16px + env(safe-area-inset-bottom)); }

.call-controls { position: relative; z-index: 4; display: flex; justify-content: center; flex-wrap: wrap; gap: 22px;
  width: 100%; padding: 26px 16px calc(36px + env(safe-area-inset-bottom)); transition: opacity .25s, transform .25s; }
.video-mode .call-controls { background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.hide-ui .call-top { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.hide-ui .call-controls { opacity: 0; transform: translateY(16px); pointer-events: none; }
.cc-item { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: .82em; opacity: .95; }
.cc-btn {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.14); color: #fff; backdrop-filter: blur(12px);
  transition: transform .12s, background .15s;
}
.cc-btn:hover:not(:disabled) { background: rgba(255,255,255,.24); }
.cc-btn:active:not(:disabled) { transform: scale(.92); }
.cc-btn.active { background: #fff; color: #111; }
.cc-btn.off { background: #fff; color: var(--danger); }
.cc-btn.decline { background: var(--danger); box-shadow: 0 8px 26px rgba(255, 93, 108, .45); }
.cc-btn.decline:hover { background: #ff7480; }
.cc-btn.accept { background: #22c55e; box-shadow: 0 8px 26px rgba(34, 197, 94, .45); }
.cc-btn.accept:hover { background: #34d27a; }
.cc-btn.wiggle { animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%, 50%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-14deg); } 20%, 40% { transform: rotate(14deg); } }
@media (max-width: 760px) {
  .call-controls { gap: 14px 18px; padding-top: 18px; }
  .cc-btn { width: 58px; height: 58px; }
  .cc-item { font-size: .78em; }
  .call-pip { width: 104px; aspect-ratio: 3 / 4; border-radius: 14px; }
  .call-pip.c-br, .call-pip.c-bl { bottom: 200px; }
  .call-center h2 { font-size: 1.6em; }
}

/* ============================================================ переходы */
.fade-enter-active, .fade-leave-active { transition: opacity .2s; }
.fade-enter-from, .fade-leave-to { opacity: 0; }
.pop-enter-active { transition: opacity .15s, transform .18s var(--ease); }
.pop-leave-active { transition: opacity .12s, transform .12s; }
.pop-enter-from, .pop-leave-to { opacity: 0; transform: scale(.92) translateY(6px); }
.slide-up-enter-active, .slide-up-leave-active { transition: opacity .18s, transform .2s var(--ease); }
.slide-up-enter-from, .slide-up-leave-to { opacity: 0; transform: translateY(10px); }
.slide-up-enter-active, .slide-up-leave-active { transition: opacity .25s, transform .25s var(--ease); }
.slide-up-enter-from, .slide-up-leave-to { opacity: 0; transform: translateY(12px); }
.slide-down-enter-active, .slide-down-leave-active { transition: opacity .2s, transform .2s; }
.slide-down-enter-from, .slide-down-leave-to { opacity: 0; transform: translateY(-8px); }
.swap-enter-active, .swap-leave-active { transition: opacity .1s, transform .12s; }
.swap-enter-from, .swap-leave-to { opacity: 0; transform: scale(.6) rotate(-20deg); }
.drawer-enter-active, .drawer-leave-active { transition: transform .28s var(--ease); }
.drawer-enter-from, .drawer-leave-to { transform: translateX(-100%); }
.panel-enter-active, .panel-leave-active { transition: margin .28s var(--ease), opacity .2s; }
.panel-enter-from, .panel-leave-to { margin-right: calc(-1 * var(--info-w)); opacity: 0; }
.call-enter-active, .call-leave-active { transition: opacity .3s, transform .35s var(--ease); }
.call-enter-from, .call-leave-to { opacity: 0; transform: scale(1.03); }
.toast-enter-active, .toast-leave-active { transition: opacity .25s, transform .3s var(--ease); }
.toast-enter-from, .toast-leave-to { opacity: 0; transform: translateY(14px) scale(.96); }
.notif-enter-active, .notif-leave-active { transition: opacity .25s, transform .35s var(--ease); }
.notif-enter-from, .notif-leave-to { opacity: 0; transform: translateX(40px); }

/* ============================================================ адаптив */
@media (max-width: 1180px) {
  .app.with-info .info-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 300px; }
  .messages-inner, .composer { padding-left: 12px; padding-right: 12px; }
}

/* веб-версия на широком мониторе: интерфейс не растягивается, а встаёт по центру, как WhatsApp Web */
@media (min-width: 1680px) {
  html.is-web body {
    background:
      radial-gradient(900px 640px at 10% 6%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 70%),
      radial-gradient(820px 620px at 90% 94%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 70%),
      var(--bg);
  }
  html.is-web #app { padding: 22px; }
  html.is-web .app {
    max-width: 1600px; margin: 0 auto; border-radius: 20px; overflow: hidden;
    border: 1px solid var(--border); box-shadow: 0 30px 90px rgba(0, 0, 0, .45);
  }
  html.is-web .notifs { top: 36px; right: calc((100vw - 1600px) / 2 + 14px); }
}

/* ---------- телефон: как мобильный Telegram — список чатов или переписка на весь экран */
.ch-back { display: none; }
@media (max-width: 760px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  /* без увеличения двойным касанием и задержки нажатий */
  html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  button, a, .chat-item, .msg-row { touch-action: manipulation; }
  .app { height: var(--app-h, 100dvh); }
  .sidebar { width: 100% !important; flex: 1 1 auto; border-right: 0; }
  .sb-resizer { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app:not(.chat-open) .main { display: none; }
  .main { width: 100%; flex-direction: column; }
  .main > .chat { min-height: 0; }

  .chat-head { height: 56px; padding: 0 6px 0 4px; gap: 2px; }
  .ch-back { display: grid; flex-shrink: 0; }
  .ch-peer { flex: 1; min-width: 0; gap: 10px; padding: 4px 6px; }
  .ch-peer .avatar { width: 38px !important; height: 38px !important; }
  .ch-actions { gap: 0; }
  .ch-actions .icon-btn:nth-child(3) { display: none; }
  .chat-head.has-call .ch-peer { max-width: none; }
  #call-bar-slot, #call-bar-slot.has-chat { position: static; padding: 6px 10px; order: -1; background: var(--panel); }
  #call-bar-slot:empty { display: none; }
  #call-bar-slot .call-bar { max-width: 100%; width: 100%; }

  .messages-inner { padding: 10px 8px 6px; }
  .bubble { max-width: 86%; }
  .composer { padding-bottom: env(safe-area-inset-bottom); }
  input, textarea, select { font-size: 16px; }

  .app.with-info .info-panel { position: fixed; inset: 0; width: 100%; z-index: 45; border-left: 0; }
  .drawer { width: min(320px, 86%); }
  .notifs { left: 10px; right: 10px; width: auto; top: 10px; }
  .toasts { width: calc(100% - 24px); }

  .modal-backdrop { padding: 0; }
  .settings { width: 100%; height: var(--app-h, 100dvh); max-width: none; max-height: none; border-radius: 0; flex-direction: column; border: 0; }
  .settings-nav { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .settings-nav h3, .settings-nav .nav-spacer { display: none; }
  .settings-nav button { flex-shrink: 0; height: 38px; white-space: nowrap; }
  .settings-body { padding: 18px 16px 30px; }
  .sound-grid { grid-template-columns: 1fr 1fr; }
  .pane { max-width: none; }
  .modal { max-width: calc(100vw - 20px); }
}
/* сенсорные экраны: долгое нажатие открывает наше меню, а не системное выделение */
@media (hover: none) {
  .bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .msg-side-btn { display: none; }
}
