How can I avoid Gimbal Lock with Rotations?

@Thumper Thank you for this post!
I don’t think I understand this enough to solve my case, though based on the way that you solved it, could you please help me?

I have a planet and a hand that is grabbing it, and rotates the camera. I’ve made this work up to a point where if I click towards the Z axis (pole), it will rotate the whole thing 180 degrees. Here is a picture of the nodes and an in-game view