/* Multilingual: Noto Sans covers CJK; Thai/Japanese body classes tune stack */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;700&family=Noto+Sans+JP:wght@400;500;700&family=Noto+Sans+SC:wght@400;500;700&family=Noto+Sans+Thai:wght@400;500;700&display=swap');

body.locale-zh {
    font-family: 'Noto Sans SC', system-ui, sans-serif;
}

body.locale-th {
    font-family: 'Noto Sans Thai', 'Noto Sans SC', system-ui, sans-serif;
}

body.locale-ja {
    font-family: 'Noto Sans JP', 'Noto Sans SC', system-ui, sans-serif;
}

body.locale-en {
    font-family: 'Noto Sans', system-ui, -apple-system, sans-serif;
}

/* ========== 右上角语言入口 + 底部动作面板（主流 H5） ========== */
.k3-lang-root {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    z-index: 10050;
    pointer-events: none;
}

.k3-lang-root > * {
    pointer-events: auto;
}

/* 胶囊按钮：毛玻璃 + 细描边，与常见 App 顶栏入口一致 */
.k3-lang-trigger {
    position: relative;
    z-index: 10060;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 12px 0 10px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    background: rgba(15, 18, 40, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.92);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        border-color 0.15s ease;
}

.k3-lang-trigger:active {
    transform: scale(0.97);
}

.k3-lang-root.k3-lang-open .k3-lang-trigger {
    border-color: rgba(102, 126, 234, 0.55);
    box-shadow:
        0 4px 18px rgba(102, 126, 234, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.k3-lang-globe {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.9;
}

.k3-lang-trigger-text {
    max-width: 5.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.k3-lang-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.55;
    transition: transform 0.2s ease;
}

.k3-lang-root.k3-lang-open .k3-lang-chevron {
    transform: rotate(180deg);
}

/* 遮罩（关闭时不拦截页面点击） */
.k3-lang-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10040;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

.k3-lang-root.k3-lang-open .k3-lang-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* 底部动作面板 */
.k3-lang-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10045;
    max-height: min(70vh, 420px);
    padding: 0 env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    background: linear-gradient(180deg, #1a1d35 0%, #12141f 100%);
    border-radius: 18px 18px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: none;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.45);
    transform: translateY(105%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
}

.k3-lang-root.k3-lang-open .k3-lang-sheet {
    transform: translateY(0);
}

.k3-lang-sheet-handle {
    width: 36px;
    height: 4px;
    margin: 10px auto 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.18);
}

.k3-lang-sheet-title {
    margin: 0 20px 12px;
    padding: 0;
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.06em;
}

.k3-lang-list {
    list-style: none;
    margin: 0;
    padding: 4px 12px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.k3-lang-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 6px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition:
        background 0.15s ease,
        border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.k3-lang-item:active {
    background: rgba(102, 126, 234, 0.18);
}

.k3-lang-item.is-active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.35) 0%, rgba(118, 75, 162, 0.22) 100%);
    border-color: rgba(102, 126, 234, 0.45);
    color: #fff;
}

.k3-lang-item-name {
    flex: 1;
}

.k3-lang-check {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-cyan, #22d3ee);
    opacity: 0;
}

.k3-lang-item.is-active .k3-lang-check {
    opacity: 1;
}

/* 登录/注册：顶栏与刘海区 */
body.auth-page .k3-lang-root {
    top: calc(12px + env(safe-area-inset-top, 0px));
}
