I've had similar stuff, including massive panic attacks / anxiety, especially in graduate school. I learned to deal with it through diet, exercise, but mostly by getting outside and getting more sunlight. If your climate / weather allows for it, go take a sick day, pack a lunch, and go spend at least half the day in some sunny park or beach.
I also find it helps to write out all the thoughts in your head. If I don't do this, I feel like my brain is stuck in a loop, always coming right back to whatever major issue I'm having. Getting that issue down on paper somehow lets my brain move on and really think about some other things for a while.
I do the same thing when I over-think. It's overload and background noise in my head. I go through a couple waves every year with very bad panic attacks for a few good weeks, usually triggered by stress. I notice it's when I have a hunch to do something but then delay on it for a few minutes/hours/etc. starts as a restless feeling which then leads to dervish behavior then thoughts directed internally... leading to hyper ventilation, heart palpitations, etc. Good advice I'll have to try that next time.
I also find it helps to write out all the thoughts in your head. If I don't do this, I feel like my brain is stuck in a loop, always coming right back to whatever major issue I'm having. Getting that issue down on paper somehow lets my brain move on and really think about some other things for a while.