/* ============================================================
   LARPER — Main Stylesheet
   Dark Charcoal + Crimson Red Community Platform
   ============================================================ */

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

:root {
  /* Core backgrounds */
  --bg:         #100D10;
  --bg2:        #16121A;
  --panel:      #21171B;
  --panel2:     #2A1E24;
  --surface:    #2E2028;
  --surface2:   #3A2832;

  /* Brand */
  --red:        #E5394F;
  --red-lt:     #FF6B82;
  --red-dk:     #B22B3E;
  --red-glow:   rgba(229, 57, 79, 0.35);

  /* Text */
  --text:       #F5F2F3;
  --text2:      #C4B0B8;
  --text3:      #7A6572;
  --text4:      #4A3842;

  /* Accents */
  --green:      #4ADE80;
  --yellow:     #FBBF24;
  --blue:       #60A5FA;
  --purple:     #A78BFA;
  --orange:     #FB923C;

  /* Borders */
  --border:     rgba(229, 57, 79, 0.12);
  --border2:    rgba(255, 255, 255, 0.07);

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,.5);
  --shadow-md:  0 4px 20px rgba(0,0,0,.6);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.7);
  --red-shadow: 0 4px 20px rgba(229,57,79,.3);

  /* Sizes */
  --rail-w:     68px;
  --sidebar-w:  240px;
  --member-w:   240px;
  --topbar-h:   48px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  22px;
}

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }
input, textarea, select { font-family: inherit; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--red-dk); }

/* ── App Shell Layout (Discord-inspired, original design) ── */
.app-shell {
  display: grid;
  grid-template-columns: var(--rail-w) var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "rail topbar topbar"
    "rail sidebar main";
  height: 100vh;
  overflow: hidden;
}

.app-shell.member-open {
  grid-template-columns: var(--rail-w) var(--sidebar-w) 1fr var(--member-w);
  grid-template-areas:
    "rail topbar topbar topbar"
    "rail sidebar main members";
}

/* ── Top Bar ─────────────────────────────────────────────── */
.top-bar {
  grid-area: topbar;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 100;
  height: var(--topbar-h);
  position: sticky;
  top: 0;
}
.top-bar-left { display: flex; align-items: center; gap: .8rem; min-width: 0; overflow: hidden; }
.top-bar-right { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.top-channel-name { font-weight: 700; font-size: .95rem; color: var(--text); white-space: nowrap; }
.top-channel-topic { font-size: .8rem; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 1px solid var(--border2); padding-left: .8rem; max-width: 400px; }
.top-badge { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: .6rem; font-weight: 800; min-width: 16px; height: 16px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.top-btn { position: relative; }
.mobile-menu-btn { display: none; }

/* ── Server Rail ─────────────────────────────────────────── */
.server-rail {
  grid-area: rail;
  background: var(--bg);
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .5rem 0;
  gap: .3rem;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  z-index: 200;
}

.rail-logo {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  margin-bottom: .3rem;
  transition: border-radius .2s, transform .2s, box-shadow .2s;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(229,57,79,.25);
}
.rail-logo:hover { border-radius: var(--radius-xl); transform: scale(1.06); box-shadow: 0 0 24px rgba(229,57,79,.45); }
.rail-logo-img { width: 100%; height: 100%; object-fit: cover; }

.rail-separator { width: 32px; height: 2px; background: var(--border2); border-radius: 2px; margin: .15rem 0; flex-shrink: 0; }

.rail-servers { display: flex; flex-direction: column; align-items: center; gap: .35rem; width: 100%; padding: 0 .5rem; flex: 1; }

.server-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-radius .2s, transform .2s;
  border: 2px solid transparent;
  position: relative;
}
.server-icon:hover { border-radius: var(--radius-xl); transform: scale(1.05); border-color: var(--red); }
.server-icon.active { border-radius: var(--radius-xl); border-color: var(--red); box-shadow: 0 0 0 2px var(--red-glow); }
.server-icon-img { width: 100%; height: 100%; object-fit: cover; }
.server-icon-fallback {
  width: 100%; height: 100%;
  background: var(--panel2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; color: var(--text2);
}
.server-icon .rail-unread-dot {
  position: absolute;
  left: -8px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px;
  background: var(--text);
  border-radius: 50%;
}

.rail-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
  position: relative;
}
.rail-btn:hover { background: var(--red); color: #fff; border-color: var(--red); border-radius: var(--radius-xl); }
.rail-add { color: var(--green); border-color: rgba(74, 222, 128, .2); }
.rail-add:hover { background: var(--green); border-color: var(--green); }
.rail-badge { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: .6rem; font-weight: 800; min-width: 16px; height: 16px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }

.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding-bottom: .3rem; }

.rail-avatar-wrap { position: relative; cursor: pointer; }
.rail-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border2);
  transition: border-color .2s;
}
.rail-avatar:hover { border-color: var(--red); }
.presence-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg);
}
.presence-dot.online  { background: var(--green); }
.presence-dot.idle    { background: var(--yellow); }
.presence-dot.dnd     { background: var(--red); }
.presence-dot.offline { background: var(--text4); }

