.language-switcher {
  position: relative;
  z-index: 24;
  flex: 0 0 auto;
  pointer-events: auto;
}

.language-switcher summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.language-switcher summary::-webkit-details-marker {
  display: none;
}

.language-switcher summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin: -3px 1px 0 3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 160ms ease, margin 160ms ease;
}

.language-switcher[open] summary,
.language-switcher summary:hover {
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.language-switcher[open] summary::after {
  margin-top: 3px;
  transform: rotate(225deg);
}

.language-switcher-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(530px, calc(100vh - 96px));
  padding: 10px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 22px;
  background: rgba(8, 14, 34, 0.9);
  box-shadow: 0 24px 70px rgba(2, 6, 22, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
}

.language-switcher-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 45px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.76);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.language-switcher-menu a:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.08);
}

.language-switcher-menu a.active {
  color: #fff;
  border-color: rgba(168, 188, 255, 0.28);
  background: linear-gradient(135deg, rgba(88, 128, 255, 0.26), rgba(210, 111, 255, 0.2));
}

.language-switcher-menu a span:last-child {
  color: rgba(255, 255, 255, 0.42);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.topbar.on-light .language-switcher summary {
  color: rgba(18, 29, 58, 0.7);
  border-color: rgba(20, 34, 67, 0.12);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 26px rgba(35, 48, 87, 0.08);
}

.topbar.on-light .language-switcher[open] summary,
.topbar.on-light .language-switcher summary:hover {
  color: #101a35;
  border-color: rgba(20, 34, 67, 0.22);
  background: rgba(255, 255, 255, 0.94);
}

@media (max-width: 760px) {
  .topbar-inner:has(.language-switcher) .nav {
    max-width: calc(100vw - 184px);
  }

  .language-switcher summary {
    width: 40px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .language-switcher summary::before {
    content: "文";
    font-size: 13px;
    line-height: 1;
  }

  .language-switcher summary::after {
    display: none;
  }

  .language-switcher-menu {
    position: fixed;
    top: 70px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100vh - 84px);
  }
}

@media (max-width: 420px) {
  .language-switcher-menu {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .language-switcher summary,
  .language-switcher summary::after,
  .language-switcher-menu a {
    transition: none;
  }
}
