/* ============================================
   COINRUSH CHAT — Premium v3
   Modern glassmorphism, micro-interactions,
   emoji picker, reactions, typing indicators,
   reply threads, link previews, scroll-to-bottom,
   sound toggles, character counter.
   ============================================ */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
  --cr-chat-primary: #fbbf24;
  --cr-chat-primary-rgb: 251, 191, 36;
  --cr-chat-secondary: #f59e0b;
  --cr-chat-accent: #fcd34d;
  --cr-chat-bg-dark: #0a0c10;
  --cr-chat-bg-medium: #11141a;
  --cr-chat-bg-light: #1a1e28;
  --cr-chat-bg-elevated: #1f2430;
  --cr-chat-text-primary: #f0f2f5;
  --cr-chat-text-secondary: #8b95a5;
  --cr-chat-text-muted: #5a6374;
  --cr-chat-border: rgba(255, 255, 255, 0.06);
  --cr-chat-border-light: rgba(255, 255, 255, 0.04);
  --cr-chat-glow: rgba(251, 191, 36, 0.25);
  --cr-chat-radius: 14px;
  --cr-chat-radius-sm: 8px;
  --cr-chat-transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Green Theme */
.cr-chat-container.green, .cr-floating-chat-panel.green, .cr-floating-chat-btn.green, .cr-chat-minimized.green {
  --cr-chat-primary: #5bffb2; --cr-chat-primary-rgb: 91, 255, 178;
  --cr-chat-secondary: #34d399; --cr-chat-accent: #6ee7b7;
  --cr-chat-glow: rgba(91, 255, 178, 0.2);
}
/* Purple Theme */
.cr-chat-container.purple, .cr-floating-chat-panel.purple, .cr-floating-chat-btn.purple, .cr-chat-minimized.purple {
  --cr-chat-primary: #a78bfa; --cr-chat-primary-rgb: 167, 139, 250;
  --cr-chat-secondary: #8b5cf6; --cr-chat-accent: #c4b5fd;
  --cr-chat-glow: rgba(167, 139, 250, 0.2);
}
/* Blue Theme */
.cr-chat-container.blue, .cr-floating-chat-panel.blue, .cr-floating-chat-btn.blue, .cr-chat-minimized.blue {
  --cr-chat-primary: #60a5fa; --cr-chat-primary-rgb: 96, 165, 250;
  --cr-chat-secondary: #3b82f6; --cr-chat-accent: #93c5fd;
  --cr-chat-glow: rgba(96, 165, 250, 0.2);
}
/* Pink/Neon Theme */
.cr-chat-container.pink, .cr-floating-chat-panel.pink, .cr-floating-chat-btn.pink, .cr-chat-minimized.pink {
  --cr-chat-primary: #ff2d92; --cr-chat-primary-rgb: 255, 45, 146;
  --cr-chat-secondary: #b44aff; --cr-chat-accent: #00f5ff;
  --cr-chat-glow: rgba(255, 45, 146, 0.25);
  --cr-chat-bg-dark: #0d0810; --cr-chat-bg-medium: #140e1a; --cr-chat-bg-light: #1e1428;
}

/* ============================================
   SPINNER — shared loading indicator
   ============================================ */
@keyframes cr-spin {
  to { transform: rotate(360deg); }
}
.cr-chat-spinner {
  width: 22px; height: 22px;
  border: 2px solid rgba(var(--cr-chat-primary-rgb), 0.15);
  border-top-color: var(--cr-chat-primary);
  border-radius: 50%;
  animation: cr-spin 0.7s linear infinite;
}

/* ============================================
   MAIN CONTAINER
   ============================================ */
.cr-chat-container {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  min-height: 400px; max-height: 700px;
  background: var(--cr-chat-bg-dark);
  border: 1px solid var(--cr-chat-border);
  border-radius: var(--cr-chat-radius);
  overflow: hidden;
  overscroll-behavior: contain;
  font-family: 'Inter', 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.03) inset;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   HEADER — Glassmorphism
   ============================================ */
.cr-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(17, 20, 26, 0.95) 0%, rgba(17, 20, 26, 0.85) 100%);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--cr-chat-border);
  position: relative; z-index: 5;
}
.cr-chat-header::after {
  content: ''; position: absolute; bottom: -1px; left: 12px; right: 12px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--cr-chat-primary-rgb), 0.15), transparent);
}
.cr-chat-header-left { display: flex; align-items: center; gap: 8px; }
.cr-chat-header-icon { width: 18px; height: 18px; color: var(--cr-chat-primary); opacity: 0.85; }
.cr-chat-header-icon svg { width: 100%; height: 100%; }
.cr-chat-header-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.8px;
  color: var(--cr-chat-text-primary); text-transform: uppercase;
  background: linear-gradient(135deg, var(--cr-chat-text-primary), var(--cr-chat-primary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.cr-chat-header-right { display: flex; align-items: center; gap: 6px; }
.cr-chat-online-indicator { display: flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 500; color: var(--cr-chat-text-muted); }
.cr-chat-online-pulse {
  width: 6px; height: 6px; background: #22c55e; border-radius: 50%;
  animation: cr-pulse 2.5s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}
@keyframes cr-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(1.3); } }
.cr-chat-minimize-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; background: rgba(255,255,255,0.04);
  border: 1px solid transparent; border-radius: 7px;
  color: var(--cr-chat-text-muted); cursor: pointer;
  transition: all var(--cr-chat-transition);
}
.cr-chat-minimize-btn:hover { background: rgba(255,255,255,0.08); color: var(--cr-chat-text-primary); border-color: var(--cr-chat-border); }
.cr-chat-minimize-btn svg { width: 16px; height: 16px; }

