/* ═══════════════════════════════════════════════════════════════════
   QUIMII MESSAGING — styles.css
   Ultra-premium social messaging UI · 2026 design system
   ═══════════════════════════════════════════════════════════════════ */

/* ─── DESIGN TOKENS ─────────────────────────────────────────────── */
:root {
  --brand: #1DA1F2;
  --brand-dim: rgba(29, 161, 242, 0.15);
  --brand-glow: rgba(29, 161, 242, 0.35);
  --brand-hover: #1a91da;

  /* Dark theme (default) */
  --bg-base:      #0d0f14;
  --bg-sidebar:   #0f1117;
  --bg-elevated:  #161b24;
  --bg-glass:     rgba(22, 27, 36, 0.85);
  --bg-hover:     rgba(255, 255, 255, 0.04);
  --bg-active:    rgba(29, 161, 242, 0.08);
  --bg-input:     rgba(255, 255, 255, 0.05);
  --bg-msg-out:   linear-gradient(135deg, #1DA1F2 0%, #0d7ac9 100%);
  --bg-msg-in:    rgba(255, 255, 255, 0.06);
  --bg-tooltip:   #1e2330;

  --border:       rgba(255, 255, 255, 0.07);
  --border-focus: rgba(29, 161, 242, 0.5);

  --text-primary:   #f0f2f5;
  --text-secondary: rgba(240, 242, 245, 0.55);
  --text-muted:     rgba(240, 242, 245, 0.3);
  --text-brand:     #1DA1F2;
  --text-danger:    #ff4d4f;

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 8px 32px rgba(0,0,0,0.45);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.6);
  --shadow-brand: 0 4px 20px rgba(29, 161, 242, 0.3);

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;
  --radius-pill: 999px;

  --sidebar-width: 320px;
  --topbar-height: 64px;

  --font-main:  'DM Sans', sans-serif;
  --font-brand: 'Sora', sans-serif;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth:   cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-base:      #f0f4f8;
  --bg-sidebar:   #ffffff;
  --bg-elevated:  #ffffff;
  --bg-glass:     rgba(255, 255, 255, 0.92);
  --bg-hover:     rgba(0, 0, 0, 0.04);
  --bg-active:    rgba(29, 161, 242, 0.08);
  --bg-input:     rgba(0, 0, 0, 0.04);
  --bg-msg-out:   linear-gradient(135deg, #1DA1F2 0%, #0d7ac9 100%);
  --bg-msg-in:    #ffffff;
  --bg-tooltip:   #1e2330;

  --border:       rgba(0, 0, 0, 0.08);
  --border-focus: rgba(29, 161, 242, 0.5);

  --text-primary:   #0d0f14;
  --text-secondary: rgba(13, 15, 20, 0.55);
  --text-muted:     rgba(13, 15, 20, 0.35);

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:  0 8px 32px rgba(0,0,0,0.12);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.15);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, textarea { font-family: inherit; }

::selection { background: var(--brand-dim); color: var(--text-primary); }

/* ─── ANIMATIONS ─────────────────────────────────────────────────── */
@keyframes fadeIn       { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeUp       { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: translateY(0) } }
@keyframes fadeDown     { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: translateY(0) } }
@keyframes scaleIn      { from { opacity: 0; transform: scale(0.92) } to { opacity: 1; transform: scale(1) } }
@keyframes scaleInBounce{ from { opacity: 0; transform: scale(0.8) } to { opacity: 1; transform: scale(1) } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px) } to { opacity: 1; transform: translateX(0) } }
@keyframes slideInLeft  { from { opacity: 0; transform: translateX(-20px) } to { opacity: 1; transform: translateX(0) } }
@keyframes msgOut       { from { opacity: 0; transform: translateX(16px) scale(0.97) } to { opacity: 1; transform: translateX(0) scale(1) } }
@keyframes msgIn        { from { opacity: 0; transform: translateX(-16px) scale(0.97) } to { opacity: 1; transform: translateX(0) scale(1) } }
@keyframes pulse        { 0%,100% { opacity: 1 } 50% { opacity: 0.5 } }
@keyframes ripple       { 0% { transform: scale(0); opacity: 0.5 } 100% { transform: scale(2.5); opacity: 0 } }
@keyframes waveBar {
  0%, 100% { transform: scaleY(0.3) }
  50%       { transform: scaleY(1) }
}
@keyframes badgePop { 0% { transform: scale(0) } 70% { transform: scale(1.15) } 100% { transform: scale(1) } }
@keyframes splashBar {
  0%   { width: 0%; opacity: 1 }
  70%  { width: 85%; opacity: 1 }
  100% { width: 100%; opacity: 0 }
}
@keyframes recDot { 0%,100% { opacity: 1 } 50% { opacity: 0 } }
@keyframes shimmer {
  0%   { background-position: -400px 0 }
  100% { background-position: 400px 0 }
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateY(12px) }
  to   { opacity: 1; transform: translateY(0) }
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ─── SPLASH ─────────────────────────────────────────────────────── */
.splash {
  position: fixed; inset: 0;
  background: var(--bg-base);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s var(--ease-smooth), transform 0.4s var(--ease-smooth);
}
.splash.exit {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}
.splash-inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.splash-logo { width: 72px; height: 72px; animation: scaleInBounce 0.6s var(--ease-spring); }
.splash-logo-img { width: 100%; height: 100%; object-fit: contain; }
.splash-logo-fallback {
  width: 72px; height: 72px;
  background: var(--brand);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand);
}
.splash-logo-fallback .logo-q {
  font-family: var(--font-brand); font-size: 36px; font-weight: 700; color: #fff;
}
.splash-wordmark {
  font-family: var(--font-brand); font-size: 28px; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.5px;
  animation: fadeUp 0.5s 0.2s var(--ease-out-expo) both;
}
.splash-loader {
  width: 140px; height: 3px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  animation: fadeIn 0.3s 0.4s both;
}
.splash-bar {
  height: 100%; background: var(--brand);
  border-radius: var(--radius-pill);
  animation: splashBar 1.5s var(--ease-out-expo) 0.4s forwards;
}