/* ── Channel Sidebar ─────────────────────────────────────── */
.channel-sidebar {
  grid-area: sidebar;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: visible;
  border-right: 1px solid var(--border);
  z-index: 100;
  min-height: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header #sidebarServerName { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-header-actions { display: flex; gap: .3rem; flex-shrink: 0; }

.channel-list { flex: 1; overflow-y: auto; padding: .5rem 0; }

.channel-category {
  padding: .6rem .8rem .2rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  user-select: none;
}
.channel-category-name { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); flex: 1; }
.channel-category-add { color: var(--text3); opacity: 0.8; transition: opacity .2s, color .2s, transform .15s; font-size: 1.15rem; padding: 0 4px; cursor: pointer; line-height: 1; }
.channel-category:hover .channel-category-add { opacity: 1; color: var(--text); transform: scale(1.15); }
.channel-category:hover .channel-category-name { color: var(--text2); }

.channel-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .8rem;
  margin: .05rem .5rem;
  border-radius: var(--radius-sm);
  color: var(--text3);
  cursor: pointer;
  transition: all .15s;
  font-size: .9rem;
  font-weight: 500;
  position: relative;
}
.channel-item:hover { background: var(--surface); color: var(--text2); }
.channel-item.active { background: var(--surface2); color: var(--text); }
.channel-item.active::before { content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%); width: 4px; height: 18px; background: var(--red); border-radius: 0 3px 3px 0; }
.channel-item.unread { color: var(--text); font-weight: 700; }
.channel-icon { font-size: .85rem; flex-shrink: 0; color: var(--text4); }
.channel-item.active .channel-icon, .channel-item:hover .channel-icon { color: var(--text2); }
.channel-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-unread-badge { background: var(--red); color: #fff; font-size: .65rem; font-weight: 800; min-width: 16px; height: 16px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

.channel-action-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text4);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  transition: all .15s ease;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin-left: 4px;
}
.channel-action-btn svg {
  display: block;
}
.channel-item:hover .channel-action-btn {
  display: inline-flex;
}
.channel-action-btn:hover {
  color: var(--danger, #f04747);
  background: rgba(240, 71, 71, 0.15);
}
@media (hover: none) {
  .channel-action-btn {
    display: inline-flex;
    opacity: 0.7;
  }
}

.channel-item-wrap {
  display: flex;
  flex-direction: column;
}
.channel-item.voice-ch.connected {
  color: var(--green);
}
.channel-item.voice-ch.connected .channel-icon {
  color: var(--green);
}
.voice-count-badge {
  background: rgba(74, 222, 128, 0.2);
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: auto;
}
.voice-channel-users {
  display: flex;
  flex-direction: column;
  padding-left: 2rem;
  padding-right: 0.5rem;
  gap: 2px;
}
.voice-user-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text3);
  transition: all 0.15s ease;
}
.voice-user-entry:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text2);
}
.voice-user-avatar-wrap {
  position: relative;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.voice-user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  transition: box-shadow 0.15s ease;
}
.voice-user-avatar.default-avatar {
  background: var(--surface2);
  color: var(--text2);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voice-user-entry.speaking .voice-user-avatar {
  box-shadow: 0 0 0 2px var(--green);
}
.voice-live-dot {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--red);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 0 3px;
  border-radius: 3px;
  line-height: 1.2;
}
.voice-user-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-user-icons {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  opacity: 0.8;
}

.sidebar-voice-status {
  padding: 0.55rem 0.75rem;
  background: rgba(74, 222, 128, 0.08);
  border-top: 1px solid rgba(74, 222, 128, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text2);
  flex-shrink: 0;
}
.sidebar-voice-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 0;
  flex: 1;
}
.sidebar-voice-info:hover .sidebar-voice-sub {
  color: var(--green);
}
.sidebar-voice-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sidebar-voice-title {
  font-size: 0.72rem;
  color: var(--green);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sidebar-voice-sub {
  font-size: 0.8rem;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}
.sidebar-voice-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}
.voice-mini-btn {
  background: transparent;
  border: none;
  color: var(--text3);
  width: 26px;
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  transition: all 0.15s ease;
}
.voice-mini-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.voice-mini-btn.active-red {
  background: rgba(229, 57, 79, 0.2);
  color: var(--red-lt);
}
.voice-mini-btn.active-green {
  background: rgba(74, 222, 128, 0.2);
  color: var(--green);
}
.voice-mini-btn.disconnect-btn:hover {
  background: rgba(229, 57, 79, 0.25);
  color: var(--red-lt);
}
.voice-connected-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

/* ── Main Area ───────────────────────────────────────────── */
.main-area {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg2);
  position: relative;
  min-height: 0;
}

.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--text3);
}
.welcome-screen h2 { font-size: 1.4rem; color: var(--text2); margin-bottom: .5rem; }

/* ── Chat Area ───────────────────────────────────────────── */
.chat-area { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.chat-header {
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-shrink: 0;
  min-height: 48px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}

.messages-loading { display: flex; justify-content: center; padding: 2rem; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border2); border-top-color: var(--red); border-radius: 50%; animation: spin 1s linear infinite; }

