/**
 * Community Hub - Nordic Domain Days
 * 
 * A clean, modern chat UI inspired by Slack/Discord (desktop) 
 * and WhatsApp/Telegram (mobile).
 */

/* =============================================================================
   CSS Custom Properties - Design Tokens
   ============================================================================= */

:root {
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Font sizes - Compact */
  --text-xs: 0.6875rem;    /* 11px */
  --text-sm: 0.75rem;      /* 12px */
  --text-base: 0.8125rem;  /* 13px */
  --text-lg: 0.9375rem;    /* 15px */
  --text-xl: 1.0625rem;    /* 17px */
  --text-2xl: 1.25rem;     /* 20px */
  
  /* Spacing - Compact */
  --space-1: 0.125rem;     /* 2px */
  --space-2: 0.25rem;      /* 4px */
  --space-3: 0.5rem;       /* 8px */
  --space-4: 0.75rem;      /* 12px */
  --space-5: 1rem;         /* 16px */
  --space-6: 1.25rem;      /* 20px */
  --space-8: 1.5rem;       /* 24px */
  --space-10: 2rem;        /* 32px */
  --space-12: 2.5rem;      /* 40px */
  
  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* Transitions */
  --transition-fast: 0.1s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
  
  /* Layout - Compact */
  --rail-width: 56px;
  --sidebar-width: 220px;
  --header-height: 48px;
  --input-height: 36px;
}

/* Light theme (default) - Pure white/gray, neon accents */
:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #fafafa;
  --color-bg-tertiary: #f5f5f5;
  --color-bg-hover: #eeeeee;
  --color-bg-active: #e0e0e0;
  
  --color-border: #e5e5e5;
  --color-border-light: #f0f0f0;
  
  --color-text: #171717;
  --color-text-secondary: #525252;
  --color-text-muted: #737373;
  --color-text-inverse: #ffffff;
  
  /* Neon accent - configurable per event */
  --color-primary: #ff6b35;
  --color-primary-hover: #e85a2a;
  --color-primary-light: rgba(255, 107, 53, 0.12);
  
  --color-accent: #00d4ff;
  --color-success: #22c55e;
  --color-warning: #eab308;
  --color-error: #ef4444;
  
  --color-rail: #171717;
  --color-rail-text: #a3a3a3;
  --color-rail-active: #ffffff;
}

/* Dark theme - Pure grayscale, neon accents */
[data-theme="dark"] {
  --color-bg: #111111;
  --color-bg-secondary: #1a1a1a;
  --color-bg-tertiary: #262626;
  --color-bg-hover: #333333;
  --color-bg-active: #404040;
  
  --color-border: #333333;
  --color-border-light: #262626;
  
  --color-text: #f5f5f5;
  --color-text-secondary: #a3a3a3;
  --color-text-muted: #737373;
  --color-text-inverse: #111111;
  
  /* Neon accent - same as light for consistency */
  --color-primary: #ff6b35;
  --color-primary-hover: #ff8255;
  --color-primary-light: rgba(255, 107, 53, 0.2);
  
  --color-rail: #0d0d0d;
  --color-rail-text: #737373;
  --color-rail-active: #f5f5f5;
  
  /* Adjusted semantic for dark backgrounds */
  --color-success: #22c55e;
  --color-warning: #fbbf24;
  --color-error: #f87171;
}

/* =============================================================================
   Base & Reset
   ============================================================================= */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
}

p { margin: 0; }

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
}

ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

img {
  max-width: 100%;
  height: auto;
}

/* =============================================================================
   Utility Classes
   ============================================================================= */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* =============================================================================
   App Layout - Desktop
   ============================================================================= */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Icon Rail (far left) */
.icon-rail {
  width: var(--rail-width);
  background: var(--color-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-3) 0;
  flex-shrink: 0;
}

.rail-logo {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: var(--text-base);
  margin-bottom: var(--space-5);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.rail-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-rail-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  position: relative;
}

.rail-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-rail-active);
}

.rail-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-rail-active);
}

.rail-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--color-rail-active);
  border-radius: 0 2px 2px 0;
}

.rail-btn svg {
  width: 20px;
  height: 20px;
}

.rail-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
}

.rail-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: transform var(--transition-fast);
  text-decoration: none;
}

