On the product $\prod_{k=1}^{(p-1)/2}(x-e^{2\pi i k^2/p})$ with $x$ a root of unity Let $p$ be an odd prime. Dirichlet's class number formula for quadratic fields essentially determines the value of the product $\prod_{k=1}^{(p-1)/2}(1-e^{2\pi ik^2/p})$. I think it is interesting to investigate 
the product $$S_p(x)=\prod_{k=1}^{(p-1)/2}(x-e^{2\pi i k^2/p})$$ with $x$ a root of unity. In a recent preprint available from http://arxiv.org/abs/1908.02155, I determined the value of $S_p(i)$ for $p\equiv 1\pmod4$.
For the cubic root $\omega=(-1+\sqrt{-3})/2$ of unity, I have proved in the same preprint that
$$(-1)^{|\{1\le k\le\lfloor\frac{p+1}3\rfloor:\ (\frac kp)=-1\}|}S_p(\omega)=\begin{cases}1&\text{if}\ p\equiv1\pmod{12},\\\omega \varepsilon_p^{h(p)}&\text{if}\ p\equiv5\pmod{12},\end{cases}$$
where $(\frac kp)$ is the Legendre symbol, $\varepsilon_p$ and $h(p)$ are the fundamental unit and the class number of the real quadratic field $\mathbb Q(\sqrt p)$.
Question 1. How to determine the value of $S_p(i)$ for primes $p\equiv3\pmod4$? How to determine the value of $S_p(\omega)$ for primes $p\equiv 7,11\pmod{12}$?
Question 2. Let $p>3$ be a prime and let $n>2$ be an integer. Define
$$f_n(p)=(-1)^{|\{1\le k<\frac p{2^n}:\ (\frac kp)=1\}|}S_p(e^{2\pi i/2^n})$$
Via numerical computation, I guess that 
$$e^{-2\pi i(p-1)/2^{n+2}}f_n(p)>0$$ if $p\equiv1\pmod4$, and 
$$(-1)^{(h(-p)+1)/2}f(p)e^{-2\pi i(p+2^n-1)/2^{n+2}}>0$$ 
if $p\equiv3\pmod4$, where $h(-p)$ is the class number of the imaginary quadratic field $\mathbb Q(\sqrt{-p})$.
How to prove this observation? How to determine the exact values of $S_p(e^{2\pi i/2^n})$ $(n=3,4,\ldots)$?
Your comments are welcome!
New Addition (August 12, 2019). I have conjectures on the exact values of $S_p(i)$ and $S_p(\omega)$ for primes $p\equiv 3\pmod4$. For the conjectural value of $S_p(i)$ with $p\equiv3\pmod4$, see my posted answer. Here I state my conjecture on $S_p(\omega)$.
Conjecture. Let $p>3$ be a prime with $p\equiv 3\pmod4$, and let $(x_p,y_p)$ be the least positive integer solution to the diophantine equation 
$$3x^2+4\left(\frac p3\right)=py^2.$$ Then
\begin{align}S_p(\omega)=&(-1)^{(h(-p)+1)/2}\left(\frac p3\right)\frac{x_p\sqrt3-y_p\sqrt{p}}2
\\&\times\begin{cases}i&\text{if}\ p\equiv7\pmod{12},
\\(-1)^{|\{1\le k<\frac p3:\ (\frac kp)=1\}|}i\omega&\text{if}\ p\equiv11\pmod{12}.
\end{cases}\end{align}
For example, this conjecture predicts that 
$$S_{79}(\omega)=i\frac{\sqrt{79}-5\sqrt3}2\ \ \text{and}\ \ 
S_{227}(\omega)=i\omega(1338106\sqrt3-153829\sqrt{227}).$$
 A: Let $p>3$ be a prime with $p\equiv3\pmod 4$. We first show that 
