/* ==========================================================================
   ChatSphere V2 - Dark Violet Neon Glassmorphism Design System
   Supercharged with WhatsApp-Style Interactions & BeReal Stories
   100% Zero Emojis | Pure SVG Icons & Minimalist Elegance
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-space: #080811;
  --bg-space-dark: #040408;
  --bg-card: rgba(18, 16, 32, 0.72);
  --bg-card-hover: rgba(28, 24, 48, 0.85);
  --bg-input: rgba(12, 10, 22, 0.88);
  --bg-glass-pill: rgba(25, 20, 44, 0.85);

  --accent-violet: #a855f7;
  --accent-violet-light: #c084fc;
  --accent-violet-dark: #7e22ce;
  --accent-gradient: linear-gradient(135deg, #a855f7 0%, #7e22ce 50%, #4338ca 100%);
  --accent-glow: 0 0 24px rgba(168, 85, 247, 0.45);

  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-light: rgba(255, 255, 255, 0.16);
  --border-accent: rgba(168, 85, 247, 0.35);

  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #d8b4fe;

  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #00E5FF; /* Electric Cyan for Read Receipts */

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-pill: 9999px;

  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* User Configurable Font Size */
  --chat-font-size: 0.92rem;
}

body.font-small { --chat-font-size: 0.82rem; }
body.font-medium { --chat-font-size: 0.92rem; }
body.font-large { --chat-font-size: 1.05rem; }

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  color: inherit;
  box-shadow: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100dvh;
  background-color: var(--bg-space);
  color: var(--text-primary);
  font-family: var(--font-main);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Cosmic Background */
.cosmic-background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% -10%, #2e1065 0%, #17082e 35%, #080811 75%);
}

.cosmic-sphere {
  position: absolute;
  top: -160px;
  left: 50%;
  transform: translateX(-50%);
  width: 580px;
  height: 440px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #a855f7 0%, #6b21a8 40%, rgba(88, 28, 135, 0.4) 70%, transparent 100%);
  filter: blur(45px);
  opacity: 0.65;
  animation: spherePulse 8s ease-in-out infinite alternate;
}

.cosmic-sphere-secondary {
  position: absolute;
  bottom: -150px;
  right: -80px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(126, 34, 206, 0.25) 0%, transparent 70%);
  filter: blur(50px);
}

@keyframes spherePulse {
  0% { transform: translateX(-50%) scale(0.96); opacity: 0.55; }
  100% { transform: translateX(-50%) scale(1.04); opacity: 0.75; }
}

/* App Viewport Container (100% Fluid on Mobile/Landscape, Elegant Frame on Laptop/Desktop) */
.app-viewport {
  position: relative;
  z-index: 1;
  width: 100%;
  width: 100vw;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: rgba(10, 9, 18, 0.55);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  overflow: hidden;
}

/* Laptop & Desktop Dual-Pane Mode */
@media (min-width: 992px) and (hover: hover) and (pointer: fine) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #05050a;
    padding: 24px;
  }

  .app-viewport {
    width: 92vw;
    max-width: 1200px;
    height: 90vh;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 70px -15px rgba(126, 34, 206, 0.4);
    flex-direction: row;
  }

  #screen-auth {
    position: absolute;
    inset: 0;
    z-index: 100;
    border-radius: 28px;
  }

  #screen-explore {
    width: 380px;
    min-width: 340px;
    max-width: 420px;
    border-right: 1px solid var(--border-glass);
    display: flex !important;
    flex-direction: column;
    height: 100%;
  }

  #screen-chat {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    height: 100%;
    background: rgba(8, 8, 17, 0.85);
  }

  .chat-room-header .back-btn {
    display: none !important;
  }

  .desktop-chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
  }
}

/* Screens Layout */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.22s ease-in-out, transform 0.22s ease-in-out;
}

.screen.active {
  display: flex;
  opacity: 1;
}

/* ==========================================================================
   Screen 1: Welcome & Auth Screen
   ========================================================================== */
