.language-switcher {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    color: var(--text-main, #172033);
    font-family: Arial, sans-serif;
}

.language-switcher[open] {
    z-index: 1002;
}

.language-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 52px;
    height: 40px;
    border: 1px solid var(--border-light, #dfe3e8);
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
}

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

.language-toggle i {
    font-size: 10px;
    color: var(--text-muted, #64748b);
}

.language-toggle:hover,
.language-switcher[open] > .language-toggle {
    border-color: var(--text-muted, #64748b);
}

.language-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 84px;
    padding: 4px 0;
    border: 1px solid var(--border-light, #dfe3e8);
    border-radius: 4px;
    background: #fff;
}

.language-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #20262e;
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
}

.language-button[aria-pressed="true"] {
    color: #16813b;
}

.language-button:hover {
    background: #f4f6f5;
}

.language-toggle:focus-visible {
    outline: 2px solid var(--primary, #007aff);
    outline-offset: 3px;
}

.language-button:focus-visible {
    outline: 2px solid var(--primary, #007aff);
    outline-offset: -3px;
}

.language-status {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11000;
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border: 1px solid #dbe3ec;
    border-radius: 12px;
    background: #fff;
    color: #172033;
    box-shadow: 0 4px 24px #17203320;
    font-size: 14px;
}

/* The provider retains its translation controls and attribution at page end. */
.language-provider { text-align: center; }
.language-provider:empty { display: none; }
/* The site buttons replace the provider's fixed toolbar, including its offset. */
iframe.goog-te-banner-frame,
iframe.VIpgJd-ZVi9od-ORHb-OEVmcd {
    display: none !important;
}
body:has(#site-google-translate) { top: 0 !important; }
.auth-box > .language-switcher { display: block; width: fit-content; margin: 0 auto 20px; }
header:has(.language-switcher) {
    top: 0;
    height: auto;
    min-height: 80px;
}

/* Keep the logo, navigation and compact language controls on one desktop row. */
@media (min-width: 769px) {
    header .container {
        display: flex;
        flex-wrap: nowrap;
        max-width: var(--container-width, 1200px);
        gap: 28px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    header .container > div:first-child { flex: 0 0 auto; }
    header .logo { white-space: nowrap; }
    header .header-actions { flex-wrap: nowrap; }
    header .container > .language-switcher { margin-inline-start: -16px; }
    header .nav-links {
        flex: 1 1 auto;
        min-width: 0;
        gap: 24px;
        flex-wrap: nowrap;
        align-items: center;
        overflow-x: auto;
        padding-block: 6px;
    }
    header .nav-links > a {
        flex: 0 0 auto;
        font-size: 13px;
        text-transform: none;
        letter-spacing: 0;
        white-space: nowrap;
    }
    header .header-action-btn { padding-inline: 9px; }
    /* English labels need more space; other languages keep the original alignment. */
    html[data-site-language="en"] header .container { max-width: 1600px; gap: 16px; }
    html[data-site-language="en"] header .nav-links { gap: 14px; }
}

@media (max-width: 768px) {
    header .container > .language-switcher { margin-inline-start: auto; }
    .language-toggle, .language-button { height: 48px; }
    header .nav-links {
        top: var(--site-navigation-height, 80px);
        max-height: calc(100dvh - var(--header-height));
    }
}

@media print {
    .language-switcher, .language-status, .language-provider { display: none !important; }
}
