/* ===== Topbar search ===== */
.topbar-search{ flex: 1; max-width: 520px; min-width: 180px; position: relative; }
.topbar-search input{
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 9px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--ink);
}
/* ===== Search autocomplete dropdown ===== */
.search-autocomplete{
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(7,17,32,0.12);
  max-height: 340px; overflow-y: auto;
  display: none; z-index: 100;
}
.search-autocomplete.open{ display: block; }
.search-ac-item{
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; text-decoration: none;
  transition: background 0.12s;
}
.search-ac-item:hover{ background: var(--surface); }
.search-ac-item:first-child{ border-radius: 12px 12px 0 0; }
.search-ac-avatar{
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.search-ac-avatar svg{ width: 20px; height: 20px; }
.search-ac-info{ display: flex; flex-direction: column; min-width: 0; }
.search-ac-name{ font-size: 13.5px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-ac-username{ font-size: 12px; color: var(--ink-dim); }
.search-ac-footer{
  display: block; text-align: center;
  padding: 10px 14px; font-size: 13px; font-weight: 500;
  color: var(--accent); text-decoration: none;
  border-top: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  transition: background 0.12s;
}
.search-ac-footer:hover{ background: var(--surface); }

/* ===== Avatar dropdown ===== */
.avatar-dropdown{ position: relative; }
.avatar-btn{
  background: none; border: none; padding: 0; cursor: pointer;
  display: flex;
}
.avatar-dropdown-menu{
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(7,17,32,0.1);
  min-width: 170px;
  display: none;
  flex-direction: column;
  padding: 6px;
  z-index: 50;
}
.avatar-dropdown-menu.open{ display: flex; }
.avatar-dropdown-link{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
  background: none;
  border: none;
  text-align: left;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
}
.avatar-tiny{ width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; background-size: cover !important; background-position: center !important; border: none !important; }
.avatar-dropdown-link svg{ flex-shrink: 0; display: block; }
.avatar-dropdown-link span{ line-height: 16px; }
.avatar-dropdown-link:hover{ background: var(--surface); }
.avatar-dropdown-danger{ color: var(--alert); }
.avatar-dropdown-danger:hover{ background: rgba(225,79,79,0.08); }

/* ===== Notifications dropdown ===== */
.notif-dropdown{ position: relative; }
.notif-btn{ position: relative; }
.notif-badge{
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px;
  background: var(--alert); color: #fff;
  font-size: 9.5px; font-weight: 700;
  padding: 0 4px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
}
.notif-menu{
  position: absolute; top: calc(100% + 6px); right: -10px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(7,17,32,0.1);
  min-width: 300px; max-width: 360px;
  display: none;
  flex-direction: column;
  z-index: 50;
}
.notif-menu.open{ display: flex; }
.notif-menu-header{
  padding: 14px 18px; font-size: 14px; font-weight: 600;
  color: var(--ink); border-bottom: 1px solid var(--border);
}
.notif-list{ max-height: 320px; overflow-y: auto; }
.notif-item{
  display: flex; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.notif-item:hover{ background: var(--surface); }
.notif-item:last-child{ border-bottom: none; }
.notif-item-unread{ background: var(--signal-soft); }
.notif-item-unread:hover{ background: rgba(0,200,150,0.20); }
.notif-icon{ font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.notif-avatar{ width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.notif-item-body{ min-width: 0; flex: 1; }
.notif-item-body p{ margin: 0; font-size: 13.5px; color: var(--ink); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item-body strong{ font-weight: 600; }
.notif-item-time{ font-size: 12px; color: var(--ink-dim); }
.notif-menu-empty{
  padding: 24px 18px; text-align: center;
  font-size: 13.5px; color: var(--ink-dim);
}

/* ===== Topbar chat dropdown ===== */
.chat-topbar-dropdown{ position: relative; }
.chat-topbar-btn{ position: relative; }
.chat-topbar-btn .unread-badge{
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px;
  background: var(--alert); color: #fff;
  font-size: 9.5px; font-weight: 700;
  padding: 0 4px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
}
.chat-topbar-menu{
  position: absolute; top: calc(100% + 6px); right: -10px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(7,17,32,0.1);
  min-width: 280px; max-width: 340px;
  display: none;
  flex-direction: column;
  z-index: 50;
}
.chat-topbar-menu.open{ display: flex; }
.chat-topbar-list{ max-height: 320px; overflow-y: auto; }
.chat-topbar-list .chat-conv-item{
  display: flex; gap: 10px; padding: 12px 18px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s;
}
.chat-topbar-list .chat-conv-item:hover{ background: var(--surface); }
.chat-topbar-list .chat-conv-item:last-child{ border-bottom: none; }
.chat-topbar-list .chat-conv-avatar{
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 600; color: #fff;
}
.chat-topbar-list .chat-conv-body{ flex: 1; min-width: 0; }
.chat-topbar-list .chat-conv-name{ font-size: 13.5px; font-weight: 600; color: var(--ink); }
.chat-topbar-list .chat-conv-preview{ font-size: 12.5px; color: var(--ink-dim); margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-topbar-list .chat-conv-right{ display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-topbar-list .chat-conv-time{ font-size: 11px; color: var(--ink-dim); white-space: nowrap; }
.chat-topbar-list .chat-conv-unread{
  font-size: 10.5px; background: var(--signal); color: #fff;
  padding: 2px 6px; border-radius: 10px; font-weight: 600;
  min-width: 16px; text-align: center;
}

@media(max-width:980px){
  .topbar-search{ max-width: none; }
  .topbar-search input{ width: 100%; }
  .avatar-dropdown-menu{ right: -4px; min-width: 190px; }
  .avatar-dropdown-link{ padding: 12px 16px; font-size: 14px; }
}

@media(max-width:640px){
  .avatar-dropdown-menu{ right: -8px; min-width: 180px; }
  .avatar-dropdown-link{ padding: 14px 16px; font-size: 14px; }
  .notif-menu{ right: -60px; min-width: 0; width: calc(100vw - 24px); max-width: 360px; }
  .chat-topbar-menu{ right: -60px; min-width: 0; width: calc(100vw - 24px); max-width: 340px; }
}
