/* ============================================================
   PepeChat 🐸 — Design System & Main Styles
   Glassmorphism | Frog-green | Vanilla CSS
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Accent — Frog Green Neon */
  --accent: #32e67a;
  --accent-hover: #28c767;
  --accent-light: rgba(50, 230, 122, 0.18);
  --accent-glow: 0 0 20px rgba(50, 230, 122, 0.5);
  --accent-border: rgba(50, 230, 122, 0.3);

  /* Glass Effects */
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shimmer: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.05) 100%);

  /* Danger */
  --danger: #f05252;
  --danger-hover: #d63030;
  --danger-light: rgba(240, 82, 82, 0.15);

  /* Success */
  --success: #2dce6c;
  --success-light: rgba(45, 206, 108, 0.15);

  /* Typography */
  --font: 'Inter', system-ui, sans-serif;
  --text-xs: 0.7rem;
  --text-sm: 0.8rem;
  --text-md: 0.9rem;
  --text-base: 1rem;
  --text-lg: 1.1rem;
  --text-xl: 1.3rem;
  --text-2xl: 1.6rem;

  /* Timing */
  --transition: 0.3s ease-out;
  --transition-fast: 0.15s ease-out;

  /* Radius */
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Blur */
  --blur: blur(15px);
  --blur-sm: blur(8px);
}

/* ── Dark Theme (default) ──────────────────────────────────── */
[data-theme="dark"] {
  --bg-app: #0c1a10;
  --bg-sidebar: rgba(10, 22, 13, 0.95);
  --bg-chat: #111e14;
  --bg-header: rgba(10, 22, 13, 0.92);
  --bg-input: rgba(255,255,255,0.06);
  --bg-input-hover: rgba(255,255,255,0.1);
  --bg-hover: rgba(45, 206, 108, 0.06);
  --bg-active: rgba(45, 206, 108, 0.15);
  --bg-message-in: #1a2e1e;
  --bg-message-out: #1a3d26;
  --bg-bubble: rgba(12, 26, 16, 0.88);
  --bg-modal: rgba(10, 22, 13, 0.98);
  --bg-card: rgba(20, 40, 25, 0.92);
  --bg-toast: rgba(18, 36, 22, 0.97);
  --bg-context: rgba(12, 26, 16, 0.99);

  --border: rgba(45, 206, 108, 0.1);
  --border-active: rgba(45, 206, 108, 0.45);

  --text-primary: #e2f0e6;
  --text-secondary: #7a9982;
  --text-muted: #3d5944;
  --text-accent: #2dce6c;

  --shadow: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.35);
  --shadow-glow: 0 0 24px rgba(45, 206, 108, 0.2);

  --scrollbar-thumb: rgba(45, 206, 108, 0.15);
  --scrollbar-thumb-hover: rgba(45, 206, 108, 0.3);
}

/* ── Light Theme ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg-app: #eef7f0;
  --bg-sidebar: rgba(255, 255, 255, 0.94);
  --bg-chat: #f7faf8;
  --bg-header: rgba(255, 255, 255, 0.92);
  --bg-input: rgba(0,0,0,0.05);
  --bg-input-hover: rgba(0,0,0,0.08);
  --bg-hover: rgba(45, 206, 108, 0.07);
  --bg-active: rgba(45, 206, 108, 0.12);
  --bg-message-in: #ffffff;
  --bg-message-out: #dcf8c6;
  --bg-bubble: rgba(255, 255, 255, 0.92);
  --bg-modal: rgba(246, 252, 248, 0.99);
  --bg-card: rgba(255, 255, 255, 0.97);
  --bg-toast: rgba(255, 255, 255, 0.97);
  --bg-context: rgba(248, 254, 250, 0.99);

  --border: rgba(45, 206, 108, 0.15);
  --border-active: rgba(45, 206, 108, 0.45);

  --text-primary: #0f2017;
  --text-secondary: #4d7259;
  --text-muted: #8aab95;
  --text-accent: #22a558;

  --shadow: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-glow: 0 0 20px rgba(45, 206, 108, 0.2);

  --scrollbar-thumb: rgba(45, 206, 108, 0.2);
  --scrollbar-thumb-hover: rgba(45, 206, 108, 0.35);
}

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

html { font-size: 16px; height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* ── Typing Animation ───────────────────────────────────────── */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.4;
  animation: typingBounce 1.4s 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: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* ── Frog Emojis (Background & Rain) ───────────────────────── */