#messagesList { display: flex; flex-direction: column; }

/* Message groups */
.msg-group { padding: .1rem 1rem .1rem; }
.msg-group:hover { background: rgba(255,255,255,.02); }

.msg-header { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .1rem; }
.msg-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0; cursor: pointer; transition: opacity .2s; }
.msg-avatar:hover { opacity: .85; }
.msg-first-row { display: flex; align-items: flex-start; gap: .8rem; padding: .4rem 1rem .1rem; }
.msg-first-row .msg-avatar { margin-top: 1px; }

.msg-author-name { font-weight: 700; font-size: .9rem; cursor: pointer; }
.msg-author-name:hover { text-decoration: underline; }
.msg-timestamp { font-size: .72rem; color: var(--text4); }

.msg-content-wrap { padding-left: 54px; /* avatar + gap */ }
.msg-content {
  font-size: .92rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-content:empty { display: none; }
.msg-content.deleted { color: var(--text4); font-style: italic; }
.msg-edited-tag { font-size: .72rem; color: var(--text4); margin-left: .3rem; }

.msg-attachment img { max-width: 400px; max-height: 300px; border-radius: var(--radius-sm); margin-top: .4rem; cursor: pointer; }

.msg-reactions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; padding-left: 54px; }
.reaction-btn {
  display: flex; align-items: center; gap: .3rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .82rem;
  cursor: pointer; transition: all .15s;
}
.reaction-btn:hover { border-color: var(--red); background: var(--surface2); }
.reaction-btn.mine { border-color: var(--red); background: rgba(229,57,79,.12); color: var(--red-lt); }

.msg-actions { display: none; position: absolute; right: 1rem; top: 0; transform: translateY(-50%); background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .2rem .3rem; gap: .1rem; flex-direction: row; }
.msg-group:hover .msg-actions { display: flex; }
.msg-action-btn { padding: .25rem .4rem; border-radius: 4px; color: var(--text3); font-size: .8rem; transition: all .15s; cursor: pointer; }
.msg-action-btn:hover { background: var(--surface2); color: var(--text); }

.msg-reply-preview {
  display: flex; align-items: center; gap: .5rem;
  padding: .2rem 1rem .2rem 54px;
  font-size: .8rem; color: var(--text3);
  border-left: 2px solid var(--border2);
  margin-left: 54px;
  margin-bottom: .1rem;
  cursor: pointer;
}
.msg-reply-preview:hover { color: var(--text2); }

.announcement-banner-msg {
  background: linear-gradient(135deg, rgba(229,57,79,.1), rgba(229,57,79,.05));
  border-left: 3px solid var(--red);
  margin: .5rem 1rem;
  border-radius: var(--radius-sm);
  padding: .5rem .8rem;
}

/* Load more */
.load-more-btn {
  align-self: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem 1.2rem;
  color: var(--text3);
  font-size: .82rem;
  cursor: pointer;
  margin: .5rem auto;
  transition: all .2s;
}
.load-more-btn:hover { border-color: var(--red); color: var(--text); }

/* System messages */
.system-msg { text-align: center; color: var(--text4); font-size: .8rem; padding: .3rem 1rem; font-style: italic; }

/* ── Composer ────────────────────────────────────────────── */
.chat-composer { padding: .4rem 1rem .75rem; flex-shrink: 0; position: relative; }
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: .3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem .4rem;
  transition: border-color .2s;
}
.composer-row:focus-within { border-color: rgba(229,57,79,.5); }

.composer-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
  font-size: .88rem;
  background: none;
  border: none;
  cursor: pointer;
}
.composer-btn:hover { color: var(--red-lt); background: rgba(229,57,79,.1); }
.composer-btn .gif-label {
  font-size: .72rem; font-weight: 800; letter-spacing: .03em;
  background: linear-gradient(135deg, var(--red), var(--red-lt));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.composer-input-wrap { flex: 1; min-width: 0; }
.composer-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: .92rem;
  resize: none;
  max-height: 180px;
  padding: .35rem .3rem;
  line-height: 1.4;
  font-family: inherit;
}
.composer-input::placeholder { color: var(--text4); }

.composer-send {
  width: 34px; height: 34px;
  background: var(--red);
  border-radius: var(--radius-sm);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
  border: none;
  cursor: pointer;
}
.composer-send:hover { background: var(--red-lt); transform: scale(1.05); }

.typing-indicator {
  font-size: .78rem; color: var(--text3);
  padding: .15rem .3rem;
  min-height: 1.1rem;
  margin-bottom: .2rem;
}

