/* ══════════════════════════════════════════════════════════════════════
   Kasit Messenger — WhatsApp Clone Stylesheet
   Full-featured dark theme messenger with WhatsApp-accurate design
   ══════════════════════════════════════════════════════════════════════ */

/* ── Reset & Variables ────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* WhatsApp-accurate dark palette */
  --bg-primary: #111b21;
  --bg-secondary: #202c33;
  --bg-hover: #2a3942;
  --bg-active: #2a3942;
  --bg-chat: #0b141a;
  --bg-input: #2a3942;
  --bg-bubble-out: #005c4b;
  --bg-bubble-in: #202c33;
  --bg-header: #202c33;
  --bg-panel: #111b21;
  --border: #2a3942;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --text-bubble: #e9edef;
  --accent: #00a884;
  --accent-hover: #06cf9c;
  --accent-light: rgba(0, 168, 132, 0.15);
  --blue-check: #53bdeb;
  --danger: #ea0038;
  --shadow: rgba(0,0,0,0.3);
  --radius: 8px;
  --sidebar-width: 400px;
  --header-height: 60px;
  --input-height: 62px;
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* ── App Layout ───────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Icon Button ──────────────────────────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.hidden { display: none !important; }

/* ════════════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-width: 340px;
  max-width: 500px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.sidebar-header {
  height: var(--header-height);
  background: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}
.sidebar-header .user-avatar { cursor: pointer; }
.sidebar-header .user-avatar img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.sidebar-actions { display: flex; gap: 4px; }

/* Search */
.search-bar {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
}
.search-bar svg { color: var(--text-secondary); flex-shrink: 0; }
.search-bar input {
  flex: 1;
  background: var(--bg-input);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 14px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }

.chat-item .avatar {
  width: 49px; height: 49px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-item-info {
  flex: 1;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.chat-item:last-child .chat-item-info { border-bottom: none; }

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.chat-item-name {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-time {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 8px;
}
.chat-item-time.unread { color: var(--accent); }

.chat-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}
.chat-item-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.chat-item-preview .checks {
  color: var(--blue-check);
  margin-right: 3px;
}

.unread-badge {
  background: var(--accent);
  color: #111b21;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
  margin-left: 8px;
}

/* ════════════════════════════════════════════════════════════════════
   MAIN CHAT AREA
   ════════════════════════════════════════════════════════════════════ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  background: var(--bg-chat);
  border-bottom: 6px solid var(--accent);
}
.empty-state .empty-icon { margin-bottom: 28px; opacity: 0.5; }
.empty-state h2 { font-size: 32px; font-weight: 300; color: var(--text-primary); margin-bottom: 12px; }
.empty-state p { font-size: 14px; color: var(--text-secondary); max-width: 500px; }

/* Active Chat */
.active-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
}

/* Chat Header */
.chat-header {
  height: var(--header-height);
  background: var(--bg-header);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}
.back-btn { display: none; }
.chat-header-avatar img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
}
.chat-header-info { flex: 1; min-width: 0; cursor: pointer; }
.chat-header-info h3 {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-text { font-size: 12px; color: var(--text-secondary); }
.status-text.online { color: var(--accent); }
.chat-header-actions { display: flex; gap: 2px; }

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 40px 8px 60px;
  display: flex;
  flex-direction: column;
  /* WhatsApp wallpaper pattern */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath d='M30 5 L35 15 L30 12 L25 15 Z' fill='%23ffffff' opacity='0.02'/%3E%3Ccircle cx='10' cy='40' r='2' fill='%23ffffff' opacity='0.015'/%3E%3Ccircle cx='50' cy='45' r='1.5' fill='%23ffffff' opacity='0.015'/%3E%3C/svg%3E");
}

.messages { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; padding-top: 48px; }

/* Date Label */
.date-label {
  text-align: center;
  margin: 12px 0;
}
.date-label span {
  background: #182229;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 8px;
  display: inline-block;
}

/* Message Bubble */
.message {
  max-width: 65%;
  padding: 6px 7px 8px 9px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
  animation: msgIn 0.15s ease-out;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.sent {
  align-self: flex-end;
  background: var(--bg-bubble-out);
  border-top-right-radius: 0;
}
.message.received {
  align-self: flex-start;
  background: var(--bg-bubble-in);
  border-top-left-radius: 0;
}

.message-text {
  color: var(--text-bubble);
  font-size: 14.2px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 1px;
  float: right;
  margin-left: 12px;
  position: relative;
  top: 5px;
}
.message-time {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
}
.message-checks {
  font-size: 14px;
  line-height: 1;
}
.message-checks.read { color: var(--blue-check); }
.message-checks.delivered { color: rgba(255,255,255,0.45); }

/* Message with image */
.message-image {
  border-radius: 6px;
  max-width: 330px;
  width: 100%;
  margin-bottom: 4px;
  cursor: pointer;
}

/* Replied message */
.message-reply {
  background: rgba(0,0,0,0.15);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 12px;
  cursor: pointer;
}
.message-reply .reply-name { color: var(--accent); font-weight: 500; }
.message-reply .reply-text { color: var(--text-secondary); }

/* Audio message */
.message-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}
.audio-play-btn {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--text-primary);
}
.audio-waveform {
  flex: 1;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.audio-waveform span {
  width: 3px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: height 0.1s;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-items: center;
}
.typing-indicator span {
  width: 8px; height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Message Input ────────────────────────────────────────────────── */
.message-input-area {
  min-height: var(--input-height);
  background: var(--bg-header);
  display: flex;
  align-items: flex-end;
  padding: 5px 10px;
  gap: 4px;
  flex-shrink: 0;
}
.input-wrapper {
  flex: 1;
  position: relative;
}
.input-wrapper textarea {
  width: 100%;
  background: var(--bg-input);
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  resize: none;
  overflow-y: auto;
  max-height: 120px;
  min-height: 38px;
  line-height: 1.4;
  box-sizing: border-box;
  display: block;
}
.input-wrapper textarea:focus { outline: none; }
.input-wrapper textarea::placeholder { color: var(--text-muted); }
/* Legacy fallback for any remaining input */
.input-wrapper input {
  width: 100%;
  background: var(--bg-input);
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
}
.input-wrapper input:focus { outline: none; }
.input-wrapper input::placeholder { color: var(--text-muted); }

.send-btn { color: var(--text-secondary); }
.send-btn.active { color: var(--accent); }
.mic-btn { color: var(--text-secondary); }

/* ════════════════════════════════════════════════════════════════════
   EMOJI PICKER
   ════════════════════════════════════════════════════════════════════ */
.emoji-picker {
  position: fixed;
  bottom: var(--input-height);
  left: var(--sidebar-width);
  width: 350px;
  height: 320px;
  background: var(--bg-header);
  border-radius: 12px 12px 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -2px 12px var(--shadow);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.emoji-search {
  padding: 10px;
}
.emoji-search input {
  width: 100%;
  background: var(--bg-input);
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font);
  outline: none;
}
.emoji-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 4px 10px;
}
.emoji-grid .emoji-item {
  font-size: 24px;
  text-align: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}
.emoji-grid .emoji-item:hover { background: var(--bg-hover); }

/* ════════════════════════════════════════════════════════════════════
   ATTACHMENT MENU
   ════════════════════════════════════════════════════════════════════ */
.attach-menu {
  position: fixed;
  bottom: calc(var(--input-height) + 8px);
  left: calc(var(--sidebar-width) + 50px);
  background: var(--bg-header);
  border-radius: 12px;
  padding: 8px 0;
  z-index: 20;
  min-width: 200px;
  box-shadow: 0 4px 16px var(--shadow);
  animation: slideUp 0.15s ease;
}
.attach-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition);
}
.attach-option:hover { background: var(--bg-hover); }
.attach-icon { font-size: 20px; }

