12. Let the arithmetic sequence $\left\{a_{n}\right\}$ satisfy
$$
\frac{\sin ^{2} a_{3}-\cos ^{2} a_{3}+\cos ^{2} a_{3} \cdot \cos ^{2} a_{6}-\sin ^{2} a_{3} \cdot \sin ^{2} a_{6}}{\sin \left(a_{4}+a_{5}\right)}=1,
$$

with common difference $d \in(-1,0)$. If and only when $n=9$, the sum of the first $n$ terms of the sequence $\left\{a_{n}\right\}$, $S_{n}$, reaches its maximum value, then the range of the first term $a_{1}$ is ( ).
(A) $\left(\frac{7 \pi}{6}, \frac{4 \pi}{3}\right)$
(B) $\left(\frac{4 \pi}{3}, \frac{3 \pi}{2}\right)$
(C) $\left[\frac{7 \pi}{6}, \frac{4 \pi}{3}\right]$
(D) $\left[\frac{4 \pi}{3}, \frac{3 \pi}{2}\right]$
12. B.

Simplifying the original expression, we get
$$
\begin{array}{l}
\frac{\sin ^{2} a_{3}\left(1-\sin ^{2} a_{6}\right)-\cos ^{2} a_{3}\left(1-\cos ^{2} a_{6}\right)}{\sin \left(a_{4}+a_{5}\right)} \\
=\frac{\sin ^{2} a_{3} \cdot \cos ^{2} a_{6}-\cos ^{2} a_{3} \cdot \sin ^{2} a_{6}}{\sin \left(a_{4}+a_{5}\right)} \\
=\frac{\sin \left(a_{3}+a_{6}\right) \cdot \sin \left(a_{3}-a_{6}\right)}{\sin \left(a_{4}+a_{5}\right)} \\
=\sin \left(a_{3}-a_{6}\right)=1 \\
\Rightarrow a_{3}-a_{6}=\frac{\pi}{2}+2 k \pi(k \in \mathbf{Z}) \\
\Rightarrow-3 d=\frac{\pi}{2}+2 k \pi(k \in \mathbf{Z}) \\
\Rightarrow d=-\frac{\pi}{6}-\frac{2 k \pi}{3}(k \in \mathbf{Z}) .
\end{array}
$$

Since $d \in(-1,0)$, we have $d=-\frac{\pi}{6}$.
Also, in $S_{n}$, $S_{9}$ is the largest, so $a_{9}>0, a_{10}<0$, which means
$$
\begin{array}{l}
a_{9}=a_{1}+8\left(-\frac{\pi}{6}\right)>0, \\
a_{10}=a_{1}+9\left(-\frac{\pi}{6}\right)<0
\end{array} \Rightarrow \frac{4 \pi}{3}<a_{1}<\frac{3 \pi}{2} .
$$