/* ── Member Sidebar ──────────────────────────────────────── */
.member-sidebar {
  grid-area: members;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.member-sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.member-list { flex: 1; overflow-y: auto; padding: .5rem 0; }
.member-section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); padding: .5rem 1rem .2rem; }
.member-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .35rem 1rem;
  cursor: pointer; transition: background .15s;
  border-radius: var(--radius-sm);
  margin: .05rem .5rem;
}
.member-item:hover { background: var(--surface); }
.member-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; position: relative; }
.member-name { font-size: .88rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-role-color { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── User Dropdown ───────────────────────────────────────── */
.user-dropdown {
  position: fixed;
  bottom: 12px;
  left: calc(var(--rail-w) + 8px);
  min-width: 220px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
}
.dropdown-user-header { padding: .6rem 1rem .4rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.dropdown-user-header .d-username { font-weight: 700; font-size: .95rem; }
.dropdown-user-header .d-tag { font-size: .78rem; color: var(--text3); }
.dropdown-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .8rem;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer; transition: all .15s;
  border: none; background: none; width: 100%; text-align: left;
}
.dropdown-item:hover { background: var(--surface); color: var(--text); }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: .3rem 0; }
.logout-item { color: var(--red-lt); }
.logout-item:hover { background: rgba(229,57,79,.12); color: var(--red-lt); }

/* ── Notification Panel ──────────────────────────────────── */
.notif-panel {
  position: fixed;
  top: var(--topbar-h);
  right: .5rem;
  width: 320px;
  max-height: 460px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}
.notif-panel-header { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.notif-panel-header h3 { font-size: .9rem; font-weight: 700; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item { padding: .7rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; font-size: .84rem; }
.notif-item:hover { background: var(--surface); }
.notif-item.unread { border-left: 2px solid var(--red); }
.notif-item .notif-text { color: var(--text2); }
.notif-item .notif-time { font-size: .72rem; color: var(--text4); margin-top: .15rem; }
.empty-notif { padding: 2rem; text-align: center; color: var(--text3); font-size: .88rem; }
.panel-overlay { position: fixed; inset: 0; z-index: 9998; }

/* ── Auth Shell ──────────────────────────────────────────── */
.auth-shell {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(229,57,79,.08) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(229,57,79,.05) 0%, transparent 50%),
    var(--bg);
  padding: 1rem;
  overflow-y: auto;
  z-index: 5000;
}
.auth-shell.hidden { display: none !important; }

.auth-card {
  background: var(--panel);
  border: 1px solid rgba(229,57,79,.18);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 48px rgba(0,0,0,.6), 0 0 0 1px rgba(229,57,79,.08);
  margin: auto;
}
.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.8rem;
}
.auth-logo img {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow: 0 0 28px rgba(229,57,79,.4);
}
.auth-logo-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .04em;
}
.auth-title { font-size: 1.3rem; font-weight: 700; margin-bottom: .3rem; text-align: center; }
.auth-sub { font-size: .88rem; color: var(--text3); text-align: center; margin-bottom: 1.5rem; }
.auth-switch { text-align: center; font-size: .88rem; color: var(--text3); margin-top: 1.2rem; }
.auth-switch a { color: var(--red-lt); cursor: pointer; }
.auth-switch a:hover { text-decoration: underline; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text2); margin-bottom: .35rem; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: .6rem .9rem;
  color: var(--text);
  font-size: .92rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(229,57,79,.15);
}
.form-input::placeholder { color: var(--text4); }
.form-select { cursor: pointer; }
.form-select option { background: var(--panel); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-error { font-size: .8rem; color: var(--red-lt); margin-top: .3rem; }
.form-hint { font-size: .78rem; color: var(--text3); margin-top: .3rem; }
.form-check { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .88rem; color: var(--text2); user-select: none; }
.form-check input { width: 15px; height: 15px; accent-color: var(--red); cursor: pointer; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: .9rem;
  cursor: pointer; transition: all .2s;
  white-space: nowrap; border: none;
}
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 4px 14px rgba(229,57,79,.35); }
.btn-primary:hover { background: var(--red-lt); transform: translateY(-1px); box-shadow: var(--red-shadow); }
.btn-secondary { background: var(--surface); color: var(--text2); border: 1px solid var(--border2); }
.btn-secondary:hover { border-color: var(--red); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text3); border: 1px solid var(--border2); }
.btn-ghost:hover { color: var(--text); border-color: var(--text3); }
.btn-danger { background: var(--red-dk); color: #fff; }
.btn-danger:hover { background: var(--red); }
.btn-green { background: rgba(74,222,128,.2); color: var(--green); border: 1px solid rgba(74,222,128,.3); }
.btn-green:hover { background: rgba(74,222,128,.3); }
.btn-sm { padding: .35rem .9rem; font-size: .82rem; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-link { background: none; border: none; color: var(--red-lt); font-size: .85rem; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.icon-btn { width: 30px; height: 30px; border-radius: var(--radius-sm); color: var(--text3); display: flex; align-items: center; justify-content: center; transition: all .15s; }
.icon-btn:hover { background: var(--surface2); color: var(--text); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 32px; height: 32px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: .85rem; cursor: pointer; transition: all .2s;
}
.modal-close:hover { background: var(--red); color: #fff; border-color: var(--red); }
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.2rem; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.2rem; right: 1.2rem; display: flex; flex-direction: column; gap: .5rem; z-index: 99999; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem;
  background: var(--panel2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: .88rem; font-weight: 600;
  min-width: 240px; max-width: 360px;
  box-shadow: var(--shadow-md);
  animation: slideInRight .3s ease;
  pointer-events: all;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast.warning { border-left: 3px solid var(--yellow); }

/* ── DM Area ─────────────────────────────────────────────── */
.dm-area { display: flex; height: 100%; overflow: hidden; }
.dm-list { width: 240px; border-right: 1px solid var(--border); flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden; }
.dm-list-header { padding: .8rem 1rem; font-weight: 700; font-size: .88rem; color: var(--text2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.dm-list-items { flex: 1; overflow-y: auto; }
.dm-item { display: flex; align-items: center; gap: .7rem; padding: .5rem .8rem; cursor: pointer; border-radius: var(--radius-sm); margin: .1rem .4rem; transition: background .15s; }
.dm-item:hover { background: var(--surface); }
.dm-item.active { background: var(--surface2); }
.dm-item-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; position: relative; }
.dm-item-name { font-size: .9rem; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-item-preview { font-size: .78rem; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Settings Area ───────────────────────────────────────── */
.settings-area {
  padding: 2rem;
  overflow-y: auto;
  max-width: 700px;
  width: 100%;
  height: 100%;
}
.settings-section { margin-bottom: 2rem; }
.settings-section h3 { font-size: 1rem; font-weight: 700; color: var(--text2); margin-bottom: 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }

/* ── Admin Area ──────────────────────────────────────────── */
.admin-area {
  padding: 2rem;
  overflow-y: auto;
  height: 100%;
  width: 100%;
}
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.admin-stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; text-align: center; }
.admin-stat-card .stat-num { font-size: 2rem; font-weight: 800; color: var(--red-lt); }
.admin-stat-card .stat-lbl { font-size: .78rem; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.admin-table th { text-align: left; padding: .6rem 1rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); background: var(--bg); border-bottom: 1px solid var(--border); }
.admin-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); color: var(--text2); }
.admin-table tr:hover td { background: var(--surface); }

/* ── GIF Picker ──────────────────────────────────────────── */
.gif-picker {
  position: absolute;
  bottom: calc(100% + .4rem);
  left: 0;
  right: 0;
  max-width: 380px;
  max-height: 400px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}
.gif-search { padding: .4rem .5rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.gif-search-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: .35rem .7rem;
  color: var(--text); font-size: .88rem; outline: none;
}
.gif-search-input:focus { border-color: var(--red); }
.gif-grid {
  flex: 1; overflow-y: auto; padding: .4rem;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem;
}
.gif-item { aspect-ratio: 16/9; border-radius: 4px; overflow: hidden; cursor: pointer; background: var(--surface); }
.gif-item img { width: 100%; height: 100%; object-fit: cover; transition: opacity .2s; }
.gif-item:hover img { opacity: .82; }
.gif-no-key { padding: 1rem; text-align: center; color: var(--text3); font-size: .84rem; grid-column: 1/-1; }

/* ── Emoji Picker ────────────────────────────────────────── */
.emoji-picker {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem;
  display: flex; flex-wrap: wrap; gap: .15rem;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  max-width: 300px;
  max-height: 220px;
}
.emoji-item {
  font-size: 1.3rem; cursor: pointer;
  padding: .2rem; border-radius: 4px;
  transition: background .1s; line-height: 1;
  user-select: none;
}
.emoji-item:hover { background: var(--surface2); }

/* ── Invite Preview ──────────────────────────────────────── */
.invite-preview-card { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.invite-server-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover; }
.invite-server-name { font-weight: 700; }
.invite-server-members { font-size: .82rem; color: var(--text3); }

/* ── Profile Card (hover popup) ──────────────────────────── */
.profile-popup {
  position: fixed;
  z-index: 9999;
  width: 280px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.profile-popup-banner { height: 60px; background: linear-gradient(135deg, var(--red-dk), var(--panel)); }
.profile-popup-banner img { width: 100%; height: 100%; object-fit: cover; }
.profile-popup-body { padding: .8rem 1rem 1rem; }
.profile-popup-avatar { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--panel2); object-fit: cover; margin-top: -28px; margin-bottom: .5rem; }
.profile-popup-name { font-weight: 700; font-size: 1rem; }
.profile-popup-tag  { font-size: .78rem; color: var(--text3); }
.profile-popup-bio  { font-size: .84rem; color: var(--text2); margin-top: .5rem; word-break: break-word; }
.profile-popup-roles { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .7rem; }
.profile-popup-role { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface); font-weight: 600; }
.profile-popup-actions { display: flex; gap: .5rem; margin-top: .8rem; }

/* ── Skeleton loaders ────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }
.skeleton-msg { height: 16px; margin: .3rem 0; border-radius: 4px; }
.skeleton-avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; }
.tab-btn { padding: .5rem 1rem; font-size: .88rem; font-weight: 600; color: var(--text3); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .2s; }
.tab-btn:hover { color: var(--text2); }
.tab-btn.active { color: var(--red-lt); border-bottom-color: var(--red); }

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text3); }
.text-red { color: var(--red-lt); }
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-sm { font-size: .84rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text3); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }
.empty-state h3 { font-size: 1.1rem; color: var(--text2); margin-bottom: .4rem; }

/* ── Voice Channel Placeholder ───────────────────────────── */
/* ── Voice Stage & Video ─────────────────────────────────── */
.voice-stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg2);
  position: relative;
  overflow: hidden;
}

.voice-stage-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  flex-shrink: 0;
}

.voice-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.voice-header-icon {
  font-size: 1.8rem;
  color: var(--green);
}

.voice-header-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.voice-header-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.voice-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.voice-badge.connected {
  background: rgba(74, 222, 128, 0.15);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.voice-badge.p2p {
  background: rgba(229, 57, 79, 0.12);
  color: var(--red-lt);
  border: 1px solid rgba(229, 57, 79, 0.25);
}

.voice-badge.count {
  background: var(--surface2);
  color: var(--text2);
}

.voice-stage-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
}

.voice-stage-content.has-screen {
  justify-content: flex-start;
}

/* Screen Share Player Card */
.voice-screen-player-card {
  width: 100%;
  max-width: 1100px;
  background: #08080c;
  border: 1px solid rgba(229, 57, 79, 0.3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

.voice-screen-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(20, 20, 28, 0.95);
  border-bottom: 1px solid var(--border);
}

.voice-screen-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.voice-live-tag {
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  animation: pulse 2s infinite ease-in-out;
}

.voice-video-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Participant Grid */
.voice-participants-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  justify-content: center;
  width: 100%;
  max-width: 1000px;
}

.voice-participants-grid.compact-grid {
  max-width: 1100px;
}

.voice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.2rem;
  width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  position: relative;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.voice-card:hover {
  transform: translateY(-2px);
  border-color: rgba(229, 57, 79, 0.3);
}

.voice-card-avatar-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}