/* ============================================
   CHANNEL TABS
   ============================================ */
.cr-chat-tabs {
  display: flex; padding: 6px 12px; gap: 4px;
  background: var(--cr-chat-bg-medium);
  border-bottom: 1px solid var(--cr-chat-border);
}
.cr-chat-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 10px; background: transparent;
  border: 1px solid transparent; border-radius: var(--cr-chat-radius-sm);
  color: var(--cr-chat-text-muted); font-size: 10.5px; font-weight: 600;
  cursor: pointer; transition: all var(--cr-chat-transition);
  position: relative; text-transform: uppercase; letter-spacing: 0.5px;
}
.cr-chat-tab:hover:not(.locked) { color: var(--cr-chat-text-secondary); background: rgba(255,255,255,0.03); }
.cr-chat-tab.active {
  background: rgba(var(--cr-chat-primary-rgb), 0.1);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.2);
  color: var(--cr-chat-primary);
  box-shadow: 0 0 12px rgba(var(--cr-chat-primary-rgb), 0.08);
}
.cr-chat-tab.locked { opacity: 0.35; cursor: not-allowed; }
.cr-chat-tab-icon { width: 13px; height: 13px; }
.cr-chat-tab-icon svg { width: 100%; height: 100%; }
.cr-chat-tab-badge {
  position: absolute; top: -3px; right: -3px;
  padding: 1px 5px; background: #ef4444;
  border: 2px solid var(--cr-chat-bg-medium); border-radius: 8px;
  font-size: 8px; font-weight: 700; color: #fff; letter-spacing: 0;
}
.cr-chat-tab-badge--join { background: #8b5cf6; }
.cr-chat-tab--game.active {
  background: rgba(var(--cr-chat-primary-rgb), 0.14);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.3);
  color: var(--cr-chat-primary); font-weight: 700;
}

/* ============================================
   MESSAGES AREA
   ============================================ */
.cr-chat-messages-wrapper {
  flex: 1; position: relative; min-height: 0; overflow: hidden;
}
.cr-chat-messages {
  height: 100%; overflow-y: auto;
  padding: 4px 0;
  display: flex; flex-direction: column; gap: 0;
  background: var(--cr-chat-bg-dark);
  overscroll-behavior: contain;
  scroll-behavior: auto;
}
.cr-chat-messages::-webkit-scrollbar { width: 3px; }
.cr-chat-messages::-webkit-scrollbar-track { background: transparent; }
.cr-chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 10px; }
.cr-chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

/* ============================================
   MESSAGE — Ultra-clean Kick/Discord fusion
   ============================================ */
.cr-msg {
  position: relative;
  padding: 4px 12px 4px 12px;
  transition: background 0.1s ease;
  animation: cr-msg-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}
.cr-msg--hover {
  background: rgba(255, 255, 255, 0.02);
}
.cr-msg--own {
  background: rgba(var(--cr-chat-primary-rgb), 0.025);
  border-left: 2px solid rgba(var(--cr-chat-primary-rgb), 0.15);
}
.cr-msg--own.cr-msg--hover {
  background: rgba(var(--cr-chat-primary-rgb), 0.05);
}

/* "You" tag for own messages */
.cr-msg-you {
  display: inline-flex; align-items: center;
  padding: 0 4px; border-radius: 3px;
  font-size: 8px; font-weight: 700;
  letter-spacing: 0.3px; text-transform: uppercase;
  line-height: 14px; height: 14px;
  margin-left: 4px; vertical-align: middle;
  background: rgba(var(--cr-chat-primary-rgb), 0.1);
  color: var(--cr-chat-primary);
  border: 1px solid rgba(var(--cr-chat-primary-rgb), 0.15);
}
@keyframes cr-msg-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   REPLY CONTEXT — Compact inline thread ref
   ============================================ */
.cr-msg-reply {
  display: flex; align-items: center; gap: 4px;
  margin-left: 32px; margin-bottom: 1px;
  padding: 1px 0 1px 8px;
  font-size: 0;
  opacity: 0.55;
  transition: opacity 0.15s ease;
  cursor: pointer;
}
.cr-msg-reply:hover { opacity: 0.85; }
.cr-msg-reply__pipe {
  width: 2px; height: 10px; flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 1px;
}
.cr-msg-reply__icon {
  width: 10px; height: 10px; flex-shrink: 0;
  color: rgba(255,255,255,0.3);
}
.cr-msg-reply__user {
  font-size: 11px; font-weight: 600; flex-shrink: 0;
  line-height: 1;
}
.cr-msg-reply__text {
  font-size: 11px; color: var(--cr-chat-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; line-height: 1;
}
.cr-msg--threaded {
  border-left: 2px solid rgba(var(--cr-chat-primary-rgb), 0.2);
}

/* ============================================
   MESSAGE ROW — avatar + content inline
   ============================================ */
.cr-msg-row {
  display: flex; gap: 8px; align-items: flex-start;
  position: relative;
}

/* ============================================
   AVATAR — Compact 26px
   ============================================ */
.cr-msg-avatar-wrap {
  position: relative; flex-shrink: 0;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px; z-index: 2;
}
.cr-msg-avatar {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #000; text-transform: uppercase;
  transition: transform 0.12s ease;
}

/* PNG Border Frame Overlay — scaled down */
.cr-msg-avatar-wrap::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none; z-index: 10;
  background-size: contain; background-position: center; background-repeat: no-repeat;
  opacity: 0.8; width: 40px; height: 40px;
}
.cr-msg-avatar-wrap.avatar-rookie::before { display: none; }
.cr-msg-avatar-wrap.avatar-bronze::before { background-image: url('/static/img/borders/Bronzeborder.png'); }
.cr-msg-avatar-wrap.avatar-silver::before { background-image: url('/static/img/borders/Silverborder.png'); }
.cr-msg-avatar-wrap.avatar-gold::before { background-image: url('/static/img/borders/Goldborder.png'); }
.cr-msg-avatar-wrap.avatar-platinum::before,
.cr-msg-avatar-wrap.avatar-diamond::before { background-image: url('/static/img/borders/Diamondborder.png'); width: 42px; height: 42px; }
.cr-msg-avatar-wrap.avatar-challenger::before { background-image: url('/static/img/borders/Challengerborder.png'); width: 44px; height: 44px; }
.cr-msg-avatar-wrap.avatar-ruby::before { background-image: url('/static/img/borders/Rubyborder.png'); width: 44px; height: 44px; }
.cr-msg-avatar-wrap.avatar-legendary::before { background-image: url('/static/img/borders/Challengerborder.png'); width: 46px; height: 46px; }

