/* ── Design tokens ────────────────────────────────────────── */
:root {
  --bg-deep: #0a1014;   /* deepest auth/loading background */
  --bg-0: #111b21;      /* deepest background */
  --bg-1: #182229;      /* subtle raised surface */
  --bg-2: #202c33;      /* header / footer surface */
  --bg-3: #2a3942;      /* input / item background */
  --bg-4: #3b4a54;      /* border / divider */
  --text-1: #e9edef;    /* primary text */
  --text-2: #8696a0;    /* secondary text */
  --accent: #00a884;    /* green accent */
  --danger: #ef4444;    /* destructive red */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.55);
  /* message bubbles */
  --bubble-out: #005c4b;
  --bubble-in: #202c33;
  --bubble-out-txt: #e9edef;
  --bubble-in-txt: #e9edef;
  --bubble-out-meta: #c4dee4;
  /* chat background */
  --chat-bg: #0b141a;
  /* hover overlay on dark surface */
  --hover-overlay: rgba(255,255,255,0.06);
  /* scrollbar */
  --scrollbar-thumb: #374045;
  --scrollbar-track: transparent;
}

/* ── Light mode overrides ─────────────────────────────────── */
[data-theme="light"] {
  --bg-deep: #f0f2f5;
  --bg-0: #f0f2f5;
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #f0f2f5;
  --bg-4: #d1d7db;
  --text-1: #111b21;
  --text-2: #54656f;
  --shadow: 0 4px 20px rgba(0,0,0,0.15);
  --bubble-out: #d9fdd3;
  --bubble-in: #ffffff;
  --bubble-out-txt: #111b21;
  --bubble-in-txt: #111b21;
  --bubble-out-meta: #54656f;
  --chat-bg: #efeae2;
  --hover-overlay: rgba(0,0,0,0.05);
  --scrollbar-thumb: #c1c9ce;
  --scrollbar-track: transparent;
}

html, body {
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-0);
  color: var(--text-1);
}

/* ── Reusable popup/context menu shell ───────────────────── */
.ctx-menu {
  position: fixed;
  z-index: 9500;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 200px;
  overflow: hidden;
  border: 1px solid var(--bg-4);
}
.ctx-menu-hdr {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-4);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background .1s;
}
.ctx-menu-item:hover {
  background: var(--hover-overlay);
}
.ctx-menu-item.danger {
  color: var(--danger);
}
.ctx-menu-item i {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* ── App loading screen ───────────────────────────────────── */
.app-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.app-loading-logo {
  font-size: 56px;
  color: #00a884;
  line-height: 1;
}
.app-loading-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.04em;
}
@keyframes _spin { to { transform: rotate(360deg); } }
.app-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0,168,132,0.25);
  border-top-color: #00a884;
  border-radius: 50%;
  animation: _spin 0.8s linear infinite;
}

/* ── Auth / Login ─────────────────────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
}

.auth-card {
  background: var(--bg-2);
  border-radius: 16px;
  padding: 28px 32px 32px;
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--bg-3);
  transition: width 0.18s ease;
}

.auth-card.auth-card-register {
  width: 520px;
}

/* Brand row — icon + name/tagline */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.auth-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--bg-0);
  flex-shrink: 0;
}
.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
  margin: 0;
}
.auth-subtitle {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-0);
  padding: 3px;
}

.auth-tab {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  background: #00a884;
  color: var(--bg-0);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form.auth-form-register {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
  align-items: start;
}

.auth-form.auth-form-register > .auth-username-field,
.auth-form.auth-form-register > .auth-error,
.auth-form.auth-form-register > .auth-button {
  grid-column: 1 / -1;
}

.auth-label {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.auth-label-span-2 {
  grid-column: 1 / -1;
}

.auth-textarea {
  resize: vertical;
  min-height: 58px;
  font-family: inherit;
}

.auth-input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--bg-3);
  background: var(--bg-0);
  color: var(--text-1);
  font-size: 14px;
  transition: border-color 0.15s;
}

.auth-input:focus {
  outline: none;
  border-color: #00a884;
}

.auth-error {
  color: #f97373;
  font-size: 13px;
}

.auth-button {
  margin-top: 4px;
  padding: 11px 12px;
  border-radius: 8px;
  border: none;
  background: #00a884;
  color: var(--bg-0);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.auth-button:hover { background: #00c39b; }

.auth-button:disabled {
  opacity: 0.6;
  cursor: default;
}

@media (max-width: 560px) {
  .auth-card,
  .auth-card.auth-card-register {
    width: min(100%, 420px);
    padding: 24px 20px 24px;
  }

  .auth-form.auth-form-register {
    grid-template-columns: 1fr;
  }

  .auth-label-span-2 {
    grid-column: auto;
  }
}

/* app-shell layout uses Bootstrap flex/rows; keep colors here only */

.app-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--bg-2);
}

.app-rail {
  width: 72px;
  background: var(--bg-2);
  border-right: 1px solid var(--bg-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
  padding-bottom: 8px;
  gap: 4px;
}

/* Hide the icon rail when QR screen is visible (login/QR flow) */
#qrScreen:not(.d-none) ~ .wa-layout .app-rail {
  display: none !important;
}

.app-rail-icon {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  border: none;
  background: transparent;
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  position: relative;
}

.app-rail-icon.active,
.app-rail-icon:hover {
  background: var(--bg-0);
}

.app-header-left {
  display: flex;
  flex-direction: column;
}

.app-header-title {
  font-size: 14px;
  font-weight: 600;
}

.app-header-sub {
  font-size: 12px;
  color: var(--text-2);
}

.app-header-right {
  position: relative;
}

.profile-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-2);
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.profile-initial {
  font-size: 14px;
  font-weight: 600;
}

.profile-menu {
  position: absolute;
  right: 0;
  top: 40px;
  background: #020617;
  border-radius: 8px;
  border: 1px solid #1f2933;
  min-width: 200px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 50;
}

.profile-menu-item {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
  background: transparent;
  border: none;
  color: #e5e7eb;
  cursor: pointer;
}

.profile-menu-item:hover {
  background: #111827;
}

.sidebar {
  background: var(--bg-0);
  border-right: 1px solid var(--bg-2);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bg-2);
}

.sidebar-user-block {
  display: flex;
  flex-direction: column;
}

.sidebar-user {
  font-weight: 600;
}

.sidebar-role {
  font-size: 12px;
  color: var(--text-2);
}

.sidebar-logout {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  background: #ef4444;
  color: white;
}

.sidebar-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg-2);
}

.sidebar-section-title {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.sidebar-small-button {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--bg-2);
  background: var(--bg-2);
  color: var(--text-1);
  cursor: pointer;
}

.session-list {
  max-height: 160px;
  overflow-y: auto;
}

.chat-list {
  overflow-y: auto;
}

.session-item,
.chat-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #e5e7eb;
  cursor: pointer;
  display: block;
  font-size: 14px;
}

.session-item.active,
.chat-item.active {
  background: #111827;
}

.session-name {
  font-size: 13px;
  font-weight: 500;
}

.session-status {
  font-size: 11px;
  color: var(--text-2);
}

.sidebar-search {
  width: 100%;
  margin-bottom: 6px;
  padding: 8px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 13px;
}

.chat-title {
  font-size: 14px;
  font-weight: 500;
}

.chat-subtitle {
  font-size: 12px;
  color: var(--text-2);
}

.chat-locked {
  margin-left: 4px;
  font-size: 11px;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
}

.chat-meta {
  font-size: 11px;
  color: var(--text-2);
}

.admin-note {
  font-size: 12px;
  color: var(--text-2);
}

.main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  min-height: 0;
}

.chat-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-2);
  background: var(--bg-2);
}

.chat-header-title {
  font-weight: 600;
  font-size: 14px;
}

.chat-header-sub {
  font-size: 12px;
  color: var(--text-2);
}

.chat-disappearing-pill {
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #00a884;
  background: rgba(0, 168, 132, 0.1);
  border: 1px solid rgba(0, 168, 132, 0.25);
  padding: 3px 8px;
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
}

.chat-header-actions {
  color: var(--text-1);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.chat-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
}

.chat-header-icon:hover {
  background: var(--bg-0);
}

.chat-typing-indicator {
  display: none; /* subtitle already shows typing status */
}

.messages-pane {
  flex: 1;
  min-height: 0;
  padding: 12px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
  background:
    radial-gradient(circle at 0 0, var(--bg-2) 1px, transparent 1px),
    radial-gradient(circle at 8px 8px, var(--bg-2) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--chat-bg);
}

.message-row {
  display: flex;
  margin-bottom: 2px;
}

.message-row.has-tail {
  margin-bottom: 8px;
}

.message-row.from-me {
  justify-content: flex-end;
}

.message-row.from-them {
  justify-content: flex-start;
  align-items: flex-start;
}

.message-bubble {
  max-width: 65%;
  padding: 6px 7px 4px 9px;
  border-radius: 8px;
  position: relative;
  font-size: 13px;
  line-height: 1.4;
  background: var(--bubble-in);
  color: var(--bubble-in-txt);
  width: fit-content;
  /* WhatsApp-style tail using box-shadow trick on ::before */
}
/* When inside .bubble-wrap, max-width is on the wrapper */
.bubble-wrap > .message-bubble {
  max-width: 100%;
}

.message-row.from-me .message-bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-txt);
}

.message-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-2);
}

.message-row.from-me .message-meta {
  color: var(--bubble-out-meta);
}

.message-sender {
  font-weight: 500;
}

