/* ═══════════════════════════════════════════
   ANGram v4 — Telegram-style UI
   ═══════════════════════════════════════════ */

/* ── EMOJI FIX — critical for mobile ── */
@font-face {
  font-family: 'EmojiFont';
  src: local('Apple Color Emoji'), local('Segoe UI Emoji'), local('Noto Color Emoji'), local('Android Emoji');
}

/* ── THEMES ── */
[data-theme="tg-dark"], :root {
  --bg:       #0e1621;
  --bg2:      #17212b;
  --bg3:      #1c2c3a;
  --bg4:      #242f3d;
  --surface:  #17212b;
  --surface2: #1c2c3a;
  --accent:   #5bacf4;
  --accent2:  #2b7cd6;
  --accent3:  #64d2ff;
  --text:     #ffffff;
  --text2:    #708899;
  --text3:    #4a6278;
  --msg-out:  #2b5278;
  --msg-in:   #182533;
  --border:   rgba(255,255,255,0.06);
  --shadow:   0 4px 24px rgba(0,0,0,0.5);
  --danger:   #f05555;
  --success:  #4dbe63;
  --warn:     #fbb813;
  --unread:   #4dbe63;
  --blue-link: #5bacf4;
}
[data-theme="tg-light"] {
  --bg:       #f4f4f5;
  --bg2:      #ffffff;
  --bg3:      #f0f0f1;
  --bg4:      #e3e3e5;
  --surface:  #ffffff;
  --surface2: #f4f4f5;
  --accent:   #2481cc;
  --accent2:  #1a6fbb;
  --accent3:  #0a84ff;
  --text:     #000000;
  --text2:    #6d6d72;
  --text3:    #a0a0a5;
  --msg-out:  #effdde;
  --msg-in:   #ffffff;
  --border:   rgba(0,0,0,0.08);
  --shadow:   0 2px 12px rgba(0,0,0,0.1);
  --danger:   #e53935;
  --success:  #43a047;
  --warn:     #f57c00;
  --unread:   #43a047;
  --blue-link: #2481cc;
}
[data-theme="dark"] {
  --bg:#0b0f1e; --bg2:#111827; --bg3:#1a2236; --bg4:#222d42;
  --surface:#16213a; --surface2:#1e2d4a;
  --accent:#00d4ff; --accent2:#0095b8; --accent3:#00ffd0;
  --text:#e8eaf6; --text2:#8899bb; --text3:#5566aa;
  --msg-out:#0f3460; --msg-in:#1a2236;
  --border:rgba(0,212,255,0.1); --shadow:0 4px 32px rgba(0,0,0,0.6);
  --danger:#ff4d6d; --success:#00e676; --warn:#ffb300;
  --unread:#00e676; --blue-link:#00d4ff;
}
[data-theme="midnight"] {
  --bg:#070711; --bg2:#0d0d1a; --bg3:#13132a; --bg4:#1a1a36;
  --surface:#0f0f20; --surface2:#16163a;
  --accent:#7c5cfc; --accent2:#5a3ddd; --accent3:#c084fc;
  --text:#e2e0ff; --text2:#8880cc; --text3:#5550aa;
  --msg-out:#1e1060; --msg-in:#13132a;
  --border:rgba(124,92,252,0.12); --shadow:0 4px 32px rgba(0,0,0,0.8);
  --danger:#ff4466; --success:#44ee88; --warn:#ffcc00;
  --unread:#44ee88; --blue-link:#7c5cfc;
}
[data-theme="forest"] {
  --bg:#0a1612; --bg2:#0f1e18; --bg3:#162820; --bg4:#1e3328;
  --surface:#122018; --surface2:#1a2e22;
  --accent:#22dd88; --accent2:#17aa66; --accent3:#88ffcc;
  --text:#d4f0e8; --text2:#6aaa8a; --text3:#447766;
  --msg-out:#0e3022; --msg-in:#162820;
  --border:rgba(34,221,136,0.1); --shadow:0 4px 32px rgba(0,0,0,0.7);
  --danger:#ff5566; --success:#00ff88; --warn:#ffcc33;
  --unread:#00ff88; --blue-link:#22dd88;
}
[data-theme="sunset"] {
  --bg:#1a0a1e; --bg2:#220d28; --bg3:#2e1236; --bg4:#3a1844;
  --surface:#26102e; --surface2:#341840;
  --accent:#ff6eb4; --accent2:#dd44aa; --accent3:#ffaa55;
  --text:#fce8ff; --text2:#cc88bb; --text3:#996699;
  --msg-out:#3a0e40; --msg-in:#2e1236;
  --border:rgba(255,110,180,0.12); --shadow:0 4px 32px rgba(0,0,0,0.7);
  --danger:#ff4455; --success:#44ffaa; --warn:#ffcc00;
  --unread:#44ffaa; --blue-link:#ff6eb4;
}
[data-theme="ocean"] {
  --bg:#020e1a; --bg2:#041422; --bg3:#071c2e; --bg4:#0b2540;
  --surface:#05172a; --surface2:#091f38;
  --accent:#00b4d8; --accent2:#0077b6; --accent3:#48cae4;
  --text:#caf0f8; --text2:#5a9fb5; --text3:#3a7a99;
  --msg-out:#052244; --msg-in:#071c2e;
  --border:rgba(0,180,216,0.12); --shadow:0 4px 32px rgba(0,0,0,0.8);
  --danger:#ff4477; --success:#00ffbb; --warn:#ffcc33;
  --unread:#00ffbb; --blue-link:#00b4d8;
}

/* ── RESET ── */
*,*::before,*::after {
  box-sizing:border-box; margin:0; padding:0;
  touch-action:manipulation;
}
html,body {
  height:100%; overflow:hidden;
  background:var(--bg); color:var(--text);
  font-family:-apple-system,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;
  font-size:14px; line-height:1.5;
  -webkit-user-select:none; user-select:none;
  -webkit-touch-callout:none;
  overscroll-behavior:none;
}
/* Emoji rendering everywhere */
.emoji, .msg-text, .chat-name, .chat-last,
.msg-bubble span, .voice-dur, h1,h2,h3,h4,
.nav-btn span:first-child, .tab-btn,
.list-btn, .slide-nav a, button {
  font-family: -apple-system,'Segoe UI',Roboto,'Helvetica Neue',
    'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',
    'Android Emoji',sans-serif;
}
.msg-text, .message-input, input, textarea, [contenteditable] {
  -webkit-user-select:text; user-select:text;
  font-family: -apple-system,'Segoe UI',Roboto,'Helvetica Neue',
    'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
a { cursor:pointer; color:var(--blue-link); text-decoration:none; }
button {
  cursor:pointer; border:none; background:none; color:inherit;
  -webkit-tap-highlight-color:transparent;
  font-family:inherit;
}
input,textarea {
  -webkit-user-select:text; user-select:text;
  font-family:inherit; color:var(--text); background:none; border:none; outline:none;
}
input::placeholder { color:var(--text3); }
::-webkit-scrollbar { width:3px; height:3px; }
::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.1); border-radius:3px; }
.hidden { display:none !important; }

