/* New scripts need their own line breaking; keep existing locales unchanged. */
html:is(:lang(ko), :lang(th), :lang(ar), :lang(ja), :lang(pl)) :is(.btn, .badge, .nav-link-title, .page-title, .card-title) {
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
}

html:lang(ko) {
  word-break: keep-all;
}

html:is(:lang(th), :lang(ar)) :is(.btn, .badge, .form-check-label) {
  /* Leave room above/below vowel marks and Arabic letterforms. */
  line-height: 1.5;
  letter-spacing: normal;
}

.language-switcher bdi {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

html:is(:lang(ko), :lang(th), :lang(ar), :lang(ja), :lang(pl)) .device-table th {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
  letter-spacing: normal;
}

html:is(:lang(ko), :lang(th), :lang(ar), :lang(ja), :lang(pl)) .device-control-workspace :is(.schema-label, .form-check-label) {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
}

html:is(:lang(ko), :lang(th), :lang(ar), :lang(ja), :lang(pl)) :is(.offline-config-message, .loading-config-message, .config-error-message) {
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 1rem;
  text-align: center;
}

/* Let Arabic text choose its reading direction without reversing layout rows. */
html:lang(ar) :is(h1, h2, h3, h4, h5, h6, p, label, .schema-label, .schema-unit, .nav-link-title, .form-check-label, .form-control) {
  unicode-bidi: plaintext;
}

html:lang(ar) .schema-control:is(.schema-rally-level-select, .schema-canyon-rank-select) {
  padding-left: .5rem;
  padding-right: 2rem;
  background-position: right .5rem center;
}