/* ════════════════════════════════════════════════════════════════════
   PANELS (Status, Profile, New Chat)
   ════════════════════════════════════════════════════════════════════ */
.status-panel,
.profile-panel,
.new-chat-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-panel);
  z-index: 10;
  display: flex;
  flex-direction: column;
  animation: panelSlide 0.25s ease;
}
@keyframes panelSlide {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.status-header,
.profile-header-bg,
.new-chat-header {
  height: 110px;
  background: var(--bg-header);
  display: flex;
  align-items: flex-end;
  padding: 0 20px 16px;
  gap: 20px;
  flex-shrink: 0;
}
.status-header h3,
.profile-header-bg h3,
.new-chat-header h3 {
  font-size: 19px;
  font-weight: 500;
}

/* Status Panel */
.status-content { flex: 1; overflow-y: auto; }
.my-status {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; cursor: pointer;
}
.my-status:hover { background: var(--bg-hover); }
.status-avatar { position: relative; }
.status-avatar img { width: 50px; height: 50px; border-radius: 50%; }
.status-avatar .add-icon {
  position: absolute; bottom: 0; right: 0;
  background: var(--accent); color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.status-info h4 { font-size: 16px; }
.status-info p { font-size: 13px; color: var(--text-secondary); }
.status-section-label {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-item {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px; cursor: pointer;
}
.status-item:hover { background: var(--bg-hover); }
.status-ring {
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  padding: 2px;
}
.status-ring img { width: 100%; height: 100%; border-radius: 50%; }
.status-ring.viewed { border-color: var(--text-muted); }

/* Profile Panel */
.profile-content { flex: 1; overflow-y: auto; padding: 20px 0; }
.profile-avatar-large {
  display: flex; justify-content: center; padding: 20px;
}
.profile-avatar-large img {
  width: 200px; height: 200px;
  border-radius: 50%;
}
.profile-field {
  padding: 14px 30px;
  border-bottom: 1px solid var(--border);
}
.profile-field label {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 4px;
  display: block;
}
.profile-field .field-value {
  font-size: 16px;
  color: var(--text-primary);
  outline: none;
  padding: 4px 0;
}

/* New Chat Panel */
.new-chat-search { padding: 8px 12px; }
.new-chat-search input {
  width: 100%;
  background: var(--bg-input);
  border: none; border-radius: 8px;
  padding: 8px 12px; color: var(--text-primary);
  font-family: var(--font); outline: none;
}
.new-chat-options { padding: 8px 0; }
.new-option {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; cursor: pointer; font-size: 16px;
}
.new-option:hover { background: var(--bg-hover); }
.new-option span { font-size: 22px; }

.contacts-list { flex: 1; overflow-y: auto; }
.contact-item {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px; cursor: pointer;
}
.contact-item:hover { background: var(--bg-hover); }
.contact-item img { width: 45px; height: 45px; border-radius: 50%; }
.contact-item-info h4 { font-size: 16px; font-weight: 400; }
.contact-item-info p { font-size: 13px; color: var(--text-secondary); }

/* ════════════════════════════════════════════════════════════════════
   CONTEXT MENU
   ════════════════════════════════════════════════════════════════════ */
.context-menu {
  position: fixed;
  background: var(--bg-header);
  border-radius: 8px;
  padding: 6px 0;
  z-index: 100;
  min-width: 180px;
  box-shadow: 0 4px 20px var(--shadow);
}
.ctx-item {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition);
}
.ctx-item:hover { background: var(--bg-hover); }

/* ════════════════════════════════════════════════════════════════════
   CALL OVERLAY
   ════════════════════════════════════════════════════════════════════ */
.call-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-card {
  text-align: center;
  animation: callIn 0.3s ease;
}
@keyframes callIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.call-card img {
  width: 120px; height: 120px;
  border-radius: 50%;
  margin-bottom: 20px;
}
.call-card h2 { font-size: 28px; font-weight: 400; margin-bottom: 8px; }
.call-card p { color: var(--text-secondary); margin-bottom: 40px; }
.call-timer { font-size: 18px; color: var(--accent); margin-bottom: 30px; }
.call-actions { display: flex; gap: 30px; justify-content: center; }
.call-action-btn {
  width: 56px; height: 56px;
  border-radius: 50%; border: none;
  font-size: 24px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.call-action-btn:hover { transform: scale(1.1); }
.call-action-btn.mute { background: var(--bg-hover); }
.call-action-btn.end { background: var(--danger); }
.call-action-btn.speaker { background: var(--bg-hover); }

/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { width: 100%; max-width: 100%; }
  .chat-area { position: absolute; inset: 0; z-index: 5; transform: translateX(100%); transition: transform 0.25s ease; }
  .chat-area.active { transform: translateX(0); }
  .back-btn { display: flex; }
  .messages-container { padding: 8px 12px; }
  .emoji-picker { left: 0; width: 100%; bottom: 0; max-height: 50vh; }
  .attach-menu { left: 10px; }
  .status-panel, .profile-panel, .new-chat-panel { width: 100%; }
  /* Mobile: Make all overlays fullscreen */
  .channel-view, .active-chat { height: 100%; }
  .create-popup { width: 100%; max-width: 100%; border-radius: 0; max-height: 100vh; height: 100%; }
  .create-popup-overlay { align-items: stretch; }
  .channel-info-panel, .channel-members-mgmt { width: 100% !important; }
  .user-profile-panel { width: 100% !important; }
  .chat-header-info h3 { font-size: 15px; }
  .chat-header-actions { gap: 0; }
  #channelBackBtn, #groupBackBtn { display: flex !important; }
  /* Comments panel full width */
  .comments-panel { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; }
}

@media (max-width: 480px) {
  .message { max-width: 88%; }
  .chat-header-actions .icon-btn:nth-child(3),
  .chat-header-actions .icon-btn:nth-child(4) { display: none; }
  .messages-container { padding: 8px 8px; }
  .message-input-area { padding: 6px 8px; }
  .create-slide { padding: 24px 16px 16px; }
  .ch-avatar-section { flex-direction: column; align-items: center; }
}

/* ── Unread separation line ───────────────────────────────────────── */
.unread-divider {
  text-align: center;
  margin: 12px 0;
}
.unread-divider span {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
}

/* ── Group: sender name in bubble ─────────────────────────────────── */
.message-sender {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 2px;
}

/* ── Link preview ─────────────────────────────────────────────────── */
.link-preview {
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
  cursor: pointer;
}
.link-preview img { width: 100%; height: 130px; object-fit: cover; }
.link-preview-text { padding: 8px; }
.link-preview-text h5 { font-size: 13px; margin-bottom: 2px; }
.link-preview-text p { font-size: 12px; color: var(--text-secondary); }

/* ── Photo grid in message ────────────────────────────────────────── */
.photo-grid {
  display: grid; gap: 3px; border-radius: 6px; overflow: hidden;
  margin-bottom: 4px;
}
.photo-grid.g2 { grid-template-columns: 1fr 1fr; }
.photo-grid.g3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.photo-grid.g3 img:first-child { grid-row: span 2; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }

/* ── Reactions ────────────────────────────────────────────────────── */
.message-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.reaction {
  background: var(--bg-hover);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 14px;
  cursor: pointer;
}
.reaction:hover { background: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════════════════════════════════════ */
.auth-screen {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.auth-container {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 420px; max-width: 95vw;
  padding: 40px 36px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 26px; font-weight: 600; color: var(--text-primary); }
.auth-logo h1 span { color: var(--accent); }
.auth-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

.auth-form h2 { font-size: 20px; font-weight: 600; margin-bottom: 20px; text-align: center; }

.auth-tabs { display: flex; gap: 0; margin-bottom: 20px; border-radius: 8px; overflow: hidden; background: var(--bg-primary); }
.auth-tab {
  flex: 1; padding: 10px; text-align: center;
  background: transparent; border: none;
  color: var(--text-secondary); cursor: pointer;
  font-family: var(--font); font-size: 14px;
  transition: all var(--transition);
}
.auth-tab.active { background: var(--accent); color: #fff; }

.auth-group { margin-bottom: 16px; }
.auth-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.auth-group input[type="text"],
.auth-group input[type="email"],
.auth-group input[type="password"],
.auth-group input[type="tel"] {
  width: 100%; padding: 12px 14px;
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-family: var(--font); font-size: 14px;
  outline: none; transition: border var(--transition);
}
.auth-group input:focus { border-color: var(--accent); }

.pw-field { position: relative; }
.toggle-pw {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-secondary);
}

.phone-input { display: flex; gap: 8px; }
.phone-input select {
  width: 90px; padding: 12px 8px;
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-family: var(--font); font-size: 14px; outline: none;
}
.phone-input input { flex: 1; }

.password-strength { margin-top: 6px; }
.pw-bar { height: 4px; width: 0; border-radius: 2px; transition: width 0.3s, background 0.3s; background: #333; }

.auth-options { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-size: 13px; }
.auth-options label { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; }
.auth-options a { color: var(--accent); text-decoration: none; }
.auth-options a:hover { text-decoration: underline; }

.auth-btn {
  width: 100%; padding: 12px;
  background: var(--accent); border: none; border-radius: 8px;
  color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: var(--font);
  transition: background var(--transition);
}
.auth-btn:hover { background: var(--accent-hover); }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0; color: var(--text-secondary); font-size: 13px;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.social-btns { display: flex; gap: 12px; }
.social-btn {
  flex: 1; padding: 10px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-primary); cursor: pointer; font-family: var(--font); font-size: 13px;
  transition: background var(--transition);
}
.social-btn:hover { background: var(--bg-hover); }

.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-secondary); }
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-secondary); }
.auth-switch a { color: var(--accent); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"],
.auth-field input[type="tel"] {
  width: 100%; padding: 12px 14px;
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-family: var(--font); font-size: 14px;
  outline: none; transition: border var(--transition);
}
.auth-field input:focus { border-color: var(--accent); }

.auth-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-size: 13px; }
.auth-row label { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; }
.auth-link { color: var(--accent); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }

