At EDI, stay airside—compact airport with good food and shops, ideal for a short layover.
Take the tram to Princes Street (35 minutes, GBP 7.50). Walk up the Royal Mile toward Edinburgh Castle. The Castle exterior and esplanade are free to view. Entry to the castle interior costs GBP 21 and is worth it with 3 hours, but skip it with less. Walk back down the Royal Mile to Princes Street and take the tram back. Allow 45 minutes for the return.
Take the tram to Princes Street, walk the Royal Mile, and buy a timed entry to Edinburgh Castle (GBP 21, book online to skip the queue). Spend 1.5 hours inside. Descend via the Grassmarket for lunch: Elephant House cafe on George IV Bridge does good lunches for GBP 10 to 14 and was a well-known writing location. Walk along Princes Street Gardens before heading back.
With 10 hours, add Arthur's Seat: a 251m hill with a hiking trail to the summit in 45 minutes. It starts at Holyrood Park, 15 minutes east of the Royal Mile. The view from the top covers the whole city and the Firth of Forth. Alternatively, the Scottish National Museum of Scotland on Chambers Street is free and takes 2 hours.