/* =========================================================
   VOIDSECTOR TOPBAR — CLEAN & STABLE
   - Unified dropdown system
   - No conflicting overrides
   - Safe viewport margins
   - Friends / Messages / Alerts identical layout
========================================================= */

/* =========================
   ROOT VARIABLES
========================= */
:root{
  --vs-text: var(--text);
  --vs-muted: var(--text-sub);

  --vs-cyan: var(--primary);
  --vs-border: rgba(var(--primary-rgb),0.20);

  --vs-bg-topbar: var(--bg);
  --vs-bg-panel: var(--surface);
  --vs-bg-panel-head: var(--card-solid);

  --vs-radius: 18px;
  --vs-radius-sm: 14px;

  --vs-dd-width: 392px;
  --vs-dd-maxh: 520px;
  --vs-dd-safe: 14px;

  --vs-shadow-panel: 0 24px 70px rgba(0,0,0,.6);
  --vs-shadow-soft: 0 10px 40px rgba(0,0,0,.45);

  --vs-font-ui: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --vs-font-display: var(--vs-font-ui);
}

[data-theme="light"] {
  --vs-shadow-panel: 0 24px 70px rgba(0,0,0,.12);
  --vs-shadow-soft: 0 4px 20px rgba(0,0,0,.08);
}

/* =========================
   TOPBAR
========================= */
.vs-topbar{
  position: sticky;
  top: 0;
  z-index: 9999;

  height: 62px;
  padding: 0 14px;

  display:flex;
  align-items:center;
  justify-content: space-between;

  background: var(--vs-bg-topbar);
  border-bottom: 1px solid var(--vs-border);
  box-shadow: var(--vs-shadow-soft);

  color: var(--vs-text);
}

/* layout */
.vs-topbar__left,
.vs-topbar__center,
.vs-topbar__right{
  display:flex;
  align-items:center;
  gap: 10px;
}
.vs-topbar__left,
.vs-topbar__right{ min-width: 220px; }

/* =========================
   LOGO
========================= */
.vs-logo{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 10px;

  text-decoration:none;
  color: var(--vs-text);
  font-family: var(--vs-font-display);
  font-weight:900;
  letter-spacing:1px;

  border-radius: var(--vs-radius);
  border:1px solid transparent;
}
.vs-logo:hover{
  border-color: var(--vs-border);
}
.vs-logo__dot{
  width:10px;height:10px;border-radius:50%;
  background: var(--vs-cyan);
}

/* =========================
   NAV BUTTONS
========================= */
.vs-navbtn{
  display:flex;
  align-items:center;
  gap:8px;

  height: 42px;
  padding: 0 12px;

  border-radius: var(--vs-radius);
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);

  color: var(--vs-text);
  font-size:13px;
  text-decoration:none;
  cursor:pointer;

  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.vs-navbtn:hover{
  background: rgba(var(--primary-rgb),.08);
  border-color: var(--vs-border);
  transform: translateY(-1px);
}
.vs-navbtn--btn{ outline:none; }

.vs-ic svg{
  width:20px;height:20px;
}

/* badge */
.vs-badge{
  position:absolute;
  top:-6px; right:-6px;
  min-width:18px;height:18px;
  padding:0 6px;
  border-radius:999px;

  background:#ff3b4a;
  color:#fff;
  font-size:11px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.vs-badge[hidden]{ display:none; }

/* =========================
   MENU (details)
========================= */
.vs-menu{ position:relative; }
.vs-menu > summary{ list-style:none; }
.vs-menu > summary::-webkit-details-marker{ display:none; }

/* =========================
   DROPDOWN PANEL (UNIFIED)
========================= */
.vs-menu > .vs-dd{
  position:absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);

  width: min(var(--vs-dd-width), calc(100vw - (var(--vs-dd-safe) * 2)));
  max-height: var(--vs-dd-maxh);

  background: var(--vs-bg-panel);
  border:1px solid var(--vs-border);
  border-radius: var(--vs-radius);

  box-shadow: var(--vs-shadow-panel);
  overflow:hidden;

  opacity:0;
  pointer-events:none;
  z-index:10000;
}

