AI often generates stuff that looks plausible but is wrong. In this case, with your code, textBox
appears to be a Text object instance, and so is an ITextInstance class. The documentation does not list that there is an elem
property so it's not valid to use it. The object is not even a HTML element (as it's rendered directly in to the canvas) so CSS styling is simply not applicable to that kind of object.
If it was a HTML element object, like "Text Input", you could call getElement() and then use the standard DOM APIs to alter its style.