.topbar {
  --topbar-primary: #243b84;
  --topbar-bg: #243b84;
  --topbar-border: #1c2f6d;
  --topbar-text: #ffffff;
  --topbar-hover: rgba(255, 255, 255, 0.14);
  --topbar-hover-border: rgba(255, 255, 255, 0.3);
  --topbar-input-bg: rgba(255, 255, 255, 0.1);
  --topbar-input-border: rgba(255, 255, 255, 0.35);
  --topbar-input-placeholder: rgba(255, 255, 255, 0.78);
  /* Выпадающие меню — тот же синий тон, что и панель */
  --topbar-dropdown-bg: var(--topbar-bg);
  --topbar-dropdown-text: var(--topbar-text);
  --topbar-dropdown-hover: var(--topbar-hover);
  --topbar-dropdown-border: rgba(255, 255, 255, 0.22);
  --topbar-dropdown-muted: rgba(255, 255, 255, 0.78);
  --topbar-dropdown-shadow: 0 14px 36px rgba(7, 12, 28, 0.45);

  position: sticky;
  top: 0;
  z-index: 1300;
  border-bottom: 1px solid var(--topbar-border);
  background: var(--topbar-bg);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

:root[data-theme="dark"] .topbar,
:root[data-topbar-theme="dark"] .topbar,
:root[data-topbar-theme="dark"] header.topbar {
  --topbar-primary: #0f1628;
  --topbar-bg: #0f1628;
  --topbar-border: #2a3d66;
  --topbar-text: #eef3ff;
  --topbar-hover: rgba(255, 255, 255, 0.1);
  --topbar-hover-border: rgba(255, 255, 255, 0.22);
  --topbar-input-bg: rgba(255, 255, 255, 0.08);
  --topbar-input-border: rgba(255, 255, 255, 0.24);
  --topbar-input-placeholder: rgba(235, 242, 255, 0.65);
  --topbar-dropdown-bg: var(--topbar-bg);
  --topbar-dropdown-text: var(--topbar-text);
  --topbar-dropdown-hover: var(--topbar-hover);
  --topbar-dropdown-border: rgba(255, 255, 255, 0.16);
  --topbar-dropdown-muted: rgba(234, 240, 255, 0.78);
  --topbar-dropdown-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}

header.topbar {
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.topbar-inner {
  width: min(100%, 1440px);
  max-width: 100%;
  margin: 0 auto;
  padding-left: max(clamp(0.35rem, 2vw, 0.85rem), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(0.35rem, 2vw, 0.85rem), env(safe-area-inset-right, 0px));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.topbar-shell {
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.topbar-row {
  display: flex;
  align-items: center;
  width: 100%;
}

.topbar-row--head {
  gap: clamp(0.55rem, 1.5vw, 1rem);
  min-height: 76px;
  padding: 0.35rem 0;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
}

.topbar-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 0;
}

.topbar-logo__img {
  width: clamp(64px, 8vw, 80px);
  height: clamp(64px, 8vw, 80px);
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.9)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.topbar-logo__img.is-error {
  opacity: 0.4;
}

.topbar-logo:hover .topbar-logo__img,
.topbar-logo:focus-visible .topbar-logo__img {
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 1)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.topbar-logo:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 4px;
  border-radius: 8px;
}

.topbar-row--nav {
  display: flex;
  justify-content: center;
  padding: 0.28rem 0 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.08);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.45) transparent;
}

.topbar-head-center {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 14rem;
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  line-height: 1.15;
}

.topbar-org-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--topbar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-org-sub {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-tools {
  flex: 0 0 auto;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: clamp(0.22rem, 1.2vw, 0.4rem);
  flex-shrink: 0;
  flex-wrap: nowrap;
  padding: 0;
  border: 0;
  background: transparent;
  min-width: 0;
}

.topbar-tools__lang {
  display: inline-flex;
  align-items: center;
}

.topbar-nav {
  list-style: none;
  margin: 0 auto;
  padding: 0 0 0.12rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.2rem 0.3rem;
  width: max-content;
  max-width: 100%;
}

.topbar-nav__item {
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

.topbar-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.28rem 0.82rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--topbar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.topbar-nav__link:hover,
.topbar-nav__link:focus-visible {
  background: var(--topbar-hover);
  border-color: var(--topbar-hover-border);
  outline: none;
}

.topbar-nav__link.is-active {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.45);
}

.topbar-icon-btn {
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--topbar-text);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.topbar-icon-btn:hover,
.topbar-icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.55);
  outline: none;
}

