## 1. Issue Description
- **Report**: User reported "Missing or insufficient permissions" error on PC when accessing a Daily Note AND when deleting it.
- **Analysis**: 
    1. **Read Error**: The `onSnapshot` listener in `DocumentClient.tsx` was attaching immediately upon component mount, racing with auth.
    2. **Write/Delete Error**: Soft Delete (`update` isDeleted=true) failed because `firestore.rules` checked `resource.data.authorId`. For "phantom" or freshly created docs, `resource.data` might be unreliable or strictly enforced rules blocked access.

## 2. Fix Implementation
### A. Client-Side Fix (Read Error)
- **Component**: `nextapp/src/app/docs/[id]/DocumentClient.tsx`
- **Change**: Updated `useEffect` hooks to await `!loading` (Auth Ready).

### B. Server-Side Fix (Delete Error)
- **File**: `firestore.rules`
- **Change**: Explicitly allowed `update` and `delete` if the document ID matches the pattern `daily-*-UID` (where UID matches the requester). This bypasses reliance on `resource.data`.
  ```javascript
  allow update, delete: if isAuthenticated() && (
      isAuthor() || 
      docId.matches('daily-.*-' + request.auth.uid)
  );
  ```

## 3. Verification
- [x] `npm run build` passes.
- [x] `firebase deploy --only firestore:rules` successful.
- [ ] User confirms permission errors are resolved (Read & Delete & Purge).

### C. Server-Side Fix (Purge API Error)
- **File**: `nextapp/src/app/api/admin/purge/route.ts`
- **Change**: Added fallback check for `docId.includes(userUid)` for Daily Notes.
  ```typescript
  const isDailyOwner = docId.startsWith('daily-') && docId.includes(userUid);
  if (!isAdmin && !isAuthor && !isDailyOwner) { ... }
  ```
