I've been reviewing this question as I have a similar situation.
I'm a US citizen and for nearly a year I held a type D long-stay visa for the Czech Republic (CR). This visa expired nearly two months ago (~60 days).
I had previously contacted the Czech Embassy in Washington DC (twice to confirm) as well as a reputable visa-aid service in Prague, both of whom assured me that I could legally remain in the Czech Republic for up to 90 days as a tourist after my long-stay visa expired. This was, of course, due to my 90-day visa exempt permission as a US citizen. On this basis, I've remained in the CR until now and I've every reason to believe I'm doing so legally.
Additionally, having visited this site, I was made aware of Regulation (EU) 2016/399 regarding the Schengen visa free (or short stay) 90/180 law. From Article 6:
"2. [...] Periods of stay authorised under a residence permit or a long-stay visa shall not be taken into account in the calculation of the duration of stay on the territory of the Member States."
However I've also spoken consular staff from both the German and Hungarian embassies (both in DC) who told me that time spent in the Schengen zone while my long-stay visa was active, even in the country that granted it, would count against my 90 day visa free permission.
When I asked for clarification, the German staff member told me this was generally a "grey area" but that border agents would apply the law as he described. The consular staff at the Hungarian embassy instead directed me to EU Regulation No. 265/2010, citing the following of the Schengen borders code:
"Aliens who hold valid residence permits issued by one of the Member States may, on the basis of that permit and a valid travel document, move freely for up to three months in any six-month period within the territories of the other Member States, provided that they fulfil the entry conditions referred to in Article 5(1)(a), (c) and (e) [...]"
Reading this law, it doesn't appear to specifically say anything regarding time spent on a long-stay visa counting against my visa-free travel permission, so I'm not sure what the intention was. The officer did make the word "valid" bold in the e-mail, but this still says nothing of my visa free 90-days. Regardless, the 2016 regulation linked above specifically addresses this.
So it would seem that the embassies of Germany and Hungary are mistaken, or at least believe their border agents are free to interpret/disregard the law as they choose. This is very alarming though as their capacity to be misinformed may extend to the immigration officers at departure points. My last stamped entry into the Schengen zone was recorded in Germany last August after a trip to the UK, but naturally I returned to the Czech Republic shortly after as that's where I was living.
It would be nice to think that, if scrutinized, I can refer to the 2016 regulation to show I'm within the remit of the law. However even if I am prepared with this information, I am now concerned that a misguided officer could still penalize me and require that I fight it in court. I'd greatly prefer not to go through the pain of missing a flight followed by a legal case to have my wrongfully incurred penalties overturned. It would also be extremely detrimental to my career if I'm unable to readily return to the EU/Schengen Zone in the future.
Likewise, it will be difficult to find an affordable flight out of the CR that does not transit through another European nation. I'd rather not have to bring a lawyer with me when I leave (if this would even help). I've only ~30 visa-free days remaining so I'll need to depart soon.
I am wondering first whether anyone has insight into why these Embassies would give me this seemingly mistaken information. Second, has anyone had an issue at the border such as this where they successfully made their case? What would you recommend I be prepared to do/say when I leave to protect myself against wrongful penalization?