Sex/gender together cover, as I see it, three main areas; all of which are complicated, but misery of which haven't been recognized as such (or even recognized at all) until fairly recently.
The first is biological (usually called "sex"), chromosomes and various traits. This is often percieved as being strictly binary, but it's not: the genetic traits and other features typical of one sex or the other don't always spread together, and often the most superficially obvious ones don't match the ones that have broader impact. So that's complicated in ways that are often not recognized.
Then there is socially ascribed roles (this is ones of the things usually labeled "gender"); these are the expectations put on someone by society related to masculinity or femininity.
The there is one's own perception of one's own masculinity or femininity (this is sometimes also referred to as "gender", but often, and more clearly, "gender identity").
This is complicated, because it shaped by lots of things, including social gender stereotypes, and whether they align our conflict with ones current socially ascribed gender.