What can border guards check on your smart phone when entering USA?

I don’t travel much but have heard lots of horror stories about entering into the USA. What exactly can the border guards check in your smart phone when entering the USA? I use mine a lot and it’s connected to online banking, email, social media and google drive. I’m assuming he can’t check things like online banking, but is he really allowed to go through email? I text people I’m close to like my girl friend and I’m really not comfortable with a stranger going through it. Can I put on app specific passwords? Can you watch the border guard check your phone?