This! And! Representation is never gonna be 100% approved by 100% of the audience.
For example, if you're writing a woman, and that woman is a damsel in distress, then you might resonate with some women who feel like they need help, but at the same time alienate women who don't like their gender to appear weak. If you go the opposite way and make her a strong rouge type, then you're playing into the tough loner of a woman trope. Some women will find that representation freeing while others will not like how her independence and rouge-like behaviors make her look like a bitch.
I know the same problem exists for characters who are minorities, too. Like, for the longest time, children's cartoons which featured black supporting characters made them all smart, nerdy, and\or hard working. Which is better than the alternative! But also kinda reinforces racist stereotypes by making a big deal out of not using racist stereotypes in an Exception Proves the Rule kinda way. It's also difficult to relate to and actually enjoy characters with little to no percievable flaws, or who are annoyingly nerdy in ways no real life human being has ever been, and thus these characters exist in a limbo of not actually pleasing any audience members while simultaneously meeting a diversity quota. Token characters were a really big deal when I was a kid, and they were almost universally meh.
Cartoons with actual non-white characters that were well written (static shock, avatar the last airbender, teen titans) definitely had some issues where characterization could get racialized, but they also gave us some of the best children's cartoon characters! And unlike bland token characters, these characters are relatable and enjoyable to watch.
So! While it would be easy (and unfortunately frequently opted for) to avoid writing characters that could result in an accusation of sexism or racism, I think it's best to write the characters anyway, and then listen to criticism!
Sure, you might get weird comments like "you fetishized black people" in a fic where a character is married to a mixed black man (literally saw this happen and now we're permanently down a story featuring a gay mixed couple because the guy's spouse had a fleeting thought about how his husband's hair was beautiful smh).
But even if you get a message that at first seems like it's completely crazy- you obviously never intended to make your story racist or sexist- it's best to revisit that comment after the initial defensiveness has waned. You might find it has merit, or you might find that it came out of left field. If you have trouble identifying which it is, then reach out to others and ask. BUT NEVER REACH OUT OR RESPOND WHILE YOU ARE FEELING DEFENSIVE OR LIKE YOUR FEELINGS WERE HURT! WAIT FOR THAT EMOTION TO WANE BECAUSE YOU WILL ALIENATE A WHOLE BUNCH OF PEOPLE AND GIVE CYBER BULLIES AMMUNITION IF YOU MAKE AN AGGRESSIVE POST IN RESPONSE TO CRITICISM!!!!!!
Either way, learn from what you've done right and what you haven't done right, and don't stop stepping out of your comfort zone with characters! It's a great way to not only learn how to write complex characters from any background, but reading and writing stories is proven to expand a person's emotional intelligence and ability to empathize with others.