@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Discord-inspired layer architecture */
  --bg-deepest: #111214;
  --bg-dark: #1E1F22;
  --bg-sidebar: #2B2D31;
  --bg-primary: #313338;
  --bg-elevated: #383A40;
  --bg-hover: #3F4148;
  --bg-active: #4E5058;
  --border-color: #3F4147;
  --border-light: #4E5058;

  /* Text hierarchy */
  --text-header: #F2F3F5;
  --text-primary: #DBDEE1;
  --text-secondary: #B5BAC1;
  --text-muted: #80848E;
  --text-link: #00AFF4;

  /* Accent */
  --accent: #5865F2;
  --accent-hover: #4752C4;
  --accent-active: #3C45A5;
  --accent-glow: rgba(88,101,242,0.2);

  /* Status */
  --green: #23A559;
  --yellow: #F0B232;
  --red: #F23F43;

  /* Sizing */
  --sidebar-w: 72px;
  --channel-w: 240px;
  --chat-hdr: 48px;
  --user-h: 52px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-low: 0 1px 0 rgba(4,4,5,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);

  /* Transitions */
  --fast: 0.12s cubic-bezier(0.4,0,0.2,1);
  --norm: 0.18s cubic-bezier(0.4,0,0.2,1);
  --slow: 0.3s cubic-bezier(0.4,0,0.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-deepest);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  opacity: 0;
  animation: bodyIn 0.3s ease-out forwards;
}
@keyframes bodyIn { 0% { opacity: 0; } 100% { opacity: 1; } }

::selection { background: var(--accent); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── LOGIN ─────────────────────────────────── */
.login-page {
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; padding: 20px;
  background: radial-gradient(ellipse 600px 400px at 50% -10%, rgba(88,101,242,0.06) 0%, transparent 70%), var(--bg-deepest);
}
.login-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: clamp(32px,5vw,48px) clamp(24px,4vw,40px);
  width: min(400px, 100%);
  box-shadow: var(--shadow-lg);
  animation: fadeScale 0.35s ease-out;
}
.login-box h2 {
  font-size: 26px; font-weight: 800; text-align: center;
  background: linear-gradient(135deg, var(--accent), #9b59b6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px; letter-spacing: -0.5px;
}
.login-subtitle {
  text-align: center; color: var(--text-secondary); font-size: 14px;
  margin-bottom: 28px;
}
.login-box .error {
  display: none; color: var(--red); font-size: 13px; text-align: center;
  padding: 10px; background: rgba(242,63,67,0.1); border: 1px solid rgba(242,63,67,0.25);
  border-radius: var(--radius-xs); margin-bottom: 14px;
}
.login-box .error.show { display: block; }
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 20px;
  background: var(--bg-dark); border-radius: var(--radius-md);
  overflow: hidden; border: 1px solid var(--border-color);
}
.auth-tab {
  flex: 1; padding: 10px; text-align: center;
  font-size: 13px; font-weight: 600; font-family: inherit;
  color: var(--text-muted); cursor: pointer;
  background: none; border: none; transition: var(--norm);
}
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-tab:hover:not(.active) { background: var(--bg-hover); color: var(--text-primary); }

.login-box form { display: flex; flex-direction: column; gap: 10px; }
.login-box input {
  background: var(--bg-dark); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md); padding: 12px 14px;
  color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none;
  transition: var(--norm);
}
.login-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-box input::placeholder { color: var(--text-muted); }
.login-box .login-btn {
  background: var(--accent); border: none;
  border-radius: var(--radius-md); padding: 12px;
  color: #fff; font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: var(--norm); margin-top: 4px;
}
.login-box .login-btn:hover { background: var(--accent-hover); }
.login-box .login-btn:active { background: var(--accent-active); }
.login-box .login-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.auth-quick {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.auth-quick-label {
  font-size: 10px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 600; margin-right: 4px;
}
.auth-quick-btn {
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 6px 14px;
  color: var(--text-secondary); font-size: 12px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: var(--fast);
}
.auth-quick-btn:hover { border-color: var(--accent); color: #fff; background: var(--accent-glow); }
.auth-quick-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── LAYOUT ─────────────────────────────────── */
.app-layout { display: flex; height: 100vh; width: 100vw; overflow: hidden; animation: slideUp 0.25s ease-out; }

/* ─── SERVER SIDEBAR ─────────────────────────── */
.server-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; z-index: 10;
  background: var(--bg-deepest);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0;
}
.server-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--fast);
  background: var(--bg-dark); border: none; color: var(--text-muted);
  position: relative;
}
.server-icon svg { transition: var(--fast); }
.server-icon:hover { border-radius: 14px; background: var(--accent); color: #fff; transform: scale(1.05); }
.server-icon:active { transform: scale(0.95); }
.server-icon.active { background: var(--accent); color: #fff; border-radius: 14px; }
.server-icon.active::before {
  content: ''; position: absolute; left: -10px;
  width: 3px; height: 24px; background: #fff; border-radius: 2px;
}
.server-divider { width: 32px; height: 1px; background: var(--bg-elevated); margin: 4px 0; }
.server-guild-list { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }

/* ─── CHANNEL SIDEBAR ────────────────────────── */
.channel-sidebar {
  width: var(--channel-w); flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border-color);
}
.sidebar-header {
  height: var(--chat-hdr); padding: 0 16px;
  display: flex; align-items: center; font-weight: 700; font-size: 15px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  color: var(--text-header);
}
.section-label {
  padding: 16px 16px 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
}
.channel-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.channel-item {
  padding: 7px 10px; border-radius: var(--radius-xs);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 500;
  color: var(--text-secondary); transition: all var(--fast);
  margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: none;
}
.channel-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.channel-item:active { transform: scale(0.98); }
.channel-item.active { background: var(--bg-hover); color: #fff; }
.channel-item .user-status.online { animation: pulse 2.5s ease-in-out infinite; }
.channel-item .hash { opacity: 0.4; font-weight: 400; font-size: 16px; color: var(--text-muted); }
.channel-item .user-status {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.channel-item .user-status.online { background: var(--green); box-shadow: 0 0 0 2px rgba(35,165,89,0.2); }
.channel-item .user-status.offline { background: var(--text-muted); opacity: 0.35; }
.channel-item .avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
}

/* ─── USER PANEL ──────────────────────────────── */
.user-panel {
  height: var(--user-h); padding: 0 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.user-panel-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
}
.user-panel-info { flex: 1; min-width: 0; }
.user-panel-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-header); }
.user-panel-status { font-size: 11px; color: var(--green); font-weight: 500; }
.user-panel-actions { display: flex; gap: 2px; }
.panel-action-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: var(--radius-xs); transition: var(--fast);
}
.panel-action-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }
.panel-action-btn.logout-btn:hover { color: var(--red); background: rgba(242,63,67,0.1); }
.user-panel-actions button {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: var(--radius-xs); transition: var(--fast);
}
.user-panel-actions button:hover { color: var(--red); background: rgba(242,63,67,0.1); }

