Problem: Segments crossing midnight were split into different nights - 22:30-23:15 (21.03) → assigned to 21.03 - 00:30-02:45 (22.03) → assigned to 22.03 But both belong to the same night (21/22.03)! Solution: Gap-based grouping - Sort segments chronologically - Group segments with gap < 2 hours - Night date = wake_time.date() (last segment's end date) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>