/* ================================================================
   Blitz1v1 — Unified Chat System Styles
   Dark-first, uses --th-* variables, light theme overrides.
   ================================================================ */

/* ── Chat header button (nav) ──────────────────────────────────── */

/* Ensure the quick-nav-account is a flex row so inserted buttons align */
.quick-nav-account {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
}

/* Match the notification bell exactly */
.quick-nav-chat-btn,
.bz-chat-header-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--th-muted);
  flex-shrink: 0;
  transition: all 0.2s ease;
  padding: 0;
}

.quick-nav-chat-btn:hover,
.bz-chat-header-btn:hover {
  color: var(--th-text);
  transform: translateY(-1px);
}

.quick-nav-chat-btn .notif-icon,
.bz-chat-header-btn .notif-icon {
  width: 18px;
  height: 18px;
  display: block;
}

/* Unread count badge — same as .notif-dot from notifications.css */
.quick-nav-chat-btn .notif-dot,
.bz-chat-header-btn .notif-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  height: 18px;
  min-width: 18px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--th-nav-panel, var(--th-bg));
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
  z-index: 10;
}

.bz-chat-header-btn {
  position: relative;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--th-border);
  background: var(--th-input-bg);
  color: var(--th-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0 !important;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
  margin-right: 2px;
  box-sizing: border-box;
  line-height: 1;
  font-size: 0;
  vertical-align: middle;
}

.bz-chat-header-btn:hover {
  background: rgba(16, 185, 129, 0.12) !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
  color: #10b981 !important;
  transform: scale(1.05);
}

.bz-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--th-bg);
  animation: bz-badge-pulse 2s infinite;
  line-height: 1;
}

@keyframes bz-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ── Modal backdrop & container ───────────────────────────────── */
.bz-chat-modal {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.bz-chat-modal.open {
  opacity: 1;
  pointer-events: all;
}

.bz-chat-backdrop {
  position: absolute;
  inset: 0;
  background: var(--th-overlay, rgba(0,0,0,0.6));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.bz-chat-container {
  position: relative;
  display: flex;
  width: min(920px, 95vw);
  height: min(680px, 88vh);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--th-border);
  background: var(--th-bg2);
  box-shadow: 0 40px 120px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05) inset;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.bz-chat-modal.open .bz-chat-container {
  transform: translateY(0) scale(1);
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.bz-chat-sidebar {
  width: 300px;
  min-width: 200px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  background: #0d1117;
  flex-shrink: 0;
  overflow: hidden;
}

/* ── Resize handle ────────────────────────────────────────────── */
.bz-chat-resize-handle {
  width: 9px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 10;
  transition: background 0.15s ease;
  user-select: none;
  touch-action: none;
}

.bz-chat-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1px;
  height: 40px;
  background: var(--th-border);
  border-radius: 2px;
  transition: background 0.15s ease, height 0.15s ease;
}

.bz-chat-resize-handle:hover,
.bz-chat-resize-handle.dragging,
.bz-chat-resize-handle:focus-visible {
  background: rgba(16,185,129,0.06);
  outline: none;
}

.bz-chat-resize-handle:hover::after,
.bz-chat-resize-handle.dragging::after,
.bz-chat-resize-handle:focus-visible::after {
  background: #10b981;
  height: 60px;
}

.bz-chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--th-border);
  box-sizing: border-box;
}

.bz-chat-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--th-text);
  margin: 0;
  background: none;
  -webkit-text-fill-color: currentColor;
}

.bz-chat-close {
  position: absolute;
  top: 17px;
  right: 17px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--th-border);
  background: var(--th-input-bg);
  color: var(--th-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.bz-chat-close svg {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
  stroke: var(--th-muted) !important;
  transition: stroke 0.2s ease, transform 0.2s ease;
}

.bz-chat-close:hover {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.3);
  color: #ef4444;
}

.bz-chat-close:hover svg {
  stroke: #ef4444 !important;
  transform: scale(1.1);
}

.bz-chat-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--th-border);
}

.bz-chat-search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--th-border);
  background: var(--th-input-bg);
  color: var(--th-text);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.bz-chat-search:focus {
  border-color: rgba(16,185,129,0.5);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.08);
}

.bz-chat-search::placeholder { color: var(--th-muted2); }

.bz-chat-conv-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--th-scrollbar) transparent;
  padding: 4px 0;
}