/* Message reaction pills */
.bubble-wrap {
  display: inline-flex;
  flex-direction: column;
  max-width: 70%;
  position: relative;
}
.message-row.from-me .bubble-wrap {
  align-items: flex-end;
}
.message-row.from-them .bubble-wrap {
  align-items: flex-start;
}
.bubble-wrap .message-bubble {
  max-width: 100%;
}
/* Reaction bar sits at the bottom of bubble-wrap, overlapping the bubble bottom */
.msg-reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: -12px;
  margin-bottom: 4px;
  padding: 0 8px;
  position: relative;
  z-index: 2;
}
.message-row.from-me .msg-reaction-bar {
  justify-content: flex-end;
}
.message-row.from-them .msg-reaction-bar {
  justify-content: flex-start;
}
.msg-reaction-pill {
  background: #1f2c34;
  border: 1.5px solid var(--bg-4);
  border-radius: 20px;
  padding: 3px 8px 3px 5px;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  line-height: 1.3;
  transition: background .12s;
}
.msg-reaction-pill:hover {
  background: var(--bg-3);
}
.msg-reaction-pill .reaction-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
}

/* Chat search highlights */
mark.msg-search-highlight {
  background: #f0b400;
  color: #111;
  border-radius: 2px;
  padding: 0 1px;
}
.message-row.search-match .message-bubble {
  outline: 1px solid rgba(240,180,0,0.4);
  border-radius: 8px;
}
.message-row.search-match-active .message-bubble {
  outline: 2px solid #f0b400;
  border-radius: 8px;
}
/* Search result items in info pane */
.cs-result-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-3);
  cursor: pointer;
  transition: background .1s;
}
.cs-result-item:hover { background: rgba(255,255,255,0.04); }
.cs-result-item.cs-result-active { background: rgba(240,180,0,0.1); }
/* Info pane search mode: hide normal header decorations */
#infoPane[data-search-mode] .info-pane-avatar,
#infoPane[data-search-mode] #infoPhone,
#infoPane[data-search-mode] #infoPresence { display: none !important; }

/* Message action button — chevron overlay inside the bubble, top-right corner */
.message-actions {
  display: none;
  position: absolute;
  top: 2px;
  right: 4px;
  z-index: 2;
}

.message-row:hover .message-actions {
  display: flex;
}

.message-action-button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(17,27,33,0.6);
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(4px);
}

.message-action-button:hover {
  background: rgba(17,27,33,0.85);
}

/* Message context menu popup */
.msg-ctx-menu {
  position: fixed;
  background: var(--bg-2);
  border: 1px solid var(--bg-3);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  z-index: 9000;
  min-width: 180px;
  overflow: hidden;
  padding: 4px 0;
}

.msg-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border: none;
  background: transparent;
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.msg-ctx-item:hover {
  background: rgba(255,255,255,0.07);
}

.msg-ctx-item.danger {
  color: #ef4444;
}

.msg-ctx-item i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.message-row {
  position: relative;
}

.message-reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--bg-2);
  border-left: 3px solid #00a884;
  font-size: 12px;
  color: var(--text-1);
}

.message-reply-preview-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

.message-reply-preview-cancel {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  padding-left: 6px;
}

/* WhatsApp-style floating format popup (appears above textarea on text selection) */
#_composerFmtPopup {
  animation: fmtPopupIn 0.1s ease;
}
#_composerFmtPopup::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: var(--tail-left, 50%);
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #233138;
}
@keyframes fmtPopupIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-input-row {
  padding: 10px 12px;
  border-top: 1px solid var(--bg-2);
  display: flex;
  gap: 8px;
}

.dropdown-menu-dark {
  background-color: var(--bg-2);
  color: var(--text-1);
}

.dropdown-menu-dark .dropdown-item {
  color: var(--text-1);
}

.dropdown-menu-dark .dropdown-item:hover {
  background-color: var(--bg-0);
}

.message-input {
  flex: 1;
  padding: 9px 14px;
  border-radius: 21px;
  border: 1px solid var(--bg-2);
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 15px;
  resize: none;
  overflow-y: auto;
  min-height: 21px;
  max-height: 84px;
  line-height: 1.4;
  font-family: inherit;
  display: block;
  scrollbar-width: none;
}

.message-send-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #00a884;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.message-send-button:hover {
  background: #06cf9c;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 14px;
}

.sidebar-tabs {
  display: flex;
  padding: 4px 12px;
  gap: 4px;
}

.sidebar-tab {
  flex: 1;
  padding: 6px 0;
  border-radius: 999px;
  border: 1px solid #1f2933;
  background: #020617;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}

.sidebar-tab.active {
  background: #22c55e;
  color: #020617;
  border-color: #22c55e;
}

.call-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.call-item {
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: #020617;
}

.call-title {
  font-size: 13px;
  font-weight: 500;
}

.call-subtitle {
  font-size: 11px;
  color: var(--text-2);
}

.sidebar-empty {
  font-size: 12px;
  color: #6b7280;
}

.syncing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-0);
  border-bottom: 1px solid var(--bg-3);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes vnPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.7); } }
#sidebarResizeHandle:hover, #sidebarResizeHandle.dragging { background: rgba(0,168,132,0.45) !important; }
.message-row.msg-selected { background: rgba(0,168,132,0.12) !important; outline: 1px solid rgba(0,168,132,0.3); border-radius: 4px; }
@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes typingBubbleIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  animation: typingBubbleIn 0.2s ease-out;
}
.typing-bubble .typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-2);
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}
.typing-bubble .typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble .typing-dot:nth-child(3) { animation-delay: 0.4s; }
.typing-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0 16px 8px 16px;
  flex-shrink: 0;
}
.typing-bubble-label {
  font-size: 11.5px;
  color: var(--text-2);
  margin-bottom: 3px;
  font-weight: 500;
}
.spin-icon { display: inline-block; animation: spin 1s linear infinite; }

.pinned-separator {
  padding: 4px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-2);
  background: var(--bg-0);
  border-top: 1px solid var(--bg-3);
  margin-top: 2px;
  pointer-events: none;
  user-select: none;
}

.chat-load-more-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: none;
  border: none;
  color: #00a884;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.chat-load-more-btn:hover {
  background: rgba(255,255,255,0.05);
}

/* ── Chat list skeleton loader ── */
@keyframes skeleton-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

.chat-skeleton {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #1a2333;
}

.chat-skeleton-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(90deg, #1a2333 25%, #243044 50%, #1a2333 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.4s infinite linear;
}

