/* ============================================================= */
/* PRIVATE 2-PERSON REALTIME MESSENGER — DESIGN SYSTEM */
/* ============================================================= */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-dark: #0b0914;
  --bg-surface: #130e24;
  --bg-card: rgba(23, 17, 41, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.4);
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --text-main: #f3f0ff;
  --text-dim: #9ca3af;
  --text-muted: #6b7280;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-lg: 20px;
  --radius-md: 14px;
}

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

body.dark-theme {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 10% 10%, rgba(139, 92, 246, 0.18) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(236, 72, 153, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* LIGHT MODE THEME SYSTEM (CRYSTAL CLEAR HIGH CONTRAST) */
body[data-theme="light"], .light-theme {
  --bg-dark: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --border-color: rgba(0, 0, 0, 0.12);
  --accent-purple: #7c3aed;
  --accent-purple-glow: rgba(124, 58, 237, 0.2);
  --text-main: #0f172a;
  --text-dim: #475569;
  --text-muted: #64748b;
  background-color: #f1f5f9 !important;
  background-image: 
    radial-gradient(at 10% 10%, rgba(124, 58, 237, 0.08) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(236, 72, 153, 0.08) 0px, transparent 50%) !important;
  color: #0f172a !important;
}

body[data-theme="light"] .messenger-app-layout {
  background: #ffffff !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .messenger-header {
  background: #ffffff !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .header-name {
  color: #0f172a !important;
  font-weight: 700;
}

body[data-theme="light"] .header-avatar {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.3);
  color: #7c3aed;
}

body[data-theme="light"] .header-status.offline {
  color: #64748b !important;
}

body[data-theme="light"] .btn-header-action {
  background: #f1f5f9 !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #0f172a !important;
}

body[data-theme="light"] .btn-header-action:hover {
  background: #e2e8f0 !important;
}

body[data-theme="light"] .three-dots-dropdown-menu {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12) !important;
}

body[data-theme="light"] .dropdown-item-btn {
  color: #1e293b !important;
}

body[data-theme="light"] .dropdown-item-btn:hover {
  background: #f1f5f9 !important;
}

body[data-theme="light"] .dropdown-divider {
  background: rgba(0, 0, 0, 0.08) !important;
}