/* ─── MAIN CONTENT ──────────────────────────── */
.main-content {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: var(--bg-primary); overflow: hidden;
}

/* Chat Header */
.chat-header {
  height: var(--chat-hdr); padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-primary); flex-shrink: 0; z-index: 5;
  box-shadow: var(--shadow-low);
}
.chat-header .title {
  font-size: 16px; font-weight: 700; color: var(--text-header);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-header .topic {
  font-size: 12px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (min-width: 640px) { .chat-header .topic { display: block; } }
@media (max-width: 639px) { .chat-header .topic { display: none; } }
.chat-header .spacer { flex: 1; }
.header-divider { width: 1px; height: 20px; background: var(--border-color); margin: 0 4px; flex-shrink: 0; }
.header-actions { display: flex; gap: 2px; margin-left: auto; }
.icon-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--fast); border-radius: var(--radius-xs);
}
.icon-btn:hover { background: var(--bg-elevated); color: var(--text-primary); }
.icon-btn:active { transform: scale(0.9); }

/* ─── MESSAGES ────────────────────────────────── */
.messages-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 8px 12px; display: flex; flex-direction: column;
  position: relative;
}
.message-group {
  display: flex; gap: 10px;
  padding: 2px 0; position: relative;
  animation: msgIn 0.12s ease-out;
}
@keyframes msgIn { 0% { opacity: 0; transform: translateY(6px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes msgInLeft { 0% { opacity: 0; transform: translateX(-8px); } 100% { opacity: 1; transform: translateX(0); } }
@keyframes msgInRight { 0% { opacity: 0; transform: translateX(8px); } 100% { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 4px var(--accent-glow); } 50% { box-shadow: 0 0 12px var(--accent-glow); } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }
@keyframes slideUp { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes fadeScale { 0% { opacity: 0; transform: scale(0.95); } 100% { opacity: 1; transform: scale(1); } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes borderGlow { 0%, 100% { border-color: var(--border-color); } 50% { border-color: var(--accent); } }
@keyframes dotPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.3); } }
.message-group:hover { background: rgba(255,255,255,0.02); margin: 0 -12px; padding: 2px 12px; border-radius: 4px; }
.message-group:nth-child(1) { animation-delay: 0.02s; }
.message-group:nth-child(2) { animation-delay: 0.04s; }
.message-group:nth-child(3) { animation-delay: 0.06s; }
.message-group:nth-child(4) { animation-delay: 0.08s; }
.message-group:nth-child(5) { animation-delay: 0.10s; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; margin-top: 2px;
  user-select: none; overflow: hidden;
}
.msg-avatar-img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.msg-avatar-initial { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #fff; }
.msg-body { flex: 1; min-width: 0; overflow: hidden; }
.msg-header {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 1px;
  flex-wrap: wrap;
}
.msg-username {
  font-size: 14px; font-weight: 700; cursor: pointer; letter-spacing: -0.2px;
}
.msg-username:hover { text-decoration: underline; }
.msg-timestamp {
  font-size: 10px; color: var(--text-muted); white-space: nowrap;
}
.msg-text {
  font-size: 14px; line-height: 1.5;
  word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap;
  color: var(--text-primary);
}
.msg-text code {
  background: var(--bg-dark); padding: 1px 6px; border-radius: 3px;
  font-size: 12px; font-family: 'Consolas', 'Courier New', monospace; border: 1px solid var(--border-color);
}
.msg-text .code-block-wrap pre {
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-xs); padding: 12px; margin: 6px 0;
  overflow-x: auto; font-size: 12px; font-family: 'Consolas', 'Courier New', monospace;
}
.msg-text a { color: var(--text-link); text-decoration: none; }
.msg-text a:hover { text-decoration: underline; }

/* File messages */
.file-preview {
  margin: 4px 0; border-radius: var(--radius-xs); overflow: hidden;
  max-width: min(400px, 80vw); border: 1px solid var(--border-color); background: #000;
}
.file-preview img, .file-preview video {
  width: 100%; display: block; max-height: 320px; object-fit: contain;
}
.file-message {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-xs); padding: 10px 14px; margin: 4px 0;
  cursor: pointer; transition: var(--fast); max-width: min(360px, 75vw);
}
.file-message:hover { border-color: var(--accent); background: var(--bg-elevated); }
.file-icon {
  width: 28px; height: 28px; border-radius: 4px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.file-size { font-size: 11px; color: var(--text-muted); }
.file-download {
  color: var(--accent); text-decoration: none; flex-shrink: 0;
  padding: 4px 8px; border-radius: var(--radius-xs); font-weight: 600;
  transition: var(--fast); font-size: 13px;
}
.file-download:hover { background: var(--accent-glow); }

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.reaction {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 12px; cursor: pointer;
  font-size: 12px; background: var(--bg-dark); border: 1px solid var(--border-color);
  transition: var(--fast); user-select: none;
}
.reaction:hover { border-color: var(--accent); background: var(--bg-elevated); }
.reaction.active { background: var(--accent-glow); border-color: var(--accent); }
.reaction .count { font-size: 10px; color: var(--text-muted); font-weight: 600; }

/* Message actions (hover toolbar) */
.msg-actions {
  display: none; position: absolute; right: 4px; top: -16px;
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 2px; gap: 1px;
  box-shadow: var(--shadow-md); z-index: 10;
}
.message-group:hover .msg-actions { display: flex; }
.msg-action-reaction {
  background: none; border: none; cursor: pointer;
  padding: 2px 5px; border-radius: 3px; font-size: 14px;
  transition: var(--fast); line-height: 1;
}
.msg-action-reaction:hover { background: var(--bg-elevated); transform: scale(1.08); }

/* Date separator */
.date-separator {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 8px; flex-shrink: 0;
  animation: slideUp 0.2s ease-out;
}
.date-separator::before, .date-separator::after {
  content: ''; flex: 1; height: 1px; background: var(--border-color);
}
.date-separator span {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Code copy button */
.code-block-wrap { position: relative; }
.code-copy-btn {
  position: absolute; top: 6px; right: 6px;
  background: var(--bg-elevated); border: 1px solid var(--border-color);
  border-radius: var(--radius-xs); color: var(--text-muted);
  cursor: pointer; padding: 4px 8px; font-size: 10px;
  font-family: inherit; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.3px; transition: var(--fast); opacity: 0;
  z-index: 2;
}
.code-block-wrap:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.code-copy-btn.copied { background: var(--green); color: #fff; border-color: var(--green); }

/* Auto-scroll button */
.scroll-bottom-btn {
  position: absolute; bottom: 100%; right: 16px;
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: 50%; width: 34px; height: 34px;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--fast);
  box-shadow: var(--shadow-md); z-index: 5;
  transform: translateY(-8px);
}
.scroll-bottom-btn.show { display: flex; }
.scroll-bottom-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.scroll-bottom-btn:active { transform: translateY(-8px) scale(0.95); }

/* Bookmark */
.msg-bookmark {
  position: absolute; left: -6px; top: 4px;
  background: none; border: none; color: transparent; cursor: pointer;
  padding: 2px; font-size: 11px; transition: var(--fast);
  opacity: 0; z-index: 2;
}
.message-group:hover .msg-bookmark { opacity: 1; }
.msg-bookmark:hover { color: var(--yellow); }
.msg-bookmark.active { color: var(--yellow); opacity: 1; }

/* ─── TYPING ───────────────────────────────────── */
.typing-area {
  padding: 2px 16px; font-size: 12px; color: var(--text-muted);
  min-height: 22px; font-style: italic; flex-shrink: 0;
}

/* ─── INPUT AREA ────────────────────────────── */
.input-area {
  padding: 0 12px 10px; flex-shrink: 0; position: relative;
}
.input-wrapper {
  background: var(--bg-elevated); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md); display: flex; align-items: flex-end;
  transition: var(--norm);
}
.input-wrapper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-tools {
  display: flex; align-items: center;
  padding: 6px 2px 6px 10px; gap: 2px; flex-shrink: 0;
}
.input-tools button {
  background: none; border: none; color: var(--text-muted);
  width: 30px; height: 30px; border-radius: var(--radius-xs);
  cursor: pointer; transition: var(--fast);
  display: flex; align-items: center; justify-content: center;
}
.input-tools button:hover { background: var(--bg-hover); color: var(--text-primary); }
.input-wrapper textarea {
  flex: 1; background: none; border: none; padding: 10px 6px;
  color: var(--text-primary); font-size: 14px; font-family: inherit;
  outline: none; resize: none; max-height: 160px; line-height: 1.4;
  min-height: 44px;
}
.input-wrapper textarea::placeholder { color: var(--text-muted); }
.send-btn {
  background: var(--accent); border: none; color: #fff;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  margin: 4px; cursor: pointer; transition: var(--fast); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { background: var(--accent-active); }

/* File label */
.file-label {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px; border-radius: var(--radius-xs); font-size: 12px;
  color: var(--text-secondary); margin: 3px 10px 0; flex-shrink: 0;
  background: var(--bg-dark); border: 1px solid var(--border-color);
}
.file-label .clear {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 2px; display: flex; align-items: center; justify-content: center;
}
.file-label .clear:hover { color: var(--red); }

/* ─── EMOJI PICKER ─────────────────────────────── */
.emoji-picker {
  position: absolute; bottom: calc(100% + 6px); left: 8px;
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 8px;
  width: min(300px, calc(100vw - 30px));
  max-height: min(260px, 40vh); overflow-y: auto;
  display: none; z-index: 100; box-shadow: var(--shadow-lg);
}
.emoji-picker.show { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-picker span { font-size: 22px; cursor: pointer; padding: 3px; border-radius: 4px; text-align: center; transition: var(--fast); }
.emoji-picker span:hover { background: var(--bg-hover); transform: scale(1.15); z-index: 1; }

/* ─── SEARCH ───────────────────────────────────── */
.search-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  z-index: 200; display: none; justify-content: center;
  padding: 8vh 12px 0;
}
.search-overlay.show { display: flex; }
.search-modal {
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: min(520px, 100%); max-height: 65vh;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.search-modal input {
  width: 100%; padding: 16px;
  background: none; border: none;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary); font-size: 15px; font-family: inherit; outline: none;
}
.search-modal input::placeholder { color: var(--text-muted); }
.search-results { padding: 6px; overflow-y: auto; flex: 1; }
.search-result-item {
  padding: 10px 12px; border-radius: var(--radius-xs);
  cursor: pointer; transition: var(--fast);
}
.search-result-item:hover { background: var(--bg-elevated); }
.search-result-item .result-user { font-size: 12px; font-weight: 700; }
.search-result-item .result-text { font-size: 13px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── AI PANEL ─────────────────────────────────── */
.ai-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(400px, 100vw);
  background: var(--bg-sidebar); border-left: 1px solid var(--border-color);
  z-index: 150; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--slow);
  box-shadow: var(--shadow-lg);
}
.ai-panel.open { transform: translateX(0); }

/* Header */
.ai-header {
  height: 44px; padding: 0 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--bg-sidebar);
}
.ai-new-chat-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  width: 28px; height: 28px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: var(--fast); flex-shrink: 0;
}
.ai-new-chat-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.ai-title {
  font-size: 15px; font-weight: 700; color: var(--text-header);
  white-space: nowrap; margin-right: 2px;
}
.ai-header-spacer { flex: 1; }
.ai-model-select {
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-xs); padding: 3px 6px;
  color: var(--text-primary); font-size: 10px; font-family: inherit; outline: none;
  cursor: pointer; max-width: 100px;
}
.ai-header-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; display: flex; align-items: center; justify-content: center;
}
.ai-header-close:hover { color: var(--text-primary); background: var(--bg-hover); border-radius: 4px; }

