/* === Termius-inspired Dark UI === */
:root {
  --bg-base: #0f1923;
  --bg-surface: #15202e;
  --bg-card: #1b2a3b;
  --bg-elevated: #243548;
  --bg-hover: #2a3d52;
  --bg-input: #1b2a3b;
  --accent: #36e8ac;
  --accent-hover: #2ed69e;
  --accent-glow: rgba(54, 232, 172, 0.15);
  --accent-soft: rgba(54, 232, 172, 0.1);
  --accent-2: #5ab4ff;
  --gradient: linear-gradient(135deg, #1a5276 0%, #0d4a3e 100%);
  --gradient-accent: linear-gradient(135deg, #3b9eff 0%, #36e8ac 100%);
  --green: #36e8ac;
  --green-soft: rgba(54, 232, 172, 0.12);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, 0.12);
  --yellow: #ffc857;
  --yellow-soft: rgba(255, 200, 87, 0.12);
  --text-primary: #f0f4f8;
  --text-secondary: #b0bec5;
  --text-muted: #7a8fa0;
  --border: #2a3a4e;
  --border-light: #223040;
  --sidebar-width: 300px;
  --header-height: 52px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --transition: 0.15s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.screen { display: none; height: 100vh; height: 100dvh; }
.screen.active { display: flex; }

/* === SVG Icons === */
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }
.icon-sm { width: 15px; height: 15px; }
.icon-send { width: 18px; height: 18px; fill: white; stroke: none; }

/* === Auth Screen === */
#auth-screen {
  justify-content: center;
  align-items: center;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(46, 230, 168, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(76, 164, 255, 0.05) 0%, transparent 50%);
}

.auth-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  display: block;
  margin: 0 auto 16px;
  width: 48px;
  height: 48px;
  color: var(--accent);
}

.auth-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-form h2 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
}

.form-group { margin-bottom: 14px; }

.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  background: var(--bg-input);
  color: var(--text-primary);
}

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

.form-group input::placeholder { color: #6a7e92; }

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--gradient-accent);
  color: white;
  width: 100%;
  padding: 12px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn-primary:hover:not(:disabled) { opacity: 0.9; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

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

/* === Chat Screen === */
#chat-screen { flex-direction: row; }

/* === Sidebar === */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
  overflow: hidden;
}

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

.sidebar-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

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

.room-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.room-item {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  position: relative;
}

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

.room-item.active {
  background: var(--accent-soft);
}

.room-item-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.room-item.active .room-item-icon { background: var(--gradient-accent); color: white; }

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

.room-item-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-item-last-msg {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  opacity: 0.7;
}

.room-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.room-item-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}

.room-item:hover .room-item-actions { display: flex; }
.room-item:hover .unread-badge { display: none; }

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

.room-action-btn:hover { background: var(--bg-elevated); color: var(--text-secondary); }
.room-action-delete:hover { background: var(--red-soft); color: var(--red); }