/* ─── APP LAYOUT ─────────────────────────────────────────────────── */
.app {
  display: flex; height: 100vh;
  transition: opacity 0.3s; 
}
.app.hidden { opacity: 0; pointer-events: none; }

/* ─── SIDEBAR ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

/* Sidebar Header */
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
}
.brand-logo-img { width: 30px; height: 30px; object-fit: contain; }
.brand-logo-fallback {
  width: 30px; height: 30px;
  background: var(--brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.brand-logo-fallback span {
  font-family: var(--font-brand); font-size: 16px; font-weight: 700; color: #fff;
}
.brand-name {
  font-family: var(--font-brand); font-size: 18px; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.3px;
}
.sidebar-header-actions { display: flex; gap: 4px; }

/* Icon Button */
.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.18s var(--ease-smooth);
  position: relative; overflow: hidden;
  flex-shrink: 0;
}
.icon-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(0.92); }

/* Search */
.sidebar-search { padding: 12px 12px 8px; flex-shrink: 0; }
.search-wrapper {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
.search-icon { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.search-input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 14px; color: var(--text-primary);
  padding: 10px 0;
}
.search-input::placeholder { color: var(--text-muted); }
.search-clear {
  width: 18px; height: 18px; cursor: pointer;
  color: var(--text-muted); display: none; align-items: center; justify-content: center;
}
.search-clear svg { width: 14px; height: 14px; }
.search-clear.visible { display: flex; }

/* Filter Tabs */
.filter-tabs {
  display: flex; gap: 4px;
  padding: 0 12px 10px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: all 0.2s var(--ease-smooth);
}
.filter-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-tab.active {
  background: var(--brand-dim);
  color: var(--brand);
  border-color: rgba(29, 161, 242, 0.2);
}

/* Chat List */
.chat-list {
  flex: 1; overflow-y: auto;
  padding: 4px 8px;
  display: flex; flex-direction: column; gap: 2px;
}

.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s var(--ease-smooth);
  position: relative;
  animation: fadeUp 0.3s var(--ease-out-expo) both;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }
.chat-item.active .chat-item-name { color: var(--brand); }
.chat-item:active { transform: scale(0.98); }

/* Pinned & Archived badges */
.chat-item[data-pinned="true"] .chat-item-name::after {
  content: "·📌"; font-size: 11px; margin-left: 4px;
}