.frog-emoji {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  user-select: none;
  animation: frogFloat var(--float-duration, 10s) linear forwards;
}

#frog-bg .frog-emoji {
  z-index: -1;
  animation: none; /* background frogs are static or have distinct drift */
}

@keyframes frogFloat {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  100% {
    transform: translate(var(--float-x, 100px), 110vh) rotate(360deg);
  }
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ── Auth Screen ───────────────────────────────────────────── */
#auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  z-index: 1000;
  padding: 1rem;
}

#auth-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 15% 20%, rgba(45,206,108,0.14) 0%, transparent 55%),
    radial-gradient(ellipse 60% 80% at 85% 80%, rgba(45,206,108,0.09) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(45,206,108,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  background: var(--bg-bubble);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  position: relative;
  animation: slideUp 0.4s ease-out;
}

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

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(145deg, #2dce6c, #1a9e4e);
  border-radius: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 32px rgba(45,206,108,0.45), 0 0 0 4px rgba(45,206,108,0.12);
  animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

.auth-logo h1 {
  font-size: var(--text-2xl);
  font-weight: 800;
  background: linear-gradient(135deg, #2dce6c, #7ee8a2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-top: 0.25rem;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 1.75rem;
}

.auth-tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: calc(var(--radius) - 4px);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font);
  transition: all var(--transition-fast);
}

.auth-tab.active {
  background: linear-gradient(135deg, #2dce6c, #22b85a);
  color: #fff;
  box-shadow: 0 2px 10px rgba(45,206,108,0.45);
}

/* Forms */
.auth-form { display: none; flex-direction: column; gap: 1rem; }
.auth-form.active { display: flex; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: var(--text-md);
  color: var(--text-primary);
  font-family: var(--font);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent);
  background: var(--bg-input-hover);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input.error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-light); }
.form-input.success { border-color: var(--success); }

.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
  display: none;
  align-items: center;
  gap: 0.3rem;
}
.form-error.visible { display: flex; }

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.password-wrapper {
  position: relative;
}

.password-wrapper .form-input { padding-right: 3rem; }

.password-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  transition: color var(--transition-fast);
}
.password-toggle:hover { color: var(--accent); }

/* Password Strength */
.password-strength {
  display: flex;
  gap: 4px;
  margin-top: 0.4rem;
}

.strength-bar {
  flex: 1;
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--border);
  transition: background var(--transition-fast);
}
.strength-bar.weak   { background: #e53e3e; }
.strength-bar.medium { background: #d69e2e; }
.strength-bar.strong { background: #38a169; }

/* Buttons */
.btn {
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: var(--text-md);
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.btn:active::after { opacity: 1; }

.btn-primary {
  background: linear-gradient(135deg, #2dce6c, #1aaa55);
  color: #fff;
  box-shadow: 0 4px 18px rgba(45,206,108,0.4);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(45,206,108,0.55);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-input-hover); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #c53030);
  color: #fff;
  box-shadow: 0 4px 16px rgba(229,62,62,0.3);
}
.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(229,62,62,0.45);
}

.btn-warning {
  background: linear-gradient(135deg, #f6ad55, #ed8936);
  color: #fff;
  box-shadow: 0 4px 16px rgba(237,137,54,0.3);
}
.btn-warning:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(237,137,54,0.45);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-full { width: 100%; }

.hidden { display: none !important; }
.flex { display: flex !important; }
.flex-column { flex-direction: column !important; }

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.active { color: var(--accent); background: var(--accent-light); }

.btn-icon-sm { padding: 0.3rem; border-radius: var(--radius-sm); }

/* ── App Layout ────────────────────────────────────────────── */
#app {
  display: none;
  height: 100vh;
  overflow: hidden;
}

#app.visible { display: flex; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 30%;
  min-width: 280px;
  max-width: 420px;
  background: var(--bg-sidebar);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: transform var(--transition), background var(--transition);
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
  background-image: linear-gradient(135deg, rgba(50, 230, 122, 0.05) 0%, transparent 100%);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  position: relative;
  overflow: hidden;
}

.sidebar-header::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(50,230,122,0.1) 0%, transparent 40%);
  animation: headerGlow 8s infinite linear;
  pointer-events: none;
}

@keyframes headerGlow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.sidebar-logo {
  font-size: var(--text-lg);
  font-weight: 800;
  background: linear-gradient(135deg, #2dce6c, #7ee8a2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex: 1;
  letter-spacing: -0.01em;
}

/* Search */
.search-bar {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 0.55rem 0.75rem 0.55rem 2.25rem;
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-family: var(--font);
  outline: none;
  transition: all var(--transition-fast);
}

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

.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-input-hover);
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
}

