/* ═══════════════════════════════════════════════════════════════════
   PULSE CHAT — "Liquid Carbon" Design System
   Fonts: Clash Display (headings) + Plus Jakarta Sans (body) + JetBrains Mono (code/meta)
   Palette: Near-black obsidian · Electric mint · Amber ember · Crystal glass
═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Clash+Display:wght@400;500;600;700&family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ───────────────────────────────────────────────────── */
:root {
  /* Core */
  --bg-void:       #04050a;
  --bg-deep:       #080b14;
  --bg-surface:    #0d1120;
  --bg-glass:      rgba(255,255,255,0.028);
  --bg-glass-hover:rgba(255,255,255,0.052);
  --bg-elevated:   rgba(255,255,255,0.06);

  /* Borders */
  --border-subtle: rgba(255,255,255,0.055);
  --border-mid:    rgba(255,255,255,0.09);
  --border-bright: rgba(255,255,255,0.14);

  /* Accents */
  --mint:          #00e5b0;
  --mint-dim:      #00c896;
  --mint-glow:     rgba(0,229,176,0.18);
  --mint-faint:    rgba(0,229,176,0.06);
  --purple:        #7c6af7;
  --purple-dim:    #6a56e6;
  --purple-glow:   rgba(124,106,247,0.18);
  --ember:         #ff7b45;
  --ember-glow:    rgba(255,123,69,0.18);

  /* Text */
  --tx-primary:    #eef0f8;
  --tx-secondary:  #8b90ad;
  --tx-muted:      #40465c;
  --tx-placeholder:rgba(139,144,173,0.45);

  /* Avatar palette */
  --av1: #00e5b0; --av2: #ff7b45; --av3: #7c6af7;
  --av4: #f0c040; --av5: #4cb8f5; --av6: #e05c8a;
  --av7: #a0e040; --av8: #c47cf7;

  /* Dimensions */
  --sidebar-w:     232px;
  --header-h:      58px;
  --input-h:       72px;
  --radius-xs:     5px;
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     18px;
  --radius-xl:     24px;
  --radius-pill:   999px;

  /* Fonts */
  --font-display:  'Clash Display', sans-serif;
  --font-body:     'Plus Jakarta Sans', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;

  /* Motion */
  --spring:        cubic-bezier(.16,1,.3,1);
  --ease-out:      cubic-bezier(.22,1,.36,1);
  --ease-in-out:   cubic-bezier(.45,0,.25,1);
  --t-fast:        0.15s;
  --t-mid:         0.28s;
  --t-slow:        0.5s;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--tx-primary);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  cursor: default;
}

/* ── Aurora Canvas ───────────────────────────────────────────────── */
#aurora {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.65;
}

/* ── Film Grain ──────────────────────────────────────────────────── */
.grain {
  position: fixed;
  inset: -200%;
  width: 400%; height: 400%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  animation: grainShift 0.8s steps(1) infinite;
}
@keyframes grainShift {
  0%  { transform: translate(0,0); }
  25% { transform: translate(-2%,-3%); }
  50% { transform: translate(3%, 2%); }
  75% { transform: translate(-1%, 4%); }
}

/* ══════════════════ LOGIN ═════════════════════════════════════════ */

#login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  transition: opacity var(--t-slow) var(--ease-out),
              transform var(--t-slow) var(--ease-out);
}

#login-overlay.out {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}

.login-scene { position: relative; }

.login-halo {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 520px; height: 520px;
  background: radial-gradient(ellipse,
    rgba(0,229,176,0.07) 0%,
    rgba(124,106,247,0.05) 45%,
    transparent 72%);
  border-radius: 50%;
  pointer-events: none;
  animation: haloPulse 5s ease-in-out infinite;
}

@keyframes haloPulse {
  0%,100% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  50%      { opacity: 0.65; transform: translate(-50%,-50%) scale(1.08); }
}

.login-card {
  position: relative;
  width: 400px;
  padding: 48px 44px 40px;
  background: linear-gradient(
    160deg,
    rgba(255,255,255,0.055) 0%,
    rgba(255,255,255,0.028) 60%,
    rgba(0,229,176,0.025) 100%
  );
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 40px 80px -20px rgba(0,0,0,0.7),
    0 0 60px -10px rgba(0,229,176,0.05);
  backdrop-filter: blur(40px) saturate(1.4);
  -webkit-backdrop-filter: blur(40px) saturate(1.4);
  display: flex; flex-direction: column; gap: 22px;
  animation: cardRise 0.7s var(--spring) both;
}