/* ============================================
   MESSAGE CONTENT — Flowing inline layout
   ============================================ */
.cr-msg-content {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 0;
  line-height: 1.35;
}

/* Inline meta: badges + username + time on one line */
.cr-msg-inline {
  display: inline; vertical-align: baseline;
  font-size: 0; /* collapse whitespace */
}
.cr-msg-title {
  display: inline-flex; align-items: center;
  padding: 0 4px; border-radius: 3px;
  font-size: 8px; font-weight: 800;
  letter-spacing: 0.4px; text-transform: uppercase;
  line-height: 14px; height: 14px;
  margin-right: 3px; vertical-align: middle;
  background: transparent; border: 1px solid transparent;
}
.cr-msg-title.legendary { color: #f472b6; border-color: rgba(244,114,182,0.2); background: rgba(244,114,182,0.06); }
.cr-msg-title.master { color: #a78bfa; border-color: rgba(167,139,250,0.2); background: rgba(167,139,250,0.06); }
.cr-msg-title.expert { color: #60a5fa; border-color: rgba(96,165,250,0.2); background: rgba(96,165,250,0.06); }
.cr-msg-title.vip { color: #fbbf24; border-color: rgba(251,191,36,0.2); background: rgba(251,191,36,0.06); }

.cr-msg-lv {
  display: inline-flex; align-items: center;
  padding: 0 3px; border-radius: 3px;
  font-size: 8px; font-weight: 600;
  line-height: 14px; height: 14px;
  margin-right: 4px; vertical-align: middle;
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.4);
  border: 1px solid rgba(255,255,255,0.06);
}

.cr-msg-user {
  font-size: 12.5px; font-weight: 700;
  vertical-align: baseline;
}

.cr-msg-time {
  font-size: 9px; color: var(--cr-chat-text-muted);
  margin-left: 5px; vertical-align: baseline;
  opacity: 0.3; font-weight: 400;
  transition: opacity 0.12s ease;
}
.cr-msg--hover .cr-msg-time { opacity: 0.6; }

/* Message text — flows naturally after meta */
.cr-msg-text {
  font-size: 13px; line-height: 1.45;
  color: rgba(255,255,255,0.92);
  word-break: break-word;
  margin-top: 1px;
}

/* Stripped link placeholder */
.cr-msg-text-stripped {
  font-size: 11px; opacity: 0.35;
  font-style: italic;
}

/* ============================================
   HOVER TOOLBAR — Minimal floating pill
   ============================================ */
.cr-msg-toolbar {
  position: absolute; top: -6px; right: 0;
  display: flex; gap: 0;
  background: var(--cr-chat-bg-elevated);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  padding: 1px;
  z-index: 10;
  animation: cr-tb-pop 0.08s ease-out;
}
@keyframes cr-tb-pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
.cr-msg-toolbar__btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 24px; border-radius: 3px;
  background: transparent;
  border: none; color: var(--cr-chat-text-muted); cursor: pointer;
  padding: 0;
  transition: all 0.1s ease;
}
.cr-msg-toolbar__btn:hover {
  background: rgba(var(--cr-chat-primary-rgb), 0.12);
  color: var(--cr-chat-primary);
}
.cr-msg-toolbar__btn svg { display: block; }

/* ============================================
   REACTIONS — Always visible, animated pills
   ============================================ */
.cr-msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px; margin-left: 34px;
  padding-bottom: 2px;
}
.cr-msg-rx {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; height: 24px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
  user-select: none;
  animation: cr-rx-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cr-rx-pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.cr-msg-rx:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
  transform: scale(1.08);
}
.cr-msg-rx--own {
  background: rgba(var(--cr-chat-primary-rgb), 0.12);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.3);
}
.cr-msg-rx--own:hover {
  background: rgba(var(--cr-chat-primary-rgb), 0.2);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.4);
}
.cr-msg-rx__emoji { font-size: 14px; line-height: 1; }
.cr-msg-rx__count {
  font-size: 11px; font-weight: 700;
  color: var(--cr-chat-text-secondary);
  min-width: 6px; text-align: center;
}
.cr-msg-rx--own .cr-msg-rx__count { color: var(--cr-chat-primary); }

.cr-msg-rx--add {
  color: var(--cr-chat-text-muted);
  background: rgba(255,255,255,0.02); border-style: dashed;
  border-color: rgba(255,255,255,0.08);
  padding: 2px 7px;
  opacity: 0.5;
  transition: all 0.15s ease;
}
.cr-msg-rx--add:hover {
  opacity: 1;
  color: var(--cr-chat-primary);
  background: rgba(var(--cr-chat-primary-rgb), 0.08);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.25);
}