.auth-social { display: flex; gap: 12px; }
.auth-title { font-size: 26px; font-weight: 600; text-align: center; color: var(--text-primary); }
.auth-title span { color: var(--accent); }
.auth-subtitle { text-align: center; color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; }

.password-wrapper { position: relative; }
.password-wrapper input { width: 100%; padding-right: 42px; }

.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; margin-bottom: 8px; }
.checkbox-label a { color: var(--accent); text-decoration: none; }

.otp-info { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 8px; }

.settings-profile { display: flex; align-items: center; gap: 16px; padding: 16px 20px; cursor: pointer; transition: background var(--transition); }
.settings-profile:hover { background: var(--bg-hover); }
.settings-profile img { width: 56px; height: 56px; border-radius: 50%; }
.settings-profile h4 { font-size: 16px; font-weight: 500; }
.settings-profile p { font-size: 13px; color: var(--text-secondary); }

.settings-group { border-bottom: 1px solid var(--border); padding: 8px 0; }
.settings-item-info h4 { font-size: 15px; font-weight: 400; }
.settings-item-info p { font-size: 13px; color: var(--text-secondary); }
.settings-item.danger .settings-item-info h4 { color: var(--danger); }

.settings-action-btn {
  display: block; width: 100%; margin-top: 12px;
  padding: 10px; background: var(--bg-input); border: 1px dashed var(--border);
  border-radius: 8px; color: var(--text-secondary);
  cursor: pointer; font-family: var(--font); text-align: center;
}
.settings-action-btn:hover { border-color: var(--accent); color: var(--accent); }

.settings-content { padding: 0; }

.admin-search { display: flex; gap: 12px; margin-bottom: 16px; padding: 16px 0 0; flex-wrap: wrap; }
.admin-search input,
.admin-search select {
  padding: 10px 14px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary); font-family: var(--font);
  font-size: 14px; outline: none; flex: 1;
}
.admin-search input:focus,
.admin-search select:focus { border-color: var(--accent); }
.admin-table-wrap { overflow-x: auto; }

.profile-avatar-large { text-align: center; padding: 24px 0; position: relative; display: inline-block; width: 100%; }
.profile-avatar-large img { width: 120px; height: 120px; border-radius: 50%; }
.avatar-edit-btn { position: absolute; bottom: 24px; right: calc(50% - 70px); background: var(--accent); border: none; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 16px; }

.profile-field { padding: 16px 24px; border-bottom: 1px solid var(--border); }
.profile-field label { font-size: 12px; color: var(--accent); margin-bottom: 4px; display: block; }
.field-value { font-size: 16px; padding: 4px 0; outline: none; }

