/* ==========================================================================
   1. GLOBAL STYLES, VARIABLES & BASE
   ========================================================================== */
:root {
  --md-primary:              #6750A4;
  --md-on-primary:           #FFFFFF;
  --md-primary-container:    #EADDFF;
  --md-on-primary-container: #21005D;
  --md-secondary:            #625B71;
  --md-secondary-container:  #E8DEF8;
  --md-on-secondary-container: #1D192B;
  --md-tertiary:             #7D5260;
  --md-tertiary-container:   #FFD8E4;
  --md-on-tertiary-container: #31111D;
  --md-error:                #B3261E;
  --md-error-container:      #F9DEDC;
  --md-on-error-container:   #410E0B;
  --md-background:           #FFFBFE;
  --md-surface:              #FFFBFE;
  --md-surface-1:            #F4EFF4;
  --md-surface-2:            #EDE7F6;
  --md-surface-3:            #E8DEF8;
  --md-on-surface:           #1C1B1F;
  --md-on-surface-variant:   #49454F;
  --md-outline:              #79747E;
  --md-outline-variant:      #CAC4D0;
  --md-owner:                #B3261E;
  --md-admin:                #1565C0;
  --md-success:              #2E7D32;
  --md-motion: cubic-bezier(0.2, 0, 0, 1);
}

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

body {
  font-family: 'Google Sans Text', sans-serif;
  background: var(--md-background);
  color: var(--md-on-surface);
  height: 100dvh; 
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Material Symbols Icon Configuration */
.icon {
  font-family: 'Material Symbols Rounded';
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 22px; 
  line-height: 1;
  user-select: none; 
  pointer-events: none;
}
.icon.f { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.icon.sm { font-size: 18px; }
.icon.xs { font-size: 16px; }

/* Custom Scrollbars */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--md-outline-variant); border-radius: 99px; }


/* ==========================================================================
   2. LOGIN SCREEN
   ========================================================================== */
#login-screen {
  position: fixed; 
  inset: 0; 
  z-index: 100;
  background: var(--md-background);
  display: flex; 
  align-items: center; 
  justify-content: center;
}
.login-card {
  background: var(--md-surface-1);
  border-radius: 28px; 
  padding: 48px 40px 40px;
  width: 340px; 
  text-align: center;
  box-shadow: 0 1px 2px #0000001c, 0 2px 6px 2px #0000001a;
}
.login-icon-wrap {
  width: 56px; 
  height: 56px; 
  border-radius: 16px;
  background: var(--md-primary-container);
  display: flex; 
  align-items: center; 
  justify-content: center;
  margin: 0 auto 20px;
}
.login-icon-wrap .icon {
  font-size: 28px; 
  color: var(--md-on-primary-container);
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 28;
}
.login-title { 
  font-family: 'Google Sans', sans-serif; 
  font-size: 24px; 
  font-weight: 700; 
  color: var(--md-on-surface); 
}
.login-title em { 
  font-style: normal; 
  color: var(--md-primary); 
}
.login-sub { 
  font-size: 14px; 
  color: var(--md-on-surface-variant); 
  margin: 8px 0 32px; 
  line-height: 1.5; 
}
.btn-google {
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 10px;
  width: 100%; 
  padding: 10px 24px;
  background: var(--md-primary); 
  color: var(--md-on-primary);
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 14px; 
  font-weight: 500;
  border: none; 
  border-radius: 100px; 
  cursor: pointer;
  position: relative; 
  overflow: hidden; 
  transition: box-shadow .2s;
}
.btn-google::after { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: 100px; 
  background: #fff; 
  opacity: 0; 
  transition: opacity .15s; 
}
.btn-google:hover::after { opacity: .08; }
.btn-google:hover { box-shadow: 0 1px 3px #0000004d, 0 4px 8px 3px #00000026; }


/* ==========================================================================
   3. APP SHELL & SIDEBAR
   ========================================================================== */
#app { 
  display: flex; 
  height: 100dvh; 
  overflow: hidden; 
}

#sidebar {
  width: 264px; 
  min-width: 264px;
  background: var(--md-surface-3);
  display: flex; 
  flex-direction: column;
  overflow: hidden; 
  flex-shrink: 0;
}
.sidebar-header {
  display: flex; 
  align-items: center;
  padding: 12px 8px 4px; 
  gap: 4px; 
  min-height: 64px;
}
.app-logo { 
  font-family: 'Google Sans', sans-serif; 
  font-size: 18px; 
  font-weight: 700; 
  color: var(--md-on-surface); 
  flex: 1; 
  padding-left: 4px; 
}
.app-logo em { 
  font-style: normal; 
  color: var(--md-primary); 
}