.topbar-icon-btn--search,
.topbar-icon-btn--menu {
  display: none;
}

.topbar-a11y-pill {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--topbar-text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  flex: 0 0 40px;
}

.topbar-a11y-pill:hover,
.topbar-a11y-pill:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.75);
  outline: none;
}

.topbar-a11y-pill__icon {
  font-size: 1.1rem;
  line-height: 1;
}

.topbar-a11y-pill__text {
  white-space: nowrap;
}

.topbar-lang {
  display: inline-flex;
  align-items: stretch;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.topbar-lang__btn {
  min-width: 38px;
  height: 100%;
  padding: 0 0.45rem;
  border: 0;
  background: transparent;
  color: var(--topbar-text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.topbar-lang__btn + .topbar-lang__btn {
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}

.topbar-lang__btn:hover {
  background: var(--topbar-hover);
}

.topbar-lang__btn.is-active {
  background: rgba(255, 255, 255, 0.28);
}

.topbar-lang__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
  z-index: 1;
}

.topbar-list__item--search-toggle {
  display: none;
}

.topbar-search-toggle-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--topbar-text);
  cursor: pointer;
  padding: 0;
}

.topbar-search-toggle-icon {
  width: 20px;
  height: 20px;
  display: block;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.topbar-icon-btn--search .topbar-search-toggle-icon {
  pointer-events: none;
}

.topbar-mobile-search-wrap {
  width: 100%;
  box-sizing: border-box;
  padding: 0.35rem 0 0.5rem;
}

.topbar-mobile-search-wrap[hidden] {
  display: none !important;
}

.topbar-mobile-search-form {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
}

.topbar-mobile-search__input.mobile-search-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--topbar-input-border);
  border-radius: 10px;
  background: var(--topbar-input-bg);
  color: var(--topbar-text);
  font: inherit;
  font-size: 1rem;
  outline: none;
  box-sizing: border-box;
}

.topbar-mobile-search__input.mobile-search-input::placeholder {
  color: var(--topbar-input-placeholder);
}

.topbar-mobile-search__go {
  flex: 0 0 auto;
  padding: 0 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.22);
  color: var(--topbar-text);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.topbar-search {
  flex: 1 1 auto;
  width: auto;
  max-width: min(420px, 46vw);
  min-width: 8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--topbar-input-border);
  border-radius: 999px;
  background: var(--topbar-input-bg);
  padding: 0 0.75rem;
}

.topbar-search__icon {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  opacity: 0.88;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.topbar-search__input {
  width: 100%;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--topbar-text);
  font: inherit;
  font-size: 0.88rem;
  outline: none;
}

.topbar-search__input::placeholder {
  color: var(--topbar-input-placeholder);
}

.topbar-search:focus-within {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* В шапке — круг с лупой; клик по label открывает поле */
.topbar-search--compact {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  min-width: 40px;
  max-width: 40px;
  padding: 0;
  gap: 0;
  overflow: hidden;
  cursor: pointer;
  transition: max-width 0.2s ease, padding 0.2s ease, gap 0.2s ease;
}

.topbar-search--compact .topbar-search__trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.topbar-search--compact .topbar-search__icon {
  margin: 0;
  pointer-events: none;
}

.topbar-search--compact .topbar-search__input {
  width: 0;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  margin: 0;
  opacity: 0;
  flex: 0 0 0;
  cursor: text;
}

.topbar-search--compact:focus-within {
  width: auto;
  min-width: 7.5rem;
  max-width: min(11rem, 22vw);
  height: 40px;
  padding: 0 0.55rem 0 0;
  gap: 0.3rem;
  cursor: text;
  overflow: visible;
}

.topbar-search--compact:focus-within .topbar-search__trigger {
  width: 28px;
  flex-shrink: 0;
}

.topbar-search--compact:focus-within .topbar-search__input {
  width: 100%;
  min-width: 4rem;
  opacity: 1;
  flex: 1 1 auto;
}

.topbar-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "logo main tools";
  align-items: center;
  column-gap: clamp(0.3rem, 1.2vw, 0.85rem);
  row-gap: 0.25rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: clamp(52px, 11vw, 72px);
  padding: max(0.25rem, env(safe-area-inset-top, 0px)) 0 0.3rem;
  box-sizing: border-box;
}