.chat-skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-skeleton-line {
  border-radius: 4px;
  background: linear-gradient(90deg, #1a2333 25%, #243044 50%, #1a2333 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.4s infinite linear;
}

.chat-skeleton-name {
  width: 55%;
  height: 12px;
}

.chat-skeleton-preview {
  width: 80%;
  height: 10px;
}

/* ── Message loading skeleton ── */
.msg-loading-skeleton {
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  padding: 16px;
  height: 100%;
}
.msg-skel-row {
  display: flex;
}
.msg-skel-row.from-me { justify-content: flex-end; }
.msg-skel-row.from-them { justify-content: flex-start; }
.msg-skel-bubble {
  height: 38px;
  width: 200px;
  border-radius: 10px;
  background: linear-gradient(90deg, #1a2333 25%, #243044 50%, #1a2333 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.2s infinite linear;
}
.msg-skel-bubble.short { width: 120px; }
.msg-skel-bubble.medium { width: 160px; }

/* ── Media thumbnail skeleton ── */
.media-thumb-skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, #1a2333 25%, #243044 50%, #1a2333 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.2s infinite linear;
  opacity: 0.9;
}

/* ── Group sender name above bubble ── */
.message-sender-name {
  font-size: 11px;
  font-weight: 600;
  color: #53bdeb;
  margin-bottom: 2px;
}

/* ── Quoted/reply block inside bubble ── */
.message-quoted {
  background: rgba(0,0,0,0.2);
  border-left: 3px solid #53bdeb;
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 12px;
  overflow: hidden;
  max-height: 60px;
}

.message-row.from-me .message-quoted {
  background: rgba(0,0,0,0.15);
  border-left-color: rgba(255,255,255,0.4);
}

.message-quoted-sender {
  color: #53bdeb;
  font-weight: 600;
  font-size: 11px;
  margin-bottom: 1px;
}

.message-row.from-me .message-quoted-sender {
  color: rgba(255,255,255,0.7);
}

.message-quoted-text {
  color: var(--text-1);
  opacity: 0.8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

/* Reply quote — color-coded sender name bar */
.message-quoted-sender { color: #53bdeb; }
.message-row.from-me .message-quoted-sender { color: rgba(255,255,255,0.75); }
/* Each participant gets a hue via data-color attribute */
.message-quoted[data-color="0"] .message-quoted-sender { color: #53bdeb; }
.message-quoted[data-color="1"] .message-quoted-sender { color: #e67e22; }
.message-quoted[data-color="2"] .message-quoted-sender { color: #2ecc71; }
.message-quoted[data-color="3"] .message-quoted-sender { color: #e74c3c; }
.message-quoted[data-color="4"] .message-quoted-sender { color: #9b59b6; }
.message-quoted[data-color="5"] .message-quoted-sender { color: #f39c12; }
.message-quoted[data-color="6"] .message-quoted-sender { color: #1abc9c; }
.message-quoted[data-color="7"] .message-quoted-sender { color: #e91e63; }

/* Highlight on scroll-to-quoted */
@keyframes msg-flash { 0%,100% { background: transparent; } 50% { background: rgba(0,168,132,0.18); } }
.msg-highlight { animation: msg-flash 1.5s ease; border-radius: 8px; }

/* ═══════════════════════════════════════════════════════════
   CSS UTILITY FRAMEWORK — avoid inline styles in JS/HTML
   ════════════════════════════════════════════════════════════ */

/* ── Buttons ─────────────────────────────────────────────── */
.btn { border: none; border-radius: var(--radius-sm); padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: opacity .15s, background .15s; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--bg-0); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #00c49a; }
.btn-secondary { background: var(--bg-3); color: var(--text-1); border: 1px solid var(--bg-4); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-4); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.1); }
.btn-ghost { background: transparent; color: var(--text-2); border: none; }
.btn-ghost:hover:not(:disabled) { color: var(--text-1); background: var(--hover-overlay); }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; }
.btn-icon-sm { width: 28px; height: 28px; padding: 0; border-radius: 50%; }
.btn-full { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Form inputs ─────────────────────────────────────────── */
.form-inp, .form-textarea {
  width: 100%; background: var(--bg-3); border: 1px solid var(--bg-4); border-radius: var(--radius-sm);
  padding: 8px 12px; color: var(--text-1); font-size: 13px; outline: none; box-sizing: border-box;
  font-family: inherit;
}
.form-inp:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 72px; }
.form-select {
  width: 100%; background: var(--bg-3); border: 1px solid var(--bg-4); border-radius: var(--radius-sm);
  padding: 8px 12px; color: var(--text-1); font-size: 13px; outline: none; box-sizing: border-box;
}
.form-label { font-size: 12px; color: var(--text-2); margin-bottom: 4px; display: block; }
.form-hint { font-size: 11px; color: var(--text-2); margin-top: 3px; opacity: 0.8; }
.form-field { margin-bottom: 14px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-row { display: flex; gap: 8px; }

/* ── Layout ──────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 16px; }
.min-w-0 { min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow-y: auto; flex: 1; }
.w-full { width: 100%; }

/* ── Spacing ─────────────────────────────────────────────── */
.p-0 { padding: 0; }
.p-sm { padding: 8px; }
.p-md { padding: 16px; }
.p-lg { padding: 24px; }
.px-md { padding-left: 16px; padding-right: 16px; }
.py-md { padding-top: 16px; padding-bottom: 16px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 14px; }
.mt-sm { margin-top: 8px; }

/* ── Typography ──────────────────────────────────────────── */
.text-primary { color: var(--text-1) !important; }
.text-muted { color: var(--text-2); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-md { font-size: 13px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 15px; }
.font-600 { font-weight: 600; }
.italic { font-style: italic; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-center { text-align: center; }

/* ── Surface cards ───────────────────────────────────────── */
.surface { background: var(--bg-2); border-radius: var(--radius-sm); }
.surface-border { border: 1px solid var(--bg-4); }
.divider { border-top: 1px solid var(--bg-4); }
.divider-bottom { border-bottom: 1px solid var(--bg-4); }

/* ── Avatar ──────────────────────────────────────────────── */
.avatar {
  width: 46px; height: 46px; border-radius: 50%; background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; color: var(--text-1); flex-shrink: 0; overflow: hidden;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── List rows ───────────────────────────────────────────── */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--bg-1); }
.list-row:last-child { border-bottom: none; }
.list-row-info { flex: 1; min-width: 0; }
.list-row-name { font-size: 14px; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-sub { font-size: 12px; color: var(--text-2); margin-top: 1px; }

/* ── Context menu ────────────────────────────────────────── */
.ctx-menu {
  position: fixed; z-index: 9500; background: var(--bg-2);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  min-width: 200px; overflow: hidden; border: 1px solid var(--bg-4);
}
.ctx-menu-hdr { padding: 10px 16px; border-bottom: 1px solid var(--bg-4); font-size: 13px; font-weight: 600; color: var(--text-1); }
.ctx-menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 16px; background: none; border: none; color: var(--text-1);
  font-size: 13px; cursor: pointer; text-align: left; white-space: nowrap; transition: background .1s;
}
.ctx-menu-item:hover { background: var(--hover-overlay); }
.ctx-menu-item.danger { color: var(--danger); }
.ctx-menu-item i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state-center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; text-align: center; min-height: 120px; }
.empty-state-icon { font-size: 36px; color: var(--bg-4); display: block; margin-bottom: 10px; }
.empty-state-text { color: var(--text-2); font-size: 13px; }

/* ── Contact highlight (sidebar list) ───────────────────── */
@keyframes contactHighlight {
  0%   { background: rgba(0,168,132,0.25); }
  100% { background: transparent; }
}
.contact-highlight { animation: contactHighlight 2s ease-out forwards; border-radius: 8px; }

/* ── Section headers (inside overlay bodies) ─────────────── */
.section-hdr { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; padding: 12px 16px 6px; }

/* ── Toggle row ──────────────────────────────────────────── */
.toggle-row { display: flex; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--bg-4); }
.toggle-label { font-size: 13px; color: var(--text-1); }
.toggle-desc { font-size: 11px; color: var(--text-2); margin-top: 2px; }

/* ── Search bar in overlay ───────────────────────────────── */
.overlay-search {
  background: var(--bg-3); border: none; border-bottom: 1px solid var(--bg-4);
  padding: 10px 16px; color: var(--text-1); font-size: 13px; outline: none;
  width: 100%; box-sizing: border-box;
}
.overlay-search::placeholder { color: var(--text-2); }

/* ── Overlay footer bar ──────────────────────────────────── */
.overlay-footer {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--bg-4); background: var(--bg-2); flex-shrink: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9100;
  overflow-y: auto;
  padding: 16px;
  box-sizing: border-box;
}

.overlay-card {
  /* Match admin/panel tone for all modal shells */
  background: #1f2c34;
  border-radius: var(--radius);
  border: 1px solid var(--bg-4);
  width: 640px;
  max-width: 96vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.overlay-card--wide {
  width: 960px;
}

.overlay-card--tall {
  height: 88vh;
}

.overlay-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-4);
  background: var(--bg-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  flex-shrink: 0;
  min-height: 44px;
}

.overlay-close {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.overlay-close:hover {
  color: var(--text-1);
  background: var(--hover-overlay);
}

.overlay-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  color: var(--text-1);
}

.overlay-body--settings {
  padding: 20px;
}

.overlay-body--col-gap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-settings-card {
  width: 560px;
  max-width: min(560px, calc(100vw - 24px));
  max-height: 82vh;
}

.group-settings-card .overlay-header {
  padding: 10px 14px;
  min-height: 42px;
}

.group-settings-body {
  padding: 0;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.user-table th,
.user-table td {
  border-bottom: 1px solid #111827;
  padding: 6px 4px;
  text-align: left;
}

.user-table th {
  color: var(--text-2);
  font-weight: 500;
}

.session-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.session-table th,
.session-table td {
  border-bottom: 1px solid #111827;
  padding: 6px 4px;
  text-align: left;
}

.session-table th {
  color: var(--text-2);
  font-weight: 500;
}

.chat-unread-badge {
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #25d366;
  color: var(--bg-0);
  font-size: 11px;
  text-align: center;
}

/* Info pane */

#infoPane {
  font-size: 13px;
}

#infoMeta {
    padding: 12px 14px;
}

#infoMeta h6 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  margin-top: 8px;
  margin-bottom: 4px;
}

#infoMeta .info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

#infoMeta .info-label {
  color: var(--text-2);
}

#infoMeta .info-value {
  color: #e5e7eb;
}

.badge-role {
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-role-user {
  background: var(--bg-2);
  color: var(--text-1);
}

.badge-role-admin {
  background: #00a884;
  color: var(--bg-0);
}

.badge-role-super {
  background: #d97706;
  color: var(--bg-0);
}

.api-textarea {
  width: 100%;
  min-height: 120px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--bg-2);
  background: var(--bg-0);
  color: var(--text-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
    'Courier New', monospace;
  font-size: 12px;
  resize: vertical;
}

/* ── Context / dropdown menus ── */
.chat-dropdown-menu {
  background: var(--bg-2);
  border: 1px solid var(--bg-4);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 150;
  min-width: 160px;
  overflow: hidden;
}

.chat-dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-1);
  cursor: pointer;
}

.chat-dropdown-item:hover {
  background: var(--hover-overlay);
}

.chat-dropdown-item.danger { color: #ef4444; }
.chat-dropdown-item.danger:hover { background: rgba(239,68,68,0.08); }

/* rail unread badge */
.app-rail-icon { position: relative; }
.rail-unread-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #00a884;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

.pending-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #fb923c;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

/* ── Reaction picker ── */
.reaction-picker {
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  border-radius: 24px;
  padding: 4px 8px;
  display: flex;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  z-index: 200;
}

.reaction-picker-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  padding: 4px 6px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}

.reaction-picker-btn:hover {
  background: var(--bg-0);
}

/* ── Media messages ── */
.message-media-wrap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg-3);
}

.message-media-wrap--sticker {
  width: 120px;
  max-width: 120px;
  aspect-ratio: 1 / 1;
}

.message-media-img {
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: block;
  object-fit: cover;
  margin-bottom: 2px;
}

/* ── Overflow fix for chat list ── */
.chat-list {
  overflow-y: auto;
}

/* ── Session list scrollable ── */
.session-list {
  max-height: 160px;
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════
   WhatsApp Web layout — new classes
   ═══════════════════════════════════════════════════════════ */

/* Main layout — flex row fills the viewport height */
.wa-layout {
  display: flex;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.wa-layout.magic-group-focus .app-rail,
.wa-layout.magic-group-focus .sidebar,
.wa-layout.magic-group-focus #sidebarResizeHandle {
  display: none !important;
}

/* Rail */
.app-rail {
  flex-shrink: 0;
  width: 72px;
  height: 100%;
}

.app-rail-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-rail-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail-danger { color: #ef4444; }
.rail-danger:hover { background: rgba(239, 68, 68, 0.12) !important; }

/* Sidebar — flex column fills height */
.sidebar {
  flex-shrink: 0;
  width: 360px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.22s ease;
}

.sidebar.sidebar-collapsed {
  width: 0 !important;
}

#btnToggleSidebar {
  display: none !important;
}

.sidebar-sessions {
  flex-shrink: 0;
  border-bottom: 1px solid var(--bg-2);
}

/* Calls panel — replaces sidebar-calls; fills remaining sidebar space like chat-list */
.calls-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--bg-2);
}