.icon-btn {
  width: 40px; 
  height: 40px; 
  border-radius: 100px;
  background: none; 
  border: none; 
  color: var(--md-on-surface-variant);
  display: flex; 
  align-items: center; 
  justify-content: center;
  cursor: pointer; 
  position: relative; 
  overflow: hidden; 
  flex-shrink: 0;
}
.icon-btn::after { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: 100px; 
  background: currentColor; 
  opacity: 0; 
  transition: opacity .15s; 
}
.icon-btn:hover::after { opacity: .08; }
.icon-btn:active::after { opacity: .14; }
.icon-btn.accent { color: var(--md-primary); }

.nav-section { 
  padding: 14px 16px 4px; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
}
.nav-label { 
  font-size: 11px; 
  font-weight: 500; 
  letter-spacing: 1.5px; 
  text-transform: uppercase; 
  color: var(--md-on-surface-variant); 
}
.nav-add-btn { 
  width: 24px; 
  height: 24px; 
  border-radius: 100px; 
  background: none; 
  border: none; 
  color: var(--md-primary); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer; 
}
.nav-add-btn .icon { font-size: 18px; }

#sidebar-scroll { 
  flex: 1; 
  overflow-y: auto; 
  padding: 0 8px 8px; 
  display: flex; 
  flex-direction: column; 
  gap: 2px; 
}

/* Channel Items */
.channel-item {
  display: flex; 
  align-items: center;
  min-height: 40px; 
  border-radius: 100px;
  padding: 0 8px 0 12px; 
  gap: 8px;
  cursor: pointer; 
  position: relative; 
  overflow: hidden; 
  transition: background .15s;
}
.channel-item::after { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: 100px; 
  background: var(--md-on-surface); 
  opacity: 0; 
  transition: opacity .15s; 
}
.channel-item:hover::after { opacity: .08; }
.channel-item:active::after { opacity: .14; }
.channel-item.active { background: var(--md-secondary-container); }
.channel-item.active::after { background: var(--md-on-secondary-container); }
.channel-item.active .ch-label { color: var(--md-on-secondary-container); font-weight: 700; }
.ch-hash { 
  font-size: 15px; 
  font-weight: 700; 
  color: var(--md-on-surface-variant); 
  flex-shrink: 0; 
  font-family: 'Google Sans', sans-serif; 
}
.ch-label { 
  flex: 1; 
  font-size: 13.5px; 
  font-weight: 500; 
  color: var(--md-on-surface-variant); 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}
.ch-badge { 
  background: var(--md-primary); 
  color: #fff; 
  font-size: 10px; 
  font-weight: 700; 
  padding: 1px 5px; 
  border-radius: 100px; 
  flex-shrink: 0; 
}
.ch-lock { font-size: 14px; color: var(--md-on-surface-variant); }

.ch-actions { 
  display: flex; 
  gap: 2px; 
  opacity: 0; 
  transition: opacity .15s; 
  flex-shrink: 0; 
  z-index: 1; 
  position: relative; 
}
.channel-item:hover .ch-actions { opacity: 1; }
.ch-action-btn { 
  width: 26px; 
  height: 26px; 
  border-radius: 100px; 
  background: none; 
  border: none; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer; 
  color: var(--md-on-surface-variant); 
}
.ch-action-btn:hover { background: var(--md-outline-variant); }
.ch-action-btn .icon { font-size: 15px; }
.ch-action-btn.del { color: var(--md-error); }

/* Direct Messages Items */
.dm-item {
  display: flex; 
  align-items: center; 
  gap: 10px;
  min-height: 44px; 
  border-radius: 12px;
  padding: 4px 8px; 
  cursor: pointer; 
  position: relative; 
  overflow: hidden;
  transition: background .15s;
}
.dm-item::after { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: 12px; 
  background: var(--md-on-surface); 
  opacity: 0; 
  transition: opacity .15s; 
}
.dm-item:hover::after { opacity: .08; }
.dm-item.active { background: var(--md-secondary-container); }
.dm-item.active::after { background: var(--md-on-secondary-container); }
.dm-avatar-sm { 
  width: 28px; 
  height: 28px; 
  border-radius: 50%; 
  object-fit: cover; 
  flex-shrink: 0; 
  background: var(--md-surface-2); 
}
.dm-label { 
  flex: 1; 
  font-size: 13px; 
  font-weight: 500; 
  color: var(--md-on-surface-variant); 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}
