/* ─── CipherTalk — Dark UI ────────────────────────────────────────────── */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a28;
  --bg-hover: #22223a;
  --bg-active: #2a2a45;
  --border: #2a2a40;
  --border-light: #3a3a55;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #5a5a78;
  --accent: #818cf8;
  --accent-glow: rgba(129, 140, 248, .25);
  --accent-2: #c084fc;
  --gradient: linear-gradient(135deg, #818cf8, #c084fc);
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;
  --own-bubble: #2d2b55;
  --other-bubble: #1a1a28;
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-width: 360px;
  --font: 'Nunito', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%; overflow: hidden;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ─── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── Auth Screen ────────────────────────────────────────────────────── */
.auth-screen {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(ellipse at 20% 50%, rgba(129,140,248,.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(192,132,252,.06) 0%, transparent 50%);
}

.auth-container {
  width: 100%; max-width: 400px; padding: 40px 32px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  margin: 16px;
}

.auth-logo { text-align: center; margin-bottom: 32px; }
.logo-icon { width: 72px; height: 72px; margin: 0 auto 16px; }
.logo-icon svg { width: 100%; height: 100%; }
.auth-title {
  font-size: 28px; font-weight: 800;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.auth-tabs { display: flex; gap: 4px; margin-bottom: 24px; background: var(--bg-tertiary); border-radius: var(--radius-sm); padding: 4px; }
.auth-tab {
  flex: 1; padding: 10px; border: none; background: none;
  color: var(--text-secondary); font-family: var(--font); font-weight: 600;
  border-radius: 8px; cursor: pointer; transition: all .2s;
}
.auth-tab.active { background: var(--accent); color: white; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input, .modal-input {
  width: 100%; padding: 14px 16px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font); font-size: 15px; outline: none; transition: border-color .2s;
}
.auth-form input:focus, .modal-input:focus { border-color: var(--accent); }
.auth-form input::placeholder, .modal-input::placeholder { color: var(--text-muted); }

.btn-primary {
  padding: 14px; border: none; border-radius: var(--radius-sm);
  background: var(--gradient); color: white;
  font-family: var(--font); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: opacity .2s, transform .1s;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:active { transform: scale(.98); }

.auth-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 12px; font-family: var(--font-mono);
}

/* ─── App Layout ─────────────────────────────────────────────────────── */
.app-screen { display: flex; height: 100%; }

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width); max-width: 100vw;
  display: flex; flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
}

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

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 18px;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none;
  background: var(--bg-tertiary); border-radius: 10px;
  color: var(--text-secondary); cursor: pointer; transition: all .2s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.search-box {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 16px; padding: 10px 14px;
  background: var(--bg-tertiary); border-radius: var(--radius-sm);
  border: 1px solid transparent; transition: border-color .2s;
}
.search-box:focus-within { border-color: var(--border-light); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  flex: 1; border: none; background: none; outline: none;
  color: var(--text-primary); font-family: var(--font); font-size: 14px;
}
.search-box input::placeholder { color: var(--text-muted); }

.sidebar-actions {
  display: flex; gap: 8px; padding: 0 16px 12px;
}
.sidebar-action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px; border: 1px dashed var(--border);
  background: none; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-family: var(--font); font-size: 12px;
  cursor: pointer; transition: all .2s;
}
.sidebar-action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px; }

.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }

.chat-avatar {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: white; position: relative; flex-shrink: 0;
}
.chat-avatar.small { width: 36px; height: 36px; font-size: 14px; border-radius: 10px; }

.status-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--bg-secondary);
}
.status-dot.online { background: var(--success); }

.chat-info { flex: 1; min-width: 0; }
.chat-info-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.chat-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; margin-left: 8px; font-family: var(--font-mono); }
.chat-info-bottom { display: flex; justify-content: space-between; align-items: center; }
.chat-preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.unread-badge {
  background: var(--accent); color: white;
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px; flex-shrink: 0; margin-left: 8px;
}

.empty-chats { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 14px; }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }

/* ─── Chat Area ──────────────────────────────────────────────────────── */
.chat-area {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg-primary);
  background-image:
    radial-gradient(circle at 70% 80%, rgba(129,140,248,.03) 0%, transparent 40%),
    radial-gradient(circle at 30% 20%, rgba(192,132,252,.02) 0%, transparent 40%);
}

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.chat-header-info { min-width: 0; }
.header-name {
  font-weight: 700; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 8px;
}
.header-status { font-size: 12px; color: var(--text-muted); }
.header-status.online { color: var(--success); }