/* Quick reaction picker */
.cr-msg-qr {
  display: flex; gap: 2px;
  margin-top: 4px; margin-left: 34px;
  padding: 4px 5px;
  background: var(--cr-chat-bg-elevated);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  width: fit-content;
  animation: cr-tb-pop 0.12s ease-out;
  z-index: 11; position: relative;
}
.cr-msg-qr__btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: transparent; border: none; cursor: pointer;
  font-size: 17px; transition: all 0.12s ease;
}
.cr-msg-qr__btn:hover {
  background: rgba(var(--cr-chat-primary-rgb), 0.12);
  transform: scale(1.25);
}

/* ============================================
   SYSTEM MESSAGE
   ============================================ */
.cr-msg--system { padding: 2px 12px; text-align: center; }
.cr-msg-sys {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  background: rgba(var(--cr-chat-primary-rgb), 0.04);
  border: 1px solid rgba(var(--cr-chat-primary-rgb), 0.06);
  border-radius: 100px;
}
.cr-msg-sys__icon { width: 10px; height: 10px; color: var(--cr-chat-primary); opacity: 0.5; }
.cr-msg-sys__icon svg { width: 100%; height: 100%; }
.cr-msg-sys__text { font-size: 10px; font-weight: 500; color: var(--cr-chat-text-muted); }

/* ============================================
   EMPTY & LOCKED STATES
   ============================================ */
.cr-chat-empty, .cr-chat-locked-panel {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 32px; text-align: center;
}
.cr-chat-empty-icon, .cr-chat-locked-icon { width: 40px; height: 40px; color: var(--cr-chat-text-muted); opacity: 0.35; }
.cr-chat-empty-icon svg, .cr-chat-locked-icon svg { width: 100%; height: 100%; }
.cr-chat-locked-icon { color: var(--cr-chat-primary); opacity: 0.5; }
.cr-chat-empty h3, .cr-chat-locked-panel h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--cr-chat-text-secondary); }
.cr-chat-empty p, .cr-chat-locked-panel p { margin: 0; font-size: 12px; color: var(--cr-chat-text-muted); }
.cr-chat-locked-requirement {
  margin-top: 6px; padding: 8px 16px;
  background: rgba(var(--cr-chat-primary-rgb), 0.06);
  border: 1px solid var(--cr-chat-border); border-radius: 8px;
  font-size: 12px; color: var(--cr-chat-text-secondary);
}
.cr-chat-locked-requirement strong { color: var(--cr-chat-primary); }
.cr-chat-current-level { display: block; margin-top: 3px; font-size: 10px; color: var(--cr-chat-text-muted); }

/* Guild */
.cr-chat-tab--guild.active { background: rgba(139,92,246,0.1); border-color: rgba(139,92,246,0.2); color: #a78bfa; }
.cr-chat-locked-icon--guild { color: #8b5cf6; opacity: 0.5; }
.cr-chat-join-guild-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; background: #8b5cf6;
  border: none; border-radius: 8px; color: #fff;
  font-size: 12px; font-weight: 600; text-decoration: none;
  cursor: pointer; transition: filter var(--cr-chat-transition);
}
.cr-chat-join-guild-btn:hover { filter: brightness(1.1); }
.cr-chat-join-guild-btn svg { width: 14px; height: 14px; }

/* ============================================
   SCROLL TO BOTTOM BUTTON
   ============================================ */
.cr-chat-scroll-btn {
  position: absolute; bottom: 10px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 14px; background: var(--cr-chat-bg-elevated);
  border: 1px solid rgba(var(--cr-chat-primary-rgb), 0.2);
  border-radius: 20px; color: var(--cr-chat-primary);
  cursor: pointer; z-index: 8;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: cr-scroll-btn-in 0.2s ease-out;
  transition: all var(--cr-chat-transition);
}
.cr-chat-scroll-btn:hover {
  background: rgba(var(--cr-chat-primary-rgb), 0.15);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.35);
  transform: translateX(-50%) scale(1.05);
}
.cr-chat-scroll-btn svg { width: 14px; height: 14px; }
.cr-chat-scroll-btn__count {
  font-size: 10px; font-weight: 700;
  background: var(--cr-chat-primary); color: #000;
  padding: 1px 6px; border-radius: 10px;
}
@keyframes cr-scroll-btn-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ============================================
   INPUT AREA
   ============================================ */
.cr-chat-input-area {
  padding: 8px 12px 8px 12px;
  background: linear-gradient(180deg, rgba(17,20,26,0.85) 0%, rgba(17,20,26,0.95) 100%);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--cr-chat-border);
  position: relative;
}