.calls-panel-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.sidebar-search-wrap {
  flex-shrink: 0;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--bg-2);
}

.sidebar-search-inner {
  position: relative;
  margin-bottom: 0;
}

.sidebar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-2);
  font-size: 14px;
  pointer-events: none;
}

/* Override old sidebar-search to accommodate search icon */
.sidebar-search {
  width: 100%;
  padding: 8px 36px 8px 36px;
  margin-bottom: 0;
  height: 35px;
  box-sizing: border-box;
}

.sidebar-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.sidebar-search-clear:hover { color: var(--text-1); }

.sidebar-tabs {
  padding: 4px 0 8px;
}

/* Chat list fills remaining sidebar space */
.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  max-height: none;
}

/* WhatsApp-style 72px chat items */
.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  min-height: 72px;
  font-size: inherit;
}

.chat-item-content.chat-item-content--with-community{
  gap: 3px;
}

.chat-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.chat-unread-badge--overlay {
  position: absolute;
  bottom: 0;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 18px;
  background: #25d366;
  color: var(--bg-0);
  box-sizing: border-box;
}
.chat-unread-badge--overlay.chat-unread-badge--muted {
  background: var(--text-2);
  color: var(--bg-0);
}

.chat-item:hover { background: var(--bg-1); }
.chat-item.active { background: var(--bg-3); }

.chat-avatar-lg {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
}

.chat-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
}

.chat-item-name {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.chat-item-time {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.chat-item-preview {
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.chat-item-community {
  font-size: 11px;
  color: #00a884;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: -1px;
  margin-bottom: 1px;
}

/* Main pane */
.main-pane {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

.chat-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
  cursor: pointer;
}

.min-width-0 { min-width: 0; }

/* Message input row — column so reply preview stacks above input bar */
.message-input-row {
  flex-direction: column;
  flex-shrink: 0;
  background: var(--bg-2);
}

.message-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.input-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #aebac1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.input-icon-btn:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.08);
}

/* Small icon buttons inside sidebar header */
.rail-icon-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #aebac1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
}

.rail-icon-sm:hover { background: rgba(255, 255, 255, 0.1); }

/* Info pane */
.info-pane {
  /* Small screen: absolute drawer overlay */
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  background: var(--bg-0);
}

.info-pane.drawer-open {
  transform: translateX(0);
}

/* Large screen: side-by-side panel, not a drawer overlay */
@media (min-width: 801px) {
  .info-pane {
    position: relative;
    top: auto; right: auto; bottom: auto;
    width: 0;
    max-width: none;
    transform: none;
    box-shadow: none;
    border-left: 1px solid var(--bg-3);
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: auto;
  }
  .info-pane.drawer-open {
    width: 360px;
    transform: none;
  }
  .info-pane-backdrop {
    display: none !important;
  }
}

/* ── Medium screens: info pane as fixed drawer to avoid squeezing chat ──── */
@media (min-width: 801px) and (max-width: 1100px) {
  .info-pane {
    position: fixed !important;
    top: 0;
    right: 0;
    bottom: 0;
    width: 0 !important;
    border-left: none;
    box-shadow: -4px 0 16px rgba(0,0,0,0.45);
    z-index: 220 !important;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .info-pane.drawer-open {
    width: 320px !important;
  }
  /* Show backdrop on medium screens when info pane is open */
  .info-pane-backdrop {
    display: block !important;
    position: fixed !important;
    z-index: 219;
  }
  .info-pane-backdrop:not(.visible) {
    display: none !important;
  }
}

/* ── 1100-1200px: narrow info pane to prevent chat crush ─────────────────── */
@media (min-width: 1101px) and (max-width: 1199px) {
  .info-pane.drawer-open {
    width: 280px;
  }
}

/* Backdrop behind info-pane drawer */
.info-pane-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 199;
  display: none;
}

.info-pane-backdrop.visible {
  display: block;
}


.info-pane-header {
  padding: 28px 24px 20px;
  background: var(--bg-2);
  flex-shrink: 0;
  text-align: center;
  border-bottom: 1px solid var(--bg-3);
  position: relative;
}
.info-pane-close-btn {
  position: absolute;
  top: 10px; left: 10px;
  background: none; border: none;
  color: var(--text-2); font-size: 18px;
  cursor: pointer; padding: 4px 6px;
  border-radius: 4px; line-height: 1;
}
.info-pane-close-btn:hover { color: var(--text-1); background: rgba(255,255,255,0.08); }

#infoName {
  font-size: 19px;
  font-weight: 400;
  color: var(--text-1);
  margin-bottom: 2px;
}

#infoPhone {
  font-size: 13px;
  color: var(--text-2);
}

.info-participant-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.info-participant-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
}
.info-participant-item:hover { background: rgba(255,255,255,0.05); }
.info-participant-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #aec3cc;
  flex-shrink: 0;
}
.info-participant-name { font-size: 13px; color: var(--text-1); }
.info-participant-role { font-size: 11px; color: #00a884; }

.info-pane-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--bg-3) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 600;
  color: #aec3cc;
  margin: 0 auto 12px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.info-pane-avatar:hover {
  opacity: 0.85;
}

.info-pane-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0;
  min-height: 0;
}

/* Info tab bar */
.info-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--bg-3);
  background: var(--bg-2);
  flex-shrink: 0;
}
.info-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  padding: 10px 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.15s, border-color 0.15s;
}
.info-tab.active { color: #00a884; border-bottom-color: #00a884; }
.info-tab:hover:not(.active) { color: var(--text-1); }

/* Tab panels */
.info-tab-panel { display: none; }
.info-tab-panel.active { display: block; }

/* Info cards (WA-style sections) */
.info-card {
  background: var(--bg-2);
  margin-bottom: 8px;
  overflow: hidden;
}
.info-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.info-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--bg-3);
}
.info-detail-icon { color: var(--text-2); font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.info-detail-text { color: var(--text-1); font-size: 13px; line-height: 1.4; }
.info-detail-text.multiline { white-space: pre-line; }
.info-action-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
}
.info-action-btn:hover { background: rgba(255,255,255,0.04); }
.info-action-btn i { color: var(--text-2); font-size: 17px; }
.info-hdr-btn {
  background: none;
  border: none;
  color: #00a884;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.info-hdr-btn-icon { color: var(--text-2); }
.info-empty {
  font-size: 12px;
  color: var(--text-2);
  font-style: italic;
  padding: 12px 14px;
  padding: 6px 0;
}

/* Media grid (tab) */
.info-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.info-media-cell {
  aspect-ratio: 1;
  background: #1a2830;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.info-media-video-badge {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: rgba(0,0,0,.55);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 9px;
  color: #fff;
}
.info-load-more {
  width: 100%;
  margin-top: 6px;
  background: none;
  border: 1px solid var(--bg-3);
  border-radius: 6px;
  color: var(--text-2);
  font-size: 11px;
  padding: 5px;
  cursor: pointer;
}

/* Links tab */
.info-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-2);
  margin-bottom: 2px;
  cursor: pointer;
}
.info-link-item:hover { background: #243540; }
.info-link-icon { color: #00a884; font-size: 20px; flex-shrink: 0; }
.info-link-body { flex: 1; min-width: 0; }
.info-link-domain { font-size: 13px; color: var(--text-1); font-weight: 500; }
.info-link-url { font-size: 11px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Docs tab */
.info-doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-2);
  margin-bottom: 2px;
}
.info-doc-icon { font-size: 22px; color: var(--text-2); flex-shrink: 0; }
.info-doc-body { flex: 1; min-width: 0; }
.info-doc-name { font-size: 13px; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-doc-meta { font-size: 11px; color: var(--text-2); }
.info-doc-dl { color: var(--text-2); font-size: 15px; flex-shrink: 0; text-decoration: none; }
.info-doc-dl:hover { color: #00a884; }

/* Join request cards (WA style) */
.join-request-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-3);
}
.join-request-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #aec3cc;
  flex-shrink: 0;
}
.join-request-info { flex: 1; min-width: 0; }
.join-request-name { font-size: 13px; color: var(--text-1); font-weight: 500; }
.join-request-sub { font-size: 11px; color: var(--text-2); }
.join-request-actions { display: flex; flex-direction: column; gap: 4px; }
.join-req-approve {
  background: #00a884;
  border: none;
  border-radius: 6px;
  color: var(--bg-0);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
}
.join-req-reject {
  background: none;
  border: 1px solid #4a5568;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}
.join-req-reject:hover { border-color: #ef4444; color: #ef4444; }


/* Message bubble tails — only on the last bubble of a consecutive sender group */
.message-row.has-tail.from-me .message-bubble {
  border-bottom-right-radius: 2px;
}

.message-row.has-tail.from-them .message-bubble {
  border-bottom-left-radius: 2px;
}

.message-row.has-tail.from-me .message-bubble::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -7px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 7px 7px;
  border-color: transparent transparent transparent var(--bubble-out);
}

.message-row.has-tail.from-them .message-bubble::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -7px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 7px 7px 0;
  border-color: transparent var(--bg-2) transparent transparent;
}

/* When reactions are present (.bubble-wrap), hide tail to avoid clipping */
.message-row.has-tail.from-me .bubble-wrap .message-bubble::after,
.message-row.has-tail.from-them .bubble-wrap .message-bubble::after {
  display: none;
}

