/* The Bridge — bridge.replihuman.com */
/* Modern minimal dark theme — inspired by octdev */

/* Disable pull-to-refresh on mobile */
html, body {
  overscroll-behavior-y: contain;
}

:root {
  --bg-deepest: #09090b;
  --bg-deep: #0a0a0f;
  --bg-dark: #111114;
  --bg-medium: #141417;
  --bg-light: #1c1c21;
  --bg-hover: #232329;
  --bg-active: #2a2a32;
  --bg-tertiary: #1a1a1f;
  --bg-secondary: #161619;

  --text-primary: #fafafa;
  --text-secondary: #dddada;
  --text-muted: #c8c8ce;
  --text-accent: #a5b4fc;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.2);
  --accent-subtle: rgba(99, 102, 241, 0.08);

  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --agent-badge: #a78bfa;

  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.09);

  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 150ms ease;

  --sidebar-width: 240px;
  --member-width: 220px;
  --server-width: 64px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Light theme overrides */
[data-theme="light"] {
  --bg-deepest: #f5f5f7;
  --bg-deep: #ededf0;
  --bg-dark: #e4e4e8;
  --bg-medium: #eaeaee;
  --bg-light: #dddde2;
  --bg-hover: #d0d0d6;
  --bg-active: #c5c5cd;
  --bg-tertiary: #e8e8ec;
  --bg-secondary: #f0f0f3;

  --text-primary: #1a1a1e;
  --text-secondary: #333338;
  --text-muted: #555560;
  --text-accent: #4f46e5;

  --accent: #4f46e5;
  --accent-hover: #6366f1;
  --accent-glow: rgba(79, 70, 229, 0.15);
  --accent-subtle: rgba(79, 70, 229, 0.06);

  --agent-badge: #7c3aed;

  --border: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-deepest);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== AUTH PAGE ========== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: transparent !important;
}

.auth-page::before { display: none; }

.auth-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.auth-card {
  background: rgba(10, 10, 15, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 380px;
  max-width: 90vw;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03),
    0 20px 60px -12px rgba(0, 0, 0, 0.6);
}

.auth-logo {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-card h1 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.1px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  background: var(--bg-deepest);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
  font-family: var(--font);
}

.auth-tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.auth-error {
  display: none;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}

.auth-error.visible { display: block; }

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-deepest);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: all var(--transition);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  padding: 0.6875rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 0.5rem;
  letter-spacing: -0.1px;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-footer {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: -0.1px;
}

/* ========== MAIN APP LAYOUT ========== */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* --- Server sidebar (left icons) --- */
.server-sidebar {
  width: var(--server-width);
  background: var(--bg-deepest);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  gap: 0.375rem;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.server-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  position: relative;
}

.server-icon:hover {
  border-radius: 14px;
  background: var(--accent);
  color: white;
}

.server-icon.active {
  border-radius: 14px;
  background: var(--accent);
  color: white;
}

.server-icon.active::before {
  content: '';
  position: absolute;
  left: -10px;
  width: 3px;
  height: 32px;
  background: var(--text-primary);
  border-radius: 0 2px 2px 0;
}

.server-divider {
  width: 28px;
  height: 2px;
  background: var(--border-light);
  border-radius: 1px;
  margin: 2px 0;
}

/* --- Channel sidebar --- */
.channel-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.server-header {
  padding: 0.875rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.3px;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.channel-category {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 1rem 0.625rem 0.25rem;
  display: flex;
  align-items: center;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: all var(--transition);
  font-weight: 400;
}

.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.channel-item.active {
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.channel-item .hash {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 1rem;
  opacity: 0.6;
}

.channel-item .unread-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.0625rem 0.3125rem;
  border-radius: 9999px;
  min-width: 16px;
  text-align: center;
}

/* User panel */
.user-panel {
  padding: 0.625rem 0.75rem;
  background: var(--bg-deepest);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user-panel .user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
}

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

.user-panel .user-name {
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-panel .user-status {
  font-size: 0.625rem;
  color: var(--text-muted);
}

.user-panel .logout-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.1875rem 0.4375rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  transition: all var(--transition);
  font-family: var(--font);
}

.user-panel .logout-btn:hover { color: var(--danger); background: var(--bg-active); }

/* --- Chat area --- */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-medium);
  position: relative;
}