/* Reply preview bar */
.cr-chat-reply-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 6px;
  background: rgba(var(--cr-chat-primary-rgb), 0.08);
  border: 1px solid rgba(var(--cr-chat-primary-rgb), 0.15);
  border-radius: 10px;
  animation: cr-msg-in 0.15s ease-out;
}
.cr-chat-reply-preview__bar {
  width: 3px; height: 28px; flex-shrink: 0;
  background: var(--cr-chat-primary); border-radius: 2px;
}
.cr-chat-reply-preview__content {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.cr-chat-reply-preview__label {
  font-size: 10px; font-weight: 600; color: var(--cr-chat-primary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.cr-chat-reply-preview__user { font-size: 12px; font-weight: 700; }
.cr-chat-reply-preview__text {
  font-size: 12px; color: var(--cr-chat-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cr-chat-reply-preview__close {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0;
  background: transparent; border: none; border-radius: 4px;
  color: var(--cr-chat-text-muted); cursor: pointer;
  transition: all var(--cr-chat-transition);
}
.cr-chat-reply-preview__close:hover { color: #ef4444; background: rgba(239,68,68,0.1); }
.cr-chat-reply-preview__close svg { width: 12px; height: 12px; }

/* Input wrapper */
.cr-chat-input-wrapper {
  display: flex; gap: 6px; align-items: center;
  background: var(--cr-chat-bg-medium);
  border: 1px solid var(--cr-chat-border);
  border-radius: 12px; padding: 4px 5px 4px 4px;
  transition: all var(--cr-chat-transition);
}
.cr-chat-input-wrapper:focus-within {
  border-color: rgba(var(--cr-chat-primary-rgb), 0.25);
  box-shadow: 0 0 0 2px rgba(var(--cr-chat-primary-rgb), 0.05);
  background: var(--cr-chat-bg-dark);
}
.cr-chat-input {
  flex: 1; padding: 7px 8px; background: transparent;
  border: none; font-size: 13px; color: var(--cr-chat-text-primary);
  min-height: 32px; outline: none; font-family: inherit;
}
.cr-chat-input::placeholder { color: var(--cr-chat-text-muted); font-weight: 400; }
.cr-chat-input:hover, .cr-chat-input:focus { background: transparent; border: none; box-shadow: none; outline: none; }
.cr-chat-input:disabled { opacity: 0.4; cursor: not-allowed; }

/* Emoji button */
.cr-chat-emoji-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; min-width: 32px;
  background: transparent; border: none; border-radius: 8px;
  color: var(--cr-chat-text-muted); cursor: pointer;
  transition: all var(--cr-chat-transition);
}
.cr-chat-emoji-btn:hover { color: var(--cr-chat-primary); background: rgba(var(--cr-chat-primary-rgb), 0.08); }
.cr-chat-emoji-btn.active { color: var(--cr-chat-primary); background: rgba(var(--cr-chat-primary-rgb), 0.12); }
.cr-chat-emoji-btn svg { width: 18px; height: 18px; }

/* Character counter */
.cr-chat-char-count {
  font-size: 10px; font-weight: 500; color: var(--cr-chat-text-muted);
  padding: 0 4px; flex-shrink: 0; white-space: nowrap;
  transition: color var(--cr-chat-transition);
}
.cr-chat-char-count.warn { color: #f59e0b; }
.cr-chat-char-count.danger { color: #ef4444; font-weight: 700; }

/* Send button — subtle, matches theme */
.cr-chat-send-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; min-width: 34px;
  background: rgba(var(--cr-chat-primary-rgb), 0.12);
  border: 1px solid rgba(var(--cr-chat-primary-rgb), 0.2);
  border-radius: 8px;
  color: var(--cr-chat-primary); cursor: pointer;
  transition: all var(--cr-chat-transition);
  flex-shrink: 0; outline: none;
}
.cr-chat-send-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.cr-chat-send-btn:hover:not(:disabled) {
  background: rgba(var(--cr-chat-primary-rgb), 0.2);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.35);
  box-shadow: 0 0 10px rgba(var(--cr-chat-primary-rgb), 0.15);
  transform: scale(1.05);
}
.cr-chat-send-btn:active:not(:disabled) { transform: scale(0.94); }
.cr-chat-send-btn:disabled {
  opacity: 0.2; cursor: not-allowed;
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.05);
  color: var(--cr-chat-text-muted);
}
.cr-chat-send-btn:not(:disabled) {
  background: rgba(var(--cr-chat-primary-rgb), 0.15);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.3);
  color: var(--cr-chat-primary);
  box-shadow: 0 0 6px rgba(var(--cr-chat-primary-rgb), 0.1);
}

/* Login / Banned */
.cr-chat-login-prompt, .cr-chat-banned {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px;
  background: rgba(var(--cr-chat-primary-rgb), 0.06);
  border: 1px solid var(--cr-chat-border); border-radius: 10px;
  font-size: 12px; font-weight: 500; color: var(--cr-chat-primary);
  cursor: pointer; transition: all var(--cr-chat-transition);
}
.cr-chat-login-prompt:hover { background: rgba(var(--cr-chat-primary-rgb), 0.1); }
.cr-chat-banned {
  background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.15);
  color: #ef4444; cursor: default;
}
.cr-chat-banned-icon { width: 14px; height: 14px; }
.cr-chat-banned-icon svg { width: 100%; height: 100%; }

/* ============================================
   ANTI-SPAM — Warning banner & cooldown
   ============================================ */
.cr-chat-spam-warning {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; margin-bottom: 6px;
  border-radius: 8px; font-size: 11px; font-weight: 600;
  animation: cr-spam-shake 0.35s ease-out;
}
.cr-chat-spam-warning--cooldown {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}
.cr-chat-spam-warning--duplicate {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
}
.cr-chat-spam-warning--muted {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
}
.cr-chat-spam-warning svg { flex-shrink: 0; }
@keyframes cr-spam-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-4px); }
  30% { transform: translateX(3px); }
  45% { transform: translateX(-2px); }
  60% { transform: translateX(1px); }
}

/* Cooldown state on input */
.cr-chat-input-wrapper--cooldown {
  border-color: rgba(245, 158, 11, 0.15) !important;
  opacity: 0.6;
  pointer-events: none;
}
.cr-chat-send-btn--cooldown {
  animation: cr-cooldown-pulse 1s ease-in-out infinite;
}
@keyframes cr-cooldown-pulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.4; }
}

