:root {
  scroll-padding-top: 88px;
}

section[id] {
  scroll-margin-top: 88px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  height: 78px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(225, 233, 242, 0.72);
  box-shadow: none;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.site-header__desktop {
  display: block;
  height: 100%;
}

.site-header__inner {
  width: min(calc(100% - 40px), 1280px);
  height: 100%;
  margin-inline: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 36px;
}

.site-header__logo,
.mobile-site-header__logo {
  display: block;
  flex: none;
  line-height: 0;
}

.site-header__logo img {
  width: 116px;
  height: auto;
}

.site-header__nav {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
}

.site-header__nav-link {
  position: relative;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #062a61;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease;
}

.site-header__nav-link svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.site-header__nav-link:hover {
  color: #2f80ed;
}

.site-header__nav-link[aria-current="page"] {
  color: #ff6a00;
}

.site-header__nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 26px;
  height: 3px;
  background: #ff6a00;
  border-radius: 999px;
}

.site-header__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.site-header__search,
.mobile-site-header__icon {
  width: 46px;
  height: 46px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: #062a61;
  background: #f5f8fc;
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.site-header__search:hover,
.mobile-site-header__icon:hover {
  color: #145bb8;
  background: #eaf4ff;
}

.site-header__search:active,
.mobile-site-header__icon:active {
  transform: translateY(1px);
}

.site-header__search svg,
.mobile-site-header__icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
}

