The interactions between CSS container queries and highlight pseudos are not discussed anywhere, as best I can tell. In chromium right now you cannot define and use a custom highlight pseudo defined inside an @container media query (I haven't checked ::selection or the others). I would like to disallow it due to implementation challenges.
If there's a compelling use case for changing custom highlights depending on containers queries please add it in the comments.
It's also not currently possible to use container based units in highlight declarations. The obvious thing would be to treat them like font units and resolve against the originating element and that's what seems to be said in the resolution to #7591. But that's also added implementation complexity.
On the one hand, the most likely thing to drive using container units is the font size which would be available, maybe, once #7591 is implemented. On the other hand, do we want the added complexity?
Thoughts?