.topbar {
  position: sticky;
  top: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 18px 20px;
  margin-bottom: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.7rem;
  background: rgba(8, 11, 19, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
}

.topbar__primary {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  transition: opacity 220ms ease, transform 220ms ease;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 20px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: #08111d;
  background: linear-gradient(135deg, #76d0ff 0%, #63a8ff 35%, #6b66ff 100%);
  box-shadow: 0 18px 34px rgba(80, 126, 255, 0.35);
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  color: #9aa7c5;
}

.brand__text strong {
  color: #f7faff;
  font-size: 1rem;
  font-weight: 700;
}

.topnav {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(18px);
}

.topnav a {
  padding: 0.78rem 1.05rem;
  border-radius: 999px;
  color: #9aa7c5;
  font-weight: 600;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
  color: #f7faff;
  background: rgba(255, 255, 255, 0.06);
}

.topnav__cta {
  color: #f7fbff;
  background: linear-gradient(135deg, rgba(98, 99, 255, 0.22), rgba(103, 215, 255, 0.18));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.topnav__cta:hover {
  background: linear-gradient(135deg, rgba(98, 99, 255, 0.32), rgba(103, 215, 255, 0.24));
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.15rem;
  background: rgba(255, 255, 255, 0.04);
  color: #f7faff;
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.menu-toggle:hover {
  border-color: rgba(103, 215, 255, 0.36);
  background: rgba(103, 215, 255, 0.08);
}

.menu-toggle:focus-visible,
.topnav a:focus-visible {
  outline: 2px solid rgba(103, 215, 255, 0.72);
  outline-offset: 3px;
}

.menu-toggle__line {
  position: absolute;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 220ms ease, opacity 220ms ease;
}

.menu-toggle__line:nth-child(1) {
  transform: translateY(-6px);
}

.menu-toggle__line:nth-child(2) {
  transform: translateY(0);
}

.menu-toggle__line:nth-child(3) {
  transform: translateY(6px);
}

.topbar.is-nav-open .menu-toggle__line:nth-child(1) {
  transform: translateY(0) rotate(45deg);
}

.topbar.is-nav-open .menu-toggle__line:nth-child(2) {
  opacity: 0;
}

.topbar.is-nav-open .menu-toggle__line:nth-child(3) {
  transform: translateY(0) rotate(-45deg);
}

body.menu-open {
  overflow: hidden;
}

@media (max-width: 820px) {
  .page-shell,
  .subpage-shell {
    padding-top: 110px;
  }

  .topbar {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 120;
    padding: 14px;
    margin-bottom: 0;
    gap: 0;
    align-items: stretch;
    border-radius: 1.45rem;
    background: rgba(8, 11, 19, 0.84);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  }

  .topbar__primary {
    justify-content: space-between;
    width: 100%;
    position: relative;
    z-index: 161;
  }

  .brand {
    min-width: 0;
  }

  .brand__text {
    min-width: 0;
  }

  .brand__text strong,
  .brand__text span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .menu-toggle {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    z-index: 165;
  }

  .topnav {
    position: fixed;
    inset: 0;
    z-index: 150;
    width: 100vw;
    min-height: 100vh;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 0.85rem;
    margin-top: 0;
    padding: 112px 20px 28px;
    opacity: 0;
    visibility: hidden;
    overflow-y: auto;
    pointer-events: none;
    transform: translateY(-14px);
    border: 0;
    border-radius: 0;
    background:
      radial-gradient(circle at top left, rgba(108, 99, 255, 0.22), transparent 24%),
      radial-gradient(circle at top right, rgba(103, 215, 255, 0.16), transparent 22%),
      rgba(5, 7, 13, 0.94);
    backdrop-filter: blur(22px);
    transition:
      opacity 220ms ease,
      visibility 220ms ease,
      transform 220ms ease,
      padding 220ms ease;
  }

  .topbar.is-nav-open .topnav {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .topbar.is-nav-open {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .topbar.is-nav-open .brand {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
  }

  .topbar.is-nav-open .topbar__primary {
    justify-content: flex-end;
  }

  .topnav a {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
    padding: 1rem 1.1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
}