.chat-avatar { position: relative; flex-shrink: 0; }
.chat-avatar img {
  width: 48px; height: 48px;
  border-radius: 50%; object-fit: cover;
  display: block;
  background: var(--bg-elevated);
}
.status-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
}
.status-dot.online  { background: #2ecc71; }
.status-dot.offline { background: var(--text-muted); }
.status-dot.away    { background: #f39c12; }

.chat-item-body { flex: 1; min-width: 0; }
.chat-item-row1 {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 3px;
}
.chat-item-name {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 160px;
}
.chat-item-time { font-size: 11.5px; color: var(--text-muted); flex-shrink: 0; }
.chat-item-row2 { display: flex; align-items: center; justify-content: space-between; }
.chat-item-preview {
  font-size: 13px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.chat-item-preview.typing { color: var(--brand); font-style: italic; }

.unread-badge {
  min-width: 20px; height: 20px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
  margin-left: 6px;
  animation: badgePop 0.3s var(--ease-spring);
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  flex-shrink: 0;
}
.my-profile {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.18s;
}
.my-profile:hover { background: var(--bg-hover); }
.my-avatar { position: relative; }
.my-avatar img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.my-info { flex: 1; }
.my-name { display: block; font-size: 13.5px; font-weight: 600; }
.my-status { display: block; font-size: 12px; color: var(--brand); }

/* ─── CHAT MAIN ──────────────────────────────────────────────────── */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg-base);
  position: relative; overflow: hidden;
  min-width: 0;
}

/* Empty State */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  animation: fadeIn 0.4s var(--ease-smooth);
  padding: 40px;
}
.empty-logo { margin-bottom: 8px; }
.empty-logo-img { width: 64px; height: 64px; object-fit: contain; opacity: 0.6; }
.empty-logo-fallback {
  width: 64px; height: 64px;
  background: var(--brand-dim);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  opacity: 0.7;
}
.empty-logo-fallback span {
  font-family: var(--font-brand); font-size: 32px; font-weight: 700; color: var(--brand);
}
.empty-title {
  font-family: var(--font-brand); font-size: 22px; font-weight: 700;
  color: var(--text-primary);
}
.empty-subtitle {
  font-size: 14px; color: var(--text-secondary); text-align: center; line-height: 1.6;
}
.btn-primary {
  display: flex; align-items: center; gap: 8px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 10px 22px;
  font-size: 14px; font-weight: 600;
  transition: all 0.2s var(--ease-smooth);
  margin-top: 8px;
  box-shadow: var(--shadow-brand);
}
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:hover { background: var(--brand-hover); transform: translateY(-1px); box-shadow: 0 6px 24px rgba(29,161,242,0.4); }
.btn-primary:active { transform: scale(0.97); }

/* Chat Window */
.chat-window {
  flex: 1; display: flex; flex-direction: column;
  height: 100%;
}
.chat-window.hidden { display: none; }

.hidden {
  display: none !important;
}

