/* ══════════════════════════════════════════════════════════════════════════════
   TeamTalk — Corporate Messenger Styles
   Dark theme with glassmorphism, gradients, and micro-animations
   ══════════════════════════════════════════════════════════════════════════════ */

/* Setup screen (Capacitor first launch) */
.setup-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary, #0f0f17);
  overflow: auto;
}

:root {
  --bg-primary: #0f0f17;
  --bg-secondary: #161625;
  --bg-tertiary: #1e1e32;
  --bg-hover: #252540;
  --bg-active: #2a2a4a;
  --surface: rgba(30, 30, 55, 0.7);
  --glass: rgba(30, 30, 55, 0.5);
  --glass-border: rgba(100, 100, 200, 0.15);

  --text-primary: #e8e8f0;
  --text-secondary: #9d9dbc;
  --text-muted: #6b6b8a;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

  --green: #22c55e;
  --red: #ef4444;
  --orange: #f97316;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 24px 0;
}

.auth-bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: orbFloat 8s ease-in-out infinite;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: #6366f1;
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 350px;
  height: 350px;
  background: #8b5cf6;
  bottom: -80px;
  right: -80px;
  animation-delay: -3s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: #ec4899;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -5s;
}

@keyframes orbFloat {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -30px) scale(1.05);
  }

  66% {
    transform: translate(-20px, 20px) scale(0.95);
  }
}

.auth-card {
  background: var(--glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  margin: auto;
  flex-shrink: 0;
  animation: cardAppear 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto 2px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logo-icon img {
  display: block;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: #ffffff;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: #1a1a2e;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.auth-error {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.05);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  gap: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--accent-hover);
  text-decoration: none;
  font-weight: 500;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ── Auth link buttons ─────────────────────────────────────────── */
.auth-link-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
  text-decoration: underline;
  width: 100%;
  text-align: center;
  font-family: inherit;
  transition: color 0.15s;
}

.auth-link-btn:hover {
  color: var(--accent);
}

/* ── Auth warnings & notes ─────────────────────────────────────── */
.auth-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 12px;
  color: #f59e0b;
}

.auth-note {
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 11px;
  line-height: 1.5;
}

.auth-note-warning {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.auth-note-info {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--text-secondary);
}

.auth-hint-box {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Recovery method selector ──────────────────────────────────── */
.recovery-method-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.recovery-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.15s;
  flex-wrap: wrap;
}

.recovery-option:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
}

.recovery-option input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
  flex-shrink: 0;
}

.recovery-option-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.recovery-option-desc {
  font-size: 11px;
  color: var(--text-muted);
  width: 100%;
  padding-left: 24px;
  margin-top: -2px;
}

.recovery-fields {
  animation: slideUp 0.2s ease;
}

.recovery-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

/* ── Mnemonic grid ─────────────────────────────────────────────── */
.mnemonic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 10px 0;
}

.mnemonic-word {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.mnemonic-word-num {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 14px;
}

.mnemonic-word-text {
  color: var(--text-primary);
  font-weight: 500;
}

.mnemonic-verify-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 10px;
  text-align: center;
  letter-spacing: 1px;
}

.mnemonic-verify-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-mnemonic-recovery {
  margin-top: 10px;
}

.auth-mnemonic-recovery textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  outline: none;
  resize: vertical;
  margin: 6px 0 8px;
}

.auth-mnemonic-recovery textarea:focus {
  border-color: var(--accent);
}

/* ── Field status indicators ───────────────────────────────────── */
.field-status {
  font-size: 11px;
  margin-top: 4px;
  min-height: 16px;
  transition: color 0.15s;
}

.field-status.status-ok {
  color: #34d399;
}

.field-status.status-error {
  color: #f87171;
}

.field-status.status-checking {
  color: var(--text-muted);
}

/* ── Password strength bar ─────────────────────────────────────── */
.password-strength {
  height: 3px;
  border-radius: 2px;
  margin-top: 6px;
  background: var(--glass-border);
  overflow: hidden;
}

.password-strength-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}

/* ── Small button variant ──────────────────────────────────────── */
.btn-sm {
  padding: 8px 12px !important;
  font-size: 13px !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   MAIN APP LAYOUT
   ══════════════════════════════════════════════════════════════════════════════ */
.app-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-height, 100vh);
  display: flex;
  overflow: hidden;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: #0A0A14;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Stitch-inspired gradient blobs */
.sidebar::before {
  content: '';
  position: absolute;
  top: -40px;
  left: -60px;
  width: 220px;
  height: 220px;
  background: rgba(124, 93, 255, 0.18);
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
}

.sidebar::after {
  content: '';
  position: absolute;
  bottom: 8%;
  right: -60px;
  width: 260px;
  height: 260px;
  background: rgba(255, 78, 142, 0.08);
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}

/* Sidebar children above blobs */
.sidebar>* {
  position: relative;
  z-index: 1;
}