@keyframes cardRise {
  from { opacity: 0; transform: translateY(32px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

/* Brand */
.brand {
  display: flex; align-items: center; gap: 12px;
}

.brand-orb {
  position: relative;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}

.orb-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(0,229,176,0.5);
  animation: orbPulse 2.4s ease-in-out infinite;
}

@keyframes orbPulse {
  0%,100% { transform: scale(1); opacity: 0.6; }
  50%     { transform: scale(1.35); opacity: 0; }
}

.orb-core {
  width: 14px; height: 14px;
  background: radial-gradient(circle at 35% 35%, #00ffd4, var(--mint));
  border-radius: 50%;
  box-shadow: 0 0 18px var(--mint), 0 0 36px rgba(0,229,176,0.3);
  animation: coreBreathe 3s ease-in-out infinite;
}

@keyframes coreBreathe {
  0%,100% { box-shadow: 0 0 14px var(--mint), 0 0 28px rgba(0,229,176,0.25); }
  50%     { box-shadow: 0 0 24px var(--mint), 0 0 50px rgba(0,229,176,0.4); }
}

.brand-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--tx-primary);
  background: linear-gradient(135deg, #fff 0%, var(--mint) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-tagline {
  font-size: 13.5px;
  color: var(--tx-secondary);
  font-weight: 300;
  margin-top: -12px;
  letter-spacing: 0.3px;
  font-style: italic;
}

/* Field */
.field-wrap { display: flex; flex-direction: column; gap: 8px; }

.field-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--tx-muted);
}

.field-box {
  position: relative;
}

.field-box input {
  width: 100%;
  padding: 13px 18px;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--tx-primary);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  outline: none;
  transition:
    border-color var(--t-mid) var(--ease-out),
    background var(--t-mid) var(--ease-out),
    box-shadow var(--t-mid) var(--ease-out);
}

.field-box input::placeholder { color: var(--tx-placeholder); }

.field-underline {
  position: absolute;
  bottom: -1px; left: 12px; right: 12px;
  height: 2px;
  background: linear-gradient(90deg, var(--mint), #7c6af7);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-mid) var(--spring);
}

.field-box input:focus {
  border-color: rgba(0,229,176,0.25);
  background: rgba(0,229,176,0.04);
  box-shadow: 0 0 0 3px rgba(0,229,176,0.08);
}
.field-box input:focus ~ .field-underline { transform: scaleX(1); }

/* Join button */
.join-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dim) 100%);
  border: none;
  border-radius: var(--radius-md);
  color: #021a14;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  overflow: hidden;
  transition:
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-mid) var(--ease-out),
    filter var(--t-mid);
  box-shadow: 0 6px 30px rgba(0,229,176,0.28), 0 2px 8px rgba(0,0,0,0.3);
}

.join-btn .btn-icon { transition: transform var(--t-mid) var(--spring); }

.join-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,229,176,0.4), 0 4px 12px rgba(0,0,0,0.3);
  filter: brightness(1.06);
}
.join-btn:hover .btn-icon { transform: translateX(3px); }
.join-btn:active { transform: translateY(0) scale(0.98); }

.btn-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg,
    transparent 30%,
    rgba(255,255,255,0.25) 50%,
    transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s var(--ease-out);
}
.join-btn:hover .btn-shimmer { transform: translateX(100%); }

.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--tx-muted);
}
.login-hint kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--tx-secondary);
}

/* ══════════════════ APP SHELL ══════════════════════════════════════ */

#app {
  position: relative; z-index: 10;
  display: flex;
  height: 100vh;
  overflow: hidden;
  animation: appReveal 0.6s var(--spring) both;
}

@keyframes appReveal {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: none; }
}

#app.hidden { display: none; }

/* ══════════════════ SIDEBAR ════════════════════════════════════════ */

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.032) 0%,
    rgba(255,255,255,0.018) 100%
  );
  border-right: 1px solid var(--border-subtle);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,229,176,0.15), transparent);
}

/* Sidebar top brand */
.sb-top {
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.brand-sm {
  display: flex; align-items: center; gap: 9px;
}

.orb-sm-dot {
  width: 9px; height: 9px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--mint);
  animation: coreBreathe 3s ease-in-out infinite;
}

.brand-sm-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--tx-primary);
}

/* Section label */
.sb-section-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--tx-muted);
  flex-shrink: 0;
}