.encrypt-badge {
  font-size: 11px; font-family: var(--font-mono);
  padding: 2px 8px; background: rgba(52,211,153,.15);
  color: var(--success); border-radius: 6px;
}

.back-btn { display: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
}

.message { display: flex; gap: 8px; max-width: 75%; animation: msgIn .25s ease; }
.message.own { margin-left: auto; flex-direction: row-reverse; }
.message.other { margin-right: auto; }

@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar { flex-shrink: 0; width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: white; margin-top: auto; }

.msg-bubble {
  padding: 10px 14px; border-radius: 16px 16px 16px 4px;
  background: var(--other-bubble); border: 1px solid var(--border);
  word-break: break-word;
}
.msg-bubble.own { border-radius: 16px 16px 4px 16px; background: var(--own-bubble); border-color: rgba(129,140,248,.2); }

.msg-sender { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.msg-content { font-size: 14px; line-height: 1.5; }
.msg-content a { color: var(--accent); text-decoration: underline; }
.msg-content code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; font-family: var(--font-mono); font-size: 13px; }
.msg-content img.msg-image { max-width: 280px; border-radius: 10px; cursor: pointer; }

.msg-meta { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 4px; font-family: var(--font-mono); }
.edited { font-style: italic; }

.message-system { text-align: center; padding: 8px 0; }
.message-system span {
  font-size: 12px; color: var(--text-muted);
  background: var(--bg-tertiary); padding: 4px 14px; border-radius: 20px;
}

.typing-indicator {
  padding: 4px 20px; font-size: 12px; color: var(--accent);
  font-style: italic; animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

.message-input-area {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}
.message-input-area textarea {
  flex: 1; padding: 12px 16px; resize: none;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font); font-size: 14px; outline: none;
  max-height: 120px; transition: border-color .2s;
}
.message-input-area textarea:focus { border-color: var(--accent); }
.message-input-area textarea::placeholder { color: var(--text-muted); }

.send-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: none;
  background: var(--gradient); border-radius: 12px;
  color: white; cursor: pointer; transition: opacity .2s, transform .1s;
}
.send-btn:hover { opacity: .85; }
.send-btn:active { transform: scale(.95); }

/* ─── Empty State ────────────────────────────────────────────────────── */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: 12px;
}
.empty-state h2 {
  font-size: 24px; font-weight: 800;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.empty-state p { font-size: 14px; }
.encrypt-note { font-family: var(--font-mono); font-size: 12px !important; opacity: .6; }

/* ─── Modals ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 20px; padding: 24px;
  width: 100%; max-width: 420px; max-height: 80vh; overflow: hidden;
  display: flex; flex-direction: column; animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 18px; font-weight: 700; }

.user-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.user-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
}
.user-item:hover { background: var(--bg-hover); }
.user-item-name { font-weight: 600; font-size: 14px; }
.user-item-username { font-size: 12px; color: var(--text-muted); }

.group-member-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
}
.group-member-item:hover { background: var(--bg-hover); }
.group-member-item input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }

/* ─── Toasts ─────────────────────────────────────────────────────────── */
.toasts { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-primary); font-family: var(--font); font-size: 14px;
  opacity: 0; transform: translateX(40px); transition: all .3s ease;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--error); color: var(--error); }

/* ─── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; }
  .chat-area { position: absolute; inset: 0; z-index: 10; display: none; }
  .chat-area.show-mobile { display: flex; }
  .sidebar.hidden-mobile { display: none; }
  .back-btn { display: flex; }
  .empty-state { display: none; }
  .message { max-width: 85%; }
}

@media (min-width: 769px) {
  .back-btn { display: none; }
  .chat-area:not(.hidden) ~ .empty-state { display: none; }
}

/* ─── Smooth transitions ─────────────────────────────────────────────── */
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ─── Setup Banner ───────────────────────────────────────────────────── */
.setup-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; margin-bottom: 16px;
  background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.25);
  border-radius: var(--radius-sm); color: var(--success);
  font-size: 13px; font-weight: 600;
}

