#header .tools-header {
  max-width: calc(100vw - 24px);
}

.tools-nav .lang-switcher {
  margin-inline-start: auto;
}

.lang-switcher {
  position: relative;
  flex: 0 0 auto;
  color: #333333;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  text-align: start;
}

.lang-switcher button,
.lang-switcher input {
  box-sizing: border-box;
  font: inherit;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid #dbe4ea;
  border-radius: 6px;
  background: #ffffff;
  color: #333333;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  cursor: pointer;
}

.lang-toggle:hover,
.lang-switcher.open .lang-toggle {
  background: #eef6fa;
  border-color: #057cb5;
  color: #057cb5;
}

.lang-switcher svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.lang-toggle-code {
  direction: ltr;
}

.lang-toggle .lang-toggle-arrow {
  width: 12px;
  height: 12px;
  transition: transform 0.15s ease;
}

.lang-switcher.open .lang-toggle-arrow {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  z-index: 1000;
  inset-block-start: calc(100% + 8px);
  inset-inline-end: 0;
  width: min(320px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid #dbe4ea;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.15);
  line-height: 1.4;
}

.lang-dropdown[hidden],
.lang-list li[hidden],
.lang-no-results[hidden] {
  display: none;
}

.lang-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #dbe4ea;
  border-radius: 6px;
  color: #666666;
}

.lang-search {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  border: 0;
  background: #ffffff;
  color: #333333;
  font-size: 0.9rem !important;
}

.lang-search:focus {
  outline: none;
}

.lang-search-wrap:focus-within,
.lang-toggle:focus-visible,
.lang-list li:focus-visible {
  outline: 2px solid #057cb5;
  outline-offset: 2px;
}

.lang-list {
  max-height: min(300px, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.lang-list li {
  margin: 2px 0;
  border-radius: 6px;
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #333333;
  text-align: start;
  cursor: pointer;
}

.lang-option:hover:not(:disabled),
.lang-list li:focus .lang-option {
  background: #eef6fa;
}

.lang-option.active {
  background: #057cb5;
  color: #ffffff;
}

.lang-option.active:hover,
.lang-list li:focus .lang-option.active {
  background: #005a9c;
}

.lang-option-native {
  font-size: 0.95rem;
  font-weight: 600;
  unicode-bidi: isolate;
}

.lang-option-name {
  font-size: 0.75rem;
  opacity: 0.8;
  text-align: end;
}

.lang-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lang-no-results {
  margin: 0;
  padding: 16px 8px;
  color: #666666;
  font-size: 0.9rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .lang-toggle-arrow {
    transition: none !important;
  }
}