.topbar-bar .topbar-logo {
  grid-area: logo;
  flex-shrink: 0;
  min-width: 0;
}

.topbar-bar__nav {
  grid-area: main;
  min-width: 0;
  max-width: 100%;
  display: none;
  justify-content: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.45) transparent;
}

.topbar-bar > .topbar-search {
  grid-area: main;
  justify-self: end;
  display: none;
  min-width: 0;
  max-width: min(420px, 100%);
}

.topbar-bar .topbar-tools {
  grid-area: tools;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: nowrap;
  margin-left: 0;
  max-width: 100%;
  min-width: 0;
  gap: clamp(0.22rem, 1.2vw, 0.4rem);
}

.topbar-bar .topbar-tools > * {
  flex: 0 0 auto;
}

.topbar-list__link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.58rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--topbar-text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

#toolbarToggleBtn.topbar-a11y-pill[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.32);
  border-color: #fff;
}

.topbar-list__link:hover,
.topbar-list__link:focus-visible {
  background: var(--topbar-hover);
  border-color: var(--topbar-hover-border);
}

.topbar-list__link.is-active {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.45);
}

.topbar-list__button {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar .topbar-dropdown__menu {
  position: absolute;
  left: 0;
  top: calc(100% + 0.2rem);
  min-width: 17rem;
  border: 1px solid var(--topbar-dropdown-border, rgba(255, 255, 255, 0.22));
  border-radius: 10px;
  background: var(--topbar-dropdown-bg);
  box-shadow: var(--topbar-dropdown-shadow, 0 14px 36px rgba(7, 12, 28, 0.45));
  padding: 0.3rem;
  display: none;
  z-index: 130;
}

.topbar .topbar-dropdown__menu--wide {
  min-width: min(31rem, calc(100vw - 1rem));
}

/* Длинный список: как карточки на faq.html */
.topbar .topbar-dropdown__menu--faq {
  max-height: min(75vh, 32rem);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.4rem 0.35rem 0.45rem;
  scrollbar-color: rgba(255, 255, 255, 0.45) rgba(0, 0, 0, 0.12);
  scrollbar-gutter: stable;
}

.topbar .topbar-dropdown__head {
  margin: 0.15rem 0.4rem 0.35rem;
  padding: 0.28rem 0.22rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--topbar-dropdown-muted, rgba(255, 255, 255, 0.78));
  border-bottom: 1px solid var(--topbar-dropdown-border, rgba(255, 255, 255, 0.2));
  line-height: 1.35;
}

.topbar .topbar-dropdown__link--sub {
  font-size: 0.86rem;
  color: var(--topbar-dropdown-muted, rgba(255, 255, 255, 0.82));
  padding-top: 0.38rem;
  padding-bottom: 0.38rem;
}

.topbar .topbar-dropdown:hover .topbar-dropdown__menu,
.topbar .topbar-dropdown:focus-within .topbar-dropdown__menu {
  display: block;
}

.topbar .topbar-dropdown__link {
  display: block;
  padding: 0.5rem 0.58rem;
  border-radius: 8px;
  color: var(--topbar-dropdown-text);
  text-decoration: none;
  font-size: 0.9rem;
}

.topbar .topbar-dropdown__link:hover,
.topbar .topbar-dropdown__link:focus-visible {
  background: var(--topbar-dropdown-hover);
  color: var(--topbar-dropdown-text);
  outline: none;
}