.welcome-screen {
  justify-content: space-between;
  align-items: center;
  padding: 40px 24px 32px;
  padding-top: calc(40px + var(--safe-top));
  padding-bottom: calc(32px + var(--safe-bottom));
  text-align: center;
}

.brand-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 15px;
}

.brand-logo-glow {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.4) 0%, rgba(126, 34, 206, 0.1) 70%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 25px rgba(168, 85, 247, 0.65));
}

.brand-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
  margin-bottom: 6px;
  background: linear-gradient(180deg, #ffffff 30%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tagline {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 280px;
  line-height: 1.45;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.auth-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--border-glass);
}

.auth-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab.active {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.4);
}

.form-group {
  margin-bottom: 14px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-left: 4px;
}

.input-pill {
  width: 100%;
  height: 46px;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  padding: 0 18px;
  color: #ffffff;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-pill:focus {
  border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.btn-primary {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--accent-gradient);
  border: none;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(147, 51, 234, 0.5);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:active {
  transform: scale(0.97);
}

.demo-login-chip {
  margin-top: 14px;
  padding: 8px 14px;
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  color: var(--text-accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, transform 0.15s;
}

.demo-login-chip:hover {
  background: rgba(168, 85, 247, 0.22);
}

.demo-login-chip:active {
  transform: scale(0.96);
}

/* ==========================================================================
   Screen 2: Conversations List (Minimalist Clean Design)
   ========================================================================== */
.explore-header {
  padding: 16px 20px 10px;
  padding-top: calc(16px + var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
  position: relative;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.online-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--success);
  border: 2px solid var(--bg-space);
}

.explore-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.2px;
}

/* WhatsApp-Style Filter Tabs (Pure Minimalist Text with Accent Underline) */
.filter-tabs-wrapper {
  padding: 8px 20px 4px;
  display: flex;
  align-items: center;
  gap: 22px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.filter-tabs-wrapper::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  -webkit-appearance: none;
  appearance: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 6px 0 10px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: color 0.18s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-tab:hover {
  color: #ffffff;
}

.filter-tab.active {
  color: #ffffff;
  font-weight: 600;
  background: transparent !important;
  box-shadow: none !important;
}

.filter-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  background: var(--accent-violet);
  border-radius: 3px 3px 0 0;
  box-shadow: 0 0 10px var(--accent-violet);
}

/* Inline Lobby Search Bar */
.lobby-search-container {
  padding: 10px 18px 4px;
  background: transparent;
  animation: fadeInDown 0.2s ease;
}

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

.lobby-search-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  color: var(--text-muted);
}

.lobby-search-inner:focus-within {
  border-color: var(--accent-violet);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

.lobby-search-inner input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  color: #ffffff;
  font-size: 0.88rem;
  font-family: inherit;
}

.lobby-search-inner input::placeholder {
  color: var(--text-muted);
}

/* Conversations Scroll List */
.conversations-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 14px 100px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Minimalist Clean Row (No boxy borders, seamless aesthetic) */
.conv-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.18s, transform 0.15s;
  position: relative;
  touch-action: pan-y;
}

.conv-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

.conv-card:active {
  transform: scale(0.99);
  background: rgba(255, 255, 255, 0.07);
}

.conv-card.pinned {
  background: rgba(168, 85, 247, 0.04);
}

.conv-details {
  flex: 1;
  min-width: 0;
}

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

.conv-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conv-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.conv-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conv-preview {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.unread-badge {
  background: var(--accent-gradient);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.5);
}

.pin-indicator {
  display: inline-flex;
  align-items: center;
  color: var(--accent-violet);
}

.conv-actions-btn {
  -webkit-appearance: none;
  appearance: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}

.conv-actions-btn:hover {
  opacity: 1;
  color: #ffffff;
}

/* Speed Dial Popover Menu (Directly above Center Bottom Button) */
.speed-dial-menu {
  position: absolute;
  bottom: calc(66px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px) scale(0.94);
  background: rgba(18, 14, 32, 0.96);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75), 0 0 24px rgba(126, 34, 206, 0.3);
  z-index: 40;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
  min-width: 200px;
}

.speed-dial-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

