/* Keep the bilingual picker in normal flow: neither field belongs under a fixed footer. */
#twoLangsCardsModal {
    width: calc(100% - 32px);
    max-width: 760px;
    height: auto;
    max-height: none;
    overflow: visible;
    background: #fff;
    border-radius: 8px;
}

#twoLangsCardsModal .sticky-header {
    position: relative;
    padding: 20px 24px;
    border-radius: 8px 8px 0 0;
}

#twoLangsCardsHeader {
    margin: 0;
    font-size: 22px;
    line-height: 1.35;
    text-align: center;
    overflow-wrap: anywhere;
}

#twoLangsCardsModal .modal-content {
    position: static;
    height: auto;
    max-height: none;
    padding: 28px;
    overflow: visible;
}

#twoLangsCardsModal .bilingual-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    align-items: center;
    gap: 32px;
}

#twoLangsCardsModal .bilingual-preview .card {
    margin: 0;
}

#twoLangsCardsModal .bilingual-preview img {
    display: block;
    width: 100%;
    height: auto;
}

#twoLangsCardsModal .bilingual-languages {
    display: grid;
    gap: 24px;
    min-width: 0;
}

#twoLangsCardsModal .input-field {
    display: grid;
    min-width: 0;
    margin: 0;
    padding-top: 0;
}

#twoLangsCardsModal .input-field > label,
#twoLangsCardsModal .input-field > label.active {
    position: static;
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-size: 14px;
    line-height: 1.4;
    transform: none;
    grid-row: 1;
}

#twoLangsCardsModal .lang-autocomplete input.lang-autocomplete-input {
    box-sizing: border-box;
    width: 100%;
    height: 44px;
    margin: 0;
    font-size: 16px;
    text-overflow: ellipsis;
}

#twoLangsCardsModal .lang-autocomplete-list {
    margin: 0;
    max-height: min(240px, 30vh);
    max-height: min(240px, 30dvh);
    overscroll-behavior: contain;
}

/* The lower menu opens upward so the options remain within a short viewport. */
#twoLangsCardsModal .input-field:last-child .lang-autocomplete-list {
    top: auto;
    bottom: 100%;
}

#twoLangsCardsModal .modal-footer {
    position: static;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    height: auto;
    padding: 12px 20px;
    border-top: 1px solid #e5e5e5;
    border-radius: 0 0 8px 8px;
    background: #f6f7f7;
}

#twoLangsCardsModal .modal-footer .btn,
#twoLangsCardsModal .modal-footer .btn-flat {
    height: auto;
    min-height: 44px;
    margin: 0;
    padding: 10px 16px;
    font-size: 15px;
    line-height: 1.5;
    white-space: normal;
    text-align: center;
    transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 160ms ease;
}

#twoLangsCardsModal .modal-footer a:active {
    transform: scale(0.97);
}

#twoLangsCardsModal .modal-footer a:focus-visible {
    outline: 2px solid #008c8c;
    outline-offset: 3px;
}

@media (max-width: 560px) {
    #twoLangsCardsModal .sticky-header { padding: 16px; }
    #twoLangsCardsHeader { font-size: 19px; }
    #twoLangsCardsModal .modal-content { padding: 20px; }
    #twoLangsCardsModal .bilingual-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    #twoLangsCardsModal .bilingual-preview { width: 112px; margin: auto; }
    #twoLangsCardsModal .bilingual-languages { gap: 16px; }
    #twoLangsCardsModal .modal-footer { padding: 12px; }
}

@media (max-height: 500px) {
    #twoLangsCardsModal .sticky-header { padding: 12px 16px; }
    #twoLangsCardsHeader { font-size: 18px; }
    #twoLangsCardsModal .modal-content { padding: 16px; }
    #twoLangsCardsModal .bilingual-layout { grid-template-columns: 88px minmax(0, 1fr); gap: 20px; }
    #twoLangsCardsModal .bilingual-preview { width: 88px; }
    #twoLangsCardsModal .bilingual-languages { gap: 12px; }
    #twoLangsCardsModal .modal-footer { padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    #twoLangsCardsModal .modal-footer a:active { transform: none; }
}
