Nestled in a labyrinth of streets in the heart of Morocco's ancient city of Fez, stands the world's oldest working library.
Its sculpted dark wooden door stands almost hidden on the edge of a square where artisans hammer away at copper in a deafening din, delighting passing tourists.
But for the few lucky enough to be allowed behind the door, a staircase tiled with green and blue hints at the written wonders beyond.
As early writings from the Arabic-speaking world have come under increasing threat from extremists, the Qarawiyyin library is home to priceless treatises in Islamic studies, astronomy and medicine.
Last year the Islamic State group burned thousands of rare manuscripts at the Mosul library in Iraq, and in 2013 Islamists torched countless early writings from the Islamic world and Greece in Mali's Timbuktu.
The Qarawiyyin library has just emerged from years of restoration, although no date has yet been fixed for a public opening.
"All that's left to be done are a few finishing touches and the electricity," says Boubker Jouane, the library's deputy director.
"A house of science and wisdom", according to its founder Fatima Al-Fihri, the Qarawiyyin library was one of the Arab world's largest centres of learning.
Fihri, the daughter of a wealthy merchant from Al-Qayrawan in Tunisia, established the library, the university that originally housed it and a mosque in 859.
Today the university has moved to a new location, but the mosque -- which shares an emerald-green tile roof with the library -- still stands.
The library as it appears today was built in the 14th century under sultan Abu Inan, and completely restructured under king Mohammed V, the grandfather of Morocco's current monarch.
Over the centuries, sultans, noblemen, princesses and wise men have contributed works to its shelves.
Under an imposing ceiling of wooden arabesques and a huge copper chandelier, the main reading room sits next an area that contains some 20,000 books.
A short walk -- through a corridor of mosaics, past panels of sculpted cedar wood under finely chiselled ceilings -- leads to the library's centrepiece.
The manuscript room is hidden behind two heavy metal doors and protected by an alarm system and surveillance cameras.
Its wooden window shutters are closed to prevent sunlight from entering.
The precious manuscripts are each bundled in a grey-coloured cardboard file and displayed on standard metal shelves.
Works can be consulted sitting at one of two chairs next to a simple table -- on which sits a green felt cushion embroidered with gold thread.
Around 3,800 titles are kept here, some of them priceless
One example is a treatise on medicine by philosopher and physician Ibn Tufayl from the 12th century.
"From baldness to corn on the foot, all ailments of the body are listed -- in verse to make them easier to learn," Jouane says.
The word "diabetes", which is of Greek origin, already features written in Arabic script.
Another gem is a handwritten copy of historian and philosopher Ibn Khaldun's "Book of Lessons". The treatise in history has been signed by the 14th-century thinker himself.
"Praise be to God, what is written belongs to me," a line he wrote reads in breathtakingly elegant handwriting.
Another 12th-century manuscript -- a treatise in astronomy by philosopher Al-Farabi -- shows the course of the planet Jupiter, complete with drawings of astonishing precision.
And then there is a treatise on the Malikite doctrine in Islam written by the grandfather of the Arab philosopher Averroes.
Its 200 pages of gazelle leather are inscribed with tiny immaculate calligraphy dotted with embellishments in gold ink.
Perhaps surprisingly, one of the "works most in demand" according to Jouane is Christian: a 12th century copy of the Gospel of Mark in Arabic.
It was translated "in all likelihood by a Christian man of letters from Andalusia who had come to Qarawiyyin to learn Arabic", says Jouane, expressing pride at the "incredible degree of tolerance at the time".
The library counted 30,000 manuscripts when it was founded under Abu Inan. But many were destroyed, stolen or plundered over the years, says Jouane.
"There's only very little left of what once was, but today we carefully watch over these priceless treasures."