I usualy think in a simpler way. When I borrow a chord then everything around that chord behaves as it was in that particular mode keeping in mind the melody or the progression intention (what I want to express and what sounds like its going to ear wise) so when a IIb chord shows up the imediate response is phrygian or phrygian major 1b2345b6b7 or the tritone sub for the V7 chord which is very momentary (but can as well act as a real V5 to the bV of the initial key #C7-#F7-B) so your D5 Db5 C5 B5 can as well be D-Amaj7-C/#F7-Bmin.

   Geting back to modes, a scale can not contain both 2 and b2 so you have to choose the right interpretation for a chromatic movement. Even in blues the chromatisism is allowed by the ear because the harmonic framework is robust and the blue notes dont imply new chords but the color of them. So you have to think in a harmonic way and express whatever it feels like. If your progression must be in  C than the B chord can't be - or + in any mode so it has to be a modified V which sounds like C Lydian to me (with that f#) and the appearance of the b2 and being major gives the Phrygian major. Lydian = V as classical tonic / Phrygian + = IV as classical tonic ( harmonic minor derivative ) but you can stay modal and ignore the real tonic ..... if you want C minor as the key than C dorian #4 = V as classical tonic (harmonic minor again) and  phrygian = iv as tonic. So to recap you travel through 2 keys and 2 modes which you can combine ex: phrygian + #4/Lydian b2 or phrygian #4   use this to improvise through it. The only exception is not to play b2 when the D chord is playing.

It just needs practice and concentration. ...