.voice-card-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  transition: all 0.2s ease;
  border: 3px solid transparent;
}

.voice-card-avatar.default-avatar {
  background: var(--surface2);
  color: var(--text);
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-card.speaking .voice-card-avatar {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.4), 0 0 20px rgba(74, 222, 128, 0.6);
  animation: voicePulse 1.2s infinite alternate ease-in-out;
}

@keyframes voicePulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

.voice-card-live {
  position: absolute;
  bottom: 0;
  right: 0;
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  border: 2px solid var(--surface);
}

.voice-card-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.voice-card-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.voice-card-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 20px;
}

.voice-badge-icon {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text3);
}

.voice-badge-icon.muted {
  background: rgba(229, 57, 79, 0.15);
  color: var(--red-lt);
}

.voice-badge-icon.deafened {
  background: rgba(229, 57, 79, 0.2);
  color: var(--red-lt);
}

/* Voice Floating / Dock Controls */
.voice-dock-controls {
  padding: 0.8rem 1.5rem;
  background: rgba(18, 18, 24, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-shrink: 0;
  z-index: 50;
}

.voice-dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text);
  background: var(--surface);
}

.voice-dock-btn:hover {
  background: var(--surface2);
  transform: translateY(-1px);
}

.voice-dock-btn .dock-icon {
  font-size: 1rem;
}