/* ─── Invite Status ──────────────────────────────────────────────────── */
.invite-status {
  font-size: 12px; margin-top: 4px; padding: 0 4px; min-height: 18px;
  font-family: var(--font-mono); transition: color .2s;
}
.invite-status.valid { color: var(--success); }
.invite-status.invalid { color: var(--error); }
.invite-status.checking { color: var(--text-muted); }

/* ─── Role Badge ─────────────────────────────────────────────────────── */
.role-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono); letter-spacing: .5px;
}
.role-badge.admin, .role-badge.superadmin {
  background: rgba(129,140,248,.15); color: var(--accent);
}

/* ─── Admin Panel ────────────────────────────────────────────────────── */
.admin-modal { max-width: 600px; max-height: 85vh; }

.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--bg-tertiary); border-radius: var(--radius-sm); padding: 4px;
}
.admin-tab {
  flex: 1; padding: 10px; border: none; background: none;
  color: var(--text-secondary); font-family: var(--font); font-weight: 600;
  border-radius: 8px; cursor: pointer; transition: all .2s; font-size: 13px;
}
.admin-tab.active { background: var(--accent); color: white; }

.admin-tab-content { overflow-y: auto; max-height: 55vh; }

.admin-list { display: flex; flex-direction: column; gap: 6px; }

.admin-user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s;
}
.admin-user-card:hover { border-color: var(--border-light); }
.admin-user-card.blocked { opacity: .5; }

.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.admin-user-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }

.admin-user-actions { display: flex; gap: 4px; flex-shrink: 0; }

.admin-action-btn {
  padding: 6px 10px; border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-secondary);
  font-family: var(--font); font-size: 11px; font-weight: 600;
  border-radius: 6px; cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.admin-action-btn:hover { border-color: var(--border-light); color: var(--text-primary); }
.admin-action-btn.danger { border-color: rgba(248,113,113,.3); color: var(--error); }
.admin-action-btn.danger:hover { background: rgba(248,113,113,.1); }
.admin-action-btn.warn { border-color: rgba(251,191,36,.3); color: var(--warning); }
.admin-action-btn.warn:hover { background: rgba(251,191,36,.1); }
.admin-action-btn.success { border-color: rgba(52,211,153,.3); color: var(--success); }
.admin-action-btn.success:hover { background: rgba(52,211,153,.1); }

/* ─── Invite Cards ───────────────────────────────────────────────────── */
.invite-create-form {
  padding: 16px; background: var(--bg-tertiary);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
}

.form-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.modal-input select, select.modal-input {
  width: 100%; padding: 14px 16px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font); font-size: 15px; outline: none;
}

.invite-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.invite-card.expired { opacity: .4; }
.invite-card.used-up { opacity: .4; }

.invite-code-display {
  font-family: var(--font-mono); font-size: 18px; font-weight: 600;
  letter-spacing: 3px; color: var(--accent);
  padding: 6px 14px; background: rgba(129,140,248,.1);
  border-radius: 8px; cursor: pointer; user-select: all; transition: background .15s;
}
.invite-code-display:hover { background: rgba(129,140,248,.2); }

.invite-info { flex: 1; min-width: 0; }
.invite-label-text { font-weight: 600; font-size: 13px; }
.invite-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }

.invite-usage {
  font-family: var(--font-mono); font-size: 12px;
  padding: 3px 8px; border-radius: 6px;
  background: var(--bg-secondary); color: var(--text-secondary);
}
.invite-usage.full { color: var(--error); }

/* ─── Copy tooltip ───────────────────────────────────────────────────── */
.copy-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: white; padding: 8px 20px;
  border-radius: 20px; font-size: 13px; font-weight: 600;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 300;
}
.copy-toast.show { opacity: 1; }