.topbar .topbar-dropdown__link:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35) inset;
}

/* ——— Адаптивная шапка: телефон → планшет → десктоп ——— */

/* Телефон: меню в выдвижной панели, компактные кнопки (планшет 900px+ — полная шапка) */
@media (max-width: 899px) {
  header.topbar {
    overflow-x: clip;
    overflow-x: hidden;
  }

  .topbar-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "logo . tools";
    min-height: clamp(50px, 14vw, 58px);
    column-gap: clamp(0.25rem, 2vw, 0.5rem);
  }

  .topbar-row--nav,
  .topbar-bar__nav,
  .topbar-search,
  .topbar-bar > .topbar-search {
    display: none !important;
  }

  .topbar-logo__img {
    width: clamp(48px, 12vw, 56px);
    height: clamp(48px, 12vw, 56px);
  }

  .topbar-tools__lang {
    display: none;
  }

  .topbar-a11y-pill__text {
    display: none;
  }

  .topbar-bar .topbar-tools .topbar-icon-btn,
  .topbar-bar .topbar-tools #themeToggleBtn.topbar-theme-btn,
  .topbar-bar .topbar-tools #toolbarToggleBtn.topbar-a11y-pill,
  .topbar-bar .topbar-tools .topbar-a11y-pill {
    box-sizing: border-box;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    padding: 0;
    margin: 0;
    flex: 0 0 40px;
    border-radius: 10px;
    justify-content: center;
    align-items: center;
  }

  .topbar-bar .topbar-tools .topbar-a11y-pill__text {
    display: none;
  }

  .topbar-bar .topbar-tools .topbar-a11y-pill__icon {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1;
  }

  .topbar-icon-btn--search,
  .topbar-icon-btn--menu {
    display: inline-flex;
  }

  .topbar-tools {
    gap: clamp(0.2rem, 1.5vw, 0.35rem);
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .topbar-mobile-drawer__panel {
    width: min(100vw - 0.35rem, 22rem);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Узкий телефон */
@media (max-width: 700px) {
  .topbar-bar {
    min-height: 50px;
    column-gap: 0.25rem;
  }

  .topbar-logo__img {
    width: 44px;
    height: 44px;
  }

  .topbar-bar .topbar-tools .topbar-icon-btn,
  .topbar-bar .topbar-tools #themeToggleBtn.topbar-theme-btn,
  .topbar-bar .topbar-tools #toolbarToggleBtn.topbar-a11y-pill,
  .topbar-bar .topbar-tools .topbar-a11y-pill {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    flex-basis: 40px;
    border-radius: 10px;
    padding: 0;
  }

  .topbar-tools {
    gap: 0.22rem;
  }
}

@media (max-width: 380px) {
  .topbar-inner {
    padding-left: max(0.25rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.25rem, env(safe-area-inset-right, 0px));
  }

  .topbar-logo__img {
    width: 40px;
    height: 40px;
  }

  .topbar-bar .topbar-tools .topbar-icon-btn,
  .topbar-bar .topbar-tools #themeToggleBtn.topbar-theme-btn,
  .topbar-bar .topbar-tools #toolbarToggleBtn.topbar-a11y-pill,
  .topbar-bar .topbar-tools .topbar-a11y-pill {
    width: 38px;
    min-width: 38px;
    max-width: 38px;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    flex-basis: 38px;
    border-radius: 9px;
  }

  .topbar-theme-btn__icon {
    font-size: 1.05rem;
  }
}

@media (min-width: 900px) {
  .topbar-head-center {
    display: flex;
  }
}

/* Планшет и узкий десктоп: две строки — меню видно, не «огрызок» */
@media (min-width: 900px) and (max-width: 1319px) {
  header.topbar {
    overflow-x: clip;
    overflow-x: hidden;
  }

  .topbar-bar {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "logo search tools"
      "nav nav nav";
    min-height: auto;
    row-gap: 0.35rem;
    padding-bottom: 0.5rem;
    column-gap: clamp(0.45rem, 1.2vw, 0.85rem);
  }

  .topbar-bar__nav {
    grid-area: nav;
    display: flex;
    justify-self: stretch;
    overflow-x: visible;
  }

  .topbar-bar > .topbar-search {
    grid-area: search;
    display: inline-flex;
    justify-self: end;
  }

  .topbar-bar .topbar-tools {
    grid-area: tools;
  }

  .topbar-logo__img {
    width: 56px;
    height: 56px;
  }

  .topbar-icon-btn--search,
  .topbar-icon-btn--menu {
    display: none !important;
  }

  .topbar-tools__lang {
    display: inline-flex;
  }

  .topbar-nav {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    row-gap: 0.2rem;
  }

  .topbar-nav__link {
    font-size: 0.88rem;
    padding: 0.32rem 0.72rem;
  }

  .topbar-a11y-pill__text {
    display: none;
  }
}

/* Широкий десктоп: одна строка, поиск — только иконка (40px), место отдаём меню */
@media (min-width: 1320px) {
  .topbar-bar {
    grid-template-columns: auto minmax(0, 1fr) max-content auto;
    grid-template-areas: "logo nav search tools";
    min-height: 72px;
    column-gap: clamp(0.5rem, 1vw, 1rem);
  }

  .topbar-bar__nav {
    grid-area: nav;
    display: flex;
    justify-self: stretch;
    overflow-x: visible;
  }

  .topbar-bar > .topbar-search {
    grid-area: search;
    display: inline-flex;
    justify-self: end;
    max-width: max-content;
  }

  .topbar-bar .topbar-tools {
    grid-area: tools;
  }

  .topbar-logo__img {
    width: clamp(56px, 5vw, 68px);
    height: clamp(56px, 5vw, 68px);
  }

  .topbar-icon-btn--search,
  .topbar-icon-btn--menu {
    display: none !important;
  }

  .topbar-tools__lang {
    display: inline-flex;
  }

  .topbar-nav {
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }

  .topbar-nav__link {
    font-size: 0.9rem;
    padding: 0.3rem 0.78rem;
  }

  .topbar-search--compact:focus-within {
    max-width: min(14rem, 28vw);
  }
}

/* Средний широкий экран: компактнее кнопки справа, подписи меню без уменьшения шрифта */
@media (min-width: 1320px) and (max-width: 1480px) {
  .topbar-a11y-pill__text {
    display: none;
  }

  .topbar-nav__link {
    padding: 0.3rem 0.62rem;
  }
}

/* Широкий экран */
@media (min-width: 1361px) {
  .topbar-bar .topbar-tools .topbar-a11y-pill {
    width: auto;
    min-width: 0;
    max-width: none;
    height: auto;
    min-height: 40px;
    max-height: none;
    padding: 0 0.75rem;
    gap: 0.35rem;
    border-radius: 999px;
    flex: 0 0 auto;
  }

  .topbar-a11y-pill__text {
    display: inline;
  }

  .topbar-nav__link {
    font-size: 0.9rem;
    padding: 0.3rem 0.85rem;
  }
}

@media (max-width: 960px) {
  :root[data-theme="dark"] .topbar-icon-btn,
  :root[data-theme="dark"] .topbar-lang,
  :root[data-theme="dark"] .topbar-burger-btn,
  :root[data-theme="dark"] #toolbarToggleBtn.topbar-a11y-pill,
  :root[data-theme="dark"] #themeToggleBtn.topbar-theme-btn,
  :root[data-topbar-theme="dark"] .topbar-icon-btn,
  :root[data-topbar-theme="dark"] .topbar-lang,
  :root[data-topbar-theme="dark"] .topbar-burger-btn,
  :root[data-topbar-theme="dark"] #toolbarToggleBtn.topbar-a11y-pill,
  :root[data-topbar-theme="dark"] #themeToggleBtn.topbar-theme-btn {
    background: var(--theme-surface-soft, #1c2948);
    border-color: var(--theme-border, #33456d);
    color: var(--theme-text, #eef3ff) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .topbar,
  .topbar-list__link,
  #toolbarToggleBtn,
  .topbar-search,
  .topbar .topbar-dropdown__menu,
  .topbar .topbar-dropdown__link {
    transition: none !important;
  }
}

.topbar-burger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.16);
  color: var(--topbar-text, #fff);
  cursor: pointer;
  padding: 0;
  font: inherit;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.topbar-burger-btn:hover,
.topbar-burger-btn:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.74);
  outline: none;
}

.topbar-burger-icon {
  position: relative;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  box-shadow: 0 -7px 0 currentColor, 0 7px 0 currentColor;
}

.topbar-mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 1450;
}

.topbar-mobile-drawer[hidden] {
  display: none !important;
}

.topbar-mobile-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--theme-bg, #0f1628) 82%, rgba(0, 0, 0, 0.55));
  -webkit-tap-highlight-color: transparent;
}

.topbar-mobile-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100vw - 0.5rem, 22rem);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--theme-surface, #fff);
  color: var(--theme-text, #18243d);
  border-left: 1px solid var(--theme-border, #d4deef);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18);
  transform: translateX(0);
  animation: topbarDrawerIn 0.22s ease-out;
}

@keyframes topbarDrawerIn {
  from {
    transform: translateX(12px);
    opacity: 0.92;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.topbar-mobile-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--theme-border, #d4deef);
  background: color-mix(in srgb, var(--theme-primary-soft) 30%, var(--theme-surface));
}

.topbar-mobile-drawer__title {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.topbar-mobile-drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--theme-border, #d4deef);
  background: var(--theme-surface, #fff);
  color: var(--theme-text, #18243d);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.topbar-mobile-drawer__close:hover,
.topbar-mobile-drawer__close:focus-visible {
  border-color: color-mix(in srgb, var(--theme-primary, #243b84) 40%, var(--theme-border));
  outline: none;
}

.topbar-mobile-drawer__scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.5rem 0.65rem 1rem;
}

.topbar-mobile-drawer__section {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  margin-bottom: 0;
}

.topbar-mobile-drawer__link {
  display: block;
  padding: 0.62rem 0.55rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--theme-text, #18243d);
  border: 1px solid transparent;
}

.topbar-mobile-drawer__link:hover,
.topbar-mobile-drawer__link:focus-visible {
  background: color-mix(in srgb, var(--theme-primary-soft) 48%, var(--theme-surface));
  border-color: var(--theme-border, #d4deef);
  outline: none;
}

.topbar-mobile-drawer__link.is-active {
  background: color-mix(in srgb, var(--theme-primary-soft) 62%, var(--theme-surface));
  border-color: color-mix(in srgb, var(--theme-primary) 35%, var(--theme-border));
}

.topbar-mobile-drawer__hint {
  margin: 0.5rem 0 0.15rem;
  padding: 0.15rem 0.55rem 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--theme-muted, #5f6d8c);
}

.topbar-mobile-drawer__link--sub {
  font-weight: 600;
  font-size: 0.88rem;
  padding-left: 0.78rem;
}

.topbar-mobile-drawer__lang {
  margin-top: 0.35rem;
  padding: 0 0.55rem 0.5rem;
}

.topbar-mobile-drawer__lang .topbar-lang {
  width: 100%;
  max-width: 12rem;
  height: 44px;
  border-color: var(--theme-border, #d4deef);
  background: var(--theme-surface-soft, #f4f7fc);
}

.topbar-mobile-drawer__lang .topbar-lang__btn {
  flex: 1 1 50%;
  min-width: 0;
  color: var(--theme-text, #18243d);
  font-size: 0.85rem;
}

.topbar-mobile-drawer__lang .topbar-lang__btn.is-active {
  background: color-mix(in srgb, var(--theme-primary-soft) 70%, var(--theme-surface));
}

html.topbar-drawer-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .topbar-mobile-drawer__panel {
    animation: none !important;
  }
}

#themeToggleBtn.topbar-theme-btn {
  padding: 0;
  color: #fff !important;
  font-weight: 600;
  box-shadow: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}

@media (max-width: 899px) {
  #themeToggleBtn.topbar-theme-btn {
    padding: 0;
    min-width: 0;
  }

  #toolbarToggleBtn.topbar-a11y-pill {
    box-sizing: border-box;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    padding: 0;
    gap: 0;
    border-radius: 10px;
    flex: 0 0 40px;
    justify-content: center;
  }
}

#themeToggleBtn.topbar-theme-btn:hover,
#themeToggleBtn.topbar-theme-btn:focus-visible {
  background: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.55) !important;
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

#themeToggleBtn.topbar-theme-btn.is-dark-active {
  background: rgba(255, 255, 255, 0.16) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
}

.topbar-theme-btn__icon {
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0.95;
}

/* Панель слабовидящих: светлая шапка по умолчанию (не наследует тёмный фон страницы) */
html[data-a11y-on]:not([data-topbar-theme="dark"]) header.topbar {
  --topbar-bg: #243b84;
  --topbar-border: #ffffff;
  --topbar-text: #ffffff;
  --topbar-hover: rgba(255, 255, 255, 0.2);
  --topbar-hover-border: rgba(255, 255, 255, 0.55);
  --topbar-input-bg: rgba(255, 255, 255, 0.14);
  --topbar-input-border: rgba(255, 255, 255, 0.55);
  --topbar-input-placeholder: rgba(255, 255, 255, 0.88);
  --topbar-dropdown-bg: #243b84;
  --topbar-dropdown-text: #ffffff;
  --topbar-dropdown-hover: rgba(255, 255, 255, 0.2);
  --topbar-dropdown-border: rgba(255, 255, 255, 0.35);
  --topbar-dropdown-muted: rgba(255, 255, 255, 0.9);
  background: #243b84 !important;
  border-bottom-color: rgba(255, 255, 255, 0.35) !important;
  color: #ffffff !important;
}

html[data-a11y-on][data-topbar-theme="dark"] header.topbar,
html[data-a11y-on][data-a11y-scheme="dark"][data-topbar-theme="dark"] header.topbar {
  --topbar-primary: #0f1628;
  --topbar-bg: #0f1628;
  --topbar-border: #2a3d66;
  --topbar-dropdown-bg: #0f1628;
  background: #0f1628 !important;
  border-bottom-color: #2a3d66 !important;
  color: #eef3ff !important;
}

html[data-a11y-on][data-a11y-contrast="high"] header.topbar {
  --topbar-bg: #000000;
  --topbar-border: #ffffff;
  --topbar-dropdown-bg: #000000;
  background: #000000 !important;
  border-bottom-color: #ffffff !important;
}

html[data-a11y-on] header.topbar .topbar-nav__link,
html[data-a11y-on] header.topbar .topbar-list__link,
html[data-a11y-on] header.topbar .topbar-icon-btn,
html[data-a11y-on] header.topbar .topbar-lang__btn,
html[data-a11y-on] header.topbar .topbar-burger-btn,
html[data-a11y-on] header.topbar #toolbarToggleBtn.topbar-a11y-pill,
html[data-a11y-on] header.topbar #themeToggleBtn.topbar-theme-btn,
html[data-a11y-on] header.topbar .topbar-search__input,
html[data-a11y-on] header.topbar .topbar-mobile-search__input,
html[data-a11y-on] header.topbar .topbar-dropdown__link {
  color: #ffffff !important;
}

html[data-a11y-on] header.topbar .topbar-icon-btn,
html[data-a11y-on] header.topbar .topbar-lang,
html[data-a11y-on] header.topbar .topbar-burger-btn,
html[data-a11y-on] header.topbar #toolbarToggleBtn.topbar-a11y-pill,
html[data-a11y-on] header.topbar #themeToggleBtn.topbar-theme-btn {
  background: rgba(255, 255, 255, 0.14) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
}

html[data-a11y-on] header.topbar .topbar-search__input,
html[data-a11y-on][data-theme="dark"] header.topbar .topbar-search__input {
  background: transparent !important;
  color: #ffffff !important;
  border-color: transparent !important;
}

html[data-a11y-on] header.topbar .topbar-search__input::placeholder {
  color: rgba(255, 255, 255, 0.88) !important;
  opacity: 1 !important;
}