/* open state */
.vs-menu[open] > .vs-dd{
  opacity:1;
  pointer-events:auto;
}

/* =========================
   DROPDOWN HEADER
========================= */
.vs-dd__head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap:12px;

  padding:12px 14px;
  background: var(--vs-bg-panel-head);
  border-bottom:1px solid var(--vs-border);
}
.vs-dd__title{
  font-family: var(--vs-font-display);
  font-size:14px;
  letter-spacing:.6px;
}
.vs-dd__sub{
  font-size:12px;
  opacity:.7;
}

/* close button */
.vs-dd__close{
  width:34px;height:34px;
  border-radius: var(--vs-radius-sm);
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  color: var(--vs-text);
  cursor:pointer;
}
.vs-dd__close:hover{
  background: rgba(var(--primary-rgb),.10);
  border-color: var(--vs-border);
}

/* =========================
   DROPDOWN BODY
========================= */
.vs-dd__body{
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;

  max-height: calc(var(--vs-dd-maxh) - 56px);
  overflow:auto;
}

/* list */
.vs-dd__list{
  display:flex;
  flex-direction:column;
  gap:8px;
}

/* item */
.vs-dd__item{
  padding:12px 14px;
  border-radius: var(--vs-radius);
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  cursor:pointer;

  display:flex;
  flex-direction:column;
  gap:2px;
}
.vs-dd__item:hover{
  background: rgba(var(--primary-rgb),.08);
  border-color: var(--vs-border);
}
.vs-dd__itemTitle{
  font-size:13px;
  font-weight:700;
}
.vs-dd__itemMeta{
  font-size:12px;
  color: var(--vs-muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.vs-dd__divider{
  height:1px;
  background: rgba(255,255,255,.10);
  margin:6px 2px;
}

/* =========================
   FRIENDS INPUT ROW
========================= */
.vs-dd__row{
  display:flex;
  gap:8px;
}
.vs-dd__input{
  flex:1;
  height:38px;
  padding:0 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.16);
  background:#050A14;
  color:var(--vs-text);
}
.vs-dd__btn{
  height:38px;
  padding:0 12px;
  border-radius:12px;
  border:1px solid var(--vs-border);
  background: rgba(var(--primary-rgb),.12);
  color:var(--vs-text);
  cursor:pointer;
}

/* =========================
   USER
========================= */
.vs-user{
  display:flex;
  align-items:center;
  gap:10px;

  padding:6px 10px;
  border-radius: var(--vs-radius);
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);

  color:var(--vs-text);
  text-decoration:none;
}
.vs-avatar{
  width:34px;height:34px;
  border-radius:50%;
  overflow:hidden;
  background:#111;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* =========================
   TOAST (Realtime invites)
========================= */
.vs-toast-wrap{
  position: fixed;
  top: 70px;
  right: 14px;
  left: auto;
  z-index: 10003;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}
.vs-toast--clickable{
  cursor: pointer;
}
.vs-toast--clickable:hover{
  border-color: rgba(var(--primary-rgb),0.5);
  box-shadow: 0 12px 36px rgba(0,0,0,0.55), inset 0 0 22px rgba(var(--primary-rgb),0.12);
}
.vs-toast{
  pointer-events: auto;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  min-width: 260px;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(10,14,20,0.92);
  border: 1px solid rgba(var(--primary-rgb),0.25);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45), inset 0 0 18px rgba(var(--primary-rgb),0.08);
  backdrop-filter: blur(10px);
}
.vs-toast__msg{
  font-size: 13px;
  color: var(--text);
  line-height: 1.2;
}
.vs-toast__btn{
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid rgba(var(--primary-rgb),0.35);
  background: rgba(var(--primary-rgb),0.08);
  color: var(--text);
  cursor: pointer;
}
.vs-toast__btn:hover{
  background: rgba(var(--primary-rgb),0.14);
}
.vs-toast__close{
  font-size: 12px;
  width: 28px;
  height: 28px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
}
.vs-toast__close:hover{
  background: rgba(255,255,255,0.08);
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width:520px){
  .vs-menu > .vs-dd{
    max-height: 70vh;
  }
}