/* Conversation items */
.bz-chat-conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-radius: 0;
}

.bz-chat-conv-item:hover {
  background: rgba(255,255,255,0.04);
}

.bz-chat-conv-item.active {
  background: rgba(16,185,129,0.10);
  border-left: 3px solid #10b981;
}

.bz-chat-conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.bz-chat-conv-info {
  flex: 1;
  min-width: 0;
}

.bz-chat-conv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 3px;
}

.bz-chat-conv-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--th-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bz-chat-conv-time {
  font-size: 0.72rem;
  color: var(--th-muted2);
  white-space: nowrap;
  flex-shrink: 0;
}

.bz-chat-conv-bottom {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bz-chat-conv-preview {
  font-size: 0.78rem;
  color: var(--th-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.bz-chat-unread-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #10b981;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  flex-shrink: 0;
}

/* Empty state */
.bz-chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 6px;
}

.bz-chat-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  opacity: 0.6;
}

.bz-chat-empty-state p {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--th-text);
  margin: 0;
}

.bz-chat-empty-state span {
  font-size: 0.78rem;
  color: var(--th-muted2);
}

/* ── Chat window ──────────────────────────────────────────────── */
.bz-chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--th-bg);
}

.bz-chat-window-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 40px;
}

.bz-chat-placeholder-icon {
  font-size: 3rem;
  opacity: 0.4;
  margin-bottom: 8px;
}

.bz-chat-window-placeholder h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--th-text);
  margin: 0;
  opacity: 0.8;
}

.bz-chat-window-placeholder p {
  font-size: 0.82rem;
  color: var(--th-muted2);
  margin: 0;
  max-width: 240px;
}

/* Active chat pane */
.bz-chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.bz-chat-window-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 12px 64px 12px 16px;
  border-bottom: 1px solid var(--th-border);
  background: var(--th-bg2, #0d1117);
  flex-shrink: 0;
  box-sizing: border-box;
}

.bz-chat-back,
.bz-chat-mobile-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--th-border);
  background: var(--th-input-bg);
  color: var(--th-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.bz-chat-mobile-back {
  display: none;
}

.bz-chat-back svg,
.bz-chat-mobile-back svg {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
  stroke: var(--th-muted) !important;
  transition: stroke 0.2s ease, transform 0.2s ease;
}

.bz-chat-container.bz-sidebar-collapsed .bz-chat-sidebar {
  display: none;
}

.bz-chat-container.bz-sidebar-collapsed .bz-chat-resize-handle {
  display: none;
}

body.bz-chat-resizing,
body.bz-chat-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.bz-chat-container.bz-sidebar-collapsed .bz-chat-mobile-back {
  display: inline-flex;
}

.bz-chat-container.bz-sidebar-collapsed .bz-chat-mobile-back svg {
  transform: rotate(180deg) !important;
}

.bz-chat-back:hover,
.bz-chat-mobile-back:hover {
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.3);
  color: #10b981;
}

.bz-chat-back:hover svg,
.bz-chat-mobile-back:hover svg {
  stroke: #10b981 !important;
}

.bz-chat-peer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  color: #fff;
  flex-shrink: 0;
}

.bz-chat-peer-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bz-chat-peer-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.bz-chat-peer-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--th-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.bz-chat-peer-status {
  font-size: 0.75rem;
  color: #10b981;
}

.bz-chat-peer-status.typing {
  font-style: italic;
}

.bz-chat-peer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--th-border);
  background: var(--th-input-bg);
  color: var(--th-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.bz-chat-peer-link:hover {
  background: rgba(16,185,129,0.1);
  border-color: rgba(16,185,129,0.3);
  color: #10b981;
}

/* ── Messages area ────────────────────────────────────────────── */
.bz-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--th-scrollbar) transparent;
}

.bz-load-more {
  align-self: center;
  padding: 6px 16px;
  margin-bottom: 12px;
  border-radius: 20px;
  border: 1px solid var(--th-border);
  background: var(--th-input-bg);
  color: var(--th-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bz-load-more:hover {
  background: var(--th-card);
  color: var(--th-text);
  border-color: rgba(16,185,129,0.3);
}

/* Date divider */
.bz-chat-date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 6px;
}

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

.bz-chat-date-divider span {
  font-size: 0.72rem;
  color: var(--th-muted2);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Context badges */
.bz-chat-ctx-badge {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  margin: 8px 0 4px;
  border: 1px solid transparent;
  cursor: help;
}

.bz-chat-ctx-badge.challenge {
  background: rgba(168,85,247,0.12);
  border-color: rgba(168,85,247,0.25);
  color: #c084fc;
}

.bz-chat-ctx-badge.live_pairing {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.25);
  color: #60a5fa;
}

.bz-chat-ctx-badge.direct {
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.25);
  color: #34d399;
}

