I'm a bit older than you OP, and I just want COMFORT when walking miles in a big city. And of course something decent for going out at night, but I've found over the years that anything goes in the daytime, and just a little effort at night is all you need!
So I swear by loose stretchy jersey like trousers that are just so comfortable to wear. Like these, so comfortable especially if it's warm, as they seem to let the air in somehow lol. Loose T shirt on top. I have a big bust but small waist so I buy a bigger size and tie a knot in the side of the T shirt and it looks very chic ha ha. But it's not stuck to me as I don't like things too fitted.
Printed Tapered Ankle Grazer Trousers | M&S Collection | M&S (marksandspencer.com)
Might sound like I've given up, but honestly they are the best thing ever. A good pair of broken in trainers for walking are essential. Backpack of choice for putting in and taking off the layers as needed is a good bet too.
I'm not a dress person so I go for tailored dark coloured trousers and nice tops for nightime. One pair of flat shoes kind of like brogue design, high on the instep anyway. Like these
Trim Detail Slip On Flat Loafers | M&S Collection | M&S (marksandspencer.com)
A light puffer jacket, a scarf, a small crossbody bag and you're done. Oh and don't forget the lippy and the debit card lol.
Have a wonderful time, Madrid is fabulous.