Late Tuesday night, Jennifer Granholm, the former two-time Democratic governor of Michigan, was standing in a conference centre in midtown Manhattan at what was supposed to be Hillary Clinton's victory party when everything came crashing down.
Ms. Granholm, a co-chair of Ms. Clinton's transition team, had planned to travel to Washington after the election to start preparing for her presidency. Instead, Ms. Granholm arrived there on Friday to drop off equipment and help wind down the operation.
"Most of me is still in depression, with maybe a toe into acceptance," said Ms. Granholm, referring to the model for the five stages of grief. A particular source of sorrow was that Donald Trump squeaked out a win in the state she used to govern, which had not voted for a Republican presidential candidate in 28 years.
Related: 'It will be devastating': Women's rights at risk under Trump presidency
Read more: The real reason Donald Trump got elected? We have a white extremism problem
Read more: Which countries stand to gain – and lose – from a Trump presidency
The vote is a "huge wake-up call," Ms. Granholm said. "The Democratic Party used to speak for the workers who felt they were not being seen. It just breaks my heart that we weren't able to speak to them in this election in a way that was compelling."
Nowhere is the shock greater than within the Democratic Party, which faces a struggle to regroup. Going into Tuesday's election, Democrats expected to win the presidency and perhaps take back control of the Senate. They did neither, and Republicans now dominate both the executive and legislative branches of government.
Democrats will spend at least two years in the political wilderness before their next chance to shift the balance of power, the mid-term elections in 2018. During that time, their challenges include figuring out exactly what went wrong in the campaign, deciding whether and how to work with the president-elect, and plotting the broader direction of the party.
Such choices are fraught with disagreement, as the centrist and progressive arms of the party prepare to battle for its future. Also, the Democrats have relatively little leverage as Mr. Trump seeks to push through his agenda. He has said he intends to dismantle or overhaul some or all of President Barack Obama's signature achievements, including the health-care legislation known as Obamacare.
But Democrats also note that Mr. Trump's victory is more tenuous than it seems. Ms. Clinton is on track to win the popular vote with some ballots still to be counted, and voter turnout appears to be the lowest since the 2000 election.
"Donald Trump won't be the first president to misunderstand and over-read his mandate," said Geoff Garin, a Democratic strategist and pollster who advised a political action committee working to elect Ms. Clinton.
"Democrats need to be strong and smart in taking action when Trump oversteps his mandate, as he most certainly will."
In the short run, Democrats must decide how they will deal with Mr. Trump. Two leaders of the progressive wing of the party – Senator Bernie Sanders of Vermont and Senator Elizabeth Warren of Massachusetts – said this week that they would be willing to co-operate if his proposals would improve the economic situation of working-class families.
But they vowed to oppose any effort to deepen the divisions created by Mr. Trump's campaign. "If Donald Trump takes people's anger and turns it against Muslims, Hispanics, African-Americans and women, we will be his worst nightmare," Mr. Sanders said in a post on Twitter on Thursday.
In Congress, the Democrats' position is "bleak," said Thomas Mann, an expert on U.S. politics at the Brookings Institution. Republicans are likely to package the toughest parts of their legislative agenda using a special process called budget reconciliation, he said.
In the Senate, such measures involve a limited period of debate and are not subject to filibuster, meaning they can pass with a simple majority, which the Republicans possess if they are unified.
Democrats could make life difficult for Mr. Trump by using procedural delays as he chooses his cabinet. "If they're not getting what they consider to be plausible nominees, they could stretch this out and raise holy hell," Mr. Mann said.
In the longer run, Democrats need a fresh winning strategy. While they hold a demographic advantage over Republicans, the election showed that edge cannot compensate for large losses among white working-class voters in the Midwest.
On Friday, Ms. Clinton's team presented an early version of a post-mortem in a conference call with fundraisers, according to a person who listened to the call. Jennifer Palmieri, the director of communications for the campaign, pointed to difficulties like the anti-establishment mood among voters and the challenge of succeeding a two-term president from the same party.
Ms. Palmieri also said white, college-educated voters had not turned out in the expected numbers, attributing the drop to the unprecedented intervention by James Comey, the director of the Federal Bureau of Investigation.
Behind closed doors, Democrats are pointing fingers at each other and the party establishment, with some saying it acted in unfair ways to help Ms. Clinton secure the nomination over Mr. Sanders, who, some assert, could have beaten Mr. Trump.
While that is impossible to prove, many Democrats believe Mr. Sanders spoke in a more visceral and effective way to the concerns of working-class voters than Ms. Clinton did. "Our party is going to internalize a bit of Bernie Sanders," Ms. Granholm predicted. The strength and clarity of his message "will be part of our DNA."