.terms-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.terms-label a { color: var(--accent); text-decoration: none; }

/* OTP */
.otp-inputs { display: flex; gap: 10px; justify-content: center; margin: 24px 0; }
.otp-digit {
  width: 48px; height: 56px; text-align: center;
  font-size: 22px; font-weight: 600;
  background: var(--bg-primary); border: 2px solid var(--border);
  border-radius: 10px; color: var(--text-primary);
  font-family: var(--font); outline: none;
  transition: border-color var(--transition);
}
.otp-digit:focus { border-color: var(--accent); }

.otp-footer { text-align: center; margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.otp-footer a { color: var(--accent); text-decoration: none; cursor: pointer; }

/* ══════════════════════════════════════════════════════════════════════
   SIDEBAR DROPDOWN
   ══════════════════════════════════════════════════════════════════════ */
.sidebar-dropdown {
  position: absolute; top: 52px; right: 12px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 6px; z-index: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  min-width: 200px; overflow: hidden;
}
.dd-item {
  padding: 12px 20px; cursor: pointer;
  color: var(--text-primary); font-size: 14px;
  transition: background var(--transition);
}
.dd-item:hover { background: var(--bg-hover); }
.dd-item.logout { color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════════
   SETTINGS PANEL
   ══════════════════════════════════════════════════════════════════════ */
.settings-panel {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--bg-panel);
  z-index: 200; overflow-y: auto;
  border-right: 1px solid var(--border);
}
.settings-header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--bg-header);
  height: var(--header-height);
  position: sticky; top: 0; z-index: 1;
}
.settings-header h3 { font-size: 18px; font-weight: 500; }

.settings-profile-card {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; cursor: pointer;
  transition: background var(--transition);
}
.settings-profile-card:hover { background: var(--bg-hover); }
.settings-profile-card img { width: 56px; height: 56px; border-radius: 50%; }
.settings-profile-card .settings-profile-info h4 { font-size: 16px; font-weight: 500; }
.settings-profile-card .settings-profile-info p { font-size: 13px; color: var(--text-secondary); }

.settings-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; cursor: pointer;
  transition: background var(--transition);
}
.settings-item:hover { background: var(--bg-hover); }
.settings-item .settings-icon { font-size: 20px; width: 32px; text-align: center; color: var(--text-secondary); }
.settings-item .settings-label h4 { font-size: 15px; font-weight: 400; }
.settings-item .settings-label p { font-size: 13px; color: var(--text-secondary); }

/* Settings Sub-panels */
.settings-sub {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--bg-panel);
  z-index: 210; overflow-y: auto;
  border-right: 1px solid var(--border);
}
.settings-sub-header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--bg-header);
  height: var(--header-height);
  position: sticky; top: 0; z-index: 1;
}
.settings-sub-header h3 { font-size: 18px; font-weight: 500; }
.settings-sub-content { padding: 16px 20px; }

.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.settings-row label { font-size: 15px; color: var(--text-primary); }
.settings-row p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.settings-select {
  padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-primary); font-family: var(--font); font-size: 13px;
  outline: none;
}

.settings-link-btn {
  background: none; border: none;
  color: var(--accent); cursor: pointer;
  font-family: var(--font); font-size: 14px;
  padding: 8px 0;
}
.settings-link-btn:hover { text-decoration: underline; }
.settings-link-btn.danger { color: var(--danger); }

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--bg-hover); border-radius: 24px;
  transition: background var(--transition);
}
.slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; left: 3px; bottom: 3px;
  background: var(--text-secondary); border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: #fff; }

/* Blocked List */
.blocked-list { margin-top: 12px; }
.blocked-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.blocked-item img { width: 40px; height: 40px; border-radius: 50%; }
.blocked-item span { flex: 1; font-size: 14px; }
.unblock-btn {
  padding: 6px 12px; background: none; border: 1px solid var(--accent);
  color: var(--accent); border-radius: 6px; cursor: pointer;
  font-family: var(--font); font-size: 12px;
}
.unblock-btn:hover { background: var(--accent); color: #fff; }

.add-blocked-btn {
  display: block; width: 100%; margin-top: 12px;
  padding: 10px; background: var(--bg-input); border: 1px dashed var(--border);
  border-radius: 8px; color: var(--text-secondary);
  cursor: pointer; font-family: var(--font); text-align: center;
}
.add-blocked-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════════════════════════════════ */
.admin-panel {
  position: absolute; left: 0; top: 0; bottom: 0; right: 0;
  background: var(--bg-primary);
  z-index: 300; overflow-y: auto;
  display: flex; flex-direction: column;
}
.admin-header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--bg-header);
  height: var(--header-height);
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--border);
}
.admin-header h3 { font-size: 18px; font-weight: 500; }
.admin-content { flex: 1; overflow-y: auto; }

/* Stats Bar */
.admin-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; padding: 20px 24px;
}
.stat-card {
  background: var(--bg-secondary); border-radius: 10px;
  padding: 20px; text-align: center;
  border: 1px solid var(--border);
}
.stat-card .stat-value,
.stat-card .stat-num {
  font-size: 32px; font-weight: 700; color: var(--accent);
  line-height: 1.2;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Admin Tabs */
.admin-tabs {
  display: flex; gap: 0; padding: 0 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.admin-tab {
  padding: 12px 20px; cursor: pointer;
  color: var(--text-secondary); font-size: 14px;
  border-bottom: 2px solid transparent;
  white-space: nowrap; transition: all var(--transition);
  background: none; border-top: none; border-left: none; border-right: none;
  font-family: var(--font);
}
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-tab:hover { color: var(--text-primary); }

.admin-tab-content { display: none; padding: 20px 24px; }
.admin-tab-content.active { display: block; }

/* Admin Search/Filter Bar */
.admin-search-bar {
  display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.admin-search-bar input,
.admin-search-bar select {
  padding: 10px 14px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary); font-family: var(--font);
  font-size: 14px; outline: none;
}
.admin-search-bar input { flex: 1; min-width: 200px; }
.admin-search-bar input:focus,
.admin-search-bar select:focus { border-color: var(--accent); }

/* Admin Table */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left; padding: 12px 16px; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-secondary); background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.admin-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px; vertical-align: middle;
}
.admin-table tr:hover { background: var(--bg-hover); }
.admin-table tr.row-blocked { opacity: 0.5; }

.admin-user-cell { display: flex; align-items: center; gap: 10px; }
.admin-user-cell img { width: 36px; height: 36px; border-radius: 50%; }

.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); margin-right: 6px;
}
.status-dot.online { background: var(--accent); }

.role-select {
  padding: 4px 8px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-primary); font-family: var(--font); font-size: 13px;
}

