I literally keep a laptop next to my bed so when i think up a solution for whatever problem i'm working on i can make a note about it. It's not pretty but it works.
In the last few years I started actively trying to stop myself from thinking about company code (and other work stuff too) when I'm not at work. You know, work life balance and all that. Did wonders to my mental health.
Lol I spent like 3 hours debugging why one of our services in stging wasnt publishing messages to kafka and 2 hours on a call with devops on monday trying to figure out why terraform tore down a diff services mongo permissions