/* V849 — polished profile-adjacent language dropdown with real SVG flags. */
.app-modern-shell .app-language-switcher {
    position: relative !important;
    display: block !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
}

.app-modern-shell .app-language-switcher > summary.app-language-switcher__button {
    list-style: none !important;
    min-width: 144px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 12px 0 11px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    border: 1px solid #d4d9e0 !important;
    border-radius: 16px !important;
    background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%) !important;
    color: #1b2128 !important;
    box-shadow: 0 10px 24px rgba(17, 24, 39, .06), inset 0 1px 0 rgba(255, 255, 255, .9) !important;
    cursor: pointer !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, transform .18s ease !important;
}
.app-modern-shell .app-language-switcher > summary.app-language-switcher__button::-webkit-details-marker { display: none !important; }
.app-modern-shell .app-language-switcher > summary.app-language-switcher__button::marker { content: "" !important; }
.app-modern-shell .app-language-switcher > summary.app-language-switcher__button:hover,
.app-modern-shell .app-language-switcher[open] > summary.app-language-switcher__button {
    border-color: #c6ccd5 !important;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfd 100%) !important;
}
.app-modern-shell .app-language-switcher > summary.app-language-switcher__button:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 4px rgba(61, 106, 247, .14), 0 12px 28px rgba(17, 24, 39, .08) !important;
}
.app-modern-shell .app-language-switcher[open] > summary.app-language-switcher__button {
    box-shadow: 0 16px 36px rgba(17, 24, 39, .1), inset 0 1px 0 rgba(255, 255, 255, .92) !important;
}

.app-language-switcher__current {
    min-width: 0;
    display: none;
    align-items: center;
    gap: 10px;
    color: inherit;
    font: 700 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: -.012em;
    white-space: nowrap;
}
html[data-app-language="ru"] .app-language-switcher__current--ru,
html[data-app-language="en"] .app-language-switcher__current--en,
html[data-app-language="zh"] .app-language-switcher__current--zh { display: inline-flex; }

.app-language-switcher__chevron {
    width: 14px !important;
    height: 14px !important;
    flex: 0 0 auto;
    color: #66707c;
    transition: transform .18s ease, color .18s ease;
}
.app-language-switcher[open] .app-language-switcher__chevron {
    transform: rotate(180deg);
    color: #2f3640;
}

.app-language-switcher__menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1600;
    width: 232px;
    padding: 8px;
    display: grid;
    gap: 4px;
    border: 1px solid #e4e8ed;
    border-radius: 20px;
    background: rgba(255, 255, 255, .98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 28px 72px rgba(17, 24, 39, .16), 0 3px 12px rgba(17, 24, 39, .06);
}

.app-language-switcher__option {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-width: 0;
    height: 50px;
    padding: 0 12px;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 12px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #232a33;
    text-align: left;
    font: 700 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    transition: background-color .14s ease, color .14s ease, transform .14s ease;
}
.app-language-switcher__option:hover {
    background: #f5f7fa;
    color: #161b21;
}
.app-language-switcher__option:focus-visible {
    outline: none;
    background: #f2f5ff;
    box-shadow: inset 0 0 0 1px rgba(61, 106, 247, .22);
}
.app-language-switcher__option:active { transform: scale(.992); }
.app-language-switcher__option[aria-checked="true"] {
    background: #f3f5f7;
    color: #151a20;
}
.app-language-switcher__option-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}
.app-language-switcher__check {
    justify-self: end;
    color: #20262d;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    opacity: 0;
    transform: scale(.82);
    transition: opacity .14s ease, transform .14s ease;
}
.app-language-switcher__option[aria-checked="true"] .app-language-switcher__check { opacity: 1; transform: scale(1); }

/* SVG flags stay crisp and consistent across desktop, mobile and different OS emoji fonts. */
.app-language-flag {
    display: inline-block;
    width: 26px;
    height: 18px;
    flex: 0 0 26px;
    border: 1px solid rgba(17, 24, 39, .12);
    border-radius: 6px;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
    overflow: hidden;
}
.app-language-flag--ru { background-image: url("/static/flags/ru.svg"); }
.app-language-flag--us { background-image: url("/static/flags/us.svg"); }
.app-language-flag--cn { background-image: url("/static/flags/cn.svg"); }

