Brexit: What are Scotland's options?
Politicians have repeatedly pledged to explore "all options" in relation to Scotland's ties with the EU following the Brexit vote. Here, I examine some of those options.
The Reverse Greenland
This option is inspired by Greenland, which joined the EU as part of Denmark in 1973, but then seceded from the union in 1985 after gaining autonomy.
This scenario would see Scotland, potentially alongside fellow Remain-voting areas like Northern Ireland and Gibraltar, stay in the EU while the rest of the UK leave.
Scotland would effectively have associate membership of the union - it would still have access to the single market, EU citizenship and free movement, and would still pay membership dues. It would take up the seat at the table in Brussels vacated by the UK.
This unprecedented move would create a whole new form of EU member - a sort of member sub-state - although First Minister Nicola Sturgeon has repeatedly said that we are navigating "uncharted territory".
In theory, this is the option endorsed most heartily by Scots; they backed the union in 2014's independence referendum, before heftily endorsing the EU in June. However, there are myriad of questions hanging over the Reverse Greenland - currency and trade to start with, but potentially more crucially over free movement of people, a central pillar of the EU.
Kirsty Hughes, an associate fellow at the Friends of Europe think tank, said the Reverse Greenland was an "interesting but tricky" proposition.
How would free movement between Scotland and the rest of the UK be policed? A hard border? Would Gretna become the new Calais? Who would set immigration policy?
Ms Hughes said free movement of people could be "politically difficult", but said it didn't have to be in practice.
She said: "I can envisage free movement of people so that people from elsewhere in the EU can work in Scotland and Northern Ireland, but in England and Wales the government there say you can come and visit as tourists but you can't work here.
"Now that wouldn't necessarily require border controls, it's just different rights to work - businesses shouldn't break the law in employing people who don't have the right to work. But politically it's obviously going to be sensitive."
Trade could also be an issue - Scotland sells roughly twice as much to the rest of the UK as it does to the rest of the world. Tobias Lock, lecturer in EU law at the University of Edinburgh, said it would be "tricky in practice" for Scotland to remain in both unions.
He said: "The problem with that is that you'd be creating two markets within the UK. Scotland would be part of the single market and if the rest of the UK leaves the single market, this would create problems for trade between England and Scotland, for example."
The Norway Model
A less extreme version of the Reverse Greenland would see Scotland remain fully part of the EU's single market, but without being a full EU member.
This may be a more likely solution than the Reverse Greenland, given Prime Minister Theresa May's mantra that "Brexit means Brexit" and her attorney general's statement that "all of the UK" would be leaving the EU.
This would be a negotiated settlement, similar to Norway's deal with the EU, which sees it bound by some Brussels doctrines - including free movement, social and employment policy and the environment - but with access to the single market and its own policies in areas like agriculture, fisheries and external trade.
The Open Europe think tank has suggested a "constitutionally possible" version of this for the UK. This would include a commitment as part of the Brexit deal to not repeal any EU laws that affect Scotland, while Scotland would still come under EU laws in relation to free movement and fisheries and make a contribution to the EU budget.
In return, Scotland would be granted a seat on the Committee of Permanent Representatives, a non-voting body which has some influence in EU law-making.
The think tank speculated that the issue of free movement could be addressed by giving the Scottish Parliament the power to issue national insurance numbers valid only north of the border, while granting extra documents via the electoral roll to give Scots free movement in the EU.
This is potentially a simpler solution than the Reverse Greenland approach of retaining full membership, but would still involve very complex, detailed negotiations - in addition to the already tricky task ministers face of untangling the UK from the EU's institutions.
One glimmer of hope for pro-Remain Scots might be Cyprus: the EU showed flexibility in relation to that divided island, admitting the Republic to the union in 2004 while effectively turning a blind eye to the Turkish-controlled breakaway north.
A potentially more revolutionary solution which has won cross-party support is federalism, similar to the model of government used in Germany, Switzerland and the United States.
Labour has tasked former justice secretary Lord Falconer with exploring a federalist solution that Scottish leader Kezia Dugdale "tentatively" suggested could keep Scotland in both the UK and EU.
Long a policy of the Liberal Democrats, federalism has also been championed by senior Scottish Conservative MSP Murdo Fraser.
His model would see the existence of Holyrood and the other devolved administrations cemented in a written constitution, and the creation of an English parliament sitting alongside the UK one at Westminster.
This greater level of devolution would make it easier for Scotland and Northern Ireland - and potentially even Remain-voting London - to have their own, separate relationships with the EU.
Although he acknowledged issues with the model - such as an English parliament being more disproportionately powerful due to the vast majority of the population living in England - Mr Fraser suggested that such a system could bring together the "very divided country" illustrated by the Scottish independence and Brexit referendums.
The prospect of Scotland remaining in the EU by leaving the UK has been the most hotly-discussed option - thanks in no small part to Ms Sturgeon initially suggesting a second independence poll was "highly likely" in the wake of the Brexit vote.
The first minister insists that independence is not her "starting point" in negotiations, but says it has to be "on the table" as a possibility.
In practical terms, the easiest way to do this in relation to the EU would be for Scotland to stay in as the UK leaves, rather than going through the process of readmission after Brexit. This constrains the timetable for any second Scottish referendum.
Friends of Europe's Ms Hughes said: "In 2014 the SNP said it could take 18 months to detach from the UK if the vote was a Yes. So if these EU negotiations are said to take two years for an exit deal and longer for a trade deal, you'd have to have a referendum by next summer if you were to have a chance at all of staying in the EU rather than joining again."
Re-joining the EU post-Brexit would raise a host of fresh questions, many familiar from the 2014 campaign, such as what currency Scotland would use and whether it would meet the EU's entry criteria economically. However Ms Hughes said it might not be overly difficult for Scotland to gain readmission post-Brexit - if the key questions could be answered.
She said: "Scotland meets a lot of the entry criteria now, but it would have to talk through a lot of the UK's opt-outs on the Euro and on justice affairs and so on - Scotland would have to decide if it would be a fully participating EU state."
Deal, or maybe no deal
As difficult to achieve as many of the options listed above may turn out to be, perhaps the least likely outcome is of no deal being done at all. Politically, it would be very difficult to justify ignoring Scotland (and Northern Ireland and London) altogether.
One of Theresa May's first acts as prime minister was to head straight to Edinburgh for talks with Ms Sturgeon. And while she has said some of the options discussed were "impracticable", she has pledged to consider them all.
All of that said, those newly settling into government in Westminster are already facing a terrifically complex job, and on a tight timescale. As soon as Article 50 of the Lisbon Treaty is invoked, setting the formal process of quitting the EU in motion, ministers have two years to negotiate the divorce.
While all have pledged to consult the devolved legislatures, a series of UK government figures have ruled out the idea of Scotland having any "veto" over Brexit.
Several have also spoken against the idea of a second independence poll - Ms May herself says Scots "had their vote" in 2014 - and with just one Scottish Tory MP in the government, Scotland's protests may seem a rather remote problem when compared with the labyrinthine task of negotiating exit from the EU and new trade deals.
And, despite Ms Sturgeon's talk of the "overwhelming" win for Remain in Scotland, one million Scots still voted for Brexit - 38% of those who voted. While few will argue against her aiming to get the best deal possible for Scotland, a not insignificant number of Scots won't want Ms Sturgeon to derail Brexit altogether.