As dave said, clean the drains. The drains come off al four corners of the sunroof. Two down the A pillars, two down the C pillars. It's impossible to get to the back ones without dropping the headliner, which isn't really that bad if you don't have to take it out of the car.
The top of the headliner is some nasty fiberglass raisin, try not to touch it.
I've had the hoses come off the drains in the sunroof before, so when I had to swap the sunroof out, I hose clamped the drain tubes on. They get dry and hard, and just fall off.
Also, there's a drainage tray that moves back and forth with the sunroof as it slides open and closed, it has a slightly complicated mechanism, and sometimes that can stop sliding causing all the water off the back of the sunroof to drip directly into the headliner.