.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  min-height: 68px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0;
}

.topbar-left {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
}

.brand {
  text-decoration: none;
  color: var(--text);
  display: inline-flex;
  align-items: center;
}

.brand-main {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.08rem;
}

.primary-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
}

.primary-nav a {
  text-decoration: none;
  color: #32495b;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.34rem 0.68rem;
  white-space: nowrap;
}

.primary-nav a:hover {
  background: #dce8ee;
  color: #142838;
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.github-link {
  text-decoration: none;
  color: #32495b;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.3rem 0.62rem;
  white-space: nowrap;
}

.github-link:hover {
  background: #dce8ee;
  color: #142838;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
  background: #fff;
}

.lang-switch a {
  text-decoration: none;
  color: #40566a;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.21rem 0.48rem;
  min-width: 2.2rem;
  text-align: center;
}

.lang-switch a:hover {
  background: #dce8ee;
  color: #162a3a;
}

.lang-switch a.active {
  background: var(--accent);
  color: #fff;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: #314a5e;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  line-height: 1;
  cursor: pointer;
}

.menu-toggle:hover {
  background: #dce8ee;
  color: #142838;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 24, 38, 0.4);
  z-index: 39;
}

.mobile-backdrop[hidden] {
  display: none !important;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: min(84vw, 320px);
  background: #fff;
  border-right: 1px solid var(--border);
  box-shadow: 0 18px 34px rgba(7, 19, 31, 0.2);
  z-index: 40;
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.mobile-drawer[hidden] {
  display: none !important;
}

.mobile-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.92rem;
  font-weight: 700;
  color: #2f485b;
}

.drawer-close {
  border: 1px solid var(--border);
  background: #fff;
  color: #334a5e;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.28rem 0.52rem;
  cursor: pointer;
}

.drawer-close:hover {
  background: #dce8ee;
  color: #142838;
}

.mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.mobile-nav a,
.mobile-github {
  text-decoration: none;
  color: #263e50;
  font-size: 0.93rem;
  border-radius: 9px;
  padding: 0.48rem 0.56rem;
}

.mobile-nav a:hover,
.mobile-github:hover {
  background: #dce8ee;
  color: #142838;
}

.mobile-lang p {
  margin: 0 0 0.4rem;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #617488;
  font-weight: 700;
}

.mobile-lang nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mobile-lang a {
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: #294054;
  padding: 0.44rem 0.55rem;
  font-size: 0.88rem;
}

.mobile-lang a:hover {
  background: #dce8ee;
  color: #142838;
}

.mobile-lang a.active {
  background: #e8f4f2;
  border-color: #bddfd8;
  color: #104a45;
  font-weight: 600;
}

body.menu-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .menu-toggle {
    display: inline-block;
  }

  .primary-nav,
  .github-link {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    min-height: 62px;
    gap: 0.5rem;
  }

  .brand-main {
    font-size: 1.03rem;
  }

  .topbar-right {
    gap: 0.32rem;
  }

  .lang-switch a {
    font-size: 0.72rem;
    padding: 0.2rem 0.4rem;
    min-width: 1.95rem;
  }

  .mobile-drawer {
    width: min(88vw, 300px);
  }
}
