/* =====================================================================
   Messenger 2.0 — дружелюбный Telegram-стиль
   Шрифт Nunito, мягкие формы, градиентные исходящие пузыри,
   6 акцентов, светлая/тёмная тема
   ===================================================================== */

:root {
  --c1: #4F7BFF;
  --c2: #7B61FF;
  --accent: var(--c1);
  --accent-soft: color-mix(in srgb, var(--c1) 14%, transparent);
  --accent-softer: color-mix(in srgb, var(--c1) 8%, transparent);
  --grad: linear-gradient(135deg, var(--c1), var(--c2));

  --bg: #EEF1F8;
  --panel: #FFFFFF;
  --panel-2: #F4F6FB;
  --panel-3: #E9EDF6;
  --text: #1A2233;
  --muted: #7A8499;
  --line: #E4E8F1;
  --bubble-in: #FFFFFF;
  --bubble-in-text: #1A2233;
  --bubble-out-text: #FFFFFF;
  --wall: #DCE4F3;
  --doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='none' stroke='%234F6FB8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' opacity='.16'%3E%3Cpath d='M22 30h36a8 8 0 0 1 8 8v14a8 8 0 0 1-8 8H38l-9 8v-8h-7a8 8 0 0 1-8-8V38a8 8 0 0 1 8-8z'/%3E%3Cpath d='M160 36l4 9 10 1-7 7 2 10-9-5-9 5 2-10-7-7 10-1z'/%3E%3Cpath d='M104 128c-6-8-18-2-14 7 3 6 14 13 14 13s11-7 14-13c4-9-8-15-14-7z'/%3E%3Ccircle cx='196' cy='160' r='10'/%3E%3Cpath d='M30 170l40-14-14 34-6-14z'/%3E%3Cpath d='M140 206c7-7 17-7 24 0'/%3E%3Ccircle cx='146' cy='198' r='1.5'/%3E%3Ccircle cx='158' cy='198' r='1.5'/%3E%3Ccircle cx='76' cy='104' r='4'/%3E%3Cpath d='M200 92h16M208 84v16'/%3E%3Cpath d='M120 60q10-14 20 0t20 0'/%3E%3C/g%3E%3C/svg%3E");
  --danger: #EF4B5B;
  --success: #22C27A;
  --online: #22C27A;
  --shadow-1: 0 1px 2px rgba(20, 30, 60, .06);
  --shadow-2: 0 6px 20px rgba(20, 30, 60, .10);
  --shadow-3: 0 18px 50px rgba(20, 30, 60, .18);
  --fs: 15px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-bubble: 18px;
  --sidebar-w: 380px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

html[data-accent="mint"]   { --c1: #14B88F; --c2: #2EC5CE; }
html[data-accent="sunset"] { --c1: #FF7A3D; --c2: #FF4F7B; }
html[data-accent="violet"] { --c1: #8B5CF6; --c2: #D946EF; }
html[data-accent="ocean"]  { --c1: #0EA5E9; --c2: #2563EB; }
html[data-accent="berry"]  { --c1: #E0457B; --c2: #9D4EDD; }

html.dark {
  --bg: #0D1220;
  --panel: #161D2D;
  --panel-2: #1D2638;
  --panel-3: #253046;
  --text: #E8ECF5;
  --muted: #8C96AB;
  --line: #232D42;
  --bubble-in: #212A3D;
  --bubble-in-text: #E8ECF5;
  --wall: #0F1626;
  --doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' opacity='.05'%3E%3Cpath d='M22 30h36a8 8 0 0 1 8 8v14a8 8 0 0 1-8 8H38l-9 8v-8h-7a8 8 0 0 1-8-8V38a8 8 0 0 1 8-8z'/%3E%3Cpath d='M160 36l4 9 10 1-7 7 2 10-9-5-9 5 2-10-7-7 10-1z'/%3E%3Cpath d='M104 128c-6-8-18-2-14 7 3 6 14 13 14 13s11-7 14-13c4-9-8-15-14-7z'/%3E%3Ccircle cx='196' cy='160' r='10'/%3E%3Cpath d='M30 170l40-14-14 34-6-14z'/%3E%3Cpath d='M140 206c7-7 17-7 24 0'/%3E%3Ccircle cx='146' cy='198' r='1.5'/%3E%3Ccircle cx='158' cy='198' r='1.5'/%3E%3Ccircle cx='76' cy='104' r='4'/%3E%3Cpath d='M200 92h16M208 84v16'/%3E%3Cpath d='M120 60q10-14 20 0t20 0'/%3E%3C/g%3E%3C/svg%3E");
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- BUTTONS / INPUTS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 14px;
  font-weight: 700; font-size: 15px; transition: transform .12s, filter .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--c1) 35%, transparent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: color-mix(in srgb, var(--c1) 20%, transparent); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-danger-soft { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn-danger-soft:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.btn-danger { background: var(--danger); color: #fff; }
.link-btn { color: var(--accent); font-weight: 700; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 18px; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--panel-2); outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--accent); background: var(--panel); }

.switch {
  position: relative; width: 42px; height: 24px; border-radius: 12px; flex-shrink: 0;
  background: var(--panel-3); transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease);
}
input:checked + .switch { background: var(--accent); }
input:checked + .switch::after { transform: translateX(18px); }
.toggle-row input, .drawer-switch input { position: absolute; opacity: 0; pointer-events: none; }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--muted); user-select: none; }
.check input { position: absolute; opacity: 0; }
.check-box {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); flex-shrink: 0;
  display: grid; place-items: center; transition: all .15s;
}
.check input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check-box::after { content: "\f00c"; font: 900 11px "Font Awesome 6 Free"; color: #fff; }
.check input:focus-visible + .check-box { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- AVATAR ---------- */
.avatar {
  position: relative; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; overflow: visible;
  color: #fff; font-weight: 800; text-transform: uppercase; user-select: none;
  background: linear-gradient(135deg, var(--a1, #7aa2ff), var(--a2, #5b6cff));
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.saved { background: var(--grad); }
.avatar .dot {
  position: absolute; right: 0; bottom: 0; width: 28%; height: 28%; min-width: 10px; min-height: 10px;
  background: var(--online); border-radius: 50%; border: 2.5px solid var(--panel);
}
.avatar-32 { width: 32px; height: 32px; font-size: 13px; }
.avatar-40 { width: 40px; height: 40px; font-size: 16px; }
.avatar-48 { width: 48px; height: 48px; font-size: 18px; }
.avatar-54 { width: 54px; height: 54px; font-size: 20px; }
.avatar-56 { width: 56px; height: 56px; font-size: 21px; }
.avatar-96 { width: 96px; height: 96px; font-size: 36px; }
.avatar-120 { width: 120px; height: 120px; font-size: 44px; }
.avatar-placeholder { background: var(--accent-soft); color: var(--accent); }

/* ===================================================================
   AUTH
   =================================================================== */
.auth-page {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
  background: var(--wall) var(--doodle); background-size: 240px;
  overflow-y: auto;
}
.auth-bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ab {
  position: absolute; padding: 10px 16px; border-radius: 18px 18px 18px 6px;
  background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow-2);
  opacity: .9; animation: floaty 7s ease-in-out infinite;
}
.ab.out { background: var(--grad); color: #fff; border-radius: 18px 18px 6px 18px; }
.ab1 { top: 12%; left: 8%; }
.ab2 { top: 22%; right: 10%; animation-delay: -2s; }
.ab3 { bottom: 20%; left: 6%; animation-delay: -4s; }
.ab4 { bottom: 12%; right: 12%; animation-delay: -1s; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@media (max-width: 720px) { .auth-bubbles { display: none; } }

.auth-card {
  position: relative; width: 100%; max-width: 400px;
  background: var(--panel); border-radius: 28px; padding: 36px 30px 28px;
  box-shadow: var(--shadow-3);
  animation: pop .35s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo-mark {
  width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 24px;
  display: grid; place-items: center; font-size: 32px; color: #fff; background: var(--grad);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--c1) 40%, transparent);
  transform: rotate(-6deg);
}
.auth-logo-mark i { transform: rotate(6deg) translateX(-2px); }
.auth-logo h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.auth-logo p { color: var(--muted); margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.field { position: relative; display: flex; align-items: center; }
.field > i { position: absolute; left: 16px; color: var(--muted); font-size: 15px; pointer-events: none; }
.field input {
  width: 100%; height: 50px; padding: 0 46px 0 44px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--panel-2); outline: none; font-size: 15px;
  transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--accent); background: var(--panel); }
.field-eye { position: absolute; right: 6px; width: 38px; height: 38px; border-radius: 12px; color: var(--muted); }
.field-eye:hover { color: var(--text); }
.field-hint { font-size: 12.5px; color: var(--muted); margin: -4px 4px 2px; }
.strength { display: flex; align-items: center; gap: 10px; margin: -2px 4px 0; font-size: 12.5px; font-weight: 700; }
.strength-track { flex: 1; height: 5px; background: var(--panel-3); border-radius: 4px; overflow: hidden; }
.strength-fill { height: 100%; width: 0; border-radius: 4px; transition: width .25s, background .25s; }
.auth-switch { text-align: center; color: var(--muted); font-size: 14px; margin-top: 4px; }
.auth-switch a { font-weight: 700; }
.auth-error { min-height: 20px; margin-top: 14px; text-align: center; color: var(--danger); font-size: 14px; font-weight: 600; }
.auth-error.info { color: var(--muted); }

/* ===================================================================
   APP LAYOUT
   =================================================================== */
.app { display: flex; height: 100dvh; width: 100%; overflow: hidden; }

.sidebar {
  position: relative; width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.sidebar-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; padding-top: max(10px, env(safe-area-inset-top)); }
.search { position: relative; flex: 1; display: flex; align-items: center; }
.search > i { position: absolute; left: 14px; color: var(--muted); font-size: 14px; pointer-events: none; }
.search input {
  width: 100%; height: 42px; padding: 0 38px 0 40px; border-radius: 21px;
  background: var(--panel-2); border: 1.5px solid transparent; outline: none; transition: all .15s;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { border-color: var(--accent); background: var(--panel); }
.search-clear { position: absolute; right: 6px; width: 30px; height: 30px; border-radius: 50%; color: var(--muted); }
.search-clear:hover { background: var(--panel-3); }

.folders { display: flex; gap: 4px; padding: 4px 10px 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.folders::-webkit-scrollbar { display: none; }
.folder {
  flex-shrink: 0; padding: 7px 14px; border-radius: 18px; font-size: 14px; font-weight: 700; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s, color .15s;
}
.folder:hover { background: var(--panel-2); color: var(--text); }
.folder.active { background: var(--accent-soft); color: var(--accent); }
.folder-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11.5px; display: inline-grid; place-items: center; }

/* ---------- CHAT LIST ---------- */
.chat-list { flex: 1; overflow-y: auto; padding: 6px 8px 90px; }
.list-label { padding: 12px 10px 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 16px;
  cursor: pointer; position: relative; user-select: none; transition: background .12s;
}
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--grad); color: #fff; }
.chat-item.active .ci-time, .chat-item.active .ci-preview, .chat-item.active .ci-ticks, .chat-item.active .ci-author { color: rgba(255,255,255,.85); }
.chat-item.active .ci-badge { background: #fff; color: var(--c1); }
.chat-item.active .avatar .dot { border-color: var(--c1); }
.ci-body { flex: 1; min-width: 0; }
.ci-top, .ci-bottom { display: flex; align-items: center; gap: 6px; }
.ci-top { margin-bottom: 2px; }
.ci-name { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.ci-name i { font-size: 12px; opacity: .7; }
.ci-time { font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
.ci-ticks { color: var(--accent); font-size: 12px; }
.ci-preview { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-author { color: var(--text); font-weight: 600; }
.ci-typing { color: var(--accent); font-weight: 600; }
.chat-item.active .ci-typing { color: #fff; }
.ci-badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; flex-shrink: 0;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
.ci-badge.muted { background: var(--muted); }
.ci-pin { color: var(--muted); font-size: 12px; transform: rotate(45deg); }
.ci-mute { color: var(--muted); font-size: 11px; }
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 50px 24px; color: var(--muted);
}
.empty .empty-emoji { font-size: 44px; margin-bottom: 6px; }
.empty b { color: var(--text); font-size: 16px; }
.skeleton-list { padding: 4px; }
.sk { height: 62px; border-radius: 16px; margin-bottom: 6px; background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- FAB ---------- */
.fab-wrap { position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fab {
  width: 56px; height: 56px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 20px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--c1) 45%, transparent); transition: transform .2s var(--ease);
}
.fab:hover { transform: scale(1.05); }
.fab.open { transform: rotate(45deg); }
.fab.open i::before { content: "\2b"; }
.fab-menu {
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-3); padding: 6px; min-width: 200px;
  animation: menuIn .18s var(--ease); transform-origin: bottom right;
}
.fab-menu button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 11px 14px; border-radius: 10px; font-weight: 600; text-align: left; }
.fab-menu button:hover { background: var(--panel-2); }
.fab-menu i { width: 18px; color: var(--muted); }

/* ===================================================================
   CHAT AREA
   =================================================================== */
.chat-area { flex: 1; min-width: 0; position: relative; background: var(--wall) var(--doodle); background-size: 240px; display: flex; }
.chat-placeholder { flex: 1; display: grid; place-items: center; padding: 24px; }
.placeholder-card {
  text-align: center; max-width: 360px; padding: 30px 26px; border-radius: 26px;
  background: color-mix(in srgb, var(--panel) 80%, transparent); backdrop-filter: blur(10px);
  box-shadow: var(--shadow-2);
}
.placeholder-art { width: 80px; height: 80px; border-radius: 26px; margin: 0 auto 16px; display: grid; place-items: center; font-size: 34px; color: #fff; background: var(--grad); transform: rotate(-6deg); }
.placeholder-card h3 { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.placeholder-card p { color: var(--muted); font-size: 14.5px; }
.placeholder-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip-btn { padding: 9px 14px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; display: inline-flex; gap: 8px; align-items: center; }
.chip-btn:hover { background: color-mix(in srgb, var(--c1) 22%, transparent); }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* ---------- HEADER ---------- */
.chat-header {
  position: relative; z-index: 5; display: flex; align-items: center; gap: 6px;
  min-height: 60px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.back-btn { display: none; }
.chat-peer { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 14px; }
.chat-peer:hover { background: var(--panel-2); }
.chat-peer-info { min-width: 0; }
.chat-peer-info h2 { font-size: 16.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status.online, .chat-status.typing { color: var(--accent); }
.chat-header-actions { display: flex; gap: 2px; }
.typing-dots { display: inline-flex; gap: 3px; margin-right: 6px; vertical-align: middle; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: tdot 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes tdot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.chat-search {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  padding-top: max(8px, env(safe-area-inset-top)); background: var(--panel);
}
.chat-search input { flex: 1; height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--panel-2); outline: none; }
.chat-search input:focus { border-color: var(--accent); }
.chat-search-count { font-size: 13px; color: var(--muted); min-width: 44px; text-align: center; }

/* ---------- MESSAGES ---------- */
.messages-wrap { position: relative; flex: 1; min-height: 0; }
.messages {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  padding: 14px max(14px, calc((100% - 820px) / 2)) 10px;
  display: flex; flex-direction: column; overscroll-behavior: contain;
}
.load-more { align-self: center; margin: 4px 0 10px; padding: 6px 14px; border-radius: 16px; font-size: 13px; font-weight: 700; color: var(--muted); background: color-mix(in srgb, var(--panel) 75%, transparent); }
.day-sep { position: sticky; top: 4px; z-index: 2; align-self: center; margin: 10px 0; padding: 4px 12px; border-radius: 14px; font-size: 13px; font-weight: 700; color: var(--text); background: color-mix(in srgb, var(--panel) 80%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow-1); }
.unread-sep { align-self: stretch; text-align: center; margin: 8px 0; padding: 5px; font-size: 13px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--panel) 70%, transparent); border-radius: 10px; }
.system-msg { align-self: center; max-width: 80%; text-align: center; margin: 6px 0; padding: 5px 12px; border-radius: 14px; font-size: 13px; font-weight: 600; color: var(--text); background: color-mix(in srgb, var(--panel) 72%, transparent); backdrop-filter: blur(8px); }
.messages-empty { margin: auto; text-align: center; padding: 22px 26px; border-radius: 22px; background: color-mix(in srgb, var(--panel) 80%, transparent); backdrop-filter: blur(8px); color: var(--muted); max-width: 300px; }
.messages-empty .empty-emoji { font-size: 48px; margin-bottom: 8px; cursor: pointer; transition: transform .15s; }
.messages-empty .empty-emoji:hover { transform: scale(1.15) rotate(-8deg); }
.messages-empty b { display: block; color: var(--text); margin-bottom: 4px; }

.msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 2px; max-width: 100%; }
.msg.first { margin-top: 8px; }
.msg.out { justify-content: flex-end; }
.msg-avatar-slot { width: 32px; flex-shrink: 0; align-self: flex-end; }
.msg-avatar-slot .avatar { cursor: pointer; }

.bubble {
  position: relative; max-width: min(560px, 78%); padding: 7px 11px 7px 12px;
  border-radius: var(--r-bubble); line-height: 1.42; word-wrap: break-word; overflow-wrap: anywhere;
  box-shadow: var(--shadow-1); transition: background .3s;
}
.msg.in .bubble { background: var(--bubble-in); color: var(--bubble-in-text); }
.msg.out .bubble { background: var(--grad); background-attachment: fixed; color: var(--bubble-out-text); }
.msg.in:not(.last) .bubble { border-bottom-left-radius: 6px; }
.msg.in:not(.first) .bubble { border-top-left-radius: 6px; }
.msg.out:not(.last) .bubble { border-bottom-right-radius: 6px; }
.msg.out:not(.first) .bubble { border-top-right-radius: 6px; }
.msg.in.last .bubble { border-bottom-left-radius: 4px; }
.msg.out.last .bubble { border-bottom-right-radius: 4px; }
.msg.highlight .bubble { animation: hl 1.6s ease; }
@keyframes hl { 0%, 40% { box-shadow: 0 0 0 3px var(--accent), var(--shadow-2); } 100% { box-shadow: var(--shadow-1); } }
.msg.found .bubble { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c1) 55%, transparent); }
.msg.appear { animation: msgIn .22s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.b-sender { font-size: 13.5px; font-weight: 800; margin-bottom: 1px; cursor: pointer; }
.b-fwd { font-size: 13px; margin-bottom: 3px; opacity: .85; }
.b-fwd b { font-weight: 700; }
.msg.in .b-fwd { color: var(--accent); }
.b-reply {
  display: flex; gap: 8px; margin: 2px 0 5px; padding: 4px 8px 4px 10px; border-radius: 8px; cursor: pointer;
  border-left: 3px solid currentColor; font-size: 13.5px; line-height: 1.3; max-width: 100%;
}
.msg.in .b-reply { background: var(--accent-softer); color: var(--accent); }
.msg.out .b-reply { background: rgba(255,255,255,.16); color: #fff; }
.b-reply img { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; flex-shrink: 0; }
.b-reply-body { min-width: 0; }
.b-reply-author { display: block; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-reply-text { display: block; color: var(--text); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.out .b-reply-text { color: #fff; }
.b-text { white-space: pre-wrap; }
.b-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg.in .b-text a { color: var(--accent); }
.b-text .emoji-only { font-size: 2.2em; line-height: 1.2; }
.meta-spacer { display: inline-block; width: 52px; height: 1px; }
.msg.out .meta-spacer { width: 66px; }
.edited .meta-spacer { width: 100px; }
.msg.out.edited .meta-spacer { width: 114px; }
.b-meta {
  position: absolute; right: 10px; bottom: 5px; display: flex; align-items: center; gap: 4px;
  font-size: 11.5px; white-space: nowrap; user-select: none;
}
.msg.in .b-meta { color: var(--muted); }
.msg.out .b-meta { color: rgba(255,255,255,.8); }
.b-meta .tick.read { color: #fff; }
.b-image { margin: -3px -7px 4px -8px; border-radius: 14px; overflow: hidden; cursor: zoom-in; background: var(--panel-3); }
.b-image img { width: 100%; max-height: 420px; min-height: 80px; object-fit: cover; }
.bubble.media-only { padding: 3px; }
.bubble.media-only .b-image { margin: 0; }
.bubble.media-only .b-meta { background: rgba(0,0,0,.45); color: #fff; padding: 2px 7px; border-radius: 10px; right: 10px; bottom: 10px; }
.bubble.sticker { background: none !important; box-shadow: none; padding: 0; }
.bubble.sticker .b-meta { position: static; justify-content: flex-end; margin-top: 2px; padding: 2px 8px; border-radius: 10px; background: color-mix(in srgb, var(--panel) 80%, transparent); color: var(--muted); align-self: flex-end; width: fit-content; margin-left: auto; }
.bubble.sticker .b-meta .tick.read { color: var(--accent); }
.b-sticker { width: 160px; height: 160px; object-fit: contain; }
.bubble.sticker .b-reply { background: var(--panel); color: var(--accent); }
.bubble.sticker .b-reply-text { color: var(--text); }

.b-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 6px; border-radius: 14px;
  font-size: 14px; font-weight: 700; transition: transform .1s;
}
.reaction:active { transform: scale(.92); }
.msg.in .reaction { background: var(--accent-soft); color: var(--accent); }
.msg.in .reaction.mine { background: var(--accent); color: #fff; }
.msg.out .reaction { background: rgba(255,255,255,.2); color: #fff; }
.msg.out .reaction.mine { background: #fff; color: var(--c1); }
.bubble.sticker .reaction { background: var(--panel); color: var(--accent); }
.bubble.sticker .reaction.mine { background: var(--accent); color: #fff; }
.reaction .rc { font-size: 12.5px; }

.msg-hover-btn {
  align-self: center; width: 30px; height: 30px; border-radius: 50%; opacity: 0; flex-shrink: 0;
  color: var(--muted); background: color-mix(in srgb, var(--panel) 85%, transparent); font-size: 13px; transition: opacity .12s;
}
.msg:hover .msg-hover-btn { opacity: 1; }
@media (hover: none) { .msg-hover-btn { display: none; } }

.scroll-down {
  position: absolute; right: 18px; bottom: 14px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--panel); color: var(--muted); box-shadow: var(--shadow-2); font-size: 16px;
  animation: pop .2s var(--ease);
}
.scroll-down:hover { color: var(--text); }
.scroll-down-badge { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }

/* ---------- COMPOSER ---------- */
.composer { position: relative; padding: 8px 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer > * { max-width: 820px; margin-left: auto; margin-right: auto; }
.compose-bar {
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; margin-bottom: 6px;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-1); animation: pop .15s var(--ease);
}
.compose-bar-icon { color: var(--accent); font-size: 17px; }
.compose-bar-body { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 10px; }
.compose-bar-title { display: block; font-size: 13.5px; font-weight: 800; color: var(--accent); }
.compose-bar-text { display: block; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-box {
  flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 2px; padding: 3px;
  background: var(--panel); border-radius: 24px; box-shadow: var(--shadow-1);
}
.composer-box .icon-btn { width: 42px; height: 42px; }
#msg-input {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent;
  padding: 10px 4px; max-height: 180px; line-height: 1.4; font-size: var(--fs);
}
#msg-input::placeholder { color: var(--muted); }
.send-btn {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; color: #fff; font-size: 18px;
  background: var(--grad); box-shadow: 0 6px 16px color-mix(in srgb, var(--c1) 40%, transparent);
  display: grid; place-items: center; transition: transform .15s var(--ease), opacity .15s;
}
.send-btn i { transform: translateX(-1px); }
.send-btn:disabled { opacity: .5; box-shadow: none; cursor: default; }
.send-btn:not(:disabled):hover { transform: scale(1.06); }
.send-btn.edit-mode i::before { content: "\f00c"; }

.panel {
  position: absolute; left: 12px; bottom: calc(100% - 4px); width: 350px; max-width: calc(100% - 24px); margin: 0;
  background: var(--panel); border-radius: 20px; box-shadow: var(--shadow-3); overflow: hidden; z-index: 6;
  animation: menuIn .18s var(--ease); transform-origin: bottom left;
}
@media (min-width: 1100px) { .panel { left: max(12px, calc((100% - 820px) / 2)); } }
.panel-tabs { display: flex; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.panel-tab { flex: 1; padding: 8px; font-weight: 700; font-size: 14px; color: var(--muted); border-bottom: 2.5px solid transparent; }
.panel-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.panel-body { height: 280px; overflow-y: auto; padding: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-grid button { font-size: 24px; height: 40px; border-radius: 10px; transition: transform .1s; }
.emoji-grid button:hover { background: var(--panel-2); transform: scale(1.15); }
.emoji-cat { grid-column: 1 / -1; font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 8px 4px 4px; }
.stickers-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sticker-item { aspect-ratio: 1; border-radius: 14px; padding: 6px; transition: background .15s, transform .15s; }
.sticker-item:hover { background: var(--panel-2); transform: scale(1.05); }
.sticker-item img { width: 100%; height: 100%; object-fit: contain; }
.sticker-item.broken { display: none; }

.drop-zone { position: absolute; inset: 10px; z-index: 20; border-radius: 22px; border: 3px dashed var(--accent); background: color-mix(in srgb, var(--panel) 85%, transparent); display: grid; place-items: center; text-align: center; color: var(--accent); font-weight: 800; pointer-events: none; }
.drop-zone i { font-size: 42px; margin-bottom: 10px; }

/* ===================================================================
   DRAWER
   =================================================================== */
.drawer-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 15, 30, .4); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 51; width: 300px; max-width: 86vw;
  background: var(--panel); box-shadow: var(--shadow-3); display: flex; flex-direction: column;
  transform: translateX(-105%); transition: transform .28s var(--ease); visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head {
  position: relative; padding: 22px 20px 16px; padding-top: max(22px, env(safe-area-inset-top));
  background: var(--grad); color: #fff;
}
.drawer-head .avatar { box-shadow: 0 0 0 3px rgba(255,255,255,.35); cursor: pointer; }
.drawer-theme { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 14px; color: #fff; }
.drawer-theme:hover { background: rgba(255,255,255,.18); color: #fff; }
.drawer-name { margin-top: 14px; font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-login { font-size: 14px; opacity: .85; }
.drawer-items { flex: 1; overflow-y: auto; padding: 8px; }
.drawer-items > button, .drawer-switch {
  width: 100%; display: flex; align-items: center; gap: 18px; padding: 12px 14px; border-radius: 12px;
  font-weight: 600; text-align: left; cursor: pointer; position: relative;
}
.drawer-items > button:hover, .drawer-switch:hover { background: var(--panel-2); }
.drawer-items i { width: 20px; text-align: center; color: var(--muted); font-size: 17px; }
.drawer-switch span:not(.switch) { flex: 1; }
.drawer-items .danger, .drawer-items .danger i { color: var(--danger); }
.drawer-sep { height: 1px; background: var(--line); margin: 6px 10px; }
.drawer-foot { padding: 12px 22px; padding-bottom: max(12px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 12.5px; }

/* ===================================================================
   CONTEXT MENU
   =================================================================== */
.ctx {
  position: fixed; z-index: 70; min-width: 210px; max-width: 280px; padding: 6px;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-3);
  animation: menuIn .14s var(--ease);
}
@keyframes menuIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.ctx-reactions { display: flex; gap: 2px; padding: 4px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.ctx-reactions button { font-size: 22px; width: 36px; height: 36px; border-radius: 50%; transition: transform .12s; }
.ctx-reactions button:hover { transform: scale(1.25); background: var(--panel-2); }
.ctx-reactions button.mine { background: var(--accent-soft); }
.ctx-item { width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 14.5px; text-align: left; }
.ctx-item:hover { background: var(--panel-2); }
.ctx-item i { width: 18px; text-align: center; color: var(--muted); }
.ctx-item.danger, .ctx-item.danger i { color: var(--danger); }

/* ===================================================================
   MODALS
   =================================================================== */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-overlay { position: absolute; inset: 0; background: rgba(10, 15, 30, .45); animation: fade .2s; }
.modal-card {
  position: relative; width: 100%; max-width: 420px; max-height: calc(100dvh - 32px);
  background: var(--panel); border-radius: 24px; box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; overflow: hidden; animation: pop .22s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 8px 22px; }
.modal-head h3 { font-size: 19px; font-weight: 800; }
.modal-foot { padding: 12px 18px 18px; }
.modal-x { position: absolute; top: 12px; right: 12px; z-index: 2; }

.profile-card { overflow-y: auto; }
.profile-cover { position: relative; display: flex; flex-direction: column; align-items: center; padding: 30px 20px 18px; text-align: center; background: linear-gradient(180deg, var(--accent-soft), transparent); }
.profile-cover .avatar { margin-bottom: 12px; box-shadow: 0 8px 26px color-mix(in srgb, var(--c1) 30%, transparent); cursor: zoom-in; }
.profile-cover h2 { font-size: 21px; font-weight: 800; max-width: 100%; word-break: break-word; }
.profile-status { color: var(--muted); font-size: 14px; margin-top: 2px; }
.profile-status.online { color: var(--accent); }
.avatar-edit {
  position: absolute; top: 102px; left: calc(50% + 24px); width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad); color: #fff; display: grid; place-items: center; cursor: pointer; border: 3px solid var(--panel);
}
.avatar-edit:hover { filter: brightness(1.08); }
.profile-actions { display: flex; justify-content: center; gap: 10px; padding: 0 18px 12px; }
.profile-actions button { flex: 1; max-width: 110px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 14px; background: var(--panel-2); color: var(--accent); font-size: 13px; font-weight: 700; }
.profile-actions button:hover { background: var(--accent-soft); }
.profile-actions i { font-size: 18px; }
.info-list { padding: 0 10px 6px; }
.info-row { display: flex; gap: 16px; padding: 10px 12px; border-radius: 12px; align-items: flex-start; }
.info-row:hover { background: var(--panel-2); }
.info-row > i { width: 20px; text-align: center; color: var(--muted); margin-top: 3px; }
.info-row .v { font-weight: 600; word-break: break-word; white-space: pre-wrap; }
.info-row .k { font-size: 12.5px; color: var(--muted); }
.info-row.clickable { cursor: pointer; }
.profile-foot { padding: 6px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.profile-edit { padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.lbl { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); position: relative; }
.lbl input, .lbl textarea { font-weight: 500; font-size: 15px; color: var(--text); padding: 11px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--panel-2); outline: none; resize: none; }
.lbl input:focus, .lbl textarea:focus { border-color: var(--accent); background: var(--panel); }
.counter { position: absolute; right: 10px; bottom: 8px; font-size: 11.5px; font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; cursor: pointer; font-weight: 600; position: relative; }
.toggle-row small { display: block; color: var(--muted); font-weight: 500; }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; }

.section-title { display: flex; align-items: center; justify-content: space-between; padding: 8px 22px; font-weight: 800; font-size: 14px; color: var(--accent); }
.member-list { padding: 0 10px; }
.member { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px; cursor: pointer; }
.member:hover { background: var(--panel-2); }
.member-body { flex: 1; min-width: 0; }
.member-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { font-size: 13px; color: var(--muted); }
.member-sub.online { color: var(--accent); }
.role-badge { font-size: 12px; font-weight: 700; color: var(--accent); }
.member-kick { width: 32px; height: 32px; font-size: 14px; }
.member-kick:hover { color: var(--danger); }

.people-card { height: min(620px, calc(100dvh - 32px)); }
.group-name-row { display: flex; align-items: center; gap: 12px; padding: 4px 18px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px; }
.chips:not(:empty) { padding-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.chip .avatar { width: 24px; height: 24px; font-size: 10px; }
.chip:hover { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.search-in-modal { margin: 0 18px 8px; flex: none; }
.people-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.person { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px; cursor: pointer; }
.person:hover { background: var(--panel-2); }
.person-body { flex: 1; min-width: 0; }
.person-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 13px; color: var(--muted); }
.person-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex-shrink: 0; }
.person.selected .person-check { background: var(--accent); border-color: var(--accent); }
.person.selected .person-check::after { content: "\f00c"; font: 900 11px "Font Awesome 6 Free"; color: #fff; }

.settings-card { max-width: 460px; }
.settings-body { overflow-y: auto; padding: 0 18px 18px; }
.set-group { padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-group:last-child { border-bottom: 0; }
.set-title { font-size: 14px; font-weight: 800; color: var(--accent); margin-bottom: 10px; }
.set-row { display: flex; justify-content: space-between; font-weight: 600; margin: 14px 0 8px; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--panel-2); border-radius: 14px; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.seg button.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-1); }
.accents { display: flex; gap: 12px; flex-wrap: wrap; }
.accents button { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--c1), var(--c2)); transition: transform .15s; position: relative; }
.accents button:hover { transform: scale(1.1); }
.accents button.active::after { content: "\f00c"; font: 900 14px "Font Awesome 6 Free"; color: #fff; position: absolute; inset: 0; display: grid; place-items: center; }
.accents button.active { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--c1); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.pw-form { display: flex; flex-direction: column; gap: 8px; }

.dialog-card { max-width: 360px; padding: 22px 22px 14px; }
.dialog-card h3 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.dialog-card p { color: var(--muted); margin-bottom: 12px; white-space: pre-line; }
.dialog-card .input { margin-bottom: 12px; }
.dialog-card .check { margin-bottom: 12px; color: var(--text); }
.dialog-btns { display: flex; justify-content: flex-end; gap: 6px; }
.dialog-btns .btn { height: 40px; padding: 0 16px; }

.image-send-card { max-width: 480px; }
.image-send-preview { padding: 0 18px; }
.image-send-preview img { width: 100%; max-height: 55dvh; object-fit: contain; border-radius: 16px; background: var(--panel-2); }
.image-send-row { display: flex; gap: 8px; padding: 12px 18px 18px; }

/* ---------- LIGHTBOX ---------- */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(5, 8, 15, .92); display: grid; place-items: center; padding: 50px 16px; animation: fade .2s; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; animation: pop .22s var(--ease); cursor: default; }
.lightbox-x, .lightbox-dl { position: absolute; top: max(12px, env(safe-area-inset-top)); color: #fff; font-size: 20px; }
.lightbox-x { right: 12px; }
.lightbox-dl { right: 60px; }
.lightbox-x:hover, .lightbox-dl:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }

/* ---------- CALL ---------- */
.call-screen {
  position: fixed; inset: 0; z-index: 90; color: #fff; overflow: hidden;
  background: radial-gradient(circle at 30% 20%, var(--c2), transparent 60%), linear-gradient(160deg, var(--c1), #1b1f3a);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: max(40px, env(safe-area-inset-top)) 20px max(40px, env(safe-area-inset-bottom));
  animation: fade .25s;
}
#remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#local-video { position: absolute; right: 16px; top: max(16px, env(safe-area-inset-top)); width: 120px; height: 170px; object-fit: cover; border-radius: 16px; z-index: 2; box-shadow: var(--shadow-3); transform: scaleX(-1); background: #000; }
.call-center { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; text-align: center; margin-top: 8vh; }
.call-screen.video-on .call-center { margin-top: 0; }
.call-screen.video-on .call-avatar { display: none; }
.call-avatar { box-shadow: 0 0 0 10px rgba(255,255,255,.1), 0 0 0 22px rgba(255,255,255,.05); margin-bottom: 26px; }
.call-screen.ringing .call-avatar { animation: ring 1.6s ease-in-out infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 16px rgba(255,255,255,.14), 0 0 0 34px rgba(255,255,255,.06); } }
.call-center h3 { font-size: 26px; font-weight: 800; text-shadow: 0 2px 10px rgba(0,0,0,.3); }
.call-center p { opacity: .85; margin-top: 4px; font-size: 16px; text-shadow: 0 1px 6px rgba(0,0,0,.3); }
.call-controls { position: relative; z-index: 2; display: flex; gap: 22px; }
.call-btn { width: 64px; height: 64px; border-radius: 50%; font-size: 22px; background: rgba(255,255,255,.18); backdrop-filter: blur(10px); color: #fff; transition: transform .15s, background .15s; }
.call-btn:hover { transform: scale(1.06); background: rgba(255,255,255,.28); }
.call-btn.off { background: #fff; color: #1b1f3a; }
.call-btn.end { background: var(--danger); }
.call-btn.accept { background: var(--success); animation: ring 1.6s infinite; }

/* ---------- TOASTS ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 16px; background: #1f2638; color: #fff; font-weight: 600; font-size: 14.5px; box-shadow: var(--shadow-3); animation: toastIn .25s var(--ease); pointer-events: auto; }
.toast.error i { color: #ff8a95; }
.toast.success i { color: #6ee7a8; }
.toast.out { animation: toastOut .2s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 1100px) { :root { --sidebar-w: 330px; } }

@media (max-width: 768px) {
  .sidebar { width: 100%; border-right: 0; }
  .chat-area { position: fixed; inset: 0; z-index: 10; transform: translateX(100%); transition: transform .28s var(--ease); visibility: hidden; }
  .app.chat-open .chat-area { transform: none; visibility: visible; }
  .back-btn { display: inline-flex; }
  .hide-sm { display: none; }
  .chat-header { padding-left: 4px; }
  .bubble { max-width: 84%; }
  .messages { padding-left: 10px; padding-right: 10px; }
  .composer { padding-left: 8px; padding-right: 8px; }
  .panel { left: 8px; right: 8px; width: auto; max-width: none; }
  .modal { align-items: end; padding: 0; }
  .modal-card { max-width: none; border-radius: 24px 24px 0 0; max-height: 92dvh; animation: sheetUp .28s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
  .dialog-card { margin: 0; }
  .people-card { height: 88dvh; }
  .b-sticker { width: 140px; height: 140px; }
  .row2 { grid-template-columns: 1fr; }
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