/* App header simplified */
.app-header-right {
  position: static;
}

/* ═══════════════════════════════════════════════════════════
   WhatsApp Web exact color corrections
   ═══════════════════════════════════════════════════════════ */

/* Login/auth — WhatsApp-style dark theme corrections */
.auth-container {
  flex: 1;
  min-height: 0;
  background: var(--chat-bg);
}

.auth-card {
  background: var(--bg-2);
  border: 1px solid var(--bg-3);
  color: var(--text-1);
}

.auth-title { color: var(--text-1); }
.auth-subtitle { color: var(--text-2); }
.auth-brand-icon { background: #00a884; color: var(--bg-0); }

.auth-tabs {
  background: var(--bg-0);
}
.auth-tab {
  background: transparent;
  color: var(--text-2);
  border: none;
}
.auth-tab.active {
  background: #00a884;
  color: var(--bg-0);
}

.auth-label { color: var(--text-2); }

.auth-input {
  background: var(--bg-0);
  color: var(--text-1);
  border: 1px solid var(--bg-3);
}
.auth-input:focus { border-color: #00a884; }

.auth-error { color: #f97373; }

.auth-button { background: #00a884; color: var(--bg-0); }
.auth-button:hover { background: #00c39b; }

/* Sidebar tabs — WhatsApp green */
.sidebar-tab {
  background: transparent;
  color: var(--text-2);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.sidebar-tab.active {
  background: #00a884;
  color: #ffffff;
  border-color: #00a884;
}

.sidebar-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.sidebar-tab.active .sidebar-tab-count {
  background: rgba(17, 27, 33, 0.18);
}

.sidebar-tab:not(.active):hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-1);
}

/* Secondary text throughout */
.sidebar-role,
.sidebar-section-title,
.chat-header-sub,
.chat-typing-indicator,
.chat-item-time,
.chat-item-preview,
.call-subtitle,
.session-status,
.admin-note,
.sidebar-search-icon,
.overlay-close {
  color: var(--text-2);
}

/* Search bar inner */
.sidebar-search {
  background: var(--bg-3);
  border: 1px solid transparent;
  color: var(--text-1);
}

.sidebar-search:focus {
  border-color: #00a884;
  outline: none;
}

.sidebar-search::placeholder {
  color: var(--text-2);
}

/* Message input overrides */
.message-input {
  background: var(--bg-3);
  border: 1px solid transparent;
  color: var(--text-1);
}

.message-input:focus {
  outline: none;
}

.message-input::placeholder {
  color: var(--text-2);
}

.message-input::-webkit-scrollbar {
  display: none;
}

/* Profile menu */
.profile-menu {
  background: var(--bg-2);
  border-color: var(--bg-4);
}

.profile-menu-item:hover {
  background: var(--bg-3);
}

/* Call items */
.call-item {
  background: var(--bg-1);
}

/* Unread badge */
.chat-unread-badge {
  background: #00a884;
  color: #ffffff;
}
.chat-unread-badge--muted {
  background: var(--text-2);
  color: var(--bg-0);
}

/* Reply preview */
.message-reply-preview {
  border-left-color: #00a884;
}

/* App-header sub text */
.app-header-sub {
  color: var(--text-2);
}

/* ═══════════════════════════════════════════════════════════
   Sidebar header — user card
   ═══════════════════════════════════════════════════════════ */

.sidebar-header {
  padding: 10px 12px;
  gap: 6px;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-1);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  text-align: left;
}

.sidebar-user-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
/* Online/offline status dot */
.sidebar-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg-0);
  background: #6b7280;
  display: none;
}
.sidebar-avatar[data-connected="1"]::after {
  display: block;
  background: #00a884;
}
.sidebar-avatar[data-connected="0"]::after {
  display: block;
  background: #6b7280;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-user {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-phone {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════
   Session picker popup
   ═══════════════════════════════════════════════════════════ */

.session-picker-popup {
  position: fixed;
  background: #233138;
  border: 1px solid var(--bg-4);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  width: 420px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  z-index: 400;
  overflow: hidden;
}

.session-picker-header {
  padding: 12px 14px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--bg-4);
  flex-shrink: 0;
}

.session-picker-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.session-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.12s;
}

.session-picker-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.session-picker-item.active {
  background: rgba(0, 168, 132, 0.12);
}

.session-picker-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  flex-shrink: 0;
  overflow: hidden;
}

.session-picker-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.session-picker-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #1f2c34;
  display: none;
}

.session-picker-avatar[data-connected="1"]::after {
  display: block;
  background: #00a884;
}

.session-picker-avatar[data-connected="0"]::after {
  display: block;
  background: var(--text-2);
}

.session-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.session-status-dot.connected {
  background: #00a884;
}

.session-status-dot.disconnected {
  background: var(--text-2);
}

.session-picker-info {
  flex: 1;
  min-width: 0;
}

.session-picker-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-picker-phone,
.session-picker-status-text {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-picker-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.session-picker-btn {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--bg-4);
  background: transparent;
  color: var(--text-1);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.4;
}

.session-picker-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.session-picker-btn.danger {
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
}

.session-picker-btn.danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.session-picker-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.session-picker-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--bg-4);
  flex-shrink: 0;
}

.session-picker-add-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px dashed var(--bg-4);
  background: transparent;
  color: #00a884;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.session-picker-add-btn:hover {
  background: rgba(0, 168, 132, 0.08);
  border-color: #00a884;
}

/* ═══════════════════════════════════════════════════════════
   Responsive tablet layout  (768 px – 1199 px)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 768px) and (max-width: 1199px) {
  /* Narrow sidebar to give more room to chat */
  .sidebar {
    width: 280px !important;
  }

  /* Tighten sidebar header */
  .sidebar-header {
    padding: 10px 10px;
    gap: 6px;
  }

  .sidebar-user-card {
    gap: 8px;
  }

  /* Smaller chat item */
  .chat-item {
    padding: 10px 10px;
  }

  /* Tighter chat header */
  .chat-header {
    padding: 8px 12px;
  }

  /* Slightly smaller fonts */
  .chat-item-name {
    font-size: 14px;
  }

  .chat-item-preview {
    font-size: 12px;
  }
}

/* ═══════════════════════════════════════════════════════════
   Responsive mobile layout  (≤ 767 px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Hide decorative chrome */
  .app-rail { display: none !important; }
  .mobile-bottom-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 120;
    display: grid;
    grid-template-columns: 1fr 1fr 72px 1fr 1fr;
    align-items: center;
    gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(17, 27, 33, 0.96);
    border-top: 1px solid rgba(134, 150, 160, 0.22);
    backdrop-filter: blur(16px);
  }
  .mobile-dock-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    color: #8696a0;
    border-radius: 14px;
    padding: 6px 4px;
    font-size: 10px;
    cursor: pointer;
  }
  .mobile-dock-btn i {
    font-size: 20px;
    line-height: 1;
  }
  .mobile-dock-btn.active {
    color: #00a884;
  }
  .mobile-dock-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #00a884;
    color: #fff;
    border: none;
    font-size: 26px;
    cursor: pointer;
    margin: 0 auto;
    box-shadow: 0 4px 16px rgba(0, 168, 132, 0.5);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }
  .mobile-dock-fab:active {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.4);
  }
  .mobile-dock-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-3);
    color: var(--text-1);
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .mobile-dock-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
  }
  .mobile-only-btn { display: flex !important; }
  .mobile-hidden-btn { display: none !important; }
  /* Info pane is now a drawer overlay — allow on mobile, just make it wider */
  .info-pane { width: 100% !important; max-width: 100% !important; }
  /* Header acts as "tap to close" on mobile — show pointer cursor */
  .info-pane-header { cursor: pointer; }

  /* Hide resize handle — not needed on mobile */
  #sidebarResizeHandle { display: none !important; }

  /* Fill viewport below the app-header */
  .wa-layout {
    position: relative;
    overflow: hidden;
  }

  /* Sidebar: full-width, slides left when chat is opened */
  .sidebar {
    position: absolute;
    inset: 0;
    width: 100% !important;
    z-index: 10;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
    transform: translateX(0);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.mobile-hidden {
    transform: translateX(-100%);
    pointer-events: none;
  }

  /* Main pane: full-width, hidden right until chat selected */
  /* No bottom padding by default — dock is hidden in chat view */
  .main-pane {
    position: absolute;
    inset: 0;
    width: 100% !important;
    z-index: 9;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateX(100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* When the mobile dock is visible (sidebar view), pad to clear it */
  .wa-layout.mobile-dock-visible .main-pane {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .main-pane.mobile-visible {
    transform: translateX(0);
    z-index: 11;
  }

  /* Show back arrow in chat header */
  #chatHeaderBack {
    display: flex !important;
  }

  /* Ensure session picker doesn't overflow narrow screens */
  .session-picker-popup {
    width: calc(100vw - 16px);
    left: 8px !important;
  }

  /* Taller, more accessible input bar on mobile */
  .message-input-bar {
    padding: 8px 10px;
    gap: 8px;
  }
  .message-input {
    font-size: 16px; /* prevent iOS zoom on focus */
  }
  .input-icon-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  /* Modals/overlays full-screen on mobile */
  .overlay-card {
    width: 100% !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .overlay {
    align-items: flex-end;
  }
}

/* ═══════════════════════════════════════════════════════════
   New Chat popup & contact list
   ═══════════════════════════════════════════════════════════ */

.new-chat-card {
  width: 440px;
  max-height: 70vh;
}

.new-chat-body {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  flex: 1;
}

.new-chat-phone-wrap {
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg-4);
  flex-shrink: 0;
}

.new-chat-phone-label {
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (min-width: 768px) {
  .mobile-bottom-dock { display: none; }
  .mobile-only-btn { display: none !important; }
  .mobile-hidden-btn { display: flex !important; }
}

.mobile-dock-btn {
  border: none;
  background: none;
}

.new-chat-input-wrap {
  position: relative;
}

.new-chat-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-2);
  font-size: 14px;
  pointer-events: none;
}

.new-chat-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--bg-3);
  color: var(--text-1);
  font-size: 14px;
}

