#languageSelect {
    position: absolute;
    left: auto;
    right: 0;
    bottom: auto;
    display: block;
    min-width: 84px;
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
    -webkit-box-flex: 0;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    z-index: 99;
}

html[lang="ar-AR"] #languageSelect {
    right: auto;
    left: 0;
}

@media screen and (max-width: 991px) {
    #languageSelect {
        position: static;
    }
}

#languageSelect .languageSelect-container {
    position: relative;
}

#languageSelect .languageSelect-toggle {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    margin-top: 0;
    margin-bottom: 0;
    padding: 8px 20px 8px 12px;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    border-radius: 5px;
    background-color: #030729;
    color: #fff;
}

#languageSelect .flag-icon {
    width: 20px;
    height: 15px;
    margin-right: 5px;
}

#languageSelect .lang {
    display: block;
    max-height: 20px;
    margin-right: 0;
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
    font-size: 14px;
    line-height: 20px;
}

#languageSelect .arrow {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 3px;
    border-color: transparent #fff #fff transparent;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
}

#languageSelect .languageSelect-list {
    display: none;
    position: absolute;
    right: 0;
    width: 130px;
    min-width: 100%;
    padding-top: 4px;
    padding-bottom: 4px;
    border-style: solid;
    border-width: 1px;
    border-color: rgba(0, 0, 0, 0.15);
    background-color: #fff;
}

#languageSelect .languageSelect-list.show {
    display: block;
}

#languageSelect .languageSelect-list-item-link {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
    padding: 3px 5px;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    border: 2px solid transparent;
    color: #000;
    font-size: 14px;
    text-decoration: none;
    -webkit-transition: border-color 300ms ease;
    -o-transition: border-color 300ms ease;
    transition: border-color 300ms ease;
}

#languageSelect .languageSelect-list-item-link:hover {
    border-color: #c4cbfa;
    background-color: #dfe4fe;
}


#languageSelect .languageSelect-list-item-link-flag {
    width: 22px;
    height: 18px;
    margin-right: 4px;
}

/* Header: logo + WPML-style language dropdown (de / fr) */
.header-brand-with-lang {
    display: flex;
    align-items: center;
    gap: 14px;
   
}

.header-lang__switcher .wpml-ls-legacy-dropdown {
    width: auto;
    min-width: 8.5em;
    max-width: 100%;
}

.header-lang__switcher .wpml-ls-legacy-dropdown > ul {
    position: relative;
    padding: 0;
    margin: 0 !important;
    list-style-type: none;
}

.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-item {
    padding: 0;
    margin: 0;
    list-style-type: none;
}

.header-lang__switcher .wpml-ls-legacy-dropdown a {
    display: block;
    text-decoration: none;
    color: #444;
    border: 1px solid #cdcdcd;
    background-color: #fff;
    padding: 5px 10px;
    line-height: 1;
}

.header-lang__switcher .wpml-ls-legacy-dropdown a span {
    vertical-align: middle;
}

.header-lang__switcher .wpml-ls-legacy-dropdown a.wpml-ls-item-toggle {
    position: relative;
    padding-right: calc(10px + 1.4em);
    cursor: pointer;
}

.header-lang__switcher .wpml-ls-legacy-dropdown a.wpml-ls-item-toggle:after {
    content: "";
    vertical-align: middle;
    display: inline-block;
    border: 0.35em solid transparent;
    border-top: 0.5em solid #444;
    position: absolute;
    right: 10px;
    top: calc(50% - 0.175em);
}

.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-current-language:hover > a,
.header-lang__switcher .wpml-ls-legacy-dropdown a:focus,
.header-lang__switcher .wpml-ls-legacy-dropdown a:hover {
    color: #000;
    background: #eee;
}

.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-sub-menu {
    visibility: hidden;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    border-top: 1px solid #cdcdcd;
    padding: 0;
    margin: 0;
    list-style-type: none;
    z-index: 200;
}

.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-current-language.is-open .wpml-ls-sub-menu,
.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-current-language:hover .wpml-ls-sub-menu,
.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-current-language:focus-within .wpml-ls-sub-menu {
    visibility: visible;
}

.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-sub-menu a {
    border-width: 0 1px 1px;
}

.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-flag {
    display: inline;
    vertical-align: middle;
}

.header-lang__switcher .wpml-ls-legacy-dropdown .wpml-ls-flag + span {
    margin-left: 0.4em;
}

@media screen and (max-width: 991px) {
    .header-brand-with-lang {
        flex-wrap: wrap;
    }

    .header-lang__switcher {
        width: auto;
        max-width: 42%;
    }

    /* Первый ряд: логотип + навигация; второй ряд: переключатель языка */
    .header-menu.header-menu--mobile-lang-below {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        grid-template-areas:
            "logo nav"
            "lang lang";
        column-gap: 16px;
        row-gap: 12px;
        align-items: center;
    }

    .header-menu.header-menu--mobile-lang-below .header-brand-with-lang {
        display: contents;
    }

    .header-menu.header-menu--mobile-lang-below .header-logo {
        grid-area: logo;
        justify-self: start;
    }

    .header-menu.header-menu--mobile-lang-below .navigation-wrapper {
        grid-area: nav;
        justify-self: end;
        width: auto;
        min-width: 0;
    }

    .header-menu.header-menu--mobile-lang-below .lang__switcher.header-lang__switcher {
        grid-area: lang;
        justify-self: center;
        width: 100%;
        max-width: 18em;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 768px) {
    .header-brand-with-lang {
        justify-content: center;
        grid-row-gap: 5px;
    }
}