Instead of focusing on how advanced technology is advanced, view magic as technology, given the same advantages and pitfalls that we know of.
Loose notes follow.
Magic as code, with upstream. This allows different levels of processing and patching.
A city might not allow flying, for instance. That magic is suppressed.
“Wild magic” is when a patching system is corrupted, such as during a badly cast ritual.
This also allows “utility” magic, like telecommunications.
Aside: I love FF8 and that moon thing. Maybe a moon based magic communications array!
Make certain types of magic hightly regulated, and law enforcement could be called in.
Oh! Religion, aka the clerical magic, is an emotional interface to the energy, and the more on is “faithful” the more a diety is able to use the transactional energy for their own purpose.
Those that figure this out, they are hunted. Not even many gods know this directly.