.lang-switcher {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left, 0px));
  bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  z-index: 60;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.lang-switcher__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgb(51 65 85);
  border-radius: 9999px;
  background: rgb(15 23 42 / 0.92);
  backdrop-filter: blur(12px);
  color: rgb(226 232 240);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    0 4px 24px rgb(0 0 0 / 0.35),
    0 0 0 1px rgb(255 255 255 / 0.04) inset;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.lang-switcher__trigger:hover,
.lang-switcher__trigger:focus-visible {
  background: rgb(30 41 59 / 0.96);
  border-color: rgb(220 38 38 / 0.45);
  outline: none;
  box-shadow:
    0 6px 28px rgb(127 29 29 / 0.25),
    0 0 0 2px rgb(220 38 38 / 0.25);
}

.lang-switcher.is-open .lang-switcher__trigger {
  border-color: rgb(220 38 38 / 0.6);
  background: rgb(30 41 59);
}

.lang-switcher__globe {
  color: rgb(248 113 113);
  flex-shrink: 0;
}

.lang-switcher__current {
  max-width: 8.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-switcher__chevron {
  color: rgb(148 163 184);
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.lang-switcher.is-open .lang-switcher__chevron {
  transform: rotate(180deg);
}

.lang-switcher__panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.5rem);
  width: min(22rem, calc(100vw - 1.5rem));
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.98);
  transform-origin: left bottom;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0.22s ease;
  pointer-events: none;
}

.lang-switcher.is-open .lang-switcher__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.lang-switcher__panel[hidden] {
  display: block;
}

.lang-switcher__panel-inner {
  border: 1px solid rgb(51 65 85);
  border-radius: 0.875rem;
  background: rgb(15 23 42 / 0.97);
  backdrop-filter: blur(16px);
  box-shadow:
    0 12px 40px rgb(0 0 0 / 0.45),
    0 0 0 1px rgb(255 255 255 / 0.04) inset;
  overflow: hidden;
}

.lang-switcher__heading {
  margin: 0;
  padding: 0.75rem 1rem 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(100 116 139);
}

.lang-switcher__list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0.5rem 0.5rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.125rem 0.35rem;
  max-height: min(18.5rem, 55vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgb(71 85 105) transparent;
}

.lang-switcher__list > li {
  min-width: 0;
}

.lang-switcher__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.5rem 0.55rem;
  border-radius: 0.5rem;
  color: rgb(203 213 225);
  text-decoration: none;
  font-size: 0.8125rem;
  line-height: 1.25;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.lang-switcher__option:hover,
.lang-switcher__option:focus-visible {
  background: rgb(51 65 85 / 0.55);
  color: rgb(248 250 252);
  outline: none;
}

.lang-switcher__option.is-active {
  background: rgb(127 29 29 / 0.35);
  color: rgb(254 226 226);
  font-weight: 600;
}

.lang-switcher__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-switcher__check {
  color: rgb(248 113 113);
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .lang-switcher__current {
    max-width: 5.5rem;
  }

  .lang-switcher__panel {
    width: min(calc(100vw - 1.25rem), 20rem);
  }

  .lang-switcher__list {
    max-height: min(16rem, 50vh);
    gap: 0.1rem 0.25rem;
  }

  .lang-switcher__option {
    padding: 0.45rem 0.5rem;
    font-size: 0.78125rem;
  }
}

@media (max-width: 360px) {
  .lang-switcher__list {
    grid-template-columns: 1fr;
    max-height: min(14rem, 45vh);
  }

  .lang-switcher__label {
    white-space: normal;
  }
}

[dir="rtl"] .lang-switcher {
  left: auto;
  right: max(0.75rem, env(safe-area-inset-right, 0px));
}

[dir="rtl"] .lang-switcher__panel {
  left: auto;
  right: 0;
  transform-origin: right bottom;
}
