.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;
}

.auth-btn {
  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;
  cursor: pointer;
}

.auth-btn:hover {
  background: #dce8ee;
  color: #142838;
}

.admin-badge {
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7c3d12;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
}

.admin-badge:hover {
  background: #fde68a;
}

.auth-dashboard {
  text-decoration: none;
  color: #32495b;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

.auth-dashboard:hover {
  color: #142838;
  text-decoration: underline;
}

.auth-user {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.82rem;
  color: #40566a;
  font-weight: 500;
  white-space: nowrap;
}

.auth-user-name {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.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-account {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 0;
}

.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) {
  .topbar-inner {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .menu-toggle {
    display: inline-block;
  }

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

  /* Drawer handles all nav, auth, and language at this breakpoint */
  .user-menu,
  .topbar-right > a.auth-btn,
  .topbar-right > .admin-badge,
  .topbar-right > form,
  .lang-switch {
    display: none;
  }
}

/* ── User menu dropdown ───────────────────────────────────────── */

.user-menu {
  position: relative;
}

.user-avatar-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.user-initials {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}

.user-avatar-btn:hover {
  background: var(--accent-strong);
}

.user-avatar-btn[aria-expanded="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  min-width: 190px;
  background: #162534;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(7, 19, 31, 0.36);
  z-index: 50;
  overflow: hidden;
}

.user-dropdown[hidden] {
  display: none !important;
}

.user-dropdown-header {
  padding: 0.75rem 1rem 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(0, 0, 0, 0.18);
}

.user-dropdown-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2edf6;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.user-dropdown-role {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fcd34d;
  background: rgba(252, 211, 77, 0.12);
  border: 1px solid rgba(252, 211, 77, 0.3);
  border-radius: 999px;
  padding: 0.1em 0.48em;
}

.user-dropdown-nav {
  padding: 0.35rem 0;
}

.user-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.48rem 1rem;
  font-size: 0.88rem;
  color: #b8cfe0;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.user-dropdown-btn {
  width: 100%;
  text-align: left;
}

.user-dropdown-item--muted {
  color: #6e8a9e;
  font-size: 0.84rem;
}

.user-dropdown-item--muted:hover {
  color: #b8cfe0;
}

.user-dropdown-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 0.3rem 0;
}

/* ── Drawer user info ─────────────────────────────────────────── */

.drawer-user-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0;
}

.drawer-user-avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.drawer-user-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Responsive ───────────────────────────────────────────────── */

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

  .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);
  }
}
