Can someone explain this integration trick for log-sine integrals?

I was working on this rather challenging log-sine integral:

$$ \int_{0}^{2\pi}x^{2}\ln^{2}\left(2\sin\left(x \over 2\right)\right)\,{\rm d}x = {13\pi^{5} \over 45} $$

The upper limit is a waiver from the norm of $\frac{\pi}{2}$. Anyway, when integrating log-sin integrals one can often times use the famous identity

$$\displaystyle -\ln(2\sin(x/2))=\sum_{k=1}^{\infty}\frac{\cos(kx)}{k}$$

by switching sum and integral, integrating, then evaluating the sums. However, this is only valid when $x\neq \pm \pi,\pm2\pi,\ldots$. So, just for the heck of it, I decided to do something I thought would not be viable but have done it anyway. I integrated $$\displaystyle \int_{0}^{2\pi}\frac{x^{2}\cos^{2}(kx)}{k^{2}},$$ evaluated the resulting sums and arrived at $\displaystyle \frac{41{\pi}^{5}}{180}$.

Now, take the integral $$\displaystyle \int_{0}^{\pi}x^{2}\ln^{2}(2\cos(x/2))dx=\frac{11{\pi}^{5}}{180}.$$ This one can be done by using Cauchy's cosine formula, differentiating, and so on. Anyway, note that when I add the two results, the correct result for the integral at hand is obtained.

$$\displaystyle \frac{41{\pi}^{5}}{180}+\frac{11{\pi}^{5}}{180}=\frac{13{\pi}^{5}}{45}.$$

By quandary/query is why does this happen to work?. A fluke? Does that cosine sum represent something that when evaluated and added to the above log-cos integral happens to be equivalent to the log-sine integral in question?.

See what I am trying to explain?. I done something I knew I was not supposed to, but it happened to work out. If viable, what would $\displaystyle \int_{0}^{2\pi}\frac{x^{2}\cos^{2}(kx)}{k^{2}}$ represent such that when it is added to $\displaystyle \int_{0}^{\pi}x^{2}\ln^{2}(2\cos(x/2))dx=\frac{11{\pi}^{5}}{180}$ equals $\displaystyle \int_{0}^{2\pi}x^{2}\ln^{2}(2\sin(x/2))dx=\frac{13{\pi}^{5}}{45}$.

I knew I could not just square the cosine and multiply by $x^2$. But,sometimes it can be done due to Parseval, i.e., $\displaystyle \ln^{2}(2\sin(x/2))=\sum_{n=1}^{\infty}\sum_{k=1}^{\infty}\frac{\cos(nx)\cos(kx)}{nk}$. Then, because $\displaystyle \int_{0}^{\pi}\cos(nx)\cos(kx)dx=0, \;\ n\neq k$, one can integrate $\displaystyle \int_{0}^{\pi}\frac{\cos^{2}(kx)}{k^{2}}$, then sum.

This works for $2\pi$ as well, but that $x^2$ term tends to throw a wrench in things But I do not think I can do this in my case because of the $x^2$ term. Or can I?. I was surprised when I saw this. I thought perhaps I stumbled onto a cool way to evaluate this, but I am not entirely sure what I have.

Or, if anyone has their own clever method?.

EDIT: I managed to evaluate this integral by considering the identity

$$\ln\left(2\sin\left(\frac{x}{2}\right)\right)=\ln(1-e^{ix})+\frac{i}{2}(\pi -x)$$


Preliminaries

