/* Privacy Shield Overlay */
.privacy-shield {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  padding: 20px;
}

.privacy-shield-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  margin-bottom: 20px;
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.3);
}

.privacy-shield h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.privacy-shield p {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 380px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Semi-transparent anti-leak watermark */
.chat-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.035;
  background-repeat: repeat;
  background-size: 260px 140px;
}

/* File Message Bubble */
.file-bubble-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  min-width: 220px;
  max-width: 340px;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.file-bubble-card:hover {
  background: rgba(255, 255, 255, 0.12);
}

.file-bubble-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.file-bubble-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.file-bubble-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.file-download-btn {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
}

.file-download-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

/* Quoted Reply UI */
.quote-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(59, 130, 246, 0.15);
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #93c5fd;
  margin-bottom: 8px;
}

.quote-preview-bar span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-cancel-quote {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.btn-cancel-quote:hover {
  color: #fff;
}

.msg-quote-block {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid rgba(255, 255, 255, 0.5);
  padding: 5px 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
}

.msg-quote-block:hover {
  background: rgba(0, 0, 0, 0.35);
}

/* Typing indicator in header */
.typing-status-text {
  font-size: 12px;
  color: #38bdf8;
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #38bdf8;
  animation: typingBlink 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBlink {
  0% { opacity: 0.2; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
  100% { opacity: 0.2; transform: translateY(0); }
}

/* Emoji Popover Drawer */
.emoji-popover {
  position: absolute;
  bottom: 80px;
  left: 20px;
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 100;
  max-width: 320px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.emoji-item {
  font-size: 20px;
  padding: 4px;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  transition: transform 0.1s ease, background 0.1s ease;
  user-select: none;
}

.emoji-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.2);
}

/* Message Hover Actions (Recall, Reply, React) */
.msg-row {
  position: relative;
}

.msg-hover-actions {
  display: none;
  position: absolute;
  top: -14px;
  right: 12px;
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px 4px;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.msg-row.me .msg-hover-actions {
  right: auto;
  left: 12px;
}

.msg-row:hover .msg-hover-actions {
  display: flex;
}

.msg-act-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 6px;
  font-size: 12px;
  border-radius: 4px;
  transition: var(--transition);
}

.msg-act-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Audio Playback Speed Badge */
.voice-speed-badge {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 6px;
}

.voice-speed-badge:hover {
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
}

/* Message Reactions */
.msg-reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-main);
  cursor: pointer;
}

.reaction-tag.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
}

/* Recalled message bubble */
.msg-bubble.recalled {
  background: rgba(255, 255, 255, 0.04) !important;
  color: var(--text-dim) !important;
  font-style: italic;
  font-size: 13px;
  border: 1px dashed var(--border-color) !important;
}

/* Remember Password Checkbox Row on Auth Screen */
.form-checkbox-row {
  display: flex;
  align-items: center;
  margin-top: -6px;
  margin-bottom: 18px;
  user-select: none;
}

.remember-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.remember-checkbox-label:hover {
  color: #fff;
}

.remember-checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
  border-radius: 4px;
}

.remember-checkbox-label .checkbox-text {
  font-size: 13px;
  color: #94a3b8;
}

.remember-checkbox-label input[type="checkbox"]:checked ~ .checkbox-text {
  color: #e2e8f0;
}

/* ==========================================
   Markdown & Code Block Styling
   ========================================== */
.msg-content-body {
  word-break: break-word;
  line-height: 1.6;
}

/* Inline Code: `code` */
.inline-code {
  font-family: Consolas, Menlo, Monaco, "Courier New", monospace;
  background: rgba(255, 255, 255, 0.14);
  color: #f472b6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.msg-row.me .inline-code {
  background: rgba(0, 0, 0, 0.28);
  color: #fed7aa;
  border-color: rgba(255, 255, 255, 0.15);
}

/* Blockquote: > quote */
.msg-quote {
  margin: 6px 0;
  padding: 8px 14px;
  border-left: 3px solid #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  border-radius: 0 6px 6px 0;
  color: rgba(248, 250, 252, 0.92);
  font-style: normal;
}
.msg-row.me .msg-quote {
  border-left-color: #93c5fd;
  background: rgba(0, 0, 0, 0.22);
  color: #e0f2fe;
}

/* Safe External Link Detection */
.msg-link {
  color: #38bdf8;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  transition: color 0.15s ease;
}
.msg-link:hover {
  color: #7dd3fc;
}
.msg-row.me .msg-link {
  color: #bae6fd;
}
.msg-row.me .msg-link:hover {
  color: #f0f9ff;
}

/* Multi-line Code Block Frame */
.code-block-frame {
  margin: 8px 0;
  border-radius: 8px;
  background: #0b1120;
  border: 1px solid #334155;
  overflow: hidden;
  font-family: Consolas, Menlo, Monaco, "Courier New", monospace;
  max-width: 100%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* Code Block Header */
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: #162032;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
}