.dm-item.active .dm-label { color: var(--md-on-secondary-container); font-weight: 700; }
.dm-unread { 
  background: var(--md-primary); 
  color: #fff; 
  font-size: 10px; 
  font-weight: 700; 
  padding: 1px 5px; 
  border-radius: 100px; 
  flex-shrink: 0; 
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 10px 12px; 
  border-top: 1px solid var(--md-outline-variant);
  display: flex; 
  align-items: center; 
  gap: 10px;
}
.user-avatar { 
  width: 34px; 
  height: 34px; 
  border-radius: 50%; 
  object-fit: cover; 
  flex-shrink: 0; 
  background: var(--md-surface-2); 
  cursor: pointer; 
}
.user-info { flex: 1; overflow: hidden; cursor: pointer; }
.user-display-name { 
  font-size: 12.5px; 
  font-weight: 600; 
  color: var(--md-on-surface); 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}
.user-role-text { font-size: 11px; color: var(--md-on-surface-variant); margin-top: 1px; }
.badge-owner { 
  display: inline-block; 
  background: var(--md-tertiary-container); 
  color: var(--md-on-tertiary-container); 
  font-size: 10px; 
  font-weight: 600; 
  padding: 1px 7px; 
  border-radius: 100px; 
}
.badge-admin { 
  display: inline-block; 
  background: #BBDEFB; 
  color: #0D47A1; 
  font-size: 10px; 
  font-weight: 600; 
  padding: 1px 7px; 
  border-radius: 100px; 
}


/* ==========================================================================
   4. CHAT HEADER, LAYOUT & MESSAGES
   ========================================================================== */
#chat-area { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  overflow: hidden; 
  background: var(--md-surface); 
}

.chat-topbar {
  height: 64px; 
  min-height: 64px; 
  padding: 0 8px 0 16px;
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  background: var(--md-surface); 
  border-bottom: 1px solid var(--md-outline-variant);
}
.topbar-left { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.channel-title { 
  font-family: 'Google Sans', sans-serif; 
  font-size: 18px; 
  font-weight: 700; 
  color: var(--md-on-surface); 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}
.channel-title-hash { color: var(--md-primary); }
.topbar-right { display: flex; align-items: center; gap: 4px; }

.btn-tonal {
  display: flex; 
  align-items: center; 
  gap: 6px; 
  padding: 8px 16px 8px 12px;
  background: var(--md-secondary-container); 
  color: var(--md-on-secondary-container);
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 13px; 
  font-weight: 500;
  border: none; 
  border-radius: 100px; 
  cursor: pointer; 
  position: relative; 
  overflow: hidden;
  transition: box-shadow .15s; 
  white-space: nowrap;
}
.btn-tonal::after { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: 100px; 
  background: var(--md-on-secondary-container); 
  opacity: 0; 
  transition: opacity .15s; 
}
.btn-tonal:hover::after { opacity: .08; }
.btn-tonal .icon { font-size: 18px; }

/* Message Container & Empty View */
#messages-container { 
  flex: 1; 
  overflow-y: auto; 
  padding: 8px; 
  display: flex; 
  flex-direction: column; 
}
.no-channel-msg { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  gap: 12px; 
  color: var(--md-on-surface-variant); 
  font-size: 14px; 
  text-align: center; 
}
.no-channel-msg .icon { 
  font-size: 48px; 
  color: var(--md-outline-variant); 
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 48; 
}

/* Discord Style Grouped Layout */
.msg-row {
  display: flex; 
  gap: 12px; 
  padding: 2px 12px; 
  border-radius: 12px;
  transition: background .12s; 
  align-items: flex-start;
}
.msg-row:hover { background: var(--md-surface-1); }
.msg-row.grouped { padding-top: 1px; padding-bottom: 1px; position: relative; }

.msg-avatar { 
  width: 36px; 
  height: 36px; 
  border-radius: 50%; 
  object-fit: cover; 
  flex-shrink: 0; 
  margin-top: 2px; 
  background: var(--md-surface-2); 
  cursor: pointer; 
}
.msg-avatar-spacer { width: 36px; flex-shrink: 0; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }

