.bms-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0;
  isolation: isolate;
}
.bms-topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 0.5rem;
  min-height: 3.5rem;
}
.bms-topbar__brand .bms-brand-logo--simple,
.bms-topbar__brand .bms-brand-logo--topbar {
  height: 2.85rem;
  max-width: min(44vw, 10.75rem);
  filter:
    drop-shadow(0 2px 5px rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 16px rgba(114, 255, 127, 0.2));
}
@media (min-width: 768px) {
  .bms-topbar__brand .bms-brand-logo--simple,
  .bms-topbar__brand .bms-brand-logo--topbar {
    height: 3rem;
    max-width: 11.75rem;
  }
}
[data-theme="light"] .bms-topbar__brand .bms-brand-logo--simple,
[data-theme="light"] .bms-topbar__brand .bms-brand-logo--topbar {
  filter: drop-shadow(0 1px 4px rgba(22, 29, 53, 0.28)) contrast(1.08);
}
.bms-topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--bms-topbar-text, var(--bms-text));
  text-decoration: none;
  flex-shrink: 0;
  padding: 0.1rem 0.2rem;
}
.bms-topbar__menu-btn {
  display: none;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.bms-topbar__left { display: flex; align-items: center; gap: 0.6rem; min-width: 0; flex-shrink: 0; }
.bms-topbar__right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; margin-left: auto; }