/* Footer */
.cr-chat-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px; padding: 0 2px; min-height: 18px;
}
.cr-chat-connection-status {
  display: flex; align-items: center; gap: 3px;
  font-size: 9px; color: #f59e0b; opacity: 0.5;
}
.cr-chat-connection-status.connected { color: #22c55e; }
.cr-chat-connection-status svg { width: 10px; height: 10px; }

/* Sound toggle */
.cr-chat-sound-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex-shrink: 0;
  background: transparent; border: none; border-radius: 4px;
  color: var(--cr-chat-text-muted); cursor: pointer; opacity: 0.5;
  transition: all var(--cr-chat-transition);
}
.cr-chat-sound-toggle:hover { opacity: 1; color: var(--cr-chat-primary); }
.cr-chat-sound-toggle svg { width: 12px; height: 12px; }

/* ============================================
   TYPING INDICATOR
   ============================================ */
.cr-chat-typing {
  display: flex; align-items: center; gap: 6px;
  padding: 0 4px; flex: 1; justify-content: center;
}
.cr-chat-typing__dots {
  display: flex; gap: 3px; align-items: center;
}
.cr-chat-typing__dots span {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--cr-chat-primary); opacity: 0.5;
  animation: cr-typing-bounce 1.2s ease-in-out infinite;
}
.cr-chat-typing__dots span:nth-child(2) { animation-delay: 0.15s; }
.cr-chat-typing__dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cr-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.cr-chat-typing__text { font-size: 10px; color: var(--cr-chat-text-muted); font-style: italic; }

/* ============================================
   EMOJI PICKER
   ============================================ */
.cr-emoji-picker {
  position: absolute; bottom: 100%; left: 8px; right: 8px;
  margin-bottom: 6px;
  background: var(--cr-chat-bg-elevated);
  border: 1px solid var(--cr-chat-border);
  border-radius: 12px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
  z-index: 20; overflow: hidden;
  animation: cr-emoji-in 0.18s ease-out;
}
@keyframes cr-emoji-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cr-emoji-picker__header { padding: 8px 8px 4px; }
.cr-emoji-picker__search {
  width: 100%; padding: 7px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--cr-chat-border);
  border-radius: 8px; color: var(--cr-chat-text-primary);
  font-size: 12px; outline: none; font-family: inherit;
  transition: border-color var(--cr-chat-transition);
  box-sizing: border-box;
}
.cr-emoji-picker__search:focus { border-color: rgba(var(--cr-chat-primary-rgb), 0.3); }
.cr-emoji-picker__search::placeholder { color: var(--cr-chat-text-muted); }
.cr-emoji-picker__cats {
  display: flex; gap: 2px; padding: 4px 8px;
  border-bottom: 1px solid var(--cr-chat-border);
}
.cr-emoji-picker__cat-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 5px; border-radius: 6px;
  background: transparent; border: none; cursor: pointer;
  font-size: 16px; opacity: 0.5;
  transition: all var(--cr-chat-transition);
}
.cr-emoji-picker__cat-btn:hover { opacity: 0.8; background: rgba(255,255,255,0.04); }
.cr-emoji-picker__cat-btn.active { opacity: 1; background: rgba(var(--cr-chat-primary-rgb), 0.1); }
.cr-emoji-picker__grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  padding: 6px 8px 8px; max-height: 160px; overflow-y: auto;
}
.cr-emoji-picker__grid::-webkit-scrollbar { width: 3px; }
.cr-emoji-picker__grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.cr-emoji-picker__emoji {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1; border-radius: 6px;
  background: transparent; border: none; cursor: pointer;
  font-size: 18px;
  transition: all var(--cr-chat-transition);
}
.cr-emoji-picker__emoji:hover { background: rgba(var(--cr-chat-primary-rgb), 0.12); transform: scale(1.2); }
.cr-emoji-picker__empty { grid-column: 1 / -1; text-align: center; padding: 16px; font-size: 12px; color: var(--cr-chat-text-muted); }

/* ============================================
   MINIMIZED STATE
   ============================================ */
.cr-chat-minimized {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--cr-chat-bg-dark);
  border: 1px solid var(--cr-chat-border);
  border-radius: 10px; cursor: pointer;
  transition: all var(--cr-chat-transition);
  position: relative;
}
.cr-chat-minimized:hover {
  border-color: rgba(var(--cr-chat-primary-rgb), 0.25);
  box-shadow: 0 0 20px rgba(var(--cr-chat-primary-rgb), 0.08);
}
.cr-chat-minimized-icon { width: 18px; height: 18px; color: var(--cr-chat-primary); opacity: 0.7; }
.cr-chat-minimized-icon svg { width: 100%; height: 100%; }
.cr-chat-minimized-label { font-size: 13px; font-weight: 500; color: var(--cr-chat-text-secondary); }
.cr-chat-notification-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; background: #ef4444; border-radius: 50%;
  animation: cr-pulse 1.5s ease-in-out infinite;
}
.cr-chat-online-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.15);
  border-radius: 16px; font-size: 11px; font-weight: 500; color: #22c55e;
}

/* ============================================
   DM TOGGLE BUTTON (header)
   ============================================ */