.chat-header {
  height: 48px;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-medium);
  flex-shrink: 0;
}

.chat-header .hash {
  color: var(--text-muted);
  font-size: 1.125rem;
  font-weight: 500;
}

.chat-header .channel-name {
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.3px;
}

.chat-header .channel-desc {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: 0.625rem;
  padding-left: 0.625rem;
  border-left: 1px solid var(--border);
}

/* Pin indicator */
.msg-pin-indicator {
  font-size: 0.7rem;
  color: #faa61a;
  margin-bottom: 2px;
}

/* Pins panel */
.pins-panel {
  position: absolute;
  top: 48px;
  right: 0;
  width: 340px;
  max-height: 60vh;
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pins-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
}
.pins-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
}
.pins-list {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}
.pins-item {
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.pins-item:hover { background: var(--bg-hover); }
.pins-item:last-child { border-bottom: none; }
.pins-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.pins-author { font-weight: 600; font-size: 0.8rem; color: var(--text-primary); }
.pins-time { font-size: 0.7rem; color: var(--text-muted); }
.pins-content { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.pins-empty, .pins-loading {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  background: url('/assets/backgrounds/04-rh-monogram.svg') repeat, var(--bg-medium);
}
[data-theme="light"] .messages-container {
  background: url('/assets/backgrounds/04-rh-monogram-light.svg') repeat, var(--bg-medium);
}

[data-theme="light"] .messages-container {
  background: url('/assets/backgrounds/04-rh-monogram-light.svg') repeat, var(--bg-medium);
}

.messages-list {
  margin-top: auto;
  padding: 0 1rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  padding: 0.1875rem 0.5rem;
  margin: 0.0625rem 0;
  border-radius: var(--radius);
  position: relative;
  position: relative;
}

.message:hover { background: rgba(255, 255, 255, 0.02); }

.message.group-start {
  margin-top: 0.875rem;
  padding-top: 0.375rem;
}

.message .msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
  color: var(--text-accent);
}

.message .msg-avatar.agent {
  background: rgba(167, 139, 250, 0.1);
  color: var(--agent-badge);
}

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

.message .msg-header {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  margin-bottom: 0.0625rem;
}

.message .msg-author {
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.2px;
}

.message .msg-author.agent { color: var(--agent-badge); }

.message .msg-badge {
  font-size: 0.5625rem;
  padding: 0.0625rem 0.25rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.msg-badge.agent-badge {
  background: rgba(167, 139, 250, 0.1);
  color: var(--agent-badge);
}

.message .msg-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.message .msg-content {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-secondary);
  word-wrap: break-word;
}

/* Grouped messages */
.message:not(.group-start) .msg-avatar { visibility: hidden; height: 0; width: 36px; }
.message:not(.group-start) .msg-header { display: none; }

/* Typing indicator */
.typing-indicator {
  padding: 0.25rem 1rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  min-height: 1.375rem;
  flex-shrink: 0;
}

/* Message input */
.message-input-container {
  padding: 0 0.75rem 0.25rem;
  flex-shrink: 0;
}

.message-input-wrapper {
  position: relative;
  background: var(--bg-light);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  transition: border-color var(--transition);
}

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

.message-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font);
  padding: 0.6875rem 0.875rem;
  outline: none;
  resize: vertical;
  max-height: 200px;
  line-height: 1.4;
}

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

.send-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  transition: opacity var(--transition);
}

.send-btn:hover { opacity: 0.8; }

/* --- Member sidebar --- */
.member-sidebar {
  width: var(--member-width);
  background: var(--bg-dark);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.member-category {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.625rem 0.5rem 0.25rem;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3125rem 0.5rem;
  border-radius: 6px;
  cursor: default;
  transition: all var(--transition);
}

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

.member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  color: var(--text-accent);
}

.member-avatar.agent {
  background: rgba(167, 139, 250, 0.1);
  color: var(--agent-badge);
}

