In modular curves and modular forms, there is an adelic formulation, in which smaller open subgroups of some adelic group relate to higher level structure. As we know, higher level structure corresponds to higher torsion points (when we say "higher" we mean, e.g., $E[n]$ is "higher" than $E[m]$ if $m \mid n$). In complex multiplication, higher torsion points correspond to higher ray class fields, which correspond to smaller open subgroups of the ideles of the field of complex multiplication in question! (*Since someone asked, I sketch this in more detail below)
Thus I would like to ask whether there is a formulation that combines the adelic formulation of complex multiplication with the adelic formulation of modular curves.
To simplify and thus explain the principles**, it would be best to work with elliptic curves with complex multiplication. Let $F$ be a quadratic imaginary field.
Then I have the following guess for an idea: We have an injection from the ideles of $F$ into the rational adelic points of $\mathrm{GL}_2$, and after quotienting by the rational (i.e. non-adelic) points, we still have a nice inclusion? I would guess that the resulting points at those corresponding to CM elliptic curves and their level structures, but I don't entirely understand how to prove this.
Furthermore, assuming this is true, what does this say about the Galois action? Does this allow us to construct the Galois action (i.e. rational structure) on modular curves?
(Also, to be even more precise, we should let the ideles of $F$ be represented by the adelic points of the Weil restriction of $G_m$ from $F$ to $\mathbb{Q}$).
*In the adelic formulation of modular curves, we view modular curves as quotients of the adelic points of $GL_2$. We get different modular curves, e.g. $\Gamma(N)$ instead of $\Gamma(M)$ (for $M,N$ some positive integers) by considering different open subgroups of the adeles. As is well-known, $\Gamma(N)$ parametrizes elliptic curves with "level N" structure, meaning pairs consisting of elliptic curves and $N$-torsion points. In complex multiplication, the $N$-torsion points correspond to the ray class field of level $N$, and this is, in particular, done through an adelic formulation of the main theorem of complex multiplication.
**Though I assume everything will extend to higher-dimensional Shimura varieties in an analogous way.