Dear RorD,
It sounds like you have a lot going in your favor as far as a positive relationship with your SD, even if custody seems unlikely.
Some more thoughts: It's a given that SD's mom will interrogate and be suspicious of you even the PD. You are wise to be looking ahead. If a "divorce" between SD and her mom is imminent in the next few years, you may need to take steps now to protect yourself from the fallout that will also be predictable. Someone mentioned documenting everything. A very good idea. Also, on bpdcentral.com they are touting a new book about BPD and divorce. You might be able to apply some of the advice to this situation. You know a natural disaster is coming, so be prepared! Also, you might want to read Stop Walking on Eggshells to help yourself understand and cope with this situation. It can also provide some phrases to use (some tools) for you and SD to use with her mom. I just wouldn't tell SD the source of these ideas!

Another thought: when I was a young girl, I couldn't understand why some kids would take an instant dislike to me or others. Like a reaction. I always thought it was me. Now I know it wasn't me. I explain to my kids that we're not going to like everyone and not everyone is going to like us. I just don't understand it, but that is the way it is. Doesn't mean we're not "nice" or "worthy" or whatever. For whatever reason, it just doesn't work. It helps them (and me) take things less personally.
As for a parent tearing down a child, perhaps you can point out generally that sometimes when people are angry and say mean things, they are really revealing something that they don't like about themselves. I don't know how I can bring that down to a ten year old level, but I'd try. I would not bring it up when she's talking about her mom specifically, but I'll bet she's bright enough to make the connection herself when she needs to.
Art is also another great outlet for expressing frustration and for taking one's mind elsewhere for escape. It sounds like you are very strong, capable individuals and this is simply the challenge life is presenting you, not to be avoided but met face on. The fact that you are there listening to your SD means someone does care, SD matters. She is way ahead in having a healthy perspective than those kids whose viewpoints are not acknowledged. Kudos to you!
Hope this brainstorming is useful. Peace, Seeker