.admin-actions { display: flex; gap: 4px; }
.admin-action-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; padding: 4px 6px; border-radius: 4px;
  transition: background var(--transition);
}
.admin-action-btn:hover { background: var(--bg-hover); }

/* Admin Messages List */
.admin-messages-list { max-height: 500px; overflow-y: auto; }
.admin-msg-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.admin-msg-item img { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.admin-msg-info { flex: 1; min-width: 0; }
.admin-msg-header { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.admin-msg-header strong { color: var(--text-primary); }
.admin-msg-time { float: right; font-size: 12px; }
.admin-msg-text { font-size: 14px; color: var(--text-primary); word-break: break-word; }
.admin-msg-actions { display: flex; gap: 4px; flex-shrink: 0; }
.admin-msg-item.flagged { border-left: 3px solid var(--danger); padding-left: 12px; }

.admin-empty { text-align: center; padding: 40px; color: var(--text-secondary); font-size: 15px; }

/* Reports */
.report-item {
  background: var(--bg-secondary); border-radius: 8px;
  padding: 16px; margin-bottom: 12px;
  border: 1px solid var(--border);
}
.report-item.resolved { opacity: 0.6; }
.report-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.report-badge {
  padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; text-transform: uppercase;
}
.report-badge.pending { background: rgba(243,156,18,0.2); color: #f39c12; }
.report-badge.resolved { background: rgba(0,168,132,0.2); color: var(--accent); }
.report-time { font-size: 12px; color: var(--text-secondary); }
.report-body { font-size: 14px; margin-bottom: 12px; }
.report-body p { color: var(--text-secondary); margin-top: 4px; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report-btn {
  padding: 6px 16px; border-radius: 6px; border: none;
  cursor: pointer; font-family: var(--font); font-size: 13px;
  transition: opacity var(--transition);
}
.report-btn:hover { opacity: 0.8; }
.report-btn.resolve { background: var(--accent); color: #fff; }
.report-btn.block-user { background: var(--danger); color: #fff; }
.report-btn.dismiss { background: var(--bg-hover); color: var(--text-primary); }

/* Broadcast */
.broadcast-form { max-width: 600px; }
.broadcast-form textarea {
  width: 100%; padding: 12px 14px; min-height: 100px; resize: vertical;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-family: var(--font); font-size: 14px; outline: none;
}
.broadcast-form textarea:focus { border-color: var(--accent); }
.broadcast-options { display: flex; gap: 20px; margin: 12px 0; }
.broadcast-options label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--text-secondary); cursor: pointer;
}
.broadcast-send-btn {
  padding: 10px 28px; background: var(--accent); border: none; border-radius: 8px;
  color: #fff; cursor: pointer; font-family: var(--font); font-size: 14px; font-weight: 600;
}
.broadcast-send-btn:hover { background: var(--accent-hover); }

.broadcast-history { margin-top: 24px; }
.broadcast-history h4 { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }
.broadcast-history-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.broadcast-time { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }

/* Activity Logs */
.log-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.log-time { color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; min-width: 50px; }
.log-text { color: var(--text-primary); }

/* ══════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 10000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: 8px;
  color: #fff; font-size: 14px; font-family: var(--font);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3s forwards;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  max-width: 360px;
}
.toast-success { background: var(--accent); }
.toast-error { background: var(--danger); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(10px); } }

/* ══════════════════════════════════════════════════════════════════════
   BROADCAST & PIN TAGS IN MESSAGES
   ══════════════════════════════════════════════════════════════════════ */
.broadcast-tag, .pin-tag {
  font-size: 11px; color: var(--text-secondary);
  margin-top: 4px; font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE — smaller screens
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-panel { position: fixed; }
  .settings-panel, .settings-sub { width: 100vw; }
  .auth-container { padding: 24px 20px; }
}

/* ══════════════════════════════════════════════════════════════════════
   FILTER TABS (sidebar)
   ══════════════════════════════════════════════════════════════════════ */
.chat-filter-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 12px 8px;
  background: var(--bg-panel);
  flex-shrink: 0;
}
.filter-tab {
  background: var(--bg-input);
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font);
  padding: 5px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 500;
}
.filter-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-tab.active {
  background: var(--accent);
  color: #111b21;
}

/* Chat Section Label */
.chat-section-label {
  padding: 10px 20px 6px;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

/* Saved Messages Sidebar Item */
.saved-messages-item .saved-avatar {
  width: 49px; height: 49px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

/* Channel sidebar items */
.channel-sidebar-item .chat-item-name svg {
  opacity: 0.5;
}

/* ══════════════════════════════════════════════════════════════════════
   SAVED MESSAGES PANEL (Self-Chat)
   ══════════════════════════════════════════════════════════════════════ */
.saved-panel {
  position: absolute; top: 0; left: var(--sidebar-width); right: 0;
  bottom: 0; height: 100%;
  background: var(--bg-chat); z-index: 25;
  display: flex; flex-direction: column;
}
.saved-panel .chat-header {
  background: var(--bg-header);
}
.saved-panel .messages-container {
  flex: 1; overflow-y: auto;
  background: var(--bg-chat);
}
.saved-panel .messages {
  padding: 12px 60px;
  display: flex;
  flex-direction: column;
}
.saved-panel .message-input-area {
  background: var(--bg-secondary);
}

/* ══════════════════════════════════════════════════════════════════════
   CHANNELS PANEL
   ══════════════════════════════════════════════════════════════════════ */
.channels-panel {
  position: absolute; top: 0; left: 0;
  width: var(--sidebar-width); height: 100%;
  background: var(--bg-primary); z-index: 25;
  display: flex; flex-direction: column;
}
.channels-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--bg-header);
  height: var(--header-height); border-right: 1px solid var(--border);
}
.channels-header h3 { font-size: 18px; font-weight: 500; }
.channels-list { flex: 1; overflow-y: auto; }
.channel-section-label {
  padding: 10px 20px 6px;
  font-size: 13px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.channel-item { cursor: pointer; }
.channel-join-badge {
  font-size: 12px; color: var(--accent); font-weight: 600;
  padding: 2px 10px; border: 1px solid var(--accent);
  border-radius: 12px;
}

/* ══════════════════════════════════════════════════════════════════════
   CREATE CHANNEL / GROUP POPUP + SLIDER
   ══════════════════════════════════════════════════════════════════════ */
.create-popup-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.create-popup {
  background: var(--bg-primary);
  border-radius: 16px;
  width: 440px; max-width: 94vw;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.create-popup-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none;
  color: var(--text-secondary); font-size: 24px;
  cursor: pointer; z-index: 5;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.create-popup-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.create-popup-slider {
  position: relative;
  overflow: hidden;
}
.create-slide {
  display: none;
  padding: 32px 28px 20px;
  flex-direction: column;
  gap: 16px;
  animation: slideFadeIn 0.3s ease;
}
.create-slide.active { display: flex; }
@keyframes slideFadeIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.create-slide h3 { font-size: 22px; font-weight: 600; text-align: center; }
.create-slide-desc { text-align: center; color: var(--text-secondary); font-size: 13px; margin-top: -8px; }
.create-slide-btns { display: flex; gap: 10px; }
.create-slide-btns .auth-btn { flex: 1; }
.auth-btn.outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.auth-btn.outline:hover { background: var(--bg-hover); }
.create-slider-dots {
  display: flex; justify-content: center; gap: 8px;
  padding: 12px 0 20px;
}
.create-slider-dots .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bg-hover);
  transition: background 0.3s, transform 0.3s;
}
.create-slider-dots .dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

/* ══════════════════════════════════════════════════════════════════════
   CHANNEL VIEW
   ══════════════════════════════════════════════════════════════════════ */
.channel-view {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg-chat);
  position: relative;
}
.channel-sender-name {
  font-size: 13px; font-weight: 500; color: var(--accent);
  margin-bottom: 2px;
}
.channel-sender-name.self {
  color: #53bdeb;
}

/* ══════════════════════════════════════════════════════════════════════
   USER PROFILE VIEWER
   ══════════════════════════════════════════════════════════════════════ */
.user-profile-panel {
  position: absolute; top: 0; right: 0;
  width: var(--sidebar-width); height: 100%;
  background: var(--bg-primary); z-index: 30;
  display: flex; flex-direction: column;
  box-shadow: -2px 0 12px rgba(0,0,0,0.3);
}
.profile-header-bg {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--bg-header);
  height: var(--header-height);
}
.profile-header-bg h3 { font-size: 18px; font-weight: 500; }
.profile-avatar-large {
  display: flex; justify-content: center; padding: 24px 0 12px;
}
.profile-avatar-large img {
  width: 120px; height: 120px; border-radius: 50%;
  object-fit: cover;
}
.profile-field {
  padding: 8px 24px;
}
.profile-field label {
  font-size: 12px; color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 2px; display: block;
}
.field-value {
  font-size: 15px; color: var(--text-primary);
  padding: 4px 0;
}

