.lang-switcher {
  position: relative;
  z-index: 1001;
  flex-shrink: 0;
  margin-left: auto;
  margin-right: 18px;
}

/* The brand name uses white-space: nowrap, so the logo needs an explicit
   min-width before it will yield space to the switcher. */
.header-menu > .header-logo {
  min-width: 0;
  overflow: hidden;
}

.header-menu > .header-logo .brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-switcher__current {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-switcher__btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 112px;
  height: 42px;
  padding: 0 13px;
  border: 1px solid #726cf9;
  border-radius: 5px;
  background: #fff;
  color: #1c1c1c;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lang-switcher__btn:hover,
.lang-switcher__btn[aria-expanded="true"] {
  border-color: #a66ffc;
  box-shadow: 0 0 0 2px rgba(114, 108, 249, 0.14);
}

.lang-switcher__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.lang-switcher__btn[aria-expanded="true"] .lang-switcher__chevron {
  transform: rotate(180deg);
}

.lang-switcher__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: max-content;
  min-width: 160px;
  max-height: min(70vh, 330px);
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid #dedede;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(34, 24, 73, 0.16);
}

.lang-switcher__list[hidden] {
  display: none !important;
}

.lang-switcher__list li {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
}

.lang-switcher__link {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 9px 11px;
  border-radius: 4px;
  color: #1c1c1c;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}

.lang-switcher__link:hover {
  background: #f2efff;
  color: #645ee8;
}

.lang-switcher__item--active {
  background: rgba(114, 108, 249, 0.12);
  color: #645ee8;
  font-weight: 700;
  pointer-events: none;
}

@media screen and (max-width: 991px) {
  .lang-switcher {
    margin-left: auto;
    margin-right: 12px;
  }

  .lang-switcher__btn {
    min-width: 0;
    max-width: 132px;
    height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  .lang-switcher__list {
    right: 0;
  }
}

@media screen and (max-width: 479px) {
  .lang-switcher {
    margin-right: 8px;
  }

  .lang-switcher__btn {
    min-width: 0;
    max-width: 112px;
    padding: 0 8px;
  }

  .lang-switcher__list {
    position: fixed;
    top: auto;
    right: 12px;
    left: 12px;
    width: auto;
  }
}