.voice-dock-btn.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.voice-dock-btn.btn-danger {
  background: rgba(229, 57, 79, 0.2);
  border-color: rgba(229, 57, 79, 0.4);
  color: var(--red-lt);
}

.voice-dock-btn.btn-active-screen {
  background: rgba(74, 222, 128, 0.2);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--green);
}

.voice-dock-btn.btn-leave {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.voice-dock-btn.btn-leave:hover {
  background: var(--red-dk);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: var(--rail-w) 1fr; grid-template-areas: "rail topbar" "rail main"; }
  .app-shell.member-open { grid-template-columns: var(--rail-w) 1fr; grid-template-areas: "rail topbar" "rail main"; }
  .channel-sidebar { position: fixed; left: var(--rail-w); top: 0; bottom: 0; z-index: 300; transform: translateX(-100%); transition: transform .25s ease; width: var(--sidebar-w); }
  .channel-sidebar.open { transform: translateX(0); }
  .member-sidebar { display: none !important; }
  .mobile-menu-btn { display: flex !important; }
  .top-channel-topic { display: none; }
}
@media (max-width: 600px) {
  .app-shell { grid-template-columns: 0 1fr; }
  .server-rail { position: fixed; left: 0; top: 0; bottom: 0; z-index: 400; transform: translateX(-100%); transition: transform .25s ease; }
  .server-rail.open { transform: translateX(0); }
  .auth-card { padding: 1.5rem; }
  .modal-box { padding: 1.5rem; border-radius: var(--radius-lg); }
}