/* ══════════════════════════════════════════════════════════════════════
   @MENTION STYLE
   ══════════════════════════════════════════════════════════════════════ */
.mention {
  color: #53bdeb;
  cursor: pointer;
  font-weight: 500;
}
.mention:hover {
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════════════
   ADMIN CHANNELS LIST
   ══════════════════════════════════════════════════════════════════════ */
.admin-channel-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.admin-channel-info {
  flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.admin-channel-info strong { font-size: 14px; }
.admin-channel-actions {
  display: flex; gap: 8px;
}
.admin-channel-actions .admin-action-btn {
  padding: 6px; border-radius: 6px;
}

/* ══════════════════════════════════════════════════════════════════════
   CALL BUTTON ACTIVE STATE
   ══════════════════════════════════════════════════════════════════════ */
.active-call-btn {
  color: var(--accent) !important;
  background: var(--accent-light) !important;
  border-radius: 50%;
}

/* ══════════════════════════════════════════════════════════════════════
   CHANNEL NO PERMISSION BAR
   ══════════════════════════════════════════════════════════════════════ */
.channel-no-permission {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
}
.channel-no-permission svg {
  opacity: 0.5;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════
   CHANNEL MEMBERS MANAGEMENT PANEL
   ══════════════════════════════════════════════════════════════════════ */
.channel-members-mgmt {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.members-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  transition: background 0.15s;
}
.member-item:hover {
  background: var(--bg-hover);
}
.member-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.member-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.member-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
  margin-top: 2px;
}
.member-role.admin { color: #ff6b6b; background: rgba(255,107,107,0.15); }
.member-role.moderator { color: #ffd43b; background: rgba(255,212,59,0.15); }
.member-role.member { color: var(--text-secondary); background: rgba(255,255,255,0.05); }
.role-select-ch {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════════════════════
   AVATAR PICKER PANEL
   ══════════════════════════════════════════════════════════════════════ */
.avatar-picker-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.avatar-filter-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.avatar-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.avatar-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.avatar-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px;
}
.avatar-grid-item {
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}
.avatar-grid-item:hover {
  transform: scale(1.08);
  border-color: var(--accent);
}
.avatar-grid-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.avatar-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-grid-item.upload-avatar {
  background: var(--bg-input);
  flex-direction: column;
  gap: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  border-radius: 12px;
}
.avatar-grid-item.upload-avatar svg {
  opacity: 0.7;
}
.avatar-grid-item.small {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}
.avatar-grid-item.small img {
  border-radius: 50%;
}

/* ══════════════════════════════════════════════════════════════════════
   PROFILE SETUP SCREEN
   ══════════════════════════════════════════════════════════════════════ */
.profile-setup-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.setup-container {
  width: 100%;
  max-width: 460px;
  padding: 40px 32px;
  text-align: center;
}
.setup-header {
  margin-bottom: 28px;
}
.setup-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 12px 0 4px;
}
.setup-header p {
  font-size: 14px;
  color: var(--text-secondary);
}
.setup-avatar-section {
  margin-bottom: 24px;
}
.setup-avatar-preview {
  position: relative;
  display: inline-block;
  width: 96px;
  height: 96px;
}
.setup-avatar-preview img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  object-fit: cover;
}
.setup-avatar-upload-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}
.setup-avatar-upload-btn:hover {
  transform: scale(1.1);
}
.setup-avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.setup-fields {
  text-align: left;
  margin-bottom: 24px;
}
.setup-fields .auth-field {
  margin-bottom: 16px;
}
.setup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.setup-skip-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 10px;
  transition: color 0.2s;
}
.setup-skip-btn:hover {
  color: var(--text-primary);
}

/* ══════════════════════════════════════════════════════════════════════
   VIEW COUNT (channel messages)
   ══════════════════════════════════════════════════════════════════════ */
.view-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-secondary);
  font-size: 11px;
  margin-left: 6px;
}
.view-count svg {
  opacity: 0.6;
}

/* ══════════════════════════════════════════════════════════════════════
   SUGGESTED CHANNEL JOIN BADGE
   ══════════════════════════════════════════════════════════════════════ */
.channel-join-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.suggested-channel {
  border-left: 3px solid var(--accent);
}

/* ══════════════════════════════════════════════════════════════════════
   GROUP TYPE SELECTOR
   ══════════════════════════════════════════════════════════════════════ */
.grp-type-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.grp-type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.grp-type-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.grp-type-btn.active {
  border-color: var(--accent);
  background: rgba(83,189,235,0.1);
  color: var(--accent);
}
.grp-type-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 16px 0;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════════════════
   GROUP MEMBER MANAGEMENT
   ══════════════════════════════════════════════════════════════════════ */