.unread-badge {
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  padding: 0 7px;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.user-info {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Chat Main === */
#chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-base);
}

#chat-header {
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#room-info { flex: 1; }
#room-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
#room-members-count { font-size: 12px; color: var(--text-muted); }

/* === Messages === */
#messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}

#messages-list { flex: 1; }

.message {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
  align-items: flex-end;
  max-width: 72%;
}

.message.message-mine {
  flex-direction: row-reverse;
  margin-left: auto;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  align-self: flex-start;
}

.message-mine .message-avatar { display: none; }

.message-body { min-width: 0; display: flex; flex-direction: column; }
.message-mine .message-body { align-items: flex-end; }

.message-author {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 11px;
  font-weight: 600;
  color: #5cb8ff;
  margin-bottom: 3px;
  margin-left: 4px;
}

.message-mine .message-author { display: none; }

.message-bubble {
  background: rgba(20, 35, 50, 0.8);
  border: 1px solid #1a3040;
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 10px 14px;
  word-wrap: break-word;
  max-width: 100%;
}

.message-mine .message-bubble {
  background: rgba(20, 40, 35, 0.85);
  border-color: #1a4035;
  border-radius: var(--radius) 4px var(--radius) var(--radius);
}

.message-content {
  font-family: 'SF Mono', 'Consolas', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #4aea8b;
}

.message-mine .message-content {
  color: #5cffb1;
}

.message-content a { color: #5cb8ff; text-decoration: underline; }

.message-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 0 4px;
}

.message-mine .message-footer { flex-direction: row-reverse; }

.message-time {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 10px;
  color: #5a7a6a;
  white-space: nowrap;
}
.message-read-status {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 10px;
  color: #4aea8b;
  white-space: nowrap;
}

.message-reply-ref {
  font-size: 12px;
  color: var(--text-secondary);
  border-left: 2px solid var(--accent);
  padding: 2px 8px;
  margin-bottom: 4px;
  background: var(--accent-soft);
  border-radius: 0 4px 4px 0;
  cursor: pointer;
}

.message-mine .message-reply-ref {
  color: rgba(255,255,255,0.8);
  border-left-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.1);
}

.message-actions { display: none; margin-top: 2px; }
.message:hover .message-actions { display: flex; }

.message-action-btn {
  font-size: 11px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 3px;
}

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

.message-bubble-deleted {
  background: transparent !important;
  border: 1px dashed var(--border) !important;
  opacity: 0.6;
}

.message-content-deleted {
  font-style: italic;
  color: #5a7a6a !important;
  font-size: 12px;
}

.message-file {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-top: 4px;
  font-size: 13px;
  transition: var(--transition);
}

.message-file:hover { background: var(--bg-hover); }
.message-mine .message-file { background: rgba(255,255,255,0.12); border-color: transparent; }

.message-file-icon { color: var(--accent); }
.message-file-info { min-width: 0; overflow: hidden; }
.message-file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-file-size { font-size: 11px; color: var(--text-muted); }

.message-image {
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  cursor: pointer;
}

.system-message {
  text-align: center;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  color: #5a7a6a;
  font-size: 11px;
  margin: 8px 0;
  padding: 3px 12px;
  background: rgba(20, 35, 50, 0.5);
  border-radius: var(--radius-full);
  display: inline-block;
  align-self: center;
}

.date-separator {
  text-align: center;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  color: #5a7a6a;
  font-size: 11px;
  margin: 16px auto 8px;
  background: rgba(20, 35, 50, 0.5);
  padding: 4px 16px;
  border-radius: var(--radius-full);
  display: inline-block;
  align-self: center;
}

.typing-indicator {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  color: #5a7a6a;
  padding: 4px 8px;
}

/* === Chat Input === */
#chat-input-area {
  padding: 12px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  border-left: 2px solid var(--accent);
}

.reply-preview span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

#message-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: var(--transition);
  resize: none;
  max-height: 120px;
  min-height: 38px;
  line-height: 1.4;
  overflow-y: auto;
}

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

#message-input::placeholder { color: #6a7e92; }

#send-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* === Members Panel === */
.panel {
  width: 260px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.panel-header h3 { font-size: 14px; font-weight: 700; }

.members-list { flex: 1; overflow-y: auto; padding: 8px; }

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

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

.member-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
}

.member-avatar .online-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

.member-name { font-size: 13px; font-weight: 600; }
.member-role { font-size: 11px; color: var(--text-muted); }

/* === Admin Screen === */
#admin-screen { flex-direction: column; overflow-y: auto; background: var(--bg-base); }