/* ── SVG ICON STYLES ── */
svg { display:inline-block; vertical-align:middle; flex-shrink:0; }
.menu-btn svg, .hdr-btn svg, .icon-btn svg,
.back-btn svg, .pw-toggle svg, .reply-preview button svg { 
  pointer-events:none; 
}
/* Nav icons */
.nav-btn .nav-icon svg { display:block; width:22px; height:22px; }
.nav-btn.active .nav-icon svg { stroke:var(--accent); }
.nav-btn .nav-icon svg { stroke:var(--text3); }
.slide-nav a svg { stroke:var(--text2); }
.slide-nav a:hover svg, .slide-nav a:active svg { stroke:var(--text); }
.logout-link svg { stroke:var(--danger) !important; }
/* Input bar icons */
.icon-btn svg { stroke:var(--text3); transition:stroke .15s; }
.icon-btn:hover svg, .icon-btn:active svg { stroke:var(--text); }
.send-btn svg { fill:white; stroke:none; }
.send-btn { display:none; }  /* show/hide via JS */
.voice-btn svg { stroke:var(--text2); }
.voice-btn:active svg { stroke:white; }
/* Context menu icons */
.ctx-icon svg { stroke:var(--text2); }
button.danger .ctx-icon svg { stroke:var(--danger); }
/* Splash & auth */
.splash-icon svg { stroke:var(--accent); animation:float 2s ease-in-out infinite; }
.auth-logo svg { stroke:var(--accent); animation:float 3s ease-in-out infinite; }
.placeholder-icon svg { stroke:var(--text3); }
/* Msg check — double tick */
.msg-check svg { stroke:var(--accent); }
/* Voice buttons */
.voice-play-btn svg { fill:white; }
/* Chat header */
.chat-header .icon-btn svg { stroke:var(--text2); }
/* Settings avatar overlay */
.avatar-overlay svg { stroke:white; }
/* Back button */
.back-btn svg { stroke:var(--accent); }
/* Close X buttons */
.modal-header button svg { stroke:var(--text2); }
.settings-header button svg, .info-panel-header button svg { stroke:var(--accent); }
/* Attach menu */
.attach-menu button { color:var(--text); }
/* Role menu buttons */
.admin-btns button { color:var(--text); }
/* Info action */
.info-action-btn { color:var(--text); }
.info-action-btn.danger { color:var(--danger); }
/* Gif btn */
.gif-btn { font-weight:700; font-size:12px; letter-spacing:-.5px; }


