.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 68px;
  background: rgba(251, 248, 242, .94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 160ms ease-out;
}

.site-header.is-scrolled {
  border-bottom-color: var(--border);
}

.site-header.menu-open {
  z-index: 5000;
}

.site-header-inner {
  width: min(var(--max-content), calc(100% - (var(--gutter) * 2)));
  height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  min-width: 112px;
  text-decoration: none;
}

.site-logo img {
  display: block;
  width: 112px;
  height: auto;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.desktop-nav a,
.mobile-menu a,
.mobile-menu button {
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
}

.desktop-nav a {
  border-radius: 10px;
  padding: 10px 12px;
}

.desktop-nav a:hover,
.desktop-nav a.active {
  background: var(--primary-soft);
  color: var(--primary-active);
}

.desktop-account {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-icon-link,
.header-plain-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text) !important;
  font-size: 14px;
  font-weight: 700;
  line-height: 19px;
  text-decoration: none !important;
}

.header-plain-button {
  border-color: transparent;
  background: transparent;
}

.header-icon-link.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff !important;
}

.header-icon-link:hover,
.header-plain-button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-active) !important;
}

.header-icon-link.primary:hover {
  background: var(--primary-hover);
  color: #fff !important;
}

.mobile-menu-button {
  display: none;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-floating);
}

.mobile-menu {
  display: none;
}

body.mobile-menu-open {
  overflow: hidden;
  width: 100%;
}

.mobile-menu-layer {
  display: none;
}

@media (max-width: 899px) {
  .site-header {
    min-height: 60px;
  }

  .site-header-inner {
    height: 60px;
  }

  .site-logo img {
    width: 104px;
  }

  .desktop-nav,
  .desktop-account {
    display: none;
  }

  .mobile-menu-button {
    display: inline-flex;
  }

  .mobile-menu-layer {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: block;
    max-width: 100vw;
    overflow: hidden;
    overflow-x: clip;
    background: rgba(16, 20, 18, .36);
    pointer-events: auto;
    isolation: isolate;
    animation: mobileMenuFadeIn 160ms ease-out;
  }

  .mobile-menu-layer.is-closing {
    animation: mobileMenuFadeOut 180ms ease-in forwards;
  }

  .mobile-menu-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    appearance: none;
  }

  .mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    display: grid;
    width: min(360px, 88vw);
    max-width: 100vw;
    height: auto;
    min-height: 100vh;
    align-content: start;
    gap: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: var(--surface);
    padding: calc(14px + env(safe-area-inset-top)) 16px 20px;
    box-shadow: var(--shadow-drawer);
    animation: mobileDrawerIn 200ms cubic-bezier(.22, 1, .36, 1);
  }

  .mobile-menu-layer.is-closing .mobile-menu {
    animation: mobileDrawerOut 180ms cubic-bezier(.64, 0, .78, 0) forwards;
  }

  .mobile-menu-head {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }

  .mobile-menu-head img {
    width: 104px;
    height: auto;
  }

  .mobile-menu-head button {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-subtle);
    color: var(--text);
  }

  .mobile-menu-user {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin: 0 0 8px;
    padding: 10px 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .mobile-menu-user-avatar {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
  }

  .mobile-menu-user-text {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .mobile-menu-user-text span,
  .mobile-menu-user-text small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu-user-text span {
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    line-height: 20px;
  }

  .mobile-menu-user-text span.is-email {
    font-weight: 500;
  }

  .mobile-menu-user-text small {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
  }

  .mobile-menu a,
  .mobile-menu button {
    width: 100%;
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 12px;
    padding: 13px 12px;
    background: transparent;
    text-align: left;
  }

  .mobile-menu .mobile-menu-head button {
    width: 42px;
    min-height: 42px;
    flex: 0 0 42px;
    justify-content: center;
    padding: 0;
  }

  .mobile-menu a:not(.mobile-menu-icon-link) {
    padding-left: 14px;
  }

  .mobile-menu a:hover,
  .mobile-menu a.active,
  .mobile-menu button:hover {
    background: var(--primary-soft);
    color: var(--primary-active);
  }

  .mobile-menu-divider {
    height: 1px;
    margin: 10px 0;
    background: var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-menu-layer,
  .mobile-menu,
  .mobile-menu-backdrop {
    animation: none;
  }
}

@keyframes mobileDrawerIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes mobileDrawerOut {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

@keyframes mobileMenuFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes mobileMenuFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