.count-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  background: rgba(0,229,176,0.12);
  color: var(--mint);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0,229,176,0.2);
  transition: all var(--t-mid);
}

/* User list */
#user-list {
  flex: 1;
  list-style: none;
  padding: 4px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#user-list::-webkit-scrollbar { width: 3px; }
#user-list::-webkit-scrollbar-track { background: transparent; }
#user-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
}

#user-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 400;
  color: var(--tx-secondary);
  cursor: pointer;
  transition:
    background var(--t-fast),
    color var(--t-fast),
    transform var(--t-fast);
  animation: userSlideIn 0.3s var(--spring) both;
  position: relative;
  overflow: hidden;
}

@keyframes userSlideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: none; }
}

#user-list li:hover {
  background: var(--bg-glass-hover);
  color: var(--tx-primary);
  transform: translateX(2px);
}

.ul-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #000;
  flex-shrink: 0;
  position: relative;
}

.ul-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 8px; height: 8px;
  background: #3ecf8e;
  border-radius: 50%;
  border: 2px solid var(--bg-deep);
  box-shadow: 0 0 6px rgba(62,207,142,0.6);
}

.ul-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar footer / my profile */
.sb-footer {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.my-profile {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0,229,176,0.04);
  border: 1px solid rgba(0,229,176,0.1);
  transition: background var(--t-fast);
}

.my-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #000;
  flex-shrink: 0;
  background: var(--mint);
}

.my-name-text {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tx-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.you-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--mint);
  background: rgba(0,229,176,0.1);
  border: 1px solid rgba(0,229,176,0.2);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

/* ══════════════════ CHAT AREA ══════════════════════════════════════ */

#chat-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
  position: relative;
}

/* Header */
#chat-header {
  height: var(--header-h);
  padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.018);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.ch-hash {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--mint);
  margin-right: 6px;
  line-height: 1;
}

.ch-channel {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--tx-primary);
  letter-spacing: -0.3px;
}

.ch-sep {
  margin: 0 10px;
  color: var(--tx-muted);
  font-size: 16px;
}

.ch-sub {
  font-size: 12.5px;
  color: var(--tx-muted);
  font-weight: 400;
}

.ch-left { display: flex; align-items: center; }
.ch-right {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--tx-muted);
  font-family: var(--font-mono);
}

#logout-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--tx-muted);
  cursor: pointer;
  transition: all var(--t-fast);
}

#logout-btn:hover {
  background: rgba(255,107,107,0.1);
  color: #ff6b6b;
  border-color: #ff6b6b;
  transform: scale(1.06);
}

#logout-btn:active { transform: scale(0.95); }

.live-dot {
  width: 7px; height: 7px;
  background: #3ecf8e;
  border-radius: 50%;
  box-shadow: 0 0 8px #3ecf8e;
  animation: livePulse 2s ease-in-out infinite;
}

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

.live-label {
  color: #3ecf8e;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Messages */
#messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  scroll-behavior: smooth;
  position: relative;
}

#messages-container::-webkit-scrollbar { width: 4px; }
#messages-container::-webkit-scrollbar-track { background: transparent; }
#messages-container::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
}
#messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.12);
}

#messages-inner { max-width: 860px; margin: 0 auto; }

.chat-welcome {
  text-align: center;
  padding: 48px 0 32px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  opacity: 0.5;
}

.welcome-icon {
  font-size: 36px;
  animation: floatIcon 4s ease-in-out infinite;
}
@keyframes floatIcon {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}

.welcome-text {
  font-size: 13px;
  color: var(--tx-muted);
  font-weight: 400;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 8px;
}

/* Individual message */
.msg {
  display: flex;
  gap: 12px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  cursor: default;
  position: relative;
  transition:
    background var(--t-fast),
    transform var(--t-fast);
  animation: msgAppear 0.25s var(--spring) both;
}

@keyframes msgAppear {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.msg:hover {
  background: rgba(255,255,255,0.025);
}

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #000;
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
}

.msg-body { flex: 1; min-width: 0; }

.msg-meta {
  display: flex; align-items: baseline; gap: 9px;
  margin-bottom: 3px;
}

.msg-username {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tx-primary);
  letter-spacing: 0.1px;
}

.msg-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--tx-muted);
}

.msg-status {
  margin-left: 4px;
  font-size: 11px;
}

.msg-text {
  font-size: 14.5px;
  color: var(--tx-secondary);
  line-height: 1.55;
  word-break: break-word;
  font-weight: 400;
}

