I had to take mine completely apart to get the headliner panel out. Crank the sunroof halfway back to expose the front edge of the headliner.
The inner panel clips to the sunroof panel about 2"-3" behind the front edge. There are six little spring clips IIRC, but it's easy to scratch the sunroof panel or bend the front of the panel frame prying them out. I used a taped screwdriver since I won't see it again...but that did some damage. I'd advise a trip clip puller or something plastic.
You'll be able to slide the whole inner panel back. I then removed the six torx mounting screws (with a long flex screwdriver & bit) and pulled the metal sunroof panel out, then slid the fabric panel forward. It has these two long arms on the side that clip to a lateral slider. These can be carefully pried off & the whole thing can then be removed. You'l need some fabric glue to put the new fabric cover on.
If you want the gear box or cables, then you have a lot of little screws to get out. There are two cleverly hidden screws in the front of the sunroof opening holding up the headliner panel. The forward trim plate (in the sunroof opening) must to be removed to access them.
Re-aligning the sunroof isn't fun.
Here's a good DIY. I'm told it should be 1mm high in the rear and 1mm low in the front.