.code-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-mac-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mac-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }

.code-lang-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-left: 4px;
}

/* 1-Click Copy Button */
.btn-copy-code {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-copy-code:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}
.btn-copy-code.copied {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
}

/* Code Lines Table */
.code-block-content {
  overflow-x: auto;
  padding: 8px 0;
  background: #090e1a;
}
.code-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
  line-height: 1.55;
  tab-size: 2;
}
.code-line-tr:hover {
  background: rgba(255, 255, 255, 0.03);
}
.code-line-num {
  width: 44px;
  min-width: 44px;
  padding: 0 10px 0 12px;
  text-align: right;
  color: #475569;
  user-select: none;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  vertical-align: top;
  font-size: 11px;
}
.code-line-text {
  padding: 0 14px;
  white-space: pre;
  color: #e2e8f0;
  vertical-align: top;
}
.code-line-text code {
  font-family: inherit;
  background: transparent;
  padding: 0;
  border: none;
}

/* Syntax Keyword Coloring */
.code-token-keyword { color: #f472b6; font-weight: 600; }
.code-token-string { color: #86efac; }
.code-token-number { color: #fcd34d; }
.code-token-boolean { color: #fb923c; font-weight: 600; }
.code-token-comment { color: #64748b; font-style: italic; }
.code-token-function { color: #60a5fa; }
.code-token-operator { color: #94a3b8; }
.code-token-punctuation { color: #cbd5e1; }
.code-token-tag { color: #f87171; font-weight: 600; }
.code-token-attribute { color: #fbbf24; }

/* Toast Feedback */
.markdown-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #f8fafc;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.markdown-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================
   Mentions & Autocomplete Dropdown
   ========================================== */
.mention-tag {
  display: inline-block;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 4px;
  padding: 1px 6px;
  margin: 0 2px;
  font-weight: 500;
  font-size: 0.95em;
  line-height: 1.3;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: text;
}
.mention-tag:hover {
  background: rgba(59, 130, 246, 0.32);
  border-color: #60a5fa;
  text-decoration: none;
}
.mention-tag.mention-me {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.45);
  font-weight: 600;
}
.mention-tag.mention-me:hover {
  background: rgba(245, 158, 11, 0.35);
  border-color: #f59e0b;
}
.msg-row.me .mention-tag {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

/* Floating Autocomplete Dropdown */
.mention-dropdown {
  position: fixed;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-family);
  animation: mentionDropdownIn 0.15s ease-out;
}
@keyframes mentionDropdownIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.mention-dropdown-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  background: #0f172a;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.mention-hint {
  font-size: 10px;
  color: #64748b;
}
.mention-dropdown-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
  user-select: none;
}
.mention-item:hover,
.mention-item.active {
  background: rgba(59, 130, 246, 0.2);
}
.mention-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.mention-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.mention-nickname {
  font-size: 13px;
  font-weight: 500;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mention-handle {
  font-size: 11px;
  color: #94a3b8;
}
.mention-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  margin-left: auto;
}

/* ==========================================================================
   Network Resilience Engine UI (断线重连与离线状态指示)
   ========================================================================== */
.connection-status-banner {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  opacity: 0;
  pointer-events: none;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
  user-select: none;
}

.connection-status-banner.banner-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Offline state: Yellow/orange warning */
.connection-status-banner.banner-offline {
  background: rgba(35, 24, 10, 0.94);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.45);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 14px rgba(245, 158, 11, 0.25);
}

/* Reconnecting state: Subtle rotating spinner */
.connection-status-banner.banner-reconnecting {
  background: rgba(15, 23, 42, 0.94);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.45);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 14px rgba(59, 130, 246, 0.25);
}

.connection-status-banner .banner-spinner {
  display: inline-block;
  animation: resilience-spin 1s linear infinite;
  transform-origin: center center;
  line-height: 1;
}

/* Reconnected state: Green recovery badge (fades out after 2.5s) */
.connection-status-banner.banner-reconnected {
  background: rgba(6, 44, 28, 0.94);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.45);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 14px rgba(16, 185, 129, 0.25);
}

@keyframes resilience-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Message Bubble Status Indicators (Pending clock -> Sent tick ✓) */
.msg-status {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  vertical-align: middle;
}

.status-badge-pending {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #fbbf24;
  font-size: 11px;
  font-weight: 500;
  background: rgba(245, 158, 11, 0.15);
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  animation: resilience-pulse 2s ease-in-out infinite;
}

.status-badge-sent {
  color: #60a5fa;
  font-weight: bold;
  font-size: 12px;
  user-select: none;
  display: inline-block;
}

@keyframes resilience-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}