.rail-avatar:hover {
  transform: scale(1.08);
  text-decoration: none;
}

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

.sidebar-header {
  padding: var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  height: 30px;
  padding: 0 var(--space-3) 0 30px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: border-color var(--transition-fast);
}

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

.search-box input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
}

/* Sidebar Sections */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.sidebar-section {
  margin-bottom: var(--space-3);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-1) var(--space-3);
}

.section-title {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-action {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.section-action:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

/* Channel & DM Lists */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  min-height: 28px;
}

.nav-item:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--color-bg-active);
  color: var(--color-primary);
}

.channel-hash {
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--color-text-muted);
  width: 16px;
  text-align: center;
}

.channel-lock {
  color: var(--color-text-muted);
  width: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.channel-lock svg {
  width: 12px;
  height: 12px;
}

.nav-item.active .channel-lock {
  color: var(--color-primary);
}

.nav-item.active .channel-hash {
  color: var(--color-primary);
}

.nav-item-name {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-1);
  background: var(--color-primary);
  color: white;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* DM Avatars */
.dm-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.dm-avatar-img {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

.dm-avatar-small.dm-avatar-img {
  width: 20px;
  height: 20px;
}

.dm-avatar img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.dm-status {
  position: relative;
}

.dm-status::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  background: var(--color-success);
  border: 1.5px solid var(--color-bg-secondary);
  border-radius: var(--radius-full);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.dm-status.online::after {
  opacity: 1;
  transform: scale(1);
}

/* =============================================================================
   Main Content Area
   ============================================================================= */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-bg);
}

/* Channel Header */
.channel-header {
  height: var(--header-height);
  min-height: 48px;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--color-bg);
}

.channel-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.channel-name {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.channel-name .channel-hash {
  color: var(--color-text-muted);
  font-weight: 400;
}

.channel-description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding-left: var(--space-3);
  border-left: 1px solid var(--color-border);
}

.channel-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

.member-count {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
}

.member-count svg {
  width: 16px;
  height: 16px;
}

/* =============================================================================
   Message List
   ============================================================================= */

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Individual Message */
.message {
  position: relative;
  display: flex;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: var(--text-xs);
  flex-shrink: 0;
  margin-top: 2px;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.message-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

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

.message-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: 0;
}

.message-author {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}

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

.message-content {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.4;
  word-wrap: break-word;
}

.message-content p {
  margin-bottom: var(--space-1);
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-link {
  color: var(--color-primary);
  text-decoration: none;
  word-break: break-all;
}

.message-link:hover {
  text-decoration: underline;
}

/* Markdown Formatting */
.message-content strong {
  font-weight: 600;
}

.message-content em {
  font-style: italic;
}

.message-content del {
  text-decoration: line-through;
  opacity: 0.7;
}

.inline-code {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  font-size: 0.9em;
  padding: 1px 5px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--color-accent);
}

.code-block {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  font-size: var(--text-xs);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin: var(--space-2) 0;
  overflow-x: auto;
  white-space: pre;
}

.code-block code {
  background: none;
  padding: 0;
  color: var(--color-text);
}

.message-quote {
  border-left: 3px solid var(--color-primary);
  padding-left: var(--space-3);
  margin: var(--space-2) 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* @Mentions */
.mention {
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* Message Reactions */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
  min-height: 0;
}

.message-reactions:empty {
  display: none;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem var(--space-2);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.reaction-badge:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-hover);
}

.reaction-badge.mine {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

[data-theme="dark"] .reaction-badge.mine {
  background: rgba(25, 118, 210, 0.2);
}

.reaction-emoji {
  font-size: 1rem;
  line-height: 1;
}

.reaction-count {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.reaction-badge.mine .reaction-count {
  color: var(--color-primary);
}

/* Message Actions (reaction button) */
/* Message Actions - Floating Toolbar */
.message-actions {
  position: absolute;
  top: -12px;
  right: var(--space-3);
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: all var(--transition-fast);
  z-index: 10;
}

.message:hover .message-actions {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.message-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.message-action-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.message-action-btn.pinned {
  color: var(--color-primary);
}

.message-action-btn.pinned:hover {
  color: var(--color-primary-hover);
}

/* Pinned Messages Panel */
.pinned-panel {
  position: absolute;
  top: var(--header-height);
  right: 0;
  width: 320px;
  max-height: 400px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  margin: var(--space-3);
}

.pinned-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.pinned-panel-header h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.pinned-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.pinned-close:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.pinned-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.pinned-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.pinned-message {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-bg-secondary);
  margin-bottom: var(--space-2);
}

.pinned-message:last-child {
  margin-bottom: 0;
}

.pinned-message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-1);
}