.bz-chat-active-banner.context {
  cursor: help;
}

/* ── Message bubbles ──────────────────────────────────────────── */
.bz-chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  width: fit-content;
  min-width: 0;
  position: relative;
}

@keyframes bz-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bz-chat-bubble.outgoing {
  align-self: flex-end;
  align-items: flex-end;
}

.bz-chat-bubble.incoming {
  align-self: flex-start;
  align-items: flex-start;
}

.bz-bubble-content {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  min-width: 0;
  max-width: 100%;
}

.bz-chat-bubble.outgoing .bz-bubble-content {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.bz-chat-bubble.incoming .bz-bubble-content {
  /* Use solid opaque color — semi-transparent forces GPU recomposition on every render */
  background: #161b22;
  color: var(--th-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--th-border);
}

.bz-chat-bubble.pending .bz-bubble-content {
  opacity: 0.7;
}

.bz-chat-bubble.is-deleted .bz-bubble-content {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  box-shadow: none;
  font-style: italic;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(148, 163, 184, 0.7);
}

.bz-chat-bubble.is-deleted.outgoing .bz-bubble-content,
.bz-chat-bubble.is-deleted.incoming .bz-bubble-content {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
}

.bz-msg-deleted-label {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.bz-bubble-deleted-meta {
  font-size: 0.68rem;
  color: var(--th-muted2);
  font-style: italic;
  padding-left: 2px;
}

.bz-bubble-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  margin-top: 2px;
}

.bz-bubble-time {
  font-size: 0.68rem;
  color: var(--th-muted2);
}

.bz-bubble-status {
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  margin-left: 4px;
}

/* ── WhatsApp-style tick states ───────────────────────────────── */
.bz-tick {
  font-style: normal;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.bz-tick.pending {
  font-size: 0.65rem;
  opacity: 0.7;
}

.bz-tick.sent {
  color: rgba(255, 255, 255, 0.45);
}

.bz-tick.delivered {
  color: rgba(255, 255, 255, 0.65);
}

.bz-tick.read {
  color: #34b7f1; /* WhatsApp blue */
}

[data-theme="light"] .bz-chat-bubble.outgoing .bz-tick.sent {
  color: rgba(15, 23, 42, 0.55);
}

[data-theme="light"] .bz-chat-bubble.outgoing .bz-tick.delivered {
  color: rgba(15, 23, 42, 0.78);
}

[data-theme="light"] .bz-chat-bubble.outgoing .bz-tick.read {
  color: #0284c7;
}

/* ── Input bar ────────────────────────────────────────────────── */
.bz-chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--th-border);
  background: var(--th-bg2, #0d1117);
  /* No backdrop-filter here — it forces GPU recomposition on every keystroke */
  flex-shrink: 0;
}

.bz-chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--th-border);
  background: #12171f;
  color: var(--th-text);
  font-size: 0.875rem;
  resize: none;
  outline: none;
  height: 40px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  font-family: inherit;
}

.bz-chat-input:focus {
  border-color: rgba(16,185,129,0.5);
  box-shadow: 0 0 0 2px rgba(16,185,129,0.06);
}

.bz-chat-input::placeholder { color: var(--th-muted2); }

.bz-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(16,185,129,0.35);
}

.bz-chat-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(16,185,129,0.5);
}

.bz-chat-send:active {
  transform: scale(0.95);
}

/* ── Profile "Message" button ─────────────────────────────────── */
.profile-msg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(16,185,129,0.35);
  background: rgba(16,185,129,0.10);
  color: #10b981;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-msg-btn:hover {
  background: rgba(16,185,129,0.20);
  border-color: rgba(16,185,129,0.55);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16,185,129,0.2);
}

/* ── Embedded chat (inside challenge/FRO) ─────────────────────── */
.bz-chat-embedded {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 200px;
  border-radius: 14px;
  border: 1px solid var(--th-border);
  background: var(--th-bg2);
  overflow: hidden;
}

