/* ═══════════════════════════════════════════════════════════════
   WorkChat — COLIZEUM Dark Theme
   Telegram-style corporate messenger
═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --bg: #070d1a;
  --card: #111827;
  --card2: #1a2336;
  --gold: #ffc400;
  --gold-dim: rgba(255, 196, 0, 0.15);
  --gold-hover: #ffce33;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #e8eaed;
  --muted: #9aa0a6;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --online: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-msg: 18px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);
  --transition: 0.18s ease;
  --sidebar-w: 340px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
select option { background: var(--card2); color: var(--text); }
textarea { resize: none; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* ── Animations ── */
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(-12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(120%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes msgAppear {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.7; }
}
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}
@keyframes recPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.4); opacity: 0.6; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ══════════════════════════════════════════════════════
   AUTH SCREEN
══════════════════════════════════════════════════════ */
.auth-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #040a14 0%, #070d1a 40%, #0a1428 70%, #0d1a35 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#particleCanvas {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 0;
}

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow), 0 0 60px rgba(255,196,0,0.05);
  animation: modalIn 0.4s ease;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  justify-content: center;
}
.auth-logo-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #ffc400, #ffce33);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 9px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  color: var(--muted);
  transition: all var(--transition);
}
.auth-tab.active {
  background: var(--card2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.auth-tab:hover:not(.active) { color: var(--text); }

.auth-form { display: none; flex-direction: column; gap: 16px; }
.auth-form.active { display: flex; }

/* ── Form Group ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Password wrap ── */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.toggle-pw {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.toggle-pw:hover { color: var(--text); }

/* ── Buttons ── */
.btn-primary {
  background: var(--gold);
  color: #070d1a;
  font-weight: 700;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:hover {
  background: var(--gold-hover);
  box-shadow: 0 4px 16px rgba(255,196,0,0.3);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary.btn-full { width: 100%; }
.btn-primary.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
}
.btn-danger:hover { background: var(--danger-hover); transform: translateY(-1px); }
.btn-danger.btn-full { width: 100%; }

/* ── Icon Button ── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: var(--muted);
  transition: all var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn.active { color: var(--gold); }

/* ── Avatar ── */
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  user-select: none;
  background: var(--card2);
  color: var(--text);
}
.avatar-xl { width: 72px; height: 72px; font-size: 26px; }
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-img {
  width: 100%; height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0; left: 0;
  border-radius: 50%;
}

/* ══════════════════════════════════════════════════════
   MAIN APP LAYOUT
══════════════════════════════════════════════════════ */
.main-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: var(--text);
}
.sidebar-actions { display: flex; gap: 4px; }

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  margin: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
  color: var(--muted);
}
.sidebar-search input {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 14px;
  flex: 1;
  box-shadow: none;
}
.sidebar-search input:focus { box-shadow: none; border: none; }

.chat-list-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-list { display: flex; flex-direction: column; }

/* ── Chat Item ── */
.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  user-select: none;
}
.chat-item:hover { background: rgba(255,255,255,0.04); }
.chat-item.active { background: var(--gold-dim); }
.chat-item.active .chat-item-name { color: var(--gold); }

.saved-item {
  border-bottom: 1px solid var(--border);
}

.chat-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-item-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.chat-item-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.chat-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-item-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.chat-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.unread-badge {
  background: var(--gold);
  color: #070d1a;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mute-icon { color: var(--muted); display: flex; }

/* ── Skeleton ── */
.skeleton-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.skeleton-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--card2);
  flex-shrink: 0;
  animation: skeletonPulse 1.4s ease infinite;
}
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line {
  height: 10px;
  background: var(--card2);
  border-radius: 4px;
  animation: skeletonPulse 1.4s ease infinite;
}
.skeleton-line.w70 { width: 70%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w65 { width: 65%; }
.skeleton-line.w75 { width: 75%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w45 { width: 45%; }
.skeleton-line.w55 { width: 55%; }

/* ── Sidebar Footer ── */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  flex-shrink: 0;
}
.me-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  transition: background var(--transition);
}
.me-info:hover { background: rgba(255,255,255,0.04); }
.me-text { flex: 1; min-width: 0; }
.me-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-status { font-size: 12px; color: var(--muted); }
.me-status.online { color: var(--online); }

/* ══════════════════════════════════════════════════════
   CHAT AREA
══════════════════════════════════════════════════════ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--muted);
  animation: fadeIn 0.4s ease;
}
.empty-state h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.empty-state p { font-size: 15px; }

/* ── Chat View ── */
.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Chat Header ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.back-btn { display: none; }
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.chat-header-text { flex: 1; min-width: 0; }
.chat-header-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-status {
  font-size: 12px;
  color: var(--muted);
}
.chat-header-status.online { color: var(--online); }
.chat-header-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── Reconnect Banner ── */
.reconnect-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(239,68,68,0.15);
  border-bottom: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  font-size: 13px;
  flex-shrink: 0;
  animation: fadeIn 0.3s ease;
}
.reconnect-banner svg { animation: spin 1s linear infinite; flex-shrink: 0; }