.msg-text[contenteditable="true"]:focus {
  outline: 1px dashed var(--mint);
  background: rgba(0,229,176,0.05);
  border-radius: var(--radius-sm);
}

.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.reply-btn {
  background: rgba(0,229,176,0.1);
  border: 1px solid rgba(0,229,176,0.3);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast);
}

.reply-btn:hover {
  background: rgba(0,229,176,0.2);
  transform: scale(1.08);
}

/* Message reply indicator */
.msg-reply {
  padding: 6px 10px;
  margin-bottom: 4px;
  background: rgba(0,229,176,0.05);
  border-left: 2px solid var(--mint);
  border-radius: var(--radius-xs);
  font-size: 12px;
}

.msg-reply-label {
  color: var(--mint);
  font-weight: 600;
  margin-right: 4px;
}

.msg-reply-text {
  color: var(--tx-secondary);
}

@media (hover: hover) {
  .msg-actions {
    opacity: 0;
    transition: opacity var(--t-fast);
  }
  .msg:hover .msg-actions {
    opacity: 1;
  }
}

.reaction-btn, .delete-btn {
  background: rgba(13,17,32,0.8);
  border: 1px solid var(--border-mid);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast);
  backdrop-filter: blur(10px);
}

.reaction-btn, .delete-btn {
  background: rgba(13,17,32,0.8);
  border: 1px solid var(--border-mid);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast);
  backdrop-filter: blur(10px);
}

.reaction-btn {
  color: var(--tx-secondary);
}

.reaction-btn:hover { 
  background: rgba(0,229,176,0.15);
  border-color: var(--mint);
  transform: translateY(-1px);
}

.delete-btn { 
  color: #ff6b6b;
}

.delete-btn:hover { 
  background: rgba(255,107,107,0.15);
  border-color: #ff6b6b;
  transform: translateY(-1px);
}

/* User tooltip */
.user-tooltip {
  position: fixed;
  background: rgba(13,17,32,0.95);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--tx-primary);
  backdrop-filter: blur(10px);
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--t-fast);
  pointer-events: none;
  min-width: 180px;
}

.user-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

/* System messages */
.msg-system {
  text-align: center;
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tx-muted);
  position: relative;
  animation: msgAppear 0.25s var(--spring) both;
}

.msg-system::before,
.msg-system::after {
  content: '';
  position: absolute;
  top: 50%; height: 1px;
  width: 28%;
  background: linear-gradient(90deg, transparent, var(--border-subtle));
}
.msg-system::before { left: 8%; }
.msg-system::after  { right: 8%; background: linear-gradient(270deg, transparent, var(--border-subtle)); }

/* Image in message */
.msg-image {
   max-width: 340px;
   max-height: 280px;
   border-radius: var(--radius-md);
   margin-top: 6px;
   border: 1px solid var(--border-subtle);
   object-fit: cover;
   display: block;
   transition: transform var(--t-mid) var(--ease-out);
 }

.image-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mint);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

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

/* ══════════════════ INPUT BAR ══════════════════════════════════════ */

/* Reply Preview */
#reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  background: rgba(0,229,176,0.06);
  border-top: 1px solid rgba(0,229,176,0.2);
  border-left: 3px solid var(--mint);
}

#reply-preview.hidden {
  display: none;
}

.reply-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.reply-info {
  display: flex;
  align-items: center;
  gap: 4px;
}

.reply-label {
  color: var(--tx-muted);
}

.reply-username {
  color: var(--mint);
  font-weight: 600;
}

.reply-text {
  color: var(--tx-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.cancel-reply {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--tx-muted);
  cursor: pointer;
  font-size: 14px;
  border-radius: 3px;
}

.cancel-reply:hover {
  color: var(--tx-primary);
  background: rgba(255,255,255,0.1);
}

#input-bar {
  height: var(--input-h);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.022);
  border-top: 1px solid var(--border-subtle);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

#input-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(0,229,176,0.1) 30%,
    rgba(0,229,176,0.1) 70%,
    transparent);
  pointer-events: none;
}

/* Icon button (attach) */
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--tx-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background var(--t-fast),
    color var(--t-fast),
    border-color var(--t-fast),
    transform var(--t-fast);
}

.icon-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--tx-secondary);
  border-color: var(--border-mid);
  transform: scale(1.06);
}
.icon-btn:active { transform: scale(0.95); }

