.top-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(165deg, rgba(17, 16, 75, .88), rgba(9, 9, 34, .94));
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 24px 60px -24px rgba(8, 8, 32, .6);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
}

.top-header .nav {
  height: 108px;
  border: 0;
}

.header-brand {
  gap: 16px;
  transition: opacity .25s ease;
}

.header-brand:hover {
  opacity: .92;
}

.header-brand img {
  width: 46px !important;
  height: 88px !important;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .35));
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}

.header-brand:hover img {
  transform: scale(1.045);
}

.header-brand > span {
  font: 700 15px var(--display);
  letter-spacing: -.04em;
  color: #fff;
}

.header-brand small {
  display: block;
  color: var(--cyan);
  font: 700 9px var(--display);
  letter-spacing: .16em;
  margin-top: 4px;
}

.top-header .nav-links {
  gap: 36px;
}

.top-header .nav-links a {
  position: relative;
  font-size: 12px;
  letter-spacing: .05em;
  color: rgba(255, 255, 255, .72);
  transition: color .3s ease, letter-spacing .3s ease;
}

.top-header .nav-links a:after {
  content: '';
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -14px;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), rgba(255, 181, 16, 0));
  box-shadow: 0 0 12px rgba(255, 181, 16, .55);
  transition: right .4s cubic-bezier(.2, .8, .2, 1);
}

.top-header .nav-links a:hover {
  color: #fff;
  letter-spacing: .08em;
}

.top-header .nav-links a:hover:after {
  right: 0;
}

.top-header .nav-actions {
  gap: 22px;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .06);
  color: #fff;
  font-size: 20px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .3s ease, background .3s ease, border-color .3s ease;
}

.theme-toggle:hover {
  background: rgba(255, 181, 16, .14);
  border-color: rgba(255, 181, 16, .55);
  box-shadow: 0 0 0 8px rgba(255, 181, 16, .1);
  transform: rotate(16deg) scale(1.06);
}

.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  padding: 0 30px;
  border: 0;
  border-radius: 99px;
  background: linear-gradient(135deg, #ffc23a, var(--cyan));
  color: var(--ink);
  font: 700 13px var(--display);
  letter-spacing: .04em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 26px -8px rgba(255, 181, 16, .5);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), box-shadow .3s ease, filter .3s ease;
}

.login-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 38px -10px rgba(255, 181, 16, .6);
  filter: brightness(1.05);
}

.login-button:active {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -8px rgba(255, 181, 16, .5);
}

.top-header .menu-button {
  color: #fff;
}

.high-contrast {
  filter: saturate(.75) contrast(1.08);
}

.high-contrast .top-header {
  background: #fff;
}

.high-contrast .top-header .nav-links a,
.high-contrast .top-header .header-brand > span,
.high-contrast .top-header .header-brand small,
.high-contrast .top-header .menu-button {
  color: #171717;
}

.high-contrast .algorithm-card,
.high-contrast .directions,
.high-contrast .tour-section {
  background: #111;
}

.high-contrast .login-button {
  background: #8bd000;
}

@media (max-width: 1050px) {
  .top-header .nav-links {
    gap: 20px;
  }

  .top-header .nav-links a {
    font-size: 10px;
  }

  .top-header .nav-actions {
    gap: 14px;
  }

  .login-button {
    padding: 0 20px;
  }
}

@media (max-width: 900px) {
  .top-header .nav {
    height: 84px;
  }

  .top-header .nav-links.open {
    top: 84px;
    background: #fbfaf6;
    border-bottom: 1px solid rgba(23, 20, 80, .12);
    box-shadow: 0 24px 48px -18px rgba(23, 20, 80, .22);
  }

  .top-header .nav-links.open a {
    color: var(--ink);
  }

  .top-header .nav-links.open a:after {
    background: linear-gradient(90deg, var(--blue), rgba(45, 42, 128, 0));
    box-shadow: none;
  }

  .top-header .nav-actions {
    display: none;
  }

  .header-brand img {
    width: 31px !important;
    height: 60px !important;
  }

  .header-brand > span {
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .header-brand > span {
    display: none;
  }
}