.pinned-author {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
}

.pinned-unpin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.pinned-unpin:hover {
  background: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.pinned-message-content {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.pinned-message-link {
  display: inline-block;
  font-size: var(--text-xs);
  color: var(--color-primary);
  margin-top: var(--space-1);
}

.pinned-message-link:hover {
  text-decoration: underline;
}

/* Pinned count badge */
.pinned-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--color-primary);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Message highlight animation */
.message-highlight {
  animation: message-highlight 2s ease-out;
}

@keyframes message-highlight {
  0% { background: var(--color-primary-light); }
  100% { background: transparent; }
}

/* ========================================
   Inline Reply Quote (WhatsApp/iMessage style)
   ======================================== */

/* Reply quote inside a message (shows the message being replied to) */
.reply-quote {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  max-width: 400px;
}

.reply-quote:hover {
  background: var(--color-bg-hover);
}

.reply-quote-bar {
  width: 3px;
  background: var(--color-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

.reply-quote-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.reply-quote-author {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
}

.reply-quote-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reply preview in composer (shows what message you're replying to) */
.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-2);
}

.reply-preview-content {
  display: flex;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.reply-preview-bar {
  width: 3px;
  background: var(--color-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

.reply-preview-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.reply-preview-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.reply-preview-author {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
}

.reply-preview-message {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.reply-preview-close:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.message-action-delete:hover {
  color: var(--color-error);
  border-color: var(--color-error);
}

/* Edited indicator */
.message-edited {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
}

/* Edit Message Form */
.edit-message-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.edit-message-input {
  width: 100%;
  min-height: 60px;
  max-height: 200px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.5;
  resize: vertical;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.edit-message-input:focus {
  outline: none;
}

.edit-message-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.btn-edit-cancel,
.btn-edit-save {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.btn-edit-cancel {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.btn-edit-cancel:hover {
  background: var(--color-bg-hover);
}

.btn-edit-save {
  background: var(--color-primary);
  color: white;
}

.btn-edit-save:hover {
  background: var(--color-primary-hover);
}

.edit-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Reaction Picker (mini emoji picker) */
.reaction-picker {
  position: absolute;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: 100;
  display: flex;
  gap: var(--space-1);
}

.reaction-picker button {
  padding: var(--space-1);
  font-size: 1.25rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.reaction-picker button:hover {
  background: var(--color-bg-hover);
}

[data-theme="dark"] .mention {
  background: rgba(25, 118, 210, 0.2);
}

/* @Mention Autocomplete */
.input-wrapper {
  position: relative;
  flex: 1;
}

.mention-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: var(--space-2);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 100;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.mention-item:hover,
.mention-item.active {
  background: var(--color-bg-hover);
}

.mention-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.mention-name {
  color: var(--color-text);
  font-size: var(--text-base);
}

/* Inline Images in Messages */
.message-image-link {
  display: block;
  margin: var(--space-2) 0;
}

.message-image {
  max-width: 400px;
  max-height: 300px;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

@media (max-width: 768px) {
  .message-image {
    max-width: 100%;
    max-height: 250px;
  }
}

/* File Attachment Links (PDFs, documents, etc.) */
.message-file-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  margin: var(--space-2) 0;
  max-width: 300px;
  transition: all var(--transition-fast);
}

.message-file-link:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-primary);
}

.file-icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
}

.file-info {
  display: flex;
  flex-direction: column;
  min-width: 0; /* Allow text truncation */
}

.file-name {
  font-weight: 500;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-type {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Message Attachments */
.message-attachment {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-top: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.message-attachment:hover {
  background: var(--color-bg-hover);
  text-decoration: none;
}

.attachment-icon {
  width: 32px;
  height: 32px;
  background: var(--color-error);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.attachment-icon svg {
  width: 18px;
  height: 18px;
}

.attachment-info {
  display: flex;
  flex-direction: column;
}

.attachment-name {
  font-size: var(--text-sm);
  font-weight: 500;
}

.attachment-size {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Message Reactions */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.reaction:hover {
  background: var(--color-bg-hover);
}

.reaction.active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.reaction-count {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

/* System Messages */
.system-message {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
}

.system-message-content {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
}

/* =============================================================================
   Message Composer
   ============================================================================= */

.message-composer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* Image preview in composer */
.image-preview-container {
  padding: 0 var(--space-5) var(--space-3);
}

.image-preview-wrapper {
  position: relative;
  display: inline-block;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
}

.image-preview-img {
  max-width: 200px;
  max-height: 150px;
  width: auto;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
}

/* File Preview (for non-image attachments) */
#file-preview {
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
}

.file-preview-icon {
  font-size: var(--text-xl);
}

#file-preview-name {
  font-size: var(--text-sm);
  font-weight: 500;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: var(--color-error);
  color: white;
  border: 2px solid var(--color-bg);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.image-preview-remove:hover {
  transform: scale(1.1);
}

.image-preview-remove svg {
  width: 14px;
  height: 14px;
}

/* Upload spinner animation */
.composer-btn .spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.composer-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  transition: border-color var(--transition-fast);
}

.composer-wrapper:focus-within {
  border-color: var(--color-primary);
}

.composer-actions {
  display: flex;
  gap: var(--space-1);
}

.composer-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.composer-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.composer-btn svg {
  width: 20px;
  height: 20px;
}

.composer-input {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  padding: var(--space-2) 0;
  background: transparent;
  border: none;
  color: var(--color-text);
  resize: none;
  line-height: 1.5;
}

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

.composer-input:focus {
  outline: none;
}

.composer-send {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.composer-send:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.composer-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.composer-send svg {
  width: 20px;
  height: 20px;
}

/* Typing Indicator */
.typing-indicator {
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 28px;
}

.typing-dots {
  display: flex;
  gap: 2px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: var(--radius-full);
  animation: typing-bounce 1.4s ease-in-out infinite;
}

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

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* =============================================================================
   Auth Pages
   ============================================================================= */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 50%, #1e293b 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-header {
  padding: var(--space-8) var(--space-6) var(--space-6);
  text-align: center;
  background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg) 100%);
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: var(--text-2xl);
  margin: 0 auto var(--space-4);
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.auth-body {
  padding: var(--space-6);
}

.auth-error {
  padding: var(--space-3) var(--space-4);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  color: #dc2626;
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

[data-theme="dark"] .auth-error {
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.form-input {
  height: var(--input-height);
  padding: 0 var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: all var(--transition-fast);
}

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

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.auth-submit {
  height: var(--input-height);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-base);
  transition: all var(--transition-fast);
}

.auth-submit:hover {
  background: var(--color-primary-hover);
}

.auth-footer {
  padding: var(--space-4) var(--space-6) var(--space-6);
  text-align: center;
}

.auth-footer-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.auth-footer-text a {
  color: var(--color-primary);
  font-weight: 500;
}

/* Success State */
.auth-success {
  text-align: center;
  padding: var(--space-4) 0;
}

.auth-success-icon {
  width: 64px;
  height: 64px;
  background: #dcfce7;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  color: var(--color-success);
}

.auth-success-icon svg {
  width: 32px;
  height: 32px;
}

.auth-email-highlight {
  font-weight: 600;
  color: var(--color-text);
  word-break: break-all;
}

/* =============================================================================
   Home / Welcome Page
   ============================================================================= */

.welcome-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8);
}

.welcome-icon {
  width: 80px;
  height: 80px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-5);
  color: var(--color-text-muted);
}

.welcome-icon svg {
  width: 40px;
  height: 40px;
}

.welcome-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.welcome-description {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 400px;
}

/* =============================================================================
   Empty States
   ============================================================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
}

.empty-state-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 300px;
}

/* =============================================================================
   Mobile Styles
   ============================================================================= */

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }
  
  .app-layout {
    flex-direction: column;
  }
  
  /* Hide desktop elements */
  .icon-rail,
  .sidebar {
    display: none;
  }
  
  /* Mobile Header */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  
  /* Mobile Drawer */
  .mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
  }
  
  .mobile-drawer.open {
    opacity: 1;
    visibility: visible;
  }
  
  .mobile-drawer-content {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    max-width: 85%;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }
  
  .mobile-drawer.open .mobile-drawer-content {
    transform: translateX(0);
  }
  
  .mobile-drawer-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
  }
  
  .mobile-drawer-logo {
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    flex-shrink: 0;
  }
  
  .mobile-drawer-header h1 {
    flex: 1;
    font-size: var(--text-base);
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .mobile-drawer-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
  }
  
  .mobile-drawer-close svg {
    width: 20px;
    height: 20px;
  }
  
  .mobile-drawer-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }
  
  .dm-avatar-small,
  .user-avatar-small {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 600;
    flex-shrink: 0;
  }
  
  /* Main content full width on mobile */
  .main-content {
    height: calc(100vh - var(--header-height));
  }
  
  /* Hide channel header on mobile - use mobile header instead */
  .channel-header {
    display: none;
  }
  
  .mobile-back {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .mobile-back svg {
    width: 24px;
    height: 24px;
  }
  
  .mobile-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text);
  }
  
  .mobile-action {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .mobile-action svg {
    width: 24px;
    height: 24px;
  }
  
  /* Mobile Channel List */
  .mobile-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
  }
  
  .mobile-nav-section {
    margin-bottom: var(--space-6);
  }
  
  .mobile-nav-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-2) 0;
    margin-bottom: var(--space-2);
  }
  
  .mobile-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-text);
    text-decoration: none;
    transition: background var(--transition-fast);
  }
  
  .mobile-nav-item:hover,
  .mobile-nav-item:active {
    background: var(--color-bg-secondary);
    text-decoration: none;
  }
  
  .mobile-nav-item.active {
    background: var(--color-bg-active);
    color: var(--color-primary);
  }
  
  .mobile-nav-item svg {
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    flex-shrink: 0;
  }
  
  .mobile-nav-item .channel-hash {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text-muted);
    width: 20px;
    text-align: center;
  }
  
  /* Mobile Messages */
  .message-list {
    padding: var(--space-3);
  }
  
  .message {
    padding: var(--space-2);
  }
  
  .message-avatar {
    width: 36px;
    height: 36px;
    font-size: var(--text-sm);
  }
  
  /* Mobile Composer */
  .message-composer {
    padding: var(--space-3);
  }
  
  /* Floating Action Button */
  .fab {
    position: fixed;
    bottom: calc(var(--space-4) + 70px);
    right: var(--space-4);
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
  }
  
  .fab svg {
    width: 24px;
    height: 24px;
  }
}