/* ── Pinned Bar ── */
.pinned-bar {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  background: var(--card2);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  gap: 10px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--transition);
}
.pinned-bar:hover { background: rgba(255,196,0,0.05); }
.pinned-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  pointer-events: none;
}
#pinnedText {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

/* ── Message Search Panel ── */
.msg-search-panel {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.msg-search-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--muted);
}
.msg-search-inner input {
  background: none;
  border: none;
  padding: 0;
  flex: 1;
  box-shadow: none;
  color: var(--text);
}
.msg-search-inner input:focus { box-shadow: none; border: none; }
.msg-search-results {
  max-height: 240px;
  overflow-y: auto;
  padding: 0 8px 8px;
}
.msg-search-result {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.msg-search-result:hover { background: var(--border); }
.msg-search-result-name { font-size: 12px; font-weight: 600; color: var(--gold); margin-bottom: 2px; }
.msg-search-result-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Messages Area ── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
}
.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 8px;
  flex-shrink: 0;
}
.load-more-btn {
  background: var(--card2);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
}
.load-more-btn:hover { color: var(--text); background: var(--card); }

#messagesList {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 16px;
  flex: 1;
}

/* ── Date Divider ── */
.date-divider {
  text-align: center;
  margin: 12px 0;
  position: relative;
}
.date-divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border);
}
.date-divider span {
  position: relative;
  background: var(--bg);
  padding: 0 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Typing Indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--muted);
  animation: fadeIn 0.2s ease;
  flex-shrink: 0;
}
.typing-dots { display: flex; gap: 3px; align-items: center; }
.typing-dots span {
  width: 5px; height: 5px;
  background: var(--muted);
  border-radius: 50%;
  animation: typingDot 1.2s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ══════════════════════════════════════════════════════
   MESSAGE BUBBLES
══════════════════════════════════════════════════════ */
.msg-row {
  display: flex;
  margin-bottom: 2px;
  max-width: 100%;
  animation: msgAppear 0.2s ease;
}
.msg-row.outgoing { flex-direction: row-reverse; }
.msg-row.incoming { flex-direction: row; }

.msg-row.outgoing + .msg-row.outgoing .msg-avatar,
.msg-row.incoming + .msg-row.incoming .msg-avatar { visibility: hidden; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: flex-end;
  margin: 0 6px;
  cursor: pointer;
}
.msg-avatar .avatar { width: 32px; height: 32px; font-size: 12px; }

.msg-body {
  max-width: 68%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg-row.outgoing .msg-body { align-items: flex-end; }
.msg-row.incoming .msg-body { align-items: flex-start; }

.msg-sender-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  padding: 0 4px;
  cursor: pointer;
}
.msg-sender-name:hover { text-decoration: underline; }

/* ── Bubble ── */
.msg-bubble {
  position: relative;
  padding: 8px 12px;
  border-radius: var(--radius-msg);
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.55;
  max-width: 100%;
}

/* Outgoing bubble: gold */
.msg-row.outgoing .msg-bubble {
  background: var(--gold);
  color: #070d1a;
  border-bottom-right-radius: 4px;
}
/* Gold bubble tail top-right */
.msg-row.outgoing .msg-bubble::after {
  content: '';
  position: absolute;
  top: 0;
  right: -7px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 8px 0 0 8px;
  border-color: transparent transparent transparent var(--gold);
}

/* Incoming bubble: dark card */
.msg-row.incoming .msg-bubble {
  background: var(--card);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
/* Incoming bubble tail top-left */
.msg-row.incoming .msg-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -7px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 8px 8px 0 0;
  border-color: transparent var(--card) transparent transparent;
}

/* No tail for grouped messages (same sender, consecutive) */
.msg-row.no-tail .msg-bubble::after,
.msg-row.no-tail .msg-bubble::before { display: none; }
.msg-row.outgoing.no-tail .msg-bubble { border-bottom-right-radius: var(--radius-msg); }
.msg-row.incoming.no-tail .msg-bubble { border-bottom-left-radius: var(--radius-msg); }

/* ── Forwarded header ── */
.msg-forwarded {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  opacity: 0.8;
  border-left: 3px solid rgba(0,0,0,0.2);
  padding-left: 8px;
}
.msg-row.incoming .msg-forwarded { border-left-color: var(--gold); color: var(--gold); }
.msg-row.outgoing .msg-forwarded { border-left-color: rgba(0,0,0,0.3); color: rgba(7,13,26,0.7); }

/* ── Reply preview ── */
.msg-reply-preview {
  background: rgba(0,0,0,0.15);
  border-left: 3px solid rgba(0,0,0,0.3);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background var(--transition);
}
.msg-row.incoming .msg-reply-preview {
  background: rgba(255,196,0,0.08);
  border-left-color: var(--gold);
}
.msg-reply-preview:hover { background: rgba(0,0,0,0.25); }
.msg-reply-author {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}
.msg-row.incoming .msg-reply-author { color: var(--gold); }
.msg-row.outgoing .msg-reply-author { color: rgba(7,13,26,0.7); }
.msg-reply-text {
  font-size: 12px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Message image ── */
.msg-img {
  max-width: 280px;
  max-height: 280px;
  border-radius: 10px;
  cursor: pointer;
  display: block;
  transition: opacity var(--transition);
  object-fit: cover;
  margin-bottom: 4px;
}
.msg-img:hover { opacity: 0.9; }

/* ── File attachment ── */
.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  min-width: 180px;
}
.msg-file-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}
.msg-row.outgoing .msg-file-icon { background: rgba(0,0,0,0.15); }
.msg-row.incoming .msg-file-icon { background: var(--gold-dim); }
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-file-size { font-size: 11px; opacity: 0.65; margin-top: 2px; }