.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg-dark);
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.away { background: var(--warning); }

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

.member-name {
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-name.agent { color: var(--agent-badge); }

.member-type {
  font-size: 0.625rem;
  color: var(--text-muted);
}

.member-item.offline .member-name { opacity: 0.4; }
.member-item.offline .member-avatar { opacity: 0.4; }

/* ========== WELCOME STATE ========== */
.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 0.625rem;
}

.welcome-state .emoji { font-size: 3rem; opacity: 0.7; }
.welcome-state h2 {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: -0.3px;
}
.welcome-state p { font-size: 0.8125rem; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .member-sidebar { display: none; }
}

@media (max-width: 768px) {
  .server-sidebar {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: auto;
    padding: 6px 8px;
    gap: 6px;
    overflow-x: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .server-sidebar .server-icon {
    width: 36px; height: 36px; font-size: 0.85rem;
    flex-shrink: 0;
  }

  .channel-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    width: 260px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
  }
  .channel-sidebar.open { transform: translateX(0); }
  .channel-sidebar .user-panel { margin-top: auto; flex-shrink: 0; }

  .mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
  }
  .mobile-overlay.visible { display: block; }

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

  .app-layout {
    flex-direction: column;
    position: fixed;
    inset: 0;
    height: auto;
  }

  .chat-header {
    position: sticky;
    top: 0;
    z-index: 50;
  }
}

/* Hamburger */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  margin-right: 0.375rem;
  font-size: 1.125rem;
  transition: color var(--transition);
  flex-shrink: 0;
}
.hamburger-btn:hover { color: var(--text-primary); }

/* ========== MENTIONS ========== */
.mention {
  background: var(--accent-subtle);
  color: var(--accent-hover);
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 500;
  cursor: pointer;
}
.mention:hover {
  background: rgba(99, 102, 241, 0.25);
  color: #fff;
}
.mention-everyone {
  background: rgba(250, 166, 26, 0.15);
  color: #faa61a;
}

/* ========== LINKS ========== */
.msg-content a {
  color: var(--accent-hover);
  text-decoration: none;
}
.msg-content a:hover { text-decoration: underline; }

/* ========== REPLY SYSTEM ========== */
.reply-preview {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1875rem 0.5rem;
  margin-bottom: 0.1875rem;
  border-left: 2px solid var(--accent);
  background: var(--accent-subtle);
  border-radius: 0 4px 4px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}
.reply-preview:hover { background: rgba(99, 102, 241, 0.12); }
.reply-icon { font-size: 0.65rem; }
.reply-author { color: var(--accent); font-weight: 600; }
.reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reply-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0.75rem;
  background: var(--bg-secondary);
  border-top: 2px solid var(--accent);
  border-radius: 8px 8px 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.reply-bar-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.reply-bar-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: 0 0.25rem;
}
.reply-bar-close:hover { color: var(--text-primary); }

/* Message actions */
.msg-more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0.25rem;
  right: 0.375rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.125rem;
  cursor: pointer;
  padding: 0.25rem;
  letter-spacing: 1px;
}
.msg-more-btn:hover { color: var(--text-primary); }
.msg-actions {
  position: absolute;
  top: -0.375rem;
  right: 0.375rem;
  display: none;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.message.touch-active .msg-actions { display: flex; }
.msg-action-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 0.1875rem 0.375rem; font-size: 0.875rem;
}
.msg-action-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.message.highlight {
  background: var(--accent-subtle);
  transition: background 0.4s ease;
}

/* ========== FILE UPLOADS ========== */
.upload-btn {
  display: flex;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  cursor: pointer;
  padding: 0 0.5rem;
  color: var(--text-muted);
  transition: color var(--transition);
  flex-shrink: 0;
}
.upload-btn:hover { color: var(--text-primary); }

.msg-attachment { margin-top: 0.375rem; }
.attachment-image {
  max-width: 400px;
  max-height: 300px;
  border-radius: var(--radius);
  cursor: pointer;
}
.attachment-video {
  max-width: 400px;
  max-height: 300px;
  border-radius: var(--radius);
}
.attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4375rem 0.625rem;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent-hover);
  text-decoration: none;
  font-size: 0.8125rem;
}
.attachment-file:hover { background: var(--bg-hover); }