.msg-author { 
  font-family: 'Google Sans', sans-serif; 
  font-size: 13.5px; 
  font-weight: 700; 
  color: var(--md-on-surface); 
  cursor: pointer; 
}
.msg-author:hover { text-decoration: underline; }
.msg-author.owner-msg { color: var(--md-owner); }
.msg-author.admin-msg { color: var(--md-admin); }

.msg-ts { font-size: 11px; color: var(--md-on-surface-variant); }
.msg-hover-ts { 
  font-size: 10.5px; 
  color: var(--md-on-surface-variant); 
  opacity: 0; 
  transition: opacity .1s; 
  position: absolute; 
  left: 4px; 
  top: 50%; 
  transform: translateY(-50%); 
  white-space: nowrap; 
}
.msg-row.grouped:hover .msg-hover-ts { opacity: 1; }

.msg-content { 
  font-size: 14px; 
  line-height: 1.55; 
  color: var(--md-on-surface); 
  word-break: break-word; 
  white-space: pre-wrap; 
}
.msg-mention { 
  background: var(--md-primary-container); 
  color: var(--md-on-primary-container); 
  border-radius: 4px; 
  padding: 0 3px; 
  font-weight: 600; 
}

/* Actions Menu */
.msg-actions { display: none; gap: 2px; margin-top: 3px; }
.msg-row:hover .msg-actions { display: flex; }
.msg-action-btn { 
  display: inline-flex; 
  align-items: center; 
  gap: 3px; 
  padding: 3px 8px; 
  background: none; 
  border: none; 
  cursor: pointer; 
  border-radius: 100px; 
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 12px; 
  font-weight: 500; 
  color: var(--md-on-surface-variant); 
}
.msg-action-btn:hover { background: var(--md-surface-2); color: var(--md-on-surface); }
.msg-action-btn.del { color: var(--md-error); }
.msg-action-btn:hover.del { background: var(--md-error-container); }
.msg-action-btn .icon { font-size: 14px; }

/* Timeline Dividers */
.date-divider { display: flex; align-items: center; gap: 10px; padding: 12px 12px 4px; }
.date-divider-line { flex: 1; height: 1px; background: var(--md-outline-variant); }
.date-divider-label { 
  font-size: 11px; 
  font-weight: 600; 
  color: var(--md-on-surface-variant); 
  letter-spacing: .3px; 
  white-space: nowrap; 
}

/* Embed Images */
.msg-embed-img { 
  display: block; 
  max-width: min(420px, 100%); 
  max-height: 300px; 
  width: auto; 
  height: auto; 
  border-radius: 12px; 
  margin-top: 6px; 
  border: 1px solid var(--md-outline-variant); 
  cursor: zoom-in; 
  object-fit: contain; 
  background: var(--md-surface-1); 
}
.msg-embed-img:hover { border-color: var(--md-outline); }

/* Badges & Tags */
.role-tag { 
  display: inline-block; 
  font-size: 11px; 
  font-weight: 600; 
  padding: 0 5px; 
  border-radius: 4px; 
  margin-left: 4px; 
}


/* ==========================================================================
   5. INPUT & CHAT PILL
   ========================================================================== */
.chat-input-area { padding: 8px 16px 16px; background: var(--md-surface); }
.chat-input-wrap { position: relative; }
.input-pill {
  display: flex; 
  align-items: flex-end; 
  gap: 4px;
  background: var(--md-surface-1); 
  border-radius: 28px; 
  padding: 6px 6px 6px 20px;
  border: 1px solid var(--md-outline-variant); 
  transition: border-color .15s, background .15s;
}
.input-pill:focus-within { border-color: var(--md-primary); background: var(--md-surface); }

#msg-input {
  flex: 1; 
  background: none; 
  border: none; 
  outline: none; 
  color: var(--md-on-surface);
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 14px; 
  line-height: 1.5;
  resize: none; 
  max-height: 120px; 
  overflow-y: auto; 
  padding: 8px 0;
}
#msg-input::placeholder { color: var(--md-on-surface-variant); }
#msg-input:disabled { opacity: .5; cursor: not-allowed; }