/* Content area */
.ai-content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}

/* Conversation list */
.ai-conv-list {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}
.ai-conv-items {
  flex: 1; overflow-y: auto; padding: 6px;
}
.ai-conv-item {
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--fast);
  display: flex; align-items: center; gap: 8px;
  border: 1px solid transparent;
}
.ai-conv-item:hover { background: var(--bg-elevated); }
.ai-conv-item.active { background: var(--bg-hover); border-color: var(--border-color); }
.ai-conv-item-icon {
  width: 30px; height: 30px; border-radius: var(--radius-xs);
  background: var(--accent); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
}
.ai-conv-item-body { flex: 1; min-width: 0; }
.ai-conv-item-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-conv-item-meta {
  font-size: 10px; color: var(--text-muted); margin-top: 2px;
}
.ai-conv-item-actions {
  display: none; gap: 2px; flex-shrink: 0;
}
.ai-conv-item:hover .ai-conv-item-actions { display: flex; }
.ai-conv-item-action {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 3px; display: flex; align-items: center; justify-content: center;
  transition: var(--fast);
}
.ai-conv-item-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.ai-conv-item-action.danger:hover { color: var(--red); background: rgba(242,63,67,0.1); }

.ai-conv-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 20px; text-align: center;
  color: var(--text-muted);
}
.ai-conv-empty-text { font-size: 13px; }
.ai-conv-empty-hint { font-size: 11px; opacity: 0.7; }