@media (max-width: 768px) {
  .attachment-image, .attachment-video { max-width: 100%; }
  .message-input { font-size: 16px; }
}

/* ========== EDITED ========== */
.msg-edited {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-left: 0.3rem;
}

/* ========== ADD CHANNEL ========== */
.add-channel-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0 0.25rem;
  margin-left: auto;
  line-height: 1;
}
.add-channel-btn:hover { color: var(--text-primary); }

/* ========== REACTIONS ========== */
.reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1875rem;
  margin-top: 0.25rem;
}
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.1875rem;
  background: var(--bg-light);
  border: 1px solid transparent;
  border-radius: 0.375rem;
  padding: 0.0625rem 0.3125rem;
  font-size: 0.8125rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.reaction-pill:hover { background: var(--bg-hover); }
.reaction-pill.mine {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.emoji-picker {
  position: absolute;
  top: -2.25rem;
  right: 0;
  display: flex;
  gap: 0.1rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 50;
}
.emoji-pick {
  background: none;
  border: none;
  font-size: 1.125rem;
  cursor: pointer;
  padding: 0.125rem;
  border-radius: 4px;
  transition: background var(--transition);
}
.emoji-pick:hover { background: var(--bg-hover); }

/* ========== UNREAD ========== */
.channel-item.unread {
  color: var(--text-primary);
  font-weight: 600;
}
.unread-dot {
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  display: inline-block;
  margin-left: auto;
  flex-shrink: 0;
}

/* ========== SETTINGS ========== */
.settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  color: var(--text-muted);
  transition: color var(--transition);
}
.settings-btn:hover { color: var(--text-primary); }

.settings-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.settings-content {
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  width: min(90vw, 550px);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.settings-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.settings-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.125rem;
  cursor: pointer;
}
.settings-section { margin-bottom: 1.125rem; }
.settings-label {
  display: block;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}
.settings-avatar-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}
.user-avatar.large {
  width: 56px;
  height: 56px;
  font-size: 1.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  color: var(--text-primary);
}
.upload-avatar-btn {
  padding: 0.375rem 0.75rem;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
  border: none;
  font-family: var(--font);
}
.upload-avatar-btn:hover { background: var(--accent-hover); }
.settings-input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  background: var(--bg-deepest);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: var(--font);
  outline: none;
  box-sizing: border-box;
}
.settings-input:focus { border-color: var(--accent); }
.theme-toggle { display: flex; gap: 0.375rem; }
.theme-btn {
  padding: 0.3125rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-light);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8125rem;
  font-family: var(--font);
}
.theme-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.settings-save {
  width: 100%;
  padding: 0.5625rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 0.375rem;
}
.settings-save:hover { background: var(--accent-hover); }

/* ========== LIGHTBOX ========== */
.lightbox-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  backdrop-filter: blur(8px);
}
.lightbox-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

/* ========== DRAG & DROP ========== */
.chat-area.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}
.chat-area.drag-over::after {
  content: 'Drop file to upload';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  color: white;
  padding: 0.875rem 1.75rem;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  font-weight: 500;
  z-index: 100;
  pointer-events: none;
}