$$(i-(\frac{2}{p}))S_p(i)\in \mathbb{Q}(\sqrt{p}).$$
Clearly
$${\rm Gal}(\mathbb{Q}(i,\zeta_p)/\mathbb{Q}(\sqrt{p}))=\{\sigma_a: a\in (\mathbb{Z}/4p\mathbb{Z})^{\times},(\frac{p}{a})=+1\}.$$
Here $\sigma_a: \zeta_{4p}\mapsto\zeta_{4p}^a.$
Then for each $\sigma_a\in {\rm Gal}(\mathbb{Q}(i,\zeta_p)/\mathbb{Q}(\sqrt{p}))$, if $a\equiv 1\pmod 4$ and 
$(\frac{a}{p})=+1$, then clearly $\sigma_a$ acts trivially on $((i-(\frac{2}{p})))S_p(i)$. If 
$a\equiv 3\pmod 4$ and $(\frac{a}{p})=-1$, then 
$$\sigma_a((i-(\frac{2}{p}))S_p(i))=(-i-(\frac{2}{p}))\prod_{1\le k\le \frac{p-1}{2}}(-i-\zeta_p^{-k^2}).$$
Noting that 
$$S_p(i)S_p(-i)=(\frac{2}{p})$$
and 
$$\prod_{1\le k\le \frac{p-1}{2}}(-i-\zeta_p^{k^2})\prod_{1\le k\le \frac{p-1}{2}}(-i-\zeta_p^{-k^2})
=\frac{(-i)^p-1}{-i-1}=-i,$$
one can easily verify that 
$\sigma_a$ fixes $(i-(\frac{2}{p}))S_p(i)$.
Next we let $\varepsilon_p>1$ and $h(4p)$ be the fundamental unit and class number of $\mathbb{Q}(\sqrt{p})$ respectively. By the class number formula we have (here we let $(\frac{p}{\cdot})$ be the character modulo $4p$ of field $\mathbb{Q}(\sqrt{p})$, and let
$e^{2\pi i/4p}=i^s\times e^{2\pi it/p}$ with $ps+4t=1.$)
\begin{align*}
\varepsilon_p^{h(4p)}=&\frac{\prod_{1\le b\le 2p-1,(\frac{p}{b})=-1}\sin(\pi b/4p)}{\prod_{1\le c\le 2p-1,(\frac{p}{c})=+1}\sin(\pi c/4p)}
\\=&\prod_{1\le b\le 2p-1, (\frac{p}{b})=+1}\frac{\sin(\pi(2p-b)/4p)}{\sin(\pi b/4p)}
\\=&(-i)^{\frac{p-1}{2}}\prod_{1\le b\le 2p-1,(\frac{p}{b})=+1}\frac{1+e^{2\pi ib/4p}}{1-e^{2\pi ib/4p}}
\\=&(-i)^{\frac{p-1}{2}}\prod_{1\le b\le 2p-1,(\frac{p}{b})=+1}\frac{1+i^{sb}\zeta_p^{tb}}{1-i^{sb}\zeta_p^{tb}}
\\=&(-i)^{\frac{p-1}{2}}\prod_{1\le b\le p-1, b\equiv 1\pmod4, (\frac{b}{p})=1}\frac{1-i\zeta_p^{tb}}{1+i\zeta_p^{tb}}\prod_{1\le b\le p-1, b\equiv 3\pmod4, (\frac{b}{p})=-1}\frac{1+i\zeta_p^{tb}}{1-i\zeta_p^{tb}}\\&\times
\prod_{1\le b\le p-1, b\equiv 1\pmod4, (\frac{b}{p})=-1}\frac{1-i\zeta_p^{-tb}}{1+i\zeta_p^{-tb}}\prod_{1\le b\le p-1, b\equiv 3\pmod4, (\frac{b}{p})=1}\frac{1+i\zeta_p^{-tb}}{1-i\zeta_p^{-tb}}.
\end{align*}
Then we obtain 
\begin{align*}
\varepsilon_p^{h(4p)}=&(-i)^{\frac{p-1}{2}}(-1)^{\#\{1\le b\le p-1: (\frac{p}{b})=-1\}}
\prod_{1\le b\le p-1,2\nmid b, (\frac{b}{p})=1}\frac{1-i\zeta_p^{tb}}{1+i\zeta_p^{tb}}
\prod_{1\le b\le p-1,2\nmid b,(\frac{b}{p})=-1}\frac{1+i\zeta_p^{tb}}{1-i\zeta_p^{tb}}
\\=&(-i)^{\frac{p-1}{2}}(-1)^{\#\{1\le b\le p-1: (\frac{p}{b})=-1\}\cup\{1\le b\le p-1: 2\mid b, (\frac{b}{p})=1\}}\prod_{1\le k\le \frac{p-1}{2}}\frac{1-i\zeta_p^{k^2}}{1+i\zeta_p^{k^2}}
\\=&(-i)^{\frac{p+3}{2}}(-1)^{\#\{1\le b\le p-1: (\frac{p}{b})=-1\}\cup\{1\le b\le p-1: 2\mid b, (\frac{b}{p})=1\}}\cdot\frac{S_p(-i)}{S_p(i)}.
\end{align*}
Finally we get 
$$\varepsilon_p^{h(4p)}S_p(i)^2=(\frac{2}{p})(-i)^{\frac{p+3}{2}}(-1)^{\#\{1\le b\le p-1: (\frac{p}{b})=-1\}\cup\{1\le b\le p-1: 2\mid b, (\frac{b}{p})=1\}}.$$
A: Dr. Timothy Foo has kindly sent me his following observation (based on his numerical computation) about $S_p(i)$ for primes $p\equiv3\pmod4$: $(i-(\frac 2p))S_p(i)$ has the form $a+b\sqrt p$ with $a,b\in\mathbb Z$. 
Now I report that I have found the exact value of $S_p(i)$ for primes $p\equiv3\pmod4$.
Namely, I have formulated the following conjecture on the basis of my computation.
Conjecture. Let $p>3$ be a prime with $p\equiv3\pmod4$, and let $h(-p)$ be the calss number of the imaginary quadratic field $\mathbb Q(\sqrt{-p})$. Let $\varepsilon_p$ and $h(p)$ be the fundamental unit and the class number of the real quadratic field $\mathbb Q(\sqrt p)$ respectively. Write $\varepsilon_p^{h(p)}=a_p+b_p\sqrt p$ with $a_p$ and $b_p$ positive integers. Then
$$\left(i-(-1)^{(p+1)/4}\right)S_p(i)=(-1)^{\frac{h(-p)+1}2\cdot\frac{p+1}4}(s_p-t_p\sqrt p),$$
where 
$$s_p=\sqrt{a_p+(-1)^{(p+1)/4}}\ \ \ \text{and}\ \ \ t_p=\frac{b_p}{s_p}$$
are positive integers.
Example. For $p=79$, we have $h(-p)=5$, $h(p)=3$ and $\varepsilon_p=80+9\sqrt p$. Note that
$$\varepsilon_p^{h(p)}=(80+9\sqrt{79})^3=2047760 + 230391\sqrt{79},$$
and
$$s_p=\sqrt{2047760+1}=1431\ \ \ \text{and}\ \ \ t_p= \frac{230391}{1431}=161.$$
Thus the conjecture for $p=79$ states that
$$(i-1)S_{79}(i)=1431-161\sqrt{79}.$$