/* Conversation view */
.ai-conv-view {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}
.ai-conv-hdr {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-sidebar); flex-shrink: 0;
}
.ai-back-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  width: 26px; height: 26px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: var(--fast); flex-shrink: 0;
}
.ai-back-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.ai-conv-title-area {
  flex: 1; min-width: 0;
}
.ai-conv-title-label {
  font-size: 13px; font-weight: 600; color: var(--text-header);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: block;
}
.ai-conv-title-input {
  width: 100%; background: var(--bg-dark); border: 1px solid var(--accent);
  border-radius: 3px; padding: 3px 6px;
  color: var(--text-primary); font-size: 13px; font-weight: 600;
  font-family: inherit; outline: none;
}
.ai-conv-action {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  width: 26px; height: 26px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: var(--fast); flex-shrink: 0;
}
.ai-conv-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.ai-conv-action-danger:hover { color: var(--red); background: rgba(242,63,67,0.1); }
.ai-conv-status {
  font-size: 10px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 80px;
}

/* Messages */
.ai-msgs {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.ai-msg {
  padding: 10px 14px; border-radius: var(--radius-md);
  font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
  animation: msgIn 0.15s ease-out;
}
.ai-msg.user {
  background: var(--accent); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
  max-width: 88%;
}
.ai-msg.assistant {
  background: var(--bg-dark); border: 1px solid var(--border-color);
  align-self: flex-start; border-bottom-left-radius: 4px;
  max-width: 100%;
}
.ai-msg .ai-ts {
  font-size: 9px; color: var(--text-muted); margin-top: 4px; opacity: 0.5;
}
.ai-msg.loading {
  align-self: flex-start;
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}
.ai-msg.error {
  align-self: flex-start;
  background: rgba(242,63,67,0.1); border: 1px solid rgba(242,63,67,0.3);
  color: var(--red);
  border-bottom-left-radius: 4px;
}
.ai-typing {
  align-self: flex-start; display: flex; gap: 3px; padding: 10px 14px;
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); border-bottom-left-radius: 4px;
}
.ai-typing span {
  width: 6px; height: 6px; background: var(--text-muted);
  border-radius: 50%; animation: aiBounce 1.4s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.16s; }
