Long, long ago, on Monday, when a Hillary Clinton victory seemed likely, the forecast for the Democratic Party looked grim. The party was confident that its aging candidate, the spouse of another former Democratic president, could win, and it was optimistic about winning control of the Senate. Clinton might serve (to borrow a phrase) as a bridge to the 2010s, but the next two elections would be much tougher: Democrats would be defending a lot of difficult Senate seats in 2018, and simple structural forces made it unlikely a President Clinton could hold the White House for two terms. Who would lead the party then?

Instead, the nightmare has arrived early. All of those dangers still beset the party, but now without the bridge of a Clinton presidency to ease the blow. Donald Trump will enter the White House with a Republican Senate and a Republican House. Because President Obama was unable to get the Senate to vote on his appointee for an open Supreme Court seat, Trump will immediately have the chance to appoint a ninth member to the Court, breaking a 4-4 tie. At the state level, Republicans now control at least 34 governorships, the most since 1922, and ran up their advantage in state legislatures.

The result is that much of the Barack Obama legacy, the most sweeping and impressive progressive program of social reform since Lyndon Johnson, is in peril. There are many places where Trump and the leaders of the Republican Congress disagree, but they have all pushed for the chance to dismantle two signature Obama achievements: the Affordable Care Act, which was the crowning if incomplete culmination of decades of Democratic effort; and both domestic and multilateral efforts to slow climate change. A conservative majority on the Court also throws long-settled precedents like Roe v. Wade into question.

As if that’s not bad enough, it’s hard to see who will lead the party back now. Smart analysts have been warning of the weak Democratic bench for years, but the Clinton loss makes it even more urgent. Clinton, at 69, is unlikely to maintain a high-profile presence. Her defeat also signals the final eclipse of the political dynasty that her husband, Bill Clinton, constructed in the 1980s and 1990s and rode to two terms in the White House. This is not without irony: Bill Clinton was elected president with the support of many white, blue-collar voters, but Hillary Clinton and the team of confidants they had built up lost because of the same voters—in part thanks to Bill Clinton’s policies (in particular, NAFTA) and in part thanks to racial backlash against Barack Obama.

Obama, whose strong popularity ratings could not save Clinton, will remain a leader for the party for years to come, but he will never top a ballot again, and this cycle proved that he doesn’t have the capacity to single-handedly drag a Democratic nominee over the finish line, either.

Bernie Sanders electrified many voters, and there’s a raging battle among progressives today over whether he might have fared better in a general election, but given that he is 75 today, he is unlikely to be a repeat candidate for president. Who then? Elizabeth Warren is widely loved by the most progressive Democrats, but she, too is aging—she’ll be 71 on Election Day 2020—and somewhat unproven, having only won a single election in the bluest state in America. Tim Kaine’s profile has risen, but his low-key campaigning style didn’t exactly set Democrats afire. There is a crop of young senators who might vie for the title, like Cory Booker, who is charismatic but bland and associated with the centrist, neoliberal wing of the party. Kamala Harris, the newly elected senator from California, is viewed as a rising star, but she is just that, a newly elected senator, so it’s hard to know her future. Republican domination of governorships robs the Democratic Party of another pipeline.

Some Democrats, witnessing Michelle Obama’s commanding performances on the stump this year, have fantasized about her running for president in 2020. But she has evinced zero interest in electoral politics, and the Clinton experience should probably give Democrats pause about putting their trust in beloved former dynasties.

Of course, deciding who will lead the party is intertwined with what the party will look like. Obama has managed to hold a coalition of leftist and centrist Democrats together, but that is already crumbling. There will be great pressure for the party to adopt a vision that draws on the populist success of both Trump and Sanders, but that pressure will meet opposition from party insiders as well as from the educated, well-to-do whites on whom the party increasingly depends. With the Republican Party looking like an anti-free-trade bloc, Democrats could try to become the party of business, but that might only worsen the problems that sank Clinton. There’s no obvious answer to how the party can reconcile its need for some working-class whites with the focus on social and racial justice that has become a Democratic priority, driven by the near unification of minorities under the party’s banner.

Democratic success in Nevada, driven by the muscle of labor unions, might look like a bright spot, but it’s difficult to see how it is replicated. Unions are in secular decline, more and more states have adopted “right to work” laws, and a conservative Supreme Court and Congress are likely to continue curtailing the power of unions at the national level.

This makes the stakes in the two next elections very high. First, there’s 2018. On the House side, past trends suggest Republicans will likely lose ground in the House, but Democrats will have to win seats in several red states just to stay even in the Senate. Then comes the 2020 election. If Democrats can win then, behind whatever candidate eventually emerges, they may be in decent shape. But if they lose, the outlook is very grim. Just look to Republican success in 2010, ahead of the Census and redistricting of Congress. By winning across the board, the GOP was able to give the map a lasting tilt toward Republican dominance. A Democratic win in 2020 could rebalance that, but a loss would make the systemic challenges even greater. (There’s a reason that Obama and former Attorney General Eric Holder have already announced plans to focus on trying to help Democrats at the state level after Obama leaves office.)

The last couple decades have shown the folly of predictions of party demise, from Karl Rove’s wrecked dream of a “permanent Republican majority” to Democratic hubris in 2008, right up through forecasts of the demise of the GOP earlier this year. As Harold Macmillan may or may not have said, what makes a politician, and by extension a party, is “events, dear boy,” and one cannot assume all exogenous factors will remain stable.

If Democrats have anything on their side, it’s the same force that was supposed to save them in 2016: demographic change. As the nation gets less white, a Republican Party largely dependent on white votes will get less tenable. But many smart analysts predicted that would decide this election, too. Just days after its death was foretold, the Republican Party is radically changed but holds great power, while the Democratic Party is the one on life support.