.acg-lang-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 1200;
}

.acg-lang-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 42px;
    min-height: 36px;
    padding: 7px 9px;
    border: 1px solid rgba(127, 127, 127, .24);
    border-radius: 8px;
    background: rgba(255, 255, 255, .78);
    color: inherit;
    cursor: pointer;
    font: inherit;
    line-height: 1;
}

.acg-lang-button:hover,
.acg-lang-button:focus-visible {
    border-color: currentColor;
}

.acg-lang-button .material-icons-outlined {
    font-size: 18px;
}

.acg-lang-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.acg-lang-button [data-lang-label] {
    min-width: 1.8em;
    font-size: 12px;
    text-align: center;
}

.acg-lang-chevron {
    font-size: 16px !important;
}

.acg-lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    display: none;
    min-width: 132px;
    padding: 5px;
    border: 1px solid rgba(127, 127, 127, .22);
    border-radius: 8px;
    background: var(--bs-body-bg, #fff);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .16);
}

.acg-lang-menu.show {
    display: grid;
}

.acg-lang-menu button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
    white-space: nowrap;
}

.acg-lang-menu button:hover,
.acg-lang-menu button:focus-visible,
.acg-lang-menu button.active {
    background: rgba(25, 118, 210, .12);
    color: #1769aa;
}

.acg-lang-switcher-floating {
    position: fixed !important;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
}

.acg-cardyun-pc-lang-switcher {
    display: inline-flex;
    margin: 7px 8px 0 0;
    vertical-align: top;
}

.acg-cardyun-pc-lang-switcher .acg-lang-button {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    gap: 0;
}

.acg-cardyun-pc-lang-switcher .acg-lang-button [data-lang-label],
.acg-cardyun-pc-lang-switcher .acg-lang-chevron {
    display: none;
}

.acg-cardyun-pc-lang-switcher .acg-lang-button .material-icons-outlined {
    font-size: 22px;
    line-height: 1;
}

.acg-cardyun-wap-top-lang-switcher,
.acg-cardyun-wap-lang-switcher {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    top: max(8px, env(safe-area-inset-top));
    bottom: auto;
    z-index: 2000;
}

.acg-cardyun-wap-top-lang-switcher .acg-lang-button,
.acg-cardyun-wap-lang-switcher .acg-lang-button {
    min-width: 96px;
    min-height: 44px;
    padding: 0 10px;
    border: 1px solid #222;
    border-radius: 10px;
    background: #fff;
    box-shadow: none;
    gap: 7px;
}

.acg-cardyun-wap-top-lang-switcher .acg-lang-menu,
.acg-cardyun-wap-lang-switcher .acg-lang-menu {
    top: auto;
    bottom: auto;
    margin-top: 8px;
}

.acg-cardyun-wap-top-lang-switcher .acg-lang-mark,
.acg-cardyun-wap-lang-switcher .acg-lang-mark {
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
    font-size: 18px;
    font-weight: 500;
}

.acg-cardyun-wap-top-lang-switcher .acg-lang-button [data-lang-label],
.acg-cardyun-wap-lang-switcher .acg-lang-button [data-lang-label] {
    min-width: 1.2em;
    font-size: 15px;
    font-weight: 600;
}

.acg-cardyun-wap-top-lang-switcher .acg-lang-button > i,
.acg-cardyun-wap-lang-switcher .acg-lang-button > i {
    display: none;
}

/* Match the mobile reference header: globe only, with no text, arrow or box. */
.acg-cardyun-wap-top-lang-switcher .acg-lang-button,
.acg-cardyun-wap-lang-switcher .acg-lang-button {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    gap: 0;
}

.acg-cardyun-wap-top-lang-switcher .acg-lang-button [data-lang-label],
.acg-cardyun-wap-lang-switcher .acg-lang-button [data-lang-label],
.acg-cardyun-wap-top-lang-switcher .acg-lang-chevron,
.acg-cardyun-wap-lang-switcher .acg-lang-chevron {
    display: none;
}

.acg-cardyun-wap-top-lang-switcher .acg-lang-button .material-icons-outlined,
.acg-cardyun-wap-lang-switcher .acg-lang-button .material-icons-outlined {
    font-size: 22px;
    line-height: 1;
}

