:root {
  --bg: #f1f5f9;
  --bg-accent: #e0e7ff;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-elevated: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --rose: #dc2626;
  --rose-soft: #fef2f2;
  --bubble-me: #4f46e5;
  --bubble-me-text: #ffffff;
  --bubble-other: #ffffff;
  --bubble-other-text: #0f172a;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 12px 28px -6px rgba(15, 23, 42, 0.1), 0 4px 10px -4px rgba(15, 23, 42, 0.05);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  /* Sidebar Theme Defaults (Midnight Indigo) */
  --sb-contacts-bg: linear-gradient(165deg, #eef2ff 0%, #f5f3ff 48%, #f8fafc 100%);
  --sb-channels-bg: linear-gradient(175deg, #f8fafc 0%, #eef2ff 100%);
  --sb-glow: radial-gradient(circle at 18% 12%, rgba(79, 70, 229, 0.14), transparent 55%);
  --sb-card-bg: rgba(255, 255, 255, 0.72);
  --sb-card-hover: rgba(255, 255, 255, 0.94);
  --sb-card-active: rgba(79, 70, 229, 0.14);
  --sb-border: rgba(99, 102, 241, 0.18);
  --sb-text: #0f172a;
  --sb-text-muted: #475569;
}

[data-theme="dark"] {
  --bg: #090e1a;
  --bg-accent: #1e1b4b;
  --surface: #111827;
  --surface-muted: #1e293b;
  --surface-elevated: #172033;
  --border: #283548;
  --border-strong: #3b4b63;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-light: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.18);
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --rose: #f87171;
  --rose-soft: rgba(248, 113, 113, 0.16);
  --bubble-me: #4f46e5;
  --bubble-me-text: #ffffff;
  --bubble-other: #1e293b;
  --bubble-other-text: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 18px 34px -8px rgba(0, 0, 0, 0.55);

  --sb-contacts-bg: linear-gradient(165deg, #0f172a 0%, #1e1b4b 55%, #111827 100%);
  --sb-channels-bg: linear-gradient(175deg, #111827 0%, #171b36 100%);
  --sb-glow: radial-gradient(circle at 18% 12%, rgba(99, 102, 241, 0.24), transparent 55%);
  --sb-card-bg: rgba(15, 23, 42, 0.56);
  --sb-card-hover: rgba(30, 41, 59, 0.78);
  --sb-card-active: rgba(99, 102, 241, 0.24);
  --sb-border: rgba(129, 140, 248, 0.22);
  --sb-text: #f8fafc;
  --sb-text-muted: #cbd5e1;
}

/* 5 Sidebar Background Themes (Light + Dark Variants) */
[data-sidebar-theme="ocean"] {
  --sb-contacts-bg: linear-gradient(165deg, #ecfeff 0%, #e0f2fe 52%, #f8fafc 100%);
  --sb-channels-bg: linear-gradient(175deg, #f0f9ff 0%, #ecfeff 100%);
  --sb-glow: radial-gradient(circle at 20% 10%, rgba(14, 165, 233, 0.16), transparent 55%);
  --sb-border: rgba(14, 165, 233, 0.22);
  --sb-card-active: rgba(14, 165, 233, 0.15);
}
[data-theme="dark"] [data-sidebar-theme="ocean"] {
  --sb-contacts-bg: linear-gradient(165deg, #082f49 0%, #0f172a 60%, #091e2c 100%);
  --sb-channels-bg: linear-gradient(175deg, #0c1f2e 0%, #0f172a 100%);
  --sb-glow: radial-gradient(circle at 20% 10%, rgba(56, 189, 248, 0.22), transparent 55%);
  --sb-border: rgba(56, 189, 248, 0.22);
  --sb-card-active: rgba(14, 165, 233, 0.25);
}

[data-sidebar-theme="aurora"] {
  --sb-contacts-bg: linear-gradient(160deg, #fdf4ff 0%, #eff6ff 50%, #f5f3ff 100%);
  --sb-channels-bg: linear-gradient(175deg, #f5f3ff 0%, #fdf4ff 100%);
  --sb-glow: radial-gradient(circle at 80% 15%, rgba(168, 85, 247, 0.16), transparent 55%);
  --sb-border: rgba(168, 85, 247, 0.2);
  --sb-card-active: rgba(168, 85, 247, 0.15);
}
[data-theme="dark"] [data-sidebar-theme="aurora"] {
  --sb-contacts-bg: linear-gradient(160deg, #2e1065 0%, #172554 55%, #0f172a 100%);
  --sb-channels-bg: linear-gradient(175deg, #1e1b4b 0%, #0f172a 100%);
  --sb-glow: radial-gradient(circle at 80% 15%, rgba(192, 132, 252, 0.24), transparent 55%);
  --sb-border: rgba(192, 132, 252, 0.24);
  --sb-card-active: rgba(168, 85, 247, 0.26);
}

[data-sidebar-theme="emerald"] {
  --sb-contacts-bg: linear-gradient(165deg, #ecfdf5 0%, #f0fdfa 52%, #f8fafc 100%);
  --sb-channels-bg: linear-gradient(175deg, #f0fdf4 0%, #ecfdf5 100%);
  --sb-glow: radial-gradient(circle at 18% 12%, rgba(16, 185, 129, 0.16), transparent 55%);
  --sb-border: rgba(16, 185, 129, 0.22);
  --sb-card-active: rgba(16, 185, 129, 0.15);
}
[data-theme="dark"] [data-sidebar-theme="emerald"] {
  --sb-contacts-bg: linear-gradient(165deg, #022c22 0%, #0f172a 60%, #06281e 100%);
  --sb-channels-bg: linear-gradient(175deg, #07221b 0%, #0f172a 100%);
  --sb-glow: radial-gradient(circle at 18% 12%, rgba(52, 211, 153, 0.22), transparent 55%);
  --sb-border: rgba(52, 211, 153, 0.22);
  --sb-card-active: rgba(16, 185, 129, 0.24);
}

[data-sidebar-theme="minimal"] {
  --sb-contacts-bg: var(--surface);
  --sb-channels-bg: var(--surface);
  --sb-glow: none;
  --sb-card-bg: var(--surface-muted);
  --sb-card-hover: var(--surface-muted);
  --sb-card-active: var(--primary-soft);
  --sb-border: var(--border);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top right, var(--bg-accent) 0%, var(--bg) 48%);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.required {
  color: var(--rose);
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.hint-text {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-indigo {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-emerald {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.icon-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.icon-pill-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-pill-btn.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(79, 70, 229, 0.35);
}

.pill-mini-badge {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--surface-muted);
  color: var(--text-light);
}

.pill-mini-badge.is-on {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-btn-sm {
  width: 30px;
  height: 30px;
  font-size: 0.88rem;
}

.icon-btn:hover {
  background: var(--surface-muted);
  border-color: var(--border-strong);
  color: var(--text);
}

.icon-btn.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.inline-edit-btn {
  border: none;
  background: transparent;
  padding: 2px 5px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  opacity: 0.75;
}

.inline-edit-btn:hover {
  background: var(--surface-muted);
  opacity: 1;
}

.mini-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-light);
  border-radius: var(--radius-sm);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.icon-close-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.73rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-danger {
  background: var(--rose);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-danger-soft {
  background: var(--rose-soft);
  color: var(--rose);
  border-color: rgba(220, 38, 38, 0.25);
}

.btn-danger-soft:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.18);
}

.btn-google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-google:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

/* Forms & Alerts */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label,
.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea,
.search-input,
.lookup-row input,
.bookmarks-filter-bar select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus,
.lookup-row input:focus,
.bookmarks-filter-bar select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.alert-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.alert-box.is-error {
  background: var(--rose-soft);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: var(--rose);
}

.alert-box.is-success {
  background: var(--emerald-soft);
  border: 1px solid rgba(5, 150, 105, 0.35);
  color: var(--emerald);
}

/* Auth Loading, Auth Card & Verification Gate */
.auth-loading {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.auth-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 450px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 26px;
}

.auth-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-logo-img {
  border-radius: 12px;
  flex-shrink: 0;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-tabs,
.modal-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 16px;
}

.auth-tab-btn,
.modal-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.auth-tab-btn.is-active,
.modal-tab-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-footer {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.auth-link-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-link-btn:hover {
  text-decoration: underline;
}

.verify-hero {
  text-align: center;
  margin-bottom: 18px;
}

.verify-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.verify-hero h1 {
  margin: 0;
  font-size: 1.35rem;
}

.verify-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mfa-code-input {
  text-align: center;
  font-size: 1.3rem !important;
  letter-spacing: 0.35em;
  font-weight: 700;
}

/* Main App Shell */
.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-logo {
  border-radius: 9px;
  flex-shrink: 0;
}

.header-brand-text strong {
  display: block;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.header-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.status-pill.is-online .status-dot {
  background: var(--emerald);
}

.status-pill.is-offline .status-dot {
  background: var(--rose);
}

.id-copy-pill {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.id-copy-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.header-user-info {
  display: flex;
  flex-direction: column;
  max-width: 165px;
}

.header-name-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.header-user-info strong {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-user-info span {
  font-size: 0.72rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Avatars */
.avatar-sm,
.avatar-md,
.avatar-lg,
.avatar-xl {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

.avatar-md {
  width: 40px;
  height: 40px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
}

.avatar-xl {
  width: 76px;
  height: 76px;
}

.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  color: #ffffff;
  font-weight: 700;
}

/* 3-Pane + Right Drawer Layout */
.workspace-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 260px minmax(0, 1fr) auto;
  background: var(--bg);
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

/* Executive Gradient Sidebars with Frosted Glass Cards */
.contacts-pane {
  background: var(--sb-glow), var(--sb-contacts-bg);
  border-right: 1px solid var(--sb-border);
  color: var(--sb-text);
}

.channels-pane {
  background: var(--sb-glow), var(--sb-channels-bg);
  border-right: 1px solid var(--sb-border);
  color: var(--sb-text);
}

.contacts-pane .pane-header,
.channels-pane .pane-header {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  border-bottom-color: var(--sb-border);
}

[data-theme="dark"] .contacts-pane .pane-header,
[data-theme="dark"] .channels-pane .pane-header {
  background: rgba(15, 23, 42, 0.35);
}

.contacts-pane .sidebar-tabs {
  border-bottom-color: var(--sb-border);
}

.contacts-pane .search-input {
  background: var(--sb-card-bg);
  border-color: var(--sb-border);
  backdrop-filter: blur(8px);
}

.chat-pane {
  position: relative;
  background: var(--surface-muted);
  border-right: none;
}

.profile-drawer {
  width: 320px;
  border-right: none;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.pane-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.pane-header h2 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
}

.pane-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pane-search-wrap {
  padding: 10px 12px 8px;
}

.sidebar-tabs {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border);
}

.drawer-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 10px;
}

.sidebar-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--sb-text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 3px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.sidebar-tab.is-active {
  background: var(--sb-card-hover);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-badge {
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--rose);
  color: #ffffff;
  font-size: 0.64rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bookmarks-filter-bar {
  padding: 8px 10px 2px;
}

.bookmarks-filter-bar select {
  padding: 6px 10px;
  font-size: 0.8rem;
  background: var(--sb-card-bg);
  border-color: var(--sb-border);
}

.pane-scroll-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.pane-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
}

.empty-emoji {
  font-size: 1.9rem;
  margin-bottom: 6px;
}

/* Sidebar Theme Swatch Popover */
.sidebar-theme-popover {
  min-width: 185px;
  padding: 6px;
}

.popover-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  padding: 4px 8px 6px;
}

.theme-swatch-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.theme-swatch-item:hover,
.theme-swatch-item.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.theme-swatch-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.swatch-midnight { background: linear-gradient(135deg, #4f46e5, #1e1b4b); }
.swatch-ocean { background: linear-gradient(135deg, #0ea5e9, #082f49); }
.swatch-aurora { background: linear-gradient(135deg, #a855f7, #3b82f6); }
.swatch-emerald { background: linear-gradient(135deg, #10b981, #064e3b); }
.swatch-minimal { background: linear-gradient(135deg, #e2e8f0, #94a3b8); }

/* Contact Items */
.contact-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--sb-card-bg);
  backdrop-filter: blur(8px);
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  margin-bottom: 5px;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
}

.contact-item:hover {
  background: var(--sb-card-hover);
  border-color: var(--sb-border);
}

.contact-item.is-active {
  background: var(--sb-card-active);
  border-color: var(--primary);
}

.contact-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.presence-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
  border: 2px solid var(--surface);
}

.presence-dot.is-online {
  background: var(--emerald);
}

.contact-item-body {
  flex: 1;
  min-width: 0;
}

.contact-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.contact-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-item-time {
  font-size: 0.7rem;
  color: var(--text-light);
  flex-shrink: 0;
}

.contact-item-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.77rem;
  color: var(--sb-text-muted);
}

.contact-item-company {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Request, Bookmarks & Blocked Cards */
.sidebar-card {
  padding: 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--sb-border);
  background: var(--sb-card-bg);
  backdrop-filter: blur(8px);
  margin-bottom: 8px;
}

.sidebar-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-card-meta {
  flex: 1;
  min-width: 0;
}

.sidebar-card-meta strong {
  display: block;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-card-meta span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-light);
}

.sidebar-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.bookmark-card {
  padding: 10px;
  border: 1px solid var(--sb-border);
  border-radius: var(--radius-md);
  background: var(--sb-card-bg);
  backdrop-filter: blur(8px);
  margin-bottom: 8px;
}

.bookmark-card-jump {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}

.starred-item-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.73rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 4px;
}

.starred-item-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bookmark-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.bookmark-note-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
  background: var(--surface-muted);
  padding: 4px 7px;
  border-radius: 6px;
}

/* Channels Rail */
.channels-pane-header {
  flex-wrap: wrap;
}

.channels-contact-head {
  flex: 1;
  min-width: 0;
}

.channels-contact-title-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.channels-contact-title-row h2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channels-contact-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--sb-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channels-toolbar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--sb-border);
  background: var(--sb-card-bg);
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

.channel-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--sb-card-bg);
  backdrop-filter: blur(8px);
  cursor: pointer;
  margin-bottom: 5px;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.channel-row:hover {
  background: var(--sb-card-hover);
  border-color: var(--sb-border);
}

.channel-row.is-active {
  background: var(--sb-card-active);
  border-color: var(--primary);
}

.channel-row.is-archived {
  opacity: 0.65;
}

.channel-color-dot {
  width: 8px;
  height: 26px;
  border-radius: 4px;
  flex-shrink: 0;
}

.channel-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.channel-row-body {
  flex: 1;
  min-width: 0;
}

.channel-row-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 600;
}

.channel-row-title span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-row-preview {
  font-size: 0.75rem;
  color: var(--sb-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-unread-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.channel-row-actions {
  display: none;
  align-items: center;
  gap: 2px;
}

.channel-row:hover .channel-row-actions,
.channel-row.is-active .channel-row-actions {
  display: flex;
}

.mini-action-btn {
  border: none;
  background: transparent;
  color: var(--text-light);
  padding: 3px 5px;
  border-radius: 5px;
  font-size: 0.75rem;
  cursor: pointer;
}

.mini-action-btn:hover {
  background: var(--surface);
  color: var(--text);
}

/* Chat Stage */
.chat-empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}

.chat-empty-card {
  max-width: 440px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 26px;
  box-shadow: var(--shadow-sm);
}

.chat-empty-card h2 {
  margin: 12px 0 6px;
  font-size: 1.25rem;
}

.chat-empty-card p {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.chat-empty-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.chat-active-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

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

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.channel-badge-icon {
  font-size: 1.35rem;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--primary-soft);
  flex-shrink: 0;
}

.chat-header-titles {
  min-width: 0;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-title-row h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-contact-pill {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.chat-channel-desc {
  margin: 1px 0 0;
  font-size: 0.77rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Channel Status Filter Bar */
.channel-status-filter-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.status-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.status-filter-chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 155px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 40;
}

.dropdown-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--surface-muted);
}

.channel-search-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-count-label {
  font-size: 0.78rem;
  color: var(--text-light);
  white-space: nowrap;
}

.chat-blocked-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 16px;
  background: var(--rose-soft);
  color: var(--rose);
  border-bottom: 1px solid rgba(220, 38, 38, 0.25);
  font-size: 0.84rem;
  font-weight: 600;
}

/* Messages Stream */
.messages-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 12px;
  display: flex;
  flex-direction: column;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.date-divider span {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-light);
}

.message-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 78%;
  position: relative;
}

.message-row.is-me {
  align-self: flex-end;
  align-items: flex-end;
}

.message-row.is-highlight .message-bubble {
  box-shadow: 0 0 0 3px var(--amber);
}

.message-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-select-checkbox {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.message-sender-line {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-light);
  margin: 0 4px 3px;
}

.message-bubble-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.message-row.is-me .message-bubble-wrap {
  flex-direction: row-reverse;
}

.message-bubble {
  padding: 10px 13px;
  border-radius: 15px;
  background: var(--bubble-other);
  color: var(--bubble-other-text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 110px;
  word-break: break-word;
}

.message-row.is-me .message-bubble {
  background: var(--bubble-me);
  color: var(--bubble-me-text);
  border-color: transparent;
}

.message-row.is-deleted .message-bubble {
  background: var(--surface-muted);
  color: var(--text-light);
  border: 1px dashed var(--border-strong);
  font-style: italic;
}

.message-origin-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.08);
  margin-bottom: 5px;
}

.message-row.is-me .message-origin-tag {
  background: rgba(255, 255, 255, 0.18);
}

.message-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  cursor: pointer;
  margin-bottom: 5px;
}

.message-reply-quote {
  padding: 6px 9px;
  border-left: 3px solid var(--primary);
  background: rgba(15, 23, 42, 0.06);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.77rem;
  cursor: pointer;
}

.message-row.is-me .message-reply-quote {
  border-left-color: #c7d2fe;
  background: rgba(255, 255, 255, 0.14);
}

.message-reply-quote strong {
  display: block;
  font-size: 0.73rem;
}

.message-text {
  white-space: pre-wrap;
  font-size: 0.91rem;
  line-height: 1.48;
}

.message-media-img {
  display: block;
  max-width: 280px;
  max-height: 240px;
  border-radius: 10px;
  cursor: zoom-in;
  margin-bottom: 6px;
  object-fit: cover;
  background: var(--surface-muted);
}

.message-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.05);
  margin-bottom: 6px;
}

.message-row.is-me .message-file-card {
  background: rgba(255, 255, 255, 0.14);
}

.message-file-info {
  flex: 1;
  min-width: 0;
}

.message-file-info strong {
  display: block;
  font-size: 0.83rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-file-info span {
  font-size: 0.73rem;
  opacity: 0.85;
}

.message-file-actions {
  display: flex;
  gap: 4px;
}

.voice-player-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  margin-bottom: 4px;
}

.voice-player-box audio {
  width: 100%;
  height: 36px;
}

.voice-meta-label {
  font-size: 0.73rem;
  opacity: 0.85;
}

.message-meta-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.69rem;
  opacity: 0.8;
}

.message-pin-flag {
  font-size: 0.72rem;
}

.message-reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.reaction-chip.is-mine {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* Message Hover Action Bar */
.message-actions-bar {
  display: none;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 6px;
  box-shadow: var(--shadow-sm);
}

.message-row:hover .message-actions-bar,
.message-row:focus-within .message-actions-bar {
  display: inline-flex;
}

.msg-act-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 3px 5px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
}

.msg-act-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.msg-act-btn.is-danger:hover {
  color: var(--rose);
}

/* Typing Indicator & Scroll Bottom */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  align-self: flex-start;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  animation: bounceDot 1.1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes bounceDot {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.45;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.scroll-bottom-btn {
  position: absolute;
  right: 22px;
  bottom: 84px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 15;
}

/* Multi-Select Bottom Floating Bar */
.multi-select-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--primary-soft);
  border-top: 1px solid var(--primary);
  color: var(--text);
}

.multi-select-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Drag & Drop Upload Overlay */
.drop-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(79, 70, 229, 0.16);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 25;
  padding: 20px;
}

.drop-upload-box {
  background: var(--surface);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-md);
}

.drop-icon {
  font-size: 2.2rem;
}

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

.reply-edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-left: 3px solid var(--primary);
  background: var(--surface-muted);
  border-radius: 6px;
  margin-bottom: 8px;
}

.reply-edit-content {
  min-width: 0;
}

.reply-edit-content strong {
  display: block;
  font-size: 0.76rem;
  color: var(--primary);
}

.reply-edit-content span {
  display: block;
  font-size: 0.79rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-progress-wrap {
  margin-bottom: 8px;
}

.upload-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #0ea5e9);
  transition: width 0.15s ease;
}

.voice-recorder-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--rose-soft);
  border: 1px solid rgba(220, 38, 38, 0.25);
  margin-bottom: 8px;
}

.voice-rec-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--rose);
}

.rec-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rose);
  animation: pulseRec 1s infinite;
}

@keyframes pulseRec {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

.voice-rec-actions {
  display: flex;
  gap: 6px;
}

.composer-main-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-tool-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 1.05rem;
  cursor: pointer;
}

.composer-tool-btn:hover:not(:disabled) {
  border-color: var(--primary);
}

.composer-emoji-wrap {
  position: relative;
}

.emoji-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  z-index: 40;
}

.emoji-btn {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  padding: 5px;
  border-radius: 6px;
  cursor: pointer;
}

.emoji-btn:hover {
  background: var(--surface-muted);
}

.composer-textarea {
  flex: 1;
  min-height: 38px;
  max-height: 130px;
  resize: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-family: inherit;
  font-size: 0.91rem;
  line-height: 1.45;
}

.composer-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.composer-send-btn {
  height: 38px;
  flex-shrink: 0;
}

/* Reaction & Status Popovers */
.reaction-popover {
  position: fixed;
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  z-index: 95;
}

.status-popover {
  position: fixed;
  width: 260px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-popover-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}

.status-popover-item:hover {
  background: var(--surface-muted);
}

.status-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Business Profile Drawer */
.drawer-body {
  padding: 16px;
}

.drawer-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.drawer-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.drawer-hero h3 {
  margin: 4px 0 0;
  font-size: 1.08rem;
}

.drawer-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-id-chip {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
}

.presence-label {
  font-size: 0.76rem;
  color: var(--text-light);
}

.presence-label.is-online {
  color: var(--emerald);
  font-weight: 600;
}

.business-card-box {
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.company-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.company-logo,
.company-logo-lg {
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.company-logo {
  width: 42px;
  height: 42px;
}

.company-logo-lg {
  width: 54px;
  height: 54px;
}

.company-logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1.25rem;
}

.company-head strong {
  display: block;
  font-size: 0.9rem;
}

.company-type-tag {
  font-size: 0.76rem;
  color: var(--text-light);
}

.profile-details-list {
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-item dt {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}

.detail-item dd {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-word;
}

.drawer-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.media-filter-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.filter-pill {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.filter-pill.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.drawer-media-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-media-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.drawer-media-item strong {
  display: block;
  font-size: 0.8rem;
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-media-item span {
  font-size: 0.72rem;
  color: var(--text-light);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 80;
  overflow-y: auto;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-card-sm {
  max-width: 410px;
}

.modal-card-lg {
  max-width: 660px;
}

.modal-card-xl {
  max-width: 900px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.modal-actions-split {
  justify-content: space-between;
  align-items: center;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
}

.modal-scroll-list {
  margin-top: 12px;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Incoming Request Popup */
.incoming-req-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  margin-bottom: 14px;
}

.incoming-req-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.incoming-req-meta strong {
  font-size: 1rem;
}

.incoming-req-pref {
  margin-bottom: 14px;
}

.incoming-req-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.incoming-req-secondary-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.unlock-forgot-row {
  margin-top: 12px;
  text-align: center;
}

.status-editor-box {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.status-preview-wrap {
  min-height: 38px;
  display: flex;
  align-items: center;
}

.status-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.prefs-card-box {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

/* Settings & QR Showcase */
.id-showcase-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.field-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}

.id-copy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}

.big-chat-id {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.05em;
}

.mini-qr-box {
  width: 78px;
  height: 78px;
  background: #ffffff;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.mini-qr-box svg,
.qr-large-box svg,
.mfa-qr-box svg {
  width: 100%;
  height: 100%;
  display: block;
}

.upload-pair-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.upload-asset-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-asset-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-asset-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/* MFA Panels */
.mfa-status-banner {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.mfa-status-banner.is-enabled {
  background: var(--emerald-soft);
  color: var(--emerald);
  border-color: rgba(5, 150, 105, 0.3);
}

.mfa-qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
}

.mfa-qr-box,
.qr-large-box {
  width: 190px;
  height: 190px;
  background: #ffffff;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.mfa-secret-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.mfa-secret-code {
  font-size: 0.82rem;
  word-break: break-all;
}

.mfa-factor-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

/* Add Contact & Lookup */
.lookup-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.lookup-result-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.my-qr-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 10px 0;
}

/* Channel Icon & Color Pickers */
.picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.emoji-choice-btn {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 6px;
  padding: 4px 7px;
  cursor: pointer;
}

.color-swatch-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}

/* Search & Pinned Results */
.search-result-card {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  cursor: pointer;
}

.search-result-card:hover {
  border-color: var(--primary);
}

.search-result-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 4px;
}

/* Lightbox & File Preview */
.preview-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  max-height: 72vh;
  overflow: auto;
}

.preview-modal-body img {
  max-width: 100%;
  max-height: 68vh;
  border-radius: 10px;
}

.preview-modal-body iframe {
  width: 100%;
  height: 68vh;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.preview-text-pre {
  width: 100%;
  max-height: 65vh;
  overflow: auto;
  padding: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.84rem;
  white-space: pre-wrap;
}

.confirm-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Toast Stack */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
  max-width: 340px;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-md);
  font-size: 0.84rem;
  font-weight: 500;
}

.toast.is-success {
  border-left-color: var(--emerald);
}

.toast.is-error {
  border-left-color: var(--rose);
}

.toast.is-warning {
  border-left-color: var(--amber);
}

/* Mobile Back Button */
.mobile-back-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

/* Responsive Tablet & Mobile */
@media (max-width: 1180px) {
  .workspace-layout {
    grid-template-columns: 260px 230px minmax(0, 1fr);
  }

  .profile-drawer {
    position: fixed;
    top: 57px;
    right: 0;
    bottom: 0;
    z-index: 45;
    box-shadow: var(--shadow-md);
  }
}

@media (max-width: 899px) {
  .app-header {
    padding: 8px 12px;
  }

  .header-user-info,
  .header-actions .icon-pill-btn span:not(.pill-mini-badge) {
    display: none;
  }

  .workspace-layout {
    display: block;
    position: relative;
  }

  .pane {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-right: none;
  }

  .workspace-layout[data-mobile-pane="contacts"] .channels-pane,
  .workspace-layout[data-mobile-pane="contacts"] .chat-pane {
    display: none;
  }

  .workspace-layout[data-mobile-pane="channels"] .contacts-pane,
  .workspace-layout[data-mobile-pane="channels"] .chat-pane {
    display: none;
  }

  .workspace-layout[data-mobile-pane="chat"] .contacts-pane,
  .workspace-layout[data-mobile-pane="chat"] .channels-pane {
    display: none;
  }

  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
  }

  .message-row {
    max-width: 90%;
  }

  .form-grid-2,
  .upload-pair-grid {
    grid-template-columns: 1fr;
  }

  .profile-drawer {
    width: 100%;
    top: 0;
  }
}
