/* ===================== Topbar (universal burger) ===================== */

header.topbar{
  position: sticky;
  top: 0;
  z-index: 1500;
  background: var(--nav-bg, #fff);
  color: var(--nav-ink, #0f172a);
  border-bottom: 1px solid var(--divider, #e5e7eb);
  padding: 0; /* spacing lives inside .topbar-inner */
}

.topbar-inner{
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Brand */
.topbar .brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.topbar .brand img{
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--divider, #e5e7eb);
  flex: 0 0 auto;
}

.brand-meta{
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.1;
}

.brand-title{
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub{
  font-size: 12px;
  opacity: .8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Actions */
.actions{
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.iconbtn{
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--divider, #e5e7eb);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.iconbtn:hover{
  background: var(--pill-bg-hover, rgba(0,0,0,.04));
}

.iconbtn .badge{
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--nav-bg, #fff);
}

/* User pill */
.userpill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--divider, #e5e7eb);
  color: inherit;
  text-decoration: none;
  max-width: 180px;
}

.userpill:hover{
  background: var(--pill-bg-hover, rgba(0,0,0,.04));
}

.userpill .avatar{
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--divider, #e5e7eb);
}

.userpill span{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* ===================== Drawer ===================== */

.backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.backdrop.open{
  opacity: 1;
  pointer-events: auto;
}

.drawer{
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(86vw, 360px);
  background: var(--bg, #fff);
  border-left: 1px solid var(--divider, #e5e7eb);
  z-index: 2000;
  transform: translateX(100%);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
}

.drawer.open{
  transform: translateX(0);
}

.drawer-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-bottom: 1px solid var(--divider, #e5e7eb);
}

.drawer-title{
  font-weight: 800;
}

.drawer-body{
  padding: 12px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-body a{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--divider, #e5e7eb);
  background: var(--pill-bg, #f8fafc);
  text-decoration: none;
  color: inherit;
}

.drawer-body a.active,
.drawer-body a[class~="active"]{
  border-color: #c7d2fe;
  background: #eef2ff;
}

/* lock scroll when drawer open */
body.drawer-open{
  overflow: hidden;
  touch-action: none;
}

/* ===================== Compact on scroll ===================== */
header.topbar.compact .topbar-inner{
  padding: 6px 12px;
}

header.topbar.compact .brand-sub{
  display: none;
}

header.topbar.compact .brand img{
  width: 24px;
  height: 24px;
}

header.topbar.compact .iconbtn{
  width: 30px;
  height: 30px;
}

header.topbar.compact .userpill{
  padding: 5px 8px 5px 7px;
}

header.topbar.compact .userpill .avatar{
  width: 20px;
  height: 20px;
}

/* small screen tweak: don’t let userpill dominate */
@media (max-width: 520px){
  .userpill span{ display:none; }
  .userpill{ padding: 6px 8px; }
}
