.header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-height);
  background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 max(1.5rem, calc((100vw - var(--content-width)) / 2 + 1.5rem));
  gap: 1rem;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.header.scrolled {
  box-shadow: var(--shadow-sm);
}

.header__logo-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.header__logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
}

.header__logo-text {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: auto;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-surface) 92%, var(--bg-page));
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.55em 0.95em;
  border-radius: 999px;
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface-2);
}

.nav-link.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.header__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.theme-toggle,
.header__ham-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--text-secondary);
}

.theme-toggle:hover,
.header__ham-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.theme-toggle svg,
.header__ham-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#icon-sun {
  display: none;
}

#icon-moon {
  display: block;
}

[data-theme="dark"] #icon-sun {
  display: block;
}

[data-theme="dark"] #icon-moon {
  display: none;
}

.header__ham-btn {
  display: none;
}

.mobile-nav-overlay {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: calc(100dvh - var(--header-height));
  z-index: 199;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-nav-overlay.open {
  opacity: 1;
  visibility: visible;
}

.mobile-nav-drawer {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(300px, calc(100% - 24px));
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 0.8rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateY(-10px);
  opacity: 0;
  transition: all 0.25s ease;
}

.mobile-nav-overlay.open .mobile-nav-drawer {
  transform: translateY(0);
  opacity: 1;
}

.mobile-nav-link {
  padding: 0.8em 1em;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mobile-nav-link:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

@media (max-width: 980px) {
  .header {
    padding: 0 1rem;
    justify-content: space-between;
  }

  .header__nav {
    display: none;
  }

  .header__ham-btn {
    display: flex;
  }
}
