.lang-switcher {
  position: relative;
  z-index: 1000;
  flex-shrink: 0;
  margin-right: 0.5rem;
  min-width: 0;
}

/* Standalone bar on pages without site header (privacy, terms, auth…) */
.lang-switcher-bar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1050;
}

.lang-switcher-bar .lang-switcher {
  margin-right: 0;
}

.lang-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2.5rem;
  padding: 0 0.85rem;
  border: 0;
  border-radius: 5px;
  background: #93c5fd;
  color: #0d121b;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.2s ease;
}

.lang-switcher__btn:hover {
  filter: brightness(0.97);
}

.lang-switcher__btn[aria-expanded="true"] {
  filter: brightness(0.95);
}

.lang-switcher__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.lang-switcher__btn[aria-expanded="true"] .lang-switcher__chevron {
  transform: rotate(180deg);
}

header .lang-switcher__list,
.lang-switcher__list {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  left: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  width: max-content;
  min-width: 11.5rem;
  max-width: min(16rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 22rem);
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  border: 1px solid rgba(13, 18, 27, 0.12);
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 8px 24px rgba(13, 18, 27, 0.12);
  box-sizing: border-box;
}

header .lang-switcher__list[hidden],
.lang-switcher__list[hidden] {
  display: none !important;
}

header .lang-switcher__list li,
.lang-switcher__list li {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  line-height: normal;
  list-style: none;
}

header .lang-switcher__list a,
.lang-switcher__link {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  border-radius: 0.375rem;
  color: #0d121b;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

header .lang-switcher__list a:hover,
.lang-switcher__link:hover {
  background: rgba(147, 197, 253, 0.35);
  color: #0d121b;
}

header .lang-switcher__list a.lang-switcher__item--active,
.lang-switcher__item--active {
  background: rgba(147, 197, 253, 0.55);
  color: #0d121b;
  font-weight: 600;
  pointer-events: none;
}

/* Duplicate inside burger menu — switcher stays in header bar */
.lang-switcher--mobile,
.lang-switcher-mobile-item {
  display: none !important;
}

/*
 * Adaptive header: lang switcher visible next to CTAs / hamburger.
 * Match hamburger breakpoint from style.css (max-width 1279px).
 */
@media (max-width: 1279px) {
  header.bg-white > .container > .flex > .lang-switcher:not(.lang-switcher--mobile) {
    display: block;
    order: 2;
    flex-shrink: 0;
    margin-right: 0.25rem;
    margin-left: 0;
  }

  header.bg-white > .container > .flex > .flex-shrink-0 {
    order: 3;
    flex-shrink: 0;
    min-width: 0;
  }

  header.bg-white > .container > .flex > div:first-child {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }

  .lang-switcher__btn {
    height: 2.25rem;
    padding: 0 0.65rem;
    font-size: 0.8125rem;
  }

  .lang-switcher__list {
    min-width: 10rem;
    max-width: min(16rem, calc(100vw - 1rem));
  }
}

/* Compact code label on narrow screens (ES, DE, DA…) */
@media (max-width: 639px) {
  .lang-switcher:not(.lang-switcher--mobile) .lang-switcher__current {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .lang-switcher:not(.lang-switcher--mobile) .lang-switcher__btn {
    padding: 0 0.5rem;
    min-width: 2.65rem;
    justify-content: center;
    gap: 0.2rem;
  }

  .lang-switcher:not(.lang-switcher--mobile) .lang-switcher__btn::before {
    content: attr(data-lang-code);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
  }

  .lang-switcher:not(.lang-switcher--mobile) .lang-switcher__chevron {
    width: 10px;
    height: 6px;
  }
}