.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}
/* Chat Topbar */
.chat-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  height: var(--topbar-height);
  flex-shrink: 0;
  position: relative; z-index: 5;
}
.back-btn { display: none; }
.chat-topbar-avatar { position: relative; flex-shrink: 0; }
.chat-topbar-avatar img {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  display: block;
}
.chat-topbar-info { flex: 1; min-width: 0; }
.chat-topbar-name {
  display: block; font-size: 15px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-topbar-status {
  display: block; font-size: 12px; color: var(--text-secondary);
}
.chat-topbar-status.online-text { color: #2ecc71; }
.chat-topbar-actions { display: flex; gap: 2px; }

/* ─── MESSAGES AREA ──────────────────────────────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0;
  scroll-behavior: smooth;
  position: relative;
}
.messages-container {
  display: flex; flex-direction: column;
  padding: 0 16px;
  gap: 2px;
}

/* Date Separator */
.date-separator {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  animation: fadeIn 0.3s var(--ease-smooth);
}
.date-separator::before, .date-separator::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.date-separator-label {
  font-size: 11.5px; color: var(--text-muted); font-weight: 500;
  padding: 4px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  border: 1px solid var(--border);
}

/* Message Wrapper */
.msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  position: relative;
}
.msg-wrapper.out { align-self: flex-end; align-items: flex-end; animation: msgOut 0.25s var(--ease-out-expo) both; }
.msg-wrapper.in  { align-self: flex-start; align-items: flex-start; animation: msgIn 0.25s var(--ease-out-expo) both; }
.msg-wrapper.grouped { margin-top: 1px; }
.msg-wrapper:not(.grouped) { margin-top: 8px; }

/* Bubble */
.msg-bubble {
  position: relative;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14.5px; line-height: 1.55;
  word-break: break-word;
  transition: transform 0.12s var(--ease-smooth);
}
.msg-bubble:active { transform: scale(0.98); }
.msg-wrapper.out .msg-bubble {
  background: var(--bg-msg-out);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-wrapper.in .msg-bubble {
  background: var(--bg-msg-in);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-wrapper.out.grouped .msg-bubble { border-bottom-right-radius: var(--radius-lg); border-top-right-radius: 4px; }
.msg-wrapper.in.grouped  .msg-bubble { border-bottom-left-radius: var(--radius-lg); border-top-left-radius: 4px; }

/* Message Meta */
.msg-meta {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 2px 0;
}
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-status { display: flex; align-items: center; }
.msg-status svg { width: 14px; height: 14px; }
.msg-status.sent    { color: var(--text-muted); }
.msg-status.received{ color: var(--text-muted); }
.msg-status.read    { color: #ffffff; }
.msg-edited { font-size: 11px; color: var(--text-muted); font-style: italic; }

/* Reply Quote inside bubble */
.msg-reply-quote {
  background: rgba(255,255,255,0.08);
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}
.msg-wrapper.out .msg-reply-quote { background: rgba(255,255,255,0.15); }
.reply-quote-author { font-weight: 600; font-size: 12px; color: var(--brand); margin-bottom: 2px; }
.reply-quote-text { color: rgba(240,242,245,0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* Reactions */
.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.reaction-pill {
  display: flex; align-items: center; gap: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 7px;
  font-size: 13px; cursor: pointer;
  transition: all 0.15s var(--ease-smooth);
  user-select: none;
}
.reaction-pill:hover { border-color: var(--brand); background: var(--brand-dim); }
.reaction-pill.mine  { border-color: var(--brand); background: var(--brand-dim); }
.reaction-count { font-size: 11.5px; color: var(--text-secondary); }

/* Image/Video in message */
.msg-media {
  max-width: 100%; max-height: 320px;
  border-radius: var(--radius-md);
  object-fit: cover; display: block; cursor: zoom-in;
  margin-bottom: 4px;
}
.msg-video { max-width: 100%; max-height: 280px; border-radius: var(--radius-md); display: block; }

/* Audio Player in message */
.msg-audio-player {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  min-width: 200px;
}
.audio-play-btn {
  width: 34px; height: 34px;
  background: var(--brand); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all 0.15s var(--ease-smooth);
}
.audio-play-btn:hover { background: var(--brand-hover); transform: scale(1.08); }
.audio-play-btn svg { width: 14px; height: 14px; }
.audio-waveform-static {
  flex: 1; height: 32px;
  display: flex; align-items: center; gap: 2px;
}
.audio-waveform-static .wbar {
  width: 3px; background: rgba(255,255,255,0.25);
  border-radius: 2px; flex-shrink: 0;
  transition: background 0.2s;
}
.msg-wrapper.in .audio-waveform-static .wbar { background: var(--border); }
.audio-duration { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }

/* GIF in message */
.msg-gif {
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--radius-md);
  display: block;
  object-fit: cover;
  cursor: pointer;
}

/* File attachment */
.msg-file {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  cursor: pointer; min-width: 180px;
  transition: background 0.15s;
}
.msg-file:hover { background: rgba(255,255,255,0.1); }
.msg-wrapper.in .msg-file { background: rgba(0,0,0,0.04); }
.msg-wrapper.in .msg-file:hover { background: rgba(0,0,0,0.08); }
.file-icon {
  width: 36px; height: 36px;
  background: var(--brand-dim);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.file-icon svg { width: 18px; height: 18px; color: var(--brand); }
.file-info { min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.file-size { font-size: 11.5px; color: var(--text-secondary); }

/* Shared Post Card */
.msg-post-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  min-width: 240px; max-width: 320px;
  background: var(--bg-elevated);
}
.msg-post-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.post-card-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.post-card-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.post-card-user { font-size: 13px; font-weight: 600; }
.post-card-handle { font-size: 12px; color: var(--text-muted); }
.post-card-media { width: 100%; max-height: 160px; object-fit: cover; display: block; }
.post-card-body { padding: 10px 12px; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.post-card-footer {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.post-card-tag {
  font-size: 11px; color: var(--brand); font-weight: 600;
  background: var(--brand-dim); padding: 2px 8px; border-radius: var(--radius-pill);
}

/* ─── REPLY BAR ──────────────────────────────────────────────────── */
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  animation: fadeDown 0.2s var(--ease-out-expo);
}
.reply-bar.hidden { display: none; }
.reply-bar-content { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.reply-bar-accent { width: 3px; height: 32px; background: var(--brand); border-radius: var(--radius-pill); flex-shrink: 0; }
.reply-bar-text { min-width: 0; }
.reply-bar-author { display: block; font-size: 12px; font-weight: 700; color: var(--brand); }
.reply-bar-msg { display: block; font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── INPUT AREA ─────────────────────────────────────────────────── */
.input-area {
  border-top: 1px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 10px 12px;
  flex-shrink: 0;
  position: relative;
}
.input-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding-bottom: 8px;
}
.input-icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.18s var(--ease-smooth);
}
.input-icon-btn:hover { background: var(--bg-hover); color: var(--brand); }
.input-icon-btn:active { transform: scale(0.9); }
.input-icon-btn svg { width: 18px; height: 18px; }
.gif-label { font-size: 11px; font-weight: 800; letter-spacing: 0.5px; }
.input-field-wrapper { flex: 1; }
.message-input {
  width: 100%;
  min-height: 42px; max-height: 140px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 11px 16px;
  font-size: 14.5px; font-family: var(--font-main);
  color: var(--text-primary);
  outline: none;
  overflow-y: auto;
  word-break: break-word;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.5;
}
.message-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
.message-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.input-send-area {
  display: flex; align-items: flex-end;
  padding-top: 8px; gap: 4px;
  justify-content: flex-end;
}
.send-btn {
  width: 40px; height: 40px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease-spring);
  box-shadow: var(--shadow-brand);
}
.send-btn:hover { background: var(--brand-hover); transform: scale(1.08); }
.send-btn:active { transform: scale(0.93); }
.send-btn svg { width: 16px; height: 16px; }
.send-btn.hidden { display: none; }
.audio-btn { color: var(--text-secondary); }
.audio-btn:hover { color: var(--brand); }

/* Upload Preview */
.upload-preview {
  display: flex; flex-direction: column;
  padding: 8px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  animation: fadeDown 0.2s var(--ease-out-expo);
}
.upload-preview.hidden { display: none; }
.upload-items { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.upload-item {
  position: relative; flex-shrink: 0;
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.upload-item img, .upload-item video {
  width: 100%; height: 100%; object-fit: cover;
}
.upload-item-file {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 4px; padding: 4px;
}
.upload-item-file svg { width: 22px; height: 22px; color: var(--brand); }
.upload-item-filename { font-size: 10px; color: var(--text-secondary); text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.upload-item-remove {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px;
  background: rgba(0,0,0,0.7); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.upload-item-remove:hover { background: #ff4d4f; }
.upload-item-remove svg { width: 10px; height: 10px; color: #fff; }
.upload-progress {
  width: 100%; height: 3px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: absolute; bottom: 0; left: 0;
}
.upload-progress-bar {
  height: 100%; background: var(--brand);
  border-radius: var(--radius-pill);
  transition: width 0.3s var(--ease-smooth);
}

/* Audio Recording */
.audio-recording {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  animation: fadeDown 0.2s var(--ease-out-expo);
}
.audio-recording.hidden { display: none; }
.audio-cancel-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,77,79,0.15);
  color: #ff4d4f;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.audio-cancel-btn:hover { background: rgba(255,77,79,0.25); }
.audio-cancel-btn svg { width: 16px; height: 16px; }
.audio-waveform { flex: 1; }
.wave-bars { display: flex; align-items: center; gap: 3px; height: 28px; }
.wave-bars span {
  width: 3px; background: var(--brand); border-radius: 2px;
  transform-origin: center bottom;
}
.wave-bars span:nth-child(1)  { animation: waveBar 0.8s 0.0s infinite; height: 60%; }
.wave-bars span:nth-child(2)  { animation: waveBar 0.8s 0.07s infinite; height: 100%; }
.wave-bars span:nth-child(3)  { animation: waveBar 0.8s 0.14s infinite; height: 45%; }
.wave-bars span:nth-child(4)  { animation: waveBar 0.8s 0.21s infinite; height: 80%; }
.wave-bars span:nth-child(5)  { animation: waveBar 0.8s 0.28s infinite; height: 55%; }
.wave-bars span:nth-child(6)  { animation: waveBar 0.8s 0.07s infinite; height: 90%; }
.wave-bars span:nth-child(7)  { animation: waveBar 0.8s 0.14s infinite; height: 40%; }
.wave-bars span:nth-child(8)  { animation: waveBar 0.8s 0.21s infinite; height: 70%; }
.wave-bars span:nth-child(9)  { animation: waveBar 0.8s 0.0s infinite; height: 50%; }
.wave-bars span:nth-child(10) { animation: waveBar 0.8s 0.28s infinite; height: 85%; }
.wave-bars span:nth-child(11) { animation: waveBar 0.8s 0.14s infinite; height: 60%; }
.wave-bars span:nth-child(12) { animation: waveBar 0.8s 0.07s infinite; height: 75%; }
.audio-timer { font-size: 14px; font-weight: 600; color: var(--brand); min-width: 38px; }
.audio-rec-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #ff4d4f;
  animation: recDot 1s infinite;
  flex-shrink: 0;
}
.audio-send-btn {
  width: 36px; height: 36px;
  background: var(--brand); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s var(--ease-smooth);
}
.audio-send-btn:hover { background: var(--brand-hover); transform: scale(1.08); }
.audio-send-btn svg { width: 14px; height: 14px; }

/* ─── EMOJI PANEL ────────────────────────────────────────────────── */
.emoji-panel {
  position: fixed;
  bottom: 130px; left: var(--sidebar-width);
  width: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 100;
  overflow: hidden;
  animation: scaleIn 0.2s var(--ease-out-expo);
  transform-origin: bottom left;
}
.emoji-panel.hidden { display: none; }
.emoji-panel-header { padding: 10px; border-bottom: 1px solid var(--border); }
.emoji-search {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px; color: var(--text-primary);
  outline: none;
}
.emoji-search::placeholder { color: var(--text-muted); }
.emoji-search:focus { border-color: var(--border-focus); }
.emoji-categories {
  display: flex; gap: 4px;
  padding: 8px 10px;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.emoji-categories::-webkit-scrollbar { display: none; }
.emoji-cat-btn {
  font-size: 18px; padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s; cursor: pointer;
  flex-shrink: 0;
}
.emoji-cat-btn:hover, .emoji-cat-btn.active { background: var(--bg-hover); }
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 8px;
  max-height: 220px; overflow-y: auto;
}
.emoji-item {
  font-size: 22px; padding: 5px;
  border-radius: var(--radius-sm);
  cursor: pointer; text-align: center;
  transition: transform 0.1s, background 0.1s;
  line-height: 1;
}
.emoji-item:hover { background: var(--bg-hover); transform: scale(1.25); }
.emoji-item:active { transform: scale(1.1); }

/* ─── GIF PANEL ──────────────────────────────────────────────────── */
.gif-panel {
  position: fixed;
  bottom: 130px;
  left: var(--sidebar-width);
  width: 530px;
  height: 620px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 100;
  overflow: hidden;
  animation: scaleIn 0.2s var(--ease-out-expo);
  transform-origin: bottom left;
  display: flex;
  flex-direction: column;
  max-height: 700px;
}
.gif-panel.hidden { display: none; }

/* GIF Panel Tabs */
.gif-panel-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.gif-tab-btn {
  flex: 1; padding: 10px 12px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.15s var(--ease-smooth);
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.gif-tab-btn:hover { color: var(--text-primary); }
.gif-tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.gif-tab-btn svg { width: 13px; height: 13px; }

.gif-panel-header { padding: 8px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.gif-search {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px; color: var(--text-primary);
  outline: none;
}
.gif-search::placeholder { color: var(--text-muted); }
.gif-search:focus { border-color: var(--border-focus); }

/* GIF Tab Content wrapper */
.gif-tab-content { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.gif-tab-content.active { display: flex; }

.gif-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}
.gif-item {
  height: 250px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  background: var(--bg-hover);
  aspect-ratio: 1/1;
  position: relative;
}
.gif-item:hover { transform: scale(1.03); opacity: 0.9; }
.gif-item img {
  width: 100%; height: 100%; object-fit: contain;
  display: block; background: var(--bg-hover);
}
.gif-skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-elevated) 50%, var(--bg-hover) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-sm); height: 80px;
}

/* Favorites GIF tab */
.gif-favorites-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}
.gif-favorites-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 40px 20px;
  color: var(--text-muted); font-size: 13px; text-align: center;
}
.gif-favorites-empty svg { width: 36px; height: 36px; opacity: 0.4; }

/* GIF in chat — favorite heart overlay */
.msg-gif-wrap {
  position: relative; display: inline-block;
}
.msg-gif-wrap:hover .gif-fav-btn { opacity: 1; transform: scale(1); }
.gif-fav-btn {
  position: absolute; bottom: 6px; right: 6px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0; transform: scale(0.7);
  transition: opacity 0.18s var(--ease-out-expo), transform 0.18s var(--ease-spring);
  border: none;
  color: #fff; font-size: 14px;
  z-index: 2;
}
.gif-fav-btn:hover { background: rgba(255,77,100,0.8); transform: scale(1.1) !important; }
.gif-fav-btn.favorited { color: #ff4060; background: rgba(255,64,96,0.25); opacity: 1; transform: scale(1); }
.gif-fav-btn svg { width: 15px; height: 15px; }
.gif-fav-btn.favorited svg { fill: #ff4060; stroke: #ff4060; }

/* ─── MESSAGE HOVER ACTIONS ──────────────────────────────────────── */
.msg-quick-reply {
  position: absolute;
  top: 50%; transform: translateY(-50%) scale(0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease-out-expo), transform 0.15s var(--ease-spring);
  z-index: 4;
}
.msg-wrapper.out .msg-quick-reply { right: calc(100% + 6px); }
.msg-wrapper.in .msg-quick-reply  { left: calc(100% + 6px); }
.msg-wrapper:hover .msg-quick-reply {
  opacity: 1; pointer-events: all;
  transform: translateY(-50%) scale(1);
}
.msg-quick-reply-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s var(--ease-smooth);
  box-shadow: var(--shadow-sm);
}
.msg-quick-reply-btn:hover { background: var(--brand); color: #fff; border-color: transparent; transform: scale(1.12); }
.msg-quick-reply-btn svg { width: 13px; height: 13px; }

/* Existing actions bar */
.msg-actions {
  display: flex; gap: 2px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s var(--ease-smooth);
  margin-top: 3px;
}
.msg-wrapper:hover .msg-actions { opacity: 1; pointer-events: all; }
.msg-action-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s var(--ease-smooth);
  box-shadow: var(--shadow-sm);
}
.msg-action-btn:hover { background: var(--brand); color: #fff; border-color: transparent; }
.msg-action-btn[data-action="delete"]:hover { background: #ff4d4f; color: #fff; border-color: transparent; }
.msg-action-btn svg { width: 13px; height: 13px; }

/* ─── CONTEXT MENU ───────────────────────────────────────────────── */
.context-menu {
  position: fixed; z-index: 200;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  min-width: 180px;
  animation: scaleIn 0.18s var(--ease-out-expo);
  transform-origin: top left;
}
.context-menu.hidden { display: none; }
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  color: var(--text-primary);
  transition: background 0.12s;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item svg { width: 16px; height: 16px; color: var(--text-secondary); flex-shrink: 0; }
.ctx-item:hover svg { color: var(--brand); }
.ctx-danger { color: var(--text-danger); }
.ctx-danger svg { color: var(--text-danger); }
.ctx-danger:hover { background: rgba(255, 77, 79, 0.08); }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ─── REACTION PICKER ────────────────────────────────────────────── */
.reaction-picker {
  position: fixed; z-index: 201;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  padding: 6px 10px;
  display: flex; gap: 4px;
  animation: scaleInBounce 0.2s var(--ease-spring);
}
.reaction-picker.hidden { display: none; }
.reaction-opt {
  font-size: 22px; padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: transform 0.12s var(--ease-spring);
  line-height: 1;
}
.reaction-opt:hover { transform: scale(1.4) translateY(-4px); }
.reaction-opt:active { transform: scale(1.2); }

/* ─── TOASTS ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9998;
}
.toast {
  background: var(--bg-tooltip);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastSlide 0.25s var(--ease-out-expo);
  max-width: 300px;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid #2ecc71; }
.toast.error   { border-left: 3px solid #ff4d4f; }
.toast.info    { border-left: 3px solid var(--brand); }
.toast-exit {
  opacity: 0; transform: translateY(8px);
  transition: all 0.2s var(--ease-smooth);
}

/* ─── SKELETON LOADER ────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
.skel-chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
}
.skel-avatar { width: 48px; height: 48px; border-radius: 50%; }
.skel-body { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.skel-line { height: 12px; border-radius: var(--radius-pill); }
.skel-line.short { width: 55%; }
.skel-line.long  { width: 80%; }

/* ─── MOBILE OVERLAY ─────────────────────────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9;
  backdrop-filter: blur(4px);
}
.mobile-overlay.visible { display: block; animation: fadeIn 0.25s; }

/* ─── SCROLLBAR AUTO-HIDE ─────────────────────────────────────────── */
.messages-area { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.messages-area:hover { scrollbar-color: var(--border) transparent; }
.chat-list { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.chat-list:hover { scrollbar-color: var(--border) transparent; }

/* ─── RESPONSIVE — TABLET ────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-width: 280px; }
}

/* ─── RESPONSIVE — MOBILE ────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --sidebar-width: 100vw; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 100%;
    z-index: 10;
    transform: translateX(0);
    transition: transform 0.32s var(--ease-out-expo);
  }
  .sidebar.mobile-hidden {
    transform: translateX(-100%);
  }
  .chat-main {
    width: 100vw;
  }
  .back-btn { display: flex !important; }

  .emoji-panel, .gif-panel {
    left: 8px; right: 8px; width: auto;
    bottom: 120px;
    max-height: 420px;
  }

  .chat-topbar-actions .icon-btn:nth-child(1),
  .chat-topbar-actions .icon-btn:nth-child(2) {
    display: none;
  }

  .msg-wrapper { max-width: 88%; }

  .toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: none; }
}

/* ─── TOUCH DEVICE ENHANCEMENTS ──────────────────────────────────── */
@media (hover: none) {
  .icon-btn:hover, .input-icon-btn:hover, .chat-item:hover,
  .send-btn:hover, .btn-primary:hover {
    /* Let JS handle active states on touch */
    background: inherit;
    transform: none;
  }
  .chat-item:active { background: var(--bg-hover); }
}

/* ─── TYPING INDICATOR ────────────────────────────────────────────── */
.typing-indicator {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  animation: fadeIn 0.2s;
}
.typing-bubbles { display: flex; gap: 4px; align-items: center; }
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
}
.typing-dot:nth-child(1) { animation: pulse 1.2s 0.0s infinite; }
.typing-dot:nth-child(2) { animation: pulse 1.2s 0.2s infinite; }
.typing-dot:nth-child(3) { animation: pulse 1.2s 0.4s infinite; }
.typing-label { font-size: 13px; color: var(--text-muted); font-style: italic; }

/* ─── SCROLL TO BOTTOM BTN ────────────────────────────────────────── */
.scroll-bottom-btn {
  position: absolute; bottom: 160px; right: 16px;
  width: 38px; height: 38px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 3;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s var(--ease-smooth);
  animation: fadeIn 0.2s;
  color: var(--text-secondary);
}
.scroll-bottom-btn:hover { background: var(--brand); color: #fff; border-color: transparent; }
.scroll-bottom-btn.hidden { display: none; }
.scroll-bottom-btn svg { width: 16px; height: 16px; }

/* ─── SEND BTN APPEAR TRANSITION ─────────────────────────────────── */
.send-btn { animation: scaleInBounce 0.2s var(--ease-spring); }

/* ─── RIPPLE EFFECT ──────────────────────────────────────────────── */
.ripple-container { position: relative; overflow: hidden; }
.ripple-wave {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transform: scale(0);
  animation: ripple 0.5s var(--ease-smooth);
  pointer-events: none;
}

/* ─── FOCUS VISIBLE ──────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ═══════════════════════════════════════
   DELETE MESSAGE MODAL — QUIMII STYLE
═══════════════════════════════════════ */

/* ─── DELETE MESSAGE MODAL ───────────────────────────────────────── */
.delete-message-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.delete-message-modal.visible {
  display: flex;
  animation: fadeIn .18s ease;
}

.delete-message-card {
  width: min(100vw, 440px);
  background: var(--bg-elevated, #1e1e1e);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 24px 24px 20px 20px;
  padding: 0 0 12px;
  box-shadow: 0 -4px 40px rgba(0,0,0,.4), 0 2px 0 rgba(255,255,255,.03) inset;
  animation: sheetUp .22s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}

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

/* Drag handle */
.delete-message-card::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: rgba(255,255,255,.15);
  border-radius: 2px;
  margin: 12px auto 0;
}

/* Icon */
.delete-modal-icon {
  width: 60px; height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,59,59,.2), rgba(220,38,38,.1));
  border: 1px solid rgba(255,59,59,.18);
  display: flex; align-items: center; justify-content: center;
  margin: 20px auto 16px;
  color: #ff4d4f;
}
.delete-modal-icon svg { width: 26px; height: 26px; }

.delete-message-card h4 {
  color: var(--text-primary, #fff);
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.delete-message-card p {
  color: rgba(255,255,255,.5);
  text-align: center;
  font-size: .875rem;
  line-height: 1.55;
  margin: 0 24px 22px;
}

/* ── Actions layout ── */
.delete-message-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 14px;
}

/* Row with the two destructive actions */
.delete-msg-btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.delete-msg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 50px;
  border: none;
  border-radius: 14px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .14s ease, opacity .14s ease, background .14s ease;
  white-space: nowrap;
}
.delete-msg-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.delete-msg-btn:hover  { transform: translateY(-1px); }
.delete-msg-btn:active { transform: scale(.97); }

/* Cancelar — full width, subtle */
.delete-msg-btn.cancel {
  width: 100%;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.85);
  order: 99; /* always last */
}
.delete-msg-btn.cancel:hover { background: rgba(255,255,255,.1); }

/* Solo para mí — softer red */
.delete-msg-btn.confirm-me {
  background: rgba(255,77,79,.14);
  color: #ff8a8b;
  border: 1px solid rgba(255,77,79,.22);
}
.delete-msg-btn.confirm-me:hover {
  background: rgba(255,77,79,.22);
  color: #ff6b6b;
}

/* Para todos — solid red */
.delete-msg-btn.confirm-all {
  background: linear-gradient(135deg, #ff4d4f, #dc2626);
  color: #fff;
  box-shadow: 0 6px 20px rgba(255,77,79,.28);
}
.delete-msg-btn.confirm-all:hover { opacity: .9; }

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