Text this: A variational principle for complex boundary value problems