.sidebar-header {
  padding: 5px 0 0 5px;
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

/* ── Glass Pill Button (Contacts) ────────────────────────────────────── */
.sidebar-tab-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(124, 93, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(124, 93, 255, 0.15);
  border-radius: 10px 10px 10px 2px;
  cursor: pointer;
  transition: all 0.25s;
  margin-left: auto;
  margin-right: 12px;
  white-space: nowrap;
}

.sidebar-tab-toggle svg {
  width: 14px;
  height: 14px;
}

.sidebar-tab-toggle:hover {
  color: var(--text-primary);
  background: rgba(124, 93, 255, 0.18);
  border-color: rgba(124, 93, 255, 0.3);
  box-shadow: 0 0 12px rgba(124, 93, 255, 0.15);
}

.sidebar-tab-toggle.active {
  color: #7C5DFF;
  background: rgba(124, 93, 255, 0.15);
  border-color: rgba(124, 93, 255, 0.3);
  box-shadow: 0 0 16px rgba(124, 93, 255, 0.2);
}

.sidebar-tab-toggle .badge {
  font-size: 10px;
}

.sidebar-tab-panel {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Chats panel: flex column for 50/50 split */
.chats-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 50%;
  transition: flex 0.25s ease;
  overflow: hidden;
}

.chat-section.collapsed {
  flex: 0 0 auto;
}

.logo-small {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 10px 15px;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 16px;
}

.logo-small img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
}

.sidebar-section {
  padding: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 8px 16px;
  flex-shrink: 0;
}

.section-toggle {
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.section-toggle:hover {
  color: var(--text-secondary);
  background: var(--glass-bg);
}

.section-chevron {
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.chat-section:not(.collapsed) .section-chevron {
  transform: rotate(180deg);
}

.section-body {
  flex: 1;
  overflow-y: hidden;
  padding: 0 8px;
  scrollbar-width: none;
  transition: opacity 0.2s ease;
}

.chat-section.collapsed .section-body {
  display: none;
}

/* Show thin scrollbar on hover */
.section-body:hover {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}

.section-body:hover::-webkit-scrollbar {
  width: 4px;
}

.section-body:hover::-webkit-scrollbar-track {
  background: transparent;
}

.section-body:hover::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 4px;
}

/* Also show scrollbar when sidebar itself is hovered */
.sidebar:hover .sidebar-tab-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}

.sidebar:hover .sidebar-tab-panel::-webkit-scrollbar {
  width: 4px;
}

.sidebar:hover .sidebar-tab-panel::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar:hover .sidebar-tab-panel::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 4px;
}

/* Contact search tabs */
.contact-search-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.contact-tab {
  flex: 1;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.contact-tab:hover {
  color: var(--text-secondary);
}

.contact-tab.active {
  background: var(--accent);
  color: white;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  z-index: 10000;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  color: var(--text-secondary);
  position: relative;
}

.nav-item-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.nav-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.nav-item-preview {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

.nav-item.contact-offline {
  opacity: 0.5;
}

.nav-item.contact-offline:hover {
  opacity: 0.8;
}

.dm-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: 4px;
}

.dm-header-actions .btn-icon-sm {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
}

.dm-header-actions .btn-icon-sm:hover {
  background: var(--glass-bg);
  color: var(--text-primary);
}

.search-result-item {
  border-bottom: 1px solid var(--glass-border);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.ch-avatar {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  letter-spacing: 0.5px;
}

.ch-avatar-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 9px;
  line-height: 1;
}

.ch-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-filter-btn {
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.15s;
  opacity: 0.6;
}

.ch-filter-btn:hover {
  opacity: 1;
  color: var(--accent);
}

.ch-filter-btn.active {
  opacity: 1;
  color: var(--accent);
  background: var(--glass-bg);
}

/* ── Channel Browser ──────────────────────────────────────────────── */
.ch-sort-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.ch-sort-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

.ch-sort-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.ch-browse-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.ch-browse-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.ch-browse-card .ch-avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
  border-radius: 8px;
}

.ch-browse-info {
  flex: 1;
  min-width: 0;
}

.ch-browse-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ch-browse-desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.ch-browse-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.ch-browse-actions {
  flex-shrink: 0;
}

.ch-browse-join-btn {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.ch-browse-join-btn.join {
  background: var(--accent);
  color: white;
}

.ch-browse-join-btn.join:hover {
  filter: brightness(1.15);
}

.ch-browse-join-btn.joined {
  background: var(--glass-bg);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
}

.ch-browse-join-btn.joined:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: #f87171;
}

.ch-pin-indicator {
  font-size: 10px;
  line-height: 1;
  flex-shrink: 0;
}

.nav-item.channel-not-joined {
  opacity: 0.55;
}

/* Avatar */
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.avatar-clickable {
  cursor: pointer;
  transition: filter 0.15s;
}

.avatar-clickable:hover {
  filter: brightness(0.8);
}

.avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 28px;
  color: white;
}

.status-dot {
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  position: absolute;
  bottom: -3px;
  right: -3px;
  z-index: 1;
}

.user-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: var(--transition);
}

.nav-item:hover .user-actions {
  opacity: 1;
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon-sm:hover {
  background: var(--accent);
  color: white;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--red);
}

/* ── Chat Area ────────────────────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
  overflow: hidden;
  position: relative;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 16px 24px;
  -webkit-overflow-scrolling: touch;
}

/* ── Scroll-to-bottom button ─────────────────────────────────────── */
.scroll-bottom-btn {
  position: absolute;
  bottom: 80px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  z-index: 15;
  transition: all 0.2s;
  animation: scrollBtnAppear 0.2s ease-out;
}

.scroll-bottom-btn:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.1);
}