.chat-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  text-align: center;
  gap: 1rem;
}

.chat-list-empty-icon {
  font-size: 4rem;
  opacity: 0.5;
}

.chat-list-empty h3 {
  color: var(--text-secondary);
  font-size: var(--text-md);
  font-weight: 500;
}

.chat-list-empty p {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Chat Item */
.chat-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
  border-radius: 0;
}

.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-input);
  position: relative;
}

.avatar-placeholder {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-md);
  flex-shrink: 0;
  color: #fff;
  text-transform: uppercase;
  overflow: hidden;
  position: relative;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.avatar-sm { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--text-lg); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--text-xl); }

/* Online indicator */
.avatar-wrapper { position: relative; flex-shrink: 0; }
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: var(--success);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-sidebar);
}

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

.chat-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.chat-item-name {
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-item.unread .chat-item-time { color: var(--accent); }

.chat-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-item-preview {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.unread-badge {
  min-width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #2dce6c, #1aaa55);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(45,206,108,0.5);
}

/* ── Chat Area ─────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  transition: background var(--transition);
  position: relative;
  overflow: hidden;
}

/* Chat placeholder */
.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
  text-align: center;
}

.chat-placeholder-icon { font-size: 5rem; opacity: 0.3; }
.chat-placeholder h2 { font-size: var(--text-xl); color: var(--text-secondary); }
.chat-placeholder p { font-size: var(--text-md); color: var(--text-muted); max-width: 320px; }

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-header);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 5;
}

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

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

.chat-header-name {
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.chat-header-status.online { color: var(--success); }

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

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar { width: 3px; }

/* Date Separator */
.date-separator {
  text-align: center;
  margin: 0.75rem 0;
  position: relative;
}

.date-separator span {
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-chat);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

/* Message */
.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: msgAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes msgAppear {
  from { opacity: 0; transform: translateY(12px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.message.out { align-self: flex-end; align-items: flex-end; }
.message.in  { align-self: flex-start; align-items: flex-start; }

.message.consecutive { margin-top: 2px; }
.message.consecutive .message-avatar { visibility: hidden; }

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.message.out .message-row { flex-direction: row-reverse; }

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-transform: uppercase;
}

.message-bubble {
  background: var(--bg-message-in);
  border-radius: 20px 20px 20px 4px;
  padding: 0.65rem 0.95rem;
  position: relative;
  max-width: 100%;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform 0.2s ease;
}

.message.out .message-bubble {
  background: linear-gradient(135deg, var(--bg-message-out), #1e4d30);
  border-radius: 20px 20px 4px 20px;
  border-color: var(--accent-border);
  color: #fff;
}

.message-bubble:hover {
  transform: scale(1.01);
}

.message-sender-name {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.message-text {
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.message-time {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.message-status {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.message-status.read { color: var(--accent); }

/* IMAGE Message */
.message-image {
  max-width: 280px;
  max-height: 300px;
  border-radius: var(--radius);
  object-fit: cover;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  display: block;
}
.message-image:hover { opacity: 0.9; }

/* VIDEO Message */
.message-video {
  max-width: 280px;
  max-height: 300px;
  border-radius: var(--radius);
  object-fit: cover;
  display: block;
}

/* VIDEO NOTE (круг) */
.video-note-wrapper {
  width: 200px;
  height: 200px;
  position: relative;
  cursor: pointer;
}

.video-note-circle {
  width: 200px;
  height: 200px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 3px solid var(--accent);
}

.video-note-circle video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-note-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-full);
  opacity: 0;
  transition: opacity var(--transition-fast);
  color: #fff;
  font-size: 2rem;
}
.video-note-wrapper:hover .video-note-play { opacity: 1; }

/* AUDIO Message */
.audio-message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 200px;
  padding: 0.25rem 0;
}

.audio-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.audio-btn:hover { background: var(--accent-hover); transform: scale(1.05); }

.audio-waveform {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
}

.waveform-bar {
  width: 3px;
  border-radius: var(--radius-full);
  background: var(--accent);
  opacity: 0.6;
  transition: height 0.1s ease;
}

.audio-duration {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg-message-in);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  animation: msgAppear 0.2s ease-out;
  margin-bottom: 0.25rem;
}

.typing-indicator.visible { display: flex; }

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: typingBounce 1.2s infinite;
}
.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); opacity: 0.5; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* Input Area */
.input-area {
  background: var(--bg-header);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.message-input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.1rem 0.5rem;
  transition: all var(--transition-fast);
  min-height: 44px;
  gap: 0.25rem;
}

.message-input-wrapper:focus-within {
  border-color: var(--accent);
  background: var(--bg-input-hover);
}

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-md);
  resize: none;
  max-height: 140px;
  min-height: 30px;
  padding: 0.45rem 0.25rem;
  line-height: 1.5;
  overflow-y: auto;
}

