/* ============================================
   NEXUS CHAT — CYBERPUNK DARK THEME
   ============================================ */

:root {
  --bg-deep: #030610;
  --bg-panel: #080f1e;
  --bg-card: #0d1829;
  --bg-hover: #111e33;
  --bg-input: #0a1525;
  --cyan: #00f5ff;
  --cyan-dim: #00c4cc;
  --cyan-glow: rgba(0, 245, 255, 0.15);
  --purple: #7c3aed;
  --purple-glow: rgba(124, 58, 237, 0.15);
  --amber: #f59e0b;
  --green: #10b981;
  --pink: #ec4899;
  --red: #ef4444;
  --text-primary: #e2eaf8;
  --text-secondary: #7a9cc4;
  --text-muted: #3d5a7e;
  --border: rgba(0, 245, 255, 0.08);
  --border-active: rgba(0, 245, 255, 0.3);
  --sidebar-w: 260px;
  --header-h: 60px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Orbitron', monospace;
  --font-body: 'Rajdhani', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --shadow-cyan: 0 0 20px rgba(0, 245, 255, 0.2);
  --shadow-purple: 0 0 20px rgba(124, 58, 237, 0.3);
}

.light-mode {
  --bg-deep: #f0f4ff;
  --bg-panel: #ffffff;
  --bg-card: #f8faff;
  --bg-hover: #eef2ff;
  --bg-input: #f0f4ff;
  --text-primary: #1a2540;
  --text-secondary: #4a6080;
  --text-muted: #8aa0c0;
  --border: rgba(0, 120, 200, 0.1);
  --border-active: rgba(0, 120, 200, 0.4);
  --cyan-glow: rgba(0, 120, 200, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ============ BACKGROUND CANVAS ============ */

#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  opacity: 0.6;
}

.scanlines {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 245, 255, 0.015) 2px,
    rgba(0, 245, 255, 0.015) 4px
  );
  z-index: 1;
  pointer-events: none;
}

.noise-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  z-index: 1;
  pointer-events: none;
}

/* ============ AUTH ============ */

.auth-container {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
}

.auth-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-active);
  border-radius: 4px;
  padding: 40px;
  width: 420px;
  max-width: 95vw;
  position: relative;
  box-shadow: var(--shadow-cyan), inset 0 1px 0 rgba(0,245,255,0.1);
  animation: cardEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-style: preserve-3d;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(30px) rotateX(8deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

.auth-card::before {
  content: '';
  position: absolute;
  top: -1px; left: 10%; right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  border-radius: 2px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 36px;
}

.logo-3d {
  position: relative;
  display: inline-block;
  margin-bottom: 8px;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan), var(--purple) 60%, var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 8px;
  text-shadow: none;
  filter: drop-shadow(0 0 20px var(--cyan));
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 15px var(--cyan)); }
  50% { filter: drop-shadow(0 0 30px var(--cyan)) drop-shadow(0 0 60px var(--purple)); }
}

.auth-tagline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeSlide 0.4s ease; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.form-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--cyan);
  margin-bottom: 24px;
  text-align: center;
}

.input-group { margin-bottom: 16px; }

.input-group label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  transition: var(--transition);
}

.input-wrap:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

.input-wrap i:first-child {
  color: var(--text-muted);
  font-size: 13px;
  padding: 0 12px;
  min-width: 40px;
}

.input-wrap input, .input-wrap textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 12px 12px 0;
}

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

.toggle-pw {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 12px;
  font-size: 13px;
  transition: color 0.2s;
}
.toggle-pw:hover { color: var(--cyan); }

.btn-primary {
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 1px solid var(--cyan);
  border-radius: 3px;
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 4px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  margin-top: 8px;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--cyan-glow);
  box-shadow: var(--shadow-cyan);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-shimmer {
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0,245,255,0.2), transparent);
  transition: left 0.4s;
}

.btn-primary:hover .btn-shimmer { left: 100%; }

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 600;
}

.auth-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 10px;
  text-align: center;
  min-height: 18px;
  font-family: var(--font-mono);
}

/* ============ APP LAYOUT ============ */

.app-container {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ============ SIDEBAR ============ */

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 10;
  transition: transform 0.3s ease;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent, var(--cyan), var(--purple), transparent);
  opacity: 0.3;
}

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

.logo-small {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-actions { display: flex; gap: 4px; }

.user-profile-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.user-profile-strip:hover { background: var(--bg-hover); }

.user-avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  border: 2px solid transparent;
  background-clip: padding-box;
  position: relative;
}

.user-avatar-sm::after {
  content: '';
  position: absolute;
  bottom: -2px; right: -2px;
  width: 10px; height: 10px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid var(--bg-panel);
}

.user-info-sm { flex: 1; min-width: 0; }