/* ── Voice message ── */
.msg-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}
.msg-voice audio {
  width: 100%;
  height: 32px;
  border-radius: 99px;
  accent-color: var(--gold);
}

/* ── Message footer ── */
.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.65;
  flex-wrap: wrap;
}
.msg-edited { font-style: italic; }
.msg-time { white-space: nowrap; }
.msg-ticks { display: flex; align-items: center; gap: 1px; font-size: 13px; }
.msg-ticks.read { color: var(--gold); opacity: 1; }

/* ── Reactions ── */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--card2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text);
}
.msg-row.outgoing .reaction-btn { background: rgba(0,0,0,0.15); border-color: rgba(0,0,0,0.1); color: #070d1a; }
.reaction-btn:hover { border-color: var(--gold); background: var(--gold-dim); }
.reaction-btn.mine { border-color: var(--gold); background: var(--gold-dim); }
.reaction-count { font-size: 12px; font-weight: 600; }

/* ══════════════════════════════════════════════════════
   INPUT AREA
══════════════════════════════════════════════════════ */
.input-area {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  flex-shrink: 0;
}

/* ── Reply bar ── */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--card2);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.reply-bar-line {
  width: 3px; height: 36px;
  background: var(--gold);
  border-radius: 999px;
  flex-shrink: 0;
}
.reply-bar-content { flex: 1; min-width: 0; }
.reply-bar-author { font-size: 12px; font-weight: 700; color: var(--gold); margin-bottom: 2px; }
.reply-bar-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── File preview bar ── */
.file-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--card2);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.file-preview-inner {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.file-preview-inner img {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

/* ── Input row ── */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.input-row textarea {
  flex: 1;
  background: var(--card2);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 10px 16px;
  resize: none;
  max-height: 150px;
  line-height: 1.5;
  font-size: 14px;
  transition: border-color var(--transition);
}
.input-row textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
.input-row .icon-btn { width: 42px; height: 42px; flex-shrink: 0; }
.input-row .icon-btn:hover { background: var(--gold-dim); color: var(--gold); }
.send-btn { color: var(--gold) !important; }
.send-btn:hover { background: var(--gold-dim) !important; }

/* ── Recording state ── */
.recording-state {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
}
.rec-pulse {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--danger);
  animation: recPulse 1s ease infinite;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow), 0 0 60px rgba(0,0,0,0.5);
  animation: modalIn 0.25s ease;
  overflow: hidden;
}
.modal.modal-lg { max-width: 540px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 20px;
}
.modal-tab {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  margin-bottom: -1px;
}
.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.modal-body {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.tab-panel { display: none; flex-direction: column; gap: 14px; }
.tab-panel.active { display: flex; }

/* ── New Chat Options ── */
.new-chat-options { display: flex; gap: 12px; }
.new-chat-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  background: var(--card2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}
.new-chat-option:hover { border-color: var(--gold); background: var(--gold-dim); color: var(--gold); }
.option-icon {
  width: 52px; height: 52px;
  background: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

/* ── User List ── */
.user-list { display: flex; flex-direction: column; gap: 2px; }
.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.user-item:hover { background: rgba(255,255,255,0.05); }
.user-item-info { flex: 1; min-width: 0; }
.user-item-name { font-weight: 600; font-size: 14px; }
.user-item-sub { font-size: 12px; color: var(--muted); }
.user-item-actions { display: flex; gap: 4px; }
.online-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--card);
  position: absolute;
  bottom: 8px; left: 40px;
}
.admin-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid rgba(255,196,0,0.3);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Search wrap ── */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  transition: border-color var(--transition);
}
.search-wrap:focus-within { border-color: var(--gold); }
.search-wrap input {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  flex: 1;
  box-shadow: none;
}
.search-wrap input:focus { box-shadow: none; border: none; }