html[data-app-theme="dark"] .app-modern-shell .app-language-switcher > summary.app-language-switcher__button {
    background: linear-gradient(180deg, #1e252d 0%, #181d24 100%) !important;
    border-color: #2f3843 !important;
    color: #edf2f7 !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .2), inset 0 1px 0 rgba(255, 255, 255, .03) !important;
}
html[data-app-theme="dark"] .app-modern-shell .app-language-switcher > summary.app-language-switcher__button:hover,
html[data-app-theme="dark"] .app-modern-shell .app-language-switcher[open] > summary.app-language-switcher__button {
    border-color: #3b4653 !important;
    background: linear-gradient(180deg, #222a33 0%, #1a2028 100%) !important;
}
html[data-app-theme="dark"] .app-language-switcher__chevron { color: #aab5c3; }
html[data-app-theme="dark"] .app-language-switcher[open] .app-language-switcher__chevron { color: #edf2f7; }
html[data-app-theme="dark"] .app-language-switcher__menu {
    background: rgba(25, 30, 37, .96);
    border-color: #2f3843;
    box-shadow: 0 28px 72px rgba(0, 0, 0, .42), 0 3px 10px rgba(0, 0, 0, .22);
}
html[data-app-theme="dark"] .app-language-switcher__option { color: #dae2ec; }
html[data-app-theme="dark"] .app-language-switcher__option:hover,
html[data-app-theme="dark"] .app-language-switcher__option[aria-checked="true"] {
    background: #252d37;
    color: #fff;
}
html[data-app-theme="dark"] .app-language-switcher__option:focus-visible {
    background: #273142;
    box-shadow: inset 0 0 0 1px rgba(124, 160, 255, .34);
}
html[data-app-theme="dark"] .app-language-switcher__check { color: #f4f7fa; }
html[data-app-theme="dark"] .app-language-flag { border-color: rgba(255, 255, 255, .16); box-shadow: 0 1px 3px rgba(0, 0, 0, .28); }

@media (max-width: 1120px) {
    .app-modern-shell .app-language-switcher > summary.app-language-switcher__button {
        min-width: 136px !important;
        height: 38px !important;
        min-height: 38px !important;
        padding-inline: 10px !important;
        border-radius: 14px !important;
    }
    .app-language-switcher__menu { width: 220px; }
    .app-language-switcher__option { height: 47px; }
}

@media (max-width: 760px) {
    .app-modern-shell .app-language-switcher {
        height: auto !important;
        min-height: 0 !important;
    }
    .app-modern-shell .app-language-switcher > summary.app-language-switcher__button {
        min-width: 132px !important;
        width: auto !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 9px !important;
    }
    .app-language-switcher__current { gap: 8px; font-size: 12px; }
    .app-language-flag { width: 24px; height: 16px; flex-basis: 24px; }
    .app-language-switcher__menu {
        position: fixed;
        top: calc(var(--ma-mobile-header-h, 54px) + var(--ma-mobile-utility-h, 48px) + 6px);
        right: 8px;
        width: min(216px, calc(100vw - 16px));
        border-radius: 18px;
    }
    .app-language-switcher__option {
        height: 46px;
        padding-inline: 11px;
        grid-template-columns: 24px minmax(0, 1fr) 18px;
        gap: 11px;
    }
}


/* In the compact utility rail the language switcher must match the neighbouring controls
   instead of stretching to the full bar height. */
.app-modern-shell .workspace-utility-bar .app-language-switcher {
    align-self: center !important;
    height: auto !important;
    min-height: 0 !important;
}
.app-modern-shell .workspace-utility-bar .app-language-switcher > summary.app-language-switcher__button {
    align-self: center !important;
}

/* V852 — exact height parity with adjacent utility controls.
   Desktop top rail is 44px high, but Search / Stores / Profile controls are 36px.
   The language control must use the same 36px control height, not the rail height. */
@media (min-width: 1121px) {
    html body.app-modern-shell .workspace-utility-bar .app-language-switcher > summary.app-language-switcher__button {
        height: 36px !important;
        min-height: 36px !important;
        border-radius: 10px !important;
        border-color: rgba(0, 0, 0, .09) !important;
        background: rgba(255, 255, 255, .70) !important;
        box-shadow: none !important;
    }
    html body.app-modern-shell .workspace-utility-bar .app-language-switcher > summary.app-language-switcher__button:hover,
    html body.app-modern-shell .workspace-utility-bar .app-language-switcher[open] > summary.app-language-switcher__button {
        background: rgba(232, 232, 237, .78) !important;
        border-color: rgba(0, 0, 0, .09) !important;
        box-shadow: none !important;
    }
    html[data-app-theme="dark"] body.app-modern-shell .workspace-utility-bar .app-language-switcher > summary.app-language-switcher__button {
        border-color: rgba(255, 255, 255, .10) !important;
        background: rgba(44, 44, 46, .82) !important;
        color: rgba(255, 255, 255, .82) !important;
        box-shadow: none !important;
    }
    html[data-app-theme="dark"] body.app-modern-shell .workspace-utility-bar .app-language-switcher > summary.app-language-switcher__button:hover,
    html[data-app-theme="dark"] body.app-modern-shell .workspace-utility-bar .app-language-switcher[open] > summary.app-language-switcher__button {
        background: rgba(58, 58, 60, .92) !important;
        border-color: rgba(255, 255, 255, .10) !important;
        box-shadow: none !important;
    }
}

/* Compact/tablet rail uses 38px controls in the existing adaptive shell. */
@media (max-width: 1120px) {
    html body.app-modern-shell .workspace-utility-bar .app-language-switcher > summary.app-language-switcher__button {
        height: 38px !important;
        min-height: 38px !important;
        border-radius: 11px !important;
        box-shadow: none !important;
    }
    html body.app-modern-shell .workspace-utility-bar .app-language-switcher[open] > summary.app-language-switcher__button {
        box-shadow: none !important;
    }
}
