Shrinkwrap Showdown

CSS width: fit-content uses the widest line's width — leaving ugly dead space when the last line is short. Pretext computes the exact tightest width that still wraps identically.

340px
CSS fit-content
Uses width: fit-content; max-width: 80%. The browser wraps text, then sizes the bubble to the longest line. Shorter lines leave wasted space.
Pretext shrinkwrap
Uses walkLineRanges() to binary-search the tightest width that produces the same line count. Zero wasted pixels. Zero DOM measurement.

Why can't CSS do this?

CSS only knows "fit-content" — which is the width of the widest line after wrapping. If a paragraph wraps to 3 lines and the last line is short, CSS still sizes the container to the longest line. There's no CSS property to say "find the narrowest width that still produces exactly 3 lines." That requires measuring the text at multiple widths and comparing line counts — which is exactly what pretext's walkLineRanges() does, without touching the DOM at all. Pure arithmetic, no reflows, instant results.