/* ── Server Dropdown & Header ────────────────────────────── */
.sidebar-header {
  cursor: pointer;
  transition: background .15s ease;
  user-select: none;
  position: relative;
}
.sidebar-header:hover {
  background: rgba(255, 255, 255, 0.05);
}
.sidebar-header #sidebarServerName {
  flex: 1;
  min-width: 0;
}
.server-dropdown {
  position: absolute;
  top: calc(var(--topbar-h) + 4px);
  left: 8px;
  right: 8px;
  width: calc(100% - 16px);
  box-sizing: border-box;
  background: #171317;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7), 0 0 1px rgba(229, 57, 79, 0.3);
  padding: .4rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.server-dropdown.hidden {
  display: none !important;
}
.server-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem .75rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: background .12s, color .12s;
  user-select: none;
}
.server-dropdown-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.server-dropdown-item.invite {
  color: var(--red);
  font-weight: 600;
}
.server-dropdown-item.invite:hover {
  background: rgba(229, 57, 79, 0.15);
  color: #ff6b8a;
}
.server-dropdown-item.danger {
  color: #ef4444;
}
.server-dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.server-dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: .3rem 0;
}

/* ─── Friends Page (Discord-Grade UI) ─────────────────────── */
.friends-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.friends-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.friends-topbar-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  padding-right: .5rem;
}

.friends-topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border2);
}

.friends-tabs {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex: 1;
}

.friends-tab-pill {
  padding: .35rem .75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text2);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .12s, color .12s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.friends-tab-pill:hover {
  background: var(--surface2);
  color: var(--text);
}

.friends-tab-pill.active {
  background: var(--surface2);
  color: var(--text);
}

.friends-tab-pill.add-btn {
  background: var(--red);
  color: #fff;
  margin-left: auto;
}

.friends-tab-pill.add-btn:hover {
  background: var(--red-hover);
}

.friends-tab-pill.add-btn.active {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}

.friends-count-badge {
  background: var(--surface);
  color: var(--text3);
  font-size: .72rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 999px;
}

.friends-count-badge.has-pending {
  background: var(--red);
  color: #fff;
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem .85rem;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
  transition: background .12s, border-color .12s;
}

.friend-row:hover {
  background: var(--surface2);
  border-color: transparent;
}

.friend-row:hover .friend-actions {
  opacity: 1;
}

.friend-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  opacity: .85;
  transition: opacity .12s;
}

.friend-circle-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  font-size: .95rem;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}

.friend-circle-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
  transform: scale(1.05);
}

.friend-circle-btn.accept:hover {
  background: rgba(34, 197, 94, .18);
  color: #22c55e;
  border-color: #22c55e;
}

.friend-circle-btn.danger:hover {
  background: rgba(239, 68, 68, .18);
  color: #ef4444;
  border-color: #ef4444;
}

.friends-search-box {
  width: 100%;
  position: relative;
  margin-bottom: 1rem;
}

.friends-search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem .6rem 2.2rem;
  color: var(--text);
  font-size: .88rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.friends-search-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red-glow);
}

.friends-search-icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: .85rem;
  pointer-events: none;
}

/* ─── Role Pills & Interactive Assignment ─────────────────── */
.role-pill-interactive {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  border-width: 1px;
  border-style: solid;
  transition: transform .1s;
}

.role-pill-interactive .remove-role-btn {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: .75rem;
  margin-left: 2px;
  opacity: .7;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
}

.role-pill-interactive .remove-role-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, .2);
}

.role-assign-dropdown {
  position: relative;
  display: inline-block;
}

.role-assign-dropdown-btn {
  padding: .25rem .6rem;
  font-size: .75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px dashed var(--border2);
  color: var(--text2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  transition: border-color .15s, color .15s;
}

.role-assign-dropdown-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.role-assign-menu {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .35rem;
  z-index: 100;
  min-width: 160px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}

.role-assign-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .82rem;
  color: var(--text);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background .1s;
}

.role-assign-item:hover {
  background: var(--surface2);
}

/* ─── Verified Badges & Verification UI ──────────────────── */
.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-left: 4px;
  color: var(--red);
  cursor: help;
  filter: drop-shadow(0 0 4px rgba(229, 57, 79, 0.45));
  transition: transform .12s ease;
}

.verified-badge:hover {
  transform: scale(1.15);
}

.verified-profile-tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(229, 57, 79, 0.14);
  color: #ff6b8a;
  border: 1px solid rgba(229, 57, 79, 0.35);
  font-size: .74rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 999px;
  margin-top: .3rem;
  margin-bottom: .6rem;
  letter-spacing: .02em;
}

.verification-status-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1.5rem;
}

.verification-status-card.approved {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.06);
}

.verification-status-card.pending {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.06);
}

.verification-status-card.rejected {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.06);
}

.verification-admin-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  transition: border-color .15s;
}

.verification-admin-card:hover {
  border-color: var(--border2);
}

