
/* v5: v4 phone treatment retained for the mushaf popup only; knight reader uses approved v3 rules. */
@media (max-width:768px), (pointer:coarse) and (max-width:1100px){
 #mushaf-popup.mushaf-fit-dialog,#mushaf-popup.mushaf-fit-dialog:has(#mushaf-reader){box-sizing:border-box;width:100vw!important;max-width:100vw!important;height:100vh;height:100dvh;max-height:100dvh;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;overflow-x:hidden!important;overflow-y:auto!important;overscroll-behavior:contain}
 #mushaf-popup #mushaf-popup-body{height:auto!important;min-height:0!important}
 #mushaf-popup #mushaf-reader{height:auto!important;min-height:0;grid-template-rows:auto auto auto auto!important;padding:0!important;gap:0!important}
 #mushaf-popup #mushaf-reader>.mushaf-image,#mushaf-popup:not(:has(#mushaf-reader)) .mushaf-image{display:block;width:100%!important;max-width:100%!important;height:auto!important;max-height:none!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;object-fit:contain!important;object-position:top center!important;touch-action:pan-y pinch-zoom!important}
 #mushaf-popup:not(:has(#mushaf-reader)):has(.mushaf-image){display:block!important;overflow-y:auto!important}
 #mushaf-popup:not(:has(#mushaf-reader)) #mushaf-popup-body{display:block!important;height:auto!important}
 #mushaf-reader>.mushaf-reader-actions{width:100%!important;max-width:100%!important;padding:0!important;gap:0!important}
 .mushaf-reader-footer{padding:3px 0!important;margin:0!important}
 .reader-materials{max-height:none;overflow:visible}
}

/* Keep closed card dialogs hidden after applying mobile display rules. */
#mushaf-popup:not([open]):not(:has(#mushaf-reader)){display:none!important}
