An upper bound for class numbers of imaginary quadratic fields Let $K = \mathbb{Q}(\sqrt{-d})$ be an imaginary quadratic field with $d > 3$. Our ultimate goal is to prove the following:
$$
h_K < \begin{cases}
\dfrac{d}{4}, & -d \equiv 1 \pmod 4, \\
\dfrac{d}{2}, & -d \equiv 2 \text{ or } 3 \pmod 4.
\end{cases}
$$
where $h_K$ is the class number of $K$. I'm hinted to prove the following claim first:
CLAIM: Let $D = |\Delta_K|$, where $\Delta_K$ is the discriminant of $K$.
$$
h_K \leq \dfrac{1}{D}\sum_{1 \leq k < D/2, (k,D)=1} (D-2k) = \dfrac{\phi(D)}{2}-\dfrac{2}{D} \sum_{1 \leq k < D/2, (k,D)=1} k =:H_K.
$$
My question is: how to prove the claim and how the claim implies the final estimate.
My attempts for the CLAIM: We have already obtained the class number formula for imaginary quadratic fields as
$$
h_K = \dfrac{1}{2-\chi_K(2)} \left\vert \sum_{1 \leq k < D/2} \chi_K(k) \right\vert,
$$
where $\chi_K$ is the unique nontrivial character of $K$ with conductor $D$, defined as
$$
\chi_K(p)=\begin{cases}
1, &\text{ if } p \text{ splits completely}, \\
-1, &\text{ if } p \text{ inerts}, \\
0, &\text{ if } p \text{ ramifies}.
\end{cases}
$$
for primes $p$ and extend it completely-multiplicatively to all integers. $\chi_K$ can be expressed by Legendre symbols in the odd prime cases. Now it is quite challenging for me to estimate the sum of $\chi_K$ over $1 \leq k < D/2$. By comparing with the result, if we simply ignore the term $1/(2-\chi_K(2))$ (since it is always $\leq 1$), we ought to show
$$
\sum_{1 \leq k < D/2, (k,D)=1} \chi_K(k)  \leq \sum_{1 \leq k < D/2, (k,D)=1} \left( 1 - \dfrac{2k}{D} \right), 
$$
and I got stuck here. (Clearly, it should not hold in general that for all such $k$, $\chi_K(k) \leq 1 - \frac{2k}{D}$.)
My attempts for the final result: Granting the claim,
$$
H_K = \begin{cases}
\dfrac{\phi(d)}{2} - \dfrac{2}{d} \sum_{1 \leq k < d/2, (k,d)=1} k, &-d \equiv 1 \pmod 4, \\
\dfrac{\phi(4d)}{2} - \dfrac{1}{2d} \sum_{1 \leq k < 2d, (k,4d)=1} k, &-d \equiv 2 \text{ or } 3 \pmod 4.
\end{cases}
$$
I found the sum over half of the reduced residue class quite difficult to handle, especially when I hope to make it smaller since it is substracted from the term $\phi(d)/2$ or $\phi(4d)/2$. I have consulted the post here for inspiration but obtained nothing. I think the key stucking me is the half of reduced residue class problem.
P.S. I also viewed the post on another bound of $h_K$. The comment by @Greg Martin mentioned that $L(1, \chi_{-d}) \ll \log d$. He said that it is a standard result in analytic number theory. Could someone provide some reference on this? Though I'm still hoping to get the bound in my post from the claim above, it seems a good point for me to learn more on the estimate of $L$-functions.
I'm a new learner on analytic methods in number theory and sorry for such a long post. Thank you all for commenting and answering! :)
 A: I think it's better to use another form of Hasse's class number formula:
$$h_{K}=\frac{1}{D}\sum_{k=1}^{D}\chi_{K}(k)k.$$
This is equivalent to the formula you state since we have the following fact (if you can read chinese, you can find this result as Lemma 5 in Chapter 6 of Keqin Feng's algebraic number theory, but I think it is not hard to prove): if $\chi$ is a primitive odd character modulo $m$, then
$$\sum_{k=1}^{m-1}\chi(k)k=\frac{m}{\overline{\chi}(2)-2}\sum_{1\leq k<m/2}\chi(k).$$
Now we can see $$h_{K}=\frac{1}{D}\sum_{1\leq k<D/2,(k,D)=1}\big(\chi_{K}(k)k+\chi_{K}(D-k)(D-k)\big).$$
Since $\chi_{K}(D-k)=\chi_{K}(-k)=-\chi_{K}(k),$ we have the following estimate:
$$h_{K}=\frac{1}{D}\sum_{1\leq k<D/2,(k,D)=1}\chi_{K}(k)(2k-D)\leq\frac{1}{D}\sum_{1\leq k<D/2,(k,D)=1}(D-2k)=\frac{\phi(D)}{2}-\frac{2}{D}\sum_{1\leq k<D,(k,D)=1}k.$$
If $-d\equiv\operatorname{mod}4$, then $D=d$ and
$$h_{K}<\frac{1}{d}\sum_{1\leq k<d/2}(d-2k)=\frac{(d-1)^{2}}{4d}<\frac{d}{4}.$$
If $-d\equiv 2,3\operatorname{mod}4,$ then $D=4d$ and
$$h_{K}< \frac{1}{4d}\sum_{1\leq k<2d,(k,2)=1}(4d-2k)=\frac{d}{2}.$$