/* Modern mobile headers use icon-only controls in the top action row. */
.st-topbar-actions > .acg-lang-switcher,
.st-topbar__actions > .acg-lang-switcher,
.ny-appbar__actions > .acg-lang-switcher,
.nagoya-nav-tools > .acg-lang-switcher,
.tokyo-nav-tools > .acg-lang-switcher {
    flex: 0 0 auto;
}

.st-topbar-actions > .acg-lang-switcher .acg-lang-button,
.st-topbar__actions > .acg-lang-switcher .acg-lang-button,
.ny-appbar__actions > .acg-lang-switcher .acg-lang-button,
.nagoya-nav-tools > .acg-lang-switcher .acg-lang-button,
.tokyo-nav-tools > .acg-lang-switcher .acg-lang-button {
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    gap: 0;
}

.st-topbar-actions > .acg-lang-switcher .acg-lang-button [data-lang-label],
.st-topbar__actions > .acg-lang-switcher .acg-lang-button [data-lang-label],
.ny-appbar__actions > .acg-lang-switcher .acg-lang-button [data-lang-label],
.nagoya-nav-tools > .acg-lang-switcher .acg-lang-button [data-lang-label],
.tokyo-nav-tools > .acg-lang-switcher .acg-lang-button [data-lang-label] {
    display: none;
}

.st-topbar-actions > .acg-lang-switcher .acg-lang-button > span:not(.material-icons-outlined):not(.acg-lang-mark),
.st-topbar__actions > .acg-lang-switcher .acg-lang-button > span:not(.material-icons-outlined):not(.acg-lang-mark),
.ny-appbar__actions > .acg-lang-switcher .acg-lang-button > span:not(.material-icons-outlined):not(.acg-lang-mark),
.nagoya-nav-tools > .acg-lang-switcher .acg-lang-button > span:not(.material-icons-outlined):not(.acg-lang-mark),
.tokyo-nav-tools > .acg-lang-switcher .acg-lang-button > span:not(.material-icons-outlined):not(.acg-lang-mark),
.st-topbar-actions > .acg-lang-switcher .acg-lang-button > i,
.st-topbar__actions > .acg-lang-switcher .acg-lang-button > i,
.ny-appbar__actions > .acg-lang-switcher .acg-lang-button > i,
.nagoya-nav-tools > .acg-lang-switcher .acg-lang-button > i,
.tokyo-nav-tools > .acg-lang-switcher .acg-lang-button > i {
    display: none;
}

.st-topbar-actions > .acg-lang-switcher .acg-lang-chevron,
.st-topbar__actions > .acg-lang-switcher .acg-lang-chevron,
.ny-appbar__actions > .acg-lang-switcher .acg-lang-chevron,
.nagoya-nav-tools > .acg-lang-switcher .acg-lang-chevron,
.tokyo-nav-tools > .acg-lang-switcher .acg-lang-chevron {
    display: none;
}

.st-topbar-actions > .acg-lang-switcher .acg-lang-button .material-icons-outlined,
.st-topbar__actions > .acg-lang-switcher .acg-lang-button .material-icons-outlined,
.ny-appbar__actions > .acg-lang-switcher .acg-lang-button .material-icons-outlined,
.nagoya-nav-tools > .acg-lang-switcher .acg-lang-button .material-icons-outlined,
.tokyo-nav-tools > .acg-lang-switcher .acg-lang-button .material-icons-outlined {
    font-size: 22px;
}

@media (max-width: 420px) {
    .st-topbar-actions > .acg-lang-switcher .acg-lang-button,
    .st-topbar__actions > .acg-lang-switcher .acg-lang-button,
    .ny-appbar__actions > .acg-lang-switcher .acg-lang-button,
    .nagoya-nav-tools > .acg-lang-switcher .acg-lang-button,
    .tokyo-nav-tools > .acg-lang-switcher .acg-lang-button {
        min-width: 40px;
        padding: 0;
    }
}

@media (prefers-color-scheme: dark) {
    .acg-lang-button {
        background: rgba(30, 30, 30, .82);
    }
}

@media (max-width: 767.98px) {
    .acg-lang-button {
        min-height: 40px;
        padding: 9px 10px;
    }

    .acg-lang-menu {
        min-width: 148px;
    }
}

/* 官方模板语言按钮兼容层：只作用于运行时生成的语言控件。 */
.acg-lang-switcher.lang-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 1200;
}