.member-actions-grp {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}
.member-actions-grp .role-select-ch {
  font-size: 11px;
  padding: 3px 6px;
}
.member-actions-grp .status-select {
  min-width: 70px;
}
.remove-member-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.remove-member-btn:hover {
  background: var(--danger);
  color: #fff;
}
.add-member-btn {
  cursor: pointer;
  opacity: 0.8;
}
.add-member-btn:hover {
  opacity: 1;
  background: rgba(83,189,235,0.05);
}
.member-status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
  margin-left: 6px;
}
.member-status-badge.banned {
  background: rgba(239,83,80,0.2);
  color: var(--danger);
}
.member-status-badge.limited {
  background: rgba(255,167,38,0.2);
  color: var(--warning);
}

/* ══════════════════════════════════════════════════════════════════════
   JOIN REQUEST ACTIONS
   ══════════════════════════════════════════════════════════════════════ */
.join-request-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.jr-accept, .jr-reject {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.jr-accept {
  background: rgba(76,175,80,0.2);
  color: #4caf50;
}
.jr-accept:hover {
  background: #4caf50;
  color: #fff;
}
.jr-reject {
  background: rgba(239,83,80,0.2);
  color: var(--danger);
}
.jr-reject:hover {
  background: var(--danger);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   CHANNEL AVATAR & SETTINGS (Create Channel)
   ═══════════════════════════════════════════════════════════════ */

.ch-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.ch-avatar-preview {
  position: relative;
  width: 90px;
  height: 90px;
}
.ch-avatar-preview img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
}
.ch-avatar-cam-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}
.ch-avatar-premade {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 300px;
}
.ch-premade-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  object-fit: cover;
}
.ch-premade-avatar:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}
.ch-premade-avatar.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 100,181,246), 0.3);
}

/* Settings Toggles */
.ch-settings-section {
  margin: 16px 0;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.ch-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ch-setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.ch-setting-label {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
}
.ch-setting-info small {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-left: 12px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-secondary);
  border-radius: 24px;
  transition: 0.3s;
  border: 1px solid var(--border);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   CHANNEL INFO PANEL
   ═══════════════════════════════════════════════════════════════ */

.channel-info-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.channel-info-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
}
.ch-info-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0 16px;
  gap: 6px;
}
.ch-info-avatar-wrap {
  position: relative;
  width: 100px;
  height: 100px;
}
.ch-info-avatar-wrap img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
}
.ch-info-avatar-section h2 {
  margin: 0;
  font-size: 20px;
  color: var(--text-primary);
}
.ch-info-username {
  color: var(--accent);
  font-size: 14px;
}
.ch-info-desc {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  margin: 4px 0 0;
  max-width: 280px;
}

.ch-info-edit-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}

.ch-reactions-config {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 8px;
}
.ch-reactions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.reaction-emoji-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 18px;
}
.reaction-remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
}
.ch-add-reaction-btn {
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 4px;
}
.ch-add-reaction-btn:hover {
  background: rgba(var(--accent-rgb, 100,181,246), 0.1);
}