.new-chat-input:focus {
  outline: none;
  border-color: #00a884;
}

.new-chat-input::placeholder {
  color: var(--text-2);
}

.new-chat-contacts {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.new-chat-loading {
  padding: 20px 14px;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}

.new-chat-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.12s;
}

.new-chat-contact:hover {
  background: rgba(255, 255, 255, 0.05);
}

.new-chat-contact-avatar {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
}

.new-chat-contact-info {
  flex: 1;
  min-width: 0;
}

.new-chat-contact-name {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.new-chat-contact-phone {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

button#filterPersonal {
    display: none;
}

/* ═══════════════════════════════════════════════════════════
   Scroll-to-bottom FAB
   ═══════════════════════════════════════════════════════════ */

.scroll-fab {
  position: absolute;
  bottom: 80px;
  right: 20px;
  z-index: 50;
}

.scroll-fab-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: background 0.15s;
}

.scroll-fab-btn:hover {
  background: var(--bg-3);
}

/* ═══════════════════════════════════════════════════════════
   Read receipts (message ack ticks)
   ═══════════════════════════════════════════════════════════ */

.message-ack {
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.message-ack .bi-check2-all.read {
  color: #53bdeb;
}

/* ═══════════════════════════════════════════════════════════
   Load more messages button
   ═══════════════════════════════════════════════════════════ */

.load-more-btn {
  display: block;
  margin: 8px auto;
  padding: 6px 18px;
  border-radius: 18px;
  border: 1px solid var(--bg-4);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.load-more-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
}

/* ═══════════════════════════════════════════════════════════
   Welcome / empty state
   ═══════════════════════════════════════════════════════════ */

.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  gap: 16px;
  padding: 32px;
  text-align: center;
  background: var(--chat-bg);
  border-top: 6px solid #00a884;
}

.welcome-state-icon {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  color: var(--bg-3);
  box-shadow: 0 0 0 12px rgba(0,168,132,0.06);
  margin-bottom: 8px;
}

.welcome-state-title {
  font-size: 26px;
  font-weight: 300;
  color: var(--text-1);
  letter-spacing: -0.3px;
}

.welcome-state-sub {
  font-size: 14px;
  color: var(--text-2);
  max-width: 320px;
  line-height: 1.6;
}

.welcome-state-lock {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  margin-top: 8px;
  opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════
   Toast notifications (brief status messages)
   ═══════════════════════════════════════════════════════════ */

.toast-message {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-3);
  color: var(--text-1);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  z-index: 2147483647;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}

.toast-message.visible {
  transform: translateX(-50%) translateY(0);
}

.toast-message.toast-error {
  background: #c0392b;
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   Main pane needs position relative for FAB
   ═══════════════════════════════════════════════════════════ */

.main-pane {
  position: relative;
}

/* ═══════════════════════════════════════════════════════════
   #mainLayout — needs position relative for qrScreen overlay
   ═══════════════════════════════════════════════════════════ */

#mainLayout {
  position: relative;
  overflow: hidden;
  height: 100%;
}

/* ═══════════════════════════════════════════════════════════
   QR Authentication Screen (WhatsApp Web style)
   ═══════════════════════════════════════════════════════════ */

/* Rail user avatar (replaces logout button) */
.rail-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #00a884;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

/* Account context menu */
.rail-user-menu {
  position: fixed;
  background: var(--bg-2);
  border: 1px solid var(--bg-3);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  min-width: 200px;
  z-index: 9100;
  overflow: hidden;
}

.rail-user-menu-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--bg-4);
}

.rail-user-menu-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}

