/* Language menu and right-to-left layouts. */
.language-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    gap: 0.5rem;
    color: var(--light-text, #64748b);
    font-size: 0.85rem;
}
.language-menu select {
    width: auto;
    min-width: 8rem;
    max-width: 100%;
    margin: 0;
    padding-block: 0.45rem;
    border-radius: 999px;
    background-color: var(--surface, #fff);
    cursor: pointer;
}
.language-menu select:focus-visible {
    outline: 2px solid var(--primary-color, #ef4444);
    outline-offset: 3px;
}
html[dir="rtl"] body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}
html[dir="rtl"] select {
    background-position: left 10px center;
    padding-left: 2.2rem;
    padding-right: 0.9rem;
}
html[dir="rtl"] .fa-arrow-right {
    transform: scaleX(-1);
}
html[dir="rtl"] :is(ul, ol):not(nav ul) {
    padding-inline-start: 1.5rem;
    padding-inline-end: 0;
}
html[dir="rtl"] :is(input[type="url"], input[type="email"], input[type="number"], code, pre, .code-example, .code-output) {
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
}
/* Freeform input may contain right-to-left text; code and ciphertext remain left-to-right. */
html[dir="rtl"] textarea {
    unicode-bidi: plaintext;
}
html[dir="rtl"] :is(#jsonInput, #convertInput, #convertResult, #hashResult, #curlResult, #codeExample, #publicKeyDisplay, #privateKeyDisplay, #asymmetricResult) {
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
}
@media (max-width: 640px) {
    header { gap: 0.65rem; padding-inline: 0.75rem; }
    header nav { flex-basis: 100%; }
    .language-menu { margin-inline: auto; }
    html[dir="rtl"] .logo h1 { white-space: normal; }
}
html[dir="rtl"] .faq-list summary { padding: 1rem 0 1rem 2.25rem; }
html[dir="rtl"] .faq-list summary::after { right: auto; left: 0.3rem; }
html[dir="rtl"] .faq-list details p { padding: 0 0 1rem 2rem; }
@media (max-width: 1100px) {
    header .logo { order: 0; }
    header .language-menu { order: 1; }
    header nav { order: 2; flex-basis: 100%; }
}
html[dir="rtl"] :is(#convert-result, #hash-result, #public-key, #private-key, #import-public-key-area, #import-private-key-area, #curlResult, #codeExampleResult, .CodeMirror) {
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
}
/* These controls use left-based coordinates in their tool scripts. */
html[dir="rtl"] :is(input[type="range"], .video-timeline, .frame-strip, .compare-stage, #match-board, video, audio) {
    direction: ltr;
}
html[dir="rtl"] :is(#round-verdict, #match-summary, .player-col) {
    direction: rtl;
}
/* Use local CJK fonts; no extra font download is required. */
html[lang="ja"] body {
    font-family: 'Yu Gothic', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    line-break: strict;
    overflow-wrap: anywhere;
}
html[lang="ko"] body {
    font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
/* Keep Korean toolbar labels whole when controls wrap onto another row. */
html[lang="ko"] .editor-controls button {
    min-width: max-content;
    overflow-wrap: normal;
}

/* Local fonts cover Thai marks and Urdu joining without a network dependency. */
html[lang="th"] body {
    font-family: 'Leelawadee UI', 'Noto Sans Thai', Tahoma, sans-serif;
    line-height: 1.7;
    word-break: normal;
}
html[lang="ur"] body {
    font-family: 'Noto Naskh Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
    line-height: 1.8;
}