/* Chat Bubbles in Light Mode */
body[data-theme="light"] .chat-bubble.other .chat-bubble-content {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-left: 3px solid #7c3aed !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

body[data-theme="light"] .chat-bubble.other .chat-sender-name {
  color: #6b21a8 !important;
  font-weight: 700;
}

body[data-theme="light"] .chat-bubble.other .chat-time {
  color: #64748b !important;
}

body[data-theme="light"] .chat-bubble.other .chat-message-text {
  color: #0f172a !important;
  font-weight: 450;
}

body[data-theme="light"] .chat-bubble.self .chat-bubble-content {
  background: linear-gradient(135deg, #7c3aed, #6d28d9) !important;
  color: #ffffff !important;
}

body[data-theme="light"] .chat-bubble.self .chat-sender-name {
  color: #ffffff !important;
}

body[data-theme="light"] .chat-bubble.self .chat-time {
  color: rgba(255, 255, 255, 0.85) !important;
}

body[data-theme="light"] .chat-bubble.self .read-tick.sent {
  color: rgba(255, 255, 255, 0.8) !important;
}

/* Quoted Reply Boxes in Light Mode */
body[data-theme="light"] .chat-bubble.other .quoted-reply-box {
  background: #f1f5f9 !important;
  border-left: 3px solid #7c3aed !important;
}

body[data-theme="light"] .chat-bubble.other .quoted-reply-author {
  color: #6b21a8 !important;
}

body[data-theme="light"] .chat-bubble.other .quoted-reply-snippet {
  color: #334155 !important;
}

body[data-theme="light"] .chat-bubble.self .quoted-reply-box {
  background: rgba(0, 0, 0, 0.2) !important;
  border-left-color: #fbcfe8 !important;
}

body[data-theme="light"] .chat-bubble.self .quoted-reply-author {
  color: #fbcfe8 !important;
}

body[data-theme="light"] .chat-bubble.self .quoted-reply-snippet {
  color: #f1f5f9 !important;
}

/* Reply Preview Bar & Search Bar in Light Mode */
body[data-theme="light"] .reply-preview-bar {
  background: #f8fafc !important;
  border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .reply-bar-name {
  color: #7c3aed !important;
}

body[data-theme="light"] .reply-bar-text {
  color: #1e293b !important;
}

body[data-theme="light"] .btn-cancel-reply {
  color: #64748b !important;
}

body[data-theme="light"] .search-bar-wrapper {
  background: #ffffff !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .search-input-field {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

body[data-theme="light"] .search-input-field::placeholder {
  color: #94a3b8 !important;
}

body[data-theme="light"] .btn-close-search {
  color: #475569 !important;
}

/* Action Dropdown & Toolbar in Light Mode */
body[data-theme="light"] .delete-menu-content {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

body[data-theme="light"] .delete-menu-content button {
  color: #1e293b !important;
}

body[data-theme="light"] .delete-menu-content button:hover {
  background: #fee2e2 !important;
  color: #dc2626 !important;
}

body[data-theme="light"] .btn-react {
  background: rgba(0, 0, 0, 0.06) !important;
}

/* Footer & Input in Light Mode */
body[data-theme="light"] .messenger-input-footer {
  background: #ffffff !important;
  border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .chat-input-field {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
}

body[data-theme="light"] .chat-input-field::placeholder {
  color: #94a3b8 !important;
}

body[data-theme="light"] .btn-input-icon {
  background: #f1f5f9 !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #0f172a !important;
}

body[data-theme="light"] .btn-input-icon:hover {
  background: #e2e8f0 !important;
  border-color: #7c3aed !important;
}

/* Modals in Light Mode */
body[data-theme="light"] .vanish-modal-card {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2) !important;
  color: #0f172a !important;
}

body[data-theme="light"] .vanish-modal-card h3 {
  color: #0f172a !important;
}

body[data-theme="light"] .vanish-modal-card p {
  color: #475569 !important;
}

body[data-theme="light"] .btn-vanish-opt {
  background: #f8fafc !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  color: #1e293b !important;
}

body[data-theme="light"] .btn-vanish-opt:hover {
  background: rgba(124, 58, 237, 0.1) !important;
  border-color: #7c3aed !important;
}

body[data-theme="light"] .btn-secondary {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

body[data-theme="light"] .form-control {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
}

/* ============================================================= */
/* LOGIN PAGE STYLES */
/* ============================================================= */
.messenger-login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  padding: 2.5rem 2rem;
}

.messenger-login-card {
  width: 100%;
  max-width: 440px;
  text-align: center;
}

.messenger-brand-icon {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 20px var(--accent-purple-glow));
}

.messenger-login-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.3rem;
}

.messenger-login-subtitle {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin-bottom: 2rem;
}

.profile-selector-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-pill-option {
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 0.8rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.profile-pill-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.profile-pill-option:hover {
  border-color: var(--accent-purple);
  transform: translateY(-2px);
}

.profile-pill-option.active {
  border-color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 15px var(--accent-purple-glow);
}

.profile-pill-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.profile-avatar { font-size: 1.6rem; }
.profile-name { font-weight: 700; color: #fff; font-size: 1rem; }
.profile-tag { font-size: 0.75rem; color: var(--text-dim); }

.form-group {
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 12px var(--accent-purple-glow);
}

.btn-messenger-primary {
  background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 8px 20px var(--accent-purple-glow);
}

.btn-messenger-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px var(--accent-purple-glow);
}

.login-error-toast {
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid var(--accent-rose);
  color: #fecdd3;
  padding: 0.7rem;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-top: 1rem;
}

/* ============================================================= */
/* MAIN MESSENGER CHAT LAYOUT — ULTRA MODERN & MOBILE OPTIMIZED */
/* ============================================================= */

.messenger-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 10% 10%, rgba(139, 92, 246, 0.18) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(236, 72, 153, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  overflow: hidden;
}

.messenger-app-layout {
  width: 100%;
  max-width: 960px;
  height: 92vh;
  height: 92dvh;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  position: relative;
}

/* ============================================================= */
/* TOP MESSENGER HEADER */
/* ============================================================= */

.messenger-header {
  flex-shrink: 0;
  padding: 0.85rem 1.25rem;
  background: rgba(19, 14, 36, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 50;
}

.messenger-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
}

.header-avatar-wrap {
  position: relative;
  display: inline-block;
}

.header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.2);
  border: 1.5px solid var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.header-online-indicator {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 11px;
  height: 11px;
  background: var(--accent-emerald);
  border: 2px solid #130e24;
  border-radius: 50%;
  display: none;
}

.header-text-details {
  display: flex;
  flex-direction: column;
}

.header-name {
  font-size: 1.08rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.header-status {
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 2px;
}

.header-status.online { color: var(--accent-emerald); }
.header-status.offline { color: var(--text-muted); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-header-action {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.8rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-header-action:hover {
  background: rgba(255, 255, 255, 0.15);
}

.icon-btn-dots {
  width: 38px;
  height: 38px;
  border-radius: 50% !important;
  font-size: 1.3rem !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  line-height: 1;
}

/* Three Dots Dropdown */
.three-dots-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #18132e;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
  padding: 0.5rem;
  width: 240px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  animation: dropdownFade 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  font-family: inherit;
}

.dropdown-item-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(2px);
}

.dropdown-item-btn.danger-item { color: var(--accent-rose); }
.dropdown-item-btn.danger-item:hover { background: rgba(244, 63, 94, 0.15); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 0.3rem 0; }

/* ============================================================= */
/* SEARCH & VANISH BANNERS */
/* ============================================================= */

.search-bar-wrapper {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  background: rgba(19, 14, 36, 0.98);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 40;
}

.search-input-field {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.btn-close-search {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
}

.vanish-notice-banner {
  flex-shrink: 0;
  background: rgba(236, 72, 153, 0.2);
  border-bottom: 1px solid rgba(236, 72, 153, 0.35);
  color: #fbcfe8;
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  text-align: center;
  z-index: 40;
}

.badge-on { color: var(--accent-pink); font-weight: 800; }
.badge-off { color: var(--text-muted); }

/* ============================================================= */
/* MAIN CHAT STREAM THREAD */
/* ============================================================= */

.chat-thread-stream {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.chat-loading-spinner {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  padding: 2rem 1rem;
  animation: pulseLoading 1.5s infinite ease-in-out;
}

@keyframes pulseLoading {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.chat-empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  max-width: 340px;
  padding: 2rem 1rem;
}

.chat-empty-state .empty-icon {
  font-size: 3.2rem;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

.chat-empty-state h3 {
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.chat-empty-state p {
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--text-dim);
}

/* ============================================================= */
/* MESSAGE BUBBLES — NATIVE MESSENGER DESIGN */
/* ============================================================= */

.chat-bubble {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 82%;
  position: relative;
  user-select: text;
  -webkit-user-select: text;
  animation: messagePop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messagePop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-bubble.self {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-left: auto;
}

.chat-bubble.other {
  align-self: flex-start;
  flex-direction: row;
  margin-right: auto;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.chat-bubble-content {
  border-radius: 18px;
  padding: 0.65rem 0.95rem;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  max-width: 100%;
  word-break: break-word;
}

.chat-bubble-content:active {
  transform: scale(0.98);
}

/* Self (You) Bubble */
.chat-bubble.self .chat-bubble-content {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Other (Tuba) Bubble */
.chat-bubble.other .chat-bubble-content {
  background: #1e1938;
  color: #f3f0ff;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.chat-sender-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}

.chat-sender-name {
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.2px;
}

.chat-bubble.other .chat-sender-name {
  color: #ec4899;
}

.chat-bubble.self .chat-sender-name {
  color: rgba(255, 255, 255, 0.85);
  display: none; /* Cleaner look for self messages */
}

.chat-time {
  font-size: 0.68rem;
  opacity: 0.75;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  white-space: nowrap;
}

.read-tick {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  display: inline-flex;
  align-items: center;
}

.read-tick.seen {
  color: #38bdf8;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.2);
  padding: 1px 5px;
  border-radius: 8px;
}

.read-tick.seen .seen-text {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-right: 2px;
}

.chat-message-text {
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.edited-tag {
  font-size: 0.68rem;
  opacity: 0.7;
  font-style: italic;
  margin-left: 0.3rem;
}

/* Floating Reaction Badge */
.bubble-reaction-badge {
  position: absolute;
  bottom: -9px;
  right: 8px;
  background: #18132e;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 1px 6px;
  font-size: 0.82rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  z-index: 5;
  user-select: none;
}

.chat-bubble.self .bubble-reaction-badge {
  left: 8px;
  right: auto;
}

.bubble-vanish-tag {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: #fbcfe8;
  background: rgba(236, 72, 153, 0.25);
  padding: 1px 6px;
  border-radius: 6px;
}

/* Media (Photos, Videos, Audio) */
.bubble-media-wrapper {
  margin-bottom: 0.4rem;
  border-radius: 12px;
  overflow: hidden;
  max-width: 280px;
}

.chat-media-photo {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  display: block;
}

.chat-media-video {
  width: 100%;
  max-height: 260px;
  border-radius: 12px;
  background: #000;
  display: block;
}

.chat-media-audio {
  width: 100%;
  max-width: 250px;
  height: 38px;
  border-radius: 19px;
}

/* Quoted Reply inside Bubbles */
.quoted-reply-box {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid #c084fc;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  font-size: 0.78rem;
}

.chat-bubble.self .quoted-reply-box {
  background: rgba(0, 0, 0, 0.2);
  border-left-color: #fbcfe8;
}

.quoted-reply-author {
  font-weight: 700;
  font-size: 0.72rem;
  display: block;
  opacity: 0.95;
  margin-bottom: 1px;
}

.quoted-reply-snippet {
  opacity: 0.85;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================= */
/* NATIVE MESSAGE ACTION BOTTOM SHEET / MODAL */
/* ============================================================= */

.message-action-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeInOverlay 0.2s ease;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.message-action-sheet-card {
  width: 100%;
  max-width: 480px;
  background: #18132e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px 24px 0 0;
  padding: 1.2rem 1.1rem max(1.2rem, env(safe-area-inset-bottom)) 1.1rem;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Quick Reaction Emoji Row */
.sheet-reactions-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 0.5rem 0.6rem;
}

.sheet-react-btn {
  background: none;
  border: none;
  font-size: 1.65rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 12px;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  user-select: none;
}

.sheet-react-btn:active, .sheet-react-btn:hover {
  transform: scale(1.35);
}

/* Action Items List */
.sheet-actions-list {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
}

.sheet-action-item {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #fff;
  padding: 0.85rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
  font-family: inherit;
}

.sheet-action-item:last-child {
  border-bottom: none;
}

.sheet-action-item:hover, .sheet-action-item:active {
  background: rgba(255, 255, 255, 0.1);
}

.sheet-action-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

.sheet-action-item.sheet-danger {
  color: var(--accent-rose);
}

.sheet-action-item.sheet-danger:hover, .sheet-action-item.sheet-danger:active {
  background: rgba(244, 63, 94, 0.15);
}

.sheet-cancel-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.85rem;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.sheet-cancel-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

/* ============================================================= */
/* TYPING INDICATOR & PREVIEWS */
/* ============================================================= */

.typing-indicator-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 1.25rem;
  font-size: 0.8rem;
  color: var(--accent-purple);
  font-weight: 600;
}

.typing-dot {
  width: 5px;
  height: 5px;
  background: var(--accent-purple);
  border-radius: 50%;
  animation: typingBounce 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 typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

.reply-preview-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  background: rgba(139, 92, 246, 0.15);
  border-top: 1px solid var(--border-color);
  padding: 0.45rem 1rem;
  gap: 0.75rem;
  animation: slideUpReply 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpReply {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.reply-bar-accent {
  width: 3px;
  height: 26px;
  background: var(--accent-purple);
  border-radius: 3px;
  flex-shrink: 0;
}

.reply-bar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.reply-bar-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-purple);
}

.reply-bar-text {
  font-size: 0.8rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-cancel-reply {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.media-preview-bar {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.preview-content-box {
  position: relative;
  display: inline-block;
}

.btn-remove-media {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent-rose);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-preview-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ============================================================= */
/* BOTTOM INPUT FOOTER */
/* ============================================================= */

.messenger-input-footer {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  background: rgba(19, 14, 36, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  z-index: 50;
}

.messenger-input-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-input-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-input-icon:hover, .btn-input-icon:active {
  background: rgba(139, 92, 246, 0.25);
  border-color: var(--accent-purple);
}

.chat-input-field {
  flex: 1;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  padding: 0.65rem 1rem;
  color: #fff;
  font-family: inherit;
  font-size: 16px; /* 16px prevents iOS Safari from automatically zooming into inputs */
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-field:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 10px var(--accent-purple-glow);
}

.btn-send-messenger {
  background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.65rem 1.1rem;
  border-radius: 22px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px var(--accent-purple-glow);
  flex-shrink: 0;
}

.btn-send-messenger:hover {
  transform: translateY(-1px);
}

.btn-send-messenger:active {
  transform: translateY(1px);
}

/* ============================================================= */
/* MODALS (LIGHTBOX, VANISH, PROFILE) */
/* ============================================================= */

.lightbox-overlay, .vanish-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox-close {
  position: absolute;
  top: max(1.5rem, env(safe-area-inset-top));
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vanish-modal-card {
  background: #18132e;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.vanish-options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1rem;
}

.btn-vanish-opt {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.75rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-vanish-opt:hover, .btn-vanish-opt:active {
  background: rgba(139, 92, 246, 0.25);
  border-color: var(--accent-purple);
}

.btn-vanish-opt.disable {
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}

/* ============================================================= */
/* LIGHT THEME OVERRIDES (CRISP HIGH CONTRAST) */
/* ============================================================= */

body[data-theme="light"] .messenger-app-layout {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .messenger-header,
body[data-theme="light"] .messenger-input-footer {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .header-name {
  color: #0f172a !important;
}

body[data-theme="light"] .btn-header-action,
body[data-theme="light"] .btn-input-icon {
  background: #f1f5f9 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #0f172a !important;
}

body[data-theme="light"] .chat-input-field {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

body[data-theme="light"] .three-dots-dropdown-menu,
body[data-theme="light"] .message-action-sheet-card,
body[data-theme="light"] .vanish-modal-card {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15) !important;
}

body[data-theme="light"] .dropdown-item-btn,
body[data-theme="light"] .sheet-action-item,
body[data-theme="light"] .sheet-cancel-btn {
  color: #1e293b !important;
}

body[data-theme="light"] .sheet-reactions-bar,
body[data-theme="light"] .sheet-actions-list {
  background: #f8fafc !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .sheet-action-item {
  border-color: rgba(0, 0, 0, 0.06) !important;
}

body[data-theme="light"] .bubble-reaction-badge {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
}

body[data-theme="light"] .chat-bubble.other .chat-bubble-content {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #0f172a !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

/* ============================================================= */
/* MOBILE FULLSCREEN NATIVE APP RESPONSIVE STYLES (≤ 768px) */
/* ============================================================= */

@media (max-width: 768px) {
  html, body.messenger-body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100% !important;
    height: -webkit-fill-available !important;
    height: 100dvh !important;
    overflow: hidden !important;
    position: fixed !important;
    inset: 0 !important;
    touch-action: manipulation;
  }

  .messenger-app-layout {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100% !important;
    height: -webkit-fill-available !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .messenger-header {
    padding-top: max(0.6rem, env(safe-area-inset-top)) !important;
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
    padding-bottom: 0.6rem !important;
  }

  .header-avatar {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.1rem !important;
  }

  .header-name {
    font-size: 0.98rem !important;
  }

  .header-status {
    font-size: 0.72rem !important;
  }

  .chat-thread-stream {
    padding: 0.85rem 0.75rem !important;
    gap: 0.7rem !important;
  }

  .chat-bubble {
    max-width: 86% !important;
  }

  .chat-bubble-content {
    padding: 0.6rem 0.85rem !important;
    border-radius: 16px !important;
  }

  .chat-message-text {
    font-size: 0.92rem !important;
  }

  .messenger-input-footer {
    padding-top: 0.55rem !important;
    padding-left: 0.65rem !important;
    padding-right: 0.65rem !important;
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom)) !important;
  }

  .messenger-input-form {
    gap: 0.4rem !important;
  }

  .btn-input-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.05rem !important;
  }

  .chat-input-field {
    padding: 0.58rem 0.85rem !important;
    font-size: 16px !important;
  }

  .btn-send-messenger {
    padding: 0.58rem 0.95rem !important;
    font-size: 0.88rem !important;
  }

  .btn-send-messenger span {
    display: none; /* Icon only on tight mobile screens */
  }

  .message-action-sheet-card {
    border-radius: 20px 20px 0 0 !important;
    padding: 1rem 0.85rem max(1rem, env(safe-area-inset-bottom)) 0.85rem !important;
  }
}

