I use the Pomodoro method to stay focused when I'm online and [track my time spent unplugged](http://foote.pub/examples/unplug/index.html) to make sure there is enough of it. Good luck -- remember everything will be OK iff you let it.
Edit: so many good comments, just wanted to second that this is exceptional, honest writing and that you are not alone in this struggle !