From threats of war to brotherly hugs, North Korean leader Kim Jong Un has emerged as a skilled diplomat with the unexpected assistance of a new player in the game: US President Donald Trump.
Kim's sudden turn to statecraft at the height of tensions is straight out of a North Korean playbook that goes back decades, analysts say, but Trump's spontaneity has allowed it to have an unprecedented impact on the field of diplomacy.
After a year of multiple missile launches that brought the US mainland within range of his rockets, and the North's largest atomic test to date, Kim declared Pyongyang's nuclear quest complete and began his overtures for negotiations.
Kim reached out to the South's dovish President Moon Jae-in in time for the Winter Olympics and later made his international debut with a surprise trip to traditional ally China to finally pay his respects to President Xi Jinping, repairing a relationship that had frayed in recent years.
He is due to hold a historic summit with Trump next week in Singapore, brokered by Moon -- the first-ever meeting between a sitting US president and a North Korean leader.
"It was premeditated," said Kim Hyun-wook, a professor at the Korea National Diplomatic Academy.
"Kim knew that if he started by fixing inter-Korean ties, it would lead to talks with the US and China would reach out."
In meetings with the South Korean and Chinese leaders, including seaside strolls and al fresco woodland tea, Kim has appeared polite and pleasant, a stark contrast to Pyongyang's previous chest-thumping.
The North Korean leader has also extended goodwill gestures to the US, releasing three American detainees and dismantling his nuclear test site, while halting missile launches for over six months.
"Kim's not just good at maximum pressure, he's also pretty good at maximum engagement," said Jung Pak, a former North Korea expert at the CIA who is now a scholar at the Brookings Institution.
He has proved "quite skilled at playing the regional players against the other", she said, and "sees Beijing as a key counterweight (and probably an insurance policy) against the United States".
- Diplomatic leverage -
It is a surprising transition for a leader who had spent six years in isolation, never having left the country nor met with foreign heads of state since assuming power in 2011.
Now, Kim's diplomacy is in full gear, exchanging envoys with Washington and holding repeated summits with his Chinese and South Korean counterparts.
His approach to Beijing is a "classic example of balanced diplomacy", said Koo Kab-woo, a professor at the University of North Korean Studies in Seoul.
Kim travelled to China for a rendezvous with Xi ahead of the landmark April inter-Korean summit in the Demilitarized Zone dividing the two Koreas.
"He's going to Washington via Beijing and Seoul," Koo said. "It's the most effective way for a small state to increase diplomatic leverage."
But it was the president of the United States who may have unknowingly provided the stage for Kim to show off his diplomatic skills.
The Singapore summit is a result of Trump's spontaneity, after he accepted Kim's invitation to talk -- relayed by Seoul officials -- without consulting his aides.
When Trump issued a letter abruptly cancelling next week's summit, Moon and Kim rapidly arranged a second meeting, posing for affectionate pictures at the border, as both Seoul and Pyongyang reaffirmed the North's commitment to dialogue.
"It would be impossible if we didn't have the combination of Moon Jae-in, Donald Trump and Kim Jong Un," Koo said. "Kim met the optimal mix."
As Kim and Trump wrestle for more leverage, analysts say Kim's carefully orchestrated diplomacy will serve as insurance against a possible resumption of US-led pressure if next week's meeting goes badly.
Beyond pledging its commitment to the denuclearisation of the Korean peninsula -- a diplomatic euphemism open to wide interpretation -- Pyongyang has made no public offers of concessions, while Washington is still insisting it gives up its weapons.
But even if Singapore is a failure, Kim is likely to soldier on with his charm offensive rather than immediately return to missile and nuclear tests, said Go Myong-hyun, an analyst at the Asan Institute of Policy Studies.
"And if that's the case, South Korea and China will be able to continue helping North Korea diplomatically."