So the court did just that, and defined (for the purposes of legislation) what "Man" and "Woman" refers to, i.e. sex not gender. A person with XY chromosomes, but some sort of developmental disorder that makes them appear feminine isn't some kind of massive puzzle from a biological point of view either, you'd just say "Male with AIS" for example. From a legal (in the UK now) point of view you'd say the same, and from a social point of view you'd say whatever that person identifies as.
People love pointing out that biology is complex, but for some reason bristle at the prospect of language that accurately expresses that complexity. And to be clear, if someone who is XY identifies as a woman... *Call them a woman!* It's rude and cruel to do otherwise, but from a legal standpoint it's unhelpful to play word games.
Yes, this is what the judges were tasked to clarify. And they clarified. The situation is better now, i.e., those laws are not ambiguous anymore (well, except for that 'what is biological sex' discussion...). It is quite an arbitrary clarification, but they clarified, and arguably, they could only do it wrong. They write themselves that they are not trying to define what sex or gender is. But they disambiguated existing laws, which by itself, is a good thing.
Obviously, this is not a good judgement for trans people, but the underlying problem is not with this judgement, but that the laws are not good. No definition of what sex or gender is will make those laws better. Judges cannot change that; legislation needs to change that. The judgement clarifies that the laws were made to protect cis women from cis men. The laws unfortunely do not protect trans women. And that's bad. Completely agreed.
The discussion here has drifted in the direction of how to or not to define biological sex -- and that's also not helpful for trans rights. But the topic is still interesting and no-one claimed to be solving problems, I think.
When it comes to the law though, word games are unhelpful and get in the way, clear definitions are required. In terms of respecting human dignity, these definitions change nothing; people inclined to respect trans people will still feel the same way, and bigots will hardly change either. You can still have laws and legal structures designed to protect people while recognizing the reality of their biology, because it's about GENDER identity, not BIOLOGICAL identity.
Why is it so important to you that sex/gender is binary? Maybe try to relax and be a little less judgemental. It really does not matter for you what other people's sex is.
Intuitively, for normal people on the street, and arguably for politicians trying to define that sex is binary, how you would read a person is their sex. So that is, I would say, the historic traditional way of determining sex: by look and intuition (called common sense, usually). That's also how sex is determined at birth. (Note that in some cases, nurses need help with that, because it's not intuitively clear...)
Because this intuitional method does not work well, other ways have been tried to find something more objective than having a quick look. We found the sex chromosomes. But they are not binary either, as mentioned above. Now, one way of making chromosomes forcibly binary is to take the check for a Y cromosome, as you say. But that's just one arbitrary simplification. It is not an universally agreed criterion, because it does not always match with other criteria, particularly looks/intuition nor hormones.
And even intuitively, I argue, you should know that sex is non-binary. There are people where you cannot easily read the sex. You have an immediate intuition most of the time, sure, but not always. And then, as mentioned, your intuition may contradict chromosomes and/or hormone level categorisation of that person.
Another example: typically, an XY chromosome person with female external genitals is most probably read as clearly female. But by chromosome judgement, as you suggest, they would be clearly XY male. And at birth, they are most probably be classified as female. But they do have testicals and high testosterone levels, which again is totally in line with the male chromosomes.
Sex is not binary. Really. The world is not that simple. I'd argue that instead of trying to force sex to be binary, we should just try to not care so much about sex and gender. Because why?