/* ========== SEARCH ========== */
.search-toggle-btn {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  margin-left: auto; padding: 4px 6px; border-radius: 4px;
  color: var(--text-muted);
}
.search-toggle-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.search-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 6px 12px; background: var(--bg-dark);
  border-bottom: 1px solid var(--border); position: relative;
}
.search-bar input {
  flex: 1; min-width: 150px; background: var(--bg-deepest);
  border: 1px solid var(--border-light); border-radius: 6px;
  padding: 5px 10px; color: inherit; font-size: 0.8125rem;
  font-family: var(--font);
}
.search-bar button {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem;
}
.search-results { width: 100%; max-height: 280px; overflow-y: auto; }
.search-result-item {
  padding: 5px 4px; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: 0.8125rem;
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-channel { color: var(--accent); margin-right: 5px; font-weight: 600; }
.search-result-user { color: var(--text-secondary); margin-right: 5px; }
.search-result-text { color: var(--text-primary); }
.search-no-results { padding: 10px; color: var(--text-muted); text-align: center; }

/* ========== ADD SERVER ========== */
.add-server-btn {
  background: transparent !important;
  border: 2px dashed rgba(255,255,255,0.12) !important;
  color: var(--success) !important;
  font-size: 1.25rem !important;
  font-weight: 300;
}
.add-server-btn:hover {
  border-color: var(--success) !important;
  background: rgba(34,197,94,0.08) !important;
}

/* ========== MARKDOWN ========== */
.msg-content h2, .msg-content h3, .msg-content h4 {
  margin: 6px 0 3px; color: var(--text-primary);
}
.msg-content h2 { font-size: 1.2rem; font-weight: 600; }
.msg-content h3 { font-size: 1.05rem; font-weight: 600; }
.msg-content h4 { font-size: 0.9375rem; font-weight: 600; }
.msg-content pre {
  background: var(--bg-deepest); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin: 4px 0;
  overflow-x: auto; font-size: 0.8125rem;
}
.msg-content code { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; }
.msg-content .inline-code {
  background: rgba(255,255,255,0.05); padding: 1px 5px;
  border-radius: 4px; font-size: 0.8125rem;
}
.msg-content blockquote {
  border-left: 3px solid var(--accent); padding: 3px 10px;
  margin: 3px 0; color: var(--text-secondary); background: var(--accent-subtle);
  border-radius: 0 4px 4px 0;
}
.msg-content li { margin-left: 18px; padding: 1px 0; }
.msg-content del { color: var(--text-muted); }
.msg-content hr {
  border: none; border-top: 1px solid var(--border);
  margin: 6px 0;
}

/* ========== MARKDOWN FILE PREVIEW ========== */
.md-attachment {
  background: var(--bg-dark); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; max-width: 560px; margin: 4px 0;
}
.md-preview-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: var(--bg-deepest);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem; color: var(--text-muted);
}
.md-download-link { text-decoration: none; font-size: 0.875rem; }
.md-preview-body {
  padding: 10px 14px; max-height: 360px; overflow-y: auto;
  font-size: 0.8125rem; line-height: 1.5;
}

/* Mention autocomplete */
.mention-dropdown {
  position: fixed;
  max-height: 220px; overflow-y: auto;
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
  z-index: 1000;
}
.mention-item {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; cursor: pointer;
  transition: background 0.1s;
}
.mention-item:hover, .mention-item.active { background: var(--bg-hover); }
.mention-status {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; background: var(--text-muted);
}
.mention-status.online { background: var(--success); }
.mention-status.everyone { background: #faa61a; }
.mention-name { font-weight: 500; color: var(--text-primary); font-size: 0.8125rem; }
.mention-username { color: var(--text-muted); font-size: 0.75rem; }

/* Inline editing */
.msg-content.editing { padding: 0; }
.inline-edit-input {
  width: 100%;
  background: var(--bg-deepest);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: inherit;
  line-height: 1.4;
  padding: 6px 8px;
  resize: vertical;
  box-sizing: border-box;
}
.inline-edit-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.inline-edit-actions { margin-top: 3px; }
.inline-edit-actions .edit-hint { font-size: 0.6875rem; color: var(--text-muted); }
.inline-edit-actions .edit-save-btn,
.inline-edit-actions .edit-cancel-btn {
  background: none; border: none; cursor: pointer;
  font-size: 0.6875rem; padding: 0; text-decoration: underline;
}
.inline-edit-actions .edit-save-btn { color: var(--accent); }
.inline-edit-actions .edit-cancel-btn { color: var(--danger); }

/* Code blocks */
.code-block-wrapper {
  position: relative;
  margin: 6px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-deepest);
  border: 1px solid var(--border);
}
.code-block-wrapper pre {
  margin: 0; padding: 10px 12px;
  background: transparent; overflow-x: auto;
}
.code-block-wrapper code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125rem; line-height: 1.5;
}
.code-copy-btn {
  position: absolute; top: 5px; right: 5px;
  background: var(--bg-hover); border: 1px solid var(--border);
  color: var(--text-muted); padding: 2px 8px;
  border-radius: 4px; cursor: pointer; font-size: 0.6875rem;
  z-index: 2; opacity: 0; transition: opacity var(--transition);
}
.code-block-wrapper:hover .code-copy-btn { opacity: 1; }
.code-lang {
  position: absolute; top: 5px; left: 8px;
  font-size: 0.625rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; z-index: 2;
}

