With smoke still rising from the ruins of Hillary Clinton's defeat, Democrats are fighting for control of the machinery of the national party, and debating how best to try to counteract President-elect Donald Trump and retool to win future elections.

Outlines of the battle can be seen in the early stages of the campaign for the chairmanship of the Democratic National Committee, pitting the centrist wing of the party that has held sway for three decades - and formed Clinton's base - against more liberal members aligned with Vermont Sen. Bernie Sanders, who challenged her from the left.

The candidate getting the most buzz so far is Rep. Keith Ellison (D., Minn.), cochairman of the Congressional Progressive Caucus and the first Muslim to be elected to Congress. Sanders has endorsed Ellison, who also has the backing of incoming Senate Minority Leader Chuck Schumer (D., N.Y.).

The party should be more of an advocate for the working class and less a fund-raising clearinghouse, Sanders argues. "You can't tell working people you're on their side and at the same time raise money from Wall Street and the billionaire class," he said recently.

Clinton's money-raising juggernaut gathered $972 million for her campaign, the DNC, and state parties, but many liberal activists believe that firepower was outweighed by a fundamental misunderstanding of populist anger and an inability to connect with working-class voters.

"It seems to me Bernie Sanders would have done better than Hillary did," said Gloria Gilman, cofounder of the progressive activist group Philadelphia Neighborhood Networks, who campaigned hard for Clinton after she won the nomination. "The party needs to go back to the grass roots, and Keith Ellison seems like somebody who understands that, who can build on small donations from individuals and get the people involved."

Gilman and a group of friends sat shivah Friday to mourn the election of Trump. She said she hopes that the loss can have an upside, mobilizing liberals in resistance. "Not everybody is stymied by their shock," she said. "There's some really good organizing going on."

Former Vermont Gov. Howard Dean, who was DNC chairman a decade ago, is seeking the job again. A presidential contender in 2004, he pursued a strategy of organizing state and local parties in all 50 states, which won the hearts of grassroots activists.

Jaime Harrison, the South Carolina Democratic chairman, is weighing the race for chairman, as are several Hispanic leaders. Among them are Harry Munoz III, the DNC's national finance chairman; Labor Secretary Thomas Perez; and Reps. Ruben Gallego of Arizona and Xavier Becerra of California.

Those who favor rejuvenation at the grass roots point to big losses at lower levels of government under President Obama, who often seemed to some more zealous in guarding his own brand than in building the party's. As of January, Democrats will hold 11 fewer U.S. Senate seats, at least 14 fewer governorships, and about 900 fewer state legislative seats than they did when Obama took office.

The GOP now holds majorities in 69 of 99 state legislative chambers, compared with 36 at the start of 2010. If this trend continues, state legislative dominance will help the Republicans when it comes time to redraw House districts after the 2020 census.

The Republican Party was supposed to be the one with the wilderness problem, as Trump and his populist movement took it over, confounding its constitutional-conservative and free-market factions, and inspiring resistance from party insiders. But he won, and any reckoning about the future of the party is likely to be postponed as Trump assembles an administration and installs loyalists at the Republican National Committee.

Among the Democrats, progressive activists are still smarting over the revelations in leaked emails that DNC officials, favoring Clinton, tried behind the scenes to sabotage Sanders. The fallout from those leaks forced the last full-time chairwoman, U.S. Rep. Debbie Wasserman Schultz of Florida, to resign.

"In a time of introspection, why aren't we looking at a broad swath of the country for a chairman - people in the states who've done good jobs, and maybe we should start looking at a different generation," said Kevin Washo, former executive director of the Pennsylvania Democratic Party and the Philadelphia host committee for the 2016 convention.

"We need to try to build an operation and compete in a lot of areas of this country that we have ignored," Washo said. "We've got to be equally comfortable at the bar in the Four Seasons and at Bruno's Bar in St. Johns, Mich."

Some Democrats, including Washo and Dean, believe the next chairman should perform the role full time, arguing that a member of Congress like Ellison might not be able to undertake all the nuts-and-bolts organizing necessary.

At the same time, without a single national figure to act as a political counterweight to Trump, the next party chairman also could be called upon to be as much messenger as mechanic, and that job also can be grueling. It would help if the party came to an agreement on what the message should be first.

"We saw in this election that all the inside voices were wrong," said Rebecca Kirszner Katz, a Democratic strategist who has worked for retiring Senate Minority Leader Harry Reid of Nevada and New York City Mayor Bill de Blasio. "Democrats are hungry to have the party catch up to where the people are."

To her, that would mean a more explicit and sustained focus on issues such as income inequality and financial-industry regulation, as well as more reliance on grassroots energy than the party's corporate allies.

Others say a focus on a populist economic agenda might not be enough to attract white working-class Democrats and former Democrats who have been alienated from the party on cultural issues.

T.J. Rooney, a Harrisburg Democratic operative and past chairman of the state party, cautioned against making a decision on a new direction and chairman in the heat of the moment.

"I don't understand the immediate rush to come up with a solution when we're not 100 percent sure what the problem is," Rooney said. "That's going to require data, research, thinking, and time. I don't think it's right to suggest that what shocked our party last week is just one thing alone."

Ellison is impressive and may be the answer, Rooney said, but things aren't clear yet. "We don't need to just get it done, we need to get it right," he said.

215-854-2718@tomfitzgerald