.user-name-sm {
  display: block;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.user-status.online { color: var(--green); }

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 12px;
  transition: var(--transition);
}

.sidebar-search:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px var(--cyan-glow);
}

.sidebar-search i { color: var(--text-muted); font-size: 12px; }

.sidebar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
  font-family: var(--font-body);
}

.sidebar-section {
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.channel-list, .dm-list, .online-list {
  overflow-y: auto;
  max-height: 180px;
  padding: 0 6px;
}

.channel-list::-webkit-scrollbar,
.dm-list::-webkit-scrollbar,
.online-list::-webkit-scrollbar,
.messages-area::-webkit-scrollbar { width: 3px; }

.channel-list::-webkit-scrollbar-track,
.dm-list::-webkit-scrollbar-track,
.messages-area::-webkit-scrollbar-track { background: transparent; }

.channel-list::-webkit-scrollbar-thumb,
.dm-list::-webkit-scrollbar-thumb,
.messages-area::-webkit-scrollbar-thumb { background: var(--border-active); border-radius: 2px; }

.channel-item, .dm-item, .online-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-size: 14px;
  position: relative;
}

.channel-item:hover, .dm-item:hover, .online-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.channel-item.active, .dm-item.active {
  background: var(--cyan-glow);
  color: var(--cyan);
  border-left: 2px solid var(--cyan);
}

.channel-icon { font-size: 16px; width: 20px; text-align: center; }

.channel-hash {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 300;
}

.unread-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-family: var(--font-mono);
}

.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--green);
}

.dm-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0;
  position: relative;
}

.dm-online-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  border: 1.5px solid var(--bg-panel);
}

.logout-btn {
  margin: auto 12px 16px;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 3px;
  color: var(--red);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--red);
}

/* ============ ICON BUTTONS ============ */

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 3px;
  font-size: 14px;
  transition: var(--transition);
  position: relative;
  line-height: 1;
}

.icon-btn:hover { color: var(--cyan); background: var(--cyan-glow); }

.notif-badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--red);
  color: white;
  font-size: 9px;
  min-width: 14px; height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  padding: 0 3px;
}

/* ============ CHAT MAIN ============ */

.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-deep);
  position: relative;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--header-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.chat-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.3;
}

.menu-toggle { display: none; }

.chat-title-area { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.chat-icon { font-size: 22px; }

.chat-title-area h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-subtitle {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.header-actions { display: flex; gap: 4px; }

/* ============ MESSAGES AREA ============ */

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.welcome-3d {
  perspective: 800px;
}

.welcome-logo {
  font-family: var(--font-display);
  font-size: 80px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--purple) 50%, var(--cyan) 100%);
  background-size: 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 16px;
  animation: welcomePulse 4s ease-in-out infinite, bgShift 6s linear infinite;
  margin-bottom: 16px;
}

@keyframes welcomePulse {
  0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 30px var(--cyan)); }
  50% { transform: translateY(-8px) scale(1.02); filter: drop-shadow(0 0 60px var(--cyan)); }
}

@keyframes bgShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.welcome-screen p {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.messages-list { display: flex; flex-direction: column; gap: 2px; }

/* ============ MESSAGE BUBBLE ============ */

.message-item {
  display: flex;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  position: relative;
  animation: msgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.message-item:hover .msg-actions { opacity: 1; }

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: transform 0.2s;
}

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

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

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

.msg-username {
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s;
}

.msg-username:hover { color: var(--cyan); }

.msg-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.msg-edited {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

.msg-content {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-content.deleted {
  color: var(--text-muted);
  font-style: italic;
}

.msg-image {
  max-width: 320px;
  max-height: 240px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 6px;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.msg-image:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-cyan);
}

.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
  margin-top: 6px;
  transition: var(--transition);
}

.msg-file:hover { border-color: var(--cyan); color: var(--cyan); }

.msg-file i { color: var(--cyan); }

.msg-reply-preview {
  background: var(--bg-card);
  border-left: 3px solid var(--cyan);
  border-radius: 0 3px 3px 0;
  padding: 4px 10px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.reaction-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.reaction-chip:hover, .reaction-chip.mine {
  border-color: var(--cyan);
  background: var(--cyan-glow);
}

.reaction-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.msg-actions {
  position: absolute;
  right: 8px;
  top: 6px;
  opacity: 0;
  display: flex;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  transition: opacity 0.15s;
}

.msg-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 2px;
  transition: var(--transition);
}

.msg-actions button:hover { color: var(--cyan); background: var(--cyan-glow); }

/* Consecutive messages */
.message-item.consecutive { padding-top: 2px; }
.message-item.consecutive .msg-avatar { visibility: hidden; }
.message-item.consecutive .msg-header { display: none; }

/* Own messages */
.message-item.own .msg-username { color: var(--cyan); }

/* System messages */
.message-item.system {
  justify-content: center;
  padding: 4px;
}

.system-msg {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 1px;
}

/* Date separator */
.date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
}