/* ─── Banned Server Screen ────────────────────────────────── */
.banned-server-screen {
  max-width: 560px;
  margin: 3rem auto;
  text-align: center;
  padding: 2.5rem 2rem;
  background: var(--surface2);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.banned-server-icon {
  font-size: 3.5rem;
  margin-bottom: .8rem;
  animation: pulse 2s infinite;
}

.banned-server-title {
  color: #ef4444;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: .3rem;
}

.banned-server-name {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
}

.ban-reason-box {
  width: 100%;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1.2rem;
  text-align: left;
}

.ban-reason-label {
  font-size: .75rem;
  font-weight: 700;
  color: #f87171;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .4rem;
}

.ban-reason-text {
  font-size: 1rem;
  color: #fff;
  font-weight: 600;
  line-height: 1.4;
}

.ban-reason-date {
  font-size: .75rem;
  color: var(--text3);
  margin-top: .6rem;
}

.banned-server-desc {
  font-size: .88rem;
  color: var(--text3);
  line-height: 1.5;
  margin-bottom: .5rem;
}

.server-banned-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--panel);
  z-index: 2;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.server-icon.banned {
  filter: grayscale(0.8) brightness(0.7);
  border: 2px solid #ef4444 !important;
}


/* ── Mentions & Mention Autocomplete ─────────────────────── */
.mention {
  background: rgba(229, 57, 79, 0.18);
  color: var(--red-lt);
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: text;
}
.mention:hover {
  background: rgba(229, 57, 79, 0.32);
  text-decoration: underline;
}
.mention.mention-me {
  background: rgba(234, 179, 8, 0.22);
  color: #fde047;
  font-weight: 700;
  border: 1px solid rgba(234, 179, 8, 0.35);
}
.msg-group.mentioned {
  background: rgba(234, 179, 8, 0.08) !important;
  border-left: 3px solid #eab308;
}

.mention-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0.75rem;
  width: 290px;
  max-height: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
  z-index: 500;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.mention-popup-header {
  padding: 0.45rem 0.75rem;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.mention-popup-list {
  overflow-y: auto;
  max-height: 200px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s ease;
}
.mention-item:hover, .mention-item.active {
  background: rgba(229, 57, 79, 0.15);
  color: var(--text);
}
.mention-avatar-wrap {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.mention-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.mention-display {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mention-username {
  font-size: 0.72rem;
  color: var(--text3);
}

/* ── Search Modal Results ─────────────────────────────────── */
.search-result-card {
  padding: 0.65rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.search-result-card:hover {
  background: rgba(229, 57, 79, 0.1);
  border-color: rgba(229, 57, 79, 0.35);
  transform: translateY(-1px);
}
.search-result-snippet {
  font-size: 0.84rem;
  color: var(--text2);
  line-height: 1.4;
  word-break: break-word;
}
.search-highlight {
  background: rgba(234, 179, 8, 0.35);
  color: #fef08a;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 700;
}
.msg-flash {
  animation: flashMsg 2s ease;
}
@keyframes flashMsg {
  0% { background: rgba(229, 57, 79, 0.35); }
  100% { background: transparent; }
}


/* ── Polls ─────────────────────────────────────────── */
.poll-card {
  margin-top: 0.6rem;
  margin-bottom: 0.4rem;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid rgba(229, 57, 79, 0.25);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}
.poll-card.poll-closed {
  border-color: var(--border);
  opacity: 0.9;
}
.poll-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.poll-tag {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--red-lt);
  letter-spacing: 0.5px;
}
.poll-badge-live {
  background: rgba(74, 222, 128, 0.18);
  color: var(--green);
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
  margin-left: 4px;
}
.poll-badge-closed {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
  margin-left: 4px;
}
.poll-meta-type {
  font-size: 0.72rem;
  color: var(--text4);
  font-weight: 600;
}
.poll-question {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}
.poll-options {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}
.poll-option {
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}
.poll-option:hover:not(.disabled) {
  border-color: rgba(229, 57, 79, 0.4);
}
.poll-option.voted {
  border-color: var(--red);
}
.poll-option.disabled {
  cursor: default;
}
.poll-progress-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, rgba(229, 57, 79, 0.22), rgba(229, 57, 79, 0.14));
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.poll-option.voted .poll-progress-bar {
  background: linear-gradient(90deg, rgba(229, 57, 79, 0.38), rgba(229, 57, 79, 0.22));
}
.poll-option-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  gap: 0.75rem;
}
.poll-option-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}
.poll-vote-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1.5px solid var(--border2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.poll-vote-icon.radio {
  border-radius: 50%;
}
.poll-vote-icon.checkbox {
  border-radius: 3px;
}
.poll-vote-icon.checked {
  background: var(--red);
  border-color: var(--red);
}
.poll-vote-icon.radio.checked::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}
.poll-vote-icon.checkbox.checked::after {
  content: '';
  display: block;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}
.poll-option-text {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}
.poll-option.voted .poll-option-text {
  font-weight: 700;
}
.poll-option-right {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  flex-shrink: 0;
}
.poll-option-pct {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text2);
}
.poll-option.voted .poll-option-pct {
  color: var(--red-lt);
}
.poll-option-votes {
  font-size: 0.74rem;
  color: var(--text4);
}
.poll-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text4);
}
.poll-end-btn {
  background: transparent;
  border: none;
  color: var(--text3);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}
.poll-end-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}
