.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(16px);
}

.header {
  display: flex;
  align-items: center;
  gap: 26px;
  width: min(1180px, calc(100% - 32px));
  min-height: 72px;
  margin: auto;
}

.header-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  color: var(--text);
  font: 700 1.2rem "Space Grotesk", sans-serif;
  letter-spacing: -.06em;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px 9px 9px 2px;
  background: var(--primary);
  color: white;
  font: 700 .7rem "DM Sans", sans-serif;
  letter-spacing: -.08em;
  transform: rotate(-7deg);
  box-shadow: 3px 4px 0 var(--accent);
}

.brand-accent {
  color: var(--primary);
}

.header-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-main-links {
  flex: 1;
}

.header-account-links {
  margin-left: auto;
}

.nav-link {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
  text-decoration: none;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}

.nav-link:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  transform: translateY(-1px);
}

.sign-in {
  background: var(--primary);
  color: white;
  box-shadow: 0 5px 14px color-mix(in srgb, var(--primary) 25%, transparent);
}

.sign-in:hover {
  color: white;
  background: var(--primary-dark);
}

.sign-out {
  color: var(--primary);
}

.user-name {
  color: var(--muted);
  font-size: 1rem;
  white-space: nowrap;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--text);
  background: var(--surface);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.theme-toggle-icon {
  color: var(--primary);
  font-size: 1rem;
  line-height: 1;
}

.Mindex-title {
    text-align: center;
}

.header-nav {
  display: flex;
  align-items: center;
  flex: 1;
}

@media (max-width: 850px) {
  .site-header,
  .header {
    display: contents; 
  }

  .header-brand {
    display: flex;
    width: 100%;
    justify-content: center;
    padding: 16px 0 10px 0;
    position: relative;
    z-index: 21; 
  }

  .header-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    flex: none;
    justify-content: center;
    gap: 18px;
    padding: 12px 0;
  }

  /* one continuous background attached to the sticky nav */
  .header-nav::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    
    /* tall enough to stretch UP behind the brand area */
    height: 250px; 
    
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
    
    /* Tucked behind the links */
    z-index: -1; 
  }

  .header-main-links,
  .header-account-links {
    display: contents;
  }

  .user-name {
    display: none;
  }
}