html { scrollbar-gutter: stable; }

.header-inner {
  box-sizing: border-box;
  width: 100%;
  max-width: 1464px;
  flex-wrap: nowrap;
  gap: 24px;
  min-height: 96px;
  display: flex;
  align-items: center;
}
.header-inner > .brand,
.header-inner > .languages { flex-shrink: 0; }

.brand, .brand-wordmark {
  font-weight: 750; font-size: 1.2rem; text-decoration: none;
}
.brand-wordmark {
  display: inline-block;
  font-size: 30px;
  font-weight: 850;
  letter-spacing: -2px;
  white-space: nowrap;
  line-height: 1;
}
.brand-and { font-weight: 450; font-size: .87em; margin: 0 2px; }
.brand-period { color: #ac7637; }

.desktop-nav, .languages, .account-nav {
  display: flex; align-items: center; flex-wrap: wrap; gap: 1rem;
}
.desktop-nav {
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 24px;
  min-width: 0;
  flex: 1;
}
.nav-primary, .nav-auth { display: flex; align-items: center; gap: 18px; }
.nav-auth {
  flex-shrink: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line);
  gap: 8px;
}
.nav-link {
  color: #40584e;
  font-size: .86rem;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: 0;
  padding: .25rem 0;
}
.nav-link[aria-current],
.languages [aria-current] {
  color: #166348;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .4rem;
}
.site-header .nav-link, .site-header summary { white-space: nowrap; font-weight: 600; }
.site-header .nav-auth .nav-link {
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
}
.site-header .nav-sign-in { border: 1px solid var(--line); }
.site-header .nav-sign-in:hover,
.site-header .nav-sign-in[aria-current] {
  background: #e9ede3; border-color: #64736b;
}
.site-header .nav-sign-up {
  background: #183c37; color: #fff; border: 1px solid #183c37;
}
.site-header .nav-sign-up:hover,
.site-header .nav-sign-up[aria-current] { background: #27564b; color: #fff; }

.languages { font-size: .85rem; gap: .7rem; }

.nav-more summary {
  min-height: 44px;
  display: flex; align-items: center; gap: 6px;
  list-style: none;
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary::after { content: "⌄"; }
.nav-more[open] summary::after { transform: rotate(180deg); }
.nav-more > div { top: calc(100% + 8px); }

.user-menu { position: relative; }
.user-menu summary { cursor: pointer; font-size: .86rem; }
.user-menu > div {
  position: absolute; right: 0; top: 30px;
  min-width: 190px; z-index: 30;
  background: white; border: 1px solid var(--line);
  padding: 16px; border-radius: 12px;
  box-shadow: 0 14px 35px #183c3715;
  display: flex; flex-direction: column; gap: 16px;
}

.mobile-nav { display: none; }
.site-header .button_to { margin: 0; }

@media (max-width: 1300px) {
  .desktop-nav { display: none; }
  .mobile-nav { display: block; margin-left: auto; position: relative; }
  .mobile-nav > summary {
    cursor: pointer; padding: 12px;
    border: 1px solid var(--line); border-radius: 8px;
  }
  .mobile-nav > nav {
    position: absolute; right: 0; top: calc(100% + 12px); z-index: 40;
    box-sizing: border-box;
    width: min(340px, calc(100vw - 36px));
    display: flex; flex-direction: column; align-items: stretch;
    padding: 20px;
    background: var(--paper);
    border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 14px 35px #183c371a;
    gap: 16px;
  }
  .mobile-nav .nav-primary { flex-direction: column; align-items: stretch; gap: 8px; }
  .mobile-nav .nav-primary > .nav-link { padding: 12px 0; }
  .mobile-nav .nav-auth { border-left: 0; border-top: 1px solid var(--line); padding: 16px 0 0; flex-wrap: wrap; }
  .mobile-nav .user-menu > div { position: static; box-shadow: none; min-width: 0; margin-top: 8px; }
  .header-inner { align-items: center; }
  .header-inner > .languages { margin-left: 0; }
}

@media (max-width: 700px) {
  .header-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 12px; }
  .header-inner > .brand { grid-column: 1; grid-row: 1; }
  .header-inner > .languages { grid-column: 2; grid-row: 1; }
  .header-inner > .section-toggle { justify-self: start; grid-column: 1; grid-row: 2; }
  .header-inner > .mobile-nav { grid-column: 2; grid-row: 2; }
  .section-toggle a { padding: 0 10px; }
  .brand-wordmark { font-size: 26px; }
  .user-menu > div { right: auto; left: 0; }
}

@media (max-width: 380px) {
  .section-toggle a { padding: 0 7px; font-size: .72rem; gap: 4px; }
  .section-toggle svg { width: 16px; height: 16px; }
  .mobile-nav > summary { padding: 12px 8px; font-size: .75rem; }
}

/* Совместимость с drive-шапкой (селектор раньше жил в drive.css) */
.header-inner:has(.section-toggle) { align-items: center; gap: 18px; }
.header-inner:has(.section-toggle) .desktop-nav { flex-wrap: nowrap; gap: 14px; min-width: 0; }
.header-inner:has(.section-toggle) .desktop-nav > *,
.header-inner:has(.section-toggle) .user-menu summary { white-space: nowrap; }
.header-inner:has(.section-toggle) .languages { flex-wrap: nowrap; flex-shrink: 0; }
@media (min-width: 1400px) {
  .header-inner:has(.section-toggle) { flex-wrap: nowrap; }
  .header-inner:has(.section-toggle) .nav-link,
  .header-inner:has(.section-toggle) .user-menu summary { font-size: .8rem; }
}
@media (max-width: 1399px) {
  .header-inner:has(.section-toggle) .desktop-nav { display: none; }
  .header-inner:has(.section-toggle) .mobile-nav { display: block; margin-left: auto; }
}
@media (max-width: 900px) {
  .header-inner:has(.section-toggle) { align-items: center; gap: 14px; }
  .section-toggle { order: 5; width: 100%; box-sizing: border-box; }
  .section-toggle a { flex: 1; min-height: 44px; }
}
