:root {
  --primary: #0f8f5a;
  --primary-strong: #067247;
  --secondary: #8bea78;
  --bg: #020b08;
  --surface: #0d1813;
  --surface-2: #14241c;
  --text: #edf7f1;
  --muted: #93aa9d;
  --accent: #9cff87;
  --message-me: #0f8f5a;
  --message-peer: #12221a;
  --danger: #e95050;
  --border: rgba(255,255,255,.08);
  --shadow: 0 24px 80px rgba(0,0,0,.44);
}
body.light-theme {
  --primary: #0f8f5a;
  --primary-strong: #08744b;
  --secondary: #4ecf7a;
  --bg: #edf7f1;
  --surface: #ffffff;
  --surface-2: #dff0e7;
  --text: #102018;
  --muted: #597066;
  --accent: #08744b;
  --message-me: #0f8f5a;
  --message-peer: #ffffff;
  --border: rgba(9,41,25,.12);
  --shadow: 0 24px 70px rgba(8,54,32,.18);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Segoe UI, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); overflow: hidden; }
.hidden { display: none !important; }
input, button, textarea { font: inherit; }
button { border: 0; color: var(--text); cursor: pointer; background: linear-gradient(135deg, var(--primary), var(--primary-strong)); border-radius: 10px; font-weight: 850; transition: transform .16s ease, filter .16s ease, opacity .16s ease, background .16s ease; }
button:hover { transform: translateY(-1px); filter: brightness(1.08); }
button:active { transform: translateY(0) scale(.99); }
button.ghost { background: #09120d; color: var(--muted); border: 1px solid var(--border); }
.danger { background: var(--danger) !important; }
.loading { opacity: .64; pointer-events: none; }
.no-animations *, .no-animations *::before, .no-animations *::after { animation: none !important; transition: none !important; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 18% 16%, rgba(15,143,90,.28), transparent 30%), radial-gradient(circle at 80% 86%, rgba(139,234,120,.12), transparent 34%), var(--bg); }
.auth-panel { width: min(440px, calc(100vw - 32px)); display: grid; gap: 12px; padding: 30px; background: rgba(13,24,19,.92); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(18px); animation: panelIn .35s ease both; }
.brand-mark { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(135deg, var(--primary), #073d2a); color: white; font-size: 30px; font-weight: 950; box-shadow: 0 16px 40px rgba(15,143,90,.28); }
.eyebrow { color: var(--accent); margin: 0 0 4px; font-weight: 900; }
h1 { margin: 0 0 10px; font-size: 28px; }
.auth-copy { margin: -4px 0 6px; color: var(--muted); font-weight: 700; line-height: 1.35; }
.auth-panel input, .search-box input, #messageInput { border: 0; outline: 0; color: var(--text); background: transparent; }
.auth-panel input { height: 48px; padding: 0 14px; border-radius: 10px; background: #07120d; border: 1px solid var(--border); transition: border .18s ease, box-shadow .18s ease, transform .18s ease; }
.auth-panel input:focus { border-color: rgba(156,255,135,.52); box-shadow: 0 0 0 4px rgba(15,143,90,.14); transform: translateY(-1px); }
.auth-panel button { height: 46px; }
.error { color: #ff8d8d; min-height: 20px; margin: 0; font-weight: 800; }

.messenger { height: 100vh; display: grid; grid-template-columns: 380px 1fr; background: var(--bg); }
.sidebar { position: relative; margin: 16px 0 16px 20px; padding: 10px; border-radius: 14px; background: rgba(13,24,19,.94); border: 1px solid var(--border); box-shadow: 0 18px 60px rgba(0,0,0,.28); overflow: hidden; display: flex; flex-direction: column; min-width: 0; animation: slideInLeft .28s ease both; }
.side-top { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; padding: 0 0 8px; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; background: transparent; color: var(--muted); border-radius: 999px; font-size: 20px; }
.icon-btn:hover { background: rgba(255,255,255,.07); color: white; }
.search-box { height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 999px; background: #07120d; border: 1px solid rgba(255,255,255,.05); color: var(--muted); transition: border .18s ease, box-shadow .18s ease; }
.search-box:focus-within { border-color: rgba(156,255,135,.34); box-shadow: 0 0 0 4px rgba(15,143,90,.1); }
.search-box input { width: 100%; font-size: 16px; }
.notice { text-align: left; display: grid; gap: 4px; padding: 14px 16px; background: linear-gradient(135deg, rgba(15,143,90,.18), rgba(139,234,120,.08)); border: 1px solid rgba(156,255,135,.12); border-radius: 12px; margin-bottom: 8px; }
.notice span { color: var(--muted); font-weight: 600; }
.chat-list, .contacts { overflow: auto; scrollbar-width: thin; scrollbar-color: #235c3e transparent; }
.chat-list { max-height: 310px; }
.chat-item, .contact-item { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; min-height: 64px; padding: 9px; border-radius: 12px; color: inherit; transition: background .16s ease; }
.chat-item:hover, .contact-item:hover { background: rgba(255,255,255,.05); }
.chat-item.active { background: linear-gradient(135deg, var(--primary), #126c48); }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: white; background: linear-gradient(135deg, var(--primary), var(--secondary)); font-weight: 900; overflow: hidden; }
.avatar.big { width: 86px; height: 86px; font-size: 30px; margin: 0 auto; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.item-main { min-width: 0; }
.item-main strong, .item-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main span, .item-meta { color: var(--muted); font-size: 13px; font-weight: 700; }
.chat-item.active .item-main span, .chat-item.active .item-meta { color: rgba(255,255,255,.82); }
.contacts-title { color: var(--accent); font-weight: 900; margin: 10px 8px 6px; padding-top: 12px; border-top: 1px solid #0a120e; }
.compose-fab { position: absolute; right: 20px; bottom: 20px; width: 56px; height: 56px; border-radius: 50%; font-size: 24px; box-shadow: 0 16px 38px rgba(15,143,90,.26); }
.compose-fab.open { transform: rotate(45deg); }
.compose-menu { position: fixed; left: 178px; bottom: 82px; z-index: 18; width: 202px; padding: 8px; border-radius: 14px; background: rgba(28,31,29,.98); border: 1px solid rgba(255,255,255,.07); box-shadow: 0 18px 48px rgba(0,0,0,.42); display: grid; gap: 2px; animation: menuPop .18s cubic-bezier(.2,.9,.2,1) both; }
.compose-menu button { min-height: 38px; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: center; padding: 7px 10px; background: transparent; border-radius: 9px; text-align: left; }
.compose-menu button:hover { background: rgba(255,255,255,.07); transform: none; filter: none; }
.compose-menu span { color: var(--accent); text-align: center; font-size: 18px; }

.chat-pane { position: relative; min-width: 0; background-color: var(--bg); background-image: linear-gradient(rgba(2,11,8,.08), rgba(2,11,8,.08)), radial-gradient(circle at 20px 20px, rgba(15,143,90,.18) 1px, transparent 1.5px), radial-gradient(circle at 50px 55px, rgba(139,234,120,.1) 1px, transparent 1.5px); background-size: auto, 74px 74px, 74px 74px; overflow: hidden; }
.chat-header { position: absolute; top: 16px; left: min(420px, 26%); right: 24px; max-width: 760px; height: 64px; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 12px; background: rgba(13,24,19,.94); border: 1px solid var(--border); border-radius: 999px; z-index: 3; box-shadow: 0 10px 30px rgba(0,0,0,.28); backdrop-filter: blur(14px); animation: dropIn .25s ease both; }
.chat-header-actions { position: relative; display: flex; align-items: center; gap: 4px; justify-self: end; }
.chat-actions-menu { position: absolute; right: 12px; top: 58px; width: 210px; padding: 6px; border-radius: 12px; background: rgba(28,31,29,.98); border: 1px solid rgba(255,255,255,.07); box-shadow: 0 18px 48px rgba(0,0,0,.42); display: grid; gap: 2px; animation: menuPop .16s ease both; }
.chat-actions-menu button { min-height: 38px; padding: 0 12px; border-radius: 8px; background: transparent; text-align: left; }
.chat-actions-menu button:hover { background: rgba(255,255,255,.07); transform: none; filter: none; }
.chat-actions-menu .danger-text { color: #ffb0b0; }
.chat-search-panel { position: absolute; top: 86px; left: min(420px, 26%); right: 24px; max-width: 640px; height: 48px; z-index: 4; display: grid; grid-template-columns: 1fr auto 34px 34px 34px; gap: 6px; align-items: center; padding: 5px; border-radius: 999px; background: rgba(13,24,19,.96); border: 1px solid var(--border); box-shadow: 0 12px 34px rgba(0,0,0,.32); animation: dropIn .18s ease both; }
.chat-search-panel input { min-width: 0; height: 38px; padding: 0 12px; border: 0; outline: 0; border-radius: 999px; color: var(--text); background: #07120d; }
.chat-search-panel span { color: var(--muted); font-weight: 850; min-width: 44px; text-align: center; }
.chat-search-panel button, .reply-preview button { height: 34px; min-width: 34px; border-radius: 999px; background: transparent; color: var(--muted); }
.header-copy { min-width: 0; }
.header-copy strong, .header-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-copy span { color: var(--muted); font-size: 13px; }
.empty-state { height: 100%; display: grid; place-items: center; color: var(--muted); font-weight: 800; }
.empty-card { display: grid; justify-items: center; gap: 10px; max-width: 320px; text-align: center; padding: 24px; color: var(--muted); animation: fadeUp .28s ease both; }
.empty-card strong { color: var(--text); font-size: 22px; }
.empty-logo { width: 74px; height: 74px; display: grid; place-items: center; border-radius: 24px; color: white; background: linear-gradient(135deg, var(--primary), #073d2a); font-size: 34px; font-weight: 950; box-shadow: 0 18px 48px rgba(15,143,90,.24); }
.messages { height: 100%; overflow: auto; padding: 98px 24px 86px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: min(540px, 74%); padding: 9px 11px; border-radius: 14px 14px 14px 5px; background: var(--message-peer); align-self: flex-start; box-shadow: 0 2px 0 rgba(0,0,0,.18); animation: messageIn .18s ease both; }
.bubble.me { background: linear-gradient(135deg, var(--message-me), #12764d); border-radius: 14px 14px 5px 14px; align-self: flex-end; }
.bubble.search-hit { outline: 2px solid var(--accent); }
.bubble mark { border-radius: 4px; padding: 0 2px; color: #06110c; background: var(--accent); }
.reply-chip { margin-bottom: 6px; padding: 5px 8px; border-left: 3px solid var(--accent); border-radius: 8px; background: rgba(0,0,0,.16); color: rgba(255,255,255,.8); font-size: 12px; font-weight: 800; }
.edited-label { color: rgba(255,255,255,.58); font-size: 11px; margin-left: 5px; }
.bubble .name { color: var(--accent); font-size: 12px; font-weight: 900; margin-bottom: 3px; }
.bubble .time { color: rgba(255,255,255,.68); font-size: 11px; text-align: right; margin-left: 10px; }
.bubble-row { display: flex; align-items: flex-end; gap: 6px; }
.delete-message { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.22); color: rgba(255,255,255,.8); opacity: 0; transition: opacity .16s ease, background .16s ease; }
.bubble:hover .delete-message { opacity: 1; }
.delete-message:hover { background: var(--danger); color: #fff; }
.composer { position: absolute; left: min(420px, 26%); right: 24px; bottom: 16px; max-width: 700px; height: 54px; display: grid; grid-template-columns: 46px 1fr 46px 46px; align-items: center; gap: 4px; padding: 4px; background: rgba(13,24,19,.94); border: 1px solid var(--border); border-radius: 999px; z-index: 3; box-shadow: 0 14px 40px rgba(0,0,0,.3); backdrop-filter: blur(14px); animation: riseIn .24s ease both; }
.reply-preview { position: absolute; left: min(420px, 26%); right: 24px; bottom: 76px; max-width: 700px; min-height: 48px; z-index: 3; display: grid; grid-template-columns: 1fr 40px; gap: 8px; align-items: center; padding: 8px 10px 8px 14px; border-radius: 16px; background: rgba(13,24,19,.96); border: 1px solid var(--border); box-shadow: 0 14px 40px rgba(0,0,0,.26); }
.reply-preview strong, .reply-preview span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-preview strong { color: var(--accent); font-size: 12px; }
.reply-preview span { color: var(--muted); font-weight: 750; }
.message-context-menu { position: fixed; z-index: 80; width: 168px; padding: 6px; border-radius: 12px; background: rgba(28,31,29,.98); border: 1px solid rgba(255,255,255,.07); box-shadow: 0 18px 48px rgba(0,0,0,.42); display: grid; gap: 2px; animation: menuPop .12s ease both; }
.message-context-menu button { min-height: 36px; padding: 0 12px; background: transparent; border-radius: 8px; text-align: left; }
.message-context-menu button:hover { background: rgba(255,255,255,.07); transform: none; filter: none; }
.message-context-menu .danger-text { color: #ffb0b0; }
.message-media { display: block; width: min(320px, 64vw); max-height: 340px; object-fit: cover; border-radius: 12px; background: rgba(0,0,0,.24); }
.message-audio { width: min(310px, 64vw); max-width: 100%; display: block; }
.media-link { display: block; color: inherit; }
.bubble small { display: block; margin-top: 6px; color: rgba(237,247,241,.76); font-weight: 750; }
.document-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.08); color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.document-chip:hover { background: rgba(255,255,255,.12); }
#messageInput { height: 44px; font-size: 16px; }
.send-btn { width: 46px; height: 46px; border-radius: 50%; font-size: 18px; }

.call-modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(0,0,0,.62); backdrop-filter: blur(6px); }
.call-card { width: 320px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; text-align: center; box-shadow: 0 20px 80px rgba(0,0,0,.5); animation: callPulse .34s ease both; }
.call-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.call-actions button, .compact { height: 44px; padding: 0 14px; }
.active-call { position: fixed; top: 92px; right: 24px; z-index: 7; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; background: rgba(13,24,19,.96); border: 1px solid var(--border); border-radius: 999px; box-shadow: 0 12px 40px rgba(0,0,0,.35); animation: dropIn .22s ease both; }

.peer-profile-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; width: min(360px, calc(100vw - 32px)); z-index: 8; overflow: auto; border-radius: 18px; background: rgba(13,24,19,.97); border: 1px solid var(--border); box-shadow: 0 24px 80px rgba(0,0,0,.48); animation: slideInRight .2s cubic-bezier(.2,.9,.2,1) both; }
.peer-profile-panel header { position: sticky; top: 0; z-index: 2; min-height: 56px; display: grid; grid-template-columns: 42px 1fr; gap: 8px; align-items: center; padding: 8px 12px; background: rgba(13,24,19,.96); backdrop-filter: blur(12px); }
.peer-profile-panel header strong { font-size: 20px; }
.peer-profile-hero { display: grid; justify-items: center; gap: 7px; padding: 24px 18px; text-align: center; }
.peer-profile-hero h2, .peer-profile-hero p { margin: 0; }
.peer-profile-hero p { color: var(--muted); font-weight: 750; }
.peer-profile-card { margin: 0 14px 14px; overflow: hidden; border-radius: 16px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.055); }
.peer-profile-card div, .peer-profile-card button { width: 100%; min-height: 56px; display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center; padding: 9px 14px; color: var(--text); background: transparent; border-bottom: 1px solid rgba(255,255,255,.055); text-align: left; }
.peer-profile-card div:last-child, .peer-profile-card button:last-child { border-bottom: 0; }
.peer-profile-card span { color: var(--accent); text-align: center; font-size: 20px; }
.peer-profile-card strong, .peer-profile-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-profile-card small { color: var(--muted); font-weight: 750; }
.peer-card-title { min-height: 38px !important; display: block !important; padding: 14px 14px 4px !important; color: #a78bfa !important; font-weight: 900; border-bottom: 0 !important; }
.peer-members-list { display: grid; padding: 4px 8px 10px; }
.peer-member-row { min-height: 46px; display: grid; grid-template-columns: 36px 1fr auto; gap: 9px; align-items: center; padding: 6px; border-radius: 10px; }
.peer-member-row:hover { background: rgba(255,255,255,.055); }
.peer-member-row strong, .peer-member-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-member-row small { color: var(--muted); font-weight: 750; }
.peer-member-row i { color: var(--accent); font-size: 11px; font-style: normal; font-weight: 900; }
.peer-media-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0 14px 12px; padding: 4px; border-radius: 999px; background: rgba(255,255,255,.045); }
.peer-media-tabs button { min-height: 34px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 12px; }
.peer-media-tabs button.active { background: var(--primary); color: #fff; }
.peer-media-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 14px 18px; }
.peer-media-list img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.peer-media-file { grid-column: 1 / -1; display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); color: var(--text); text-decoration: none; }
.peer-media-file small { color: var(--muted); font-weight: 750; }

.menu-overlay { position: fixed; inset: 0; z-index: 20; background: transparent; animation: fadeIn .12s ease both; }
.side-menu { position: fixed; left: 30px; top: 66px; width: 236px; z-index: 21; padding: 6px; border-radius: 12px; background: rgba(28,31,29,.98); border: 1px solid rgba(255,255,255,.07); box-shadow: 0 18px 48px rgba(0,0,0,.42); display: grid; gap: 2px; animation: menuPop .18s cubic-bezier(.2,.9,.2,1) both; }
.menu-user-row, .menu-item, .menu-more-panel button { min-height: 36px; display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 6px 10px; text-align: left; background: transparent; border-radius: 8px; border: 0; color: var(--text); font-weight: 850; }
.menu-user-row { grid-template-columns: 34px 1fr; min-height: 44px; }
.menu-avatar { width: 30px; height: 30px; font-size: 13px; border: 2px solid rgba(156,255,135,.35); }
.menu-item span, .menu-more-panel span { color: rgba(237,247,241,.82); font-size: 20px; text-align: center; }
.menu-item i { color: var(--muted); font-style: normal; font-size: 24px; }
.menu-user-row:hover, .menu-item:hover, .menu-more-panel button:hover { background: rgba(255,255,255,.07); transform: none; filter: none; }
.menu-accounts { display: grid; gap: 2px; }
.menu-account-row { width: 100%; min-height: 46px; display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; background: transparent; color: var(--text); text-align: left; }
.menu-account-row:hover { background: rgba(255,255,255,.07); transform: none; filter: none; }
.menu-account-row span:last-child { min-width: 0; }
.menu-account-row strong, .menu-account-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-account-row small { color: var(--muted); font-weight: 750; }
.avatar.mini { width: 30px; height: 30px; font-size: 12px; }
.menu-separator { height: 1px; margin: 3px -6px; background: rgba(255,255,255,.07); }
.side-menu .danger { color: #ffb0b0; background: transparent !important; }
.menu-more-panel { position: absolute; left: calc(100% - 8px); top: 214px; width: 254px; padding: 6px; border-radius: 12px; background: rgba(28,31,29,.98); border: 1px solid rgba(255,255,255,.07); box-shadow: 0 18px 48px rgba(0,0,0,.42); display: grid; gap: 2px; animation: menuPop .16s cubic-bezier(.2,.9,.2,1) both; }
.menu-more-panel button { grid-template-columns: 28px 1fr; }
.menu-more-panel small { padding: 8px 12px 6px 48px; color: var(--muted); font-weight: 800; }

.settings-panel { position: fixed; left: 20px; top: 16px; bottom: 16px; width: 360px; z-index: 22; overflow: auto; border-radius: 16px; background: rgba(13,24,19,.96); border: 1px solid var(--border); box-shadow: 0 24px 80px rgba(0,0,0,.48); animation: slideInLeft .22s cubic-bezier(.2,.9,.2,1) both; }
.settings-header { position: sticky; top: 0; z-index: 2; height: 58px; display: grid; grid-template-columns: 44px 1fr 38px 38px 38px; gap: 6px; align-items: center; padding: 8px 12px; background: rgba(13,24,19,.96); backdrop-filter: blur(12px); }
.settings-header strong { font-size: 20px; }
.settings-profile { display: grid; justify-items: center; gap: 7px; padding: 24px 20px 28px; }
.settings-avatar { width: 108px; height: 108px; font-size: 42px; background: linear-gradient(135deg, #0f8f5a, #e95f94); box-shadow: 0 18px 44px rgba(0,0,0,.34); }
.settings-profile h2 { margin: 8px 0 0; font-size: 20px; }
.settings-profile p { margin: 0; color: var(--muted); font-weight: 750; }
.settings-card { margin: 0 16px 14px; overflow: hidden; border-radius: 18px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.055); }
.settings-row, .settings-card button { width: 100%; min-height: 58px; display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; padding: 9px 16px; color: var(--text); background: transparent; border-radius: 0; border-bottom: 1px solid rgba(255,255,255,.055); text-align: left; font-weight: 850; }
.settings-row:last-child, .settings-card button:last-child { border-bottom: 0; }
.settings-row > span, .settings-card button > span { color: rgba(237,247,241,.72); font-size: 22px; text-align: center; }
.settings-row strong, .settings-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-row small { margin-top: 4px; color: var(--muted); font-weight: 750; }
.settings-card button:hover { background: rgba(255,255,255,.055); transform: none; filter: none; }
.settings-card button em { color: var(--muted); font-style: normal; font-weight: 800; }
.settings-dots-menu { position: absolute; right: 10px; top: 50px; width: 134px; padding: 6px; border-radius: 12px; background: rgba(28,31,29,.98); border: 1px solid rgba(255,255,255,.07); box-shadow: 0 18px 48px rgba(0,0,0,.42); animation: menuPop .16s ease both; }
.settings-dots-menu button { width: 100%; min-height: 38px; padding: 0 12px; background: transparent; color: #ffb0b0; text-align: left; border-radius: 8px; }
.settings-dots-menu button:hover { background: rgba(255,255,255,.07); transform: none; filter: none; }
.settings-header.compact { grid-template-columns: 44px 1fr; }
.panel-search { height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 999px; background: #171c19; border: 2px solid rgba(156,131,255,.78); color: #a78bfa; }
.panel-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-weight: 750; }
.panel-list { display: grid; padding: 10px 8px 84px; }
.panel-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; min-height: 60px; padding: 8px 10px; border-radius: 12px; cursor: pointer; transition: background .16s ease, transform .16s ease; }
.panel-item:hover, .panel-item.active { background: rgba(255,255,255,.06); transform: translateX(2px); }
.panel-item strong, .panel-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-item span { color: var(--muted); font-weight: 750; }
.pin-mark { color: var(--accent); font-size: 10px; font-style: normal; margin-left: 5px; vertical-align: 1px; }
.panel-fab { position: absolute; right: 20px; bottom: 22px; width: 56px; height: 56px; border-radius: 50%; font-size: 28px; box-shadow: 0 16px 38px rgba(15,143,90,.26); }
.notify-section { margin: 16px 16px 0; padding: 18px; border-radius: 18px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.055); display: grid; gap: 14px; }
.notify-section h3 { margin: 0 0 6px; color: #a78bfa; font-size: 16px; }
.notify-note { margin: 10px 28px; color: var(--muted); line-height: 1.28; font-weight: 750; }
.toggle-row, .range-row, .select-row { min-height: 34px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; color: var(--text); font-weight: 850; }
.toggle-row input { display: none; }
.toggle-row span { width: 36px; height: 20px; border-radius: 999px; background: #3a413d; position: relative; transition: background .16s ease; }
.toggle-row span::after { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: #97a49d; transition: transform .16s ease, background .16s ease; }
.toggle-row input:checked + span { background: #8b6ff0; }
.toggle-row input:checked + span::after { transform: translateX(16px); background: #151515; }
.range-row em, .select-row em { color: var(--muted); font-style: normal; font-weight: 850; }
.range-row input { grid-column: 1 / -1; accent-color: #8b6ff0; }
.notify-enable { height: 42px; background: transparent; color: #a78bfa; text-align: left; padding: 0 4px; }
.danger-text { color: #ffb0b0 !important; }
.settings-line, .privacy-row { min-height: 54px; display: grid; gap: 3px; padding: 8px 0; background: transparent; color: var(--text); text-align: left; border-radius: 10px; }
.settings-line:hover, .privacy-row:hover { background: rgba(255,255,255,.055); transform: none; filter: none; }
.settings-line strong, .settings-line small, .privacy-row strong, .privacy-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-line small, .privacy-row small { color: var(--muted); font-weight: 750; }
.cache-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.cache-head button { background: transparent; color: #a78bfa; font-weight: 900; }
.cache-row { min-height: 42px; display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; }
.cache-row span { color: rgba(237,247,241,.7); font-size: 22px; text-align: center; }
.cache-row small { color: var(--muted); font-weight: 750; }
.theme-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-swatch { height: 72px; border-radius: 18px; border: 2px solid transparent; background: radial-gradient(circle at 24% 18%, rgba(156,255,135,.18), transparent 28%), #06110c; color: white; font-size: 24px; }
.theme-swatch:nth-child(2) { background: radial-gradient(circle at 70% 20%, rgba(156,255,135,.22), transparent 30%), #080d09; }
.theme-swatch:nth-child(3) { background: radial-gradient(circle at 70% 20%, rgba(83,155,210,.24), transparent 30%), #071018; }
.theme-swatch:nth-child(4) { background: radial-gradient(circle at 70% 20%, rgba(118,180,222,.28), transparent 30%), #08131a; }
.theme-swatch.active { border-color: #8b6ff0; box-shadow: 0 0 0 2px rgba(139,111,240,.18); }
.radio-row { min-height: 42px; display: grid; grid-template-columns: 44px 1fr; align-items: center; color: var(--text); font-weight: 850; }
.radio-row input { width: 22px; height: 22px; accent-color: #8b6ff0; }
.radio-row small { display: block; grid-column: 2; color: var(--muted); font-weight: 750; }
body.light-theme .sidebar,
body.light-theme .settings-panel,
body.light-theme .profile-card { background: rgba(255,255,255,.94); }
body.light-theme .side-menu,
body.light-theme .menu-more-panel,
body.light-theme .compose-menu,
body.light-theme .settings-dots-menu,
body.light-theme .chat-actions-menu { background: rgba(255,255,255,.98); border-color: rgba(9,41,25,.12); }
body.light-theme .chat-pane { background-color: var(--bg); }
body.light-theme .profile-grid input,
body.light-theme .profile-grid textarea,
body.light-theme .auth-panel input,
body.light-theme .search-box,
body.light-theme .panel-search { background: #f7fbf8; }
body.light-theme .settings-card,
body.light-theme .profile-info-card,
body.light-theme .notify-section { background: rgba(9,41,25,.045); border-color: rgba(9,41,25,.08); }

.profile-backdrop { position: fixed; inset: 0; z-index: 52; display: grid; place-items: center; padding: 22px; background: rgba(0,0,0,.62); backdrop-filter: blur(8px); animation: fadeIn .16s ease both; }
.profile-card { position: relative; width: min(640px, 100%); max-height: calc(100vh - 44px); overflow: auto; display: grid; gap: 14px; padding: 0 18px 18px; border-radius: 20px; background: linear-gradient(145deg, rgba(13,24,19,.98), rgba(7,18,13,.98)); border: 1px solid rgba(156,255,135,.13); box-shadow: var(--shadow); animation: panelIn .22s ease both; }
.profile-close { position: absolute; top: 12px; right: 12px; z-index: 3; font-size: 26px; background: rgba(0,0,0,.24); color: white; }
.profile-hero { position: relative; min-height: 260px; display: grid; place-items: end center; margin: 0 -18px; padding: 34px 18px 22px; overflow: hidden; border-radius: 20px 20px 0 0; background: linear-gradient(145deg, #123d2a, #050706); }
.profile-banner-pattern { position: absolute; inset: 0; opacity: .72; background-image: linear-gradient(115deg, transparent 0 44%, rgba(156,255,135,.13) 44% 45%, transparent 45% 100%), radial-gradient(circle at 22% 18%, rgba(63,194,106,.28), transparent 28%), radial-gradient(circle at 84% 0%, rgba(156,255,135,.14), transparent 32%); background-size: 54px 54px, auto, auto; }
.profile-avatar-wrap { position: relative; z-index: 1; display: grid; justify-items: center; cursor: pointer; }
.profile-avatar-wrap input, .profile-action input { display: none; }
.profile-avatar-wrap .avatar { width: 92px; height: 92px; font-size: 32px; border: 4px solid rgba(237,247,241,.92); box-shadow: 0 18px 42px rgba(0,0,0,.38); transition: transform .18s ease, filter .18s ease; }
.profile-avatar-wrap:hover .avatar { transform: translateY(-2px) scale(1.02); filter: brightness(1.08); }
.profile-title-block { position: relative; z-index: 1; display: grid; justify-items: center; gap: 4px; text-align: center; }
.profile-title-block h2 { margin: 0; max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 24px; }
.profile-title-block p { margin: 0; color: var(--accent); font-weight: 900; }
.profile-title-block span { color: rgba(237,247,241,.72); font-size: 13px; font-weight: 750; }
.profile-quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 2px; }
.profile-action { min-height: 66px; display: grid; justify-items: center; align-content: center; gap: 5px; border-radius: 14px; color: var(--text); background: #101613; border: 1px solid var(--border); cursor: pointer; transition: transform .16s ease, background .16s ease; }
.profile-action:hover { transform: translateY(-1px); background: #16251d; }
.profile-action span { color: var(--accent); font-size: 20px; line-height: 1; }
.profile-action strong { font-size: 13px; }
.profile-info-card { display: grid; border-radius: 14px; background: #101613; border: 1px solid var(--border); overflow: hidden; }
.profile-info-row { display: grid; grid-template-columns: 42px 1fr; gap: 10px; align-items: center; min-height: 58px; padding: 8px 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
.profile-info-row:last-child { border-bottom: 0; }
.profile-info-row > span { color: var(--accent); font-size: 20px; text-align: center; font-weight: 900; }
.profile-info-row strong, .profile-info-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-info-row small { margin-top: 3px; color: var(--muted); font-weight: 750; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.profile-grid label { display: grid; gap: 7px; color: var(--muted); font-weight: 850; }
.profile-grid label.wide { grid-column: 1 / -1; }
.profile-grid input, .profile-grid textarea { width: 100%; min-height: 46px; padding: 11px 12px; border-radius: 12px; color: var(--text); background: #07120d; border: 1px solid var(--border); outline: 0; resize: vertical; transition: border .18s ease, box-shadow .18s ease, transform .18s ease; }
.profile-grid textarea { min-height: 92px; line-height: 1.35; }
.profile-grid input:focus, .profile-grid textarea:focus { border-color: rgba(156,255,135,.52); box-shadow: 0 0 0 4px rgba(15,143,90,.14); transform: translateY(-1px); }
.profile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-actions button { height: 46px; }

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 10px; pointer-events: none; }
.toast { min-width: 260px; max-width: 360px; padding: 12px 14px; border-radius: 12px; background: rgba(13,24,19,.96); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow); animation: toastIn .22s ease both; }
.toast strong { display: block; margin-bottom: 2px; }
.toast span { color: var(--muted); font-weight: 700; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.58); backdrop-filter: blur(7px); animation: fadeIn .16s ease both; }
.dialog-card { width: min(430px, 100%); display: grid; gap: 12px; padding: 20px; border-radius: 16px; background: rgba(13,24,19,.98); border: 1px solid var(--border); box-shadow: var(--shadow); animation: panelIn .22s ease both; }
.dialog-card h2 { margin: 0; }
.dialog-card p { margin: 0; color: var(--muted); font-weight: 700; line-height: 1.4; }
.dialog-fields { display: grid; gap: 10px; }
.dialog-fields label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; }
.dialog-fields input, .dialog-fields textarea { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; color: var(--text); background: #07120d; border: 1px solid var(--border); outline: 0; resize: vertical; }
.dialog-fields input:focus, .dialog-fields textarea:focus { border-color: rgba(156,255,135,.52); box-shadow: 0 0 0 4px rgba(15,143,90,.14); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes messageIn { from { opacity: 0; transform: translateY(5px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes callPulse { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes menuPop { from { opacity: 0; transform: translateY(-6px) scale(.96); } to { opacity: 1; transform: none; } }

@media (max-width: 820px) {
  body { overflow: hidden; }
  .messenger { grid-template-columns: 1fr; }
  .sidebar { margin: 0; border-radius: 0; height: 100vh; }
  .chat-pane { display: none; }
  .messenger.chat-open .sidebar { display: none; }
  .messenger.chat-open .chat-pane { display: block; height: 100vh; }
  .chat-header, .composer, .chat-search-panel, .reply-preview { left: 10px; right: 10px; max-width: none; }
  .chat-search-panel { top: 76px; }
  .messages { padding-left: 10px; padding-right: 10px; }
  .side-menu { left: 10px; right: 10px; width: auto; top: 58px; }
  .menu-more-panel { position: static; width: auto; margin-top: 2px; }
  .compose-menu { left: auto; right: 76px; bottom: 80px; }
  .settings-panel { left: 0; top: 0; bottom: 0; width: min(390px, 100vw); border-radius: 0; }
  .peer-profile-panel { top: 0; right: 0; bottom: 0; width: min(390px, 100vw); border-radius: 0; }
  .profile-backdrop { padding: 10px; align-items: end; }
  .profile-card { max-height: calc(100vh - 20px); overflow: auto; border-radius: 18px 18px 0 0; }
  .profile-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding-right: 0; }
  .profile-grid, .profile-actions { grid-template-columns: 1fr; }
  .toast-host { left: 12px; right: 12px; }
  .toast { min-width: 0; max-width: none; }
}
