Implement a utility that prints the last N lines of input. Requirements: handle both a regular seekable file and a non-seekable stream (stdin/pipe); support Unix LF, Windows CRLF, and classic Mac CR newlines; operate under tight memory (do not read the entire file); handle extremely long lines that exceed buffer size; preserve UTF-8 correctness when splitting by lines. Follow-ups: extend to tail -f (follow file growth), handle log rotation/truncation and symlinks, and support the '-c' option for the last N bytes. Provide data structures, algorithms, time/space complexity, and edge cases.