.bz-chat-embedded-msgs {
  flex: 1;
  min-height: 120px;
  padding: 10px 12px 6px;
}

/* ── Mobile responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
  .bz-chat-container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
    max-height: 100vh;
  }

  .bz-chat-sidebar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    position: absolute;
    inset: 0;
    z-index: 1;
  }

  .bz-chat-resize-handle {
    display: none;
  }

  .bz-chat-window {
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 2;
  }

  .bz-chat-mobile-back {
    display: inline-flex;
  }

  .bz-chat-sidebar-header .bz-chat-back {
    display: none;
  }

  .bz-chat-modal.chat-mobile-window .bz-chat-sidebar {
    transform: translateX(-100%);
  }

  .bz-chat-modal.chat-mobile-window .bz-chat-window {
    transform: translateX(0);
  }



  .bz-chat-bubble {
    max-width: 85%;
  }
}

/* ── Light theme overrides ────────────────────────────────────── */
[data-theme="light"] .bz-chat-container {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
}

[data-theme="light"] .bz-chat-sidebar {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .bz-chat-window {
  background: #ffffff;
}

[data-theme="light"] .bz-chat-title {
  background: none;
  color: #0f172a;
  -webkit-text-fill-color: currentColor;
}

[data-theme="light"] .bz-chat-conv-item:hover {
  background: rgba(0,0,0,0.03);
}

[data-theme="light"] .bz-chat-conv-item.active {
  background: rgba(16,185,129,0.08);
}

[data-theme="light"] .bz-chat-search {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #0f172a;
}

[data-theme="light"] .bz-chat-search:focus {
  border-color: rgba(16,185,129,0.5);
}

[data-theme="light"] .bz-chat-window-header {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .bz-chat-input-bar {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .bz-chat-input {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #0f172a;
}

[data-theme="light"] .bz-chat-input:focus {
  border-color: rgba(16,185,129,0.5);
  box-shadow: 0 0 0 2px rgba(16,185,129,0.05);
}

[data-theme="light"] .bz-chat-bubble.incoming .bz-bubble-content {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #e2e8f0;
}

[data-theme="light"] .bz-chat-peer-link {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .bz-chat-close {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

[data-theme="light"] .bz-chat-close svg {
  stroke: #64748b !important;
}

[data-theme="light"] .bz-chat-close:hover svg {
  stroke: #ef4444 !important;
}

[data-theme="light"] .bz-chat-back,
[data-theme="light"] .bz-chat-mobile-back {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

[data-theme="light"] .bz-chat-back svg,
[data-theme="light"] .bz-chat-mobile-back svg {
  stroke: #64748b !important;
}

[data-theme="light"] .bz-chat-back:hover svg,
[data-theme="light"] .bz-chat-mobile-back:hover svg {
  stroke: #10b981 !important;
}

[data-theme="light"] .bz-chat-badge {
  border-color: #ffffff;
}

[data-theme="light"] .bz-chat-backdrop {
  background: rgba(0,0,0,0.35);
}

[data-theme="light"] .bz-chat-header-btn {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #64748b !important;
}

[data-theme="light"] .bz-chat-header-btn:hover {
  background: rgba(16,185,129,0.08) !important;
  border-color: rgba(16,185,129,0.35) !important;
  color: #10b981 !important;
}

[data-theme="light"] .profile-msg-btn {
  background: rgba(16,185,129,0.08);
  border-color: rgba(16,185,129,0.3);
}

[data-theme="light"] .bz-chat-embedded {
  background: #ffffff;
  border-color: #e2e8f0;
}

/* ── Hover Actions Menu (Glassmorphism) ────────────────────────── */
.bz-chat-bubble-container {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.bz-chat-bubble-container.outgoing {
  align-items: flex-end;
}

.bz-chat-bubble-container.incoming {
  align-items: flex-start;
}

.bz-msg-actions {
  position: absolute;
  top: -16px;
  display: flex;
  align-items: center;
  gap: 4px;
  /* Solid background — no backdrop-filter to avoid compositing during hover */
  background: #1e2530;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 20px;
  padding: 3px 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px) scale(0.95);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.bz-chat-bubble:hover .bz-msg-actions {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

.bz-chat-bubble.outgoing .bz-msg-actions {
  right: 12px;
}

.bz-chat-bubble.incoming .bz-msg-actions {
  left: 12px;
}

.bz-msg-action-btn {
  background: none;
  border: none;
  color: var(--th-muted);
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.bz-msg-action-btn:hover {
  color: var(--th-text);
  background: rgba(255, 255, 255, 0.08);
}

.bz-msg-action-btn.delete:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
}

.bz-msg-action-btn.report:hover {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
}

/* Light theme overrides for hover actions */
[data-theme="light"] .bz-msg-actions {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .bz-msg-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* ── Reply Quote Block (Inside Bubble) ─────────────────────────── */
.bz-msg-reply-quote {
  display: block;
  width: min(100%, 32rem);
  align-self: stretch;
  font-size: 0.72rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16,185,129,0.16);
  padding: 3px 7px;
  border-radius: 6px;
  margin: 0 0 2px 0;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.bz-msg-reply-quote:hover {
  background: rgba(16, 185, 129, 0.18);
  transform: translateY(-1px);
}

.bz-chat-bubble.incoming .bz-bubble-content .bz-msg-reply-quote,
.bz-chat-bubble.outgoing .bz-bubble-content .bz-msg-reply-quote {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16,185,129,0.16);
}

[data-theme="light"] .bz-chat-bubble.outgoing .bz-bubble-content .bz-msg-reply-quote,
[data-theme="light"] .bz-chat-bubble.incoming .bz-bubble-content .bz-msg-reply-quote {
  background: rgba(16,185,129,0.10);
  border-color: rgba(16,185,129,0.14);
}

.bz-reply-quote-sender {
  font-weight: 700;
  margin-bottom: 1px;
  display: block;
  color: #ffffff; /* ensure contrast on green */
  font-size: 0.74rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bz-reply-quote-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.95;
  font-size: 0.7rem;
  line-height: 1.1;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
}

/* ── Active State Banner (Above Input Bar) — WhatsApp style ──── */
.bz-chat-active-banner {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--th-bg2, rgba(13,17,23,0.95));
  border-top: 1px solid var(--th-border);
  animation: bz-banner-slide-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  overflow: hidden;
  min-height: 44px;
}

@keyframes bz-banner-slide-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ── The green left accent stripe ── */
.bz-chat-active-banner::before {
  content: '';
  display: block;
  width: 4px;
  flex-shrink: 0;
  background: #10b981;
  border-radius: 0;
}

.bz-chat-active-banner.edit::before {
  background: #f59e0b;
}

/* ── Inner wrapper: icon + text + close ── */
.bz-chat-banner-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
}

/* Reply/edit icon */
.bz-chat-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #10b981;
  opacity: 0.85;
}

.bz-chat-active-banner.edit .bz-chat-banner-icon {
  color: #f59e0b;
}

/* Text block */
.bz-chat-banner-content {
  flex: 1;
  min-width: 0;
}

.bz-chat-banner-title {
  font-weight: 700;
  font-size: 0.73rem;
  color: #10b981;
  margin-bottom: 1px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bz-chat-active-banner.edit .bz-chat-banner-title {
  color: #f59e0b;
}

.bz-chat-banner-body {
  font-size: 0.74rem;
  color: var(--th-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

/* Cancel button */
.bz-chat-banner-close {
  flex-shrink: 0;
  align-self: center;
  margin-right: 10px;
  background: none;
  border: none;
  color: var(--th-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.bz-chat-banner-close:hover {
  background: rgba(255, 255, 255, 0.10);
  color: var(--th-text);
}

/* Light theme */
[data-theme="light"] .bz-chat-active-banner {
  background: rgba(241, 245, 249, 0.98);
  border-top-color: #e2e8f0;
}

[data-theme="light"] .bz-chat-banner-body {
  color: #64748b;
}

[data-theme="light"] .bz-chat-banner-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}

/* ── Context badge inside message bubbles ─────────────────────── */
.bz-bubble-context-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  display: inline-block;
  vertical-align: middle;
}

.bz-bubble-context-badge.challenge {
  background: rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
}

.bz-bubble-context-badge.live_pairing {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

[data-theme="light"] .bz-bubble-context-badge.challenge {
  background: rgba(168, 85, 247, 0.15);
  color: #7c3aed;
}

[data-theme="light"] .bz-bubble-context-badge.live_pairing {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

/* Edit indicator */
.bz-msg-edited-tag {
  font-size: 0.65rem;
  color: var(--th-muted2);
  margin-left: 4px;
  font-style: italic;
}
