I'm trying to calculate the derivative of the Lagrangian $$\mathcal{L}=\frac{1}{2}\partial_\mu\phi\,\partial^\mu\phi-\frac{1}{2}m^2\phi^2$$ with respect to the metric tensor $g_{\mu\nu}$, with the convention $(+, -, -, -)$, in order to obtain $$T^{\mu\nu}=-g^{\mu\nu}\mathcal{L}-2\frac{\delta\mathcal{L}}{\delta g_{\mu\nu}}.$$ First I tried to do it as follows:
$$\frac{\delta\mathcal{L}}{\delta g_{\mu\nu}}=\frac{1}{2}\frac{\delta\left(g_{\alpha\beta}\partial^\alpha\phi\partial^\beta\phi\right)}{\delta g_{\mu\nu}}=\frac{1}{2}\frac{\delta g_{\alpha\beta}}{\delta g_{\mu\nu}}\partial^\alpha\phi\partial^\beta\phi=\frac{1}{4}\left(\delta_\alpha^\mu\delta_\beta^\nu+\delta_\alpha^\nu\delta_\beta^\mu\right)\partial^\alpha\phi\partial^\beta\phi=\frac{1}{2}\partial^\mu\phi\partial^\nu\phi.$$
Where I have used the formula
$$\frac{\delta g_{\alpha\beta}}{\delta g_{\mu\nu}}=\frac{1}{2}\left(\delta_\alpha^\mu\delta_\beta^\nu+\delta_\alpha^\nu\delta_\beta^\mu\right)$$
that my professor derived in class.
But, if I write $\partial_\mu\phi\partial^\mu\phi=g^{\alpha\beta}\partial_\alpha\phi\partial_\beta\phi$, I would use the expression for the derivative of the inverse metric:
$$\frac{\delta g^{\alpha\beta}}{\delta g_{\mu\nu}}=-\frac{1}{2}\left(g^{\alpha\mu}g^{\beta\nu}+g^{\alpha\nu}g^{\beta\mu}\right)$$
This formula comes from the fact that $g^{\alpha\beta}g_{\beta\rho}=\delta^{\alpha}_{\rho}$, so
$$\frac{\delta g^{\alpha\beta}}{\delta g_{\mu\nu}}g_{\beta\rho}+g^{\alpha\beta}\frac{\delta g_{\beta\rho}}{\delta g_{\mu\nu}}=0$$
which leads to
$$\frac{\delta g^{\alpha\beta}}{\delta g_{\mu\nu}}g_{\beta\rho}=-\frac{1}{2}g^{\alpha\beta}\left(\delta^\mu_\beta\delta^\nu_\rho+\delta^\mu_\rho\delta^\nu_\beta\right)=-\frac{1}{2}\left(g^{\alpha\mu}\delta^{\nu}_{\rho}+g^{\alpha\nu}\delta^{\mu}_\rho\right)$$
multiplying by $g^{\rho\varphi}$, we get
$$\frac{\delta g^{\alpha\varphi}}{\delta g_{\mu\nu}}=-\frac{1}{2}\left(g^{\alpha\mu}g^{\varphi\nu}+g^{\alpha\nu}g^{\varphi\mu}\right)$$
and then, aplying that we would get
$$\frac{\delta\mathcal{L}}{\delta g_{\mu\nu}}=-\frac{1}{2}\partial^\mu\phi\partial^\nu\phi$$
I would like to understand what's causing this problem. I suppose this question may be duplicated, but it's still not clear to me how to fix that sign error from the answers I've read. This is my first time studying GR and I would be grateful for any responses.