/* ============ Revesty ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #202225;
  color: #dcddde;
  font-size: 14px;
}

button { font-family: inherit; cursor: pointer; }
input, textarea {
  resize: vertical;
}
a { color: #00aff4; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ Screen ============ */
.screen { height: 100vh; width: 100vw; }

/* ============ Auth Screen ============ */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #202225;
}
.auth-card {
  background: #36393f;
  width: 480px;
  max-width: 90vw;
  padding: 32px;
  border-radius: 8px;
}
.auth-logo {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin: 0 auto 16px;
}
.auth-card h1 {
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}
.auth-card p {
  color: #b9bbbe;
  text-align: center;
  margin-bottom: 20px;
}
.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #b9bbbe;
  margin-bottom: 8px;
}
.field .req { color: #ed4245; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  background: #202225;
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
}
.field input:focus { border: 1px solid #5865f2; }
.btn-blurple {
  background: #5865f2;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
}
.btn-blurple:hover { background: #4752c4; }
.btn-blurple:disabled { opacity: 0.5; cursor: not-allowed; }
#auth-submit {
  width: 100%;
  margin-top: 4px;
}
.switch-text {
  text-align: center;
  color: #72767d;
  font-size: 13px;
  margin-top: 16px;
}

/* ============ Main App ============ */
#app-screen {
  display: flex;
  flex-direction: row;
}

/* Mobile bottom nav - only shown on small screens (see media query below) */
#mobile-nav { display: none; }

/* ============ Server Rail ============ */
#server-rail {
  width: 72px;
  min-width: 72px;
  background: #202225;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  overflow-y: auto;
  overflow-x: visible;
  height: 100vh;
}
#server-rail::-webkit-scrollbar { width: 0; }
.server-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.server-pill {
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  background: #fff;
  border-radius: 0 4px 4px 0;
  height: 8px;
  opacity: 0;
  transition: height 0.2s, opacity 0.2s;
}
.server-icon-wrapper.active .server-pill { opacity: 1; height: 40px; }
.server-icon-wrapper:hover .server-pill { opacity: 1; height: 20px; }
.server-icon {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: #36393f;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #dcddde;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: border-radius 0.15s, background 0.15s;
  overflow: hidden;
  user-select: none;
}
.server-icon:hover {
  border-radius: 16px;
  background: #5865f2;
  color: #fff;
}
.server-icon.active {
  border-radius: 16px;
  background: #5865f2;
  color: #fff;
}
.server-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.server-icon.home {
  background: #ffffff;
  color: #dcddde;
  font-size: 24px;
}
.server-icon.home img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  display: block;
}
.server-icon.home:hover {
  background: #5865f2;
  color: #fff;
}
.rail-dm-icon {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: #36393f;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #dcddde;
  font-weight: 600;
  font-size: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: border-radius 0.15s, background 0.15s;
}
.rail-dm-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rail-dm-icon:hover {
  border-radius: 16px;
}
.rail-dm-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f83050;
  color: #fff;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px #18181e;
}
.dm-list-item.closed { opacity: 0.55; }
.server-icon.home.active {
  background: #5865f2;
  color: #fff;
}
.server-icon.add {
  background: #36393f;
  color: #3ba55d;
  font-size: 24px;
}
.server-icon.add:hover {
  background: #3ba55d;
  color: #fff;
}
.server-divider {
  width: 32px;
  height: 2px;
  background: #2f3136;
  border-radius: 1px;
  margin: 4px 0;
}