/* =========================================================
   FACEBOOK-STYLE TOPBAR  (.fb-topbar)
========================================================= */
.fb-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  height: 56px;
  display: flex;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid rgba(var(--primary-rgb),.14);
  box-shadow: 0 2px 18px rgba(0,0,0,.45);
  padding: 0 20px;
}

/* ---------- LEFT ---------- */
.fb-topbar__left {
  flex: 0 0 260px;
  width: 260px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fb-topbar-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--grad);
  text-decoration: none;
  position: relative;
}
.fb-topbar-logo__dot {
  display: none;
}
.fb-topbar-logo__text {
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -.5px;
}

.fb-topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.fb-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
}
input.fb-search-input {
  height: 36px;
  width: 100%;
  padding: 0 12px 0 40px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.07);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, background .2s;
}
.fb-search-input::placeholder { color: var(--muted); }
.fb-search-input:focus {
  border-color: rgba(var(--primary-rgb),.4);
  background: rgba(255,255,255,.1);
}

/* ---------- CENTER ---------- */
.fb-topbar__center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
}

.fb-navtab {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  flex: 1;
  min-width: 0;
  max-width: 155px;
  padding: 0 6px;
  text-decoration: none;
  color: var(--muted);
  position: relative;
  transition: color .15s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.fb-navtab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: transparent;
  transition: background .15s;
}
.fb-navtab svg {
  width: 24px; height: 24px;
  stroke: currentColor;
  flex-shrink: 0;
}
.fb-navtab:hover {
  color: var(--text);
  background: rgba(255,255,255,.05);
  border-radius: 8px 8px 0 0;
}
.fb-navtab--active {
  color: var(--primary);
}
.fb-navtab--active::after { background: var(--primary); }
.fb-navtab--active svg { stroke: var(--primary); }
.fb-navtab--locked { opacity: .35; pointer-events: none; position: relative; }
.fb-navtab--locked::before { content: '🔒'; position: absolute; top: 2px; right: 2px; font-size: 9px; line-height: 1; }

/* ---------- RIGHT ---------- */
.fb-topbar__right {
  flex: 0 0 260px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.fb-topbar-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(var(--primary-rgb),.35);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: rgba(var(--primary-rgb),.25);
  flex-shrink: 0;
  transition: border-color .2s;
  cursor: pointer;
}
.fb-topbar-avatar:hover { border-color: var(--primary); }
.fb-topbar-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.fb-topbar-avatar__init {
  color: #e0f0ff;
  font-weight: 700;
  font-size: 15px;
}

/* ── User dropdown menu ─────────────────────────────────────────── */
.fb-user-menu {
  position: fixed;
  top: 58px;
  right: 10px;
  z-index: 10010;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  min-width: 230px;
  z-index: 8999;
  overflow: hidden;
  animation: fbMenuIn .15s cubic-bezier(.2,.9,.2,1);
}
@keyframes fbMenuIn {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.fb-user-menu-profile {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  text-decoration: none; color: var(--text);
  transition: background .15s;
}
.fb-user-menu-profile:hover { background: var(--card-hover); }
.fb-user-menu-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  background: rgba(var(--primary-rgb),.18);
  display: flex; align-items: center; justify-content: center;
}
.fb-user-menu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fb-user-menu-avatar__init { font-weight: 700; font-size: 17px; color: var(--primary); }
.fb-user-menu-info { display: flex; flex-direction: column; gap: 2px; }
.fb-user-menu-name { font-size: 14px; font-weight: 700; color: var(--text); }
.fb-user-menu-sub  { font-size: 12px; color: var(--muted); }
.fb-user-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.fb-user-menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  font-size: 14px; font-weight: 500;
  color: var(--text); text-decoration: none;
  background: none; border: none; width: 100%; text-align: left;
  cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.fb-user-menu-item:hover { background: var(--card-hover); }
