/* =====================================================================
   语言切换（顶栏）：按钮 + 下拉面板
   默认收起，点击按钮展开；点面板外部 / ESC / 改变窗口大小即收起。
   ===================================================================== */
.jp-lang {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.jp-lang__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-full);
  background: #fff;
  color: var(--c-ink-2);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color .2s, color .2s, box-shadow .2s;
}

.jp-lang__btn:hover,
.jp-lang.is-open .jp-lang__btn {
  border-color: var(--c-brand-tx);
  color: var(--c-brand-tx);
  box-shadow: 0 2px 8px rgba(31, 111, 235, .12);
}

.jp-lang__btn > svg:first-child {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--c-brand-tx);
}

.jp-lang__arw {
  width: 12px;
  height: 12px;
  flex: none;
  transition: transform .22s ease;
}

.jp-lang.is-open .jp-lang__arw {
  transform: rotate(180deg);
}

.jp-lang__cur {
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 面板 */
.jp-lang__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 70;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  width: 322px;
  max-height: 336px;
  overflow-y: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  box-shadow: 0 14px 38px rgba(18, 21, 26, .14);
}

.jp-lang.is-open .jp-lang__panel {
  display: grid;
}

.jp-lang__panel a {
  display: block;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-ink-2);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .16s, color .16s;
}

.jp-lang__panel a:hover {
  background: var(--c-brand-t);
  color: var(--c-brand-tx);
}

.jp-lang__panel a.is-on {
  background: var(--c-brand-t);
  color: var(--c-brand-tx);
  font-weight: 800;
}

/* 滚动条（细一点，亮色风格） */
.jp-lang__panel::-webkit-scrollbar {
  width: 6px;
}
.jp-lang__panel::-webkit-scrollbar-thumb {
  background: var(--c-line);
  border-radius: 3px;
}

/* 移动端：顶栏压扁，面板改为贴边全宽，避免溢出 */
@media (max-width: 768px) {
  .jp-lang__btn {
    height: 24px;
    padding: 0 8px;
    font-size: 12px;
  }
  .jp-lang__cur {
    max-width: 76px;
  }
  .jp-lang__panel {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 60vh;
  }
}

/* 小屏：顶栏太挤时优先让位给语言切换 —— 资质徽章收起，地址省略 */
@media (max-width: 900px) {
  .jp-top__badges {
    display: none;
  }
  .jp-top__l > .jp-top__i:first-child {
    display: none;
  }
  .jp-top__l {
    overflow: hidden;
  }
  .jp-top__l .jp-top__i {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* 语言项图标（圆形字母/汉字徽标，避开国旗争议） -------------------- */
.jp-lang__panel a {
  display: flex;
  align-items: center;
  gap: 8px;
}
.jp-lang__fk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c-brand-t);
  color: var(--c-brand-tx);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .01em;
}
.jp-lang__nm {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 中文两个站点用汉字，字号略大一点 */
.jp-lang__panel a[data-lang="cn"] .jp-lang__fk,
.jp-lang__panel a[data-lang="zh-Hant"] .jp-lang__fk {
  font-size: 12px;
  font-weight: 700;
}

/* 语言项图标改为国旗图片（替代原字母徽标） ------------------------- */
.jp-lang__fk {
  width: 22px;
  height: 16px;
  border-radius: 3px;
  object-fit: cover;
  flex: none;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(18, 21, 26, .10), 0 1px 2px rgba(18, 21, 26, .06);
}
.jp-lang__panel {
  width: 360px;
}