#message-input::placeholder { color: var(--text-muted); }

/* Voice Record Progress */
.voice-recording {
  display: none;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  padding: 0.45rem 0.5rem;
}
.voice-recording.visible { display: flex; }

.recording-dot {
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: var(--radius-full);
  animation: recordPulse 1s infinite;
  flex-shrink: 0;
}

@keyframes recordPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

.recording-time {
  font-size: var(--text-sm);
  color: var(--danger);
  font-weight: 500;
  flex: 1;
}

/* Send button */
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), #006fa8);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 12px rgba(0,136,204,0.4);
}
.send-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 4px 16px rgba(0,136,204,0.6);
}
.send-btn:active { transform: scale(0.96); }

/* Attach menu */
.attach-menu {
  position: absolute;
  bottom: 70px;
  left: 0.75rem;
  background: var(--bg-context);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.4rem;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  gap: 0.1rem;
  z-index: 20;
  min-width: 160px;
  animation: popIn 0.15s ease-out;
}
.attach-menu.visible { display: flex; }

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

.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border: none;
  background: none;
  font-family: var(--font);
  width: 100%;
  text-align: left;
}
.attach-menu-item:hover { background: var(--bg-hover); }

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

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

.modal-overlay.visible { display: flex; }

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease-out;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1.25rem;
  padding: 0.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color var(--transition-fast);
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { padding: 0 1.5rem 1.5rem; display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ── Settings Panel ────────────────────────────────────────── */
.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: min(360px, 100vw);
  height: 100%;
  background: var(--bg-modal);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--transition);
}

.settings-panel.visible { transform: translateX(0); }

.settings-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
}

.settings-header h2 { font-size: var(--text-lg); font-weight: 700; flex: 1; }

.settings-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.settings-username {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.settings-info {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.settings-body { flex: 1; overflow-y: auto; }

.settings-section {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.settings-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 1.25rem 0.5rem;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1.25rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.settings-item:hover { background: var(--bg-hover); }

.settings-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.settings-item-text { flex: 1; }
.settings-item-label { font-size: var(--text-md); color: var(--text-primary); }
.settings-item-desc  { font-size: var(--text-xs); color: var(--text-muted); }

.settings-toggle {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  flex-shrink: 0;
}
.settings-toggle.on { background: var(--accent); }
.settings-toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: var(--radius-full);
  top: 3px;
  left: 3px;
  transition: left var(--transition-fast);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.settings-toggle.on::after { left: calc(100% - 21px); }

/* ── Call Overlay ──────────────────────────────────────────── */
.call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 25, 0.95);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.call-overlay.visible { display: flex; }
.call-overlay.incoming { animation: fadeIn 0.3s ease-out; }

.call-avatar {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 0 0 8px rgba(255,255,255,0.1), 0 0 0 16px rgba(255,255,255,0.05);
  animation: callPulse 2s infinite;
}

@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(255,255,255,0.1), 0 0 0 16px rgba(255,255,255,0.05); }
  50%       { box-shadow: 0 0 0 12px rgba(255,255,255,0.07), 0 0 0 24px rgba(255,255,255,0.03); }
}

.call-name {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: #fff;
}

.call-status {
  font-size: var(--text-md);
  color: rgba(255,255,255,0.6);
}

.call-video-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  height: 60vh;
  background: #000;
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: none;
}
.call-video-container.visible { display: block; }

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#local-video {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 140px;
  border-radius: var(--radius);
  border: 2px solid rgba(255,255,255,0.3);
  object-fit: cover;
}

.call-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.call-btn {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all var(--transition-fast);
  color: #fff;
}

.call-btn:hover { transform: scale(1.1); }
.call-btn:active { transform: scale(0.95); }