.site-header__auth {
  min-width: 218px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.site-header__auth-skeleton,
.mobile-nav-auth__skeleton {
  width: 100%;
  height: 44px;
  display: block;
  background: #f1f5f9;
  border-radius: 15px;
  animation: header-auth-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes header-auth-pulse {
  to { opacity: 0.55; }
}

.site-header__guest-actions,
.site-header__user-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.site-header__guest-actions[hidden],
.site-header__user-actions[hidden],
.site-header__auth-skeleton[hidden],
.profile-menu[hidden],
.mobile-nav-guest-actions[hidden],
.mobile-nav-user-actions[hidden],
.mobile-nav-auth__skeleton[hidden] {
  display: none !important;
}

.site-header__login,
.site-header__register,
.site-header__library,
.site-header__avatar {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #062a61;
  border: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.site-header__login {
  padding: 0 10px;
  background: transparent;
}

.site-header__login:hover,
.site-header__library:hover {
  color: #2f80ed;
}

.site-header__register {
  min-height: 48px;
  margin-left: 2px;
  padding: 0 20px;
  color: #fff;
  background: #ff6a00;
  border-radius: 15px;
  box-shadow: 0 8px 20px rgba(255, 106, 0, 0.16);
  transition: background 150ms ease, transform 150ms ease;
}

.site-header__register:hover {
  color: #fff;
  background: #e95f00;
  transform: translateY(-1px);
}

.site-header__library {
  gap: 8px;
  padding: 0 12px;
}

.site-header__library svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.site-header__profile-wrap {
  position: relative;
}

.site-header__avatar {
  width: 42px;
  min-height: 42px;
  padding: 0;
  color: #062a61;
  background: #eaf4ff;
  border: 1px solid #dce5ef;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 850;
}

.site-header__avatar:hover,
.site-header__avatar[aria-expanded="true"] {
  background: #dcecff;
  border-color: #b7d4f4;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 110;
  width: 240px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e1e9f2;
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(20, 55, 92, 0.14);
}

.profile-menu__identity {
  padding: 8px 12px 11px;
  display: grid;
  gap: 3px;
  border-bottom: 1px solid #e1e9f2;
}

.profile-menu__identity strong {
  color: #062a61;
  font-size: 13px;
}

.profile-menu__identity span {
  color: #5f7189;
  font-size: 12px;
}

.profile-menu a,
.profile-menu button {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  color: #062a61;
  background: transparent;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.profile-menu a:hover,
.profile-menu button:hover {
  color: #145bb8;
  background: #eaf4ff;
}

.profile-menu button[data-auth-logout] {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid #e1e9f2;
}

.mobile-site-header,
.mobile-nav-drawer,
.mobile-nav-overlay {
  display: none;
}

.site-header :focus-visible {
  outline: 3px solid rgba(47, 128, 237, 0.28);
  outline-offset: 3px;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .site-header__inner {
    width: min(calc(100% - 32px), 1280px);
    gap: 20px;
  }

  .site-header__logo img { width: 104px; }
  .site-header__nav { gap: 20px; }
  .site-header__nav-link { gap: 0; }
  .site-header__nav-link svg { display: none; }
  .site-header__nav-link[aria-current="page"]::after { left: 0; }
  .site-header__auth { min-width: 187px; }
  .site-header__register { padding-inline: 14px; font-size: 0; }
  .site-header__register::after { content: "Регистрация"; font-size: 14px; }
  .site-header__library { padding-inline: 6px; font-size: 0; }
  .site-header__library svg { width: 20px; height: 20px; }
}

@media (max-width: 767px) {
  .site-header {
    height: 72px;
  }

  .site-header__desktop {
    display: none;
  }

  .mobile-site-header {
    height: 72px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .mobile-site-header__logo img { width: 98px; height: auto; }

  .mobile-site-header__actions {
    display: flex;
    gap: 9px;
  }

  .mobile-site-header__icon {
    width: 44px;
    height: 44px;
  }

  .mobile-nav-overlay[hidden],
  .mobile-nav-drawer[hidden] {
    display: none;
  }

  .mobile-nav-overlay:not([hidden]) {
    position: fixed;
    inset: 72px 0 0;
    z-index: 90;
    display: block;
    background: rgba(6, 42, 97, 0.24);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }

  .mobile-nav-drawer:not([hidden]) {
    position: fixed;
    top: 72px;
    right: 0;
    left: 0;
    z-index: 91;
    width: 100%;
    max-height: calc(100dvh - 72px);
    padding: 14px 16px calc(22px + env(safe-area-inset-bottom, 0px));
    display: block;
    overflow-y: auto;
    background: #fff;
    border-radius: 0 0 24px 24px;
    box-shadow: 0 16px 40px rgba(20, 55, 92, 0.14);
  }

  .mobile-nav-drawer__nav {
    display: grid;
    gap: 3px;
  }

  .mobile-nav-drawer__nav a {
    min-height: 52px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #062a61;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 750;
    text-decoration: none;
  }

  .mobile-nav-drawer__nav a svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
  }

  .mobile-nav-drawer__nav a[aria-current="page"] {
    color: #145bb8;
    background: #eaf4ff;
  }

  .mobile-nav-auth {
    min-height: 58px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e1e9f2;
  }

  .mobile-nav-auth__skeleton { height: 46px; }

  .mobile-nav-guest-actions,
  .mobile-nav-user-actions {
    display: grid;
    gap: 10px;
  }

  .mobile-nav-login,
  .mobile-nav-register,
  .mobile-nav-user-actions a,
  .mobile-nav-user-actions button {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #062a61;
    background: #fff;
    border: 1px solid #dce5ef;
    border-radius: 14px;
    font: inherit;
    font-size: 15px;
    font-weight: 800;
    text-decoration: none;
  }

  .mobile-nav-register {
    color: #fff;
    background: #ff6a00;
    border-color: #ff6a00;
    box-shadow: 0 8px 20px rgba(255, 106, 0, 0.16);
  }

  .mobile-nav-register:hover { color: #fff; background: #e95f00; }

  .mobile-nav-user-actions { gap: 4px; }

  .mobile-nav-user-actions__identity {
    padding: 3px 8px 13px;
    display: grid;
    gap: 3px;
  }

  .mobile-nav-user-actions__identity strong { color: #062a61; font-size: 15px; }
  .mobile-nav-user-actions__identity span { color: #5f7189; font-size: 13px; }

  .mobile-nav-user-actions a,
  .mobile-nav-user-actions button {
    justify-content: flex-start;
    padding: 0 14px;
    border-color: transparent;
  }

  .mobile-nav-user-actions a:hover,
  .mobile-nav-user-actions button:hover { color: #145bb8; background: #eaf4ff; }
  .mobile-nav-user-actions button[data-auth-logout] { margin-top: 7px; border-top: 1px solid #e1e9f2; border-radius: 0; }

  body.has-mobile-menu {
    overflow: hidden;
    overscroll-behavior: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header *,
  .site-header *::before,
  .site-header *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
