There’s plenty to worry about if the United Kingdom actually leaves the European Union. But one particularly fraught question is what will happen to the open border between Northern Ireland (part of the UK) and the Republic of Ireland (part of the EU).

If the UK wants to tightly control immigration — which was the entire point of Brexit — then it may need to restrict its border with the Republic of Ireland, which still allows unlimited migration to and from other EU countries. But doing so could have staggering implications for Northern Ireland, which is still recovering from decades of sectarian tensions and violence.

And yet, incredibly, few politicians gave this issue any attention at all in the lead-up to the Brexit vote. It’s a mess.

How Brexit could make a complete hash of the Irish border

Some quick background: Back in the 1920s, Ireland gained independence from the UK; the treaty creating the country allowed Northern Ireland’s parliament the option of staying in the UK, which it took. In the decades thereafter, the regions shared a porous border, with no need for citizens to show a passport as they cross:

This changed in the 1970s when the security situation worsened. To (vastly) oversimplify things, Northern Ireland is split between a Protestant majority that identifies as British and a sizable Catholic minority that identifies as Irish. Tensions boiled over with "the Troubles," driven in part by discrimination against Catholics and their exclusion from government, and featuring serious rioting and domestic terrorist violence. In response, the British military set up checkpoints and guard towers along the border with Ireland.

Those tensions settled down after the 1998 Good Friday Agreement, and the border is now porous again. Today, people travel freely between Ireland and Northern Ireland, signage is scarce, and it’s often tough to tell where the border even sits. The open border is a tangible sign of the end of the Troubles, and it’s a way for northern Catholics to maintain ties to the country they identify with.

So now comes Brexit. One of the main arguments for leaving the EU was that Britain should be able to control its own borders. Under EU law, the UK currently has to allow unlimited migration from France, Germany, Spain, Portugal, or any other EU member. During the eurozone crisis, Britain has seen a sharp rise in immigration from less affluent countries. Lots of British people don’t like this.

By leaving, the UK could legally restrict those flows. But, of course, any migrants in the EU could all travel freely to Ireland and hop over to the UK via Northern Ireland if they wanted. So if Britain really wants control of its borders, it will have to tighten up the Irish border.

The catch is that no one knows what this would entail. Peter Moloney, a visiting assistant professor of history at Boston College who studies EU governance, explains that the details will have to be negotiated between the EU and UK. But as an example, other borders between the EU and non-EU countries involve checkpoints, traffic stops, fences, and so on.

Practically speaking, that could prove difficult in Northern Ireland. The 310-mile border with the Republic of Ireland is poorly marked and often crosses existing farms and properties. Plus, there are tons of small country roads and byways throughout the region. Do they all get checkpoints? On top of that, many people live and work on both sides of the border. A recent tweetstorm by Séamas O'Reilly illustrated this well:

9. A border is bad for practical reasons; people like my sister live in Donegal and work in Derry, and thousands more vice versa... — Shocko (@shockproofbeats) June 27, 2016

Politically, things get even dicier. The 1998 Good Friday Agreement created a delicate power-sharing structure within Northern Ireland that was marked by compromise and ambiguity. The Protestants implicitly conceded that it was reasonable for Catholics to pursue closer ties with Ireland, while the Catholics implicitly conceded that formal unification with Ireland was unlikely. The free flow of people and trade enabled by the EU allowed Catholics to pursue those ties without requiring actual unification.

Creating a hard border could reignite those tensions. "If you’re setting up a border again, it brings back that ‘us-versus-them’ mentality and the echoes of confrontation, which has been broken down a lot in the past generation," says Moloney.

Even more concretely: Under the Good Friday Agreement, Northern Ireland can technically hold a referendum on whether to gain independence from the UK and unite with Ireland. So long as an open border existed, this was never a real issue; polling last year suggested that only 14 percent of Northern Irish people wanted to unify with the Republic of Ireland, with even Catholics preferring to stay in the UK.

But now? "The whole thing is uncertain," Moloney adds. "And it’s a totally self-inflicted wound."

Fintan O’Toole put it much more bluntly in the Irish Times: "English nationalists have placed a bomb under peace process." And here’s Pauline McCallion in Vox: "I live in Northern Ireland, and I'm scared Brexit will bring back the chaos of my childhood."

So what happens next?

No one really knows. The British people have voted, via referendum, to break up with the EU, but Britain still has to invoke Article 50 to formally leave. The government isn't bound to do so, and so far it hasn't, but it’d also be tough to defy popular will.

If Article 50 is invoked, the United Kingdom will have two years to negotiate an exit with the EU, during which time free trade and open borders between the UK and Ireland will persist. That’s when the details on the border would get hashed out.

David Cameron, who is still the British prime minister until October, has said the government will "fully involve" Northern Ireland on the exact terms of Brexit, without getting into more detail.

Enda Kenny, the prime minister of the Republic of Ireland wants to keep the border with Northern Ireland open. "[Ireland, Northern Ireland, and Great Britain] all share the common objective of wanting to preserve the common travel area, and an open border on the island of Ireland," he said recently.

Again, though, figuring this out in practice will be incredibly tricky: If the UK border with Ireland does get closed, there are big problems for Northern Ireland. If it doesn’t get closed, then there’s an easy path for migrants within the EU to get into the UK — something that Brexit proponents oppose. A third option would be to institute passport controls for anyone traveling from Northern Ireland to Great Britain, though this would mean UK citizens aren’t free to travel within their own country.

What’s especially surprising is that this barely got talked about before the Brexit vote took place. "It’s one of the many things," Moloney notes, "that wasn’t thought through."