What could the EU Withdrawal Bill mean for Scotland?
MPs are to debate amendments to the EU Withdrawal Bill, the main piece of Brexit legislation, in two marathon sessions at Westminster.
Scottish MPs are set to be involved on all sides of the debate, including Remain-backing Tory rebels, Labour members pushing for single market membership, SNP representatives tabling amendments about devolution, and Lib Dems calling for a vote on the final Brexit deal.
The Scottish government and the Scottish Parliament are also caught up in it all, with Scottish ministers insisting that Holyrood's vote to refuse consent for the Withdrawal Bill must be recognised.
What is the background to all this, and where are we likely to end up?
What's going on?
It's set to be a week of high Brexit drama at Westminster, as MPs debate the EU Withdrawal Bill, the flagship piece of Brexit legislation, for one of the last times.
The Commons will spend the next two days pondering the amendments to the bill passed in the Lords, where the government suffered 15 defeats. The government's slim majority will be tested in a series of crunch votes as it seeks to unpick the changes made in the upper chamber.
As well big issues like customs union and single market membership and whether MPs will get a "meaningful" vote on the final Brexit deal, amendments concerning devolution will be considered.
MSPs have work of their own to do, but will have one eye on Westminster as the debate unfolds - particularly because they refused to give their consent to the bill.
Normally at this stage of the legislative process, any bill which cuts across devolved areas would have been signed off by Holyrood, or at least changed to reflect the will of the Scottish Parliament. It looks increasingly like this will be the first time a bill is passed without taking heed of that.
Why didn't Holyrood give its consent?
There was an almighty row between the devolved administrations and the UK government over what happens to a set of powers which are technically in the gift of Edinburgh and Cardiff, but which have been exercised from Brussels to ensure rules and regulations are the same across the EU.
An example would be the minimum food standards agreed for specific products like coffee, honey, condensed milk, chocolate and jam. At present, these apply across the EU. Post-Brexit, UK ministers want to agree new common standards to apply across the UK.
Both sides agreed that to do this, some powers should go into UK-wide frameworks. But they were divided on how these frameworks should be set up and run in the years immediately after exit - particularly over who would have the final say over them.
The Welsh government ultimately came to a deal with UK counterparts, but Scottish ministers have held out that even the proposal accepted in Cardiff was a "power grab" which would "undermine devolution".
Talks between ministers dried up, and both sides eventually seemed to accept that there was no chance of them meeting in the middle. MSPs ultimately refused consent for the bill by 93 votes to 30.
What is going to happen?
The Scottish government wants the UK government to remove the contested section - Clause 15 - from the bill, so they can plug the gap with their own legislation; the "continuity bill" passed at Holyrood earlier in the year.
UK ministers don't want to do that, and appear ready to proceed without Holyrood's consent. They have also lodged a legal challenge against the Scottish bill at the Supreme Court, currently due to be heard in late July.
MPs will get into this when they consider a UK government amendment passed in the Lords reflecting the deal done with the Welsh government.
The SNP has tabled amendments of their own - and backed others from Plaid Cymru - aimed at changing things still further, to "protect the Scottish Parliament from the Tories' power grab".
One thing you can guarantee is that there'll be a row. And at the end of it all? The UK government amendment based on the Welsh deal will probably pass. Even Scottish Labour MPs who want a better deal say the amendment on the table is preferable to the original state of the bill.
So the likeliest outcome is that the UK government gets its way - on the devolved powers sections at least - and pushes ahead with the bill despite the lack of devolved consent.
How big of a deal is this?
Legally, it's not a red line. It's never happened before, but there's actually nothing to stop Westminster legislating across devolved areas without consent.
The "Sewel Convention" which underpins devolved consent states that UK ministers would "not normally" do this. They will contend that these are not normal circumstances - and already have a ruling from the Supreme Court that Sewel is in any case just a political convention, not a binding point of law.
Politically, it is a bigger deal. First Minister Nicola Sturgeon has written to the Speaker of the House of Commons, John Bercow, saying that "19 years of constitutional convention and practice" are being put at risk.
The SNP's Westminster leader Ian Blackford meanwhile says "failure to listen to the views of the Scottish Parliament will be a decision that will haunt he Tories for generations".
It's hard to know precisely what this will mean in the long run, because we are in such uncharted territory. The SNP are determined to make sure this point isn't lost amid all the other noise of Brexit, but on the UK level this is one Brexit row among many.
What else is being debated?
The problem for the Scottish government is that their complaint is just one on a lengthy list of worries for Theresa May.
The prime minster needs to grind out victories on a whole series of amendments, but even with the support of the DUP her government only has a working majority of 14. Rebellions from Remain-supporting Tory MPs - like East Renfrewshire's Paul Masterton - could see the government defeated.
Mr Masterton is one of the Conservative rebels who may line up behind an amendment on single market membership, which Scottish Labour's Ian Murray and Martin Whitfield have announced they will be voting for.
At last week's Prime Minister's Questions, Mr Blackford also challenged Mrs May to back the move to remain in the European Economic Area (EEA).
However, Labour's leadership is opposed to EEA membership and have instead tabled an amendment of their own seeking "full access" to the single market - leaving the original EEA one unlikely to pass.
To add another layer of complexity, the SNP are now warning that the Labour amendment could "leave the door open" to a power grab. Without their backing, it too is fairly unlikely to pass.
Elsewhere, all of the Scottish Lib Dem MPs have their names down behind an amendment calling for a referendum on the Brexit deal to be included as an option, but with none of the big parties backing them this is even less likely to be passed.
A bigger worry for the UK government is an amendment which would give MPs the power to "direct the government in their actions" if Parliament votes down the final Brexit deal negotiated with the EU. The government is determined to kill this off, and is working hard to stave off a rebellion from pro-Remain members with a compromise proposal.
What happens after this?
This stage of the legislative process is known as "ping pong", as the bill ricochets between the upper and lower chambers at Westminster until a final version is agreed. Once that happens, the Queen signs off the final wording and the EU Withdrawal Bill becomes law.
The rest of the summer and autumn will be taken up with official talks and summits as the two sides hammer out the details of withdrawal and what the future relationship will be.
The EU's chief negotiator has said talks must be complete by the end of October to give the remaining 27 member states time to sign off on the deal. It's after this point that MPs would also also get their "meaningful" vote on the deal.
As thing stand, deal or no deal, the UK is due to leave the European Union at 23:00 on 29 March, 2019.
The UK will then enter a transition period, currently scheduled to end on 31 December 2020. After that, the new economic and political relationship between the UK and the EU is to begin - if one has been negotiated by then.