A Yom Tov that falls on Saturday night, one says in "Atah Vechartanu": "Vatodienu." For "Atah Chonantanu" cannot be said, as it is not a weekday; rather, the holy Shabbat is more stringent than Yom Tov, as we conclude in Havdalah, "between holy and holy." And in the prayer there is no concluding blessing for the Havdalah, therefore it is necessary to first establish that Yom Tov is also holy, but that Shabbat is holier. And for this we say, "And You have given us as an inheritance times of joy and holy festivals… and You have bequeathed to us the sanctity of Shabbat, and the honor of the festival, and the celebration of the pilgrimage." And this is like the matter of "Who distinguishes between holy and holy." And in the Gemara they called this a "precious pearl," because in it the loftiness of the levels of Israel, the Shabbat, and Yom Tov are clarified.
יום טוב שחל להיות במוצאי שבת, אומר ב"אתה בחרתנו": "ותודיענו". ד"אתה חוננתנו" אי אפשר לומר שהרי אינו חול, אלא ששבת קודש חמור יותר מיום טוב, כמו שמסיימין בהבדלה בין "קודש לקודש". ובתפילה ליכא חתימה בהבדלה, לפיכך צריכין להקדים שגם יום טוב קודש, אלא ששבת קדוש יותר. ולזה אומרים "ותנחילנו זמני ששון ומועדי קודש… ותורישנו קדושת שבת, וכבוד מועד, וחגיגת הרגל". וזהו כעניין "המבדיל בין קודש לקודש". ובגמרא קראו לזה "מרגניתא טבא", לפי שבו מבואר רוממות מעלות ישראל והשבת ויום טוב.