/* ========== VOICE ========== */
.voice-connected {
  background: rgba(34, 197, 94, 0.06);
  border-top: 1px solid rgba(34, 197, 94, 0.15);
  padding: 8px 10px;
}
.voice-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 6px;
}
.voice-status {
  color: var(--success); font-size: 0.75rem; font-weight: 600;
  display: flex; align-items: center; gap: 5px;
}
.voice-channel-name { color: var(--text-primary); font-weight: 400; }
.voice-disconnect-btn {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font-size: 0.875rem; padding: 2px 5px; border-radius: 4px;
}
.voice-disconnect-btn:hover { background: rgba(239, 68, 68, 0.15); }
.voice-participants { margin-bottom: 6px; padding: 2px 0 3px 20px; }
.voice-participant {
  display: flex; align-items: center; gap: 5px;
  padding: 2px 0; font-size: 0.6875rem; color: var(--text-muted);
}
.voice-participant.speaking { color: var(--success); font-weight: 600; }
.voice-participant.speaking::before { content: '🟢 '; }
.voice-participant.muted { opacity: 0.4; }
.voice-participant-icon { font-size: 0.6rem; }
.voice-participant-name { color: var(--text-primary); }
.ptt-button {
  width: 100%; padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-light);
  color: var(--text-secondary);
  font-size: 0.8125rem; font-family: var(--font);
  cursor: pointer; user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: all var(--transition);
}
.ptt-button:hover { border-color: var(--accent); background: var(--bg-hover); }
.ptt-button.speaking {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.2);
}
.voice-join-btn {
  background: none; border: none; cursor: pointer;
  font-size: 0.6875rem; color: var(--text-muted);
  padding: 2px 5px; border-radius: 4px;
}
.voice-join-btn:hover { background: var(--accent-subtle); color: var(--accent); }

.voice-control-panel {
  display: none; flex-direction: column;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  padding: 6px 10px; gap: 4px;
}
.voice-buttons { display: flex; gap: 5px; }
.voice-btn {
  background: var(--bg-hover); border: none;
  border-radius: 50%; width: 30px; height: 30px;
  cursor: pointer; font-size: 0.875rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.voice-btn:hover { background: var(--bg-active); }
.voice-btn.active { background: var(--danger); }
.voice-btn.disconnect { background: rgba(239,68,68,0.8); }
.voice-btn.disconnect:hover { background: var(--danger); }

.btn-voice {
  background: var(--bg-light);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-voice:hover { background: var(--bg-hover); }
.btn-voice.join { background: rgba(34,197,94,0.9); border-color: transparent; }
.btn-voice.join:hover { background: var(--success); }
.btn-voice.leave { background: rgba(239,68,68,0.9); border-color: transparent; }
.btn-voice.leave:hover { background: var(--danger); }
.btn-voice.active { background: var(--danger); border-color: transparent; }
.btn-voice.ptt { background: rgba(99,102,241,0.9); border-color: transparent; cursor: pointer; user-select: none; -webkit-user-select: none; padding: 10px 20px; font-size: 0.9rem; }
.btn-voice.ptt:hover { background: rgba(99,102,241,1); }
.btn-voice.ptt.active { background: rgba(239,68,68,0.9); animation: ptt-pulse 0.8s ease-in-out infinite; }
@keyframes ptt-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } }
@keyframes handPulse { 0%,100% { border-color: rgba(255,160,0,0.4); } 50% { border-color: rgba(255,160,0,1); box-shadow: 0 0 12px rgba(255,160,0,0.3); } }
