/* ═══════════════════════════════════════════════════════════════
   Signal Messenger – Global Styles
   Design: Deep dark, purple/teal accents, glassmorphism panels
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --bg-base:         #0D0D1A;
  --bg-surface:      #13131F;
  --bg-elevated:     #1A1A2E;
  --bg-hover:        #222236;
  --bg-active:       #28284A;
  --bg-input:        #1E1E30;

  --accent:          #6C63FF;
  --accent-light:    #8B84FF;
  --accent-dark:     #4A43CC;
  --accent-glow:     rgba(108,99,255,0.25);
  --teal:            #3ECFCF;
  --teal-glow:       rgba(62,207,207,0.20);

  --text-primary:    #E8E8F4;
  --text-secondary:  #9090B0;
  --text-muted:      #5C5C7A;
  --text-inverse:    #0D0D1A;

  --border:          rgba(255,255,255,0.06);
  --border-focus:    rgba(108,99,255,0.50);
  --shadow-sm:       0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:       0 8px 24px rgba(0,0,0,0.5);
  --shadow-lg:       0 16px 48px rgba(0,0,0,0.6);

  --radius-sm:       6px;
  --radius-md:       12px;
  --radius-lg:       20px;
  --radius-xl:       28px;
  --radius-full:     9999px;

  --font:            'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:       'JetBrains Mono', 'Fira Code', monospace;

  --sidebar-w:       300px;
  --header-h:        60px;
  --transition:      0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.32s cubic-bezier(0.4, 0, 0.2, 1);

  /* Bubble colours */
  --bubble-out-from:   #6C63FF;
  --bubble-out-to:     #3ECFCF;
  --bubble-in-bg:      #1E1E34;
  --bubble-in-border:  rgba(255,255,255,0.06);

  /* Status colours */
  --online:   #34D399;
  --away:     #FBBF24;
  --offline:  #4B5563;
  --error:    #F87171;
}

/* ── Hide reCAPTCHA badge once logged in ───────────────────── */
.app-shell ~ .grecaptcha-badge,
.view-app .grecaptcha-badge { visibility: hidden !important; }
body.app-active .grecaptcha-badge { visibility: hidden !important; }

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

html, body {
  height: 100%; height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100vh; height: 100dvh;   /* dvh accounts for mobile browser chrome */
  width: 100vw;
  display: flex; overflow: hidden;
  /* Safe-area insets for notched phones and status bars */
  padding-top:    env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left:   env(safe-area-inset-left);
  padding-right:  env(safe-area-inset-right);
}

/* ── Utility ────────────────────────────────────────────────── */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ════════════════════════════════════════════════════════════════
   SPLASH SCREEN
   ════════════════════════════════════════════════════════════════ */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: var(--bg-base);
  transition: opacity var(--transition-slow);
}
.splash.fade-out { opacity: 0; pointer-events: none; }
.splash__logo {
  animation: logoFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 24px var(--accent-glow));
}
.splash__name {
  font-size: 1.25rem; font-weight: 600;
  color: var(--text-secondary); letter-spacing: 0.05em;
}
.splash__spinner {
  width: 28px; height: 28px; margin-top: 8px;
  border: 2.5px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════════
   AUTH SCREENS
   ════════════════════════════════════════════════════════════════ */
.view { flex: 1; display: flex; align-items: safe center; justify-content: center; overflow-y: auto; }

.auth-screen {
  width: 100%; max-width: 420px;
  padding: 32px 24px;
  margin: auto 0;
  flex-shrink: 0;
  animation: fadeSlideUp 0.3s var(--transition);
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}

.auth-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px;
}
.auth-logo svg { filter: drop-shadow(0 0 12px var(--accent-glow)); }
.auth-logo h1  { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }

.auth-tabs {
  display: flex; gap: 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab {
  flex: 1; padding: 8px 16px;
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary);
  background: none; border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.auth-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary);
}
.form-input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem; font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-muted); }

.form-error {
  margin-top: 4px; font-size: 0.8125rem;
  color: var(--error);
}

.btn-primary {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none; border-radius: var(--radius-md);
  color: #fff; font-size: 0.9375rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  box-shadow: 0 4px 16px var(--accent-glow);
  margin-top: 8px; position: relative; overflow: hidden;
}
.btn-primary::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.08));
  opacity: 0; transition: opacity var(--transition);
}
.btn-primary:hover  { transform: translateY(-1px); box-shadow: 0 6px 24px var(--accent-glow); }
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary .btn-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle; margin-right: 8px;
}