.call-btn-accept { background: linear-gradient(135deg, #38a169, #276749); box-shadow: 0 4px 20px rgba(56,161,105,0.5); }
.call-btn-decline { background: linear-gradient(135deg, #e53e3e, #c53030); box-shadow: 0 4px 20px rgba(229,62,62,0.5); }
.call-btn-mute    { background: rgba(255,255,255,0.15); }
.call-btn-mute.active { background: rgba(229,62,62,0.4); }
.call-btn-cam     { background: rgba(255,255,255,0.15); }
.call-btn-cam.active  { background: rgba(229,62,62,0.4); }

/* ── Video Note Recording ──────────────────────────────────── */
.video-note-recorder {
  position: fixed;
  bottom: 80px;
  right: 1.5rem;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.video-note-recorder.visible { display: flex; }

.vn-preview-wrapper {
  width: 160px;
  height: 160px;
  position: relative;
}

.vn-preview {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 3px solid var(--accent);
}

.vn-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

/* Circular progress bar */
.vn-progress-ring {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  transform: rotate(-90deg);
}

.vn-progress-ring circle {
  fill: none;
  stroke: var(--danger);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 502;
  stroke-dashoffset: 502;
  transition: stroke-dashoffset 0.1s linear;
}

.vn-controls {
  display: flex;
  gap: 1rem;
}

/* ── Toast Notifications ───────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  align-items: center;
}

.toast {
  background: var(--bg-toast);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1.25rem;
  font-size: var(--text-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  animation: toastIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.error  { border-color: var(--danger); text-shadow: 0 0 10px rgba(229, 62, 62, 0.3); }
.toast.success{ border-color: var(--success); text-shadow: 0 0 10px rgba(56, 161, 105, 0.3); }
.toast.warning{ border-color: #d69e2e; text-shadow: 0 0 10px rgba(214, 158, 46, 0.3); }

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


/* ── Lightbox ──────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.2s ease-out;
}

.lightbox.visible { display: flex; }

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.lightbox-close:hover { background: rgba(229, 62, 62, 0.5); }

#lightbox-content {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-content img,
#lightbox-content video {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

/* ── Audio Styles Fix ─────────────────────────────────────── */
.waveform-bar.active {
  background: #fff;
  opacity: 1;
}

/* ── Video Note Styles Fix ────────────────────────────────── */
.video-note-circle video {
  transition: transform 0.3s ease;
}
.video-note-wrapper:active .video-note-circle {
  transform: scale(0.95);
}

/* ── Offline Banner ────────────────────────────────────────── */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #d69e2e;
  color: #fff;
  text-align: center;
  padding: 0.4rem;
  font-size: var(--text-sm);
  font-weight: 500;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform var(--transition);
}
.offline-banner.visible { transform: translateY(0); }

/* ── Context Menu ──────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--bg-context);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem;
  z-index: 500;
  display: none;
  flex-direction: column;
  gap: 0.05rem;
  box-shadow: var(--shadow);
  animation: popIn 0.15s ease-out;
  min-width: 140px;
}
.context-menu.visible { display: flex; }

.context-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: background var(--transition-fast);
  border: none;
  background: none;
  font-family: var(--font);
  width: 100%;
  text-align: left;
}
.context-item:hover { background: var(--bg-hover); }
.context-item.danger { color: var(--danger); }
.context-item.danger:hover { background: var(--danger-light); }

/* ── Group Members List ────────────────────────────────────── */
.members-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 300px;
  overflow-y: auto;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem;
  border-radius: var(--radius);
  transition: background var(--transition-fast);
}
.member-item:hover { background: var(--bg-hover); }

.member-item-name { flex: 1; font-size: var(--text-md); }
.member-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-input);
}
.member-role.owner { color: var(--accent); background: var(--accent-light); }
.member-role.admin { color: #d69e2e; background: rgba(214, 158, 46, 0.15); }

/* ── User Search ───────────────────────────────────────────── */
.user-search-results {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 250px;
  overflow-y: auto;
}

.user-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.user-result-item:hover { background: var(--bg-hover); }
.user-result-item.selected { background: var(--bg-active); }

/* ── Lightbox ──────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox.visible { display: flex; }

.lightbox img, .lightbox video {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--radius-full);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-width: 100%;
    position: fixed;
    inset: 0;
    z-index: 50;
    transform: translateX(0);
    transition: transform var(--transition);
  }

  .sidebar.hidden {
    transform: translateX(-100%);
  }

  .chat-area {
    position: fixed;
    inset: 0;
    z-index: 40;
    transform: translateX(100%);
    transition: transform var(--transition);
  }

  .chat-area.visible {
    transform: translateX(0);
  }

  .chat-header-back { display: flex !important; }

  .message { max-width: 88%; }

  .settings-panel { width: 100%; border-right: none; }
}

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

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.25rem; }

/* Avatar colors — green-tinted palette */
.avatar-color-0  { background: linear-gradient(135deg, #2dce6c, #1a9e4e); }
.avatar-color-1  { background: linear-gradient(135deg, #f05252, #c0392b); }
.avatar-color-2  { background: linear-gradient(135deg, #48bb78, #276749); }
.avatar-color-3  { background: linear-gradient(135deg, #f6c90e, #c9a100); }
.avatar-color-4  { background: linear-gradient(135deg, #9f7aea, #6b46c1); }
.avatar-color-5  { background: linear-gradient(135deg, #ed8936, #c05621); }
.avatar-color-6  { background: linear-gradient(135deg, #4fd1c5, #285e61); }
.avatar-color-7  { background: linear-gradient(135deg, #f687b3, #97266d); }
.avatar-color-8  { background: linear-gradient(135deg, #68d391, #276749); }
.avatar-color-9  { background: linear-gradient(135deg, #a0aec0, #4a5568); }

/* Input file hidden */
input[type="file"] { display: none; }

/* Auth card extra glow border */
.auth-card {
  border: 1px solid rgba(45,206,108,0.2);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(45,206,108,0.08);
}

/* Send button green */
.send-btn {
  background: linear-gradient(135deg, #2dce6c, #1aaa55) !important;
  box-shadow: 0 2px 14px rgba(45,206,108,0.45) !important;
}
.send-btn:hover {
  box-shadow: 0 4px 20px rgba(45,206,108,0.65) !important;
}

/* Drag in progress */
.drag-over .message-input-wrapper {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* ── Frog Background Layer ──────────────────────────────── */
#frog-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.frog-emoji {
  position: absolute;
  font-size: 2rem;
  user-select: none;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  filter: blur(0.3px);
  animation: frogDrift var(--frog-dur, 18s) ease-in-out var(--frog-delay, 0s) infinite;
}

@keyframes frogDrift {
  0% {
    opacity: 0;
    transform: translateY(0) rotate(var(--frog-rot-start, 0deg)) scale(0.7);
  }
  10% {
    opacity: var(--frog-opacity, 0.07);
  }
  45% {
    transform: translateY(var(--frog-dy, -40px)) rotate(var(--frog-rot-mid, 8deg)) scale(1);
    opacity: var(--frog-opacity, 0.07);
  }
  80% {
    transform: translateY(var(--frog-dy2, -10px)) rotate(var(--frog-rot-end, -4deg)) scale(0.85);
    opacity: var(--frog-opacity, 0.07);
  }
  90% {
    opacity: 0;
  }
  100% {
    opacity: 0;
    transform: translateY(var(--frog-dy3, 20px)) rotate(var(--frog-rot-start, 0deg)) scale(0.7);
  }
}

/* ── Floating Theme Toggle (FAB) ────────────────────────── */
.theme-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-active);
  background: var(--bg-bubble);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25), 0 0 0 1px var(--border);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s ease, background 0.3s ease;
  animation: fabAppear 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes fabAppear {
  from { opacity: 0; transform: scale(0) rotate(-30deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

.theme-fab:hover {
  transform: scale(1.15) rotate(12deg);
  box-shadow: 0 6px 28px rgba(45,206,108,0.4), 0 0 0 2px var(--border-active);
}

.theme-fab:active {
  transform: scale(0.92);
}

.theme-fab.spin {
  animation: fabSpin 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes fabSpin {
  0%   { transform: scale(0.8) rotate(0deg); }
  60%  { transform: scale(1.1) rotate(200deg); }
  100% { transform: scale(1) rotate(360deg); }
}


/* ── Settings Profile Editing ── */
.avatar-edit-wrapper {
  position: relative;
  display: inline-block;
  margin: 0 auto 1rem;
}

.avatar-edit-btn {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 4px solid var(--bg-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: transform var(--transition-fast);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 2;
}

.avatar-edit-btn:hover {
  transform: scale(1.1);
}

.settings-bio-wrapper {
  margin: 1.5rem 1.5rem 0.5rem;
  display: flex;
  flex-direction: column;
}

.settings-bio-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0.75rem;
  font-family: inherit;
  resize: none;
  font-size: var(--text-sm);
}

.settings-bio-input:focus {
  border-color: var(--accent);
  outline: none;
}

.settings-username-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.settings-profile-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: var(--text-xs);
}
