Edit: I answered a different question than the one asked. The question asks for the least $c_d = q^2|\sqrt{d}-p/q|$. I evaluated the liminf.

If $d = a^2+b$ with $1\le b \le 2a$ then the simple continued fraction for $\sqrt{d}$ is preperiodic, and the period ends with $2a$, which is the largest coefficient, with $a$ being the second largest, and the rest of the period is a palindrome. I believe these classical results are in Hardy and Wright, *An Introduction to the Theory of Numbers*.

We can represent $\sqrt{d}$ as a terminating simple continued fraction if we allow the last coefficient to be irrational, containing the rest of the simple continued fraction, instead of an integer.

$\alpha = [a_0;a_1,...,a_n,...] = [a_0;a_1,...,a_n,[a_{n+1};a_{n+2},...]]$. Let $a_{n+1}' = [a_{n+1};a_{n+2},...]$.

If $[a_0;a_1,...,a_n] = p_n/q_n$ and then $\alpha = \frac{a_{n+1}'p_n + p_{n-1}}{a_{n+1}'q_n + q_{n-1}}$ so $$\bigg|\alpha - \frac{p_n}{q_n}\bigg| = \frac{1}{q_n(a_{n+1}'q_n + q_{n-1})} = \frac{1}{q_n^2} \frac{1}{a_{n+1}' + \frac{q_{n-1}}{q_n}}$$

So, we want to determine the liminf of $\frac{1}{a_{n+1}' + q_{n-1}/q_n}$
For $\alpha = \sqrt{a^2+b}$, or equivalently, the limsup of the reciprocal $a_{n+1}' + q_{n-1}/q_n$. The only values greater than $2a$ occur just before the period ends, when the next coefficient is $2a$, where $a_{n+1}' = a+\sqrt{a^2+b}$. The continued fraction of $q_{n-1}/q_n$ is $[0;a_n,a_{n-1},...,a_1]$ so the limit is $\sqrt{a^2+b}-a$, which means $$\frac{1}{a_{n+1}' + q_{n-1}/q_n} \to \frac{1}{2\sqrt{a^2+b}} = \frac{1}{2\sqrt{d}} = c_d.$$

If we want the infimum instead of the liminf, we get slightly lower values. Then $$c_d = \frac{1}{\frac{p}{q} + \sqrt{d}}$$

where (p,q) is the smallest nontrivial solution to $p^2-dq^2=1$. This is a convergent to the simple continued fraction just before the end of the first period if the period is even, and just before the end of the second period if the period is odd.

For example, $\sqrt{3} = [1; \overline{1,2}]$ has an even period length, so $[1;1]=2 \gt \sqrt{3}$. Then $c_3=1^2|2-\sqrt{3}| = \frac{1}{2+\sqrt{3}} \lt \frac{1}{2\sqrt{3}}$. $\sqrt{2} = [1;\overline{2}]$, so $p/q = [1;2] = 3/2 \gt \sqrt{2}$, and $c_2=2^2(3/2-\sqrt{2}) = \frac{1}{3/2 + \sqrt{2}} \lt \frac{1}{2\sqrt{2}}$.

The computation above still applies. The only candidates are convergents just before the period ends. If $p_n/q_n$ is the convergent just before the period ends, then $q_n^2|p_n/q_n - \sqrt{d}| = \frac{1}{a_{n+1}' + q_{n-1}/q_n}$ and $q_{n-1}/q_n$ has a continued fraction that consists of $0$ followed by repetitions of the period of the simple continued fraction for $\sqrt{d}$, with the last $2a$ missing. This is a convergent to the simple continued fraction of the fractional part $\sqrt{d}-\lfloor \sqrt{d} \rfloor$. When $n$ is odd, $q_{n-1}/q_n > \sqrt{d}-\lfloor \sqrt{d} \rfloor$, and the odd convergents decrease toward $\sqrt{d} - \lfloor \sqrt{d} \rfloor$ so the maximum occurs at the first occurence of an odd index just before a period ends.