.ai-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes aiBounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

/* Input area */
.ai-input-area {
  padding: 8px 10px; border-top: 1px solid var(--border-color);
  display: flex; gap: 6px; flex-shrink: 0;
}
.ai-msg-input {
  flex: 1; background: var(--bg-dark);
  border: 1px solid var(--border-color); border-radius: var(--radius-xs);
  padding: 9px 12px; color: var(--text-primary); font-size: 13px;
  font-family: inherit; outline: none; min-width: 0;
}
.ai-msg-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.ai-msg-input::placeholder { color: var(--text-muted); }
.ai-send-msg-btn {
  background: var(--accent); border: none; color: #fff;
  padding: 9px 14px; border-radius: var(--radius-xs);
  cursor: pointer; font-weight: 600; font-size: 12px;
  font-family: inherit; white-space: nowrap; transition: var(--fast);
}
.ai-send-msg-btn:hover { background: var(--accent-hover); }
.ai-send-msg-btn:active { background: var(--accent-active); }
.ai-send-msg-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Footer */
.ai-footer {
  height: 34px; padding: 0 14px; flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--bg-deepest);
}
.ai-powered-text {
  font-size: 10px; color: var(--text-muted);
}
.ai-powered-link {
  font-size: 10px; color: var(--accent); text-decoration: none;
  font-weight: 600; transition: var(--fast);
}
.ai-powered-link:hover { color: var(--accent-hover); text-decoration: underline; }

/* Confirm dialog */
.ai-confirm-overlay {
  position: absolute; inset: 0; z-index: 160;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
}
.ai-confirm-box {
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 20px;
  width: min(280px, 85%); box-shadow: var(--shadow-lg);
  text-align: center;
}
.ai-confirm-box p { font-size: 13px; color: var(--text-primary); margin-bottom: 14px; }
.ai-confirm-actions { display: flex; gap: 8px; justify-content: center; }
.ai-confirm-actions button {
  padding: 8px 20px; border-radius: var(--radius-xs);
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: none; transition: var(--fast);
}
.ai-confirm-cancel { background: var(--bg-elevated); color: var(--text-primary); }
.ai-confirm-cancel:hover { background: var(--bg-hover); }
.ai-confirm-delete { background: var(--red); color: #fff; }
.ai-confirm-delete:hover { background: #d32f2f; }

/* ─── SMART REPLIES ────────────────────────────── */
.smart-replies {
  display: flex; gap: 4px; padding: 4px 16px;
  flex-wrap: wrap; flex-shrink: 0; overflow-x: auto;
}
.smart-reply-btn {
  padding: 5px 14px; font-size: 12px; font-weight: 500;
  background: var(--bg-dark); border: 1px solid var(--border-color);
  border-radius: 16px; color: var(--text-secondary);
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: var(--fast);
}
.smart-reply-btn:hover { border-color: var(--accent); color: #fff; background: var(--accent-glow); }

/* ─── WELCOME ───────────────────────────────────── */
.welcome-screen {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; color: var(--text-muted); text-align: center; padding: 20px;
}
.welcome-screen h2 { font-size: 22px; color: var(--text-secondary); font-weight: 700; }
.welcome-screen p { font-size: 14px; max-width: 380px; line-height: 1.5; color: var(--text-muted); }
.shortcut-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; opacity: 0.6; }
@media (min-width: 768px) { .shortcut-hint { display: block; } }

/* ─── OVERLAY ───────────────────────────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 49; }
.sidebar-overlay.show { display: block; }

/* ─── MOBILE ────────────────────────────────────── */
.mobile-menu-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; display: flex; align-items: center; justify-content: center;
}
.mobile-menu-btn:hover { color: var(--text-primary); }

@media (max-width: 640px) {
  .server-sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; width: 100%; height: auto;
    flex-direction: row; padding: 4px 8px; gap: 4px;
    border-right: none; border-top: 1px solid var(--border-color);
    z-index: 50; justify-content: center;
  }
  .server-icon { width: 42px; height: 42px; }
  .server-icon.active::before { display: none; }
  .server-divider { width: 1px; height: 24px; }
  .chat-header .mobile-menu-btn { display: flex !important; }
}
@media (max-width: 560px) {
  .channel-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(240px, 75vw); z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--slow);
    box-shadow: var(--shadow-lg);
  }
  .channel-sidebar.open { transform: translateX(0); }
}
@media (min-width: 561px) {
  .mobile-menu-btn { display: none !important; }
}