.rail-user-menu-role {
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.rail-user-menu-divider {
  height: 1px;
  background: var(--bg-4);
}

.rail-user-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.rail-user-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.rail-user-menu-danger {
  color: #ef4444;
}

.rail-user-menu-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Live Events panel */
.live-events-panel {
  position: fixed;
  z-index: 1100;
  width: 540px;
  max-width: calc(100vw - 90px);
  max-height: 75vh;
  background: var(--bg-0);
  border: 1px solid var(--bg-3);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.live-events-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #1d2d35;
  border-bottom: 1px solid var(--bg-3);
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.live-events-filter {
  font-size: 11px;
  background: var(--chat-bg);
  color: #aec3cc;
  border: 1px solid var(--bg-3);
  border-radius: 4px;
  padding: 2px 4px;
  margin-left: auto;
}
.live-events-clear, .live-events-close {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.live-events-clear:hover, .live-events-close:hover { color: var(--text-1); background: rgba(255,255,255,0.07); }
.live-events-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  font-family: monospace;
}
.live-event-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 14px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.live-event-row:hover { background: rgba(255,255,255,0.04); }
.live-event-time { color: var(--text-2); flex-shrink: 0; }
.live-event-name { color: #00a884; flex-shrink: 0; font-weight: 600; }
.live-event-session { color: #53bdeb; flex-shrink: 0; font-size: 10px; }
.live-event-detail { color: #aec3cc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.qr-screen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0; /* sits after the 72px rail, keeping it always visible */
  z-index: 60;
  background: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.qr-screen-content {
  display: flex;
  align-items: center;
  gap: 80px;
  padding: 40px 24px;
}

.qr-screen-left {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 320px;
}

.qr-screen-logo {
  font-size: 56px;
  color: #00a884;
  line-height: 1;
}

.qr-screen-title {
  font-size: 28px;
  font-weight: 300;
  color: var(--text-1);
  line-height: 1.25;
}

.qr-screen-steps {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.9;
  padding-left: 18px;
  margin: 0;
}

.qr-screen-steps li + li {
  margin-top: 2px;
}

.qr-screen-steps strong,
.qr-screen-steps em {
  color: var(--text-1);
  font-style: normal;
}

.qr-screen-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid #00a884;
  color: #00a884;
  border-radius: 24px;
  padding: 8px 20px;
  font-size: 13px;
  cursor: pointer;
  align-self: flex-start;
  margin-top: 4px;
  transition: background 0.15s;
}

.qr-screen-add-btn:hover {
  background: rgba(0, 168, 132, 0.1);
}

.qr-screen-logout-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}
.qr-screen-logout-btn:hover { color: #e53935; }

.qr-screen-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-code-box {
  width: 264px;
  height: 264px;
  background: #ffffff;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  flex-shrink: 0;
}

.qr-code-box.qr-code-box-actionable {
  cursor: pointer;
  border: 1px dashed rgba(0, 168, 132, 0.45);
  box-shadow: 0 0 0 1px rgba(0, 168, 132, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.qr-code-box.qr-code-box-actionable:hover {
  border-color: #00a884;
  box-shadow: 0 14px 28px rgba(0, 168, 132, 0.18);
  transform: translateY(-1px);
}

.qr-code-box.qr-code-box-actionable:focus-visible {
  outline: 2px solid #00a884;
  outline-offset: 4px;
}

.qr-code-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.qr-code-loading {
  color: #54656f;
  font-size: 13px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.qr-code-loading .bi-arrow-clockwise {
  font-size: 24px;
  color: #aaa;
}

.qr-screen-caption {
  font-size: 14px;
  color: var(--text-1);
  font-weight: 400;
}

.qr-screen-caption-sub {
  font-size: 12px;
  color: var(--text-2);
}

/* "Use phone number instead" link on QR screen */
.qr-link-btn {
  background: none;
  border: none;
  color: #00a884;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.qr-link-btn:hover { color: #00cf9d; }

/* Pairing code section */
.pairing-code-section {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.pairing-code-hint {
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  margin: 0;
}
.pairing-code-form {
  display: flex;
  gap: 8px;
  width: 100%;
}
.pairing-phone-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  border-radius: 8px;
  color: var(--text-1);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}
.pairing-phone-input:focus {
  border-color: #00a884;
}
.pairing-get-btn {
  background: #00a884;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.pairing-get-btn:hover { background: #00cf9d; }
.pairing-get-btn:disabled { background: var(--bg-4); color: var(--text-2); cursor: default; }
.pairing-code-display {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.pairing-code-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--text-1);
  background: #1f2c34;
  border-radius: 10px;
  padding: 12px 20px;
  border: 1px solid var(--bg-4);
  font-family: monospace;
}
.pairing-code-steps {
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
  margin: 0;
}
.pairing-code-error {
  color: #ef4444;
  font-size: 13px;
  text-align: center;
}

/* Session switcher button on QR screen */
.qr-session-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.qr-session-switch-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--text-1);
}

/* QR session dropdown */
.qr-session-dropdown {
  position: fixed;
  background: #233138;
  border: 1px solid var(--bg-4);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  min-width: 260px;
  z-index: 500;
  overflow: hidden;
  padding: 4px 0;
}

.qr-session-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s;
}

.qr-session-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.qr-session-dropdown-item.active {
  background: rgba(0, 168, 132, 0.1);
}

.qr-session-dropdown-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-session-dropdown-status {
  font-size: 11px;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  /* QR screen: rail hidden on mobile so cover full width */
  .qr-screen {
    left: 0;
  }

  .qr-screen-content {
    flex-direction: column;
    gap: 28px;
    padding: 24px 16px;
  }

  .qr-screen-left {
    align-items: center;
    text-align: center;
  }

  .qr-screen-steps {
    text-align: left;
  }

  .qr-code-box {
    width: 220px;
    height: 220px;
  }

  .qr-screen-title {
    font-size: 22px;
  }

  .qr-screen-add-btn {
    align-self: center;
  }

}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Attach popup (WhatsApp-style) ─────────────────────────────────────────── */
.attach-popup {
  /* position/coords set by JS to avoid clipping by parent overflow:hidden */
  background: #1f2c34;
  border: 1px solid var(--bg-3);
  border-radius: 14px;
  padding: 12px 10px 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  z-index: 9200;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  width: 304px;
}
.attach-popup-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 8px;
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #d1d7db;
  font-size: 10.5px;
  text-align: center;
  line-height: 1.2;
  transition: background .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 72px;
}
.attach-popup-item:hover { background: rgba(255,255,255,0.07); }
.attach-popup-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: #fff;
  flex-shrink: 0;
}

/* ── Status viewer (WhatsApp-style full-panel) ─────────────────────────────── */
.status-progress-bar {
  display: flex;
  gap: 3px;
  padding: 10px 12px 6px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}
.status-progress-seg {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
  overflow: hidden;
}
.status-progress-seg-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  width: 0%;
  transition: width linear;
}
.status-progress-seg-fill.is-loading {
  width: 100%;
  opacity: 0.45;
  animation: status-progress-loading 1s ease-in-out infinite;
}
@keyframes status-progress-loading {
  0% { opacity: 0.28; }
  50% { opacity: 0.92; }
  100% { opacity: 0.28; }
}
.status-viewer-header {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
}
.status-viewer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.status-viewer-name { font-size: 13px; font-weight: 600; color: #fff; }
.status-viewer-time { font-size: 11px; color: rgba(255,255,255,0.65); }
.status-viewer-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}
.status-viewer-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.status-viewer-content img,
.status-viewer-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.status-viewer-text {
  font-size: 24px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  padding: 20px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  max-width: 480px;
}
.status-viewer-nav {
  position: absolute;
  top: 0;
  bottom: 80px;
  width: 40%;
  z-index: 5;
  cursor: pointer;
}
.status-viewer-nav-prev { left: 0; }
.status-viewer-nav-next { right: 0; }
.status-viewer-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
}
.status-viewer-reply {
  flex: 1;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 8px 14px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.status-viewer-reply::placeholder { color: rgba(255,255,255,0.55); }
.status-viewer-send {
  background: #00a884;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Compact density mode ─────────────────────────────────── */
.density-compact .chat-item { padding: 5px 10px; }
.density-compact .chat-item-content.chat-item-content--with-community {
    gap: 0px;
}
.density-compact .chat-item-content { gap: 6px; }
.density-compact .chat-header-avatar { width: 34px; height: 34px; min-width: 34px; font-size: 14px; }
.density-compact .sidebar-header { padding: 6px 8px; }
.density-compact #chatList { gap: 1px; }
.density-compact .typing-bubble-wrap { padding: 0 16px 5px; }
.density-compact .message-row { margin: 1px 0; }
.density-compact .message-bubble { padding: 5px 8px; }

/* ── Info pane toggle active state ───────────────────────── */
.chat-header-icon.active { color: var(--accent); background: rgba(0,168,132,0.12); }

/* ── Shared utility classes (reduce inline style.cssText repetition) ──── */

/* Small primary action button */
.btn-primary-sm {
  background: #00a884;
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
}
.btn-primary-sm:hover { background: #008f72; }

/* Small danger/delete button */
.btn-danger-sm {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #ef4444;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.btn-danger-sm:hover { background: rgba(220, 38, 38, 0.2); }

/* Small secondary button */
.btn-secondary-sm {
  background: var(--bg-3);
  border: none;
  color: var(--text-1);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 12px;
}
.btn-secondary-sm:hover { background: var(--bg-4); }

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th, .data-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--bg-3);
}
.data-table th { color: var(--text-2); font-weight: 500; }
.data-table td { color: var(--text-1); }
.data-table tr:hover td { background: rgba(255,255,255,0.03); }

/* Form input inside overlays */
.overlay-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  color: var(--text-1);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
}
.overlay-input:focus { border-color: #00a884; }

/* Scrollable log/code block */
.log-block {
  flex: 1;
  overflow: auto;
  padding: 16px;
  margin: 0;
  font-size: 11px;
  color: var(--text-1);
  background: var(--bg-0);
}

/* Sub-overlay backdrop (for nested dialogs at z-index:10000) */
.sub-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 16px;
  box-sizing: border-box;
}

/* Mid-level overlay backdrop (z-index:9300) */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9300;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 16px;
  box-sizing: border-box;
}

/* Wide overlay card (960px max) */
.overlay-card-lg {
  background: var(--bg-2);
  border-radius: 12px;
  width: 960px;
  max-width: 98vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Small neutral button */
.btn-neutral-xs {
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  color: var(--text-1);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.btn-neutral-xs:hover { background: var(--bg-4); }

/* Small select/input (12px, dark bg) */
.input-sm {
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  color: var(--text-1);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}
.input-sm:focus { outline: none; border-color: #00a884; }

/* Compact log entry row */
.log-entry-row {
  font-size: 11px;
  background: #131c21;
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 4px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

/* Inline flex row with gap and label */
.flex-row-sm {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

/* Standard overlay header bar */
.overlay-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--bg-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Flex fill with overflow guard */
.flex-1-min0 { flex: 1; min-width: 0; }

/* Section heading label (uppercase, muted, small) */
.section-label {
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 16px 0 8px;
}

/* Detail row in info panels */
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-3);
}

/* Small muted label above inputs */
.label-sm {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}

/* Inline error text (hidden by default) */
.error-msg {
  color: #ef4444;
  font-size: 12px;
  margin-bottom: 8px;
  display: none;
}

/* Scrollable body with y-overflow */
.scroll-y { flex: 1; overflow-y: auto; }

.contact-inspector {
  padding: 0 0 24px;
}

.contact-inspector-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 18px 10px;
  background: transparent;
  border: none;
  margin-bottom: 8px;
}

.contact-inspector-avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(11,20,26,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.18);
  box-shadow: 0 18px 32px rgba(0,0,0,0.18);
}

.contact-inspector-identity { min-width: 0; text-align: center; }
.contact-inspector-name { font-size: 30px; line-height: 1.05; font-weight: 700; color: #fff; word-break: break-word; }
.contact-inspector-phone { margin-top: 6px; font-size: 15px; color: rgba(255,255,255,0.94); }
.contact-inspector-meta { margin-top: 4px; font-size: 12px; color: rgba(255,255,255,0.82); }

.contact-inspector-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  width: min(100%, 460px);
  margin-top: 14px;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.16);
  box-shadow: 0 10px 22px rgba(0,0,0,0.12);
}

.contact-inspector-action {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 86px;
  padding: 12px 10px;
  border-radius: 0;
  border: none;
  background: rgba(11,20,26,0.18);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.contact-inspector-action.is-accent {
  background: rgba(11,20,26,0.1);
  color: #fff;
}

.contact-inspector-section {
  margin: 0 14px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  box-shadow: 0 14px 28px rgba(0,0,0,0.14);
}

.contact-inspector-section-header { padding: 16px 18px 10px; }
.contact-inspector-section-title { font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.08em; }
.contact-inspector-section-subtitle { margin-top: 6px; font-size: 12px; color: var(--text-2); }

.contact-inspector-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 18px;
}

.contact-inspector-stat {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
}

.contact-inspector-stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.contact-inspector-stat strong {
  display: block;
  font-size: 14px;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-inspector-editor { padding: 0 18px 18px; }

.contact-inspector-field-label,
.contact-inspector-subtitle {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.contact-inspector-editor-row { display: flex; gap: 10px; }

.contact-inspector-input,
.contact-inspector-textarea {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 13px 14px;
  color: var(--text-1);
  font-size: 14px;
  outline: none;
}

.contact-inspector-textarea { resize: vertical; min-height: 88px; }

.contact-inspector-inline-btn {
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--bg-0);
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
}

.contact-inspector-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.04);
  color: var(--text-1);
  text-align: left;
}

.contact-inspector-row i { font-size: 17px; width: 20px; color: var(--accent); flex-shrink: 0; text-align: center; }
.contact-inspector-row-text { min-width: 0; flex: 1; }
.contact-inspector-row-primary { font-size: 14px; color: var(--text-1); word-break: break-word; }
.contact-inspector-row-secondary { margin-top: 3px; font-size: 11px; color: var(--text-2); }

.contact-inspector-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.contact-inspector-chip-input {
  width: 100%;
  border: 1px dashed var(--bg-4);
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  padding: 10px 12px;
  outline: none;
  box-sizing: border-box;
}

.contact-inspector-subsection { padding: 0 18px 18px; }
.contact-inspector-placeholder { font-size: 12px; color: var(--text-2); padding: 2px 0 4px; }

.contact-inspector-list-item,
.contact-inspector-message,
.contact-inspector-footer-link {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
}

.contact-inspector-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
}

.contact-inspector-list-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-inspector-list-meta { margin-top: 2px; font-size: 11px; color: var(--text-2); }

