Driverless transport, underground shops, heated bike paths, armed street patrols – this is not the setting for a dystopian novel but it could soon be the city where you live.
As the world sees the biggest wave of urban growth in history – with almost 70% of its population expected to be living in urban areas by 2050, up from 56% today – the task of making cities greener and safer is becoming more urgent.
That cities are attracting more people is nothing new, noted urban specialist Philipp Rode, who runs London-based research centre LSE Cities.
"People move to cities to live and work because they're a solution: they significantly reduce the amount of movement and space required to do anything," he told the Thomson Reuters Foundation.
"But the absolute increase in population, the millions coming into cities - that's unprecedented," he added.
The shift is creating significant challenges for many cities already at risk from worsening climate change and rising inequality, with the race on to house swelling populations.
To cope with these modern-day pressures cities around the world are trying to become "smarter" - from moving storage and retail facilities underground to using data and technology to improve security, healthcare and mobility.
Many cities, particularly in poorer nations, are also facing large and expanding slum populations who lack basic services, fuelling inequality, and, in some cases, violence.
Mandy Pienaar, a 43-year-old media executive from Johannesburg, knows this only too well.
One winter evening, as she and her boyfriend drove home from the movies in the South African city, two armed assailants hijacked their car, stripped them of their clothing and stole their bank cards before the couple managed to escape.
"It was quite shocking because there were a lot of people walking past who kind of looked at me as if this was an everyday occurrence, to see a stripped woman sitting in a slum area in the cold," Pienaar recalled.
Their ordeal illustrates the "false sense of security" that comes with living as they do in a gated community, she said.
"We have bars on every window, huge dogs, electric fencing ... to us that's normal. We've become desensitised."
Community-led projects aim to tackle such violence such as "vuvuzela patrols" when groups of men armed with plastic trumpets escort women on their daily commutes in Johannesburg.
But security is not the only worry on urban planners' minds.
From the small U.S. city of Duluth to the metropolis of Hong Kong, cities are thrashing out ways to reinvent themselves and revamp how their residents live, move and consume.
"Mobility, water, waste: the world's greatest challenges are solved in cities," said Tiina Kaho, head of the Helsinki Metropolitan Smart & Clean Foundation, a coalition of businesses, researchers and state officials.
Yet as the world transforms rapidly, "cities will have to innovate like never before", she said.
From Singapore to sub-Saharan Africa, cities are running out of space to house swelling populations.
"It's a scarce resource," said Rode. "Using that space in the most efficient way possible is crucial."
Historically cities have tended to grow outwards rather than upwards, according to a report published by the World Resources Institute and Yale University in January.
But, if uncontrolled, such expansion can make it challenging to deliver basic services, with trips to school or the doctor becoming longer, for example. At the same time, it eats into farmland and can threaten green areas and biodiversity.
To be sustainable, cities will need to temper their sprawl with efforts to increase density, researchers said.
In Britain, for example, the government announced plans to build hundreds of thousands of new rural homes along its 'Green Belt' - protected areas in the English countryside.
For other cities, increasing density will mean putting more facilities below ground - not just subway networks and utilities but commercial, retail and storage facilities too.
In Hong Kong, known for its towering skyscrapers and wooded hills, there is a particular urgency to maximise use of underground space, with home and land prices among the world's highest.
The government has vowed to free more space for housing through measures like building artificial islands.
It is also looking to use underground spaces for waste treatment, data centres, water reservoirs, power stations, crematoriums and sports facilities.
"For the city, it results in more efficient use of space ... and avoids the conflicts of traffic and weather disruptions above ground," said Mark Wallace, director of infrastructure at Arup, a consultancy that studied underground space in Hong Kong.
Other cities have also gone underground, with Finland's capital Helsinki moving sport facilities and emergency shelters below the surface. Canada's Montreal, meanwhile, has a wide pedestrian network of shops and hotels beneath its streets.
In December billionaire entrepreneur Elon Musk unveiled a 1.14-mile (1.8 km) tunnel in the Los Angeles area that was dug with new fast, low-cost technology, as a first step to developing a high-speed subterranean network for vehicles.
While excavating and building underground is more expensive, there are savings in maintenance and land costs, Wallace said.
But underground living is no replacement for better land-use planning, researchers warned, while residents worry construction and access to buried facilities will eat into green space above.
Euan Mills, urban design and planning lead at Future Cities Catapult, a UK-funded innovation centre, said cities should "accommodate nature, but not at the expense of density".
For him, the answer lies in building skywards.
"Human bodies need daylight, so going underground won't work," he said.
As cities seek space to grow, they must also consider how their development affects social equality, said Rode of LSE Cities.
"In fast-expanding cities the differences between rich and poor increase," he said.
Neighbourhoods tend to display income disparities, leaving some with better access to services, and leading to what Rode called "anti-urban gestures" such as gated communities.
In South Africa, the legacy of apartheid-era city planning and rapid urban population growth, have contributed to making it the most unequal country by income, according to the World Bank.
South Africa's cities remain for the most part racially divided more than 20 years after the end of apartheid, under which millions of black people were forcibly removed from white-only urban areas to live in crowded townships and homelands, with buffer zones separating the races.
Those patterns of inequality can stoke grievances, according to urban analysts, with South Africa – which has one of the world's highest murder rates – in July deploying the army to quell a surge in violence in gang-infested parts of Cape Town.
That has led to a proliferation of private security firms, such as safety start-up Aura, which created a mobile platform allowing customers to access a network of armed emergency services.
"The police are stretched thin," said Warren Myers, founder of Aura, which has received about 25 panic alerts a day from its 70,000 users since its launch in 2017.
"We need to marry as many different technologies as possible - CCTV, facial recognition, data collection, WhatsApp groups - to better protect South Africans," he added.
But private security is hardly sufficient to tackle crime, analysts warned, as realised by cities in Latin America where drug-fueled murder rates are among the world's highest.
After decades of heavy-handed police tactics in cities in Brazil, Colombia, Mexico, Venezuela and parts of Central America, new methods of tackling crime are gaining currency, with a stronger focus on social development projects.
In Colombia's second city of Medellin, this approach has focused on urban renewal in slums: once-neglected shanty districts now boast landscaped parks, open-air gyms, schools, playgrounds and community halls where youth orchestras play.
"Sustained investment in deprived areas ... combined with increased community policing and recreational alternatives, like after-school programmes, have seemed to turn the dial in reducing homicide rates," said Robert Muggah, co-founder of the Igarape Institute, a Brazil-based think-tank.
After the death of city native and cocaine drug-lord Pablo Escobar in 1993, Medellin's murder rate plunged more than 90% from 266 per 100,000 people in 1991 to 19 per 100,000 in 2018.
Medellin resident Johan Rodriguez, 25, decided to retire from gang life after taking part in a six-month programme to keep vulnerable people away from crime.
The "Parceros" ("Mates") project, launched last year by city hall, helps teenagers go back to school, get job interviews and set up small businesses, from textiles to DJing.
"While the violence is always there, the project showed me there's something else around the corner, another way," said Rodriguez, who now works in a motorbike factory after social workers sent out his CV to employers across the city.
Yet as record numbers of people move into cities, some urban areas are facing uncertainty over the future as climate change brings worsening threats, from extreme heat to flooding.
One fifth of the world's major cities will experience unprecedented climate conditions by 2050, such as more intense dry and monsoon seasons, according to the Crowther Lab, a Swiss-based research group.
Researchers predict that as wild weather becomes more frequent, it could force millions of people to move out of harm's way, with some unable to return.
From Indonesia's sinking capital of Jakarta to the Middle East's sweltering cities, that poses a new kind of challenge for urban planners, Rode said.
"Cities have faced numerous events like wars or earthquakes when populations had to be evacuated, but the idea had always been to return and rebuild," he said.
In response to the threats, some U.S. cities - such as Minnesota's Duluth - are launching efforts to rebrand themselves as top destinations for Americans abandoning parts of the country that may one day be made inhospitable by climate change.
Angel Dobrow, 59, who works for a small firm that supports farmers, and her husband have already made the move to lakefront Duluth, leaving their longtime home in another part of Minnesota in 2017.
"As a person concerned with climate change, being near freshwater and having a little bit of land to grow food and grow herbs was critical for me," said Dobrow, sitting in her lush garden in the northern city.
Duluth, located by the world's largest freshwater lake, may not seem the most obvious choice as a haven for climate migrants.
With its frigid winters, the metropolis is often ranked as one of the coldest cities in the United States.
But Sandy Hoff, the president and owner of local real estate development firm F.I. Salter, said a changing climate could spur a property boom that would "no doubt" propel his company in ways unseen since his grandfather acquired it 90 years ago.
Dobrow said when summer heat and humidity burden other areas of Minnesota, Duluth's lakefront breezes "feel like air conditioning".
But some fear an influx of new residents could exacerbate a housing crisis in a city where few new homes have been built.
Joel Kilgour, who chairs Duluth's Affordable Housing Coalition and volunteers at housing non-profit Loaves and Fishes, said the city's homeless are forced to seek rooms at the charity as they cannot afford rising rents.
"If we as a community can't solve that, there's no way that we're going to be able to handle an influx of climate refugees in an equitable manner," Kilgour said.
Potential climate refuge cities may also struggle to build costly infrastructure, such as water treatment plants and energy utilities, without a sufficient tax base ahead of time to pay for them, researchers warned.
To try to thrive amid rapid urbanisation and worsening climate change threats, many cities around the world are trying to become "smarter".
From heated bike paths to melt snow in Toronto to high-tech sensors that detect when Barcelona's bins need emptying, governments are pooling resources from citizens and businesses to make cities more efficient, sustainable and livable.
Many of those efforts focus on improving mobility in cities, with urban planners looking at innovative ways to cut both traffic and climate-warming emissions.
Dubai - which, according to the Roads and Transport Authority (RTA), has more than one vehicle for every two people - is experimenting with driverless mobility pods that aim to combine the comfort of ride-hailing services like Uber with the efficiency and capacity of buses.
The cube-shaped vehicles, built by U.S.-based NEXT Future Transportation Inc., can carry up to 10 people each and dock together when in motion, allowing passengers to move from one unit to the other using the front and rear doors.
The vehicles – which should enter mass production at the end of 2020 – are designed to pick up single users at home, then pool people going in the same direction inside one module, as other pods are released to collect more passengers.
"It's like a relay race," said founder Tommaso Gecchelin.
Rode of LSE Cities said it was important one inefficient car system should not be replaced with another, adding autonomous vehicles should carry as many passengers as possible.
Allowing private self-driving cars could result in empty vehicles "just driving around waiting for their owners", taking up public space needlessly, he warned.
Other major smart city initiatives have run into delays or unexpected problems, sparking criticism.
Kenya's planned Konza Technopolis – a new $14.5 billion city to be built about 60km southeast of crowded Nairobi – has fallen behind schedule on its goal of accommodating 20,000 people by 2020, according to Nairobi-based entrepreneurs and analysts.
Dubbed the Silicon Savannah, Konza aims to become a modern tech hub but the first building has yet to be completed due to red tape and a lack of funding, critics noted.
Lavasa - the first city in India's $7.5 billion plan to turn 100 urban centres into Smart Cities by 2020 - has suffered from design issues, and ignored the needs of poor and marginalised groups, planners and rights groups have said.
"Urban planners, not cities, are the ones who need to get smarter," said Mills of Future Cities Catapult, calling for more investment in data collection and training of city planners.
"Google knows more about our cities than planning departments do."
Even as some cities become smarter and more efficient, calls also are mounting to slow the frantic pace of urban life.
Efforts range from the literal – with many cities pushing for lower speed limits on their roads — to the imaginative, including art installations to promote mindfulness.
On a recent "sound walk" in the English town of Reading, a dozen residents, including a retired historian and teenage students, strolled silently through parks, graveyards and bookstores.
Led by sound artist Richard Bentley, the group uploaded photos and audio recordings from their phones to Hush City, an app that maps quiet areas in cities.
With noise pollution the most common cause of environmental complaints in Europe, according to the European Commission, and more people crowding into urban areas, Bentley expects peace and quiet could become a "commodified luxury".
Historically, poorer groups lower down the social ladder have had to live in noisy parts of cities while those with more means could move away, he said.
"It's incredibly important to keep these quiet spaces and to be aware of their possible disappearance", he added.
Some places are jumping on the liveability bandwagon through Cittaslow, which means "slow city" in Italian.
The global network of more than 260 cities grades its members according to factors such as sustainable infrastructure, promotion of local economies, fairness and "good living".
South Korean member Jeonju, a city of about 650,000 people, has planted millions of trees and runs monthly car-free zones since joining in 2016, Mayor Seung-Su Kim said by email.
Pier Giorgio Oliveti, the network's secretary general, said the approach could be a "vaccine" for the ills of modernity.
But Mills of Future Cities Catapult argued that "one of the most exciting things about cities is how alive they are".
"I don't think we should be slowing them down," he added.
Now, more than ever, urban planners and government should "reflect on what cities are for", advised LSE Cities' Rode.
"Why are cities such attractive places for living and working? Because they bring people together to enjoy public life," he said.
"That real, physical experience needs to be preserved."