/* ─── NEW ANIMATIONS ────────────────────────── */
@keyframes callPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(88,101,242,0.6); } 50% { box-shadow: 0 0 0 12px rgba(88,101,242,0); } }
@keyframes videoGlow { 0%, 100% { border-color: var(--accent); } 50% { border-color: #9b59b6; } }
@keyframes audioWave { 0%, 100% { height: 3px; } 50% { height: 12px; } }
@keyframes ringPulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes connectSpin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes voiceWave { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@keyframes recordingPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes slideInRight { 0% { transform: translateX(100%); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes slideInUp { 0% { transform: translateY(20px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

/* ─── MENTIONS ──────────────────────────────── */
.mention {
  background: rgba(88,101,242,0.2);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}
.mention:hover { background: rgba(88,101,242,0.35); }

/* ─── LINK PREVIEW CARD ─────────────────────── */
.link-preview-card {
  display: flex; gap: 10px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin: 6px 0;
  max-width: min(400px, 80vw);
  animation: slideInUp 0.25s ease-out;
}
.link-preview-img {
  width: 80px; height: 60px;
  object-fit: cover; border-radius: 4px;
  flex-shrink: 0;
}
.link-preview-body { flex: 1; min-width: 0; }
.link-preview-title { font-size: 13px; font-weight: 600; color: var(--text-header); }
.link-preview-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.link-preview-domain { font-size: 10px; color: var(--text-muted); margin-top: 4px; opacity: 0.7; }
.link-preview-favicon { width: 14px; height: 14px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.link-preview-card { cursor: pointer; }
.link-preview-card:hover { border-color: var(--accent); }
.inline-media { margin: 6px 0; max-width: min(520px, 90vw); }
.inline-image { max-width: 100%; max-height: 400px; border-radius: 8px; cursor: zoom-in; display: block; }
.inline-video { max-width: 100%; max-height: 400px; border-radius: 8px; display: block; }
.video-embed { width: 100%; max-width: 520px; height: 292px; border-radius: 8px; display: block; }

/* ─── FAVORITES STAR ────────────────────────── */
.fav-star {
  cursor: pointer; font-size: 14px; margin-left: auto;
  color: var(--text-muted); transition: var(--fast);
  padding: 2px; flex-shrink: 0; user-select: none;
}
.fav-star:hover { color: var(--yellow); transform: scale(1.2); }
.fav-star.active { color: var(--yellow); }

/* ─── CALL USER BUTTONS ─────────────────────── */
.call-user-actions {
  display: none; gap: 1px; margin-left: auto; flex-shrink: 0;
}
.channel-item:hover .call-user-actions { display: flex; }
.call-user-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 2px 4px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--fast);
}
.call-user-btn:hover { color: var(--green); background: rgba(35,165,89,0.15); }
.call-user-btn:active { transform: scale(0.9); }

/* ─── VOICE RECORDER ────────────────────────── */
.voice-recorder {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); margin: 0 10px 4px;
  animation: slideInUp 0.15s ease-out;
}
.voice-recorder-timer {
  font-size: 13px; font-weight: 700;
  color: var(--red); font-variant-numeric: tabular-nums;
  animation: recordingPulse 1.2s ease-in-out infinite;
  min-width: 40px;
}
.voice-recorder-wave {
  flex: 1; height: 20px;
  display: flex; align-items: center; gap: 2px;
}
.voice-recorder-wave::before {
  content: ''; flex: 1;
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--red) 0px, var(--red) 2px, transparent 2px, transparent 6px);
  animation: voiceWave 0.5s ease-in-out infinite alternate;
}
.voice-recorder-send, .voice-recorder-cancel {
  background: none; border: none; cursor: pointer;
  padding: 4px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: var(--fast);
}
.voice-recorder-send { color: var(--green); }
.voice-recorder-send:hover { background: rgba(35,165,89,0.15); }
.voice-recorder-cancel { color: var(--red); }
.voice-recorder-cancel:hover { background: rgba(242,63,67,0.15); }
.tool-btn.recording { color: var(--red) !important; animation: recordingPulse 1s ease-in-out infinite; }

/* ─── REPLY PREVIEW ─────────────────────────── */
.reply-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--bg-dark);
  border-top: 2px solid var(--accent);
  animation: slideInUp 0.12s ease-out; flex-shrink: 0;
}
.reply-preview-content { flex: 1; min-width: 0; }
.reply-preview-label { font-size: 11px; color: var(--accent); font-weight: 600; }
.reply-preview-label .reply-preview-user { color: var(--text-header); }
.reply-preview-text { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-preview-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: var(--radius-xs);
  display: flex; transition: var(--fast);
}
.reply-preview-close:hover { color: var(--red); background: rgba(242,63,67,0.1); }

/* ─── SYSTEM MESSAGE ──────────────────────────── */
.message-group[data-system] .msg-body .msg-text {
  font-size: 12px; color: var(--text-muted); font-style: italic;
  text-align: center;
}

/* ─── INCOMING CALL ────────────────────────── */
.call-incoming {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  animation: fadeScale 0.25s ease-out;
}
.call-incoming-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px 40px;
  text-align: center;
  animation: ringPulse 2s ease-in-out infinite;
  box-shadow: var(--shadow-lg);
}
.call-incoming-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: #fff;
  margin: 0 auto 12px;
  animation: callPulse 2s ease-in-out infinite;
}
.call-incoming-name { font-size: 20px; font-weight: 700; color: var(--text-header); }
.call-incoming-type { font-size: 13px; color: var(--text-muted); margin: 4px 0 20px; }
.call-incoming-actions { display: flex; gap: 16px; justify-content: center; }
.call-btn {
  width: 52px; height: 52px; border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--norm);
}
.call-btn:hover { transform: scale(1.1); }
.call-btn:active { transform: scale(0.95); }
.call-btn-decline { background: var(--red); color: #fff; }
.call-btn-decline:hover { background: #e03030; }
.call-btn-accept { background: var(--green); color: #fff; }
.call-btn-accept:hover { background: #1d8f4c; }
.call-btn-accept-video {
  background: var(--accent); color: #fff;
  width: 52px; height: 52px; border-radius: 50%;
  border: none; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  transition: var(--norm);
}
.call-btn-accept-video:hover { background: var(--accent-hover); transform: scale(1.1); }

/* ─── ACTIVE CALL OVERLAY ───────────────────── */
.call-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  animation: fadeScale 0.2s ease-out;
}
.call-overlay-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
}
.call-video-container {
  position: relative; z-index: 1;
  width: min(90vw, 800px);
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--border-color);
  animation: videoGlow 3s ease-in-out infinite;
}
.call-video-remote {
  width: 100%; height: 100%;
  object-fit: contain; display: block;
}
.call-video-local {
  position: absolute; bottom: 16px; right: 16px;
  width: 25%; max-width: 180px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  background: #000;
  object-fit: cover;
}
.call-info {
  position: relative; z-index: 1;
  text-align: center; margin: 16px 0 8px;
}
.call-partner-name { font-size: 22px; font-weight: 700; color: #fff; }
.call-duration { font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.call-quality {
  margin-top: 6px;
}
.call-quality-select {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-xs); padding: 3px 8px;
  color: var(--text-secondary); font-size: 11px; font-family: inherit;
  cursor: pointer; outline: none;
}
.call-quality-select option { background: #1E1F22; color: var(--text-primary); }

/* ─── CALL STATS ────────────────────────────── */
.call-stats {
  position: relative; z-index: 1;
  display: flex; gap: 16px;
  padding: 6px 16px; background: rgba(0,0,0,0.5);
  border-radius: 20px; margin-bottom: 8px;
  font-size: 11px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ─── CALL TRANSCRIPTION ────────────────────── */
.call-transcription {
  position: relative; z-index: 1;
  width: min(90vw, 800px);
  max-height: 120px;
  background: rgba(0,0,0,0.6);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
  animation: slideInUp 0.2s ease-out;
}
.call-transcription-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
}
.call-transcription-summarize {
  background: var(--accent); border: none; color: #fff;
  padding: 2px 10px; border-radius: var(--radius-xs);
  font-size: 10px; font-family: inherit; cursor: pointer; font-weight: 600;
  transition: var(--fast);
}
.call-transcription-summarize:hover { background: var(--accent-hover); }
.call-transcription-text {
  padding: 8px 12px; font-size: 12px; color: var(--text-primary);
  max-height: 80px; overflow-y: auto; line-height: 1.5;
}
.transcription-interim { color: var(--text-muted); font-style: italic; }
.transcription-summarizing { color: var(--yellow); font-style: italic; margin-top: 4px; }
.transcription-summary { color: var(--green); margin-top: 4px; font-weight: 500; }

/* ─── CALL CONTROLS ─────────────────────────── */
.call-controls {
  position: relative; z-index: 1;
  display: flex; gap: 12px; align-items: center;
  margin: 8px 0 4px;
}
.call-ctrl-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--fast);
}
.call-ctrl-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.05); }
.call-ctrl-btn:active { transform: scale(0.95); }
.call-ctrl-btn.muted { background: var(--red); color: #fff; }
.call-ctrl-btn.muted:hover { background: #e03030; }
.call-ctrl-btn.active { background: var(--green); color: #fff; }
.call-ctrl-btn.active:hover { background: #1d8f4c; }
.call-ctrl-btn.recording { animation: recordingPulse 1.2s ease-in-out infinite; background: var(--red); color: #fff; }
.call-ctrl-end { background: var(--red); color: #fff; width: 52px; height: 52px; }
.call-ctrl-end:hover { background: #e03030; transform: scale(1.05); }

/* ─── CALL AUDIO VIZ ────────────────────────── */
.call-audio-viz {
  position: relative; z-index: 1;
  margin-top: 4px;
}
#audioCanvas { display: block; border-radius: var(--radius-xs); }

/* ─── CALL HISTORY ──────────────────────────── */
.call-history-overlay {
  position: fixed; inset: 0; z-index: 250;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  animation: fadeScale 0.2s ease-out;
}
.call-history-modal {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: min(400px, 90vw);
  max-height: 70vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.call-history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700; font-size: 15px; color: var(--text-header);
}
.call-history-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: var(--radius-xs);
  display: flex; transition: var(--fast);
}
.call-history-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.call-history-list {
  padding: 8px; overflow-y: auto; flex: 1;
}
.call-history-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }
.call-history-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-xs);
  transition: var(--fast);
  animation: slideInUp 0.15s ease-out;
}
.call-history-item:hover { background: var(--bg-elevated); }
.call-history-type { font-size: 16px; flex-shrink: 0; }
.call-history-partner { flex: 1; font-weight: 600; font-size: 13px; color: var(--text-primary); }
.call-history-dur { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.call-history-date { font-size: 11px; color: var(--text-muted); }

/* ─── HASH ICON ──────────────────────────────── */
.hash-icon {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 18px;
  margin-right: -4px;
}
.hash-icon.hidden { display: none; }

/* ─── MODAL ────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 250;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  animation: fadeScale 0.2s ease-out;
}
.modal-box {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  width: min(400px, 90vw);
  box-shadow: var(--shadow-lg);
}
.modal-box-wide {
  width: min(480px, 90vw);
}
.modal-title {
  font-size: 20px; font-weight: 800; color: var(--text-header);
  margin-bottom: 4px;
}
.modal-subtitle {
  font-size: 13px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.4;
}
.modal-input {
  width: 100%; background: var(--bg-primary); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 10px 14px;
  color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none;
  transition: var(--norm); margin-bottom: 20px;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.modal-input::placeholder { color: var(--text-muted); }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
}
.modal-btn {
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: none; transition: var(--fast);
}
.modal-btn-cancel {
  background: var(--bg-elevated); color: var(--text-primary);
}
.modal-btn-cancel:hover { background: var(--bg-hover); }
.modal-btn-primary {
  background: var(--accent); color: #fff;
}
.modal-btn-primary:hover { background: var(--accent-hover); }
.modal-btn-primary:active { background: var(--accent-active); }
.modal-btn-danger {
  background: var(--red); color: #fff;
}
.modal-btn-danger:hover { background: #d32f2f; }

/* ─── SETTINGS MODAL ─────────────────────────── */
.settings-group {
  margin-bottom: 16px;
}
.settings-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--text-muted); margin-bottom: 8px;
}
.settings-colors {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.settings-color-swatch {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: var(--fast);
  display: flex; align-items: center; justify-content: center;
}
.settings-color-swatch:hover { transform: scale(1.15); }
.settings-color-swatch.selected {
  border-color: #fff; box-shadow: 0 0 0 2px var(--accent);
}
.settings-color-swatch .check {
  color: #fff; font-size: 14px; font-weight: 800;
  display: none; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.settings-color-swatch.selected .check { display: block; }
.settings-avatar-row { display: flex; align-items: center; gap: 12px; }
.settings-avatar-preview {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
  overflow: hidden; flex-shrink: 0;
}
.settings-avatar-img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }

/* ─── GUILD SERVER ICONS ──────────────────────── */
.guild-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--fast);
  background: var(--bg-dark); border: none; color: #fff;
  position: relative; font-size: 16px; font-weight: 800;
}
.guild-icon:hover { border-radius: 14px; background: var(--accent); color: #fff; transform: scale(1.05); }
.guild-icon.active { background: var(--accent); color: #fff; border-radius: 14px; }
.guild-icon.active::before {
  content: ''; position: absolute; left: -10px;
  width: 3px; height: 24px; background: #fff; border-radius: 2px;
}
.guild-icon.has-notifications::after {
  content: ''; position: absolute; bottom: -2px; right: -2px;
  width: 12px; height: 12px; background: var(--red);
  border-radius: 50%; border: 2px solid var(--bg-deepest);
}
.add-guild { background: var(--bg-dark); color: var(--green); }
.add-guild:hover { background: var(--green); color: #fff; border-radius: 14px; }
.join-guild-btn { background: var(--bg-dark); color: var(--text-muted); }
.join-guild-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-radius: 14px; }
.server-spacer { flex: 1; }
.ai-icon { background: var(--bg-dark); color: var(--text-muted); margin-top: 4px; }
.ai-icon:hover { border-radius: 14px; background: var(--accent); color: #fff; }

/* ─── GUILD CHANNEL SIDEBAR ──────────────────── */
.guild-channel-section {
  padding: 8px 0;
}
.guild-channel-header {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 16px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--text-muted); cursor: pointer;
  transition: var(--fast);
}
.guild-channel-header:hover { color: var(--text-primary); }
.guild-channel-header .arrow {
  font-size: 8px; transition: transform var(--fast);
}
.guild-channel-header .arrow.collapsed { transform: rotate(-90deg); }
.guild-channel-item {
  padding: 5px 10px 5px 26px; border-radius: var(--radius-xs);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary); transition: all var(--fast);
  margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: none;
}
.guild-channel-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.guild-channel-item.active { background: var(--bg-hover); color: #fff; }
.guild-channel-item .hash { opacity: 0.4; font-weight: 400; font-size: 15px; color: var(--text-muted); }
.guild-channel-add {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; margin-left: auto;
  border-radius: var(--radius-xs); transition: var(--fast);
  display: flex; align-items: center; justify-content: center;
}
.guild-channel-add:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ─── MEMBERS PANEL ─────────────────────────────── */
.members-panel {
  width: 240px; flex-shrink: 0;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.members-header {
  height: var(--chat-hdr); padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 15px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0; color: var(--text-header);
}
.members-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: var(--radius-xs);
  display: flex; transition: var(--fast);
}
.members-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.members-list {
  flex: 1; overflow-y: auto; padding: 8px;
}
.members-section-label {
  padding: 16px 8px 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted);
}
.members-item {
  padding: 6px 10px; border-radius: var(--radius-xs);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary); transition: var(--fast);
  margin-bottom: 1px;
}
.members-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.members-item .role-badge {
  font-size: 9px; font-weight: 700; padding: 1px 6px;
  border-radius: 3px; margin-left: auto; flex-shrink: 0;
}
.members-item .role-badge.owner { background: var(--accent); color: #fff; }
.members-item .role-badge.admin { background: #f39c12; color: #000; }
.members-item .role-badge.member { background: var(--bg-dark); color: var(--text-muted); }
.role-badge {
  font-size: 9px; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; flex-shrink: 0;
}
.role-badge.owner { background: var(--accent); color: #fff; }
.members-mini-list { max-height: 200px; overflow-y: auto; }

/* ─── GUILD HEADER (in channel sidebar) ─────── */
.guild-sidebar-header {
  height: var(--chat-hdr); padding: 0 16px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0; color: var(--text-header);
}
.guild-sidebar-name { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-sidebar-actions {
  display: flex; gap: 2px;
}
.guild-sidebar-action {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: var(--fast);
}
.guild-sidebar-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.guild-sidebar-action.danger:hover { color: var(--red); }

/* ─── REDUCED MOTION ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ─── TOAST NOTIFICATIONS ───────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; padding: 10px 16px; border-radius: var(--radius-xs);
  background: var(--bg-dark); color: var(--text-primary);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-elevated);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.25s ease-out;
  max-width: 360px;
}
.toast.error { border-left: 3px solid var(--red); }
.toast.success { border-left: 3px solid var(--green); }
.toast.info { border-left: 3px solid var(--accent); }
.toast-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 2px; margin-left: auto; flex-shrink: 0; display: flex;
}
.toast-close:hover { color: var(--text-primary); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
