I'm coming from a wrestling background, so take this for what it's worth, but I think the ref screwed it up for you, not by overturning her call, but by making the call prematurely.
Sit through on the head pinch was beautiful, and in a wrestling match you probably get 3 for that, plus a pin. But from a grappling perspective, where being on your back can be a neutral position depending on how you're locked up, your opponent did still have the front headlock in place, so you're still looking for control. She's waiting for that to happen.
Then your opponent does a nice job of getting from his back and sneaking his head through as he releases the head pinch. So now you've got his back and you're back looking for control. But from a different spot.
Seems like the ref starts counting from your release of the head to determine a takedown as though you kept him on his back? But you didn't. Now you have his back and need to get hooks in. Which you're trying to do.
Unfortunately, she stops it before you get the chance to finish the job, and then you end up being penalized for her premature stop.
That's what it looks like happened to me, anyway.
She basically screwed up because she was insecure about how she was calling it and listened to your corner. That's not their fault. It's their job to advocate for you. But it's also an understandable mistake.
Reffing wrestling or grappling or jiu jitsu where you're the point man on the mat who has to make the call in real time is damned hard. They make mistakes. As far as reffing mistakes go, this wasn't a huge one on her part, but it did influence the match and put you at a disadvantage (or, to be more precise, took away an advantage from you).
I do wonder why she started the match back at standing rather than resetting it as it was stopped, where you had a clear positional advantage.
Sucks that you ended up losing the match, but in fairness, his takedown was much more clean than yours was.