.speed-dial-item {
  -webkit-appearance: none;
  appearance: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  width: 100%;
  text-align: left;
}

.speed-dial-item:hover, .speed-dial-item:active {
  background: rgba(168, 85, 247, 0.18) !important;
  transform: translateX(2px);
}

.speed-dial-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.22);
  color: var(--accent-violet-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Floating Bottom Navigation Pill */
.bottom-nav-container {
  position: absolute;
  bottom: calc(14px + var(--safe-bottom));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}

.bottom-nav-pill {
  pointer-events: auto;
  background: rgba(20, 16, 36, 0.88);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(126, 34, 206, 0.2);
}

.nav-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.nav-icon-btn:hover {
  color: #ffffff;
}

.nav-icon-btn.active {
  color: var(--accent-violet);
}

.nav-sparkle-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(168, 85, 247, 0.6);
  transition: transform 0.15s, box-shadow 0.15s;
}

.nav-sparkle-btn:active {
  transform: scale(0.92);
}

/* ==========================================================================
   Screen 3: Chat Room View
   ========================================================================== */
.chat-room-header {
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(14, 12, 24, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 10;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
}

.chat-room-user-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.chat-room-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-room-status {
  font-size: 0.74rem;
  color: var(--accent-violet);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* In-Chat Pinned Message Banner */
.pinned-chat-banner {
  background: rgba(28, 22, 50, 0.95);
  border-bottom: 1px solid var(--border-glass);
  padding: 6px 16px;
  display: none;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  z-index: 9;
}

.pinned-chat-banner.active {
  display: flex;
}

.pinned-chat-text {
  color: var(--text-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  cursor: pointer;
}

/* In-Chat Search Bar */
.inchat-search-bar {
  background: rgba(18, 14, 32, 0.95);
  border-bottom: 1px solid var(--border-glass);
  padding: 8px 16px;
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 9;
}

.inchat-search-bar.active {
  display: flex;
}

.inchat-search-input {
  flex: 1;
  height: 36px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  padding: 0 14px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
}

/* Messages Scroll Feed */
.chat-messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Wallpapers */
.chat-messages-scroll.wallpaper-space {
  background: radial-gradient(circle at 50% 30%, #150a2e 0%, #080811 100%);
}
.chat-messages-scroll.wallpaper-nebula {
  background: radial-gradient(circle at 80% 20%, #2e1065 0%, #1a0b3b 50%, #06030e 100%);
}
.chat-messages-scroll.wallpaper-starfield {
  background: #05050c;
  background-image: radial-gradient(rgba(255,255,255,0.15) 1px, transparent 0);
  background-size: 24px 24px;
}
.chat-messages-scroll.wallpaper-obsidian {
  background: #020204;
}

/* Message Rows & Bubbles */
.message-row {
  display: flex;
  gap: 10px;
  max-width: 86%;
  animation: msgSlideIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message-row.incoming {
  align-self: flex-start;
}

.message-row.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-bubble-container {
  display: flex;
  flex-direction: column;
}

.message-bubble {
  position: relative;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: var(--chat-font-size);
  line-height: 1.45;
  word-break: break-word;
}

.message-row.incoming .message-bubble {
  background: rgba(26, 22, 45, 0.85);
  border: 1px solid var(--border-glass);
  color: #ffffff;
  border-bottom-left-radius: 4px;
}

.message-row.outgoing .message-bubble {
  background: linear-gradient(135deg, #7e22ce 0%, #581c87 100%);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(126, 34, 206, 0.25);
}

/* Reply Quote Inside Bubble */
.msg-reply-quote {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid var(--accent-violet-light);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 0.78rem;
}

.msg-reply-sender {
  font-weight: 600;
  color: var(--accent-violet-light);
}

.msg-reply-text {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bubble Meta: Time, Read Checkmark, Star, Edit */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
}

.check-icon.read {
  color: var(--info); /* Cyan Electric Blue for read ticks */
}

.msg-quick-reply-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.msg-quick-reply-btn:hover {
  color: #ffffff;
}

/* Attached Media / Photos */
.msg-image-thumb {
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.2s;
  display: block;
  margin-bottom: 4px;
}

.msg-image-thumb:hover {
  transform: scale(0.98);
}

/* View Once Bubble */
.view-once-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed var(--accent-violet);
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  color: var(--text-accent);
  cursor: pointer;
}

.view-once-pill.burned {
  opacity: 0.6;
  cursor: not-allowed;
  border-style: solid;
  color: var(--text-muted);
}

/* Voice Note Player Bubble */
.msg-voice-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  min-width: 210px;
}

.voice-play-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.voice-waveform {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.waveform-bar {
  width: 3px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  height: 8px;
  transition: height 0.15s ease, background 0.15s;
}

.waveform-bar.active {
  background: var(--accent-violet);
}

.vn-speed-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border-glass);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Group Poll Card */
.msg-poll-card {
  min-width: 230px;
  padding: 4px;
}

.poll-question {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 8px;
  color: #fff;
}

.poll-opt-btn {
  width: 100%;
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
  font-size: 0.82rem;
  cursor: pointer;
  overflow: hidden;
}

.poll-opt-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: rgba(168, 85, 247, 0.25);
  z-index: 0;
  transition: width 0.3s ease;
}

.poll-opt-label {
  position: relative;
  z-index: 1;
}

.poll-opt-percent {
  position: relative;
  z-index: 1;
  font-weight: 600;
  color: var(--accent-violet-light);
}

/* Contact & Location Card */
.msg-contact-card, .msg-location-card {
  min-width: 200px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px;
}

/* Reply Draft Banner above input */
.reply-draft-banner {
  background: rgba(24, 20, 38, 0.95);
  border-top: 1px solid var(--border-glass);
  padding: 8px 18px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reply-draft-banner.active {
  display: flex;
}

.reply-draft-info {
  flex: 1;
  min-width: 0;
  border-left: 3px solid var(--accent-violet);
  padding-left: 8px;
}

.reply-draft-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-violet);
}

.reply-draft-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-draft-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

/* ==========================================================================
   Chat Input Bar & FIXED Un-Squished Voice Note Recording
   ========================================================================== */
.chat-input-bar {
  position: relative;
  padding: 10px 14px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: rgba(14, 12, 24, 0.95);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-top: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

/* When recording mode is active, completely hide attachments, text input, mic and send buttons! */
.chat-input-bar.recording-mode .composer-attach-group,
.chat-input-bar.recording-mode .chat-input-wrapper,
.chat-input-bar.recording-mode #btn-mic,
.chat-input-bar.recording-mode #btn-send {
  display: none !important;
}

.composer-attach-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.composer-icon-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.composer-icon-btn.active {
  color: var(--accent-violet);
}

.chat-input-wrapper {
  flex: 1;
  position: relative;
}

.chat-text-input {
  width: 100%;
  height: 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  padding: 0 16px;
  color: #ffffff;
  font-size: var(--chat-font-size);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.chat-text-input:focus {
  border-color: var(--accent-violet);
}

.chat-text-input::placeholder {
  color: var(--text-muted);
}

.composer-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(147, 51, 234, 0.55);
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.composer-send-btn:hover {
  transform: scale(1.05);
}

.composer-send-btn:active {
  transform: scale(0.96);
}

/* UN-SQUISHED FULL-WIDTH VOICE RECORDING OVERLAY */
.voice-recording-overlay {
  display: none;
  width: 100%;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  background: rgba(147, 51, 234, 0.16);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-pill);
  padding: 4px 14px;
  height: 46px;
}

.voice-recording-overlay.active {
  display: flex;
}

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

@keyframes recPulse {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

.rec-timer {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
}

.rec-cancel-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.rec-preview-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  color: #fff;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.rec-finish-btn {
  background: var(--accent-gradient);
  border: none;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.5);
}

/* ==========================================================================
   In-App Toast Notification Banner (No Browser Permissions Needed)
   ========================================================================== */
.inapp-toast-container {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 99999;
}

.inapp-toast {
  pointer-events: auto;
  max-width: 90%;
  width: 360px;
  background: rgba(22, 18, 42, 0.95);
  border: 1px solid var(--border-accent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  animation: toastDrop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(20px);
}

@keyframes toastDrop {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.inapp-toast-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: #fff;
}

.inapp-toast-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Modals & Action Sheets
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  background: rgba(18, 15, 34, 0.95);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: #ffffff;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* Bottom Action Sheet (WhatsApp Style) */
.action-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.action-sheet-backdrop.active {
  display: flex;
}

.action-sheet-card {
  width: 100%;
  max-width: 480px;
  background: rgba(20, 16, 38, 0.98);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  border: 1px solid var(--border-glass-light);
  border-bottom: none;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  animation: sheetSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.action-sheet-item {
  width: 100%;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

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

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

/* ==========================================================================
   WhatsApp Contact Info Sheet (Matching User Screenshot Image 3)
   ========================================================================== */
.contact-info-sheet {
  width: 100%;
  max-width: 480px;
  height: 92vh;
  max-height: 92vh;
  background: rgba(14, 12, 26, 0.98);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  border: 1px solid var(--border-glass-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.contact-info-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.contact-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 20px;
}

.contact-hero-avatar {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(126, 34, 206, 0.4);
}

.contact-hero-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.contact-hero-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.contact-actions-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 24px;
}

.contact-pill-btn {
  flex: 1;
  max-width: 100px;
  height: 60px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.contact-pill-btn:hover {
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--accent-violet);
}

.contact-section-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.contact-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.contact-row-item:last-child {
  border-bottom: none;
}

/* ==========================================================================
   Voice Call Overlay
   ========================================================================== */
.voice-call-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #3b0764 0%, #17082e 60%, #080811 100%);
  z-index: 100000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 60px 24px 50px;
}

.voice-call-overlay.active {
  display: flex;
}

.call-pulse-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: #fff;
  position: relative;
  box-shadow: 0 0 40px rgba(168, 85, 247, 0.6);
  animation: callPulse 1.8s infinite;
}

@keyframes callPulse {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(168, 85, 247, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 60px rgba(168, 85, 247, 0.8); }
  100% { transform: scale(1); box-shadow: 0 0 20px rgba(168, 85, 247, 0.4); }
}

.call-controls-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.call-circle-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: transform 0.15s;
}

.call-circle-btn:active {
  transform: scale(0.92);
}

.call-btn-mute {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.call-btn-mute.active {
  background: #ffffff;
  color: #000000;
}

.call-btn-speaker {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  transition: all 0.2s ease;
}

.call-btn-speaker.active {
  background: var(--accent-violet);
  color: #ffffff;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.8);
}

.call-btn-end {
  background: var(--danger);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.call-btn-accept {
  background: var(--success);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
  animation: acceptPulse 1.4s infinite;
}

@keyframes acceptPulse {
  0% { transform: scale(1); box-shadow: 0 0 15px rgba(16, 185, 129, 0.5); }
  50% { transform: scale(1.08); box-shadow: 0 0 30px rgba(16, 185, 129, 0.9); }
  100% { transform: scale(1); box-shadow: 0 0 15px rgba(16, 185, 129, 0.5); }
}

/* ==========================================================================
   BeReal Stories & Viewer
   ========================================================================== */
.bereal-feed-card {
  position: relative;
  width: 100%;
  height: 380px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  background: #000;
  border: 1px solid var(--border-glass-light);
}

.bereal-main-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bereal-selfie-photo {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 90px;
  height: 120px;
  border-radius: var(--radius-sm);
  border: 2px solid #ffffff;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 2;
}

.bereal-selfie-photo:hover {
  transform: scale(1.05);
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-img {
  max-width: 95%;
  max-height: 85vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
  transition: transform 0.2s ease;
}

.lightbox-close {
  position: absolute;
  top: calc(20px + var(--safe-top));
  right: 20px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hidden elements */
.hidden-file-input {
  display: none !important;
}

/* Native Web Push Permission Banner */
.push-perm-banner {
  padding: 8px 16px 4px 16px;
  animation: fadeIn 0.25s ease;
}

.push-perm-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-md);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.push-perm-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
}