.btn-send {
  width: 40px; 
  height: 40px; 
  border-radius: 100px;
  background: var(--md-primary); 
  color: var(--md-on-primary); 
  border: none; 
  cursor: pointer;
  display: flex; 
  align-items: center; 
  justify-content: center; 
  flex-shrink: 0;
  position: relative; 
  overflow: hidden; 
  transition: box-shadow .15s;
}
.btn-send::after { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: 100px; 
  background: #fff; 
  opacity: 0; 
  transition: opacity .15s; 
}
.btn-send:hover::after { opacity: .08; }
.btn-send:hover { box-shadow: 0 1px 3px #0000004d; }
.btn-send .icon { font-size: 20px; }
.btn-send:disabled { opacity: .4; cursor: not-allowed; }

/* Header Banner States */
.readonly-banner {
  text-align: center; 
  padding: 8px 16px; 
  font-size: 12.5px; 
  color: var(--md-on-surface-variant);
  background: var(--md-surface-1); 
  border: 1px solid var(--md-outline-variant); 
  border-radius: 12px;
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 6px;
}
.muted-banner {
  text-align: center; 
  padding: 8px 16px; 
  font-size: 12.5px; 
  color: var(--md-error);
  background: var(--md-error-container); 
  border-radius: 12px;
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 6px;
}


/* ==========================================================================
   6. DIALOGS & OVERLAYS (MATERIAL DESIGN SCRIM)
   ========================================================================== */
.md-scrim {
  position: fixed; 
  inset: 0; 
  z-index: 200;
  background: #00000052;
  display: flex; 
  align-items: center; 
  justify-content: center;
  animation: fade-in .15s ease;
}
.md-dialog {
  background: var(--md-surface-3); 
  border-radius: 28px; 
  padding: 24px;
  width: 360px; 
  max-width: 92vw; 
  max-height: 85dvh; 
  overflow-y: auto;
  box-shadow: 0 3px 5px #0000001a, 0 6px 10px #0000001a, 0 1px 18px #0000001a;
  animation: slide-up .2s var(--md-motion);
}
.md-dialog.wide { width: 480px; }
.md-dialog.tall { max-height: 90dvh; }

.dialog-icon { 
  color: var(--md-secondary); 
  margin-bottom: 16px; 
  font-size: 28px; 
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 28; 
}
.dialog-title { 
  font-family: 'Google Sans', sans-serif; 
  font-size: 20px; 
  font-weight: 700; 
  color: var(--md-on-surface); 
  margin-bottom: 16px; 
}
.dialog-body { font-size: 14px; color: var(--md-on-surface-variant); line-height: 1.65; }
.dialog-section { 
  font-size: 11px; 
  font-weight: 600; 
  letter-spacing: 1.2px; 
  text-transform: uppercase; 
  color: var(--md-on-surface-variant); 
  margin: 20px 0 8px; 
}
.dialog-row { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  padding: 8px 0; 
  border-bottom: 1px solid var(--md-outline-variant); 
}
.dialog-row:last-child { border-bottom: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* Outlined Text Fields & Custom Dropdowns */
.md-outlined {
  width: 100%; 
  padding: 14px 16px;
  background: var(--md-surface); 
  border: 1px solid var(--md-outline); 
  border-radius: 4px;
  color: var(--md-on-surface); 
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 14px;
  outline: none; 
  transition: border-color .15s, border-width .1s;
}
.md-outlined:focus { border-color: var(--md-primary); border-width: 2px; }
.md-outlined::placeholder { color: var(--md-on-surface-variant); }

.md-select {
  width: 100%; 
  padding: 12px 14px; 
  background: var(--md-surface);
  border: 1px solid var(--md-outline); 
  border-radius: 4px;
  color: var(--md-on-surface); 
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 14px;
  outline: none; 
  cursor: pointer;
}

.md-checkbox { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  cursor: pointer; 
  font-size: 14px; 
  color: var(--md-on-surface); 
}
.md-checkbox input { width: 18px; height: 18px; accent-color: var(--md-primary); cursor: pointer; }

/* Action Buttons */
.btn-text {
  padding: 10px 12px; 
  background: none; 
  border: none; 
  color: var(--md-primary);
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 14px; 
  font-weight: 500;
  cursor: pointer; 
  border-radius: 100px; 
  position: relative; 
  overflow: hidden; 
  transition: background .15s;
}
.btn-text::after { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: 100px; 
  background: var(--md-primary); 
  opacity: 0; 
  transition: opacity .15s; 
}
.btn-text:hover::after { opacity: .08; }
.btn-text.danger { color: var(--md-error); }
.btn-text.danger::after { background: var(--md-error); }

.btn-filled {
  padding: 10px 24px; 
  background: var(--md-primary); 
  color: var(--md-on-primary);
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 14px; 
  font-weight: 500;
  border: none; 
  border-radius: 100px; 
  cursor: pointer; 
  position: relative; 
  overflow: hidden; 
  transition: box-shadow .15s;
}
.btn-filled::after { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: 100px; 
  background: #fff; 
  opacity: 0; 
  transition: opacity .15s; 
}
.btn-filled:hover::after { opacity: .08; }
.btn-filled:hover { box-shadow: 0 1px 3px #0000004d; }
.btn-filled.danger { background: var(--md-error); }


/* ==========================================================================
   7. FLOATING CARDS & PANELS (POPUPS, TOASTS, AC)
   ========================================================================== */

/* Profile Popup Card */
#profile-popup {
  position: fixed; 
  z-index: 400; 
  width: 280px;
  background: var(--md-surface); 
  border-radius: 16px;
  box-shadow: 0 4px 16px #00000030; 
  overflow: hidden;
  animation: slide-up .15s var(--md-motion);
  display: none;
}
.profile-banner { 
  height: 60px; 
  background: linear-gradient(135deg, var(--md-primary), var(--md-tertiary)); 
}
.profile-content { padding: 0 16px 16px; }
.profile-avatar-wrap { margin-top: -24px; margin-bottom: 8px; position: relative; width: fit-content; }
.profile-avatar { 
  width: 52px; 
  height: 52px; 
  border-radius: 50%; 
  border: 3px solid var(--md-surface); 
  object-fit: cover; 
  background: var(--md-surface-2); 
}
.profile-name { font-family: 'Google Sans', sans-serif; font-size: 16px; font-weight: 700; color: var(--md-on-surface); }
.profile-nick { font-size: 12px; color: var(--md-on-surface-variant); margin-top: 2px; }
.profile-bio { font-size: 13px; color: var(--md-on-surface-variant); margin: 8px 0; line-height: 1.5; }
.profile-roles { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.profile-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* Notification Dots & Lists */
#btn-notifs { position: relative; }
.notif-dot {
  position: absolute; 
  top: 6px; 
  right: 6px;
  width: 8px; 
  height: 8px; 
  border-radius: 50%;
  background: var(--md-error); 
  border: 2px solid var(--md-surface-3);
}

#notif-panel {
  position: fixed; 
  right: 12px; 
  top: 70px; 
  z-index: 300;
  width: 320px; 
  max-height: 420px;
  background: var(--md-surface); 
  border-radius: 16px;
  box-shadow: 0 4px 20px #00000025; 
  overflow: hidden;
  display: none; 
  flex-direction: column;
  animation: slide-up .15s var(--md-motion);
}
.notif-panel-header { 
  padding: 14px 16px 10px; 
  font-family: 'Google Sans', sans-serif; 
  font-size: 15px; 
  font-weight: 700; 
  border-bottom: 1px solid var(--md-outline-variant); 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
}
#notif-list { flex: 1; overflow-y: auto; }
.notif-item { 
  padding: 10px 16px; 
  border-bottom: 1px solid var(--md-outline-variant); 
  cursor: pointer; 
  transition: background .12s; 
}
.notif-item:hover { background: var(--md-surface-1); }
.notif-item.unread { background: var(--md-primary-container); }
.notif-item.unread:hover { background: var(--md-secondary-container); }
.notif-sender { font-size: 12.5px; font-weight: 600; color: var(--md-on-surface); }
.notif-preview { 
  font-size: 12px; 
  color: var(--md-on-surface-variant); 
  margin-top: 2px; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}
.notif-time { font-size: 10.5px; color: var(--md-outline); margin-top: 2px; }
.notif-empty { padding: 32px 16px; text-align: center; font-size: 13px; color: var(--md-on-surface-variant); }

/* Members List Panel */
#members-panel {
  width: 220px; 
  min-width: 220px; 
  background: var(--md-surface-1);
  border-left: 1px solid var(--md-outline-variant);
  display: flex; 
  flex-direction: column; 
  overflow: hidden;
}
#members-panel.hidden { display: none; }
.members-header { 
  padding: 14px 16px 8px; 
  font-size: 11px; 
  font-weight: 600; 
  letter-spacing: 1.2px; 
  text-transform: uppercase; 
  color: var(--md-on-surface-variant); 
}
#members-list { 
  flex: 1; 
  overflow-y: auto; 
  padding: 0 8px 8px; 
  display: flex; 
  flex-direction: column; 
  gap: 2px; 
}
.member-item { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  padding: 5px 8px; 
  border-radius: 8px; 
  cursor: pointer; 
  transition: background .12s; 
}
.member-item:hover { background: var(--md-surface-2); }
.member-avatar-sm { 
  width: 28px; 
  height: 28px; 
  border-radius: 50%; 
  object-fit: cover; 
  flex-shrink: 0; 
  background: var(--md-surface-2); 
}
.member-name { 
  font-size: 13px; 
  font-weight: 500; 
  color: var(--md-on-surface-variant); 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}