.acg-lang-switcher.lang-switch .lang-switch__btn {
    --bs-btn-border-color: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-border-color: transparent;
    display: inline-flex;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    gap: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    line-height: 1;
    box-shadow: none;
    transition: background-color .2s ease, color .2s ease;
}

.acg-lang-switcher.lang-switch .lang-switch__btn:hover,
.acg-lang-switcher.lang-switch .lang-switch__btn:focus-visible,
.acg-lang-switcher.lang-switch.is-open .lang-switch__btn {
    background: var(--st-surface-hover, rgba(19, 150, 85, .1));
    color: inherit;
    box-shadow: none;
}

.acg-lang-switcher.lang-switch .lang-switch__btn .acg-lang-mark {
    display: inline-flex;
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
    font-size: 21px;
    font-weight: 400;
    line-height: 1;
}

.acg-lang-switcher.lang-switch .lang-switch__btn [data-lang-label],
.acg-lang-switcher.lang-switch .lang-switch__btn .lang-switch__caret,
.acg-lang-switcher.lang-switch .lang-switch__btn .acg-lang-chevron {
    display: none;
}

.acg-lang-switcher.lang-switch .acg-lang-backdrop,
.acg-lang-switcher.lang-switch .acg-lang-menu-header,
.acg-lang-switcher.lang-switch .acg-lang-option-icon,
.acg-lang-switcher.lang-switch .acg-lang-option-copy small,
.acg-lang-switcher.lang-switch .acg-lang-option-check {
    display: none;
}