/* ── SPLASH ── */
.splash { position:fixed; inset:0; z-index:9999; background:var(--bg); display:flex; align-items:center; justify-content:center; animation:splashFade 0.4s ease 1.8s forwards; }
@keyframes splashFade { to{opacity:0;pointer-events:none;visibility:hidden} }
.splash-logo { text-align:center; animation:splashIn 0.5s cubic-bezier(.34,1.56,.64,1); }
@keyframes splashIn { from{scale:0.5;opacity:0} to{scale:1;opacity:1} }
.splash-icon { font-size:72px; animation:float 2s ease-in-out infinite;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
.splash-name { font-size:28px; font-weight:700; color:var(--accent); letter-spacing:1px; margin-top:10px; }

/* ── AUTH ── */
.screen { position:fixed; inset:0; z-index:100; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.auth-bg { position:fixed; inset:0; background:var(--bg); pointer-events:none; }
.auth-bg::after { content:''; position:absolute; inset:0; background:radial-gradient(ellipse at 30% 40%,rgba(91,172,244,.08),transparent 60%); }
.auth-container { position:relative; min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:24px 20px 40px; max-width:400px; margin:0 auto; }
.auth-header { text-align:center; margin-bottom:28px; }
.auth-logo { font-size:52px; display:block; margin-bottom:6px; animation:float 3s ease-in-out infinite;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.auth-title { font-size:28px; font-weight:700; color:var(--accent); }
.auth-sub { color:var(--text2); font-size:14px; margin-top:4px; }
.auth-form { width:100%; background:var(--surface); border-radius:16px; padding:24px 20px; border:1px solid var(--border); }
.auth-form h2 { font-size:20px; font-weight:600; margin-bottom:16px; }
.form-group { position:relative; margin-bottom:14px; }
.form-group input, .settings-input, .modal-input {
  width:100%; padding:13px 14px; background:var(--bg3);
  border:1px solid var(--border); border-radius:10px;
  font-size:15px; color:var(--text); transition:border-color .2s;
  -webkit-user-select:text; user-select:text;
}
.form-group input:focus,.settings-input:focus,.modal-input:focus { border-color:var(--accent); outline:none; }
.form-group label { position:absolute; left:14px; top:50%; transform:translateY(-50%); color:var(--text3); font-size:14px; pointer-events:none; transition:all .2s; }
.form-group input:not(:placeholder-shown)~label,
.form-group input:focus~label { top:2px; font-size:10px; background:var(--bg3); padding:0 4px; color:var(--accent); transform:none; border-radius:3px; }
.pw-group { position:relative; }
.pw-toggle { position:absolute; right:12px; top:50%; transform:translateY(-50%); font-size:18px; opacity:.5; z-index:2; padding:6px; min-width:36px; min-height:36px; display:flex; align-items:center; justify-content:center;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.form-error { color:var(--danger); font-size:13px; min-height:18px; margin-bottom:6px; }
.btn-primary {
  width:100%; padding:14px; background:var(--accent);
  color:#fff; font-size:15px; font-weight:600; border-radius:10px;
  border:none; cursor:pointer; transition:filter .15s;
  min-height:48px; display:flex; align-items:center; justify-content:center;
  -webkit-tap-highlight-color:transparent;
}
.btn-primary:active { filter:brightness(.85); }
.btn-secondary {
  padding:12px 18px; background:var(--bg3); color:var(--text);
  border:1px solid var(--border); border-radius:10px; font-size:14px;
  min-height:44px; -webkit-tap-highlight-color:transparent;
}
.btn-secondary:active { background:var(--bg4); }
.auth-switch { text-align:center; margin-top:14px; font-size:13px; color:var(--text2); }
.auth-switch a { color:var(--accent); padding:4px; -webkit-tap-highlight-color:transparent; }

/* ═══════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════ */
#app { display:flex; height:100%; height:100dvh; overflow:hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width:360px; flex-shrink:0;
  background:var(--bg2);
  display:flex; flex-direction:column;
  height:100%; height:100dvh;
  border-right:1px solid var(--border);
  position:relative; z-index:10;
}
.sidebar-header {
  display:flex; align-items:center; gap:6px;
  padding:8px 10px;
  background:var(--bg2);
  border-bottom:1px solid var(--border);
  flex-shrink:0; min-height:54px;
}
.menu-btn {
  width:40px; height:40px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:20px; flex-shrink:0; color:var(--text2);
  -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji',sans-serif;
}
.menu-btn:active { background:var(--bg3); }
.search-bar {
  flex:1; display:flex; align-items:center; gap:8px;
  background:var(--bg3); border-radius:20px; padding:7px 12px;
  border:1px solid transparent; min-height:36px;
}
.search-bar:focus-within { border-color:var(--accent); }
.search-bar span { color:var(--text3); font-size:15px; flex-shrink:0;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.search-bar input { background:none; flex:1; font-size:14px; -webkit-user-select:text; user-select:text; }
.hdr-btn {
  width:36px; height:36px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:18px; color:var(--text2); flex-shrink:0;
  -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.hdr-btn:active { background:var(--bg3); color:var(--accent); }

/* Tabs */
.section-tabs { display:flex; border-bottom:1px solid var(--border); background:var(--bg2); flex-shrink:0; overflow-x:auto; }
.section-tabs::-webkit-scrollbar { display:none; }
.tab-btn {
  flex:1; min-width:50px; padding:10px 6px;
  font-size:13px; font-weight:500; color:var(--text2);
  border-bottom:2px solid transparent;
  white-space:nowrap; min-height:42px;
  -webkit-tap-highlight-color:transparent;
}
.tab-btn.active { color:var(--accent); border-bottom-color:var(--accent); font-weight:600; }
.tab-btn:active { background:var(--bg3); }

/* ── CHAT LIST ── */
.chat-list {
  flex:1; overflow-y:auto; overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  position:relative; z-index:1;
}
.chat-item {
  display:flex; align-items:center; gap:10px;
  padding:8px 10px;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  width:100%; min-height:68px;
  border-bottom:1px solid var(--border);
  -webkit-user-select:none; user-select:none;
  touch-action:manipulation;
  transition:background .1s;
  position:relative;
}
.chat-item:active, .chat-item.tapping { background:var(--bg3) !important; }
.chat-item.active { background:var(--surface2); }

/* Avatar — TG style */
.chat-avatar {
  width:50px; height:50px; border-radius:50%;
  background:linear-gradient(135deg,var(--accent2),var(--accent3));
  display:flex; align-items:center; justify-content:center;
  font-size:20px; font-weight:600; color:#fff;
  flex-shrink:0; overflow:hidden; pointer-events:none;
  font-family:-apple-system,sans-serif;
}
.chat-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; pointer-events:none; }
.chat-avatar.av-blue   { background:linear-gradient(135deg,#2b5fcc,#5bacf4); }
.chat-avatar.av-green  { background:linear-gradient(135deg,#0da969,#4dbe63); }
.chat-avatar.av-orange { background:linear-gradient(135deg,#e8700a,#f0a732); }
.chat-avatar.av-red    { background:linear-gradient(135deg,#cc2929,#f05555); }
.chat-avatar.av-purple { background:linear-gradient(135deg,#7b3fcc,#c084fc); }
.chat-avatar.av-teal   { background:linear-gradient(135deg,#0da5a5,#4acfcf); }
.chat-avatar.av-pink   { background:linear-gradient(135deg,#c2266a,#f06aba); }

.chat-info { flex:1; min-width:0; pointer-events:none; }
.chat-name-row { display:flex; align-items:center; justify-content:space-between; gap:6px; margin-bottom:3px; }
.chat-name { font-weight:600; font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; }
.chat-time { font-size:12px; color:var(--text2); white-space:nowrap; flex-shrink:0; }
.chat-bottom-row { display:flex; align-items:center; justify-content:space-between; gap:6px; }
.chat-last { font-size:14px; color:var(--text2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; }
/* Unread badge — TG green circle */
.unread-badge {
  background:var(--unread); color:#fff;
  border-radius:12px; padding:1px 7px;
  font-size:12px; font-weight:600; min-width:20px; text-align:center;
  flex-shrink:0; line-height:18px;
}
.unread-badge.muted { background:var(--text3); }
/* Type icon (channel/group) */
.chat-icon { font-size:14px; margin-right:2px; vertical-align:middle;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.section-header { padding:8px 12px 3px; font-size:12px; font-weight:600; color:var(--text3); text-transform:uppercase; letter-spacing:.5px; }

/* ── CHAT AREA ── */
.chat-area { flex:1; display:flex; flex-direction:column; height:100%; height:100dvh; position:relative; overflow:hidden; background:var(--bg); }
.chat-placeholder { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--text3); gap:14px; }
.placeholder-icon { font-size:64px; animation:float 3s ease-in-out infinite;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.chat-placeholder p { font-size:15px; color:var(--text2); }
.active-chat { flex:1; display:flex; flex-direction:column; height:100%; overflow:hidden; }

/* ── CHAT HEADER ── */
.chat-header {
  display:flex; align-items:center; gap:8px; padding:0 12px;
  background:var(--bg2); border-bottom:1px solid var(--border);
  min-height:54px; flex-shrink:0;
}
.back-btn {
  display:none; width:40px; height:40px; border-radius:50%;
  align-items:center; justify-content:center; font-size:26px; color:var(--accent);
  -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji',sans-serif;
}
.back-btn:active { background:var(--bg3); }
.chat-header-info {
  display:flex; align-items:center; gap:10px; flex:1; cursor:pointer; min-width:0;
  -webkit-tap-highlight-color:transparent; padding:8px 0;
}
.chat-header-avatar {
  width:38px; height:38px; border-radius:50%;
  background:linear-gradient(135deg,var(--accent2),var(--accent3));
  display:flex; align-items:center; justify-content:center;
  font-size:16px; font-weight:600; color:#fff; flex-shrink:0; overflow:hidden; pointer-events:none;
}
.chat-header-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.chat-header-texts { flex:1; min-width:0; pointer-events:none; }
.chat-header-name { font-weight:600; font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-header-status { font-size:13px; color:var(--accent); margin-top:1px; }
.chat-header-status.offline { color:var(--text2); }
.chat-actions { display:flex; align-items:center; gap:2px; flex-shrink:0; }
.icon-btn {
  width:40px; height:40px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; font-size:18px; color:var(--text2);
  -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.icon-btn:active { background:var(--bg3); color:var(--text); }

/* ── MESSAGES ── */
.messages-container {
  flex:1; overflow-y:auto; overflow-x:hidden;
  padding:10px 8px 4px;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  /* TG chat background */
  background:var(--bg);
}
/* Optional TG wallpaper look */
[data-theme="tg-dark"] .messages-container {
  background:#0e1621;
}
.messages-list { display:flex; flex-direction:column; gap:2px; }
.msg-wrapper { display:flex; flex-direction:column; margin:1px 4px; }
.msg-wrapper.outgoing { align-items:flex-end; }
.msg-wrapper.incoming { align-items:flex-start; }

/* TG-style bubbles */
.msg-bubble {
  max-width:80%; padding:8px 12px 6px;
  position:relative; word-break:break-word;
  font-size:15px; line-height:1.45;
  -webkit-user-select:text; user-select:text;
  /* TG bubble shape */
  border-radius:18px;
}
/* TG tail */
.outgoing .msg-bubble {
  background:var(--msg-out);
  border-bottom-right-radius:4px;
}
.incoming .msg-bubble {
  background:var(--msg-in);
  border-bottom-left-radius:4px;
}
[data-theme="tg-light"] .incoming .msg-bubble {
  box-shadow:0 1px 2px rgba(0,0,0,0.12);
}
.msg-sender { font-size:13px; font-weight:600; color:var(--accent); margin-bottom:2px; }
.msg-text {
  font-family:-apple-system,'Segoe UI',Roboto,'Helvetica Neue',
    'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
/* Meta row */
.msg-meta { display:flex; align-items:center; gap:4px; margin-top:3px; justify-content:flex-end; }
.msg-time { font-size:12px; color:var(--text2); white-space:nowrap; opacity:.8; }
/* Outgoing checkmarks */
.msg-check { font-size:13px; color:var(--accent); margin-left:1px; }
.msg-edited { font-size:11px; color:var(--text2); font-style:italic; opacity:.8; }

/* Reply */
.msg-reply {
  background:rgba(91,172,244,0.1); border-left:3px solid var(--accent);
  padding:5px 8px; border-radius:6px; margin-bottom:6px; cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.msg-reply .reply-sender { font-size:12px; font-weight:600; color:var(--accent); display:block; }
.msg-reply .reply-content { font-size:13px; color:var(--text2); overflow:hidden; white-space:nowrap; text-overflow:ellipsis; max-width:240px; display:block; }

/* Voice */
.msg-voice { display:flex; align-items:center; gap:8px; padding:2px 0; min-width:180px; }
.voice-play-btn {
  width:38px; height:38px; border-radius:50%; background:var(--accent);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-size:14px; flex-shrink:0; min-width:38px;
  -webkit-tap-highlight-color:transparent;
}
.voice-wave { flex:1; height:26px; display:flex; align-items:center; gap:2px; pointer-events:none; }
.voice-bar { display:inline-block; width:3px; background:var(--accent); border-radius:2px; opacity:.7; }
.voice-dur { font-size:12px; color:var(--text2); min-width:36px; }

/* Media */
.msg-image { max-width:100%; max-height:280px; border-radius:12px; object-fit:cover; cursor:pointer; display:block; }
.msg-gif { max-width:100%; max-height:200px; border-radius:12px; display:block; }
.msg-file { display:flex; align-items:center; gap:8px; padding:4px 0; }
.msg-file a { color:var(--accent); font-size:14px; }

/* Date divider */
.msg-date-divider {
  text-align:center; margin:10px auto; padding:4px 12px;
  background:rgba(0,0,0,0.3); color:#fff; font-size:13px;
  border-radius:12px; width:fit-content; pointer-events:none;
}
[data-theme="tg-light"] .msg-date-divider { background:rgba(0,0,0,0.2); }

/* ── INPUT AREA ── */
.channel-readonly { padding:12px; background:var(--bg2); border-top:1px solid var(--border); text-align:center; font-size:13px; color:var(--text2); flex-shrink:0; }
.input-area { background:var(--bg2); border-top:1px solid var(--border); padding:6px 8px; flex-shrink:0; position:relative; }
.reply-preview { display:flex; align-items:center; gap:8px; padding:6px 10px; background:var(--surface); border-radius:10px; margin-bottom:5px; border-left:3px solid var(--accent); }
.reply-preview.edit-mode { border-color:var(--warn); }
.reply-content { flex:1; min-width:0; }
.reply-name { font-size:12px; font-weight:600; color:var(--accent); display:block; }
.reply-text { font-size:13px; color:var(--text2); overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:block; }
.reply-preview button { padding:8px; min-width:32px; min-height:32px; font-size:16px; color:var(--text2); -webkit-tap-highlight-color:transparent; }
.input-row { display:flex; align-items:flex-end; gap:4px; }
.message-input-wrap {
  flex:1; background:var(--bg3); border-radius:22px;
  border:1px solid var(--border); overflow:hidden;
  transition:border-color .2s; max-height:120px;
}
.message-input-wrap:focus-within { border-color:var(--accent); }
.message-input {
  padding:11px 14px; min-height:44px; max-height:120px;
  overflow-y:auto; outline:none; font-size:15px; line-height:1.4;
  word-break:break-word; -webkit-user-select:text; user-select:text;
  font-family:-apple-system,'Segoe UI',Roboto,'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.message-input:empty::before { content:attr(data-placeholder); color:var(--text3); pointer-events:none; }
.send-btn {
  background:var(--accent); color:#fff;
  width:44px; height:44px; border-radius:50%; font-size:18px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0; -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji',sans-serif;
}
.send-btn:active { filter:brightness(.85); }
.voice-btn {
  width:44px; height:44px; border-radius:50%; font-size:20px;
  background:var(--bg3); color:var(--text2); flex-shrink:0;
  border:1px solid var(--border); display:flex; align-items:center; justify-content:center;
  -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.voice-btn:active { background:var(--accent); color:#fff; }
.voice-btn.recording { background:var(--danger); color:#fff; border-color:var(--danger); animation:recPulse 1s ease infinite; }
@keyframes recPulse { 0%,100%{box-shadow:0 0 0 0 rgba(240,85,85,.4)} 50%{box-shadow:0 0 0 8px rgba(240,85,85,0)} }
.gif-btn {
  width:44px; height:44px; border-radius:50%; font-size:11px; font-weight:700;
  background:var(--bg3); color:var(--accent); flex-shrink:0;
  border:1px solid var(--border); display:flex; align-items:center; justify-content:center;
  -webkit-tap-highlight-color:transparent;
}
.gif-btn:active { background:var(--accent); color:#fff; }
/* Input bar attachment btn */
.icon-btn.attach-btn { color:var(--text2); }

/* ── PICKERS ── */
.attach-menu {
  position:absolute; bottom:calc(100% + 4px); left:8px;
  background:var(--bg2); border-radius:12px; padding:6px;
  display:flex; flex-direction:column; gap:2px;
  border:1px solid var(--border); box-shadow:var(--shadow); z-index:50; min-width:180px;
}
.attach-menu button { padding:12px 14px; border-radius:10px; text-align:left; font-size:14px; min-height:44px; -webkit-tap-highlight-color:transparent; color:var(--text);
  font-family:-apple-system,'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.attach-menu button:active { background:var(--bg3); }

.emoji-picker {
  position:absolute; bottom:calc(100% + 4px); right:8px;
  width:320px; max-height:300px;
  background:var(--bg2); border-radius:14px;
  border:1px solid var(--border); box-shadow:var(--shadow);
  z-index:50; display:flex; flex-direction:column; overflow:hidden;
}
.emoji-categories { display:flex; padding:6px 8px; gap:4px; border-bottom:1px solid var(--border); overflow-x:auto; }
.emoji-categories::-webkit-scrollbar { display:none; }
.emoji-cat {
  width:36px; height:36px; border-radius:8px;
  font-size:20px; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.emoji-cat.active { background:var(--bg3); }
.emoji-cat:active { background:var(--bg4); }
.emoji-grid {
  flex:1; overflow-y:auto; padding:6px;
  display:flex; flex-wrap:wrap; gap:2px; align-content:flex-start;
  -webkit-overflow-scrolling:touch;
}
.emoji-btn-item {
  width:38px; height:38px; border-radius:8px;
  font-size:24px; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; -webkit-tap-highlight-color:transparent; cursor:pointer;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.emoji-btn-item:active { background:var(--bg3); transform:scale(1.15); }

.gif-picker {
  position:absolute; bottom:calc(100% + 4px); right:8px;
  width:320px; max-height:320px;
  background:var(--bg2); border-radius:14px;
  border:1px solid var(--border); box-shadow:var(--shadow);
  z-index:50; display:flex; flex-direction:column; overflow:hidden;
}
.gif-search-row { padding:8px; border-bottom:1px solid var(--border); }
.gif-search-row input { width:100%; padding:8px 12px; background:var(--bg3); border:1px solid var(--border); border-radius:10px; font-size:14px; -webkit-user-select:text; user-select:text; }
.gif-grid { flex:1; overflow-y:auto; padding:6px; display:grid; grid-template-columns:1fr 1fr; gap:4px; -webkit-overflow-scrolling:touch; }
.gif-item { border-radius:8px; overflow:hidden; cursor:pointer; aspect-ratio:16/9; background:var(--bg3); -webkit-tap-highlight-color:transparent; }
.gif-item img { width:100%; height:100%; object-fit:cover; pointer-events:none; }
.gif-item:active { opacity:.8; }
.gif-loading { grid-column:1/-1; text-align:center; color:var(--text3); padding:20px; font-size:14px; }

/* ── TG CONTEXT MENU ── */
.context-menu {
  position:fixed;
  background:var(--bg2); border-radius:14px;
  border:1px solid var(--border); box-shadow:var(--shadow);
  z-index:500; overflow:hidden; min-width:190px;
  animation:ctxIn .15s ease;
}
@keyframes ctxIn { from{scale:.9;opacity:0} to{scale:1;opacity:1} }
/* Emoji reaction bar at top */
.ctx-reactions {
  display:flex; gap:2px; padding:8px 10px;
  border-bottom:1px solid var(--border);
  background:var(--bg2);
}
.ctx-reaction {
  width:38px; height:38px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:22px; cursor:pointer; -webkit-tap-highlight-color:transparent;
  transition:transform .1s;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.ctx-reaction:active { transform:scale(1.3); background:var(--bg3); }
.context-menu button {
  display:flex; align-items:center; gap:10px;
  width:100%; padding:12px 16px; text-align:left;
  font-size:15px; color:var(--text); min-height:46px;
  -webkit-tap-highlight-color:transparent;
  font-family:-apple-system,'Apple Color Emoji','Segoe UI Emoji',sans-serif;
}
.context-menu button:active { background:var(--bg3); }
.context-menu button .ctx-icon { font-size:18px; width:22px; text-align:center;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.context-menu button.danger { color:var(--danger); }
.ctx-overlay { position:fixed; inset:0; z-index:499; background:rgba(0,0,0,.2); }

/* ── MODALS ── */
.modal {
  position:fixed; inset:0; z-index:200;
  display:flex; align-items:center; justify-content:center;
  background:rgba(0,0,0,.6); backdrop-filter:blur(4px);
  padding:16px; touch-action:none;
}
.modal-box {
  background:var(--surface); border-radius:16px;
  width:100%; max-width:400px;
  border:1px solid var(--border); box-shadow:var(--shadow);
  animation:modalIn .2s ease; max-height:88vh; overflow-y:auto;
  -webkit-overflow-scrolling:touch;
}
@keyframes modalIn { from{scale:.92;opacity:0} to{scale:1;opacity:1} }
.modal-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 18px 12px; border-bottom:1px solid var(--border);
}
.modal-header h3 { font-size:17px; font-weight:600; }
.modal-header button {
  width:34px; height:34px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:18px; color:var(--text2);
  -webkit-tap-highlight-color:transparent;
}
.modal-header button:active { background:var(--bg3); }
.modal-body { padding:12px 18px 16px; display:flex; flex-direction:column; gap:10px; }
.list-btn {
  display:flex; align-items:center; gap:14px;
  padding:14px 14px; background:var(--bg3); border-radius:12px;
  font-size:15px; text-align:left; width:100%; min-height:52px;
  border:none; -webkit-tap-highlight-color:transparent; color:var(--text);
  font-family:-apple-system,'Apple Color Emoji','Segoe UI Emoji',sans-serif;
}
.list-btn:active { background:var(--bg4); }
.toggle-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 0; cursor:pointer; min-height:44px;
  -webkit-tap-highlight-color:transparent;
}
.toggle-row input[type=checkbox] {
  width:48px; height:26px; appearance:none;
  background:var(--bg4); border-radius:13px; cursor:pointer;
  position:relative; transition:background .25s; flex-shrink:0;
}
.toggle-row input[type=checkbox]:checked { background:var(--accent); }
.toggle-row input[type=checkbox]::after {
  content:''; position:absolute; width:22px; height:22px;
  background:white; border-radius:50%; top:2px; left:2px;
  transition:transform .25s; box-shadow:0 1px 3px rgba(0,0,0,.3);
}
.toggle-row input[type=checkbox]:checked::after { transform:translateX(22px); }
.search-results { display:flex; flex-direction:column; gap:2px; max-height:260px; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.user-result {
  display:flex; align-items:center; gap:12px;
  padding:10px 12px; border-radius:10px; cursor:pointer; min-height:54px;
  -webkit-tap-highlight-color:transparent;
}
.user-result:active { background:var(--bg3); }
.user-result-avatar {
  width:42px; height:42px; border-radius:50%;
  background:linear-gradient(135deg,var(--accent2),var(--accent3));
  display:flex; align-items:center; justify-content:center;
  font-weight:600; color:#fff; flex-shrink:0; overflow:hidden; pointer-events:none;
}
.user-result-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.user-result-info .name { font-weight:600; font-size:15px; }
.user-result-info .sub { font-size:13px; color:var(--text2); }
.family-hint { background:rgba(251,184,19,.1); border:1px solid rgba(251,184,19,.3); border-radius:10px; padding:10px 12px; font-size:13px; color:var(--warn); }

/* ── INFO PANEL ── */
.info-panel { position:absolute; right:0; top:0; width:100%; max-width:380px; height:100%; background:var(--bg2); border-left:1px solid var(--border); z-index:50; display:flex; flex-direction:column; transform:translateX(100%); transition:transform .3s cubic-bezier(.4,0,.2,1); }
.info-panel.open { transform:translateX(0); }
.info-panel-header { display:flex; align-items:center; justify-content:space-between; padding:0 14px; min-height:54px; border-bottom:1px solid var(--border); flex-shrink:0; }
.info-panel-header button { font-size:24px; color:var(--accent); padding:8px; min-width:40px; min-height:40px; -webkit-tap-highlight-color:transparent; display:flex; align-items:center; justify-content:center; }
.info-panel-header h3 { font-size:17px; font-weight:600; }
.info-panel-body { flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.info-hero { display:flex; flex-direction:column; align-items:center; padding:20px 16px 12px; gap:8px; }
.info-big-avatar { width:80px; height:80px; border-radius:50%; background:linear-gradient(135deg,var(--accent2),var(--accent3)); display:flex; align-items:center; justify-content:center; font-size:32px; font-weight:700; color:#fff; overflow:hidden; }
.info-big-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.info-name { font-size:20px; font-weight:600; text-align:center; }
.info-desc { font-size:14px; color:var(--text2); text-align:center; max-width:280px; }
.info-stat { display:flex; gap:24px; }
.info-stat-item { text-align:center; }
.info-stat-item .num { font-size:20px; font-weight:700; color:var(--accent); }
.info-stat-item .lbl { font-size:11px; color:var(--text3); }
.info-section { padding:0 14px; margin-top:12px; }
.info-section h4 { font-size:12px; color:var(--text3); text-transform:uppercase; letter-spacing:.5px; padding:6px 0; border-bottom:1px solid var(--border); margin-bottom:6px; }
.info-row { display:flex; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--border); min-height:52px; -webkit-tap-highlight-color:transparent; }
.info-row-icon { font-size:20px; width:24px; text-align:center; flex-shrink:0; font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.info-row-label { font-size:13px; color:var(--text2); }
.info-row-value { font-size:15px; font-weight:500; }
.member-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid var(--border); min-height:52px; }
.member-row .ma { width:40px; height:40px; border-radius:50%; background:linear-gradient(135deg,var(--accent2),var(--accent3)); display:flex; align-items:center; justify-content:center; font-weight:600; color:#fff; font-size:15px; flex-shrink:0; overflow:hidden; pointer-events:none; }
.member-row .ma img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.member-row .mi { flex:1; min-width:0; pointer-events:none; }
.member-row .mn { font-size:15px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.member-row .mr { font-size:13px; color:var(--text2); }
.role-badge { font-size:12px; font-weight:600; padding:2px 8px; border-radius:6px; white-space:nowrap; }
.role-badge.owner { background:rgba(251,184,19,.2); color:var(--warn); }
.role-badge.admin { background:rgba(91,172,244,.2); color:var(--accent); }
.role-badge.member { color:var(--text2); }
.info-link-box { background:var(--bg3); border-radius:10px; padding:10px 12px; display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:6px; }
.info-link-box span { font-size:13px; color:var(--blue-link); word-break:break-all; }
.info-link-box button { padding:6px 12px; background:var(--accent); color:#fff; border-radius:8px; font-size:13px; -webkit-tap-highlight-color:transparent; }
.info-action-row { display:flex; flex-direction:column; gap:4px; margin-top:8px; }
.info-action-btn { padding:12px 14px; background:var(--bg3); border-radius:12px; text-align:left; font-size:14px; display:flex; align-items:center; gap:12px; min-height:48px; -webkit-tap-highlight-color:transparent; color:var(--text);
  font-family:-apple-system,'Apple Color Emoji','Segoe UI Emoji',sans-serif; }
.info-action-btn:active { background:var(--bg4); }
.info-action-btn.danger { color:var(--danger); }

/* ── SETTINGS ── */
.settings-panel { position:fixed; inset:0; z-index:100; background:var(--bg2); display:flex; flex-direction:column; transform:translateX(100%); transition:transform .3s cubic-bezier(.4,0,.2,1); }
.settings-panel.open { transform:translateX(0); }
.settings-header { display:flex; align-items:center; justify-content:space-between; padding:0 14px; min-height:54px; border-bottom:1px solid var(--border); flex-shrink:0; }
.settings-header button { font-size:24px; color:var(--accent); padding:8px; min-width:40px; min-height:40px; -webkit-tap-highlight-color:transparent; display:flex; align-items:center; justify-content:center; }
.settings-header h3 { font-size:17px; font-weight:600; }
.settings-body { flex:1; overflow-y:auto; padding:0 0 20px; -webkit-overflow-scrolling:touch; }
/* Avatar centered with TG style */
.settings-avatar-wrap { display:flex; flex-direction:column; align-items:center; padding:20px 0 12px; background:var(--bg2); border-bottom:1px solid var(--border); }
.settings-avatar {
  width:88px; height:88px; border-radius:50%;
  background:linear-gradient(135deg,var(--accent2),var(--accent3));
  display:flex; align-items:center; justify-content:center;
  font-size:36px; font-weight:700; color:#fff;
  cursor:pointer; position:relative; overflow:hidden;
  -webkit-tap-highlight-color:transparent;
}
.avatar-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:28px; background:rgba(0,0,0,.45); border-radius:50%; opacity:0; transition:opacity .2s; }
.settings-avatar:active .avatar-overlay { opacity:1; }
.settings-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; position:absolute; }
.settings-name-big { font-size:20px; font-weight:700; margin-top:10px; }
.settings-username-big { font-size:14px; color:var(--text2); margin-top:2px; }
/* Settings sections like TG */
.settings-group { margin-top:16px; padding:0 16px; }
.settings-group-title { font-size:13px; color:var(--accent); font-weight:600; padding:0 2px 6px; text-transform:uppercase; letter-spacing:.5px; }
.settings-section { background:var(--surface); border-radius:14px; overflow:hidden; }
.settings-row {
  display:flex; align-items:center; gap:12px;
  padding:14px 16px; min-height:52px; cursor:pointer;
  border-bottom:1px solid var(--border);
  -webkit-tap-highlight-color:transparent;
  font-size:15px;
}
.settings-row:last-child { border-bottom:none; }
.settings-row:active { background:var(--bg3); }
.settings-row-icon { font-size:20px; width:28px; text-align:center; flex-shrink:0;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.settings-row-text { flex:1; }
.settings-row-label { font-size:15px; }
.settings-row-value { font-size:13px; color:var(--text2); margin-top:2px; }
.settings-row-arrow { color:var(--text3); font-size:16px; }
.settings-section h4 { font-size:14px; font-weight:600; color:var(--accent); padding:12px 16px 4px; }
.settings-input-group { padding:0 16px 12px; display:flex; flex-direction:column; gap:10px; }
.setting-hint { font-size:12px; color:var(--text3); padding:0 2px; }
.invite-code-box { background:var(--bg3); border-radius:12px; padding:14px 16px; font-size:20px; font-weight:700; color:var(--accent); letter-spacing:4px; text-align:center; border:2px dashed var(--accent); cursor:pointer; -webkit-tap-highlight-color:transparent; }
.admin-users { display:flex; flex-direction:column; gap:3px; }
.admin-user-row { display:flex; align-items:center; gap:10px; padding:10px 14px; background:var(--bg3); border-radius:10px; min-height:54px; }
.admin-user-row .aun { flex:1; font-size:14px; }
.admin-user-row .aun strong { display:block; font-size:15px; }
.admin-user-row .aun span { font-size:12px; color:var(--text3); }
.admin-user-row .aur { font-size:13px; color:var(--accent); }
.admin-btns { display:flex; flex-direction:column; gap:3px; }
.admin-user-row button { font-size:12px; padding:5px 10px; border-radius:8px; background:var(--surface2); border:1px solid var(--border); white-space:nowrap; min-height:34px; -webkit-tap-highlight-color:transparent; color:var(--text); }
.admin-user-row button:active { background:var(--bg4); }

/* ── THEME GRID ── */
.theme-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; padding:12px 16px; }
.theme-swatch { border-radius:12px; overflow:hidden; cursor:pointer; border:2px solid transparent; transition:border-color .2s; -webkit-tap-highlight-color:transparent; }
.theme-swatch.active { border-color:var(--accent); }
.theme-swatch:active { transform:scale(.97); }
.theme-swatch-inner { height:56px; padding:8px 10px; display:flex; flex-direction:column; justify-content:space-between; }
.theme-swatch-name { font-size:11px; font-weight:600; }
.theme-dots { display:flex; gap:3px; }
.theme-dot { width:8px; height:8px; border-radius:50%; }
.theme-swatch .check { display:none; font-size:14px; }
.theme-swatch.active .check { display:block; }

/* ── SLIDE MENU (TG style) ── */
.slide-menu { position:fixed; left:0; top:0; width:300px; height:100%; height:100dvh; background:var(--bg2); z-index:300; display:flex; flex-direction:column; transform:translateX(-100%); transition:transform .3s cubic-bezier(.4,0,.2,1); box-shadow:4px 0 24px rgba(0,0,0,.5); }
.slide-menu.open { transform:translateX(0); }
.menu-overlay { position:fixed; inset:0; z-index:299; background:rgba(0,0,0,.5); }
/* TG menu header */
.slide-menu-header { padding:env(safe-area-inset-top,40px) 18px 16px; border-bottom:1px solid var(--border); flex-shrink:0; }
.slide-menu-top { display:flex; align-items:center; gap:12px; cursor:pointer; -webkit-tap-highlight-color:transparent; padding:4px 0; }
.menu-avatar { width:56px; height:56px; border-radius:50%; background:linear-gradient(135deg,var(--accent2),var(--accent3)); display:flex; align-items:center; justify-content:center; font-size:24px; font-weight:700; color:#fff; flex-shrink:0; overflow:hidden; pointer-events:none; }
.menu-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.menu-user-info { flex:1; min-width:0; pointer-events:none; }
.menu-display-name { font-size:16px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.menu-username { font-size:14px; color:var(--text2); margin-top:2px; }
.slide-nav { padding:8px 0; display:flex; flex-direction:column; flex:1; overflow-y:auto; }
.slide-nav a {
  display:flex; align-items:center; gap:14px;
  padding:14px 18px; font-size:15px; cursor:pointer; min-height:52px;
  -webkit-tap-highlight-color:transparent; color:var(--text);
  font-family:-apple-system,'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.slide-nav a:active { background:var(--surface); }
.slide-nav a .nav-icon { font-size:22px; width:28px; text-align:center; font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.slide-nav .divider { height:1px; background:var(--border); margin:4px 0; }
.logout-link { color:var(--danger) !important; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  display:none; position:fixed; bottom:0; left:0; right:0;
  background:var(--bg2); border-top:1px solid var(--border);
  z-index:60;
  padding-bottom:env(safe-area-inset-bottom,0px);
}
.nav-btn {
  flex:1; display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:8px 4px; font-size:11px; color:var(--text2);
  min-height:52px; -webkit-tap-highlight-color:transparent; touch-action:manipulation;
}
.nav-btn .nav-icon { line-height:1; pointer-events:none; display:flex; align-items:center; justify-content:center; }
.nav-btn .nav-label { pointer-events:none; font-size:10px; }
.nav-btn:active { background:var(--bg3); }
.nav-btn.active { color:var(--accent); }

/* ── CALLS ── */
.call-ui { position:fixed; inset:0; z-index:1000; display:flex; flex-direction:column; }
.call-bg { position:absolute; inset:0; background:linear-gradient(160deg,#1a2c3a 0%,#0e1621 100%); }
.call-content { position:relative; z-index:1; flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:20px; gap:14px; }
.call-avatar { width:100px; height:100px; border-radius:50%; background:linear-gradient(135deg,var(--accent2),var(--accent3)); display:flex; align-items:center; justify-content:center; font-size:44px; font-weight:700; color:#fff; box-shadow:0 0 40px rgba(91,172,244,.3); overflow:hidden; }
.call-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.call-name { font-size:28px; font-weight:700; }
.call-status { color:var(--text2); font-size:15px; }
.remote-video { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.local-video { position:absolute; bottom:90px; right:14px; width:100px; height:140px; object-fit:cover; border-radius:12px; border:2px solid rgba(255,255,255,.3); }
.call-controls { display:flex; gap:20px; margin-top:36px; z-index:2; }
.call-btn { width:62px; height:62px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:26px; box-shadow:0 4px 16px rgba(0,0,0,.4); -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif; }
.call-btn:active { transform:scale(.9); }
.mute-btn,.vid-btn,.spk-btn { background:rgba(255,255,255,0.15); color:#fff; }
.end-btn { background:var(--danger); }
.accept-btn { background:var(--success); }
.call-btn.active { background:var(--accent); }
.incoming-call { position:fixed; top:0; left:0; right:0; z-index:800; background:var(--bg2); padding:env(safe-area-inset-top,16px) 18px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:14px; animation:slideDown .3s ease; box-shadow:0 4px 16px rgba(0,0,0,.4); }
@keyframes slideDown { from{transform:translateY(-100%);opacity:0} to{transform:none;opacity:1} }
.incoming-info { display:flex; align-items:center; gap:12px; }
.incoming-avatar { width:48px; height:48px; border-radius:50%; background:linear-gradient(135deg,var(--accent2),var(--accent3)); display:flex; align-items:center; justify-content:center; font-size:20px; font-weight:700; color:#fff; overflow:hidden; }
.incoming-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.incoming-name { font-weight:700; font-size:16px; }
.incoming-type { font-size:13px; color:var(--text2); }
.incoming-actions { display:flex; gap:12px; }
.incoming-actions .call-btn { width:52px; height:52px; font-size:22px; }

/* ── TOAST ── */
.toast { position:fixed; bottom:70px; left:50%; transform:translateX(-50%); background:var(--bg2); color:var(--text); padding:10px 18px; border-radius:12px; font-size:14px; z-index:9999; border:1px solid var(--border); box-shadow:var(--shadow); max-width:320px; text-align:center; white-space:nowrap; pointer-events:none; animation:toastIn .25s ease; }
@keyframes toastIn { from{transform:translateX(-50%) translateY(16px);opacity:0} to{transform:translateX(-50%) translateY(0);opacity:1} }

/* ═══════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════ */
@media (max-width:768px) {
  .sidebar {
    width:100%; position:absolute; top:0; left:0; right:0;
    height:calc(100% - 56px); height:calc(100dvh - 56px);
    z-index:20;
  }
  .chat-list { padding-bottom:4px; }
  .chat-area {
    width:100%; position:absolute; top:0; left:0; right:0;
    height:calc(100% - 56px); height:calc(100dvh - 56px);
    transform:translateX(100%);
    transition:transform .28s cubic-bezier(.4,0,.2,1); z-index:25;
  }
  .chat-area.mobile-open { transform:translateX(0); }
  .back-btn { display:flex !important; }
  .bottom-nav { display:flex; }
  .emoji-picker, .gif-picker { width:calc(100vw - 16px); right:8px; left:8px; }
  .info-panel { max-width:100%; }
  .call-controls { gap:16px; }
  .call-btn { width:56px; height:56px; }
  .incoming-call { position:fixed; top:0; left:0; right:0; border-radius:0; }
}
@media (min-width:769px) {
  .chat-area { transform:none !important; }
  .back-btn { display:none !important; }
}

/* ── REACTIONS ── */
.msg-reactions { display:flex; flex-wrap:wrap; gap:4px; margin-top:4px; }
.reaction-badge {
  display:inline-flex; align-items:center; gap:3px;
  padding:3px 8px; border-radius:12px;
  background:var(--bg3); border:1px solid var(--border);
  font-size:15px; cursor:pointer; transition:background .15s;
  -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.reaction-badge:active { background:var(--bg4); }
.ctx-reactions { display:flex; gap:4px; padding:8px 10px; border-bottom:1px solid var(--border); overflow-x:auto; }
.ctx-reactions::-webkit-scrollbar { display:none; }
.ctx-reaction {
  width:38px; height:38px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:22px; cursor:pointer; transition:transform .1s;
  -webkit-tap-highlight-color:transparent;
  font-family:'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif;
}
.ctx-reaction:active { transform:scale(1.3); background:var(--bg3); }

/* ═══════════════════════════════════════
   ONLINE STATUS & READ RECEIPTS
   ═══════════════════════════════════════ */

/* Online dot on avatar in chat list */
.chat-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: #4dbe63;
  border-radius: 50%;
  border: 2px solid var(--bg2);
  pointer-events: none;
  animation: onlinePulse 2.5s ease-in-out infinite;
}
@keyframes onlinePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(77,190,99,0); }
  50%      { box-shadow: 0 0 0 3px rgba(77,190,99,0.2); }
}

/* Online dot in chat header */
.header-online-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: #4dbe63;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  animation: onlinePulse 2.5s ease-in-out infinite;
}

/* Typing indicator */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
}
.typing-dots span {
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,80%,100% { transform: translateY(0); opacity: 0.5; }
  40%          { transform: translateY(-4px); opacity: 1; }
}

/* Read receipt ticks */
.msg-check { display: inline-flex; align-items: center; margin-left: 2px; }
.msg-check svg { transition: stroke 0.3s; }
.msg-check.read svg   { stroke: var(--accent); }   /* blue = read */
.msg-check.unread svg { stroke: var(--text3); }     /* gray = sent/delivered */

/* Unread badge in chat list */
.unread-badge {
  background: var(--unread);
  color: #fff;
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  line-height: 18px;
  flex-shrink: 0;
}

/* Last message preview with tick */
.chat-last-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.chat-last-tick {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.chat-last-tick svg { stroke: var(--accent); }
.chat-last-tick.gray svg { stroke: var(--text3); }
.chat-last {
  font-size: 14px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