.cr-chat-dm-toggle {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent; border-radius: 7px;
  color: var(--cr-chat-text-muted); cursor: pointer;
  transition: all var(--cr-chat-transition);
}
.cr-chat-dm-toggle svg { width: 14px; height: 14px; }
.cr-chat-dm-toggle:hover { background: rgba(255,255,255,0.08); color: var(--cr-chat-text-secondary); }
.cr-chat-dm-toggle.active {
  background: rgba(var(--cr-chat-primary-rgb), 0.12);
  border-color: rgba(var(--cr-chat-primary-rgb), 0.25);
  color: var(--cr-chat-primary);
}
.cr-chat-dm-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; background: #ef4444;
  border: 2px solid var(--cr-chat-bg-medium);
  border-radius: 10px; font-size: 9px; font-weight: 700; color: #fff; line-height: 1;
}
.cr-chat-guild-toggle.locked { opacity: 0.3; cursor: not-allowed; }

/* DM avatar wrappers */
.cr-dm-item__avatar-wrap { width: 36px; height: 36px; }
.cr-dm-item__avatar-wrap .cr-chat-message-avatar { width: 36px; height: 36px; min-width: 36px; font-size: 14px; font-weight: 700; color: #fff; border: none; }
.cr-dm-item__avatar-wrap.cr-chat-avatar-wrapper::before { width: 54px; height: 54px; }
.cr-dm-item__avatar-wrap .cr-dm-item__online-dot { position: absolute; bottom: -1px; right: -1px; z-index: 12; }
.cr-dm-convo__avatar-wrap { width: 32px; height: 32px; }
.cr-dm-convo__avatar-wrap .cr-chat-message-avatar { width: 32px; height: 32px; min-width: 32px; font-size: 13px; font-weight: 700; color: #fff; border: none; }
.cr-dm-convo__avatar-wrap.cr-chat-avatar-wrapper::before { width: 48px; height: 48px; }

/* ============================================
   PRIVATE MESSAGES
   ============================================ */
.cr-dm-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; overscroll-behavior: contain; }
.cr-dm-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--cr-chat-text-muted); font-size: 13px;
  padding: 32px 16px; text-align: center;
}
.cr-dm-empty svg { width: 28px; height: 28px; opacity: 0.3; }
.cr-dm-list { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.cr-dm-list::-webkit-scrollbar { width: 4px; }
.cr-dm-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.cr-dm-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: transparent; border: 1px solid transparent;
  border-radius: 10px; cursor: pointer;
  transition: all var(--cr-chat-transition);
  text-align: left; color: inherit; font-family: inherit;
}
.cr-dm-item:hover { background: rgba(255,255,255,0.04); border-color: var(--cr-chat-border); }
.cr-dm-item.unread { background: rgba(var(--cr-chat-primary-rgb), 0.04); border-color: rgba(var(--cr-chat-primary-rgb), 0.1); }
.cr-dm-item__avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.cr-dm-item__online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: #22c55e; border: 2px solid var(--cr-chat-bg-dark);
}
.cr-dm-item__body { flex: 1; min-width: 0; }
.cr-dm-item__top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cr-dm-item__name { font-size: 13px; font-weight: 600; color: var(--cr-chat-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-dm-item__time { font-size: 10px; color: var(--cr-chat-text-muted); flex-shrink: 0; }
.cr-dm-item.unread .cr-dm-item__time { color: var(--cr-chat-primary); }
.cr-dm-item__preview { font-size: 12px; color: var(--cr-chat-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.cr-dm-item.unread .cr-dm-item__preview { color: var(--cr-chat-text-secondary); font-weight: 500; }
.cr-dm-item__you { color: var(--cr-chat-text-muted); font-weight: 400; }
.cr-dm-item__badge {
  flex-shrink: 0; min-width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px; background: var(--cr-chat-primary);
  border-radius: 10px; font-size: 10px; font-weight: 700; color: #000;
}

/* Conversation View */
.cr-dm-convo { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.cr-dm-convo__head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--cr-chat-bg-medium); border-bottom: 1px solid var(--cr-chat-border);
}
.cr-dm-back-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: transparent; border: none;
  color: var(--cr-chat-text-muted); cursor: pointer;
  transition: all var(--cr-chat-transition);
}
.cr-dm-back-btn:hover { background: rgba(255,255,255,0.06); color: var(--cr-chat-text-primary); }
.cr-dm-back-btn svg { width: 16px; height: 16px; }
.cr-dm-convo__avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.cr-dm-convo__info { display: flex; flex-direction: column; }
.cr-dm-convo__name { font-size: 13px; font-weight: 600; color: var(--cr-chat-text-primary); }
.cr-dm-convo__online { font-size: 10px; color: #22c55e; font-weight: 500; }
.cr-dm-convo__messages {
  flex: 1; overflow-y: auto; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 4px;
  overscroll-behavior: contain;
}
.cr-dm-convo__messages::-webkit-scrollbar { width: 4px; }
.cr-dm-convo__messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 4px; }

/* DM Bubbles */
.cr-dm-bubble { max-width: 80%; padding: 0; animation: crDmSlideIn 0.2s ease-out; }
@keyframes crDmSlideIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.cr-dm-bubble.mine { align-self: flex-end; }
.cr-dm-bubble.theirs { align-self: flex-start; }
.cr-dm-bubble__text { padding: 8px 12px; border-radius: 14px; font-size: 13px; line-height: 1.4; word-break: break-word; }
.cr-dm-bubble.mine .cr-dm-bubble__text { background: rgba(var(--cr-chat-primary-rgb), 0.15); color: var(--cr-chat-text-primary); border-bottom-right-radius: 4px; }
.cr-dm-bubble.theirs .cr-dm-bubble__text { background: rgba(255,255,255,0.06); color: var(--cr-chat-text-primary); border-bottom-left-radius: 4px; }
.cr-dm-bubble__meta { display: flex; align-items: center; gap: 4px; padding: 2px 6px 0; }
.cr-dm-bubble.mine .cr-dm-bubble__meta { justify-content: flex-end; }
.cr-dm-bubble__time { font-size: 10px; color: var(--cr-chat-text-muted); }
.cr-dm-bubble__status { width: 14px; height: 14px; color: var(--cr-chat-text-muted); }
.cr-dm-bubble__status.read { color: var(--cr-chat-primary); }
.cr-dm-bubble__status svg { width: 100%; height: 100%; }
.cr-dm-convo__input {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--cr-chat-border); background: var(--cr-chat-bg-medium);
}
.cr-dm-convo__input input {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--cr-chat-border); border-radius: 20px;
  padding: 8px 14px; color: var(--cr-chat-text-primary);
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color var(--cr-chat-transition);
}
.cr-dm-convo__input input::placeholder { color: var(--cr-chat-text-muted); }
.cr-dm-convo__input input:focus { border-color: rgba(var(--cr-chat-primary-rgb), 0.3); }
.cr-dm-send-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(var(--cr-chat-primary-rgb), 0.15);
  border: none; color: var(--cr-chat-primary);
  cursor: pointer; transition: all var(--cr-chat-transition); flex-shrink: 0;
}
.cr-dm-send-btn:hover:not(:disabled) { background: rgba(var(--cr-chat-primary-rgb), 0.25); transform: scale(1.05); }
.cr-dm-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.cr-dm-send-btn svg { width: 16px; height: 16px; }