/* Message input */
.msg-input-wrap {
  flex: 1;
  position: relative;
}

#message-input {
  width: 100%;
  padding: 11px 18px;
  background: rgba(255,255,255,0.038);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--tx-primary);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 400;
  outline: none;
  transition:
    border-color var(--t-mid) var(--ease-out),
    background var(--t-mid) var(--ease-out),
    box-shadow var(--t-mid) var(--ease-out);
}

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

#message-input:focus {
  border-color: rgba(0,229,176,0.22);
  background: rgba(0,229,176,0.035);
  box-shadow:
    0 0 0 3px rgba(0,229,176,0.07),
    0 2px 12px rgba(0,0,0,0.2);
}

#message-input:disabled { opacity: 0.5; cursor: not-allowed; }

.input-focus-ring {
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--radius-md) + 2px);
  pointer-events: none;
  box-shadow: 0 0 0 0 rgba(0,229,176,0);
  transition: box-shadow var(--t-mid) var(--ease-out);
}

#message-input:focus + .input-focus-ring {
  box-shadow: 0 0 0 3px rgba(0,229,176,0.08);
}

/* Send button */
.send-btn {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dim) 100%);
  border: none;
  border-radius: var(--radius-md);
  color: #021a14;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-mid) var(--ease-out),
    filter var(--t-mid);
  box-shadow: 0 4px 20px rgba(0,229,176,0.25);
}

.send-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 28px rgba(0,229,176,0.4);
  filter: brightness(1.08);
}
.send-btn:active  { transform: scale(0.93); }

.send-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.35), transparent 70%);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.send-btn:hover::after { opacity: 1; }

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
  box-shadow: none !important;
}

/* ── PWA Banner ───────────────────────────────────────────────────── */
#pwa-banner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: bannerSlideIn 0.4s var(--spring) both;
}

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

.pwa-content {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--tx-primary);
}

#pwa-install, #pwa-dismiss {
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

#pwa-install {
  background: var(--mint);
  color: #021a14;
}

#pwa-dismiss {
  background: transparent;
  color: var(--tx-muted);
}

/* ══════════════════ SCROLLBAR — MESSAGES ═══════════════════════════ */
#messages-container {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.07) transparent;
}

/* ══════════════════ RESPONSIVE ═════════════════════════════════════ */
/* Scroll controller */
#scroll-ctrl {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-mid);
  border-radius: 50%;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 90;
  transition: all var(--t-fast);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

#scroll-ctrl:active {
  cursor: grabbing;
  opacity: 0.8;
}

#scroll-ctrl:hover {
  background: rgba(0,229,176,0.15);
  border-color: var(--mint);
  transform: translateY(-50%) scale(1.08);
}

#scroll-ctrl.dragging {
  transition: none;
}

#scroll-ctrl svg {
  width: 24px;
  height: 24px;
  color: var(--tx-primary);
}

/* ── Mobile Menu Button ────────────────────────────────────────── */
.menu-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: all var(--t-fast);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.menu-btn:hover {
  background: rgba(0,229,176,0.15);
  border-color: var(--mint);
  transform: scale(1.08);
}

.menu-btn svg {
  color: var(--tx-primary);
  width: 20px;
  height: 20px;
}

