"""Minimal .env loader — no python-dotenv dependency."""

import os
from pathlib import Path


def load_dotenv() -> None:
    """Load KEY=VALUE pairs from .env alongside the caller's file."""
    dotenv_path = Path(__file__).resolve().parent.parent / ".env"
    try:
        text = dotenv_path.read_text()
    except FileNotFoundError:
        return
    for raw_line in text.splitlines():
        line = raw_line.strip()
        if not line or line.startswith("#") or "=" not in line:
            continue
        key, _, value = line.partition("=")
        key = key.strip()
        value = value.strip().strip('"').strip("'")
        if key and key not in os.environ:
            os.environ[key] = value
