Hrmm, I don't get fat, no haha. Definitely not my problem. And they may not be related (my protein before bed and sleep quality). I just noted the two were correlated: my sleep improved about the same time I started taking that whey protein before bed.
As for the actual fat/weight gain/weight loss: there is truth in the CICO equation, once you figure out how your body processes different macros. I.e., if I keep my carbohydrate and fat intake fixed, I can vary whether I gain or lose weight (slightly) by how much protein I eat. It directly corresponds to calories consumed and burned in the course of the day. Tracking it precisely is almost impossible, but estimating does work (at least for me and most athletes). It took me a while to realize, however, that I had to match my carb intake and insulin production, and that I don't digest fats well over a certain amount per day. When I figured those two things out (that I don't store or lose bodyfat if I'm in the 40-80g / day net carb window and that I can't digest more than about 120g of fat per day), I figured out how to maintain weight by varying my protein intake and exercise routines.