/* ════════════════════════════════════════════════════════════════
   APP SHELL
   ════════════════════════════════════════════════════════════════ */
.app-shell {
  display: flex; flex: 1; width: 100%;
  overflow: hidden;
  animation: fadeIn 0.2s ease;
}

/* ════════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.sidebar__header {
  height: var(--header-h);
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar__user {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; border-radius: var(--radius-md);
  padding: 6px 8px; margin-left: -8px;
  transition: background var(--transition);
}
.sidebar__user:hover { background: var(--bg-hover); }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem; font-weight: 700;
  flex-shrink: 0;
  position: relative;
}
.avatar--gradient {
  background: linear-gradient(135deg, var(--accent), var(--teal));
  color: #fff;
}
.avatar--sm  { width: 28px; height: 28px; font-size: 0.75rem; }
.avatar--lg  { width: 44px; height: 44px; font-size: 1rem; }
.avatar--xl  { width: 52px; height: 52px; font-size: 1.125rem; }

.avatar__status {
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--bg-surface);
  background: var(--offline);
}
.avatar__status--online { background: var(--online); }
.avatar__status--away   { background: var(--away); }

.sidebar__username {
  font-size: 0.875rem; font-weight: 600;
  color: var(--text-primary);
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: var(--radius-md);
  color: var(--text-secondary); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Search bar ─────────────────────────────────────────────── */
.sidebar__search {
  padding: 12px 12px 8px;
  flex-shrink: 0;
}
.sidebar__search input {
  width: 100%; padding: 9px 14px;
  background: var(--bg-input);
  border: 1.5px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-primary); font-size: 0.875rem;
  font-family: var(--font); outline: none;
  transition: border-color var(--transition);
}
.sidebar__search input:focus { border-color: var(--accent); }
.sidebar__search input::placeholder { color: var(--text-muted); }

/* ── Conversation list ──────────────────────────────────────── */
.conversation-list {
  list-style: none; overflow-y: auto; flex: 1;
  padding: 4px 0 8px;
}
.conversation-list::-webkit-scrollbar { width: 4px; }
.conversation-list::-webkit-scrollbar-track { background: transparent; }
.conversation-list::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 4px; }

.sidebar__branding {
  padding: 10px 16px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar__branding a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
.sidebar__branding a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.sidebar__branding strong {
  color: var(--text-primary);
}

.conv-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: var(--radius-md);
  margin: 0 6px;
  transition: background var(--transition);
  position: relative;
}
.conv-item:hover   { background: var(--bg-hover); }
.conv-item.active  { background: var(--bg-active); }
.conv-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%;
  transform: translateY(-50%); width: 3px; height: 60%;
  background: linear-gradient(to bottom, var(--accent), var(--teal));
  border-radius: 0 2px 2px 0;
}

.conv-item__body   { flex: 1; min-width: 0; }
.conv-item__top    { display: flex; align-items: center; justify-content: space-between; }
.conv-item__name   { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.conv-item__time   { font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0; }
.conv-item__preview {
  font-size: 0.8125rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px; margin-top: 2px;
}
.conv-item__badge {
  background: var(--accent);
  color: #fff; font-size: 0.6875rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════════
   CHAT PANEL
   ════════════════════════════════════════════════════════════════ */
.chat-panel {
  flex: 1; display: flex;
  align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}

/* ── Empty state ────────────────────────────────────────────── */
.chat-empty {
  display: flex; flex-direction: column;
  align-items: center; text-align: center; gap: 12px;
  padding: 40px 20px;
  animation: fadeIn 0.3s ease;
}
.chat-empty__icon { opacity: 0.2; margin-bottom: 8px; }
.chat-empty h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-secondary); }
.chat-empty p  { font-size: 0.875rem; color: var(--text-muted); }

/* ── Chat view ──────────────────────────────────────────────── */
.chat-view {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  animation: fadeIn 0.2s ease;
}