/* ── Mobile Overlay ───────────────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 95;
}

#sidebar-overlay.show {
  display: block;
}

/* ── Mobile Sidebar ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .menu-btn {
    display: flex;
  }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 75%;
    max-width: 280px;
    height: 100%;
    transform: translateX(-100%);
    transition: transform var(--t-mid) var(--ease-out);
    z-index: 100;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #chat-area {
    width: 100%;
  }
}

@media (max-width: 680px) {
   #scroll-ctrl {
     width: 44px;
     height: 44px;
     right: 12px;
   }
}

/* ── GIF Modal ─────────────────────────────────────────────────────── */
 #gif-modal {
   display: none;
   position: fixed;
   inset: 0;
   background: rgba(0,0,0,0.95);
   z-index: 2000;
   padding: 20px;
   overflow-y: auto;
 }

 #gif-modal.show {
   display: block;
 }

 .gif-content {
   max-width: 900px;
   margin: 0 auto;
 }

 .gif-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   padding: 16px 20px;
   background: rgba(255,255,255,0.05);
   border-radius: var(--radius-md);
   margin-bottom: 16px;
   border: 1px solid var(--border-subtle);
 }

 .gif-header span {
   color: var(--purple);
   font-family: var(--font-display);
   font-weight: 600;
   font-size: 16px;
 }

 .gif-close {
   width: 32px;
   height: 32px;
   border: none;
   background: rgba(255,255,255,0.1);
   color: var(--tx-primary);
   border-radius: var(--radius-sm);
   cursor: pointer;
   font-size: 18px;
 }

 .gif-close:hover {
   background: rgba(255,255,255,0.2);
 }

 .gif-grid {
   display: grid;
   grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
   gap: 12px;
 }

 .gif-item {
   aspect-ratio: 1;
   border-radius: var(--radius-md);
   overflow: hidden;
   cursor: pointer;
   border: 1px solid var(--border-subtle);
   transition: all var(--t-fast);
 }

 .gif-item:hover {
   transform: scale(1.05);
   border-color: var(--purple);
 }

 .gif-item img {
   width: 100%;
   height: 100%;
   object-fit: cover;
 }

 .gif-loading {
   grid-column: 1 / -1;
   text-align: center;
   padding: 40px;
   color: var(--tx-muted);
 }
 .friend-request {
   display: flex;
   align-items: center;
   gap: 8px;
   padding: 8px 12px;
   background: linear-gradient(135deg, rgba(0,229,176,0.08) 0%, rgba(124,106,247,0.08) 100%);
   border: 1px solid rgba(0,229,176,0.2);
   border-radius: var(--radius-sm);
   font-size: 12px;
   color: var(--tx-primary);
   margin-bottom: 4px;
   animation: friendRequestSlide 0.4s var(--spring) both;
 }

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

 .friend-request span {
   flex: 1;
 }

 .friend-request button {
   padding: 6px 12px;
   border: none;
   border-radius: var(--radius-sm);
   font-size: 11px;
   font-weight: 600;
   cursor: pointer;
   transition: all var(--t-fast);
   position: relative;
   overflow: hidden;
 }

 .friend-request button::before {
   content: '';
   position: absolute;
   inset: 0;
   background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
   opacity: 0;
   transition: opacity var(--t-fast);
 }

 .friend-request button:hover::before {
   opacity: 1;
 }

 .friend-request button:first-of-type {
   background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dim) 100%);
   color: #021a14;
   box-shadow: 0 2px 8px rgba(0,229,176,0.25);
 }

 .friend-request button:first-of-type:hover {
   transform: translateY(-1px);
   box-shadow: 0 4px 12px rgba(0,229,176,0.4);
 }

 .friend-request button:first-of-type:active {
   transform: scale(0.95);
 }

 .friend-request button:last-of-type {
   background: rgba(255,255,255,0.06);
   color: var(--tx-secondary);
   border: 1px solid var(--border-subtle);
 }

 .friend-request button:last-of-type:hover {
   background: rgba(255,255,255,0.1);
   color: var(--tx-primary);
   border-color: var(--border-mid);
   transform: translateY(-1px);
 }

 .friend-request button:last-of-type:active {
   transform: scale(0.95);
 }

/* Friend list item styling */
 #user-list li.friend-item {
   position: relative;
 }

 #user-list li.friend-item::before {
   content: '';
   position: absolute;
   left: 0;
   top: 50%;
   transform: translateY(-50%);
   width: 6px;
   height: 6px;
   background: var(--mint);
   border-radius: 50%;
 }

 /* Add friend button in user list */
 #user-list li button.add-friend-btn {
   width: 24px;
   height: 24px;
   display: flex;
   align-items: center;
   justify-content: center;
   background: rgba(0,229,176,0.1);
   border: 1px solid rgba(0,229,176,0.3);
   border-radius: 50%;
   color: var(--mint);
   font-size: 14px;
   font-weight: 600;
   cursor: pointer;
   transition: all var(--t-fast);
   margin-left: auto;
   flex-shrink: 0;
 }

 #user-list li button.add-friend-btn:hover {
   background: rgba(0,229,176,0.2);
   border-color: var(--mint);
   transform: scale(1.1) rotate(90deg);
   box-shadow: 0 0 12px rgba(0,229,176,0.4);
 }

 #user-list li button.add-friend-btn:active {
   transform: scale(0.9) rotate(90deg);
 }

 /* Section headers */
 #user-list li.section-header {
   padding: 6px 12px 2px;
   font-size: 11px;
   font-weight: 600;
   color: var(--tx-secondary);
   pointer-events: none;
   text-transform: uppercase;
   letter-spacing: 0.5px;
 }