Looking at the real part of $\log\left(1-e^{ix}\right)$, we get $$ \log\left(2\sin\left(\frac x2\right)\right)=-\sum_{k=1}^\infty\frac{\cos(kx)}{k}\tag1 $$ Integrating by parts twice, we get $$ \int_0^{2\pi}x^2\cos(kx)\,\mathrm{d}x=\left\{\begin{array}{}\frac{8\pi^3}3&\text{if }k=0\\\frac{4\pi}{k^2}&\text{if }k\ne0\end{array}\right.\tag2 $$

In the derivations below, we use the values of $\zeta(2)$ and $\zeta(4)$ computed at the end of this answer.

Start to evaluate one sum, then get another: $$ \begin{align} \color{#C00}{\sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{(k+j)^2kj}} &=\sum_{j=1}^\infty\sum_{k=1}^\infty\left(\frac1{kj}-\frac1{k(k+j)}\right)\left(\frac1{kj}-\frac1{j(k+j)}\right)\tag{3a}\\[3pt] &=\color{#00F}{\sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{k^2}\frac1{j^2}}-2\color{#090}{\sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{k^2(k+j)j}}+\color{#C00}{\sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{(k+j)^2kj}}\tag{3b}\\ \color{#090}{\sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{k^2(k+j)j}} &=\frac12\color{#00F}{\zeta(2)^2}\tag{3c}\\[3pt] &=\frac{\pi^4}{72}\tag{3d} \end{align} $$ Explanation:
$\text{(3a)}$: $\frac1{kj}-\frac1{k(k+j)}=\frac1{j(j+k)}$ and $\frac1{kj}-\frac1{j(k+j)}=\frac1{k(j+k)}$
$\text{(3b)}$: expand the products and separate the sums
$\phantom{\text{(3b):}}$ note that $\sum\limits_{j=1}^\infty\sum\limits_{k=1}^\infty\frac1{k^2(k+j)j}=\sum\limits_{j=1}^\infty\sum\limits_{k=1}^\infty\frac1{k(k+j)j^2}$
$\text{(3c)}$: cancel the red sums, move the green sum to the left side, and divide by $2$
$\text{(3d)}$: simplify

Evaluate the sum we started before (using the other sum we got before): $$ \begin{align} \sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{(k+j)^2kj} &=\sum_{j=1}^\infty\sum_{k=j+1}^\infty\frac1{k^2(k-j)j}\tag{4a}\\ &=\sum_{k=1}^\infty\sum_{j=1}^{k-1}\frac1{k^2(k-j)j}\tag{4b}\\ &=\sum_{k=1}^\infty\sum_{j=1}^{k-1}\frac1{k^3}\left(\frac1{k-j}+\frac1j\right)\tag{4c}\\ &=2\sum_{k=1}^\infty\left(\frac{H_k}{k^3}-\frac1{k^4}\right)\tag{4d}\\ &=2\sum_{k=1}^\infty\sum_{j=1}^\infty\frac1{k^3}\left(\frac1j-\frac1{j+k}\right)-2\zeta(4)\tag{4e}\\ &=2\sum_{k=1}^\infty\sum_{j=1}^\infty\frac1{k^2(k+j)j}-2\zeta(4)\tag{4f}\\ &=\frac{\pi^4}{36}-\frac{\pi^4}{45}\tag{4g}\\[6pt] &=\frac{\pi^4}{180}\tag{4h} \end{align} $$ Explanation:
$\text{(4a)}$: substitute $k\mapsto k-j$
$\text{(4b)}$: swap order of summation
$\phantom{\text{(4b):}}$ (we include $k=1$ since the inner sum is then $0$)
$\text{(4c)}$: partial fractions
$\text{(4d)}$: $\sum\limits_{j=1}^{k-1}\frac1{k-j}=\sum\limits_{j=1}^{k-1}\frac1j=H_k-\frac1k$
$\text{(4e)}$: $H_k=\sum\limits_{j=1}^\infty\left(\frac1j-\frac1{j+k}\right)$
$\text{(4f)}$: simplify the summand
$\text{(4g)}$: apply $(3)$
$\text{(4h)}$: simplify


Putting The Preliminaries To Work $$ \begin{align} &\int_0^{2\pi}x^2\log\!\left(2\sin\left(\frac{x}2\right)\right)^2\,\mathrm{d}x\\ &=\int_0^{2\pi}x^2\sum_{j=1}^\infty\sum_{k=1}^\infty\frac{\cos(kx)}{k}\frac{\cos(jx)}{j}\,\mathrm{d}x\tag{5a}\\ &=\int_0^{2\pi}x^2\sum_{j=1}^\infty\sum_{k=1}^\infty\frac{\color{#C00}{\cos((k+j)x)}+\color{#090}{\cos((k-j)x)}}{2kj}\,\mathrm{d}x\tag{5b}\\ &=\color{#C00}{2\pi\sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{(k+j)^2kj}}+\color{#090}{4\pi\sum_{j=1}^\infty\sum_{k=j+1}^\infty\frac1{(k-j)^2kj}+\frac{4\pi^3}3\sum_{k=1}^\infty\frac1{k^2}}\tag{5c}\\ &=2\pi\sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{(k+j)^2kj}+4\pi\sum_{j=1}^\infty\sum_{k=1}^\infty\frac1{k^2(k+j)j}+\frac{4\pi^3}3\zeta(2)\tag{5d}\\ &=\frac{\pi^5}{90}+\frac{\pi^5}{18}+\frac{2\pi^5}9\tag{5e}\\[6pt] &=\frac{13\pi^5}{45}\tag{5f} \end{align} $$ Explanation:
$\text{(5a)}$: apply $(1)$
$\text{(5b)}$: $\cos(a)\cos(b)=\frac{\cos(a+b)+\cos(a-b)}2$
$\text{(5c)}$: apply $(2)$
$\text{(5d)}$: substitute $k\mapsto k+j$ in the middle sum
$\text{(5e)}$: apply $(3)$ and $(4)$
$\text{(5f)}$: simplify