.ch-info-members-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 500;
}
.ch-info-members-row:hover {
  color: var(--accent);
}
.ch-info-member-count {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════
   REACTIONS ON MESSAGES
   ═══════════════════════════════════════════════════════════════ */

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding-top: 4px;
}
.msg-reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 15px;
  color: var(--text-primary);
  transition: background 0.2s, border-color 0.2s;
}
.msg-reaction:hover {
  background: rgba(var(--accent-rgb, 100,181,246), 0.15);
  border-color: var(--accent);
}
.msg-reaction.my-reaction {
  background: rgba(var(--accent-rgb, 100,181,246), 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

/* Reaction Quick Picker (appears on hover) */
.reaction-quick-picker {
  position: absolute;
  top: -44px;
  right: 8px;
  display: none;
  gap: 2px;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 10;
}
.message:hover .reaction-quick-picker {
  display: flex;
}
.reaction-pick-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.15s, transform 0.15s;
}
.reaction-pick-btn:hover {
  background: rgba(var(--accent-rgb, 100,181,246), 0.2);
  transform: scale(1.25);
}

/* Signed Message Author */
.signed-author {
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  margin-right: 6px;
}

/* Make messages position relative for reaction picker */
.message.channel-msg,
.message.group-msg {
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════
   TEXT FORMATTING POPUP
   ═══════════════════════════════════════════════════════════════ */

.format-popup {
  position: fixed;
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  z-index: 100;
  animation: fadeInScale 0.12s ease;
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
.fmt-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.fmt-btn:hover {
  background: rgba(var(--accent-rgb, 100,181,246), 0.2);
  color: var(--accent);
}

/* Link Dialog */
.link-dialog {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.link-dialog-inner {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 20px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.link-dialog-inner label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.link-dialog-inner input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  box-sizing: border-box;
}
.link-dialog-inner input:focus {
  border-color: var(--accent);
}
.link-dialog-btns {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.link-cancel-btn, .link-apply-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
}
.link-cancel-btn {
  background: transparent;
  color: var(--text-secondary);
}
.link-cancel-btn:hover { background: rgba(255,255,255,0.05); }
.link-apply-btn {
  background: var(--accent);
  color: #fff;
}
.link-apply-btn:hover { filter: brightness(1.15); }

/* ═══════════════════════════════════════════════════════════════
   SPOILER TEXT IN MESSAGES
   ═══════════════════════════════════════════════════════════════ */

.spoiler-text {
  background: var(--text-primary);
  color: transparent;
  border-radius: 4px;
  padding: 0 3px;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
  user-select: none;
}
.spoiler-text.revealed {
  background: rgba(var(--accent-rgb, 100,181,246), 0.15);
  color: var(--text-primary);
  user-select: text;
}

/* Formatted text in messages */
.msg-bold { font-weight: 700; }
.msg-italic { font-style: italic; }
.msg-link {
  color: #53bdeb;
  text-decoration: underline;
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════════════════════
   CHANNEL COMMENTS
   ══════════════════════════════════════════════════════════════════════ */
.msg-comment-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 13px; cursor: pointer;
  padding: 4px 8px; border-radius: 12px;
  transition: color 0.2s, background 0.2s;
  margin-top: 4px;
}
.msg-comment-btn:hover { color: var(--accent); background: var(--accent-light); }
.msg-comment-btn svg { width: 16px; height: 16px; }

.comments-panel-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex; align-items: flex-end; justify-content: center;
}
.comments-panel {
  background: var(--bg-primary);
  width: 480px; max-width: 100%;
  max-height: 70vh;
  border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  animation: slideUp 0.3s ease;
}
.comments-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.comments-panel-header h3 { font-size: 16px; font-weight: 600; }
.comments-list {
  flex: 1; overflow-y: auto;
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.comment-item {
  display: flex; gap: 10px;
}
.comment-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  flex-shrink: 0; cursor: pointer;
}
.comment-body { flex: 1; min-width: 0; }
.comment-header {
  display: flex; align-items: baseline; gap: 8px;
}
.comment-name {
  font-size: 13px; font-weight: 600;
  color: var(--accent); cursor: pointer;
}
.comment-name:hover { text-decoration: underline; }
.comment-time {
  font-size: 11px; color: var(--text-muted);
}
.comment-text {
  font-size: 14px; color: var(--text-primary);
  line-height: 1.4; margin-top: 2px;
  word-wrap: break-word;
}
.comment-reply-tag {
  font-size: 12px; color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 6px; margin-bottom: 2px;
}
.comment-actions {
  display: flex; gap: 12px; margin-top: 4px;
}
.comment-action-btn {
  background: none; border: none;
  color: var(--text-muted); font-size: 12px;
  cursor: pointer; padding: 0;
}
.comment-action-btn:hover { color: var(--text-primary); }
.comments-input-area {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
}
.comments-reply-preview {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; margin-bottom: 6px;
  background: var(--bg-secondary); border-radius: 8px;
  font-size: 12px; color: var(--accent);
}
.comments-reply-preview .icon-btn { padding: 2px; }
.comments-input-row {
  display: flex; align-items: center; gap: 8px;
}
.comments-input-row input {
  flex: 1;
  background: var(--bg-input);
  border: none; border-radius: 20px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.comments-input-row .send-btn { color: var(--accent); }
.comments-empty {
  text-align: center; padding: 32px 16px;
  color: var(--text-muted); font-size: 14px;
}

/* ══════════════════════════════════════════════════════════════════════
   FILE ATTACHMENTS IN MESSAGES
   ══════════════════════════════════════════════════════════════════════ */
.message-video {
  border-radius: 6px;
  max-width: 330px;
  width: 100%;
  margin-bottom: 4px;
}
.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  margin-bottom: 4px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.15s;
  cursor: pointer;
}
.message-file:hover { background: rgba(255,255,255,0.1); }
.file-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.file-info {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.file-name {
  font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 200px;
}
.file-size {
  font-size: 12px; color: var(--text-secondary);
}

/* Upload progress bar inside input area */
.upload-progress-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--bg-hover);
}
.upload-progress-bar .bar {
  height: 100%; background: var(--accent);
  transition: width 0.2s;
  width: 0;
}

/* File preview strip above input */
.file-preview-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}
.file-preview-strip .file-preview-name {
  flex: 1; font-size: 13px; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-preview-strip .file-preview-size {
  font-size: 12px; color: var(--text-secondary);
}
.file-preview-strip .file-preview-remove {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 18px; padding: 0 4px;
}
.file-preview-strip .file-preview-remove:hover { color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════════
   PROFILE POPUP (Telegram-style)
   ══════════════════════════════════════════════════════════════════════ */
.profile-popup-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.profile-popup {
  background: var(--bg-primary);
  border-radius: 12px;
  width: 360px; max-width: 92vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  overflow: hidden;
  position: relative;
  animation: popupSlideUp 0.2s ease;
}
@keyframes popupSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
.profile-popup-close {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.4); border: none;
  color: #fff; font-size: 22px; width: 32px; height: 32px;
  border-radius: 50%; cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.profile-popup-close:hover { background: rgba(0,0,0,0.6); }
.profile-popup-avatar-wrap {
  position: relative;
  display: flex; justify-content: center; align-items: center;
  background: linear-gradient(135deg, var(--accent), #1a1a2e);
  padding: 32px 0 24px;
}
.profile-popup-avatar-wrap img {
  width: 100px; height: 100px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--bg-primary);
  position: relative; z-index: 1;
}
.birthday-confetti {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 2;
}
.profile-popup-name {
  font-size: 20px; font-weight: 600;
  text-align: center; padding: 12px 16px 2px;
  color: var(--text-primary);
}
.profile-popup-status {
  font-size: 13px; text-align: center;
  color: var(--text-secondary); padding-bottom: 8px;
}
.profile-popup-info {
  padding: 4px 0;
}
.popup-info-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  transition: background 0.12s;
}
.popup-info-row:hover { background: var(--bg-hover); }
.popup-info-row svg { flex-shrink: 0; color: var(--text-secondary); }
.popup-info-row div {
  display: flex; flex-direction: column; gap: 1px;
}
.popup-info-value {
  font-size: 15px; color: var(--text-primary);
}
.popup-info-label {
  font-size: 12px; color: var(--text-secondary);
}
.profile-popup-actions {
  display: flex; gap: 8px; padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.profile-popup-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px; border-radius: 8px;
  border: 1px solid var(--border);
  background: none; color: var(--text-primary);
  font-size: 14px; cursor: pointer;
  transition: background 0.15s;
}
.profile-popup-btn:hover { background: var(--bg-hover); }
.profile-popup-btn.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.profile-popup-btn.primary:hover { opacity: 0.9; }

/* Birthday effect badge on popup */
.birthday-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #ff6b6b, #feca57);
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px; margin-left: 6px;
}

/* ══════════════════════════════════════════════════════════════════════
   ADMIN MEDIA TAB
   ══════════════════════════════════════════════════════════════════════ */
.admin-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; padding-top: 12px;
}
.admin-media-card {
  background: var(--bg-secondary);
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
}
.admin-media-preview {
  height: 120px; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.2); overflow: hidden;
}
.admin-media-preview img {
  width: 100%; height: 100%; object-fit: cover;
}
.admin-media-preview video {
  width: 100%; height: 100%; object-fit: cover;
}
.admin-media-preview .file-placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; color: var(--text-secondary);
}
.admin-media-preview .file-placeholder svg { opacity: 0.5; }
.admin-media-meta {
  padding: 8px 10px;
}
.admin-media-meta .media-name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-primary);
}
.admin-media-meta .media-info {
  font-size: 11px; color: var(--text-secondary); margin-top: 2px;
}
.admin-media-actions {
  display: flex; justify-content: flex-end; gap: 4px;
  padding: 4px 8px 8px;
}
.admin-media-actions button {
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer; padding: 4px;
  border-radius: 4px; transition: all 0.15s;
}
.admin-media-actions button:hover { color: var(--danger); background: var(--bg-hover); }

/* ══════════════════════════════════════════════════════════════════════
   BIRTHDAY EFFECTS
   ══════════════════════════════════════════════════════════════════════ */
@keyframes birthdayGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 107, 107, 0.3), 0 0 16px rgba(254, 202, 87, 0.2); }
  50% { box-shadow: 0 0 16px rgba(255, 107, 107, 0.5), 0 0 32px rgba(254, 202, 87, 0.4); }
}
.birthday-avatar {
  animation: birthdayGlow 2s ease-in-out infinite;
}
.birthday-ring {
  background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3) !important;
}

@media (max-width: 768px) {
  .profile-popup { width: 94vw; }
}
