I have examined this question because I have a similar situation.
I am a US citizen and I hold a Type D long stay visa for the Czech Republic (CR) for almost a year. This visa expired almost two months ago (~ 60 days).
I had already contacted the Czech Embassy in Washington DC (twice to confirm) as well as a reputable visa support service in Prague, which both assured me that I could legally stay in the Czech Republic until 90 days as a tourist my long stay visa has expired. This was of course due to my 90-day visa waiver as a US citizen. On this basis, I have stayed in the CR until now and I have every reason to believe that I am doing it legally.
In addition, after visiting this site, I was informed of Regulation (EU) 2016/399 relating to Law 90/180 concerning the Schengen visa exemption (or short stay). From Article 6:
"2. […] The periods of residence authorized by a residence permit or a long-stay visa are not taken into account when calculating the length of stay in the territory of the Member States. "
However, I also spoke to members of the consular staff of the embassies of Germany and Hungary (both in Washington) who told me they had spent time in the Schengen area while my visa long stay was in force, even in the country that had issued it. would have count against my permission without a 90-day visa.
When I asked for clarification, the German staff member said that it was usually a "gray area", but that border services officers would enforce the law as he described it. The consular staff of the Hungarian Embassy informed me of EU Regulation No 265/2010, quoting the following Schengen Borders Code:
"Foreigners holding a valid residence permit issued by one of the Member States may, on the basis of this title and a valid travel document, circulate freely for a period not exceeding three months per semester in the territory of the other Member States, provided that they fulfill the conditions for entry referred to in Article 5 (1) (a), (c) summer) […]"
In reading this law, nothing seems to indicate in particular that the time spent in a long-stay visa counts in my authorization to travel without a visa. I am not sure of the intention. The agent has put the word "valid" in bold in the e-mail, but it still does not say that I do not have a visa for 90 days. Whatever the case may be, the 2016 regulation linked above specifically addresses this.
It would seem, therefore, that the embassies of Germany and Hungary are mistaken or at least believe that their frontier agents are free to interpret / disregard the law of their choice. This is very alarming because their ability to be misinformed can extend to immigration officers at the starting points. My last entry into the Schengen area was recorded in Germany last August after a trip to the UK, but of course, I returned to the Czech Republic shortly thereafter, it is there that I lived.
It would be good to think that, if I am closely examined, I can refer to the 2016 regulations to show that I am in the remit of the law. However, even though I am prepared for this information, I am now afraid that a lost officer may still penalize me and demand that I fight in court. I would very much prefer not to have the pain of missing a flight, followed by a lawsuit, so that my wrongly sanctioned penalties would be canceled. It would also be extremely detrimental to my career if I could not easily return to the EU / Schengen area in the future.
Similarly, it will be difficult to find an affordable flight out of the Czech Republic that does not transit through another European country. I would rather not have to bring a lawyer when I leave (if it can even help). I only have about 30 days left without a visa, so I have to leave soon.
I wonder first if anyone understood why these embassies gave me this apparently wrong information. Secondly, did anyone have a problem at the border such as this one where he was able to argue his point of view? What would you recommend that I be ready to say / say when I leave to protect myself from an unwarranted penalty?