With the UK prime minister on his way out, and the leader of the opposition disowned by the shadow cabinet, the joke doing the rounds yesterday was that if Jean-Claude Juncker wants to speak to Britain about Brexit he’ll have to phone Nicola Sturgeon: the only leader left standing. As Sky's political editor, Faisal Islam, put it: “She is the only one who seems to have a plan”.

So what is it? Well, it is not to declare UDI nor hold a snap referendum. Quite rightly the First Minister will explore whether and to what extent Scotland can remain in the EU as the rest of the UK leaves. There has been much huffing and puffing about this from Westminster silverbacks: “How dare she!” But she is bound to do this by the Scotland Act itself.

Article 29 of the 1998 Act says all legislation passed by Holyrood must be in accordance with EU law. The Scotland Act will have to be amended or else EU law would still apply in Scotland after the UK leaves. The Scottish Parliament will have to give a Legislative Consent Motion (LCM) to such a change and it will be up to the Scottish Parliament to refuse to grant one.

Teresa Villiers, the Northern Ireland Secretary, has said Westminster can over-ride this, and it certainly can. The constitution is reserved. Westminster retains overall sovereignty. But MPs would have would have to vote to overturn Holyrood's LCM motion and that isn't just a formality.

Under the Scotland Act 2015 , what used to be called the Sewel convention (before M'Lord Sewell had publicised encounters with ladies of the night and Columbian marching powder) is supposedly now on a “statutory” basis. It is arguably more now than a mere convention. If the vast majority of Scotland’s MSPs refuse consent to the legislation depriving Scots of their EU citizenship, this would have considerable moral force, even if Westminster can override it.

But what if the House of Commons decided not to over-ride the Scottish Parliament? It's not inconceivable. The overwhelming majority of MPs are Remainers. The EU referendum was only advisory. MPs might argue it is wiser not to provoke Scotland into holding another independence referendum by changing the legal status of the “entrenched” Scottish Parliament without consent. Is it worth he break-up of the UK?

If Westminster is sovereign it can decide not to issue a diktat. This could leave Scotland subject to EU law while the rest of the UK leaves. But would that be such a bad thing? It may sound a constitutional nonsense – but the whole process is faintly nonsensical. The UK prime minister presumptive, Boris Johnson, is saying Brexit will not end free movement to the EU or British access to the single market.

Scots still have EU citizenship. We have been under the protection of EU/EC laws for more than 40 years. There is a moral argument it is a violation of human rights for citizens to be deprived of that citizenship without their consent. Of course, Treaty-wise, UK citizenship takes precedence over EU citizenship and the UK is the member state, not Scotland.

But we are entering constitutionally uncharted waters. No country has ever left the EU – except Greenland in 1985, which remained part of Denmark and therefore still technically subject to EU laws. Northern Ireland, Scotland and now Gibraltar are discussing a “reverse Greenland” whereby the autonomous territories remain in the EU while the UK leaves.

A hard border with England? Perhaps, but Ireland is going to have one of those anyway It's not beyond the wit of man – or woman – to get round this, especially if the UK is to remain, as Mr Johnson says, in a continuing relationship with Brussels. As the founder of Reform Scotland, Ben Thomson, argued in The Herald yesterday, why not have the best of both worlds: Scotland in the UK sterling zone but also in the European Union?

There is going to be a vacuum in UK governance for the next three months at least. The Scottish Government could use this period of uncertainty to mobilise Scots behind a new claim of right, based on the 1989 Claim of Right: “The sovereign right of the Scottish people to determine the form of government best suited to their needs." That had no legal standing at the time but it turned the UK constitution upside down. The people united can never be defeated – or something like that.