/* ============================================
   FLOATING CHAT BUTTON
   ============================================ */
.cr-floating-chat-btn {
  position: fixed; bottom: 24px; right: 24px;
  width: 54px; height: 54px;
  background: linear-gradient(135deg, var(--cr-chat-primary), var(--cr-chat-secondary));
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 9998;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 20px rgba(var(--cr-chat-primary-rgb), 0.2);
  transition: all var(--cr-chat-transition);
}
.cr-floating-chat-btn:hover {
  transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,0.4), 0 0 30px rgba(var(--cr-chat-primary-rgb), 0.3);
}
.cr-floating-chat-btn:active { transform: scale(0.95); }
.cr-floating-chat-btn svg { width: 24px; height: 24px; color: #000; }
.cr-floating-notification {
  position: absolute; top: 0; right: 0;
  width: 14px; height: 14px; background: #ef4444;
  border: 2px solid var(--cr-chat-bg-dark); border-radius: 50%;
  animation: cr-pulse 1.5s ease-in-out infinite;
}

/* ============================================
   FLOATING CHAT PANEL
   ============================================ */
.cr-floating-chat-panel {
  position: fixed; bottom: 24px; right: 24px;
  width: 380px; height: 540px; z-index: 9999;
  animation: cr-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cr-slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cr-floating-chat-panel .cr-chat-container {
  height: 100%; border-radius: var(--cr-chat-radius);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04) inset;
}
.cr-floating-close-btn {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 7px;
  color: var(--cr-chat-text-muted); cursor: pointer; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--cr-chat-transition);
}
.cr-floating-close-btn:hover { background: rgba(239,68,68,0.1); color: #ef4444; border-color: rgba(239,68,68,0.2); }
.cr-floating-close-btn svg { width: 14px; height: 14px; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .cr-floating-chat-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%; height: 75vh;
    border-radius: 16px 16px 0 0;
    animation: cr-slide-up-mobile 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes cr-slide-up-mobile { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: translateY(0); } }
  .cr-floating-chat-panel .cr-chat-container { border-radius: 16px 16px 0 0; }
  .cr-floating-chat-btn { bottom: 14px; right: 14px; width: 48px; height: 48px; }
  .cr-msg-avatar-wrap { width: 22px; height: 22px; }
  .cr-msg-avatar { width: 22px; height: 22px; min-width: 22px; font-size: 9px; }
  .cr-msg-text { font-size: 12px; }
  .cr-msg-time { opacity: 0.4; }
  .cr-msg-toolbar { display: none; }
  .cr-emoji-picker__grid { grid-template-columns: repeat(7, 1fr); }
  .cr-msg-reply { margin-left: 26px; }
  .cr-msg-reactions { margin-left: 30px; }
  .cr-msg-qr { margin-left: 30px; }
  .cr-msg--threaded { padding-left: 10px; }
  .cr-msg-avatar-wrap::before { width: 34px; height: 34px; }
  .cr-msg-avatar-wrap.avatar-platinum::before,
  .cr-msg-avatar-wrap.avatar-diamond::before { width: 36px; height: 36px; }
  .cr-msg-avatar-wrap.avatar-challenger::before,
  .cr-msg-avatar-wrap.avatar-ruby::before,
  .cr-msg-avatar-wrap.avatar-legendary::before { width: 38px; height: 38px; }
}

@media (max-width: 380px) {
  .cr-chat-header-title { font-size: 11px; }
  .cr-chat-online-indicator span { display: none; }
  .cr-chat-tab { font-size: 9px; padding: 6px 4px; }
  .cr-emoji-picker__grid { grid-template-columns: repeat(6, 1fr); }
}

/* ============================================
   ACCESSIBILITY: Focus visible
   ============================================ */
.cr-chat-tab:focus-visible,
.cr-chat-send-btn:focus-visible,
.cr-msg-toolbar__btn:focus-visible,
.cr-chat-emoji-btn:focus-visible,
.cr-chat-minimize-btn:focus-visible,
.cr-chat-dm-toggle:focus-visible,
.cr-floating-chat-btn:focus-visible,
.cr-msg-qr__btn:focus-visible,
.cr-msg-rx:focus-visible {
  outline: 2px solid var(--cr-chat-primary);
  outline-offset: 2px;
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}