:root,
[data-theme="dark"] {
  --app-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --bg-app: #000000;
  --rail-bg: #121216;
  --sidebar-bg: #16161b;
  --chat-bg: #0b1420;
  --surface: #1c1c22;
  --surface-2: #26262e;
  --glass-bg: rgba(24, 24, 30, 0.78);
  --border: rgba(255, 255, 255, 0.11);
  --text: #f8fafc;
  --muted: #98a2b3;
  --primary: #0a84ff;
  --primary-hover: #0070e0;
  --accent: #5e5ce6;
  --bubble-me: linear-gradient(135deg, #007aff, #0a84ff);
  --bubble-me-text: #ffffff;
  --bubble-other: rgba(34, 36, 46, 0.88);
  --success: #30d158;
  --danger: #ff453a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

[data-theme="light"] {
  --bg-app: #f2f2f7;
  --rail-bg: #007aff;
  --sidebar-bg: #ffffff;
  --chat-bg: #e5ecf4;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --glass-bg: rgba(255, 255, 255, 0.82);
  --border: rgba(60, 60, 67, 0.14);
  --text: #111827;
  --muted: #6c6c70;
  --primary: #007aff;
  --primary-hover: #0062cc;
  --accent: #5856d6;
  --bubble-me: linear-gradient(135deg, #007aff, #34aadc);
  --bubble-me-text: #ffffff;
  --bubble-other: rgba(255, 255, 255, 0.94);
  --success: #34c759;
  --danger: #ff3b30;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--app-font);
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text);
}

.hidden { display: none !important; }

/* Custom subtle scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 999px; }

/* App Shell */
.app-shell { display: flex; width: 100%; height: 100%; }

/* Left Navigation Rail */
.nav-rail {
  width: 68px;
  background: var(--rail-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
  flex-shrink: 0;
}

.my-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  font-size: 14px;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.rail-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s ease;
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn:hover, .rail-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}
.rail-btn.accent-rail {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
}
.rail-btn.accent-rail:hover {
  background: rgba(99, 102, 241, 0.45);
  color: #fff;
}
.rail-spacer { flex: 1; }

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #94a3b8;
  border: 2px solid var(--rail-bg);
}
.status-dot.online { background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.7); }
.status-dot.offline { background: #ef4444; }

/* Sidebar */
.sidebar {
  width: 310px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-title { font-weight: 700; font-size: 16px; }
.sidebar-sub { font-size: 12px; color: var(--success); margin-top: 2px; }

.btn-pill-accent {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  border: none;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-pill-accent:hover { filter: brightness(1.08); }

.search-box { padding: 12px 14px 6px; }
.search-box input {
  width: 100%;
  padding: 9px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  font-size: 13px;
}
.search-box input:focus { border-color: var(--primary); }

.list-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 12px 16px 6px;
  letter-spacing: 0.5px;
}

.conv-list { overflow-y: auto; flex: 1; padding: 0 8px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.14s;
  margin-bottom: 2px;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: rgba(59, 130, 246, 0.16); }

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: rgba(59, 130, 246, 0.18);
  color: var(--primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.presence-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
  background: #64748b;
}
.presence-badge.online { background: #22c55e; }

.conv-meta { min-width: 0; flex: 1; }
.conv-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.muted-id { font-size: 11px; font-weight: 400; color: var(--muted); }
.conv-del-btn {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.conv-del-btn:hover { background: var(--danger); color: #fff; }

/* Chat Pane */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  position: relative;
  min-width: 0;
}

.chat-header {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-left { display: flex; align-items: center; gap: 12px; }
.chat-title-row { display: flex; align-items: center; gap: 8px; }
.chat-header h2 { font-size: 16px; font-weight: 700; }
.chat-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.e2ee-badge {
  font-size: 11px;
  background: rgba(16, 185, 129, 0.14);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.chat-header-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Transfer Tray */
.transfer-tray {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 170px;
  overflow-y: auto;
}

.transfer-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
}

.transfer-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.progress-track {
  height: 6px;
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  transition: width 0.15s;
}

/* Messages */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 460px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px;
  border-radius: 18px;
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; font-size: 18px; }
.empty-state p { font-size: 13px; line-height: 1.55; }

.msg-row { display: flex; flex-direction: column; max-width: 72%; }
.msg-row.me { align-self: flex-end; align-items: flex-end; }
.msg-row.other { align-self: flex-start; align-items: flex-start; }

.msg-sender { font-size: 11px; color: var(--muted); margin-bottom: 4px; padding: 0 4px; }

.msg-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  background: var(--bubble-other);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.update-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(16, 28, 48, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: #f8fafc;
  font-size: 13px;
  backdrop-filter: blur(12px);
}
.update-banner.hidden { display: none !important; }
.update-banner-btn {
  padding: 6px 12px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.update-banner-btn:disabled { opacity: 0.6; cursor: default; }
.update-banner-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 4px;
}
.msg-row.me .msg-bubble {
  background: var(--bubble-me);
  color: var(--bubble-me-text);
  border: none;
}

.msg-time { font-size: 10px; color: var(--muted); margin-top: 4px; }

.file-card { display: flex; flex-direction: column; gap: 10px; min-width: 260px; max-width: 420px; }
.file-card-header { display: flex; align-items: center; gap: 10px; }
.file-icon { font-size: 26px; }
.file-name { font-weight: 600; font-size: 13px; word-break: break-all; }
.file-size { font-size: 12px; opacity: 0.85; }
.inline-video { width: 100%; max-height: 260px; border-radius: 10px; background: #000; }
.file-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Composer */
.composer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 18px 14px;
}

.transfer-mode-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.muted-sm { font-size: 12px; color: var(--muted); }
.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.composer-row { display: flex; gap: 8px; align-items: center; }
.composer-row .icon-btn { flex-shrink: 0; }
.composer-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 11px 15px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.composer-row input[type="text"]:focus { border-color: var(--primary); }

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-xs { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

.btn-ghost, .btn-ghost-sm, .btn-ghost-xs {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 13px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.btn-ghost-sm { padding: 6px 11px; }
.btn-ghost-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn-ghost:hover, .btn-ghost-sm:hover, .btn-ghost-xs:hover { border-color: var(--primary); }

.btn-success {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.full-width { width: 100%; margin-top: 16px; padding: 12px; font-size: 14px; }

/* Modals & Modern Login Shell */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.login-shell {
  width: 820px;
  max-width: 96vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  box-shadow: var(--shadow);
}

.login-hero {
  background: linear-gradient(155deg, #1e3a8a 0%, #312e81 55%, #0f172a 100%);
  color: #f8fafc;
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-badge { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-name { font-size: 20px; font-weight: 800; }
.ver-tag { font-size: 11px; background: rgba(255,255,255,0.2); padding: 2px 7px; border-radius: 999px; vertical-align: middle; }
.brand-tag { font-size: 12px; opacity: 0.8; }
.login-hero h2 { font-size: 22px; line-height: 1.3; margin-bottom: 10px; }
.hero-desc { font-size: 13px; opacity: 0.85; line-height: 1.5; margin-bottom: 20px; }

.feature-list { display: flex; flex-direction: column; gap: 10px; }
.feat-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.feat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.feat-dot.green { background: #34d399; }
.feat-dot.blue { background: #60a5fa; }
.feat-dot.purple { background: #c084fc; }
.feat-dot.amber { background: #fbbf24; }

.login-form { padding: 32px; display: flex; flex-direction: column; justify-content: center; }
.login-form h3 { font-size: 20px; margin-bottom: 4px; }

.modal-card {
  width: 460px;
  max-width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.hub-modal { width: 680px; }
.hub-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.modal-card h2 { font-size: 18px; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 13px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 14px;
  margin-bottom: 6px;
}

input[type="text"] {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--primary); }

/* Env Cards */
.env-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.env-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
}
.env-card-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; }
.env-title { font-size: 12px; font-weight: 700; }
.env-desc { font-size: 11px; color: var(--muted); line-height: 1.4; }

.badge-ok, .badge-miss, .badge-wait {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-ok { background: rgba(16, 185, 129, 0.16); color: #10b981; }
.badge-miss { background: rgba(245, 158, 11, 0.16); color: #f59e0b; }
.badge-wait { background: rgba(148, 163, 184, 0.18); color: var(--muted); }

.install-log {
  background: #020617;
  color: #a7f3d0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: Consolas, monospace;
  font-size: 11px;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-bottom: 8px;
}

.inline-input-row { display: flex; gap: 8px; align-items: center; }
.inline-input-row button { white-space: nowrap; }
.action-bar { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.two-col-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

.mini-list {
  max-height: 130px;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-pill {
  margin-top: 10px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.error-text { color: var(--danger); font-size: 12px; margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions.center { justify-content: center; }
.center-text { text-align: center; }
.call-ring-icon { font-size: 42px; margin-bottom: 10px; }

/* Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(59, 130, 246, 0.16);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.drop-box {
  background: var(--surface);
  border: 2px dashed var(--primary);
  color: var(--primary);
  font-weight: 700;
  padding: 28px 36px;
  border-radius: 16px;
}

/* Call Overlay */
.call-overlay {
  position: fixed;
  inset: 0;
  background: #020617;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-stage { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.remote-video { width: 100%; height: 100%; object-fit: contain; background: #0f172a; }
.local-video {
  position: absolute; bottom: 92px; right: 24px; width: 240px; height: 150px;
  object-fit: cover; border-radius: 14px; border: 2px solid rgba(255,255,255,0.35); background: #1e293b;
}
.call-info-bar {
  position: absolute; top: 20px; left: 24px; background: rgba(15, 23, 42, 0.78);
  color: #fff; padding: 8px 16px; border-radius: 999px; display: flex; gap: 14px; font-size: 14px;
}
.call-controls { position: absolute; bottom: 24px; display: flex; gap: 14px; }
.call-ctrl-btn {
  width: 52px; height: 52px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.18); color: #fff; font-size: 22px; cursor: pointer;
}
.call-ctrl-btn:hover { background: rgba(255,255,255,0.3); }
.call-ctrl-btn.off { background: #475569; opacity: 0.7; }
.call-ctrl-btn.danger { background: var(--danger); }

/* Mobile Portrait & iOS Safe Area Optimization */
.mobile-back-btn { display: none; }

@media (max-width: 768px) {
  html, body {
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  /* Sidebar view (default on mobile) */
  .sidebar {
    width: 100%;
    flex: 1;
    min-height: 0;
    border-right: none;
    padding-top: env(safe-area-inset-top);
  }

  .nav-rail {
    order: 2;
    width: 100%;
    height: calc(58px + env(safe-area-inset-bottom));
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--border);
    gap: 4px;
  }

  .nav-rail .rail-spacer { display: none; }
  .nav-rail .my-avatar {
    margin-bottom: 0;
    width: 34px;
    height: 34px;
    font-size: 12px;
  }
  .nav-rail .rail-btn {
    width: 40px;
    height: 40px;
  }

  .chat-pane {
    display: none;
  }

  /* Active Chat view on mobile */
  .app-shell.mobile-chat-open .sidebar,
  .app-shell.mobile-chat-open .nav-rail {
    display: none;
  }

  .app-shell.mobile-chat-open .chat-pane {
    display: flex;
    width: 100%;
    height: 100dvh;
  }

  .mobile-back-btn {
    display: inline-flex;
    flex-shrink: 0;
  }

  .chat-header {
    height: auto;
    min-height: 58px;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    gap: 8px;
  }

  .chat-header-left {
    gap: 8px;
    min-width: 0;
    flex: 1;
  }

  .chat-header-left > div:last-child {
    min-width: 0;
    flex: 1;
  }

  .chat-title-row h2 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .e2ee-badge { display: none; }

  .chat-subtitle {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .message-list {
    padding: 12px 10px;
  }

  .msg-bubble {
    max-width: 88%;
    font-size: 14px;
  }

  .inline-video {
    max-width: 100%;
    max-height: 240px;
  }

  .composer {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .transfer-mode-bar {
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
  }

  .composer-row {
    gap: 6px;
  }

  .composer-row input[type="text"] {
    font-size: 16px; /* prevent iOS Safari/WKWebView auto-zoom on focus */
    padding: 10px 12px;
  }

  /* Modals on mobile */
  .modal-backdrop {
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    align-items: center;
  }

  .login-shell {
    grid-template-columns: 1fr;
    max-width: 100%;
    max-height: 92dvh;
    overflow-y: auto;
  }

  .login-hero {
    padding: 18px 18px 14px;
  }

  .login-hero h2 {
    font-size: 18px;
    margin: 10px 0 6px;
  }

  .login-hero .hero-desc,
  .login-hero .feature-list {
    display: none;
  }

  .login-form {
    padding: 18px;
  }

  .login-form input,
  .modal-card input {
    font-size: 16px;
  }

  .hub-modal,
  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 16px;
  }

  .tool-grid,
  .two-col-meta {
    grid-template-columns: 1fr;
  }

  /* Call Overlay on mobile */
  .call-info-bar {
    top: calc(14px + env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    justify-content: space-between;
    font-size: 13px;
  }

  .local-video {
    width: 110px;
    height: 155px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    right: 14px;
  }

  .call-controls {
    bottom: calc(20px + env(safe-area-inset-bottom));
    gap: 12px;
  }
}

/* =========================================================================
   MVT CHAT — iOS Styling, Telegram Wallpapers, Emoji, Alert, Delete & Call UI
   ========================================================================= */

.sidebar-header-btns { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.btn-pill-soft {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 34px;
  height: 32px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-pill-soft:hover { filter: brightness(1.12); }

/* Frosted iOS Glass Header & Composer */
.chat-pane {
  position: relative;
  overflow: hidden;
}
.chat-pane > * { position: relative; z-index: 2; }
.chat-header, .composer {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
}
.ios-send-btn {
  width: 38px;
  height: 38px;
  padding: 0 !important;
  border-radius: 50% !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ios-send-btn svg { width: 18px; height: 18px; }
.alert-nudge-btn {
  background: rgba(255, 69, 58, 0.16) !important;
  border-color: rgba(255, 69, 58, 0.35) !important;
}
.alert-nudge-btn:hover { background: rgba(255, 69, 58, 0.32) !important; }
.alert-nudge-2-btn {
  background: rgba(245, 158, 11, 0.16) !important;
  border-color: rgba(245, 158, 11, 0.38) !important;
}
.alert-nudge-2-btn:hover { background: rgba(245, 158, 11, 0.34) !important; }

/* Telegram-Style Patterned Wallpapers */
.chat-pane::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
}
.chat-pane::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.14;
  background-repeat: repeat;
  background-size: 220px 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M25 32c0-7 6-12 14-12s14 5 14 12-6 12-14 12l-10 4 2-8c-4-2-6-5-6-8z'/%3E%3Ccircle cx='105' cy='35' r='11'/%3E%3Cpath d='M100 33h.01M110 33h.01M100 39c2.5 2.5 7.5 2.5 10 0'/%3E%3Cpath d='M170 25l6 12 13 2-9 9 2 13-12-6-12 6 2-13-9-9 13-2z'/%3E%3Cpath d='M35 110c-8-7-16 1-11 9 4 6 11 11 11 11s7-5 11-11c5-8-3-16-11-9z'/%3E%3Crect x='92' y='96' width='26' height='18' rx='4'/%3E%3Cpath d='M92 101l13 7 13-7'/%3E%3Cpath d='M172 105c0-8 14-8 14 0 0 7-7 12-7 12s-7-5-7-12z'/%3E%3Ccircle cx='179' cy='104' r='2.5'/%3E%3Cpath d='M32 178l20-8-8 20-3-9-9-3z'/%3E%3Cpath d='M102 186v-20l16-4v18'/%3E%3Ccircle cx='98' cy='186' r='4'/%3E%3Ccircle cx='114' cy='180' r='4'/%3E%3Cpath d='M165 178a14 14 0 1 0 24-10 11 11 0 1 1-14 14z'/%3E%3C/svg%3E");
}
.chat-pane[data-wallpaper="telegram_night"]::before {
  background: radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.25), transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.25), transparent 50%),
              linear-gradient(145deg, #09131f 0%, #10243a 48%, #0d324d 100%);
}
.chat-pane[data-wallpaper="telegram_classic"]::before {
  background: radial-gradient(circle at 18% 18%, rgba(167, 243, 208, 0.28), transparent 45%),
              radial-gradient(circle at 85% 78%, rgba(125, 211, 252, 0.26), transparent 50%),
              linear-gradient(135deg, #1b3b4b 0%, #2f5d62 50%, #3d6b5e 100%);
}
.chat-pane[data-wallpaper="aurora_ios"]::before {
  background: radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.35), transparent 45%),
              radial-gradient(circle at 85% 25%, rgba(168, 85, 247, 0.35), transparent 45%),
              linear-gradient(160deg, #0b1026 0%, #1e1b4b 55%, #0c4a6e 100%);
}
.chat-pane[data-wallpaper="ocean_deep"]::before {
  background: radial-gradient(circle at 75% 20%, rgba(34, 211, 238, 0.28), transparent 50%),
              linear-gradient(150deg, #031926 0%, #0a4d68 55%, #088395 100%);
}
.chat-pane[data-wallpaper="sakura_sunset"]::before {
  background: radial-gradient(circle at 20% 25%, rgba(251, 146, 60, 0.28), transparent 45%),
              radial-gradient(circle at 80% 75%, rgba(236, 72, 153, 0.3), transparent 50%),
              linear-gradient(145deg, #27093d 0%, #6b1448 52%, #9a3412 100%);
}
.chat-pane[data-wallpaper="emerald_forest"]::before {
  background: radial-gradient(circle at 25% 80%, rgba(52, 211, 153, 0.25), transparent 45%),
              linear-gradient(145deg, #041f18 0%, #064e3b 55%, #0f766e 100%);
}
.chat-pane[data-wallpaper="minimal_ios"]::before {
  background: var(--chat-bg);
}
.chat-pane[data-wallpaper="minimal_ios"]::after {
  opacity: 0;
}
.chat-pane[data-wallpaper="custom"]::before {
  background-image: var(--custom-chat-bg);
  background-size: cover;
  background-position: center;
  filter: brightness(0.76);
}
.chat-pane[data-wallpaper="custom"]::after {
  opacity: 0;
}
.chat-pane[data-wallpaper="alert2_temp"]::before {
  background-image: url("alert2_bg.jpg");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #ffffff;
  opacity: 0.94;
}
.chat-pane[data-wallpaper="alert2_temp"]::after {
  opacity: 0;
}

/* Message Footer + Delete Button */
.msg-bubble {
  border-radius: 18px !important;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
}
.msg-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}
.msg-row.me .msg-meta-row { justify-content: flex-end; }
.msg-del-btn {
  background: rgba(15, 23, 42, 0.45);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.msg-del-btn:hover {
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
}
.btn-danger-sm {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger-sm:hover { background: var(--danger); color: #fff; }

/* Floating Emoji Picker */
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 12px;
  width: min(350px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 60;
  overflow: hidden;
  backdrop-filter: blur(20px);
}
.emoji-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  padding: 4px;
  gap: 4px;
}
.emoji-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 0;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
}
.emoji-tab-btn.active { background: rgba(10, 132, 255, 0.22); }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 210px;
  overflow-y: auto;
}
.emoji-item {
  border: none;
  background: transparent;
  font-size: 23px;
  padding: 5px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s;
}
.emoji-item:hover, .emoji-item:active {
  background: var(--surface-2);
  transform: scale(1.18);
}

/* iOS Dynamic Island Alert Banner + Screen Shake */
.ios-alert-banner {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(18, 18, 24, 0.92);
  border: 1px solid rgba(255, 69, 58, 0.65);
  box-shadow: 0 12px 36px rgba(255, 69, 58, 0.35);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  min-width: 260px;
  max-width: 92vw;
  backdrop-filter: blur(18px);
  animation: iosBannerDrop 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.ios-alert-icon { font-size: 24px; animation: iosBellPulse 0.5s infinite alternate; }
.ios-alert-title { font-weight: 700; font-size: 14px; color: #ff6961; }
.ios-alert-sub { font-size: 12px; color: #e2e8f0; }

@keyframes iosBannerDrop {
  from { opacity: 0; transform: translate(-50%, -26px) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes iosBellPulse {
  from { transform: rotate(-14deg) scale(1); }
  to { transform: rotate(14deg) scale(1.15); }
}
@keyframes mvtShake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-6px); }
  30%, 60%, 90% { transform: translateX(6px); }
}
body.mvt-shake { animation: mvtShake 0.48s ease-in-out 2; }

/* MVT Studio Modal (iOS Grouped Settings) */
.studio-modal { max-width: 560px !important; }
.ios-segmented {
  display: flex;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
  margin-bottom: 14px;
}
.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 6px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.16s;
}
.seg-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(10, 132, 255, 0.35);
}
.studio-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.ios-grouped-list {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}
.group-divider {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(10, 132, 255, 0.08);
  border-bottom: 1px solid var(--border);
}
.sound-row, .font-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.sound-row:last-child, .font-row:last-child { border-bottom: none; }
.sound-row.active, .font-row.active { background: rgba(10, 132, 255, 0.14); }
.sound-row-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.sound-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}
.sound-row.active .sound-check,
.font-row.active .sound-check {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.sound-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-play-tone {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-play-tone:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.wp-card {
  position: relative;
  height: 96px;
  border-radius: 14px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  padding: 8px;
  transition: transform 0.15s;
}
.wp-card:hover { transform: scale(1.03); }
.wp-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.35); }
.wp-label {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}

/* =========================================================================
   Gorgeous Fullscreen iOS Incoming Call Screen
   ========================================================================= */
.ios-call-screen {
  position: fixed;
  inset: 0;
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060913;
  overflow: hidden;
}
.ios-call-bg-glow {
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 30% 25%, rgba(10, 132, 255, 0.55), transparent 45%),
    radial-gradient(circle at 75% 30%, rgba(168, 85, 247, 0.5), transparent 45%),
    radial-gradient(circle at 50% 80%, rgba(16, 185, 129, 0.42), transparent 50%);
  filter: blur(55px);
  animation: iosCallAura 8s ease-in-out infinite alternate;
}
@keyframes iosCallAura {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.12) rotate(12deg); }
}
.ios-call-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 760px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(44px + env(safe-area-inset-top)) 24px calc(48px + env(safe-area-inset-bottom));
  text-align: center;
  color: #fff;
}
.ios-call-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.ios-call-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.ios-call-avatar-wrap {
  position: relative;
  width: 144px;
  height: 144px;
  margin: 14px 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ios-call-avatar {
  position: relative;
  z-index: 3;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6, #bf5af2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 12px 35px rgba(10, 132, 255, 0.55);
  border: 3px solid rgba(255, 255, 255, 0.45);
}
.ios-ripple {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  animation: iosRipple 2.4s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
.ios-ripple.r2 { animation-delay: 0.8s; }
.ios-ripple.r3 { animation-delay: 1.6s; }
@keyframes iosRipple {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.95); opacity: 0; }
}
.ios-caller-name {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.4px;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}
.ios-caller-sub {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.82);
}
.ios-wave-bars {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  margin-top: 4px;
}
.ios-wave-bars span {
  width: 4px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #60a5fa, #34d399);
  animation: iosWave 0.9s ease-in-out infinite alternate;
}
.ios-wave-bars span:nth-child(2) { animation-delay: 0.12s; }
.ios-wave-bars span:nth-child(3) { animation-delay: 0.24s; }
.ios-wave-bars span:nth-child(4) { animation-delay: 0.36s; }
.ios-wave-bars span:nth-child(5) { animation-delay: 0.24s; }
.ios-wave-bars span:nth-child(6) { animation-delay: 0.12s; }
@keyframes iosWave {
  0% { height: 6px; opacity: 0.55; }
  100% { height: 26px; opacity: 1; }
}
.ios-ringtone-pill {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 14px;
  border-radius: 999px;
  backdrop-filter: blur(10px);
}
.ios-call-actions {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 18px;
}
.ios-call-btn-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}
.ios-circle-btn {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.ios-circle-btn svg { width: 32px; height: 32px; }
.ios-circle-btn.decline {
  background: linear-gradient(135deg, #ff3b30, #dc2626);
  box-shadow: 0 10px 28px rgba(255, 59, 48, 0.45);
}
.ios-circle-btn.accept {
  background: linear-gradient(135deg, #30d158, #16a34a);
  box-shadow: 0 10px 28px rgba(48, 209, 88, 0.5);
  animation: iosAcceptBounce 1.4s ease-in-out infinite;
}
.ios-circle-btn:active { transform: scale(0.92); }
@keyframes iosAcceptBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}


/* ============================================================
 * MVT CHAT v4.2.0 — Zalo Info Drawer, Reactions, Avatars, Unread,
 * Red/Yellow Host-Client Colors, Lightbox & Keyword Particle FX
 * ============================================================ */

.msg-bubble {
  user-select: text !important;
  -webkit-user-select: text !important;
}

.avatar-circle {
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.avatar-emoji {
  font-size: 20px;
  line-height: 1;
}

/* Unread counter badge in sidebar */
.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ff3b30;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.45);
}

/* Host (Red) vs Client (Yellow) Role Badges & Per-Character Colors */
.msg-sender-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 700;
}
.msg-avatar-mini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.role-badge-host {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 59, 48, 0.22);
  color: #ff6961;
  border: 1px solid rgba(255, 59, 48, 0.6);
}
.role-badge-client {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.18);
  color: #fde047;
  border: 1px solid rgba(250, 204, 21, 0.55);
}
.msg-row.is-host-msg .msg-bubble {
  border: 1.5px solid rgba(255, 69, 58, 0.72) !important;
  box-shadow: 0 0 12px rgba(255, 59, 48, 0.18);
}
.msg-row.is-client-msg .msg-bubble {
  border: 1.5px solid rgba(250, 204, 21, 0.58) !important;
}

/* Message Reactions & Quick Action Bar */
.msg-reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f8fafc;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.reaction-pill:hover {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.18);
}
.reaction-pill.mine {
  background: rgba(10, 132, 255, 0.28);
  border-color: rgba(56, 189, 248, 0.7);
}
.msg-quick-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}
.msg-react-btn, .msg-copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.msg-react-btn:hover, .msg-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

/* Enhanced Visual Media Card & Lightbox */
.inline-img-clickable {
  max-width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 12px;
  cursor: zoom-in;
  display: block;
  transition: transform 0.15s ease;
}
.inline-img-clickable:hover {
  transform: scale(1.01);
}
.media-dl-btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 600 !important;
  padding: 6px 12px !important;
  border-radius: 9px !important;
}

.mvt-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(8, 12, 20, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}
.mvt-lightbox-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.mvt-lightbox-title { color: #f8fafc; font-weight: 600; font-size: 14px; }
.mvt-lightbox-btns { display: flex; gap: 10px; }
.mvt-lb-dl {
  padding: 7px 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.mvt-lb-close {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  cursor: pointer;
}
.mvt-lightbox-img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
  margin-top: 44px;
}

/* Zalo-Style Right Conversation Info Panel (Thông tin hội thoại) */
.info-drawer {
  width: 310px;
  min-width: 280px;
  max-width: 330px;
  background: rgba(20, 22, 29, 0.96);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.info-drawer.hidden { display: none !important; }
.info-drawer-header {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  flex-shrink: 0;
}
.info-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.info-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 6px 14px;
  border-bottom: 1px solid var(--border);
}
.info-avatar-big {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007aff, #5856d6);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 122, 255, 0.35);
  margin-bottom: 10px;
}
.info-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.info-edit-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 12px;
}
.info-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}
.info-quick-actions {
  display: flex;
  gap: 18px;
  margin-top: 14px;
}
.info-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.info-quick-btn:hover { color: var(--text); }
.info-quick-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.info-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.info-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.info-count-pill {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 999px;
}
.info-media-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.info-media-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.info-media-thumb img, .info-media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.info-media-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  font-size: 16px;
}
.info-file-list, .info-link-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.info-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.15s ease;
}
.info-file-item:hover { background: rgba(255, 255, 255, 0.11); }
.info-file-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.info-file-meta { min-width: 0; flex: 1; }
.info-file-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.info-file-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.info-link-item {
  font-size: 12px;
  color: #38bdf8;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.info-link-item:hover { background: rgba(56, 189, 248, 0.18); }
.info-see-all {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.info-see-all:hover { background: rgba(255, 255, 255, 0.14); }
.info-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 6px 0; }

/* Avatar Picker Modal */
.mvt-picker-card {
  width: 360px;
  max-width: 92vw;
  background: #161b26;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 18px;
  color: #f8fafc;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}
.mvt-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.mvt-picker-head h3 { margin: 0; font-size: 15px; }
.mvt-picker-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
}
.mvt-icon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.mvt-icon-btn {
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.mvt-icon-btn:hover { transform: scale(1.1); background: rgba(255, 255, 255, 0.15); }
.mvt-icon-btn.selected { border-color: #38bdf8; background: rgba(56, 189, 248, 0.25); }
.mvt-picker-actions {
  display: flex;
  gap: 10px;
}
.mvt-upload-avatar-btn {
  flex: 1;
  text-align: center;
  padding: 9px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, #007aff, #0a84ff);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.mvt-reset-avatar-btn {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 13px;
  cursor: pointer;
}

/* Keyword Particle FX Overlay */
.mvt-fx-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
}
.fx-particle {
  position: fixed;
  user-select: none;
  will-change: transform, opacity;
}
.fx-tear {
  top: -40px;
  animation: fxTearFall linear forwards;
}
.fx-laugh {
  bottom: -50px;
  animation: fxLaughRise ease-out forwards;
}
.fx-storm-clouds {
  position: fixed;
  top: -10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  font-size: 74px;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.85)) brightness(0.55);
  animation: fxCloudFade 4.2s ease-in-out forwards;
}
.fx-rain-drop {
  position: fixed;
  top: -30px;
  width: 2px;
  background: linear-gradient(to bottom, rgba(147, 197, 253, 0), rgba(147, 197, 253, 0.85));
  transform: rotate(12deg);
  animation: fxRainFall linear infinite;
}
.fx-lightning-flash {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.42);
  animation: fxLightningFlash 0.45s ease-out forwards;
}
.fx-lightning-bolt {
  position: fixed;
  top: 40px;
  font-size: 96px;
  filter: drop-shadow(0 0 26px #fde047);
  animation: fxLightningFlash 0.5s ease-out forwards;
}

@keyframes fxTearFall {
  0% { transform: translateY(0) translateX(0) scale(0.9); opacity: 0.95; }
  50% { transform: translateY(52vh) translateX(14px) scale(1.05); opacity: 0.9; }
  100% { transform: translateY(108vh) translateX(-10px) scale(0.85); opacity: 0; }
}
@keyframes fxLaughRise {
  0% { transform: translateY(0) translateX(0) scale(0.7) rotate(-10deg); opacity: 0; }
  15% { opacity: 1; }
  60% { transform: translateY(-62vh) translateX(22px) scale(1.15) rotate(12deg); opacity: 0.95; }
  100% { transform: translateY(-112vh) translateX(-18px) scale(0.9) rotate(-14deg); opacity: 0; }
}
@keyframes fxRainFall {
  0% { transform: translate(0, 0) rotate(12deg); opacity: 0.9; }
  100% { transform: translate(-18vw, 110vh) rotate(12deg); opacity: 0.25; }
}
@keyframes fxCloudFade {
  0% { opacity: 0; transform: translateY(-30px); }
  15% { opacity: 0.95; transform: translateY(0); }
  85% { opacity: 0.95; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-30px); }
}
@keyframes fxLightningFlash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  45% { opacity: 0.2; }
  65% { opacity: 0.9; }
  100% { opacity: 0; }
}

@media (max-width: 1020px) {
  .info-drawer { display: none; }
}

/* In-Chat Search Bar & Pinned Message Banner */
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(18, 24, 38, 0.96);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-search-bar.hidden { display: none !important; }
.chat-search-bar input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 7px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.chat-search-bar input:focus { border-color: #38bdf8; }
.chat-search-count { font-size: 12px; color: var(--muted); min-width: 44px; text-align: center; }
.chat-search-nav {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
}
.chat-search-nav:hover { background: rgba(255, 255, 255, 0.18); }

.pinned-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(24, 32, 48, 0.92);
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
  flex-shrink: 0;
}
.pinned-bar.hidden { display: none !important; }
.pinned-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}
.pinned-icon { font-size: 16px; }
.pinned-content { min-width: 0; flex: 1; }
.pinned-label { font-size: 11px; font-weight: 700; color: #38bdf8; }
.pinned-text {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pinned-bar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pinned-count-btn {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.pinned-count-btn.hidden { display: none !important; }
.pinned-unpin-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 3px 6px;
}
.pinned-unpin-btn:hover { color: #ff453a; }

.msg-row.msg-highlight .msg-bubble {
  outline: 2.5px solid #38bdf8;
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.65) !important;
  transition: box-shadow 0.3s ease;
}