.fb-user-menu-item-icon {
  width: 22px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--text-sub);
}
.fb-user-menu-item--danger { color: #f87171; }
.fb-user-menu-item--danger .fb-user-menu-item-icon { color: #f87171; }

.fb-topbar-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  background: #6366f1;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  white-space: nowrap;
  transition: background .15s;
}
.fb-topbar-btn:hover { background: #4f52d8; }
.fb-topbar-btn--ghost {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
}
.fb-topbar-btn--ghost:hover { background: rgba(255,255,255,.13); }

/* ---------- SEARCH DROPDOWN ---------- */
.fb-search-dropdown {
  position: fixed;
  z-index: 10000;
  background: var(--surface);
  border: 1px solid rgba(var(--primary-rgb),.2);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
  overflow: hidden;
  min-width: 220px;
}
.fb-search-dropdown.hidden { display: none; }
.fb-drop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  transition: background .12s;
}
.fb-drop-item:hover { background: rgba(var(--primary-rgb),.08); }
.fb-drop-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(var(--primary-rgb),.3);
  display: flex; align-items: center; justify-content: center;
}
.fb-drop-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.fb-drop-avatar-init { font-size: 13px; font-weight: 700; color: #e0f0ff; }
.fb-drop-name { font-weight: 500; }

/* ---------- ICON BUTTON + BADGE ---------- */
.fb-topbar-icon-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.07);
  color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.fb-topbar-icon-btn:hover { background: rgba(255,255,255,.14); color: var(--primary); }
.fb-topbar-icon-btn svg { flex-shrink: 0; }

.fb-topbar-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 17px; height: 17px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
  line-height: 1;
}
.fb-topbar-badge.hidden { display: none; }

