Scotland and Brexit: what is the continuity bill?
Scottish ministers have published a "continuity bill" as the latest feature of their ongoing row with the UK government over post-Brexit powers. What is the continuity bill, how would it work, and what might happen next?
What's the background to this row?
At present, there are a whole raft of powers which are technically devolved, but which are exercised from Brussels as they fall into EU-wide frameworks for issues like agriculture and fisheries.
When the UK leaves the EU, these powers will be coming back from Brussels - and the Holyrood and Westminster governments are at loggerheads over how this will happen.
First there was a row over where the powers would go in the first instance, before some are incorporated into UK-wide frameworks and others are just left with the devolved administrations.
The latest offer from UK ministers is that "the presumption would now be that powers returning from the EU should sit at a devolved level".
Now, the dispute centres on how common frameworks are set up and administered. Scottish ministers aren't opposed to having these frameworks, but want them to be agreed mutually.
Cabinet Office minister David Lidington says that the UK government should be able to have the final say in some areas if they fail to strike a deal with the devolved administrations - so they can "protect the essential interests of businesses and consumers in every part of the kingdom".
Scottish Brexit minister Mike Russell says this is the UK government "using Brexit to try to take control of devolved powers without the agreement of the Scottish Parliament".
Where does the continuity bill come in?
Perhaps the biggest piece of leverage Holyrood has in the Brexit process is the legislative consent process, where MSPs are asked to sign off Westminster bills which cut across devolved areas.
Scottish ministers say that until the row over powers is sorted out, they won't be putting forward any Brexit legislation for consent votes at Holyrood.
First and foremost, this concerns the EU Withdrawal Bill - the first big bit of Brexit legislation, and the one which contains various provisions about devolved powers.
First Minister Nicola Sturgeon now says its "very likely" her government won't put forward the Withdrawal Bill for a consent vote - meaning a continuity bill might well be needed.
How would it work?
If Holyrood doesn't give its consent for the Withdrawal Bill, that doesn't derail the legislation - Westminster could just go ahead and pass it anyway, but without the contentious provisions applying to Scotland.
This would leave a gap in the law north in the border, which it would be Holyrood's job to fill.
The plan to do this is the snappily titled UK Withdrawal from the European Union (Legal Continuity) (Scotland) Bill.
This continuity bill would effectively be the Scottish Parliament's own version of the EU Withdrawal Bill, bringing EU laws across onto the domestic statute book ahead of Brexit.
After ministers "take back control" of these laws, they would then be free to amend or repeal them as they wish - crucially, at Holyrood rather than at Westminster.
This isn't necessarily a weird situation; Scotland already has a different legal system from the rest of the UK, and has increasingly been going its own way on policy with Holyrood's expanding powers.
Similar provisions were also included in the Scottish Independence Bill published in advance of the 2014 referendum, which would have brought UK laws onto the Scottish statute book so the newly independent Scottish Parliament could decide what to do with them.
However, some academics have warned that there cannot be a "simple division of powers" here, due to "the interplay of EU, UK and Scottish law", which are divided in "complex, unstraightforward ways".
Is this legal?
The bill hasn't just prompted a face-off between the Scottish and UK governments - it has opened up a rift with Holyrood's presiding officer.
Ken Macintosh has looked over the bill, and concluded that it is not within the Scottish Parliament's legislative remit.
He argues that the bill might be competent after Brexit, but says that at present it falls foul of EU law - saying it would see the parliament "make provision now for the exercise of powers which is it possible [it] will acquire in future".
The Scottish government, though, disagrees. Lord Advocate James Wolffe, the government's top legal advisor, says the bill is competent - and will be addressing MSPs on this point.
He said the bill was "carefully framed so that it does not do anything or enable anything to be done, while the UK remains a member of the EU". He added that it is "modelled, in this regard, on the UK government's EU Withdrawal Bill".
What does all this mean? Well, nothing - yet. The bill can go ahead without the presiding officer's blessing (although this has never happened before with a government bill), but there will be a period after it is voted through where it could be open to challenge in the Supreme Court.
What is the procedure from here?
Holyrood's constitution committee, which would be tasked with scrutinising the bill, have already raised concerns about the amount of time they might have to pore over it.
In a real emergency situation, Holyrood can bash out a bill inside a single day, knocking out all three stages in a single sitting - with the whole chamber sitting as a committee for stage two scrutiny.
While ministers say they do intend to have the whole chamber sit as a committee, it won't all be done in a single day - although opposition parties are sympathetic to the government's position on devolved powers, members will want plenty of time to scrutinise the bill.
Holyrood's parliamentary bureau is to discuss the timetable, and MSPs will be given a vote on how matters will pan out.
How could this end?
Technically, Westminster remains the sovereign government in the UK. It's written into the Scotland Act, which stresses that it "does not affect the power of the Parliament of the United Kingdom to make laws for Scotland".
Westminster could in theory just run over the heads of the devolved administrations and have its way regardless. The Supreme Court has underlined that legislative consent itself is a convention, rather than a legal matter that could be defended in the courts.
But the UK government swatting aside the wishes of Edinburgh and Cardiff would be a massive deal, politically. It would spark a constitutional crisis - indeed, Mr Russell contends that there is already a constitutional crisis.
The same is true of any court battle over whether the continuity bill is competent - the legal side of the case is one thing, the political implications are something else altogether.
There is also the not insignificant matter of the House of Lords, which is currently scrutinising the Withdrawal Bill.
Several peers and indeed Conservative representatives north and south of the border have indicated that should devolved consent not be forthcoming, the Lords will not allow the bill to proceed.
This would add yet another layer of constitutional crisis. In the midst of the negotiations with European leaders, a domestic showdown is probably the very last thing Theresa May needs.
So by far the preferred outcome for the UK government is to strike a deal, one way or another, to get consent. But months of talks have so far failed to produce this - could a continuity bill prove the political lever to make the difference?