I've hit the same walls as you have described and found that it's less about cognitive function and more about a combination of burnout, imposter syndrome, and some quirks of my ADHD. I still love to program but when I get the chance to I largely can't organize my thoughts well enough to make much progress, but its because I left a job about 7 months ago where I had been repeatedly hitting burnout in a really nasty several-year long cycle. Now when I sit down to do it I have a thousand things in my brain and I can't stay focused on it. I switched to managing individuals as well over the last few years since I have some natural giftings there but it's made it so that my skills at just zoning in and coding for hours is effectively atrophied since I am so interrupt-driven as a manager (constant emails/IMs and being mindful of my team who I should be supporting rather than my own personal technical goals)..
I've found I need to stop comparing myself to my late twenties self and understand that my burdens are different and I need to set different expectations of myself. As my responsibilities and noise/interference have grown, my ability to do complex design/development has been inversely effected and waned significantly and _that's ok_. I need better tools and to be better at managing my time and energies to be more targeted/specific and I am much more effective than I was all those years ago. I just have to be more intentional and forgiving of myself.
It took me 2-3 years to fully heal from my burnout. Allow yourself more time if it's only 7 months since you quit your burnout-inducing job. The improvement of my energy, my mental abilities and memory is breathtaking, mentally I feel like 18 again (though I am 35 now).
I've found I need to stop comparing myself to my late twenties self and understand that my burdens are different and I need to set different expectations of myself. As my responsibilities and noise/interference have grown, my ability to do complex design/development has been inversely effected and waned significantly and _that's ok_. I need better tools and to be better at managing my time and energies to be more targeted/specific and I am much more effective than I was all those years ago. I just have to be more intentional and forgiving of myself.