/* A paragraph may start in Hebrew and the next in English. Native Unicode bidi
   chooses each paragraph independently; source and clipboard order stay logical.
   Never use bidi-override or transform strings to simulate a writing direction. */
[data-text-layout="paragraph"] { unicode-bidi: plaintext; }
[data-text-layout="inline"],
[data-text-layout="isolated"],
[data-text-layout="field"],
[data-text-layout="structured"] { unicode-bidi: isolate; }

/* Each existing readonly line gets its own Unicode paragraph. Keep the original
   newline text nodes between inline boxes: display:block would duplicate breaks
   during native selection/copy. Width and direction keep independent alignment. */
bdi[data-text-paragraph] {
  display: inline-block;
  inline-size: 100%;
  vertical-align: top;
  unicode-bidi: isolate;
  text-align: start;
}

/* Explicitly managed direction is semantic (dir), not a CSS direction override.
   Keep centered decorative labels centered; editors align to their own start. */
textarea[data-text-layout],
input[data-text-layout],
[contenteditable][data-text-layout] { text-align: start; }

/* Long URLs and mixed-script names must fit narrow screens without altering text.
   Preformatted exports keep whitespace and use a scrollbar, never truncation. */
p[data-text-layout], blockquote[data-text-layout], figcaption[data-text-layout],
h1[data-text-layout], h2[data-text-layout], h3[data-text-layout],
h4[data-text-layout], h5[data-text-layout], h6[data-text-layout],
dd[data-text-layout], td[data-text-layout], th[data-text-layout] { overflow-wrap: anywhere; }
pre[data-text-layout] { max-inline-size: 100%; overflow: auto; }

/* Visible protocol/recovery material remains one independently ordered token. */
code[data-text-layout], kbd[data-text-layout], samp[data-text-layout],
time[data-text-layout] { unicode-bidi: isolate; }