/* ============ Sidebar ============ */
#sidebar {
  width: 240px;
  min-width: 240px;
  background: #2f3136;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 0 16px;
  height: 48px;
  min-height: 48px;
  border-bottom: 1px solid #202225;
  font-weight: 700;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.sidebar-header:hover { background: #35373c; }
.sidebar-back-btn { display: none; }
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.sidebar-list::-webkit-scrollbar { width: 8px; }
.sidebar-list::-webkit-scrollbar-thumb { background: #202225; border-radius: 4px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }

.channel-category {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #8e9297;
  padding: 16px 8px 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.channel-category:hover { color: #dcddde; }
.channel-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 4px;
  color: #8e9297;
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 14px;
}
.channel-item:hover { background: rgba(79,84,92,0.32); color: #dcddde; }
.channel-item.active { background: rgba(79,84,92,0.48); color: #fff; }
.channel-icon { margin-right: 6px; opacity: 0.7; }
.channel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-delete {
  opacity: 0;
  background: none;
  border: none;
  color: #b9bbbe;
  padding: 2px;
}
.channel-item:hover .channel-delete { opacity: 1; }

.dm-list-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 2px;
}
.dm-list-item:hover { background: rgba(79,84,92,0.32); }
.dm-list-item.active { background: rgba(79,84,92,0.48); }
.dm-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 12px;
  position: relative;
  background: #5865f2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  overflow: visible;
  flex-shrink: 0;
}
.dm-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid #2f3136;
}
.status-online { background: #3ba55d; }
.status-idle { background: #faa61a; }
.status-dnd { background: #ed4245; }
.status-offline { background: #72767d; }
.dm-info { flex: 1; min-width: 0; }
.dm-name { color: #dcddde; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-status { color: #72767d; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-list-item.active .dm-name { color: #fff; }

/* User panel at bottom of sidebar */
.user-panel {
  background: #292b2f;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.user-panel:hover { background: #323437; }
.user-panel-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #5865f2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}
.user-panel-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.user-panel-info { flex: 1; min-width: 0; }
.user-panel-name { color: #fff; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel-status { color: #b9bbbe; font-size: 12px; }
.user-panel-settings {
  background: none;
  border: none;
  color: #b9bbbe;
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-panel-settings:hover { color: #fff; background: rgba(255,255,255,0.06); }

/* ============ Main Content ============ */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-width: 0;
  background: #36393f;
  height: 100vh;
  overflow: hidden;
}
.chat-header {
  padding: 0 16px;
  height: 48px;
  min-height: 48px;
  border-bottom: 1px solid #202225;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-header-icon { color: #72767d; }
.chat-header-topic { color: #72767d; font-weight: 400; font-size: 13px; margin-left: 8px; }
.chat-header-actions { margin-left: auto; display: flex; gap: 12px; color: #b9bbbe; }
.chat-header-actions button { background: none; border: none; color: inherit; padding: 4px; border-radius: 4px; }
.chat-header-actions button:hover { color: #fff; background: rgba(255,255,255,0.06); }

.chat-header-back {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: #b9bbbe;
  cursor: pointer;
  border-radius: 50%;
  margin-right: 8px;
  padding: 0;
}
.chat-header-back:hover {
  background: rgba(255,255,255,0.1);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-top: 16px;
  padding-bottom: 8px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb { background: #202225; border-radius: 4px; }

.message-group { margin-top: 17px; padding: 2px 8px; }
.message-group:hover { background: rgba(0,0,0,0.04); }
.message-group:first-child { margin-top: auto; }
.message-row { display: flex; gap: 16px; padding: 2px 0; align-items: flex-start; }
.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #5865f2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  margin-top: 2px;
}
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-content { flex: 1; min-width: 0; }
.message-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.message-author { color: #fff; font-weight: 500; font-size: 14px; }
.message-time { color: #72767d; font-size: 11px; }
.message-text { color: #dcddde; font-size: 14px; word-wrap: break-word; line-height: 1.375; }
.message-grouped { position: relative; padding: 4px 8px 4px 76px; }
.message-grouped:hover { background: rgba(0,0,0,0.04); }
.message-grouped .message-time { position: absolute; left: 8px; top: 4px; width: 60px; text-align: right; opacity: 0; font-size: 10px; color: #72767d; }
.message-grouped:hover .message-time { opacity: 1; }
.message-grouped .message-text { color: #dcddde; font-size: 14px; line-height: 1.375; }

.chat-input {
  padding: 0 16px 24px 16px;
  flex-shrink: 0;
  margin-top: 8px;
}
.typing-indicator {
  font-size: 12px;
  color: #b9bbbe;
  margin-bottom: 4px;
  padding: 0 8px;
  height: 18px;
}
.chat-input-box {
  background: #40444b;
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-input-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  color: #fff;
  font-size: 14px;
}
.chat-input-box input:focus {
  border: none;
  outline: none;
  box-shadow: none;
}
.chat-input-box input::placeholder { color: #72767d; }
.chat-input-btn { background: none; border: none; color: #b9bbbe; padding: 4px; display: flex; align-items: center; }
.chat-input-btn:hover { color: #dcddde; }
.chat-input-disabled { cursor: not-allowed; opacity: 0.6; }
.chat-input-box input.chat-input-disabled { opacity: 0.6; color: #b9bbbe; }
.chat-input-send { color: #b9bbbe; }
.chat-input-send:hover { color: #dcddde; }

/* ============ Friends View ============ */
.friends-header {
  padding: 12px 16px;
  border-bottom: 1px solid #202225;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 16px;
}
.friends-title { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.friends-divider { width: 1px; height: 24px; background: #4f545c; }
.friends-tabs { display: flex; gap: 4px; }
.friends-tab {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: #b9bbbe;
  background: none;
  border: none;
  text-transform: capitalize;
}
.friends-tab:hover { background: rgba(255,255,255,0.04); color: #dcddde; }
.friends-tab.active { background: #4f545c; color: #fff; }
.friends-tab .badge {
  background: #ed4245;
  color: #fff;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 11px;
  margin-left: 6px;
}
.friends-action { margin-left: auto; }
.btn-green { background: #3ba55d; color: #fff; border: none; padding: 6px 12px; border-radius: 4px; font-weight: 500; font-size: 13px; }
.btn-green:hover { background: #3ba55d; opacity: 0.9; }
.btn-red { background: #ed4245; color: #fff; border: none; padding: 6px 12px; border-radius: 4px; font-weight: 500; font-size: 13px; }
.btn-red:hover { background: #c23a3d; }
.btn-gray { background: #4f545c; color: #fff; border: none; padding: 6px 12px; border-radius: 4px; font-weight: 500; font-size: 13px; }

.friends-list { flex: 1; overflow-y: auto; padding: 8px; }
.friends-list::-webkit-scrollbar { width: 8px; }
.friends-list::-webkit-scrollbar-thumb { background: #202225; border-radius: 4px; }
.friends-section-header { color: #72767d; font-size: 12px; font-weight: 700; text-transform: uppercase; padding: 16px 8px 4px; }
.friend-row {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  gap: 12px;
}
.friend-row:hover { background: rgba(255,255,255,0.04); }
.friend-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #5865f2;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: visible;
}
.friend-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.friend-info { flex: 1; min-width: 0; }
.friend-name { color: #fff; font-weight: 500; font-size: 14px; }
.friend-name .username { color: #72767d; font-weight: 400; margin-left: 6px; font-size: 13px; }
.friend-status { color: #72767d; font-size: 12px; text-transform: capitalize; }
.friend-actions { display: flex; gap: 4px; opacity: 0; }
.friend-row:hover .friend-actions { opacity: 1; }
.action-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2f3136;
  border: 1px solid #b9bbbe;
  color: #b9bbbe;
  display: flex;
  align-items: center;
  justify-content: center;
}
.action-icon-btn:hover { color: #fff; border-color: #fff; }
.action-icon-btn.accept { border-color: #3ba55d; color: #3ba55d; }
.action-icon-btn.accept:hover { background: #3ba55d; color: #fff; }
.action-icon-btn.decline { border-color: #ed4245; color: #ed4245; }
.action-icon-btn.decline:hover { background: #ed4245; color: #fff; }
.empty-state { text-align: center; padding: 60px 16px; color: #72767d; }

/* ============ Modal ============ */
#modal-container {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}
#modal-container.show { display: flex; }
.modal {
  background: #36393f;
  border-radius: 8px;
  max-width: 460px;
  width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-large {
  width: 780px;
  height: 520px;
  min-height: 520px;
  max-height: 520px;
  max-width: 780px;
}
.modal-header {
  padding: 16px;
  border-bottom: 1px solid #202225;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 { color: #fff; font-size: 18px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: #b9bbbe;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb { background: #202225; border-radius: 4px; }
.modal-footer {
  padding: 16px;
  background: #2f3136;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.modal-footer button {
  flex: 1 !important;
  height: 40px !important;
  padding: 0 16px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  border-radius: 4px !important;
  border: none !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.modal-body h3 { color: #fff; font-size: 16px; margin-bottom: 12px; font-weight: 700; }
.modal-body .description { color: #b9bbbe; font-size: 13px; margin-bottom: 16px; line-height: 1.4; }

/* Profile preview card */
.profile-card { background: #2f3136; border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.profile-banner { height: 100px; background: linear-gradient(135deg, #5865f2, #eb459e); background-size: cover; background-position: center; }
.profile-banner img { width: 100%; height: 100%; object-fit: cover; }
.profile-card-body { padding: 16px; margin-top: -40px; }
.profile-card-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 6px solid #2f3136;
  background: #5865f2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 32px;
  color: #fff;
  overflow: hidden;
}
.profile-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-card-name { color: #fff; font-size: 18px; font-weight: 700; margin-top: 8px; }
.profile-card-username { color: #b9bbbe; font-size: 13px; }
.profile-card-bio {
  background: #202225;
  border-radius: 4px;
  padding: 12px;
  margin-top: 12px;
}
.profile-card-bio-label { color: #b9bbbe; font-size: 11px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.profile-card-bio-text {
  color: #fff;
  font-size: 14px;
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}
.profile-card-bio-text::-webkit-scrollbar,
.profile-popup-section-text::-webkit-scrollbar {
  width: 6px;
}
.profile-card-bio-text::-webkit-scrollbar-thumb,
.profile-popup-section-text::-webkit-scrollbar-thumb {
  background: #202225;
  border-radius: 3px;
}

/* Settings modal layout */
.settings-modal { max-width: 1000px; height: 80vh; flex-direction: row; }
.settings-sidebar {
  width: 218px;
  background: #2f3136;
  padding: 56px 12px;
  overflow-y: auto;
}
.settings-sidebar button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border-radius: 4px;
  background: none;
  border: none;
  color: #b9bbbe;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}
.settings-sidebar button:hover { background: rgba(255,255,255,0.04); color: #dcddde; }
.settings-sidebar button.active { background: #4f545c; color: #fff; }
.settings-sidebar hr { border: none; border-top: 1px solid #202225; margin: 12px 0; }
.settings-sidebar button.danger { color: #ed4245; }
.settings-main {
  flex: 1;
  padding: 56px 40px;
  overflow-y: auto;
  position: relative;
}
.settings-main::-webkit-scrollbar { width: 8px; }
.settings-main::-webkit-scrollbar-thumb { background: #202225; border-radius: 4px; }
.settings-main h2 { color: #fff; font-size: 18px; font-weight: 700; margin-bottom: 20px; }

/* Member list (right panel) */
.member-list {
  width: 240px;
  min-width: 240px;
  background: #2f3136;
  padding: 16px 8px;
  overflow-y: auto;
}
.member-list::-webkit-scrollbar { width: 8px; }
.member-list::-webkit-scrollbar-thumb { background: #202225; border-radius: 4px; }
.member-section-header { color: #8e9297; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 8px; margin-top: 8px; }
.member-row { display: flex; align-items: center; padding: 6px 8px; border-radius: 4px; cursor: pointer; gap: 12px; }
.member-row:hover { background: rgba(255,255,255,0.04); }
.member-row.offline { opacity: 0.4; }
.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #5865f2;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: visible;
}
.member-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.member-name { font-size: 14px; font-weight: 500; color: #dcddde; }
.member-name.owner { color: #ffffff; }
.member-name.admin { color: #ed4245; }
.member-custom { font-size: 12px; color: #72767d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 2px;
  margin-left: 4px;
  color: #fff;
  font-weight: 700;
}
.role-badge.owner { background: #5865f2; }
.role-badge.admin { background: #ed4245; }

/* Toast */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #2f3136;
  color: #dcddde;
  padding: 12px 16px;
  border-radius: 4px;
  border: 1px solid #202225;
  font-size: 14px;
  max-width: 360px;
  animation: slideIn 0.2s;
}
.toast.success { border-left: 3px solid #3ba55d; }
.toast.error { border-left: 3px solid #ed4245; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Channel type selection */
.channel-type-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 4px;
  background: #2f3136;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  width: 100%;
  text-align: left;
}
.channel-type-option:hover { background: #35373c; }
.channel-type-option.selected { background: rgba(79,84,92,0.48); border-color: #5865f2; }
.channel-type-name { color: #fff; font-size: 14px; font-weight: 500; }
.channel-type-desc { color: #72767d; font-size: 12px; }

/* Welcome screen */
.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #72767d;
  text-align: center;
}
.welcome-screen h2 { color: #fff; font-size: 20px; margin-bottom: 8px; }

/* ============ Dropdown Menu ============ */
.dropdown-menu {
  position: absolute;
  background: #2f3136;
  border-radius: 4px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.24);
  padding: 8px 0;
  min-width: 220px;
  z-index: 50;
  top: 48px;
  left: 240px;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 6px 18px;
  margin: 0 8px;
  border-radius: 4px;
  color: #dcddde;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.dropdown-item:hover { background: #5865f2; color: #fff; }
.dropdown-item.danger { color: #ed4245; }
.dropdown-item.danger:hover { background: #ed4245; color: #fff; }
.dropdown-item svg { flex-shrink: 0; }
.dropdown-divider { height: 1px; background: #202225; margin: 4px 8px; }
.dropdown-label { padding: 4px 8px 4px 18px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: #72767d; }

/* Server header with dropdown */
.server-header-bar { position: relative; }
.server-header-chevron { display: flex; align-items: center; transition: transform 0.15s; }
.server-header-chevron.open { transform: rotate(180deg); }

/* Invite modal duration options */
.duration-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  background: #2f3136;
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  color: #dcddde;
  font-size: 14px;
}
.duration-option:hover { background: #35373c; }
.duration-option.selected { background: rgba(79,84,92,0.48); border-color: #5865f2; color: #fff; }

/* Ban list */
.ban-row {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  background: #2f3136;
  gap: 12px;
}

/* Color picker */
.color-input {
  width: 48px;
  height: 32px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 2px solid #202225; border-radius: 4px; }

/* Channel/category reorder controls */
.reorder-controls { display: flex; gap: 2px; opacity: 0; }
.channel-item:hover .reorder-controls { opacity: 1; }
.reorder-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #8e9297;
  border-radius: 2px;
}
.reorder-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* Category management */
.category-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #8e9297;
  cursor: pointer;
}
.category-header:hover { color: #dcddde; }
.category-delete {
  opacity: 0;
  background: none;
  border: none;
  color: #8e9297;
  padding: 2px;
}
.category-header:hover .category-delete { opacity: 1; }
.category-delete:hover { color: #ed4245; }

/* Drag & drop (channels / categories / servers) */
.channel-item.dragging, .category-header.dragging, .server-icon-wrapper.dragging { opacity: 0.4; }
.channel-item.drop-before, .category-header.drop-before { box-shadow: 0 -2px 0 0 #5865f2; }
.channel-item.drop-after, .category-header.drop-after { box-shadow: 0 2px 0 0 #5865f2; }
.server-icon-wrapper.drop-before .server-icon { box-shadow: -4px 0 0 0 #5865f2; }
.server-icon-wrapper.drop-after .server-icon { box-shadow: 4px 0 0 0 #5865f2; }
.category-header.drop-into { background: rgba(88,101,242,0.35); border-radius: 4px; color: #fff; }
.sidebar-list.drop-at-end { outline: 1px dashed #5865f2; outline-offset: -4px; border-radius: 4px; }

/* Modal checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #dcddde;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #5865f2;
  cursor: pointer;
  flex-shrink: 0;
}

/* Toggle switch (used for private channel/category rows) */
.toggle-row {
  position: relative;
  padding: 0;
  background: none;
  box-shadow: none;
  border: none;
}
.toggle-row .toggle-track {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #3b3d40;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toggle-row .toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #b9bbbe;
  transition: transform 0.15s;
}
.toggle-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  top: 0;
  left: 0;
  cursor: pointer;
  z-index: 2;
}
.toggle-row input[type="checkbox"]:checked + .toggle-track {
  background: #5865f2;
}
.toggle-row input[type="checkbox"]:checked + .toggle-track::after {
  transform: translateX(18px);
  background: #fff;
}
.toggle-row input[type="checkbox"]:focus-visible + .toggle-track {
  outline: 2px solid #5865f2;
  outline-offset: 2px;
}

/* ============ User Profile Popup ============ */
.profile-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}
.profile-popup {
  background: rgba(32, 34, 37, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  width: 340px;
  max-width: 90vw;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.profile-popup-banner {
  height: 120px;
  background-size: cover;
  background-position: center;
}
.profile-popup-body {
  padding: 16px;
  margin-top: -40px;
  position: relative;
}
.profile-popup-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 6px solid #2f3136;
  background: #5865f2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 32px;
  color: #fff;
  overflow: visible;
  position: relative;
}
.profile-popup-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-popup-avatar .status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 4px solid #2f3136;
}
.profile-popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}
.profile-popup-action-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.profile-popup-action-btn.green { background: #3ba55d; color: #fff; }
.profile-popup-action-btn.green:hover { background: #2d8049; }
.profile-popup-action-btn.gray { background: #4f545c; color: #fff; }
.profile-popup-action-btn.gray:hover { background: #5d6269; }
.profile-popup-action-btn.icon-only { flex: 0 0 40px; padding: 8px; }
.profile-popup-menu {
  position: relative;
}
.profile-popup-dropdown {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 4px;
  background: #2f3136;
  border-radius: 4px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.24);
  padding: 4px 0;
  min-width: 160px;
  z-index: 10;
}
.profile-popup-dropdown-item {
  padding: 8px 12px;
  color: #dcddde;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.profile-popup-dropdown-item:hover { background: #5865f2; color: #fff; }
.profile-popup-dropdown-item.danger { color: #ed4245; }
.profile-popup-dropdown-item.danger:hover { background: #ed4245; color: #fff; }
.profile-popup-name {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  margin-top: 8px;
}
.profile-popup-username {
  color: #b9bbbe;
  font-size: 14px;
}
.profile-popup-meta {
  color: #b9bbbe;
  font-size: 12px;
  margin-top: 4px;
}
.profile-popup-section {
  background: #202225;
  border-radius: 4px;
  padding: 12px;
  margin-top: 12px;
}
.profile-popup-section-label {
  color: #b9bbbe;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.profile-popup-section-text {
  color: #fff;
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
}
.profile-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.profile-popup-close:hover { background: rgba(0,0,0,0.7); }

/* ============ Message Context Menu ============ */
.msg-context-menu {
  position: fixed;
  background: #2f3136;
  border-radius: 4px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.24);
  padding: 4px 0;
  min-width: 180px;
  z-index: 200;
}
.msg-context-item {
  padding: 8px 12px;
  color: #dcddde;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-context-item:hover { background: #5865f2; color: #fff; }
.msg-context-item.danger { color: #ed4245; }
.msg-context-item.danger:hover { background: #ed4245; color: #fff; }
.msg-context-divider { height: 1px; background: #202225; margin: 4px 0; }
.msg-context-reactions {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
}
.msg-context-emoji {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  background: #202225;
  border: 1px solid transparent;
}
.msg-context-emoji svg { width: 24px; height: 24px; }
.msg-context-emoji:hover { background: #36393f; border-color: #5865f2; }

/* ============ Message Reactions ============ */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.message-reaction {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  color: #dcddde;
}
.message-reaction:hover { background: rgba(255,255,255,0.1); }
.message-reaction.mine { background: rgba(88,101,242,0.15); border-color: #5865f2; color: #fff; }
.message-reaction-emoji { display: inline-flex; align-items: center; }
.message-reaction-emoji svg { width: 16px; height: 16px; }

/* ============ Emoji Picker ============ */
.emoji-picker {
  position: absolute;
  bottom: 60px;
  right: 16px;
  background: #2f3136;
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.24);
  padding: 8px;
  display: flex;
  gap: 4px;
  z-index: 50;
}
.emoji-picker-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
}
.emoji-picker-item svg { width: 28px; height: 28px; }
.emoji-picker-item:hover { background: rgba(255,255,255,0.1); }

/* ============ Edit Message Bar ============ */
.edit-message-bar {
  background: #202225;
  border-radius: 4px 4px 0 0;
  padding: 8px 12px;
  margin-bottom: -8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #b9bbbe;
}
.edit-message-bar .esc-hint { margin-left: auto; color: #72767d; }

/* ============ Color Presets ============ */
.color-preset {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.color-preset:hover {
  transform: scale(1.1);
}
.color-preset.reset:hover {
  background: #3a3d41 !important;
  color: #fff;
}

/* ============ Login Lockout Message ============ */
.auth-locked {
  background: #2f3136;
  border: 1px solid #ed4245;
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 16px;
  color: #ed4245;
  font-size: 13px;
}

/* ============ Notifications & Unread ============ */
.unread-badge {
  background: #5862e0;
  color: #fff;
  border-radius: 9px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 8px;
  min-width: 18px;
  text-align: center;
}
.unread-badge.ping {
  background: #f83050;
}
.unread-badge.dm-unread {
  margin-left: auto;
  margin-right: 4px;
  border-radius: 10px;
  padding: 3px 8px;
  font-size: 12px;
}
.server-unread-indicator {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5862e0;
  bottom: 4px;
  right: 4px;
  box-shadow: 0 0 0 2px #18181e;
}
.server-unread-indicator.ping {
  background: #f83050;
}

/* ============ Mention Highlight ============ */
.mention {
  background: rgba(88, 101, 242, 0.3);
  color: #d4d7ff;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 600;
}
.own-mention {
  background: rgba(88, 101, 242, 0.6);
  color: #fff;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
}
.msg-ping {
  position: relative;
  background: rgba(250, 166, 26, 0.08);
  border-radius: 4px;
}
.msg-ping::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #faa61a;
  border-radius: 4px 0 0 4px;
}

/* ============ Mobile Responsiveness (Discord Mobile Layout) ============ */
@media (max-width: 768px) {
  #app-screen {
    position: relative;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    background: #313338;
  }
  .chat-header-back {
    display: flex !important;
  }

  /* ---- Server rail ---- */
  #server-rail {
    width: 64px;
    min-width: 64px;
    flex-shrink: 0;
    height: 100%;
    z-index: 30;
    background: #1e1f22;
    padding-top: 10px;
  }
  #server-rail .server-icon,
  #server-rail .rail-dm-icon {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    font-size: 15px;
  }
  #server-rail .server-icon:hover,
  #server-rail .server-icon.active,
  #server-rail .rail-dm-icon:hover {
    border-radius: 14px;
  }

  /* ---- Sidebar (channel drawer): full-screen like Discord mobile, slides in ---- */
  #sidebar {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    z-index: 40;
    background: #2b2d31;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 8px 0 24px rgba(0,0,0,0.4);
  }

  #main-content {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: #313338;
    display: flex;
  }

  /* Home view: friends page + rail, drawer hidden */
  #app-screen.view-home #sidebar {
    transform: translateX(-100%);
  }
  #app-screen.view-home #main-content {
    display: flex !important;
  }
  #app-screen.view-home #server-rail {
    display: flex !important;
  }

  /* Server view: full-screen channel drawer over the chat */
  #app-screen.view-server #sidebar {
    transform: translateX(0);
    z-index: 40;
    display: flex !important;
  }
  #app-screen.view-server #main-content {
    display: flex !important;
  }
  #app-screen.view-server #server-rail {
    display: none !important;
  }

  /* Chat open: full screen, covers everything */
  #app-screen.show-chat #main-content {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex !important;
    animation: mobileChatIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #app-screen.show-chat #sidebar {
    transform: translateX(-100%);
  }
  #app-screen.show-chat #server-rail {
    display: none !important;
  }
  #app-screen.show-chat #mobile-nav {
    display: none !important;
  }
  @keyframes mobileChatIn {
    from { transform: translateX(24px); opacity: 0.4; }
    to { transform: translateX(0); opacity: 1; }
  }

  /* Back button in the channel sidebar header (goes home) */
  .sidebar-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: #b9bbbe;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
  }
  .sidebar-back-btn:hover {
    background: rgba(255,255,255,0.1);
  }

  /* ---- Member list drawer ---- */
  .member-list {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 60;
    background: #2b2d31;
    box-shadow: -8px 0 24px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    animation: memberDrawerIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes memberDrawerIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
  }

  /* ---- Bottom navigation (home view only) ---- */
  #mobile-nav {
    position: absolute;
    left: 64px;
    right: 0;
    bottom: 0;
    height: calc(54px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 35;
    background: #1e1f22;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: none;
    align-items: stretch;
    box-sizing: border-box;
  }
  #app-screen.view-home #mobile-nav {
    display: flex;
  }
  #mobile-nav .mobile-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #b5bac1;
    cursor: pointer;
  }
  #mobile-nav .mobile-nav-btn.active {
    color: #fff;
  }
  #mobile-nav .mobile-nav-btn svg {
    width: 26px;
    height: 26px;
  }
  #mobile-nav .mobile-nav-home img {
    width: 26px;
    height: 26px;
    object-fit: contain;
  }

  /* ---- Friends view polish ---- */
  .friends-header {
    padding: 12px !important;
    gap: 10px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    flex-wrap: nowrap !important;
  }
  .friends-title {
    font-size: 20px !important;
  }
  .friends-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    width: 100%;
  }
  .friends-action {
    margin-left: 0 !important;
    width: 100% !important;
  }
  .friends-action button {
    width: 100% !important;
    padding: 10px 12px !important;
    font-size: 13px !important;
    justify-content: center !important;
  }
  .friends-list {
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }

  /* ---- Chat polish ---- */
  .chat-messages {
    padding: 12px 6px;
  }
  .message-avatar {
    width: 36px;
    height: 36px;
  }
  .message-grouped {
    padding-left: 62px;
  }
  .message-row {
    gap: 10px;
  }
  .chat-input {
    padding: 0 10px calc(12px + env(safe-area-inset-bottom));
  }
  .chat-input-box {
    border-radius: 12px;
    padding: 8px 12px;
  }

  /* ---- Modals ---- */
  .modal {
    width: 95vw !important;
    max-width: 95vw !important;
    height: auto !important;
    max-height: 90vh !important;
  }
  .modal-large {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    flex-direction: column !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    background: #313338 !important;
  }
  .settings-sidebar {
    width: 100% !important;
    height: auto !important;
    flex-direction: row !important;
    overflow-x: auto;
    flex-shrink: 0;
    background: #2b2d31;
    padding: 12px;
    gap: 8px;
    border-bottom: 1px solid #1f2023;
  }
  .settings-sidebar button {
    white-space: nowrap;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    font-size: 13px !important;
  }
  .settings-main {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 24px 16px !important;
    background: #313338 !important;
  }
  .modal-footer button {
    flex: 1 !important;
    height: 40px !important;
    padding: 0 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    border-radius: 4px !important;
    border: none !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Hide scrollbars for a native app feel */
  #server-rail::-webkit-scrollbar,
  #sidebar::-webkit-scrollbar,
  .chat-messages::-webkit-scrollbar,
  .sidebar-list::-webkit-scrollbar {
    display: none;
  }
}
/* Non-grouped rows sit inside .message-group (8px padding), so pull the bar left to line up with grouped ones */
.message-row.msg-ping::before {
  left: -8px;
}
.auth-locked strong { color: #fff; }