/* Desktop-only elements */
@media (min-width: 769px) {
  .mobile-header,
  .mobile-nav,
  .mobile-drawer,
  .fab {
    display: none !important;
  }
}

/* =============================================================================
   Emoji Picker
   ============================================================================= */

.emoji-picker-container {
  position: relative;
}

.emoji-picker {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 0;
  width: 320px;
  max-height: 300px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.emoji-picker-header {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.emoji-category-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.emoji-category-btn:hover {
  background: var(--color-bg-hover);
}

.emoji-category-btn.active {
  background: var(--color-primary-light);
}

[data-theme="dark"] .emoji-category-btn.active {
  background: var(--color-bg-active);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--space-1);
  padding: var(--space-2);
  overflow-y: auto;
  max-height: 220px;
}

.emoji-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-xl);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

@media (max-width: 768px) {
  .emoji-picker {
    width: calc(100vw - var(--space-4) * 2);
    left: 50%;
    transform: translateX(-50%);
  }
  
  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* =============================================================================
   Dark Mode Toggle
   ============================================================================= */

.theme-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--color-rail-text);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-rail-active);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* =============================================================================
   Scrollbar Styling
   ============================================================================= */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

/* =============================================================================
   Loading States
   ============================================================================= */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-secondary) 0%,
    var(--color-bg-tertiary) 50%,
    var(--color-bg-secondary) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-text {
  height: 16px;
  width: 100%;
}

.skeleton-text.short {
  width: 60%;
}

/* =============================================================================
   Focus Styles (Accessibility)
   ============================================================================= */

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}