.acg-lang-switcher.lang-switch .lang-switch__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    display: none;
    width: 220px;
    min-width: 220px;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--st-border, var(--acg-border, #e5e7eb));
    border-radius: 16px;
    background: var(--st-surface, var(--acg-card-bg, #fff));
    box-shadow: var(--st-overlay-shadow, 0 12px 30px rgba(15, 20, 25, .16));
}

.acg-lang-switcher.lang-switch .lang-switch__menu.show {
    display: grid;
    gap: 6px;
    animation: acg-lang-menu-enter .16s ease both;
    transform-origin: top right;
}

.acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value] {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--st-text, var(--acg-text-strong, #111319));
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
}

.acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value]:hover,
.acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value]:focus-visible {
    background: var(--st-surface-hover, #eff3f4);
    color: var(--st-text, var(--acg-text-strong, #111319));
}

.acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value].active {
    border-color: var(--st-primary, #1d9bf0);
    background: var(--st-primary-soft, #e8f5fd);
    color: var(--st-primary-readable, var(--st-primary, #0b6fa4));
    font-weight: 700;
}

.acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value].active::after {
    margin-left: auto;
    color: var(--st-primary, #1d9bf0);
    content: "✓";
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.acg-lang-switcher.lang-switch .acg-lang-option-copy {
    min-width: 0;
}

.acg-lang-switcher.lang-switch .acg-lang-option-copy strong {
    font: inherit;
}

@keyframes acg-lang-menu-enter {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 767.98px) {
    body.acg-lang-sheet-open {
        overflow: hidden;
    }

    .acg-lang-switcher.lang-switch.acg-lang-sheet-portal {
        position: fixed;
        inset: 0;
        z-index: 3000;
        width: 0;
        height: 0;
        pointer-events: none;
    }

    .acg-lang-switcher.lang-switch.acg-lang-sheet-portal > .lang-switch__btn {
        display: none;
    }

    .acg-lang-switcher.lang-switch.acg-lang-sheet-portal > .acg-lang-backdrop,
    .acg-lang-switcher.lang-switch.acg-lang-sheet-portal > .lang-switch__menu {
        pointer-events: auto;
    }

    .acg-lang-switcher.lang-switch .acg-lang-backdrop {
        position: fixed;
        inset: 0;
        z-index: 2998;
        display: none;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        background: rgba(15, 20, 25, .42);
        cursor: pointer;
    }

    .acg-lang-switcher.lang-switch.is-open .acg-lang-backdrop {
        display: block;
    }

    .acg-lang-switcher.lang-switch .lang-switch__menu {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 2999;
        width: 100vw;
        min-width: 0;
        max-height: min(80vh, 560px);
        overflow-y: auto;
        padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -8px 30px rgba(15, 20, 25, .18);
        transform-origin: bottom center;
    }

    .acg-lang-switcher.lang-switch .lang-switch__menu.show {
        display: grid;
        gap: 10px;
        animation: acg-lang-sheet-enter .2s ease both;
    }

    .acg-lang-switcher.lang-switch .acg-lang-menu-header {
        display: flex;
        min-height: 58px;
        align-items: center;
        justify-content: space-between;
        padding: 0 2px 8px;
        border-bottom: 1px solid var(--st-border, var(--acg-border, #e5e7eb));
    }

    .acg-lang-switcher.lang-switch .acg-lang-menu-header > div {
        display: grid;
        gap: 2px;
    }

    .acg-lang-switcher.lang-switch .acg-lang-menu-header strong {
        color: var(--st-text, var(--acg-text-strong, #111319));
        font-size: 20px;
        font-weight: 800;
        line-height: 1.2;
    }

    .acg-lang-switcher.lang-switch .acg-lang-menu-header small {
        color: var(--st-text-secondary, var(--acg-text-muted, #6b7280));
        font-size: 13px;
    }

    .acg-lang-switcher.lang-switch .acg-lang-close {
        display: inline-flex;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: transparent;
        color: var(--st-text-secondary, #6b7280);
        cursor: pointer;
    }

    .acg-lang-switcher.lang-switch .acg-lang-close:hover,
    .acg-lang-switcher.lang-switch .acg-lang-close:focus-visible {
        background: var(--st-surface-hover, #eff3f4);
        color: var(--st-text, #111319);
    }

    .acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value] {
        display: grid;
        grid-template-columns: 40px minmax(0, 1fr) 24px;
        min-height: 66px;
        align-items: center;
        padding: 10px 14px;
        border: 1px solid var(--st-border-strong, var(--acg-border, #e5e7eb));
        border-radius: 16px;
        background: var(--st-surface, var(--acg-card-bg, #fff));
        column-gap: 10px;
        font-size: 15px;
    }

    .acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value].active {
        border-color: var(--st-warning, #f4a261);
        background: var(--st-warning-soft, #fff3e8);
        color: var(--st-text, var(--acg-text-strong, #111319));
    }

    .acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value].active::after {
        display: none;
    }

    .acg-lang-switcher.lang-switch .acg-lang-option-icon {
        display: inline-flex;
        width: 34px;
        height: 34px;
        align-items: center;
        justify-content: center;
        color: var(--st-text-secondary, #6b7280);
        font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
        font-size: 18px;
        font-weight: 600;
        letter-spacing: -2px;
        line-height: 1;
    }

    .acg-lang-switcher.lang-switch .acg-lang-option-copy {
        display: grid;
        min-width: 0;
        gap: 2px;
    }

    .acg-lang-switcher.lang-switch .acg-lang-option-copy strong {
        overflow: hidden;
        color: var(--st-text, var(--acg-text-strong, #111319));
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .acg-lang-switcher.lang-switch .acg-lang-option-copy small {
        display: block;
        color: var(--st-text-secondary, var(--acg-text-muted, #6b7280));
        font-size: 13px;
        font-weight: 500;
    }

    .acg-lang-switcher.lang-switch .acg-lang-option-check {
        display: none;
        width: 24px;
        height: 24px;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: #f2ad00;
        color: #171717;
        font-size: 17px;
        font-weight: 700;
    }

    .acg-lang-switcher.lang-switch .lang-switch__menu [data-lang-value].active .acg-lang-option-check {
        display: inline-flex;
    }
}

@keyframes acg-lang-sheet-enter {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .acg-lang-switcher.lang-switch .lang-switch__menu.show {
        animation: none;
    }
}

/* NewYork/legacy mobile headers: keep the globe readable in both themes. */
.acg-lang-switcher .acg-lang-button,
.lang-switch > .lang-switch__btn {
    color: var(--st-text, var(--ny-ink, var(--acg-text-strong, #111319))) !important;
}

.acg-lang-switcher .acg-lang-button .acg-lang-mark,
.lang-switch > .lang-switch__btn > .fa-globe {
    color: inherit !important;
}

.acg-lang-switcher .acg-lang-button:hover,
.acg-lang-switcher .acg-lang-button:focus-visible,
.lang-switch > .lang-switch__btn:hover,
.lang-switch > .lang-switch__btn:focus-visible {
    background: var(--st-surface-hover, var(--ny-surface-3, rgba(127, 127, 127, .12))) !important;
}

@media (max-width: 767.98px) {
    .lang-switch > .lang-switch__btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: transparent !important;
        gap: 0;
    }
}