.member-item.muted-user .member-name { color: var(--md-outline); text-decoration: line-through; }

/* Rules Section Styles */
.rule-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.rule-row:last-child { margin-bottom: 0; }
.rule-num { 
  width: 22px; 
  height: 22px; 
  border-radius: 100px; 
  background: var(--md-primary-container); 
  color: var(--md-on-primary-container); 
  font-size: 11px; 
  font-weight: 700; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  flex-shrink: 0; 
  margin-top: 2px; 
}
.rule-text { font-size: 13.5px; color: var(--md-on-surface-variant); line-height: 1.6; }
.rule-text b { color: var(--md-on-surface); }

/* Switch Toggle Switches */
.md-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.md-switch input[type=checkbox] { width: 0; height: 0; opacity: 0; position: absolute; }
.md-switch-track { 
  width: 48px; 
  height: 28px; 
  border-radius: 100px; 
  background: var(--md-outline-variant); 
  position: relative; 
  transition: background .2s; 
  flex-shrink: 0; 
  cursor: pointer; 
}
.md-switch-track::after { 
  content: ''; 
  position: absolute; 
  width: 20px; 
  height: 20px; 
  border-radius: 50%; 
  background: #fff; 
  top: 4px; 
  left: 4px; 
  transition: left .2s, width .1s; 
}
.md-switch input:checked + .md-switch-track { background: var(--md-primary); }
.md-switch input:checked + .md-switch-track::after { left: 24px; }
.md-switch-label { font-size: 14px; color: var(--md-on-surface); flex: 1; }