@keyframes scrollBtnAppear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-header {
  padding: 11px 24px;
  padding-top: calc(11px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #221d2a;
  backdrop-filter: blur(12px);
  box-shadow: 0px 1px 150px #000000;
  flex-shrink: 0;
  z-index: 20;
}

.chat-header-info h2 {
  font-size: 16px;
  font-weight: 600;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── DM Header Avatar ─────────────────────────────────────────────────────── */
.dm-header-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
  flex-shrink: 0;
}

/* ── DM Mode Messages ─────────────────────────────────────────────────────── */
.message.dm-mode {
  position: relative;
  align-items: center;
}

.message.dm-mode.msg-own {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.message.dm-mode.msg-other {
  justify-content: flex-start;
}

.message.dm-mode .message-body {
  max-width: 75%;
}

/* 2-column grid for own message actions: [delete] [edit/forward] */
.msg-actions-grid {
  display: flex !important;
  flex-direction: row !important;
  gap: 3px;
  align-self: flex-start;
  margin-top: 4px;
}

.msg-actions-grid .msg-actions-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: flex-start;
}

/* If message is tall enough, flatten to single column */
.msg-actions-grid.msg-actions-single {
  flex-direction: column !important;
}

.msg-actions-grid.msg-actions-single .msg-actions-col {
  flex-direction: column;
}

/* ── Inline Action Buttons (beside message bubble) ────────────────────────── */
.msg-inline-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 4px;
  user-select: none;
}

/* ── Status ticks never selectable ─────────────────────── */
.msg-read-tick,
.msg-meta {
  user-select: none;
}


/* 1-line messages: all buttons in horizontal row */
.msg-inline-actions.msg-actions-row {
  flex-direction: row;
  gap: 2px;
}

.msg-inline-actions.msg-actions-row.msg-actions-grid {
  flex-direction: row !important;
}

.msg-inline-actions.msg-actions-row .msg-actions-col {
  flex-direction: row;
  gap: 2px;
}

/* Desktop only: show on hover (skip touch devices) */
@media (hover: hover) {
  .message:hover .msg-inline-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Mobile: show on tap (msg-selected) */
.message.msg-selected .msg-inline-actions {
  opacity: 1;
  pointer-events: auto;
}

.msg-inline-actions .msg-action-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(124, 93, 255, 0.08);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.msg-inline-actions .msg-action-btn:hover {
  background: rgba(124, 93, 255, 0.2);
  color: var(--accent);
}

.dm-gear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.dm-gear-btn:hover {
  opacity: 1;
}

.dm-modal-danger {
  color: var(--text-secondary);
}

.dm-modal-danger:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
}

.dm-call-btn {
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.dm-call-btn:hover {
  color: var(--accent);
  background: var(--glass-bg);
}

.chat-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.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%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  50% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ── Messages ─────────────────────────────────────────────────────────────── */
.search-panel {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  z-index: 15;
  animation: slideUp 0.15s ease;
}

.search-panel-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-scope {
  padding: 8px 8px;
  font-size: 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}

.search-results {
  max-height: 240px;
  overflow-y: auto;
  margin-top: 6px;
}

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.search-result-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.search-result-body {
  flex: 1;
  min-width: 0;
}

.search-result-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.search-result-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-time {
  font-size: 10px;
  color: var(--text-muted);
}

.search-result-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-text mark {
  background: rgba(99, 102, 241, 0.3);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}

.search-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 12px;
}

/* ── Pinned Message Banner ───────────────────────────────────────── */
.pinned-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 0 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  animation: slideUp 0.15s ease;
}

.pinned-bar:hover {
  background: rgba(255, 255, 255, 0.06);
}

.pinned-bar-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.pinned-bar-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pinned-bar-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.pinned-bar-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-bar-close {
  color: var(--text-muted);
  font-size: 12px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.pinned-bar-close:hover {
  opacity: 1;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  animation: msgAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes msgAppear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message:hover {
  background: var(--bg-secondary);
}

.message .avatar-sm {
  margin-top: 2px;
}

.msg-avatar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  user-select: none;
}

.msg-time-bottom {
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  line-height: 1;
  margin-top: 2px;
  user-select: none;
}

.message:hover .msg-time-bottom {
  opacity: 0.6;
}

/* ── Right-side quick action buttons ─────────────────────── */
.msg-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  padding-top: 2px;
  user-select: none;
}

.message:hover .msg-actions {
  opacity: 1;
}

.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.msg-action-btn:hover {
  background: var(--glass-bg);
  color: var(--text-primary);
}

.msg-act-delete:hover {
  color: #f43f5e;
}

