One simply needs the Highlight API. I held back, but now even Firefox ESR supports it.
https://developer.mozilla.org/en-US/docs/Web/API/Highlight
All the trickery vanishes and you get first-class CSS support.
That works on the text inside a textarea? Is there a demo showcasing this somewhere?
And there's an open issue for that already: https://github.com/bearcove/arborium/issues/62