/* ── Selected Users ── */
.selected-users {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}
.selected-user-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-dim);
  border: 1px solid rgba(255,196,0,0.3);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--gold);
}
.selected-user-tag button {
  color: var(--gold);
  opacity: 0.7;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  width: auto; height: auto;
  border-radius: 0;
}
.selected-user-tag button:hover { opacity: 1; background: none; }

/* ── Section Divider ── */
.section-divider {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  padding: 8px 4px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Settings Avatar ── */
.settings-avatar-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}
.settings-avatar {
  position: relative;
  display: inline-block;
  cursor: pointer;
}
.avatar-upload-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
  color: #fff;
}
.settings-avatar:hover .avatar-upload-overlay { opacity: 1; }

/* ── Profile View ── */
.profile-view {
  align-items: center;
  text-align: center;
}
.profile-avatar-wrap { margin-bottom: 8px; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-username { color: var(--muted); font-size: 14px; margin-top: 2px; }
.profile-status { font-size: 13px; margin-top: 4px; margin-bottom: 12px; }
.profile-status.online { color: var(--online); }
.profile-bio, .profile-phone {
  width: 100%;
  text-align: left;
  background: var(--card2);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.profile-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gold);
  margin-bottom: 4px;
}

/* ══════════════════════════════════════════════════════
   CONTEXT MENU
══════════════════════════════════════════════════════ */
.context-menu {
  position: fixed;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 1000;
  animation: modalIn 0.15s ease;
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.ctx-item:hover { background: rgba(255,255,255,0.07); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(239,68,68,0.1); }
.ctx-item svg { color: var(--muted); flex-shrink: 0; }
.ctx-item.danger svg { color: var(--danger); }
.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

/* ══════════════════════════════════════════════════════
   QUICK REACTION BAR (Telegram-style hover strip)
══════════════════════════════════════════════════════ */
.quick-react-bar {
  position: fixed;
  z-index: 1001;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55);
  animation: qrIn 0.12s ease;
  pointer-events: all;
}
.quick-react-bar.hidden { display: none; }
@keyframes qrIn {
  from { opacity: 0; transform: scale(0.85) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.qr-emoji {
  font-size: 24px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 10px;
  transition: transform 0.1s, background 0.1s;
  line-height: 1;
  user-select: none;
}
.qr-emoji:hover {
  transform: scale(1.45);
  background: rgba(255,255,255,0.07);
}
.qr-more {
  font-size: 16px;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 4px 6px;
  border-left: 1px solid var(--border);
  margin-left: 2px;
}
.qr-more:hover { color: var(--gold); background: rgba(255,196,0,0.1); }

/* ══════════════════════════════════════════════════════
   REACTION PICKER (Full — opens from «+» button)
══════════════════════════════════════════════════════ */
.reaction-picker {
  position: fixed;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 1002;
  animation: qrIn 0.15s ease;
  width: 280px;
}
.reaction-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
}
.reaction-emoji {
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  text-align: center;
  transition: transform 0.1s, background 0.1s;
  line-height: 1;
  user-select: none;
}
.reaction-emoji:hover {
  transform: scale(1.35);
  background: rgba(255,255,255,0.07);
}

/* ══════════════════════════════════════════════════════
   TOASTS
══════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  pointer-events: all;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--online); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--gold); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-text { flex: 1; color: var(--text); }

/* ══════════════════════════════════════════════════════
   IMAGE PREVIEW
══════════════════════════════════════════════════════ */
.img-preview-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease;
}
#imgPreviewImg {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  object-fit: contain;
  pointer-events: none;
}
.img-preview-close {
  position: absolute;
  top: 20px; right: 20px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background var(--transition);
  cursor: pointer;
}
.img-preview-close:hover { background: rgba(255,255,255,0.2); }

/* ══════════════════════════════════════════════════════
   RESPONSIVE — mobile/narrow
══════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  :root { --sidebar-w: 100vw; }

  .sidebar {
    position: fixed; inset: 0;
    z-index: 100;
    transform: translateX(0);
    transition: transform 0.25s ease;
  }
  .sidebar.hidden-mobile { transform: translateX(-100%); }

  .chat-area { width: 100vw; }

  .back-btn { display: flex !important; }

  .msg-body { max-width: 85%; }
}