/* ---------- NOTIFICATION & CHAT PANEL ---------- */
.fb-panel {
  position: fixed;
  top: 60px; right: 8px;
  width: 360px;
  max-height: 520px;
  background: var(--surface);
  border: 1px solid rgba(var(--primary-rgb),.18);
  border-radius: 14px;
  box-shadow: 0 16px 60px rgba(0,0,0,.7);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fb-panel.hidden { display: none; }

.fb-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.fb-panel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.fb-panel-read-all {
  font-size: 12px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}
.fb-panel-read-all:hover { background: rgba(var(--primary-rgb),.12); }

.fb-panel-search {
  position: relative;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.fb-panel-search-inp {
  width: 100%;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  padding: 7px 14px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.fb-panel-search-inp::placeholder { color: var(--muted); }

.fb-panel-body {
  overflow-y: auto;
  flex: 1;
  padding: 6px 0;
}
.fb-panel-empty {
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* Notification item */
.fb-notif-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .12s;
  border-radius: 0;
  text-decoration: none;
  color: inherit;
}
.fb-notif-item:hover { background: rgba(255,255,255,.05); }
.fb-notif-item.unread { background: rgba(var(--primary-rgb),.06); }
.fb-notif-item.unread:hover { background: rgba(var(--primary-rgb),.1); }

.fb-notif-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(var(--primary-rgb),.3);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.fb-notif-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fb-notif-avatar-init { font-size: 16px; font-weight: 700; color: #e0f0ff; }

.fb-notif-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.fb-notif-text strong { color: var(--text); }
.fb-notif-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.fb-notif-actions { display: flex; gap: 6px; margin-top: 6px; }
.fb-notif-accept {
  background: var(--primary); color: #fff; border: none;
  border-radius: 6px; font-size: 12px; font-weight: 600;
  padding: 4px 12px; cursor: pointer; transition: filter .15s;
}
.fb-notif-accept:hover { filter: brightness(1.15); }
.fb-notif-decline {
  background: rgba(255,255,255,.08); color: var(--text-sub);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px; font-size: 12px; font-weight: 600;
  padding: 4px 12px; cursor: pointer; transition: background .15s;
}
.fb-notif-decline:hover { background: rgba(255,80,80,.15); color: #f87171; }

.fb-notif-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

/* ---------- PANEL HEAD ICONS ---------- */
.fb-panel-head-icons { display: flex; gap: 4px; }
.fb-panel-icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.08);
  color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.fb-panel-icon-btn:hover { background: rgba(255,255,255,.15); color: var(--primary); }

/* ---------- PANEL TABS ---------- */
.fb-panel-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 12px 8px;
  flex-shrink: 0;
}
.fb-panel-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  background: rgba(255,255,255,.07);
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.fb-panel-tab:hover:not(.fb-panel-tab--active) { background: rgba(255,255,255,.12); }
.fb-panel-tab--active {
  background: rgba(var(--primary-rgb),.18);
  color: var(--primary);
}

/* ---------- CHAT ITEMS ---------- */
.fb-chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
  color: inherit;
}
.fb-chat-item:hover { background: rgba(255,255,255,.05); }
.fb-chat-item--global { border-bottom: 1px solid rgba(255,255,255,.06); margin-bottom: 4px; }

.fb-chat-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(var(--primary-rgb),.3);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
  font-size: 20px;
}
.fb-chat-avatar--global { background: rgba(var(--primary-rgb),.15); border: 1px solid rgba(var(--primary-rgb),.2); }
.fb-chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fb-chat-avatar-init { font-size: 17px; font-weight: 700; color: #e0f0ff; }

.fb-chat-info {
  flex: 1;
  min-width: 0;
}
.fb-chat-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fb-chat-name--unread { font-weight: 700; color: var(--text); }
.fb-chat-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.fb-chat-preview--unread { color: var(--text); font-weight: 500; }

.fb-chat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}
.fb-chat-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.fb-chat-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--primary);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1280px) {
  .fb-topbar__left { flex: 0 0 220px; width: 220px; }
}
@media (max-width: 1024px) {
  .fb-topbar__left { flex: 0 0 180px; width: 180px; }
}
@media (max-width: 900px) {
  .fb-topbar__left,
  .fb-topbar__right { flex: 0 0 auto; }
  .fb-search-input { width: 140px; }
  .fb-search-input:focus { width: 180px; }
  .fb-navtab { min-width: 52px; }
}
/* Mobile search overlay */
.mobile-search-open { display: none; }
.mobile-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.mobile-search-overlay.hidden { display: none; }
.mobile-search-overlay-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mobile-search-back {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mobile-search-back:hover { background: var(--surface); }
.mobile-search-input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 34px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.mobile-search-results {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

@media (max-width: 600px) {
  .fb-topbar-search { display: none; }
  .mobile-search-open { display: flex; }
  .fb-topbar__left { flex: 0 0 auto; min-width: 0; }
  .fb-navtab { min-width: 40px; }
  /* panels เต็มความกว้างบนมือถือ */
  #friends-panel { left: 8px !important; right: 8px !important; transform: none !important; width: auto !important; }
  .fb-waffle-panel { left: 8px !important; right: 8px !important; width: auto !important; }
}
@media (max-width: 480px) {
  .fb-topbar { padding: 0 8px; gap: 0; }
  .fb-topbar__left { flex: 0 0 auto; gap: 0; }
  .fb-topbar__right { gap: 6px; flex: 0 0 auto; }
  /* center ขยายเต็มพื้นที่กลาง */
  .fb-topbar__center { flex: 1; gap: 2px; justify-content: center; }
  .fb-navtab { min-width: 36px; padding: 0 6px; }
  .fb-navtab svg { width: 20px; height: 20px; }
  .fb-topbar-logo { width: 36px; height: 36px; }
  .fb-topbar-logo__text { font-size: 13px; }
  .fb-topbar-icon-btn { width: 34px; height: 34px; }
  .fb-topbar-icon-btn svg { width: 19px; height: 19px; }
  .fb-topbar-avatar { width: 34px; height: 34px; border-width: 1.5px; }
  .fb-topbar-avatar__init { font-size: 13px; }
  .fb-user-menu { right: 6px; min-width: 200px; }
  /* ซ่อน mobile search button เมื่อมีพื้นที่น้อยมาก — ใช้ search overlay แทน */
  .mobile-search-open { display: flex; }
}

/* =========================
   LIGHT MODE OVERRIDES (.fb-topbar)
========================= */
[data-theme="light"] .fb-topbar {
  background: #ffffff;
  border-bottom: 1px solid rgba(0,0,0,.1);
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
[data-theme="light"] input.fb-search-input {
  background: var(--bg);
  border-color: rgba(0,0,0,.15);
  color: var(--text);
}
[data-theme="light"] .fb-search-input::placeholder { color: var(--muted); }
[data-theme="light"] .fb-search-icon { color: var(--text-sub); }
[data-theme="light"] .fb-search-input:focus { background: #e4e6ea; border-color: #6366f1; }

[data-theme="light"] .fb-navtab { color: var(--text-sub); }
[data-theme="light"] .fb-navtab:hover { color: var(--text); background: rgba(0,0,0,.05); }
[data-theme="light"] .fb-navtab--active { color: var(--primary); }
[data-theme="light"] .fb-navtab--active::after { background: var(--primary); }
[data-theme="light"] .fb-navtab--active svg { stroke: var(--primary); }

[data-theme="light"] .fb-topbar-icon-btn {
  background: var(--bg);
  color: var(--text);
}
[data-theme="light"] .fb-topbar-icon-btn:hover { background: #e4e6ea; color: var(--primary); }
[data-theme="light"] .fb-topbar-badge { border-color: #ffffff; }

[data-theme="light"] .fb-topbar-avatar { border-color: rgba(var(--primary-rgb),.4); }
[data-theme="light"] .fb-topbar-logout {
  border-color: rgba(0,0,0,.12);
  background: var(--bg);
  color: var(--text-sub);
}

[data-theme="light"] .vs-navbtn {
  border-color: rgba(0,0,0,.1);
  background: rgba(0,0,0,.03);
}
[data-theme="light"] .vs-navbtn:hover { background: rgba(var(--primary-rgb),.08); }
[data-theme="light"] .vs-dd__input { background: var(--bg); border-color: rgba(0,0,0,.15); color: var(--text); }
[data-theme="light"] .vs-dd__btn { background: rgba(var(--primary-rgb),.1); }
[data-theme="light"] .vs-dd__item {
  background: rgba(0,0,0,.02);
  border-color: rgba(0,0,0,.08);
}
[data-theme="light"] .vs-dd__item:hover { background: rgba(var(--primary-rgb),.08); }
[data-theme="light"] .vs-dd__divider { background: rgba(0,0,0,.08); }
[data-theme="light"] .vs-dd__close {
  border-color: rgba(0,0,0,.1);
  background: rgba(0,0,0,.04);
}

[data-theme="light"] .fb-search-dropdown {
  background: #ffffff;
  border-color: rgba(0,0,0,.12);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
[data-theme="light"] .fb-drop-item { color: var(--text); }
[data-theme="light"] .fb-drop-item:hover { background: rgba(0,0,0,.05); }
[data-theme="light"] .fb-drop-avatar-init { color: var(--text); }
[data-theme="light"] .fb-drop-name { color: var(--text); }

[data-theme="light"] .fb-panel {
  background: #ffffff;
  border-color: rgba(0,0,0,.12);
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
}
[data-theme="light"] .fb-panel-head { border-color: rgba(0,0,0,.08); }
[data-theme="light"] .fb-panel-title { color: var(--text); }
[data-theme="light"] .fb-panel-icon-btn { background: var(--bg); color: var(--text-sub); }
[data-theme="light"] .fb-panel-icon-btn:hover { background: #e4e6ea; color: var(--primary); }

[data-theme="light"] .fb-panel-search { border-color: rgba(0,0,0,.07); }
[data-theme="light"] .fb-panel-search-inp {
  background: var(--bg);
  border-color: rgba(0,0,0,.12);
  color: var(--text);
}
[data-theme="light"] .fb-panel-search-inp::placeholder { color: var(--muted); }

[data-theme="light"] .fb-panel-empty { color: var(--muted); }
[data-theme="light"] .fb-panel-tabs { border-color: rgba(0,0,0,.07); }
[data-theme="light"] .fb-panel-tab { background: var(--bg); color: var(--text-sub); }
[data-theme="light"] .fb-panel-tab:hover:not(.fb-panel-tab--active) { background: #e4e6ea; }
[data-theme="light"] .fb-panel-tab--active { background: rgba(var(--primary-rgb),.12); color: var(--primary); }

[data-theme="light"] .fb-notif-item:hover { background: rgba(0,0,0,.04); }
[data-theme="light"] .fb-notif-item.unread { background: rgba(var(--primary-rgb),.05); }
[data-theme="light"] .fb-notif-item.unread:hover { background: rgba(var(--primary-rgb),.1); }
[data-theme="light"] .fb-notif-avatar-init { color: var(--text); }
[data-theme="light"] .fb-notif-text { color: var(--text); }
[data-theme="light"] .fb-notif-text strong { color: var(--text); }
[data-theme="light"] .fb-notif-time { color: var(--muted); }
[data-theme="light"] .fb-notif-decline { background: var(--bg); color: var(--text-sub); border-color: rgba(0,0,0,.12); }
[data-theme="light"] .fb-notif-dot { background: var(--primary); }

[data-theme="light"] .fb-chat-item:hover { background: rgba(0,0,0,.04); }
[data-theme="light"] .fb-chat-item--global { border-color: rgba(0,0,0,.07); }
[data-theme="light"] .fb-chat-avatar-init { color: var(--text); }
[data-theme="light"] .fb-chat-avatar--global { background: rgba(var(--primary-rgb),.1); border-color: rgba(var(--primary-rgb),.2); }
[data-theme="light"] .fb-chat-name { color: var(--text); }
[data-theme="light"] .fb-chat-name--unread { color: var(--text); }
[data-theme="light"] .fb-chat-preview { color: var(--muted); }
[data-theme="light"] .fb-chat-preview--unread { color: var(--text-sub); }
[data-theme="light"] .fb-chat-time { color: var(--muted); }
[data-theme="light"] .fb-chat-dot { background: var(--primary); }

[data-theme="light"] .vs-toast {
  background: rgba(255,255,255,.96);
  border-color: rgba(0,0,0,.12);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
[data-theme="light"] .vs-toast__msg { color: var(--text); }
[data-theme="light"] .vs-toast__btn { color: var(--text); border-color: rgba(var(--primary-rgb),.3); background: rgba(var(--primary-rgb),.08); }
[data-theme="light"] .vs-toast__close { background: var(--bg); color: var(--text-sub); border-color: rgba(0,0,0,.1); }

/* ── Broadcast popup ─────────────────────────────────────────── */
.vs-bc-overlay{position:fixed;inset:0;background:rgba(0,0,0,.65);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:10000;display:flex;align-items:center;justify-content:center;animation:vs-bc-in .25s ease}
@keyframes vs-bc-in{from{opacity:0;transform:scale(.92)}to{opacity:1;transform:scale(1)}}
.vs-bc-modal{background:var(--surface);border:1px solid var(--border);border-radius:22px;padding:36px 40px 32px;max-width:460px;width:90%;text-align:center;box-shadow:0 24px 70px rgba(0,0,0,.45);position:relative}
.vs-bc-icon{font-size:48px;margin-bottom:10px}
.vs-bc-label{font-size:11px;text-transform:uppercase;letter-spacing:1.2px;color:var(--primary);font-weight:800;margin-bottom:10px}
.vs-bc-msg{font-size:17px;font-weight:600;color:var(--text);line-height:1.6;margin-bottom:26px;white-space:pre-wrap;word-break:break-word}
.vs-bc-close{padding:11px 36px;border-radius:12px;background:var(--primary);color:#fff;border:none;font-size:14px;font-weight:700;cursor:pointer;transition:opacity .15s}
.vs-bc-close:hover{opacity:.82}
.vs-bc-dismiss{position:absolute;top:14px;right:16px;background:none;border:none;font-size:18px;color:var(--muted);cursor:pointer;line-height:1;padding:4px}
[data-theme="light"] .vs-bc-modal{box-shadow:0 16px 50px rgba(0,0,0,.18)}


/* ── Waffle nav panel ─────────────────────────────────────────── */
.fb-waffle-panel{
  position:fixed;top:62px;right:14px;
  width:220px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:18px;
  padding:12px;
  display:grid;grid-template-columns:1fr 1fr;gap:4px;
  box-shadow:0 16px 48px rgba(0,0,0,.5);
  z-index:10010;
  animation:waffleIn .18s cubic-bezier(.2,.9,.2,1);
}
@keyframes waffleIn{from{opacity:0;transform:translateY(-8px) scale(.96)}to{opacity:1;transform:translateY(0) scale(1)}}
.fb-waffle-panel.hidden{display:none}

.fb-waffle-item{
  display:flex;flex-direction:column;align-items:center;gap:5px;
  padding:12px 6px 10px;border-radius:12px;
  text-decoration:none;
  transition:background .14s;
  position:relative;
}
.fb-waffle-item:hover{background:rgba(var(--primary-rgb),.08)}
.fb-waffle-item.active{background:rgba(var(--primary-rgb),.12)}
.fb-waffle-item.active::after{
  content:'';position:absolute;bottom:6px;left:50%;transform:translateX(-50%);
  width:4px;height:4px;border-radius:50%;background:var(--primary);
}
.fb-waffle-icon{font-size:22px;line-height:1}
.fb-waffle-label{font-size:10px;font-weight:700;color:var(--muted);letter-spacing:.02em;white-space:nowrap}
.fb-waffle-item:hover .fb-waffle-label,
.fb-waffle-item.active .fb-waffle-label{color:var(--text)}

[data-theme="light"] .fb-waffle-panel{box-shadow:0 8px 32px rgba(0,0,0,.12)}

/* ── Friends panel row ───────────────────────────────────────────── */
.fb-friend-row{display:flex;align-items:center;padding:2px 8px 2px 0}
.fb-friend-row__main{
  flex:1;display:flex;align-items:center;gap:10px;
  padding:8px 8px;border-radius:10px;
  text-decoration:none;color:inherit;
  transition:background .14s;min-width:0;
}
.fb-friend-row__main:hover{background:rgba(var(--primary-rgb),.07)}
.fb-friend-row__main .fb-chat-name{font-size:13px;font-weight:600;color:var(--text)}
.fb-friend-remove{
  flex-shrink:0;width:30px;height:30px;border-radius:8px;border:none;
  background:none;color:var(--muted);cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  transition:background .14s,color .14s;
}
.fb-friend-remove:hover{background:rgba(239,68,68,.12);color:#ef4444}