.date-separator::before, .date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============ TYPING INDICATOR ============ */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

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

.typing-dots span {
  width: 5px; height: 5px;
  background: var(--cyan);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
  opacity: 0.7;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ============ REPLY PREVIEW ============ */

.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  font-size: 13px;
  color: var(--text-secondary);
}

.reply-preview button {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  transition: color 0.2s;
}

.reply-preview button:hover { color: var(--red); }

/* ============ INPUT AREA ============ */

.input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.message-input-wrap {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  transition: var(--transition);
}

.message-input-wrap:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

#message-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 14px;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}

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

.send-btn {
  width: 42px; height: 42px;
  background: var(--cyan);
  border: none;
  border-radius: 4px;
  color: var(--bg-deep);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.send-btn:hover {
  background: white;
  transform: scale(1.05);
  box-shadow: var(--shadow-cyan);
}

.send-btn:active { transform: scale(0.95); }

.attach-btn, .emoji-btn { flex-shrink: 0; }

/* ============ EMOJI PICKER ============ */

.emoji-picker {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--border-active);
  border-radius: 8px;
  padding: 12px;
  z-index: 1000;
  box-shadow: 0 -4px 40px rgba(0,0,0,0.4);
  width: 300px;
  animation: pickerIn 0.2s ease;
}

@keyframes pickerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.emoji-btn-item {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: transform 0.15s;
  line-height: 1;
}

.emoji-btn-item:hover {
  background: var(--bg-hover);
  transform: scale(1.3);
}

/* ============ CONTEXT MENU ============ */

.context-menu {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border-active);
  border-radius: 4px;
  padding: 4px;
  z-index: 2000;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: ctxIn 0.15s ease;
}

@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  border-radius: 2px;
  transition: var(--transition);
  text-align: left;
}

.context-menu button:hover { background: var(--bg-hover); color: var(--text-primary); }
.context-menu button i { width: 14px; color: var(--cyan); }

/* ============ RIGHT PANEL ============ */

.right-panel {
  width: 240px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.panel-header h3 {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-muted);
}

.panel-content { overflow-y: auto; padding: 8px; flex: 1; }

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}

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

.member-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0;
  position: relative;
}

.member-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bg-panel);
}

.member-dot.online { background: var(--green); }
.member-dot.offline { background: var(--text-muted); }

/* ============ MODALS ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 16, 0.85);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

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

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-active);
  border-radius: 4px;
  width: 440px;
  max-width: 95vw;
  overflow: hidden;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-purple);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--cyan);
}

.modal-body { padding: 20px; }

.avatar-editor { text-align: center; margin-bottom: 20px; }

.big-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  border: 3px solid var(--border-active);
}

.color-picker-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.color-swatches { display: flex; gap: 6px; }

.color-swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s;
}

.color-swatch:hover, .color-swatch.active { transform: scale(1.3); border-color: white; }

.modal-body .input-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: var(--transition);
}

.modal-body .input-group textarea:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px var(--cyan-glow);
}

.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-opt {
  font-size: 22px;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  border: 2px solid transparent;
  transition: var(--transition);
  line-height: 1;
}

.icon-opt:hover, .icon-opt.active {
  border-color: var(--cyan);
  background: var(--cyan-glow);
}

/* ============ LIGHTBOX ============ */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}

.lightbox-close {
  position: absolute;
  top: 20px; right: 20px;
  background: none;
  border: 1px solid var(--border-active);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 4px;
  transition: var(--transition);
}

.lightbox-close:hover { color: var(--red); border-color: var(--red); }

/* ============ UPLOAD TOAST ============ */

.upload-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--cyan);
  border-radius: 4px;
  padding: 10px 20px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 4000;
  box-shadow: var(--shadow-cyan);
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: var(--sidebar-w);
    z-index: 200;
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 30px rgba(0,0,0,0.5); }

  .menu-toggle { display: flex; }

  .right-panel { display: none !important; }

  .welcome-logo { font-size: 48px; letter-spacing: 8px; }
}

/* ============ THEME TOGGLE ============ */

.light-mode #bg-canvas { opacity: 0.15; }
.light-mode .scanlines { opacity: 0.3; }
.light-mode .logo-text { filter: drop-shadow(0 0 10px rgba(0,100,200,0.5)); }

/* ============ LOAD EARLIER ============ */

.load-earlier {
  text-align: center;
  padding: 8px;
}

.load-earlier button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  padding: 6px 16px;
  transition: var(--transition);
}

.load-earlier button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}