Could almost just instead add a class to your html, and at the same place as the markup add a style tag inline writing exactly what you need. Css doesn't have to be one huge chunk. So instead of
<div class="lots of stuff">... or <div style="lots of stuff">...
one can do
<style>
.something { lotsofstuff }
.something:evenwithpseudo { otherstuff }
@andevenwithmedia {}
</style>
<div class="something">
and just have lots of small <styles> everywhere.
That's basically how elm-css[0] does it. One writes css in the attributes of elements, and then when it's converted to DOM-stuff the css is extracted and classes created (or reused if similar). Since it's all elm-code one can reuse variables, call functions, import styles from somewhere etc
[0]: https://package.elm-lang.org/packages/rtfeldman/elm-css/late...