The rules for grappling require:
The target of your grapple must be no more than one size larger than you, and it must be within your reach. (PHB, p. 195, italics added)
Normally, this would mean that you must be within 5' of a creature to grapple it. But some creatures have a longer reach. For example, an Ancient Red Dragon could grapple a creature with its claws which is 10' away from it (an odd use of its action, but whatever).
Jeremy Crawford has already indicated that if you're grappled, you can still attack the creature grappling you even if their space is outside your reach, since you can attack the arm/tentacle/appendage that is holding onto your body. But I wondered about a similar situation: ranged attacks.
The rule on making ranged attacks while an enemy is nearby states:
When you make a ranged attack with a weapon, a spell, or some other means, you have disadvantage on the attack roll if you are within 5 feet of a hostile creature who can see you and who isn’t incapacitated. (PHB, p. 195, italics added)
So if you are grappled by a creature who is 10' or more away from you (but you're in its reach), and you make a ranged attack, do you have disadvantage?
On the one hand, you are more that 5' away from its space. On the other hand, part of its body is definitely within 5' of you, since you're grappled by it.
Is there any definitive answer to this question? I've tried to search similar questions and sage advice, but without success.