.admin-header {
  padding: 0 16px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header h2 { font-size: 15px; font-weight: 700; flex: 1; text-align: center; }

.admin-content { padding: 0; max-width: 600px; margin: 0 auto; width: 100%; }

.admin-section { margin-bottom: 0; }

.admin-section h3 {
  padding: 20px 20px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 8px;
}

.admin-section-header h3 { padding: 0; }

.stats-cards {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stat-card {
  flex: 1;
  padding: 18px 12px;
  text-align: center;
  background: var(--bg-surface);
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* Admin cards */
.admin-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
}

.admin-card:first-child { border-top: 1px solid var(--border); }
.admin-card:last-child { border-bottom: 1px solid var(--border); }

.admin-card-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.admin-card-avatar-room { color: var(--accent); }

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

.admin-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.admin-role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
}

.admin-role-admin { background: var(--accent-soft); color: var(--accent); }

.admin-status { font-size: 11px; font-weight: 600; }
.admin-status-active { color: var(--green); }
.admin-status-inactive { color: var(--red); }

.admin-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

.admin-table { background: var(--bg-surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); overflow-x: auto; }
.admin-table table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.admin-table th { font-weight: 600; font-size: 12px; color: var(--text-muted); background: var(--bg-card); }

.btn-sm {
  padding: 5px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}

.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: rgba(248, 81, 73, 0.2); }
.btn-success { background: var(--green-soft); color: var(--green); }
.btn-success:hover { background: rgba(63, 185, 80, 0.2); }
.btn-warning { background: var(--yellow-soft); color: var(--yellow); }
.btn-outline { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-hover); }

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  overflow: hidden;
}

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

.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px; }

.modal-body .form-group { margin-bottom: 14px; }
.modal-body .form-group label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.modal-body .form-group input,
.modal-body .form-group textarea,
.modal-body .form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: var(--transition);
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

.modal-body .btn { margin-top: 8px; }

/* === Dropdown === */
.dropdown-menu {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 100;
  min-width: 160px;
  overflow: hidden;
  padding: 4px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-primary);
  border-radius: 6px;
  transition: var(--transition);
}

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

/* === Mobile === */
.mobile-only { display: none; }

@media (max-width: 768px) {
  .mobile-only { display: flex; }

  #sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: left 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }

  #sidebar.open { left: 0; }

  .panel {
    position: fixed;
    right: -100%;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: right 0.25s ease;
  }

  .panel.open { right: 0; }

  #sidebar { width: 85%; max-width: 320px; }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Invite / Add Member === */
.invite-member-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 4px 0 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
  border: 1px dashed var(--border);
  background: transparent;
}

.invite-member-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.invite-user-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

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

.invite-user-item:last-child {
  border-bottom: none;
}

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

.invite-user-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: var(--transition);
}

.invite-user-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.invite-user-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.invite-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

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

.invite-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.invite-user-username {
  font-size: 11px;
  color: var(--text-muted);
}

.loading { display: flex; justify-content: center; padding: 20px; }

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* === Search Bar === */
.search-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  flex-shrink: 0;
  animation: searchSlideIn 0.15s ease;
}

@keyframes searchSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  transition: var(--transition);
}

.search-bar-inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-bar-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  padding: 8px 0;
}

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

/* === Search Results === */
.search-results-list {
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
  border-radius: var(--radius-sm);
}

.search-result-item:last-child {
  border-bottom: none;
}

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

.search-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.search-result-author {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #5cb8ff;
}

.search-result-time {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.search-result-content {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-highlight {
  background: rgba(255, 200, 87, 0.25);
  color: var(--yellow);
  border-radius: 2px;
  padding: 0 1px;
}

#messages-list:empty::after {
  content: '> awaiting messages_';
  display: block;
  text-align: center;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  color: #3a5a4a;
  font-size: 13px;
  padding: 60px 20px;
}

/* === Avatar Images === */
.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

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

/* === Sidebar Avatar === */
.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  transition: var(--transition);
}

.sidebar-avatar:hover {
  opacity: 0.8;
  box-shadow: 0 0 0 2px var(--accent);
}

.sidebar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* === Profile Edit Modal === */
.profile-edit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.profile-avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid var(--border);
}

.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-avatar-initial {
  font-size: 28px;
  font-weight: 700;
}

.profile-avatar-change-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