/* Mention Autocomplete Block */
#mention-autocomplete {
  position: absolute; 
  bottom: 100%; 
  left: 0; 
  right: 0;
  background: var(--md-surface); 
  border-radius: 12px; 
  padding: 6px;
  box-shadow: 0 2px 12px #00000020; 
  display: none; 
  max-height: 180px; 
  overflow-y: auto; 
  z-index: 10;
}
.mention-ac-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.mention-ac-item:hover, .mention-ac-item.selected { background: var(--md-surface-2); }
.mention-ac-item img { width: 24px; height: 24px; border-radius: 50%; }
.mention-ac-name { font-size: 13px; font-weight: 500; color: var(--md-on-surface); }


/* ==========================================================================
   8. TABS, LIGHTBOX, SNACKBAR & UTILS
   ========================================================================== */

/* Settings Panels Tab Controls */
.settings-tabs { display: flex; border-bottom: 1px solid var(--md-outline-variant); margin: -24px -24px 20px; }
.settings-tab { 
  flex: 1; 
  padding: 14px 8px; 
  border: none; 
  background: none; 
  cursor: pointer; 
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 13px; 
  font-weight: 500; 
  color: var(--md-on-surface-variant); 
  border-bottom: 2px solid transparent; 
  transition: color .15s, border-color .15s; 
}
.settings-tab.active { color: var(--md-primary); border-bottom-color: var(--md-primary); }

/* Embed API Block */
.api-code-block { 
  background: var(--md-surface-2); 
  border-radius: 8px; 
  padding: 10px 14px; 
  font-family: monospace; 
  font-size: 12px; 
  color: var(--md-on-surface); 
  overflow-x: auto; 
  white-space: pre; 
  margin: 8px 0; 
  border: 1px solid var(--md-outline-variant); 
}

/* Lightbox Image Previewer */
#lightbox { 
  position: fixed; 
  inset: 0; 
  z-index: 500; 
  background: #000000cc; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: zoom-out; 
  animation: fade-in .15s ease; 
}
#lightbox img { 
  max-width: 94vw; 
  max-height: 92dvh; 
  border-radius: 8px; 
  object-fit: contain; 
  box-shadow: 0 8px 32px #00000080; 
}
#lightbox-close { 
  position: absolute; 
  top: 16px; 
  right: 16px; 
  width: 40px; 
  height: 40px; 
  border-radius: 100px; 
  background: #ffffff22; 
  border: none; 
  color: #fff; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer; 
  font-size: 22px; 
}
#lightbox-close:hover { background: #ffffff44; }

