By Greg Torode, Rupam Jain and Abdul Qadir Sediqi
KABUL (Reuters) - U.S. diplomats and the Afghan Taliban have seen cause for hope in talks to end the United States' longest war, but the pivotal issues of a ceasefire and the militants sitting down with the Afghan government are far from being resolved.
Areas in which both sides have hailed progress - plans for the withdrawal of foreign troops 17 years after the U.S.-led ouster of the Taliban and assurances that Afghanistan won't become a base for al Qaeda or Islamic State - still need detailed negotiation, sources on both sides said.
The withdrawal, for example, is contingent on a ceasefire that the Taliban have yet to discuss.
"We want to be absolutely sure that the U.S. is leaving before we call off the fight," said a senior Taliban official on condition of anonymity.
But a senior U.S. official privy to the negotiations was clear a ceasefire had to come first: "How could we even do a withdrawal without a ceasefire?"
And the Taliban's assurances on counter-terrorism also come with caveats.
They say they can guarantee the United States the security of the half of the country they now control, but they would have to be in an interim government to be sure of stopping al Qaeda or Islamic State from attacking anywhere else.
Left to watch the unlikely U.S. and Taliban tango as he eyes a second term, Western-backed Afghan President Ashraf Ghani refuses to accept an interim government as part of any deal.
"We want peace, we want it quickly, but we want a proper plan ... so the mistakes of the past do not repeat," Ghani said in a televised address on Monday, referring to a bloody history of failed governments, military coups and civil war.
Ghani mentioned the deaths of previous rulers, including former President Najibullah, who was hanged from a Kabul lamppost when Taliban guerrillas swept into the capital in 1996.
Former U.S. ambassador Ryan Crocker wrote in the Washington Post that by negotiating with a Taliban that refused to talk to the Afghan leadership "we have ourselves de-legitimized the government we claim to support".
The next round of talks will be held in Qatar on Feb. 25 when Mullah Abdul Ghani Baradar, a former mujahideen fighter against the Soviet occupation of the 1980s, will head the Taliban side following his release last year from eight years in a Pakistani jail.
U.S. officials told Reuters they hope he will have the authority to negotiate on the ceasefire and the need for discussions with the Afghan government. The Taliban have so far refused to talk to the government which they dismiss as a puppet of the United States.
Baradar, a co-founder of the movement and a former military commander in western Afghanistan, will enter new talks from a position of relative strength as its new political chief, Taliban officials said.
For years, the Taliban have fought to expel foreign forces and drive the government from power, so they can restore their version of hardline Islamic law across Afghanistan.
After intensifying attacks over the last two years, the Taliban are more powerful than any at other time since they were toppled by Western forces.
And senior Taliban officials say they know the United States and other foreign forces are tired and want out. While they, meanwhile, can sense victory and a future role in government.
"If the Afghan government and the Taliban have an agreement, it will involve altering government arrangements in some respect, creating a more inclusive government and consolidating the Afghan security forces and the Taliban in some new security architecture," said James Dobbins, a former diplomat who is now senior fellow at the RAND Corporation think-tank.
Dobbins, who was the Obama administration's special representative for Afghanistan and Pakistan in 2013, said it would take a long time to reach a deal that would be sustainable.
But however much time the talks took, the senior U.S. official privy to the talks, who did not want to be identified, insisted: "We will not leave Afghanistan without a deal. We want to leave a good legacy."
Doubts have increased in recent weeks whether U.S. President Donald Trump would stomach a protracted presence in Afghanistan amid mixed signals from Washington.
U.S. officials told Reuters last month that Trump had issued verbal orders to plan for a withdrawal of about half of the 14,000 U.S. troops in Afghanistan. However, they said he could reverse course.
On Wednesday, Trump tweeted that talks "are proceeding well". He did not address any possible pact with the Taliban or troop withdrawals.
The U.S. troops in Afghanistan are part of a NATO-led mission and a U.S. counterterrorism mission largely directed at groups such as Islamic State and al Qaeda.
Some 8,000 troops from 38 other countries are participating in the operation, known as Resolute Support.
Diplomats and military attaches from many of those countries describe an intense desire to leave. Italy is considering sending home its 900 troops within a year.
The period after any deal and withdrawal is also fraught with risks. Kabul-based Western envoys say little hard thought has been given to how aid plans and other support would have to be intensified and tailored to fit a new era of peace, and possible power sharing.
Some also warn of a spike in violence as fighters on both sides return to villages and start new lives.
Afghans and regional diplomats also fear a U.S. bid to cut a hasty deal with the Taliban could allow militia groups to exploit ethnic rivalries to usurp power.
Then there is the worry that the country's nascent democracy and women's rights could crumble in the absence of foreign forces.
Ghani made clear this week they are worries he shares, even if question marks remain over his ability to shape events ahead.
"I, as an elected leader in charge of 35 million Afghans, ... know what are the probable dangers and threats after the peace deal."
(Additional reporting James Mackenzie in Islamabad; Editing by Nick Macfie)