.contact-inspector-message {
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.contact-inspector-message-top { display: flex; justify-content: space-between; gap: 10px; }
.contact-inspector-message-preview { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-inspector-message-time { flex-shrink: 0; font-size: 10px; color: var(--text-2); }

.contact-inspector-footer-link {
  margin-top: 6px;
  padding: 10px 0 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 720px) {
  .contact-inspector {
    padding-bottom: 20px;
  }
  .contact-inspector-hero {
    padding: 18px 12px 8px;
  }
  .contact-inspector-avatar {
    width: 92px;
    height: 92px;
    font-size: 30px;
  }
  .contact-inspector-name {
    font-size: 24px;
  }
  .contact-inspector-actions {
    width: 100%;
  }
  .contact-inspector-section {
    margin-left: 10px;
    margin-right: 10px;
  }
  .contact-inspector-grid { grid-template-columns: 1fr; }
  .contact-inspector-editor-row { flex-direction: column; }
  .contact-inspector-inline-btn { padding: 10px 14px; }
}

/* Full-width primary action button */
.btn-primary-full {
  width: 100%;
  background: #00a884;
  border: none;
  color: var(--bg-0);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary-full:hover { background: #06cf9c; }

/* ── Global scrollbar theming ─────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

/* ── Light mode specific adjustments ─────────────────────── */
[data-theme="light"] body { background: var(--bg-0); color: var(--text-1); }
[data-theme="light"] .app-loading-screen { background: var(--bg-deep); }
[data-theme="light"] .auth-container { background: var(--bg-deep); }
[data-theme="light"] .auth-card { background: var(--bg-2); border-color: var(--bg-4); }
[data-theme="light"] .ctx-menu { background: var(--bg-2); border-color: var(--bg-4); }
[data-theme="light"] .ctx-menu-item:hover { background: var(--hover-overlay); }
[data-theme="light"] .overlay-card { background: var(--bg-2); }
[data-theme="light"] .overlay-header { background: var(--bg-2); border-color: var(--bg-4); }
[data-theme="light"] .sidebar { background: var(--bg-1); border-color: var(--bg-4); }
[data-theme="light"] .sidebar-header { background: var(--bg-2); }
[data-theme="light"] .chat-item:hover { background: var(--hover-overlay); }
[data-theme="light"] .chat-item.active { background: var(--bg-3); }
[data-theme="light"] .search-bar input { background: var(--bg-3); color: var(--text-1); border-color: var(--bg-4); }
[data-theme="light"] .chat-header { background: var(--bg-2); border-color: var(--bg-4); }
[data-theme="light"] .compose-area { background: var(--bg-2); border-color: var(--bg-4); }
[data-theme="light"] .message-input { background: var(--bg-3); color: var(--text-1); }
[data-theme="light"] .tab-bar { border-color: var(--bg-4); }
[data-theme="light"] input, [data-theme="light"] textarea, [data-theme="light"] select {
  background: var(--bg-3);
  color: var(--text-1);
  border-color: var(--bg-4);
}
[data-theme="light"] .btn-ghost { color: var(--text-2); }
[data-theme="light"] .btn-ghost:hover:not(:disabled) { color: var(--text-1); background: var(--hover-overlay); }
[data-theme="light"] .section-label { color: var(--text-2); border-color: var(--bg-4); }

/* ── Light theme: fix hardcoded dark backgrounds ─────────────────────────── */
[data-theme="light"] .overlay-card { background: var(--bg-1); }
[data-theme="light"] .overlay-header { background: var(--bg-2); }
[data-theme="light"] .msg-reaction-pill { background: var(--bg-3); }
[data-theme="light"] .info-media-cell { background: var(--bg-3); }
[data-theme="light"] .info-link-item:hover { background: var(--hover-overlay); }
[data-theme="light"] .session-picker-popup { background: var(--bg-1); box-shadow: 0 12px 32px rgba(0,0,0,0.15); }
[data-theme="light"] .rail-user-menu { background: var(--bg-1); box-shadow: 0 10px 28px rgba(0,0,0,0.15); }
[data-theme="light"] .attach-popup { background: var(--bg-1); }
[data-theme="light"] .pairing-code-value { background: var(--bg-3); }
[data-theme="light"] .log-entry-row { background: var(--bg-3); }
[data-theme="light"] .live-events-header { background: var(--bg-2); }
[data-theme="light"] .group-settings-tab-body { background: var(--bg-1); }
[data-theme="light"] .msg-skel-bubble { background: var(--bg-3); }
[data-theme="light"] .data-table thead tr { background: var(--bg-2) !important; }
[data-theme="light"] .data-table tbody tr:hover { background: var(--hover-overlay) !important; }
[data-theme="light"] .info-pane { background: var(--bg-1); }
[data-theme="light"] .info-pane-header { background: var(--bg-2); }
[data-theme="light"] .info-pane-body { background: var(--bg-1); }
[data-theme="light"] .chat-item { color: var(--text-1); }
[data-theme="light"] .sidebar-search-wrap { background: var(--bg-2); }
[data-theme="light"] .message-input-row { background: var(--bg-2); }
[data-theme="light"] .message-input-bar { background: var(--bg-2); }
[data-theme="light"] .msg-bubble.out { background: var(--bubble-out); color: var(--bubble-out-txt); }
[data-theme="light"] .msg-bubble.in { background: var(--bubble-in); color: var(--bubble-in-txt); }
[data-theme="light"] .msg-meta { color: var(--bubble-out-meta); }
[data-theme="light"] .typing-bubble { background: var(--bg-1); }
[data-theme="light"] .rail-user-menu-item:hover { background: var(--hover-overlay); }
[data-theme="light"] .session-picker-item:hover { background: var(--hover-overlay); }

/* ── Light theme: hardcoded #1f2c34 elements ─────────────────────────────── */
[data-theme="light"] .msg-reaction-pill { background: var(--bg-3); border-color: var(--bg-4); }
[data-theme="light"] .overlay-card { background: var(--bg-1); border-color: var(--bg-4); }
[data-theme="light"] .pairing-code-value { background: var(--bg-3); border-color: var(--bg-4); }
[data-theme="light"] .attach-popup { background: var(--bg-1); border-color: var(--bg-4); }

/* ── Light theme: hero/header sections that use hardcoded #0b141a ──────────── */
[data-theme="light"] .contact-detail-hero,
[data-theme="light"] .group-hero { background: var(--bg-2) !important; }

/* ── Light theme: data-table and analytics rows ──────────────────────────── */
[data-theme="light"] .log-entry-row { background: var(--bg-3); border-color: var(--bg-4); }
[data-theme="light"] .webhook-log-row { background: var(--bg-3); border-color: var(--bg-4); }

/* ── Light theme: inline hover fix for dark hover-bg in JS panels ──────────── */
[data-theme="light"] .info-pane-section-row:hover { background: var(--hover-overlay) !important; }
[data-theme="light"] .group-member-row:hover { background: var(--hover-overlay) !important; }

/* ── Light theme: app-rail icon active/hover fix ─────────────────────────── */
[data-theme="light"] .app-rail-icon { color: var(--text-2); }
[data-theme="light"] .app-rail-icon.active,
[data-theme="light"] .app-rail-icon:hover { background: var(--hover-overlay); color: var(--text-1); }
[data-theme="light"] .app-rail { background: var(--bg-2); border-color: var(--bg-4); }

/* ── Light theme: QR screen / pairing overlay ────────────────────────────── */
[data-theme="light"] #qrScreen { background: var(--bg-0); }
[data-theme="light"] .qr-card { background: var(--bg-1); border-color: var(--bg-4); }

/* ── Light theme: message list background ────────────────────────────────── */
[data-theme="light"] #messageList { background: var(--chat-bg); }

/* ── Light theme: chat skeleton ──────────────────────────────────────────── */
[data-theme="light"] .chat-skel-item { background: transparent; }
[data-theme="light"] .chat-skel-avatar,
[data-theme="light"] .chat-skel-line { background: var(--bg-3); }

/* ── Light theme: tab pills (filter bar) ─────────────────────────────────── */
[data-theme="light"] .tab-pill { background: transparent; color: var(--text-2); }
[data-theme="light"] .tab-pill.active { background: var(--bg-3); color: var(--text-1); }

/* WhatsApp alignment overrides */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
}

.chat-header-default {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chat-header-title,
.chat-header-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header-title {
  line-height: 1.2;
}

.chat-header-sub {
  line-height: 1.2;
}

.chat-header-avatar,
.chat-header-avatar img,
.mobile-dock-avatar,
.mobile-dock-avatar img,
.info-pane-avatar {
  border-radius: 999px !important;
}

.chat-selection-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chat-selection-count {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-selection-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.message-compose-notice {
  display: none;
  padding: 10px 16px 6px;
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
  background: var(--bg-2);
}

.message-compose-notice.is-warning {
  color: #f59e0b;
}

.mobile-bottom-dock.mobile-dock-hidden {
  display: none !important;
}

.sidebar-tabs {
  overflow-x: auto;
  scrollbar-width: none;
}

.sidebar-tabs::-webkit-scrollbar {
  display: none;
}

@media (max-width: 767px) {
  .chat-header {
    gap: 6px;
    min-height: 48px;
    padding: 6px 8px;
  }

  .chat-header-default {
    gap: 2px;
  }

  .chat-header-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 13px;
  }

  .chat-header-title {
    font-size: 13px;
  }

  .chat-header-sub {
    font-size: 11px;
  }

  .chat-header-actions {
    gap: 2px;
  }

  .chat-header-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .sidebar-header {
    padding: 8px 10px;
  }

  .sidebar-search-wrap {
    padding: 8px 10px 6px;
  }

  .sidebar-tabs {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .sidebar-tab {
    padding: 6px 10px;
    font-size: 11px;
  }

  .sidebar-tab-count {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
  }

  .message-input-row {
    padding-bottom: 2px;
  }

  #btnChatMenu {
    width: 38px;
    height: 38px;
    border-radius: 19px;
  }

  #btnChatMenu i {
    font-size: 20px;
  }

  .message-input-bar {
    padding: 6px 8px;
    gap: 6px;
  }

  .message-input {
    min-height: 38px;
  }

  .info-pane-header {
    padding: 18px 16px 14px;
  }
}