/* ─── File message card ──────────────────────────────────────────────── */
.msg-file-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  text-decoration: none; color: var(--text-primary);
  min-width: 200px; max-width: 280px;
  transition: background .15s;
}
.msg-file-card:hover { background: rgba(255,255,255,0.1); }
.msg-file-icon { font-size: 28px; flex-shrink: 0; }
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-file-size { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.msg-file-dl {
  font-size: 18px; color: var(--accent); flex-shrink: 0;
  font-weight: 700;
}
.msg-image-wrap { line-height: 0; }
.msg-image {
  max-width: 260px; max-height: 300px;
  border-radius: 10px; cursor: pointer;
  display: block;
  transition: opacity .15s;
}
.msg-image:hover { opacity: .9; }

/* ─── Emoji picker ───────────────────────────────────────────────────── */
.message-input-area { position: relative; }

.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 320px;
  max-height: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.emoji-picker.hidden { display: none; }

.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.emoji-tabs::-webkit-scrollbar { display: none; }

.emoji-tab {
  background: none; border: none; cursor: pointer;
  font-size: 18px; padding: 4px 8px; border-radius: 6px;
  opacity: 0.5; transition: opacity .15s, background .15s;
  flex-shrink: 0;
}
.emoji-tab:hover { opacity: 0.8; background: var(--bg-hover); }
.emoji-tab.active { opacity: 1; background: var(--bg-hover); }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}
.emoji-grid::-webkit-scrollbar { width: 4px; }
.emoji-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.emoji-btn {
  background: none; border: none; cursor: pointer;
  font-size: 22px; padding: 4px; border-radius: 6px;
  transition: background .1s; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.emoji-btn:hover { background: var(--bg-hover); transform: scale(1.2); }

/* ─── Call UI ────────────────────────────────────────────────────────── */
.call-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.call-overlay.hidden { display: none; }

.call-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 48px;
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  min-width: 280px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}

.call-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; color: #fff;
  margin-bottom: 4px;
}
.call-name { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.call-subtitle { font-size: 13px; color: var(--text-muted); }
.call-timer { font-size: 22px; font-weight: 500; color: var(--accent); font-variant-numeric: tabular-nums; min-height: 32px; }

.call-actions { display: flex; gap: 20px; margin-top: 16px; align-items: center; }

.call-btn {
  width: 56px; height: 56px; border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, opacity .15s;
  color: #fff;
}
.call-btn:hover { transform: scale(1.08); }
.call-btn:active { transform: scale(.95); }

.call-btn.accept { background: #22c55e; }
.call-btn.decline { background: #ef4444; }
.call-btn.mute {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.call-btn.mute.active {
  background: rgba(239,68,68,.15);
  border-color: #ef4444;
  color: #ef4444;
}

/* Pulse animation on incoming call avatar */
@keyframes callPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
  50% { box-shadow: 0 0 0 16px rgba(34,197,94,0); }
}
#incoming-call .call-avatar { animation: callPulse 1.5s ease-in-out infinite; }

/* Call button in header */
#call-btn { color: var(--text-secondary); }
#call-btn:hover { color: #22c55e; }

/* ─── Message ticks ──────────────────────────────────────────────────── */
.msg-ticks {
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
  vertical-align: middle;
  line-height: 1;
}
.msg-ticks svg {
  display: block;
}
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
}

/* ─── Video call ─────────────────────────────────────────────────────── */
.call-box {
  position: relative;
}
#call-box-inner {
  min-width: 320px;
}
.call-remote-video {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16/9;
  border-radius: 12px;
  background: #000;
  object-fit: cover;
  display: block;
}
.call-local-video {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 100px;
  aspect-ratio: 4/3;
  border-radius: 8px;
  background: #111;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.2);
  z-index: 10;
  transition: opacity .2s;
}
#call-video-area {
  width: 100%;
  position: relative;
  margin-bottom: 8px;
}
#call-video-area.hidden { display: none; }

/* Video call btn in header */
#video-call-btn { color: var(--text-secondary); }
#video-call-btn:hover { color: #818cf8; }

/* ─── Voice messages ─────────────────────────────────────────────────── */
.msg-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 18px;
  min-width: 180px;
  max-width: 260px;
}
.voice-play-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform .15s, opacity .15s;
}
.voice-play-btn:hover { transform: scale(1.08); }
.voice-play-btn.playing { background: #f59e0b; }

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  height: 28px;
}
.voice-bar {
  width: 3px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.5;
  transition: height .1s ease, opacity .1s;
  min-height: 4px;
}
.voice-play-btn.playing ~ .voice-waveform .voice-bar {
  opacity: 1;
}
.voice-dur {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Recording state for mic button */
#voice-msg-btn.recording {
  color: #ef4444;
  animation: recPulse .8s ease-in-out infinite;
}
@keyframes recPulse {
  0%,100% { opacity: 1; }
  50% { opacity: .4; }
}