/* Widget presenza community (dopo nav) */
.bms-topbar-presence {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  margin-left: 0.15rem;
}
.bms-topbar-presence:not([hidden]) {
  display: flex;
}
.bms-topbar-presence__pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0.28rem 0.55rem 0.28rem 0.45rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--bms-accent-strong) 28%, var(--bms-chrome-border));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--bms-accent) 10%, transparent), color-mix(in srgb, var(--bms-blue) 8%, transparent)),
    color-mix(in srgb, var(--bms-chrome-2) 88%, transparent);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 4px 18px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
}
.bms-topbar-presence__stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.35rem;
}
.bms-topbar-presence__stat--live .bms-topbar-presence__nums strong {
  color: var(--bms-positive);
}
.bms-topbar-presence__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bms-positive);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bms-positive) 25%, transparent);
  animation: bms-presence-pulse 2.2s ease-in-out infinite;
}
@keyframes bms-presence-pulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bms-positive) 25%, transparent); }
  50% { opacity: 0.75; transform: scale(0.92); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bms-positive) 12%, transparent); }
}
.bms-topbar-presence__icon {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--bms-accent-strong);
  flex-shrink: 0;
  opacity: 0.9;
}
.bms-topbar-presence__nums {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  line-height: 1;
}
.bms-topbar-presence__nums strong {
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--bms-topbar-text, var(--bms-text));
  transition: color 0.25s ease;
}
.bms-topbar-presence__lbl {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bms-topbar-text-muted, var(--bms-text-muted));
}
.bms-topbar-presence__sep {
  width: 1px;
  height: 1.1rem;
  margin: 0 0.1rem;
  background: color-mix(in srgb, var(--bms-topbar-text-muted, #97a0c2) 35%, transparent);
}
@media (min-width: 1024px) {
  .bms-topbar-presence { display: flex; }
  .bms-topbar-presence[hidden] { display: none !important; }
}
@media (min-width: 1024px) and (max-width: 1180px) {
  .bms-topbar-presence__lbl { display: none; }
  .bms-topbar-presence__pill { padding-inline: 0.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .bms-topbar-presence__dot { animation: none; }
}

.bms-burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 18px;
  height: 14px;
}
.bms-burger span {
  display: block;
  height: 2px;
  width: 100%;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
[aria-expanded="true"] .bms-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
[aria-expanded="true"] .bms-burger span:nth-child(2) { opacity: 0; }
[aria-expanded="true"] .bms-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.topbar-email {
  font-size: 0.75rem;
  margin-left: 0.25rem;
  opacity: 0.85;
}

/* Navigazione nel topbar — visibile di default (desktop-first) */
.bms-topbar__nav {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 0.15rem 0.25rem;
  padding: 0 0.35rem;
}

.bms-topnav__group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
}

.bms-topnav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.55rem;
  border-radius: 0.55rem;
  color: var(--bms-topbar-text-muted, #97a0c2);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.bms-topnav__link:hover {
  background-color: var(--bms-topbar-active);
  color: var(--bms-topbar-text, #fff);
}
.bms-topnav__link.is-active {
  background: linear-gradient(135deg, rgba(77, 142, 83, 0.22), rgba(251, 53, 94, 0.12));
  color: var(--bms-topbar-text, #fff);
  border-color: rgba(98, 181, 105, 0.35);
  box-shadow: inset 0 -2px 0 0 var(--bms-accent-strong);
}
.bms-topnav__icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 0.5rem;
  flex-shrink: 0;
  color: var(--ic, var(--bms-topbar-text-muted, #97a0c2));
  background: color-mix(in srgb, var(--ic, #8893b5) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--ic, #8893b5) 32%, transparent);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.bms-topnav__icon { width: 0.95rem; height: 0.95rem; }
.bms-topnav__label {
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bms-topnav__badge {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.1rem 0.3rem;
  border-radius: 999px;
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.12);
}
.bms-topnav__item { position: relative; display: flex; align-items: center; }
.bms-topnav__link--toggle {
  background: none;
  cursor: pointer;
  font-family: inherit;
}
.bms-topnav__caret {
  width: 0.75rem;
  height: 0.75rem;
  opacity: 0.65;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.bms-topnav__item.is-open .bms-topnav__caret { transform: rotate(180deg); }
.bms-dropdown--nav {
  left: 0;
  right: auto;
  width: 18rem;
}
.bms-hive-nav-list {
  max-height: 16rem;
  overflow-y: auto;
}
.bms-hive-nav-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.9rem;
  text-decoration: none;
  color: var(--bms-text);
  border-bottom: 1px solid var(--bms-border-soft);
  transition: background-color 0.12s ease;
}
.bms-hive-nav-item:last-child { border-bottom: none; }
.bms-hive-nav-item:hover { background: var(--bms-surface); }
.bms-hive-nav-item__name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bms-hive-nav-item__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--bms-text-muted);
  font-variant-numeric: tabular-nums;
}
.bms-topnav__link:hover .bms-topnav__icon-box {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--ic, #000) 35%, transparent);
}
.bms-topnav__link.is-active .bms-topnav__icon-box {
  color: #fff;
  background: var(--ic, var(--bms-accent));
  border-color: var(--ic, var(--bms-accent));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--ic, #000) 45%, transparent);
}

.bms-topnav-overlay {
  position: fixed;
  inset: 3.5rem 0 0 0;
  background: rgba(2, 6, 23, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 35;
}
.bms-topnav-overlay.is-open { opacity: 1; pointer-events: auto; }
html:has(body.bms-no-scroll) {
  overflow: hidden;
}
body.bms-no-scroll {
  overflow: hidden;
  overscroll-behavior: none;
}

.bms-footer__version {
  color: var(--bms-text-muted);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  transition: color 0.15s ease;
}
.bms-footer__version:hover { color: var(--bms-text); }

@media (min-width: 1024px) and (max-width: 1279px) {
  .bms-topnav__label { font-size: 0.76rem; }
  .bms-topnav__link { padding: 0.32rem 0.45rem; }
}

/* Mobile: hamburger + pannello a tendina */
@media (max-width: 1023px) {
  .bms-topbar__menu-btn { display: inline-flex; }
  .bms-topbar__right { margin-left: 0; }

  .bms-topbar__nav {
    display: none;
    position: fixed;
    top: 3.5rem;
    left: 0;
    right: 0;
    z-index: 45;
    flex: none;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    max-height: calc(100vh - 3.5rem);
    overflow-y: auto;
    background: linear-gradient(180deg, var(--bms-chrome) 0%, var(--bms-chrome-2) 100%);
    border-top: 1px solid var(--bms-chrome-border);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
    padding: 0.75rem 1rem 1rem;
    gap: 0.35rem;
  }
  .bms-topbar__nav.is-open { display: flex; }

  .bms-topnav__group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
  }
  .bms-topnav__link {
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    font-size: 0.88rem;
    font-weight: 500;
  }
  .bms-topnav__link.is-active { box-shadow: inset 3px 0 0 0 var(--bms-accent-strong); }
  .bms-topnav__icon-box { width: 1.85rem; height: 1.85rem; }
  .bms-topnav__icon { width: 1rem; height: 1rem; }
  .bms-topnav__badge { margin-left: auto; font-size: 0.58rem; padding: 0.14rem 0.38rem; }
  .bms-topnav__item {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .bms-topnav__link--toggle { width: 100%; }
  .bms-dropdown--nav {
    position: static;
    width: 100%;
    margin: 0.15rem 0 0.35rem;
    box-shadow: inset 0 0 0 1px var(--bms-border-soft);
  }
  .topbar-email { display: none; }
}
