The document-level capture listener was closing the popover on ANY click — including clicks inside the context textarea, which made it impossible to focus the input. Replaced with an inline handler that bails when the click target is inside the menu.