@Confused20232023 You need to consult a solicitor, even if she doesn't have a cause, better be safe than sorry.
In my layman's opinion, you have acted in good faith, exchanging your share of the flat for the mortgage payments, as you say you both have agreed in writing, but your sister can claim that she thought the mortgage payments would be taken into account in case of a sale.
If she's saying 'now' that you should have paid the mortgage over the 2 years you were not living there, it sounds that she has changed her mind or probably has been advised by someone else, including a solicitor, given that it took her all this time to inform you about the mortgage payments.
She had the option to sell (with you involved), rent (with you involved) or have a lodger (with or without you involved) during all the time she lived in the flat.
In terms of the exact amount of money, you can come to an agreement by calculating the total amount of mortgage payments that your sister has paid versus the total amount of rental payments that she hasn't paid (here you can argument that you have acted in good faith by not charging her for your share of the flat. Hopefully they will cancel each other out).
If this is not legally accepted, her assumption that you 'should have paid the mortgage during the 2 years' should also not be accepted, given that it was a written agreement, although not a contract, and the fact that she has paid the mortgage without taking any legal action at the time to make you pay your share clearly demonstrates that she agreed to pay the mortgage herself.
Good luck!