/* Header */
.chat-header {
  height: var(--header-h);
  padding: 0 20px;
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-header__info { flex: 1; min-width: 0; }
.chat-header__name {
  font-size: 1rem; font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-header__status {
  font-size: 0.8125rem; color: var(--text-secondary);
}
.chat-header__status.online { color: var(--online); }
.chat-header__actions { display: flex; gap: 4px; }

/* Back button — hidden by default, shown only on narrow screens via media query */
.chat-header__back {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  margin-right: 8px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.chat-header__back:active { background: var(--bg-hover); }

/* Messages area */
.messages-area {
  flex: 1; overflow-y: auto;
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 3px;
  scroll-behavior: smooth;
}
.messages-area::-webkit-scrollbar { width: 5px; }
.messages-area::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 4px; }

/* Date separator */
.date-separator {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0 8px;
}
.date-separator::before,
.date-separator::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border);
}
.date-separator span {
  font-size: 0.75rem; color: var(--text-muted); white-space: nowrap;
}

/* Message bubbles */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 72%;
  animation: msgPop 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.msg-row--out {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-row--in  { align-self: flex-start; }

/* Group consecutive messages */
.msg-row--in + .msg-row--in   { margin-top: 2px; }
.msg-row--out + .msg-row--out { margin-top: 2px; }
.msg-row--in + .msg-row--out,
.msg-row--out + .msg-row--in  { margin-top: 10px; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Outgoing */
.msg-row--out .msg-bubble {
  background: linear-gradient(135deg, var(--bubble-out-from), var(--bubble-out-to));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* Incoming */
.msg-row--in .msg-bubble {
  background: var(--bubble-in-bg);
  color: var(--text-primary);
  border: 1px solid var(--bubble-in-border);
  border-bottom-left-radius: 4px;
}

/* Remove adjacent tail */
.msg-row--out + .msg-row--out .msg-bubble { border-bottom-right-radius: var(--radius-lg); }
.msg-row--in  + .msg-row--in  .msg-bubble { border-bottom-left-radius: var(--radius-lg); }

.msg-meta {
  display: flex; align-items: center; gap: 5px;
  margin-top: 4px; justify-content: flex-end;
}
.msg-row--in .msg-meta { justify-content: flex-start; }
.msg-time {
  font-size: 0.6875rem; color: rgba(255,255,255,0.55);
  flex-shrink: 0;
}
.msg-row--in .msg-time { color: var(--text-muted); }
.msg-status--delivered svg path:last-child { opacity: 1; }

/* ── E2E indicator ──────────────────────────────────────────── */
.e2e-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: rgba(62,207,207,0.08);
  border: 1px solid rgba(62,207,207,0.15);
  border-radius: var(--radius-full);
  font-size: 0.75rem; color: var(--teal);
  align-self: center; margin: 8px 0;
}
.e2e-badge svg { flex-shrink: 0; }

/* ── Typing indicator ───────────────────────────────────────── */
.typing-row {
  display: flex; align-self: flex-start;
  margin-top: 4px;
}
.typing-bubble {
  background: var(--bubble-in-bg);
  border: 1px solid var(--bubble-in-border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 4px;
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }

/* ── Input bar ──────────────────────────────────────────────── */
.input-bar {
  padding: 12px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: flex-end; gap: 10px;
  flex-shrink: 0;
}

.input-wrap {
  flex: 1; position: relative;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex; align-items: flex-end;
  padding: 4px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.msg-input {
  flex: 1; min-height: 38px; max-height: 160px;
  background: none; border: none; outline: none; resize: none;
  color: var(--text-primary); font-size: 0.9375rem;
  font-family: var(--font); line-height: 1.5;
  padding: 8px 0;
  scrollbar-width: none;
}
.msg-input::placeholder { color: var(--text-muted); }
.msg-input::-webkit-scrollbar { display: none; }

.btn-send {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 12px var(--accent-glow);
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.btn-send:hover  { transform: scale(1.08); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-send:active { transform: scale(0.96); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ════════════════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal {
  width: 440px; max-width: calc(100vw - 32px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeSlideUp 0.2s ease;
}
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 14px;
}
.modal__header h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.modal__search { padding: 0 16px 12px; }
.modal__search input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-size: 0.9375rem; font-family: var(--font); outline: none;
  transition: border-color var(--transition);
}
.modal__search input:focus { border-color: var(--accent); }
.modal__search input::placeholder { color: var(--text-muted); }

.user-search-results {
  list-style: none; max-height: min(50vh, 400px); overflow-y: auto;
  padding: 0 8px 12px;
}
.user-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}
.user-result-item:hover { background: var(--bg-hover); }
.user-result-item__info { flex: 1; min-width: 0; }
.user-result-item__name {
  font-size: 0.9375rem; font-weight: 600;
  color: var(--text-primary);
}
.user-result-item__handle {
  font-size: 0.8125rem; color: var(--text-secondary);
}
.user-result-item__status {
  font-size: 0.75rem; color: var(--online);
}

/* ── Search states ──────────────────────────────────────────── */
.search-placeholder {
  padding: 24px 16px; text-align: center;
  color: var(--text-muted); font-size: 0.875rem;
}

/* ════════════════════════════════════════════════════════════════
   CONVERSATION REQUEST BANNER
   ════════════════════════════════════════════════════════════════ */
.conv-request-banner {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  animation: slideDown 0.25s ease-out;
}
.conv-request-banner__text {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-secondary); font-size: 0.9rem;
}
.conv-request-banner__text svg { color: var(--accent); flex-shrink: 0; }
.conv-request-banner__text strong { color: var(--text-primary); }
.conv-request-banner__actions {
  display: flex; gap: 8px;
}
.conv-request-banner .btn {
  padding: 6px 18px; border-radius: 8px; border: none;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.conv-request-banner .btn:active { transform: scale(0.96); }
.conv-request-banner .btn--accept {
  background: var(--accent); color: #fff;
}
.conv-request-banner .btn--accept:hover { filter: brightness(1.15); }
.conv-request-banner .btn--decline {
  background: var(--bg-surface); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.conv-request-banner .btn--decline:hover { background: var(--bg-elevated); }
.conv-request-banner .btn--block {
  background: transparent; color: #ef4444;
  border: 1px solid #ef4444;
}
.conv-request-banner .btn--block:hover { background: rgba(239,68,68,0.1); }

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

/* ════════════════════════════════════════════════════════════════
   TOASTS
   ════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 900;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem; color: var(--text-primary);
  pointer-events: all;
  animation: toastIn 0.2s ease;
  max-width: 320px;
}
.toast--success { border-left: 3px solid var(--online); }
.toast--error   { border-left: 3px solid var(--error); }
.toast--info    { border-left: 3px solid var(--accent); }
.toast.fade-out { animation: toastOut 0.2s ease forwards; }

/* ════════════════════════════════════════════════════════════════
   CONNECTION BADGE
   ════════════════════════════════════════════════════════════════ */
.connection-badge {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 800;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  background: rgba(251,191,36,0.15);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: var(--radius-full);
  font-size: 0.8125rem; color: var(--away);
  animation: fadeSlideDown 0.2s ease;
}
.connection-badge__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--away);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ════════════════════════════════════════════════════════════════
   EMPTY / LOADING STATES
   ════════════════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-hover) 25%,
    var(--bg-active) 50%,
    var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
.skeleton--text  { height: 14px; margin-bottom: 8px; }
.skeleton--circle { border-radius: 50%; }

.loading-messages {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 16px;
}
.loading-msg {
  display: flex; gap: 10px; align-items: flex-start;
}
.loading-msg--out { flex-direction: row-reverse; }

/* ════════════════════════════════════════════════════════════════
   SCROLLBAR (global)
   ════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }

/* ════════════════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════════════════ */
@keyframes fadeIn        { from { opacity: 0; }          to { opacity: 1; } }
@keyframes fadeSlideUp   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fadeSlideDown { from { opacity: 0; transform: translateY(-8px) translateX(-50%); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes msgPop        { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes typingBounce  { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }
@keyframes pulse         { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes shimmer       { to { background-position: -200% 0; } }
@keyframes toastIn       { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut      { to   { opacity: 0; transform: translateX(20px); } }

/* ════════════════════════════════════════════════════════════════
   SIDEBAR ACTIONS
   ════════════════════════════════════════════════════════════════ */
.sidebar__actions {
  display: flex; gap: 2px;
}

/* ════════════════════════════════════════════════════════════════
   USER MENU (dropdown)
   ════════════════════════════════════════════════════════════════ */
.user-menu {
  position: fixed; z-index: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  min-width: 180px;
  animation: fadeSlideUp 0.15s ease;
}
.user-menu__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 16px;
  background: none; border: none; cursor: pointer;
  color: var(--text-primary); font-size: 0.875rem;
  font-family: var(--font);
  transition: background var(--transition);
}
.user-menu__item:hover { background: var(--bg-hover); }
.user-menu__item svg   { color: var(--text-secondary); flex-shrink: 0; }

/* ════════════════════════════════════════════════════════════════
   MODAL TABS
   ════════════════════════════════════════════════════════════════ */
.modal--wide { width: 520px; }
.modal__tabs {
  display: flex; gap: 4px;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-tab {
  padding: 8px 14px;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary);
  background: none; border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-tab.active {
  background: var(--accent);
  color: #fff;
}
.modal__body {
  padding: 12px 16px;
  max-height: min(60vh, 500px);
  overflow-y: auto;
}
.tab-panel { animation: fadeIn 0.15s ease; }

/* ════════════════════════════════════════════════════════════════
   CONNECTION & BLOCK LIST ITEMS
   ════════════════════════════════════════════════════════════════ */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}
.list-item:hover { background: var(--bg-hover); }
.list-item__info { flex: 1; min-width: 0; }
.list-item__name {
  font-size: 0.9375rem; font-weight: 600;
  color: var(--text-primary);
}
.list-item__sub {
  font-size: 0.8125rem; color: var(--text-secondary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem; font-weight: 500;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
  font-family: var(--font);
}
.btn-sm--accept {
  background: var(--online); color: #fff;
}
.btn-sm--accept:hover { opacity: 0.85; }
.btn-sm--reject, .btn-sm--remove, .btn-sm--unblock {
  background: var(--bg-hover); color: var(--text-secondary);
}
.btn-sm--reject:hover, .btn-sm--remove:hover { background: var(--error); color: #fff; }
.btn-sm--unblock:hover { background: var(--accent); color: #fff; }
.btn-sm--msg {
  background: var(--accent); color: #fff;
}
.btn-sm--msg:hover { background: var(--accent-light); color: #fff; }
.btn-sm--block {
  background: var(--bg-hover); color: var(--text-secondary);
}
.btn-sm--block:hover { background: var(--error); color: #fff; }

.list-item__actions { display: flex; gap: 6px; flex-shrink: 0; }

.btn-sm--send-request {
  background: var(--accent); color: #fff;
}
.btn-sm--send-request:hover { opacity: 0.85; }

/* ════════════════════════════════════════════════════════════════
   CHAT INPUT ACTIONS (location, attach)
   ════════════════════════════════════════════════════════════════ */
.input-actions {
  display: flex; gap: 2px; flex-shrink: 0;
}
.input-action-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 50%;
  color: var(--text-secondary); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.input-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ════════════════════════════════════════════════════════════════
   PRIVACY NOTICE on Registration
   ════════════════════════════════════════════════════════════════ */
.privacy-notice {
  background: rgba(62, 207, 207, 0.08);
  border: 1px solid rgba(62, 207, 207, 0.15);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 20px;
  font-size: 0.8125rem;
  color: var(--teal);
  line-height: 1.5;
}
.privacy-notice strong { color: var(--text-primary); font-weight: 600; }

.form-hint {
  font-size: 0.75rem; color: var(--text-muted);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════════════════
   LOCATION MESSAGE PREVIEW
   ════════════════════════════════════════════════════════════════ */
.location-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--teal); text-decoration: none;
}
.location-link:hover { text-decoration: underline; }

/* ════════════════════════════════════════════════════════════════
   MESSAGE STATUS COLORS (overrides)
   ════════════════════════════════════════════════════════════════ */
.msg-status { display: flex; color: rgba(255,255,255,0.55); }
.msg-status--delivered { color: rgba(255,255,255,0.9); }
.msg-status--read svg { color: #3ECFCF; }

/* ════════════════════════════════════════════════════════════════
   ACCOUNT RECOVERY
   ════════════════════════════════════════════════════════════════ */
.forgot-link {
  font-size: 0.8125rem; color: var(--accent-light);
  text-decoration: none; transition: color var(--transition);
}
.forgot-link:hover { color: var(--teal); text-decoration: underline; }

.recovery-options {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 4px;
}
.recovery-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer; transition: border-color var(--transition);
  font-size: 0.9375rem; color: var(--text-secondary);
}
.recovery-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(108,99,255,0.08);
}
.recovery-option input[type="radio"] {
  accent-color: var(--accent);
}
.recovery-option strong { color: var(--text-primary); }

.recovery-info {
  font-size: 0.9375rem; color: var(--text-secondary);
  line-height: 1.6; margin-bottom: 16px;
}

.code-input {
  text-align: center; font-size: 1.5rem;
  letter-spacing: 8px; font-weight: 700;
  font-family: var(--font-mono);
}

.recovery-success {
  text-align: center; padding: 20px 0;
}
.recovered-username {
  font-size: 1.5rem; font-weight: 800;
  color: var(--accent-light);
  margin-top: 8px;
  font-family: var(--font-mono);
  letter-spacing: 1px;
}

/* ════════════════════════════════════════════════════════════════
   MESSAGE CONTEXT MENU (long-press)
   ════════════════════════════════════════════════════════════════ */
.msg-context-menu {
  position: absolute;
  z-index: 700;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  animation: ctxPop 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.msg-context-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 50%;
  cursor: pointer; font-size: 1.25rem;
  transition: background var(--transition), transform var(--transition);
  position: relative;
}
.msg-context-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.15);
}
.msg-context-btn:active {
  transform: scale(0.95);
}
.msg-context-btn .ctx-tooltip {
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.6875rem; color: var(--text-secondary);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--transition);
}
.msg-context-btn:hover .ctx-tooltip { opacity: 1; }

.msg-context-separator {
  width: 1px; height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* Reaction badge on bubble */
.msg-reactions {
  display: flex; gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.msg-reaction-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  cursor: default;
  animation: ctxPop 0.2s ease;
}
.msg-reaction-badge .reaction-emoji { font-size: 0.9375rem; }
.msg-reaction-badge .reaction-count {
  font-size: 0.6875rem; color: var(--text-secondary); font-weight: 600;
}

/* Highlight bubble on long-press */
.msg-bubble--highlighted {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@keyframes ctxPop {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── File messages ──────────────────────────────────────────────────────────── */
.msg-bubble--file { padding: 6px 8px; }
.msg-file { display: flex; align-items: center; gap: 10px; }
.msg-file--image { flex-direction: column; gap: 4px; }
.msg-file__preview {
  max-width: 260px; max-height: 200px;
  border-radius: var(--radius-md);
  object-fit: cover; display: block;
  cursor: pointer;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
.msg-file__fallback {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; opacity: 0.7;
}
.msg-file__info {
  font-size: 0.75rem; opacity: 0.7;
  padding: 0 4px;
}
.msg-file__icon { font-size: 1.5rem; flex-shrink: 0; }
.msg-file__details { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg-file__name {
  font-size: 0.875rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
.msg-file__size { font-size: 0.75rem; opacity: 0.7; }
.msg-file__download {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: none; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,0.15); color: inherit;
  flex-shrink: 0; transition: background 0.15s;
}
.msg-file__download:hover { background: rgba(255,255,255,0.3); }
.msg-row--in .msg-file__download { background: var(--bg-hover); }
.msg-row--in .msg-file__download:hover { background: var(--border); }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE – narrow (mobile / small Android)
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  :root { --sidebar-w: 100vw; }

  .app-shell          { position: relative; overflow: hidden; height: 100%; }

  /* Sidebar & chat each take full width; only one visible at a time */
  .sidebar {
    position: absolute; z-index: 10; width: 100%; height: 100%;
    left: 0; top: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.mobile-hidden {
    transform: translateX(-100%);
    pointer-events: none;
  }

  .chat-panel {
    width: 100%;
    position: absolute; left: 0; top: 0; height: 100%;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  /* When no chat is open, push chat panel off-screen right */
  .chat-panel.mobile-hidden {
    transform: translateX(100%);
    pointer-events: none;
  }

  /* Back button — only visible on narrow screens */
  .chat-header__back {
    display: flex !important;
  }
  .chat-header__back:active { background: var(--bg-hover); }

  .auth-card          { padding: 28px 20px; }
  .msg-row            { max-width: 90%; }
}

/* ════════════════════════════════════════════════════════════════
   SETTINGS
   ════════════════════════════════════════════════════════════════ */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row__label { flex: 1; margin-right: 16px; }
.settings-row__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.settings-row__desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-hover);
  border-radius: 24px;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* Settings row vertical variant (for theme picker) */
.settings-row--vertical {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

/* Theme picker */
.theme-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: inherit;
}
.theme-swatch:hover {
  border-color: var(--border-focus);
  transform: scale(1.05);
}
.theme-swatch.active {
  border-color: var(--accent);
}
.theme-swatch__preview {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.theme-swatch__name {
  white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════════
   THEMES
   ════════════════════════════════════════════════════════════════ */

/* ── Blossom (pink) ──────────────────────────────────────────── */
[data-theme="pink"] {
  --bg-base:         #1A0A14;
  --bg-surface:      #1F0E19;
  --bg-elevated:     #2A1422;
  --bg-hover:        #36192D;
  --bg-active:       #421E38;
  --bg-input:        #251220;

  --accent:          #E91E8C;
  --accent-light:    #F472B6;
  --accent-dark:     #BE185D;
  --accent-glow:     rgba(233,30,140,0.25);
  --teal:            #F9A8D4;
  --teal-glow:       rgba(249,168,212,0.20);

  --text-primary:    #F8E8F2;
  --text-secondary:  #B890A8;
  --text-muted:      #7A5C6A;

  --border:          rgba(255,255,255,0.06);
  --border-focus:    rgba(233,30,140,0.50);

  --bubble-out-from: #E91E8C;
  --bubble-out-to:   #F472B6;
  --bubble-in-bg:    #2A1422;
  --bubble-in-border:rgba(255,255,255,0.06);
}

/* ── Sunbeam (yellow) ────────────────────────────────────────── */
[data-theme="yellow"] {
  --bg-base:         #1A1608;
  --bg-surface:      #201C0E;
  --bg-elevated:     #2A2614;
  --bg-hover:        #36301C;
  --bg-active:       #423A24;
  --bg-input:        #252010;

  --accent:          #F59E0B;
  --accent-light:    #FBBF24;
  --accent-dark:     #D97706;
  --accent-glow:     rgba(245,158,11,0.25);
  --teal:            #FCD34D;
  --teal-glow:       rgba(252,211,77,0.20);

  --text-primary:    #F8F0E0;
  --text-secondary:  #B8A880;
  --text-muted:      #7A6C50;

  --border:          rgba(255,255,255,0.06);
  --border-focus:    rgba(245,158,11,0.50);

  --bubble-out-from: #F59E0B;
  --bubble-out-to:   #FBBF24;
  --bubble-in-bg:    #2A2614;
  --bubble-in-border:rgba(255,255,255,0.06);
}

/* ── Daylight (white/light) ──────────────────────────────────── */
[data-theme="light"] {
  --bg-base:         #F5F5F7;
  --bg-surface:      #FFFFFF;
  --bg-elevated:     #EEEEF0;
  --bg-hover:        #E4E4E8;
  --bg-active:       #D8D8DE;
  --bg-input:        #EEEEF2;

  --accent:          #6C63FF;
  --accent-light:    #8B84FF;
  --accent-dark:     #4A43CC;
  --accent-glow:     rgba(108,99,255,0.15);
  --teal:            #0D9488;
  --teal-glow:       rgba(13,148,136,0.12);

  --text-primary:    #1A1A2E;
  --text-secondary:  #5C5C7A;
  --text-muted:      #9090A0;
  --text-inverse:    #FFFFFF;

  --border:          rgba(0,0,0,0.08);
  --border-focus:    rgba(108,99,255,0.50);
  --shadow-sm:       0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:       0 8px 24px rgba(0,0,0,0.10);
  --shadow-lg:       0 16px 48px rgba(0,0,0,0.12);

  --bubble-out-from: #6C63FF;
  --bubble-out-to:   #3ECFCF;
  --bubble-in-bg:    #EEEEF2;
  --bubble-in-border:rgba(0,0,0,0.06);

  --online:   #059669;
  --error:    #DC2626;
}

/* ── Claude ──────────────────────────────────────────────────── */
[data-theme="claude"] {
  --bg-base:         #1A1410;
  --bg-surface:      #201A14;
  --bg-elevated:     #2C241C;
  --bg-hover:        #382E24;
  --bg-active:       #44382C;
  --bg-input:        #261E16;

  --accent:          #D97757;
  --accent-light:    #E8956E;
  --accent-dark:     #BF5C3A;
  --accent-glow:     rgba(217,119,87,0.25);
  --teal:            #E8B88A;
  --teal-glow:       rgba(232,184,138,0.20);

  --text-primary:    #F0E6DA;
  --text-secondary:  #B8A890;
  --text-muted:      #7A6C58;

  --border:          rgba(255,255,255,0.06);
  --border-focus:    rgba(217,119,87,0.50);

  --bubble-out-from: #D97757;
  --bubble-out-to:   #E8B88A;
  --bubble-in-bg:    #2C241C;
  --bubble-in-border:rgba(255,255,255,0.06);
}