/* ── Edited badge ────────────────────────────────────────── */
.msg-edited-badge {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Voice Messages ──────────────────────────────────────────────────────── */
.btn-voice {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-voice:hover {
  background: var(--glass-bg);
  color: var(--accent);
}

.voice-recording-ui {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 10;
  border-radius: 12px;
  animation: slideIn 0.2s ease-out;
}

.voice-pulse-indicator {
  position: relative;
  width: 12px;
  height: 12px;
}

.voice-pulse-dot {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #ef4444;
  /* red */
  border-radius: 50%;
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.voice-timer {
  font-family: monospace;
  font-size: 14px;
  font-weight: 600;
  color: #ef4444;
  margin-right: auto;
}

.voice-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-send {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  padding: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-send:hover {
  background: #4f46e5;
  color: white;
}

/* Audio Player inside chat */
.voice-msg-player {
  height: 40px;
  width: 260px;
  border-radius: 20px;
  outline: none;
  margin-top: 6px;
}

.voice-msg-player::-webkit-media-controls-enclosure {
  background-color: var(--bg-active);
  background-image: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
  border-radius: 20px;
}

/* ── Inline edit ─────────────────────────────────────────── */
.msg-edit-textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  min-height: 32px;
}

.msg-edit-buttons {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.msg-edit-buttons button {
  padding: 3px 10px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  transition: background 0.15s;
}

.msg-edit-save {
  background: var(--accent);
  color: white;
}

.msg-edit-save:hover {
  filter: brightness(1.15);
}

.msg-edit-cancel {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.msg-edit-cancel:hover {
  background: var(--glass-border);
}

/* Hide avatar on non-last messages in a sequence (JS-controlled) */
.msg-avatar-col.avatar-hidden {
  visibility: hidden;
}

/* Avatar aligned to bottom of message */
.msg-avatar-col {
  align-self: flex-end;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.message-author {
  font-weight: 600;
  font-size: 14px;
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
}

.message-content {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  word-break: break-word;
}

/* Invite link buttons — escape inline line-height gap */
.message-content .invite-link-btn {
  display: flex !important;
  width: fit-content;
  line-height: 1;
}

/* Compact messages from same user */
.message.compact {
  padding-top: 2px;
  padding-bottom: 2px;
}

.message.compact .message-header {
  display: none;
}

/* System messages */
.system-message {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Message Bubbles (Stitch-inspired) ──────────────────────────────────── */

/* Own messages — right-aligned, purple bubble, no avatar */
.message.msg-own {
  flex-direction: row-reverse;
  max-width: 85%;
  margin-left: auto;
  margin-right: 0;
  padding: 4px 0;
}

.message.msg-own .msg-avatar-col {
  display: none;
}

.message.msg-own .message-body {
  background: rgb(31 32 42);
  border: 1px solid rgba(124, 93, 255, 0.3);
  border-radius: 18px 18px 0px 18px;
  padding: 10px 14px;
}

.message.msg-own .message-header {
  justify-content: flex-end;
}

.message.msg-own .message-author {
  display: none;
}

.message.msg-own .message-content {
  color: var(--text-primary);
}

.message.msg-own .message-time {
  font-size: 10px;
}

.message.msg-own .msg-actions,
.message.msg-other .msg-actions {
  display: none;
}

.message.msg-own:hover {
  background: transparent;
}

/* Other messages — left-aligned, glass bubble, avatar visible */
.message.msg-other {
  max-width: 85%;
  margin-right: auto;
  margin-left: 0;
  padding: 4px 0;
  align-items: flex-end;
}

.message.msg-other .message-body {
  background: rgb(31 32 42);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px 18px 18px 0px;
  padding: 10px 14px;
}

.message.msg-other .message-content {
  color: var(--text-primary);
}

.message.msg-other .message-time {
  font-size: 10px;
}

.message.msg-other:hover {
  background: transparent;
}

/* ── Merged Bubble Groups ──────────────────────────────────────────────────── */

/* Tighten gaps between grouped messages */
.message.group-first {
  padding-bottom: 0;
}

.message.group-middle {
  padding-top: 0;
  padding-bottom: 0;
}

.message.group-last {
  padding-top: 0;
}

/* Cancel container gap between grouped messages — must not overlap (causes dark bands with transparent bg) */
.message.group-middle,
.message.group-last {
  margin-top: -4px;
  align-items: flex-start;
}

.message.group-first {
  align-items: flex-start;
}

/* No extra margin on body — overlap slightly to prevent sub-pixel gaps */
.message.group-first .message-body,
.message.group-middle .message-body {
  margin-bottom: -1px;
  z-index: 1;
}

.message.group-middle .message-body,
.message.group-last .message-body {
  margin-top: 0;
}

/* Grouped messages need position:relative for inverse-radius notches */
.message.group-first,
.message.group-middle,
.message.group-last {
  position: relative;
}

/* group-first / group-middle: meta shows to the SIDE on hover (below action buttons) */
.message.group-first .msg-meta,
.message.group-middle .msg-meta {
  bottom: 2px;
}

/* Own group-first/middle: meta to the LEFT of the bubble */
.message.msg-own.group-first .msg-meta,
.message.msg-own.group-middle .msg-meta {
  right: calc(100% + 12px);
  left: auto;
}

/* Other group-first/middle: meta to the RIGHT of the bubble */
.message.msg-other.group-first .msg-meta,
.message.msg-other.group-middle .msg-meta {
  left: calc(100% + 12px);
  right: auto;
}

/* ── Own messages (right side): connecting corner = right ────────────────── */
.message.msg-own.group-first .message-body {
  border-radius: 18px 18px 0px 18px;
  border-bottom-width: 0;
  border-right-width: 0;
}

.message.msg-own.group-middle .message-body {
  border-radius: 18px 0px 0px 18px;
  border-top-width: 0;
  border-bottom-width: 0;
  border-right-width: 0;
}

.message.msg-own.group-last .message-body {
  border-radius: 18px 0px 0px 18px;
  border-top-width: 0;
  border-right-width: 0;
}

/* ── Other messages (left side): connecting corner = left ────────────────── */
.message.msg-other.group-first .message-body {
  border-radius: 18px 18px 18px 0px;
  border-bottom-width: 0;
  border-left-width: 0;
}

.message.msg-other.group-middle .message-body {
  border-radius: 0px 18px 18px 0px;
  border-top-width: 0;
  border-bottom-width: 0;
  border-left-width: 0;
}

.message.msg-other.group-last .message-body {
  border-radius: 0px 18px 18px 0px;
  border-top-width: 0;
  border-left-width: 0;
}

/* ── Inverse border-radius (concave notch at width step) ────────────────── */
/* JS measures adjacent bubble widths and places .inverse-notch divs at the step */

.message .message-body {
  position: relative;
  overflow: visible;
}

.inverse-notch {
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 2;
  pointer-events: none;
}

/* Own bubble bg */
.message.msg-own .inverse-notch.notch-bottom-right,
.message.msg-own .inverse-notch.notch-bottom-left,
.message.msg-own .inverse-notch.notch-top-right,
.message.msg-own .inverse-notch.notch-top-left {
  --notch-bg: rgb(31 32 42);
}

/* Other bubble bg */
.message.msg-other .inverse-notch.notch-bottom-right,
.message.msg-other .inverse-notch.notch-bottom-left,
.message.msg-other .inverse-notch.notch-top-right,
.message.msg-other .inverse-notch.notch-top-left {
  --notch-bg: rgb(31 32 42);
}

/* Bottom notch: short bubble → wider bubble below */
.inverse-notch.notch-bottom-right {
  bottom: -19px;
  background: radial-gradient(circle at 100% 100%, transparent 18px, var(--notch-bg) 18px);
}

.inverse-notch.notch-bottom-left {
  bottom: -19px;
  background: radial-gradient(circle at 0 100%, transparent 18px, var(--notch-bg) 18px);
}

/* Top notch: wide bubble → narrower bubble below */
.inverse-notch.notch-top-right {
  top: -19px;
  background: radial-gradient(circle at 100% 0, transparent 18px, var(--notch-bg) 18px);
}

.inverse-notch.notch-top-left {
  top: -19px;
  background: radial-gradient(circle at 0 0, transparent 18px, var(--notch-bg) 18px);
}

/* Bubble hover — subtle glow */
.message.msg-own:hover .message-body {
  background: rgb(57, 49, 102);
  border-color: rgba(124, 93, 255, 0.4);
}

.message.msg-other:hover .message-body {
  background: rgb(58, 59, 68);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Notch hover — highlight notch on adjacent wider message at hovered message's visual level.
   notch-top-* on next sibling = visually at hovered message's bottom edge.
   notch-bottom-* on previous sibling = visually at hovered message's top edge. */
.message.msg-own:hover+.message .inverse-notch[class*="notch-top"],
.message.msg-own:has(+ .message.msg-own:hover) .inverse-notch[class*="notch-bottom"] {
  --notch-bg: rgb(57, 49, 102);
}

.message.msg-other:hover+.message .inverse-notch[class*="notch-top"],
.message.msg-other:has(+ .message.msg-other:hover) .inverse-notch[class*="notch-bottom"] {
  --notch-bg: rgb(58, 59, 68);
}

/* Time always visible in bubble mode */
.message.msg-own .msg-time-bottom,
.message.msg-other .msg-time-bottom {
  display: none;
}

/* Reply quotes inside bubbles */
.message.msg-own .msg-reply-quote,
.message.msg-other .msg-reply-quote {
  margin-bottom: 6px;
}

/* Reactions inside bubbles */
.message.msg-own .msg-reactions,
.message.msg-other .msg-reactions {
  justify-content: flex-end;
}

/* P2P badge in bubble mode */
.message.msg-own.message-p2p,
.message.msg-other.message-p2p {
  border-left: none;
}

.message.msg-own.message-p2p .message-body {
  border-left: 2px solid var(--accent);
}

.message.msg-other.message-p2p .message-body {
  border-left: 2px solid var(--accent);
}

/* File cards inside bubbles */
.message.msg-own .file-card,
.message.msg-other .file-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.message.msg-own .file-image-preview img,
.message.msg-other .file-image-preview img {
  border-radius: 12px;
}

/* P2P delivered messages */
.message-p2p {
  border-left: 2px solid var(--accent);
}

.message-p2p .message-time::after {
  content: ' ⚡';
  font-size: 10px;
}

/* E2E encrypted message badge */
.e2e-badge {
  font-size: 11px;
  color: var(--green);
  cursor: help;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.e2e-badge:hover {
  opacity: 1;
}

/* Telegram bridge message badge */
.tg-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  background: #0088cc;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: help;
  user-select: none;
  vertical-align: middle;
}

/* Offline queue: pending messages */
.msg-pending {
  opacity: 0.5;
}

.msg-pending .message-time::after {
  content: ' ⏳';
  font-size: 10px;
}

/* Read receipt ticks (DM only) */
.msg-read-tick {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 3px;
  letter-spacing: -2px;
  transition: color 0.2s;
}

.msg-read-tick.read {
  color: #60a5fa;
  /* blue when read */
}

/* ── Message meta (time + checkmarks) — absolute positioning ──────────── */
.msg-meta {
  position: absolute;
  bottom: -16px;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  z-index: 3;
}

/* Own messages: meta at bottom-right */
.message.msg-own .msg-meta {
  right: 2px;
}

/* Other messages: meta at bottom-left */
.message.msg-other .msg-meta {
  left: 2px;
}

/* Show on hover for standalone (non-grouped) messages */
.message:hover .msg-meta {
  opacity: 1;
}

/* Add spacing below group-last bubble for hover meta */
.message.group-last {
  margin-bottom: 14px;
}

/* Unread message badge */
.unread-badge {
  background: var(--red, #ef4444);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  padding: 0 5px;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.nav-item {
  position: relative;
}

/* ── Attach Button ─────────────────────────────────────────────────────── */
.btn-attach {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.btn-attach:hover {
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

/* ── Attach Preview Bar ────────────────────────────────────────────────── */
.attach-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid var(--border);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.attach-preview-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.attach-preview-info svg {
  color: var(--accent);
  flex-shrink: 0;
}

.attach-preview-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-file-size {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.attach-image-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.btn-icon-sm {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.btn-icon-sm:hover {
  color: var(--danger);
}

/* ── File Message Cards ────────────────────────────────────────────────── */
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  margin-top: 6px;
  max-width: 360px;
  transition: background 0.2s;
}

.file-card:hover {
  background: rgba(99, 102, 241, 0.1);
}

.file-icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}

.file-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-info .file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.file-name:hover {
  text-decoration: underline;
}

.file-info .file-size {
  font-size: 11px;
  color: var(--text-muted);
}

.file-card.file-history {
  opacity: 0.7;
  border-style: dashed;
}

.file-card.file-loading {
  opacity: 0.6;
}

/* ── File Image Preview ────────────────────────────────────────────────── */
.file-image-preview {
  margin-top: 6px;
  max-width: 400px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.file-image-preview img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.2s;
}

.file-image-preview img:hover {
  transform: scale(1.02);
}

.file-image-preview.file-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  background: rgba(99, 102, 241, 0.06);
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Progress Bar ──────────────────────────────────────────────────────── */
.file-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.file-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.file-progress-bar.file-progress-indeterminate {
  width: 40%;
  animation: indeterminate-progress 1.2s ease-in-out infinite;
}

@keyframes indeterminate-progress {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(350%);
  }
}

/* ── "Request File" button ──────────────────────────────────────────────── */
.btn-request-file {
  margin-top: 4px;
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-request-file:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.25);
}

.btn-request-file:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-request-file.requesting {
  opacity: 0.7;
  cursor: wait;
}

/* ── Settings Modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  width: 520px;
  max-width: 94vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.2s ease;
}

.settings-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 560px;
  max-width: 94vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.2s ease;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Tab Bar ─────────────────────────────────────────────── */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
  display: none;
}

.settings-tab {
  flex: 1;
  min-width: 0;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  text-align: center;
}

.settings-tab:hover {
  color: var(--text-primary);
}

.settings-tab.active {
  color: var(--accent, #6366f1);
  border-bottom-color: var(--accent, #6366f1);
}

/* ── Tab Content ─────────────────────────────────────────── */
.settings-tab-content {
  display: none;
  flex-direction: column;
  gap: 4px;
}

.settings-tab-content.active {
  display: flex;
}

.settings-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* ── Setting Section ─────────────────────────────────────── */
.setting-section {
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-section:last-child {
  border-bottom: none;
}

.setting-section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.setting-annotation {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--accent, #6366f1);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
}

.setting-annotation p {
  margin: 0 0 6px;
}

.setting-annotation p:last-child {
  margin: 0;
}

.setting-annotation b {
  color: var(--text-secondary);
}

.setting-annotation code {
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ── Setting Row & Inputs ────────────────────────────────── */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.setting-row>label:first-child {
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
}

.setting-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.setting-input:focus {
  border-color: var(--accent, #6366f1);
}

.setting-select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.setting-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: monospace;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}

.setting-textarea:focus {
  border-color: var(--accent, #6366f1);
}

.setting-label-sm {
  font-size: 13px;
  color: var(--text-secondary);
}

.setting-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.setting-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.setting-muted {
  font-size: 13px;
  color: var(--text-muted);
}

.setting-mono {
  font-family: monospace;
  font-size: 12px;
}

.setting-accent {
  color: var(--accent, #6366f1);
}

.setting-id-text {
  word-break: break-all;
  color: var(--text-secondary);
  font-size: 11px;
}

.setting-status {
  font-size: 12px;
  padding: 0;
  display: none;
}

.setting-error {
  font-size: 12px;
  color: var(--error, #f43f5e);
}

.setting-result {
  margin-top: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-diagnostics {
  font-size: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 4px;
  min-height: 280px;
  max-height: 400px;
  overflow-y: auto;
  font-family: monospace;
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text-primary);
}

.setting-range-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.setting-range-wrap input[type="range"] {
  width: 100px;
  accent-color: var(--accent, #6366f1);
}

.setting-range-val {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

.setting-row.cache-info {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Avatar Upload ───────────────────────────────────────── */
.settings-avatar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.settings-avatar-upload {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
}

.settings-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  color: white;
  background: var(--accent, #6366f1);
  background-size: cover;
  background-position: center;
}

.settings-avatar-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  font-size: 24px;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 50%;
}

.settings-avatar-upload:hover .settings-avatar-overlay {
  opacity: 1;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  background: var(--bg-tertiary, rgba(255, 255, 255, 0.08));
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.btn-sm:hover {
  background: var(--accent, #6366f1);
  color: white;
  border-color: var(--accent, #6366f1);
}

.btn-sm.btn-danger {
  color: var(--error, #f43f5e);
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-sm.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error, #f43f5e);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-sm.btn-muted {
  color: var(--text-muted);
}

.btn-sm.btn-muted:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: var(--glass-border);
}

/* ── Toggle Switch ─────────────────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s;
}

.toggle input:checked+.toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(18px);
  background: white;
}


.welcome-message {
  text-align: center;
  padding: 60px 20px 30px;
}

.welcome-message h3 {
  font-size: 22px;
  margin-bottom: 8px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-message p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Chat Input ───────────────────────────────────────────────────────────── */
.chat-input-area {
  padding: 12px 24px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* ── Reply Bar (above input) ────────────────────────────────────── */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--glass-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  animation: slideUp 0.15s ease;
}

.reply-bar-accent {
  width: 3px;
  height: 28px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

.reply-bar-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.reply-bar-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.reply-bar-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-cancel {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
}

/* ── Reply Quote (inside message bubble) ────────────────────────── */
.msg-reply-quote {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  max-width: 360px;
}

.msg-reply-quote:hover {
  background: rgba(255, 255, 255, 0.06);
}

.msg-reply-quote-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

.msg-reply-quote-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.msg-reply-quote-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.msg-reply-quote-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Highlight animation when scrolling to a quoted message */
@keyframes replyHighlight {
  0% {
    background: rgba(99, 102, 241, 0.2);
  }

  100% {
    background: transparent;
  }
}

.message-highlight {
  animation: replyHighlight 1.5s ease;
}

/* ── Message Context Menu ───────────────────────────────────────── */
.msg-context-menu {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.12s ease;
}

.msg-ctx-reactions {
  display: flex;
  gap: 2px;
  padding: 2px;
}

.msg-ctx-emoji {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: transform 0.1s, background 0.12s;
  line-height: 1;
}

.msg-ctx-emoji:hover {
  background: var(--glass-bg);
  transform: scale(1.25);
}

.msg-ctx-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 2px 0;
}

.msg-ctx-item {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-primary);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-ctx-item:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Reaction Badges ───────────────────────────────────────── */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.msg-reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  font-size: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  line-height: 1.4;
}

.msg-reaction-badge:hover {
  background: rgba(255, 255, 255, 0.08);
}

.msg-reaction-badge.my-reaction {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
}

.msg-reaction-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 4px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea {
  flex: 1;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  overflow-y: hidden;
  min-height: 38px;
  max-height: 150px;
  line-height: 1.4;
}

.input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-gradient);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-send:active {
  transform: scale(0.95);
}

/* ══════════════════════════════════════════════════════════════════════════════
   VIDEO CALL
   ══════════════════════════════════════════════════════════════════════════════ */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  animation: fadeIn 0.3s ease;
}

.call-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.call-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 24px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
  z-index: 3;
}

#call-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.call-videos {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}

.local-video {
  position: absolute;
  bottom: 120px;
  right: 20px;
  width: 140px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  z-index: 4;
}

/* Voice call avatar display */
.call-voice-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: absolute;
  inset: 0;
}

.call-voice-avatar p {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.avatar-xl {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 48px;
  color: white;
  animation: voicePulse 3s ease-in-out infinite;
}

@keyframes voicePulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 var(--accent-glow);
  }

  50% {
    box-shadow: 0 0 0 20px transparent;
  }
}

/* Voice call button */
.btn-voice-call:hover {
  background: var(--green) !important;
  color: white;
}

.call-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 480px;
  margin: 0 auto;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  z-index: 5;
}

.call-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.call-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.08);
}

.call-btn.muted {
  background: var(--red);
  color: white;
}

.call-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 0 12px var(--accent-glow);
}

.call-btn.active:hover {
  background: var(--accent);
  filter: brightness(1.15);
}

.call-btn.sharing {
  background: var(--green);
  color: white;
  animation: sharingPulse 2s ease-in-out infinite;
}

@keyframes sharingPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }

  50% {
    box-shadow: 0 0 0 8px transparent;
  }
}

.call-btn-end {
  background: var(--red) !important;
  color: white !important;
  width: 56px;
  height: 56px;
}

.call-btn-end:hover {
  background: #dc2626 !important;
}

.call-btn-accept {
  background: var(--green) !important;
  color: white !important;
  width: 64px;
  height: 64px;
}

.call-btn-accept:hover {
  background: #16a34a !important;
}

/* Quality popup */
.quality-popup {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 120;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  animation: slideUp 0.15s ease;
  min-width: 140px;
}

.quality-opt {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-primary);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  white-space: nowrap;
}

.quality-opt:hover {
  background: var(--accent);
  color: white;
}

.quality-opt.selected {
  color: var(--accent);
  font-weight: 600;
}

/* ── Incoming Call Modal ──────────────────────────────────────────────────── */
.incoming-call-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}

.incoming-call-card {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 40px;
  text-align: center;
  position: relative;
  animation: cardAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.incoming-call-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--accent-glow);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.5;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}

.incoming-call-card h3 {
  font-size: 20px;
  margin: 16px 0 4px;
}

.incoming-call-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.incoming-call-actions {
  display: flex;
  gap: 24px;
  justify-content: center;
}

/* ── Back Button ─────────────────────────────────────────────────────────── */
.back-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.back-btn:hover {
  background: var(--bg-hover);
}

.back-btn:active {
  transform: scale(0.92);
}

/* ── Chat Action Bar (DM bottom bar) ─────────────────────────────────────── */
.chat-action-bar {
  display: none;
  align-items: center;
  justify-content: space-around;
  padding: 8px 12px;
  background: rgba(22, 22, 37, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  gap: 4px;
}

.chat-action-bar .action-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  font-size: 10px;
  font-weight: 500;
  font-family: inherit;
}

.chat-action-bar .action-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.chat-action-bar .action-tab:active {
  transform: scale(0.95);
}

.chat-action-bar .action-tab.active {
  color: var(--accent);
}

/* ── Sidebar Gradient Background ─────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════════════════
   HAMBURGER MENU (hidden on desktop)
   ══════════════════════════════════════════════════════════════════════════════ */
.hamburger-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.hamburger-btn:hover {
  background: var(--bg-hover);
}

.hamburger-btn:active {
  transform: scale(0.92);
}

/* ── Sidebar Backdrop (mobile overlay) ────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 49;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Show hamburger button */
  .hamburger-btn {
    display: flex;
  }

  /* Sidebar becomes a slide-out drawer */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    width: 280px;
    min-width: 280px;
    padding-left: env(safe-area-inset-left, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sidebar-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  /* Show backdrop on mobile */
  .sidebar-backdrop {
    display: block;
  }

  .auth-card {
    padding: 32px 24px;
  }

  .local-video {
    width: 100px;
    height: 140px;
    bottom: 110px;
    right: 12px;
  }

  .call-btn {
    width: 42px;
    height: 42px;
  }

  .call-btn-end,
  .call-btn-accept {
    width: 50px;
    height: 50px;
  }

  /* Chat area adjustments */
  .messages-container {
    padding: 12px 12px;
  }

  .chat-input-area {
    padding: 8px 12px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .chat-header {
    padding: 10px 12px;
    gap: 8px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    position: sticky;
    top: 0;
    min-height: 44px;
    box-sizing: border-box;
  }

  .chat-area {
    min-height: 0;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
  }

  .chat-header-info h2 {
    font-size: 15px;
  }

  /* ── DM Action Bar (Call / Video / Mute) ──────────────────────────── */
  .chat-action-bar {
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 8px 20px;
    margin: 6px 0 0;
    background: rgba(23, 23, 37, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    flex-shrink: 0;
    transition: opacity 0.2s, max-height 0.2s, margin 0.2s, padding 0.2s;
    max-height: 64px;
    overflow: hidden;
  }

  .chat-action-bar.visible {
    display: flex;
  }

  /* Hide action bar when virtual keyboard is open */
  .keyboard-visible .chat-action-bar {
    opacity: 0;
    max-height: 0;
    padding: 0;
    margin: 0;
    border: none;
    pointer-events: none;
  }

  .action-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 18px;
    background: none;
    border: none;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s;
  }

  .action-tab:hover,
  .action-tab:active {
    color: var(--accent);
    background: rgba(124, 93, 255, 0.1);
  }

  .action-tab svg {
    width: 20px;
    height: 20px;
  }

  /* Message styling */
  .message {
    padding: 6px 8px;
    gap: 8px;
  }

  .avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .message-content {
    font-size: 13px;
  }

  /* Auth adjustments for mobile */
  .auth-card {
    padding: 28px 20px;
    border-radius: var(--radius-lg);
  }

  .auth-logo h1 {
    font-size: 24px;
  }

  /* Online users — always show action buttons on mobile (no hover) */
  .user-actions {
    opacity: 1;
  }

  /* Video call mobile adjustments */
  .local-video {
    width: 90px;
    height: 130px;
    bottom: 100px;
    right: 10px;
  }

  .call-controls {
    padding: 16px 12px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  /* Show back button on mobile */
  .back-btn {
    display: flex;
  }

  /* Hide hamburger when back button is enough */
  .hamburger-btn {
    display: none;
  }

  /* Show action bar on mobile DMs (controlled by JS) */
  .chat-action-bar.visible {
    display: flex;
  }

  /* Hide DM call buttons from header on mobile (moved to action bar) */
  #dm-header-actions {
    display: none !important;
  }

  /* Mobile message bubbles — smaller padding */
  .message.msg-own .message-body,
  .message.msg-other .message-body {
    padding: 8px 12px;
  }

  /* Message action buttons: hidden inside bubbles, use context menu instead */
  .message.msg-own .msg-actions,
  .message.msg-other .msg-actions {
    display: none;
  }

  .msg-time-bottom {
    opacity: 0.6;
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   TRUST GATE
   ══════════════════════════════════════════════════════════════════════════════ */

.trust-gate-card {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 32px 40px;
  text-align: center;
  animation: cardAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 340px;
  width: 90vw;
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(16px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.trust-gate-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: white;
  margin: 0 auto;
}

.trust-gate-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 28px;
  cursor: pointer;
  user-select: none;
}

.trust-gate-stars span {
  color: var(--text-muted);
  transition: color 0.15s, transform 0.15s;
}

.trust-gate-stars span:hover {
  transform: scale(1.2);
}

.trust-gate-stars span.active {
  color: #f59e0b;
}

.trust-gate-btn {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.trust-gate-accept {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.trust-gate-accept:hover {
  background: rgba(34, 197, 94, 0.25);
}

.trust-gate-block {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.trust-gate-block:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Pending badge on DM sidebar items */
.dm-pending-badge {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.7;
}

/* Trust gate banner inside chat area */
.trust-gate-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  margin: 8px 16px;
  animation: slideUp 0.2s ease;
}

.trust-gate-banner p {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.trust-gate-banner button {
  padding: 4px 12px;
  font-size: 11px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.trust-gate-banner .btn-accept {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.trust-gate-banner .btn-accept:hover {
  background: rgba(34, 197, 94, 0.25);
}

.trust-gate-banner .btn-block {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.trust-gate-banner .btn-block:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ── Trust Badges ───────────────────────────────────────────────────── */
.trust-badge {
  font-size: 11px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: -1px;
}

.trust-ok {
  color: #4ade80;
  font-weight: 700;
  letter-spacing: 0;
}

.trust-rated {
  color: #fbbf24;
  letter-spacing: -1px;
}

.trust-pending {
  color: #94a3b8;
}

.trust-blocked {
  color: #f43f5e;
}

/* Trust score in DM header / contact modal */
.trust-score-display {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.trust-score-stars {
  color: #fbbf24;
  letter-spacing: -1px;
  font-size: 13px;
}

.trust-score-count {
  font-size: 10px;
  color: var(--text-muted);
}

/* Interactive star rating widget */
.trust-rate-widget {
  display: flex;
  gap: 2px;
  padding: 4px 0;
}

.trust-rate-star {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 2px;
  color: #475569;
  transition: color 0.1s, transform 0.1s;
}

.trust-rate-star:hover,
.trust-rate-star.active {
  color: #fbbf24;
  transform: scale(1.15);
}

/* ── Offline Banner ─────────────────────────────────────────────── */
.offline-banner {
  background: linear-gradient(90deg, #f59e0b, #d97706);
  color: #1a1a2e;
  text-align: center;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  animation: slideDown 0.3s ease;
  z-index: 10;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}