Republicans in Congress withstood for months the political turmoil caused by Donald Trump at the top of their ticket, confident of holding their majorities in the House and Senate despite his unconventional candidacy.

For a while it appeared that, with smart campaigns and strong fundraising, their optimism was justified.But Republicans are increasingly worried now that the race has spun out of control. They warn that Trump has become such a down-ballot drag that the election could flip control of the Senate to Democrats and shrink the GOP's majority in the House.It's not just Trump's behavior — including allegations of past sexual assault and his refusal to say he would accept the Nov. 8 election outcome — that is making Republican candidates worry.

Democrats have seized the opening, so confident as Hillary Clinton widens her presidential lead that her super PAC has started spending money in key Senate races, with more being considered for House contests.

No easy way

Republican operatives in congressional races see no easy way to reverse the slide in the time remaining. Nonpartisan analysts agree."I used to think there was a narrow path for them to hold on by their fingernails, but I no longer believe that's true," said Jennifer Duffy of the nonpartisan Cook Political Report. "It's not a pretty picture."

Republicans are prepared for a worst-case scenario, particularly in the Senate, where Democrats need to pick up four seats to flip the chamber if Clinton wins the White House, or five if she doesn't. The math was already in the Democrats' favor because twice as many Republicans as Democrats are up for election this year.

The best hope is that Republicans can stem their losses with candidates who heeded early warnings not to tie their prospects to Trump's volatile presidential campaign.Senators like Rob Portman in Ohio and Charles E. Grassley in Iowa have been campaigning like big-city mayors, focusing on local issues.

They and others, including Sen. Marco Rubio in Florida and Sen. John McCain in Arizona, have built field operations separate from Trump's, and it appears they will keep their seats.

Those in serious jeopardy

But Republican senators who have agonized most over the nominee _ toggling between support for and distance from Trump — are among those now in serious jeopardy.Sen. Patrick J. Toomey in Pennsylvania declined to take a definitive stance on Trump. New Hampshire Sen. Kelly Ayotte is struggling to shore up her base after abandoning Trump over his lewd comments. Both are being hit with ads bolstering their Democratic challengers _ Katie McGinty in Pennsylvania and New Hampshire Gov. Maggie Hassan.

At the same time, Democrats are cutting their losses elsewhere and shifting resources to expand the battleground to Republican terrain. Money is flowing to Missouri, where Republican Sen. Roy Blunt faces an unexpectedly strong challenge from Democratic Secretary of State Jason Kander, and North Carolina, where Republican Sen. Richard Burr is trailing Deborah Ross, a former member of the state General Assembly.Defeat seemis likely for long-struggling Sens. Mark Kirk,  R-Ill., and Ron Johnson, R-Wis.

"Overall, it's a miracle we're even in this thing right now," said one Republican Senate strategist, who like other political operatives interviewed for this story was granted anonymity to frankly assess the situation. "How could it get worse? But it always does."

Problems beyond Trump

Republicans say the problems for candidates in Congress go beyond Trump's behavior to the rapidly deteriorating political climate after a wild election year.Many donors and voters tend to view the presidential campaign as finished now that public polling puts Clinton so far ahead of Trump, they warn, and that is depressing fundraising and may dampen turnout.Big money flowed to Republicans from donors including the billionaire Koch brothers and casino magnate Sheldon Adelson, who spent more on congressional candidates than on the presidential race. But it has not been enough to keep pace in the final stretch.

The Senate Leadership Fund, the main PAC for Republican senators, spent more than $100 million this year with its combined groups, a record as they sought to confront the PAC run by allies of Democratic Sen. Harry Reid of Nevada, the minority leader.

"We are up against a perfect storm of spending from Democratic groups and donors who believe the presidential race is done," said the leader of the organization, Steven Law, a former top aide to Senate Majority Leader Mitch McConnell of Kentucky.

'Facing substantial losses'

House Republicans hope they are on sturdier ground because their 30-seat margin gives them one of the biggest majorities in years. Also few seats are competitive because of gerrymandering that has left most districts either solidly Republican or solidly Democrat.

But they sounded the alarms in a rushed series of interventions last week.Rob Simms, executive director of the National Republican Congressional Committee, warned of the "increasingly precarious" situation as leaders urged lawmakers to pony up funds for embattled colleagues.

"We could run the risk of facing substantial losses," Simms wrote in a memo to House Republicans on the day of the final presidential debate. "The national environment is beginning to create uncertainty in several of these races, as legitimate questions are now being asked about whether the unprecedented unfavorability of the presidential candidates will lead to depressed turnout."

Speaker Ryan scrambling

House Speaker Paul D. Ryan (R-Wis.), who publicly announced this month he would no longer campaign for Trump, has been stumping across the country to save his majority.House Majority Leader Kevin McCarthy of Bakersfield convened a pep-talk conference call last week that resulted in a few lawmakers transferring campaign money to their peers.

House Minority Leader Nancy Pelosi, D-Calif., expects a diminished GOP, suggesting whichever party wins control will have a single-digit majority."We're in good shape," she said.