How Can I Sense a Nearby Dark Object and Ignore More Highly Reflective Objects Further Away?

A superior technique is called 'background suppression'. You set up 2 detectors connected in inverse parallel and arrange them such that optical parallax keeps one of them from 'seeing' the emitter image until a certain range. Beyond that 'cutoff' range, the 'background' detector suppresses the signal from the 'foreground' detector by cancellation. For backgnd suppression, separate the LED several inches from the pair of photodiodes. Aim one of the photodiodes somewhat inclined toward the LED. Aim the other directly perpendicular to the circuit board plane. The inclined detector will pick up the spot through some range of overlap btwn its field of view and the beam of the LED. The perpendicular detector will have a region of overlap beginning at a greater distance. Connect this latter detector with a negative polarity with respect to your demodulation scheme. Its output will suppress response to the background quite effectively. You can adjust the angles to achieve various cutoff ranges. This works best when you use auxiliary lenses, which are actually quite easy to apply. If you have access to a technical library, you might have a look at Juds, S. 'Photoelectric Sensors and Controls'. I am involved in revising this 1988 book now, but it is still quite useful.