/* Global Snackbar Alert Toast */
#snackbar {
  position: fixed; 
  bottom: 24px; 
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #322F37; 
  color: #ECE6F0;
  font-family: 'Google Sans Text', sans-serif; 
  font-size: 14px; 
  padding: 14px 20px; 
  border-radius: 4px;
  box-shadow: 0 3px 5px #0000001a; 
  z-index: 600; 
  pointer-events: none;
  transition: transform .25s var(--md-motion), opacity .25s; 
  opacity: 0; 
  white-space: nowrap; 
  max-width: 90vw;
}
#snackbar.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* Transitions & Animations */
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.msg-in { animation: slide-up .16s var(--md-motion); }


/* ==========================================================================
   9. RESPONSIVE MOBILE BREAKPOINTS
   ========================================================================== */
.hamburger { display: none !important; }

@media (max-width: 700px) {
  #sidebar { 
    position: fixed; 
    left: 0; 
    top: 0; 
    bottom: 0; 
    z-index: 50; 
    transform: translateX(-100%); 
    transition: transform .3s var(--md-motion); 
    box-shadow: 2px 0 8px #00000020; 
  }
  #sidebar.open { transform: translateX(0); }
  .hamburger { display: flex !important; }
  #chat-area { width: 100%; }
  #members-panel { display: none !important; }
}


/* ==========================================================================
   10. WEB APPS OVERRIDES (EMBED & PORTALS)
   ========================================================================== */
body.is-embed #sidebar { display: none !important; }
body.is-embed .hamburger { display: none !important; }
body.is-embed.hide-header .chat-topbar { display: none !important; }
body.is-embed #chat-area { width: 100% !important; flex: 1; }


/* ==========================================================================
   11. BRANDED CORE THEMES (TERMINAL / ADMIN SMP)
   ========================================================================== */
body.theme-terminal {
  --md-primary: #ff4444;
  --md-on-primary: #ffffff;
  --md-primary-container: #331111;
  --md-on-primary-container: #ff4444;
  --md-background: #151515;
  --md-surface: #151515;
  --md-surface-1: #101010;
  --md-surface-2: #1a1a1a;
  --md-surface-3: #222222;
  --md-on-surface: #cccccc;
  --md-on-surface-variant: #888888;
  --md-outline: #555555;
  --md-outline-variant: #2a2a2a;
  --md-owner: #ff4444;
  --md-admin: #ff8800;
}

body.theme-terminal,
body.theme-terminal input,
body.theme-terminal textarea,
body.theme-terminal button {
  font-family: monospace !important;
}

body.theme-terminal .chat-topbar { border-bottom: 2px solid var(--md-outline-variant); }
body.theme-terminal #messages-container { 
  background: #101010; 
  border: 1px solid var(--md-outline-variant); 
  margin: 12px; 
  padding: 12px; 
  border-radius: 0; 
}
body.theme-terminal .chat-input-area { padding: 0 12px 12px; }

/* Sharp Edges Terminal Inputs */
body.theme-terminal .input-pill { border-radius: 0; border: 1px solid #333; background: #101010; }
body.theme-terminal .input-pill:focus-within { border-color: #ff4444; }
body.theme-terminal .btn-send { 
  border-radius: 0; 
  background: #ff4444; 
  font-weight: bold; 
  width: auto; 
  padding: 0 16px; 
  border: none; 
}
body.theme-terminal .btn-send .icon { display: none; }
body.theme-terminal .btn-send::before { content: "Send"; font-family: monospace; font-size: 0.9em; }

/* Flat Message Blocks styling */
body.theme-terminal .msg-avatar,
body.theme-terminal .msg-avatar-spacer { display: none !important; }
body.theme-terminal .msg-row { border-radius: 0; padding: 4px 8px; align-items: baseline; }
body.theme-terminal .msg-row:hover { background: transparent; }
body.theme-terminal .msg-meta { display: inline-flex; flex-direction: row-reverse; gap: 6px; margin: 0 6px 0 0; }
body.theme-terminal .msg-author { color: #ff4444; }
body.theme-terminal .msg-author::after { content: ":"; color: #ccc; }
body.theme-terminal .msg-ts { color: #444; font-size: 0.85em; }
body.theme-terminal .msg-content { display: inline; word-break: break-word; color: #ccc; }
body.theme-terminal .role-tag { display: none; } /* Hide heavy graphical pill labels */