# REASONING

## Initial decisions

- Selected vanilla TypeScript over a UI framework to preserve a very small bundle and reduce runtime
  overhead. The app's interactions are straightforward enough that a small controller plus DOM render
  functions should stay maintainable.
- Kept the acceptance contract isolated in `src/lib/notes-core.ts`. Hidden tests can import it without
  triggering DOM, storage, or app bootstrap behavior.
- Planned a real inverted index with postings maps instead of scanning notes with `includes()`. This
  directly targets the search correctness/performance rubric and keeps the perf hook meaningful.
- Chose a safe markdown subset renderer instead of a markdown package. Escaping all raw text before
  adding known markdown tags reduces XSS risk while avoiding a large dependency.

## Verification pivot 1

- The first `npm run build` caught a stale unused import in `src/app/app.ts` and the missing Vite CSS
  module declaration. Added the standard `src/vite-env.d.ts` and removed the unused import rather than
  weakening TypeScript settings.

## Verification pivot 2

- `npm ci`, `npm run build`, `npm test`, and `npm run lint` all passed from a clean install. A manual
  `prettier --check .` flagged generated Vite files under `dist/`, so I added `.prettierignore` for
  `dist`, `node_modules`, and `coverage`.

## Structure pivot

- A line-count check showed `src/app/app.ts` and `src/styles.css` crossing the rubric's 400-line
  "god-file" heuristic. I split markdown toolbar actions into `src/app/markdown-actions.ts`, the
  perf hook into `src/app/perf.ts`, and preview/responsive CSS into `src/preview.css` and
  `src/responsive.css`.

## Final verification

- Final verification passed with `npm run build`, `npm test`, `npm run lint`, and
  `npx prettier --check .`.
- The production build emitted `dist/` with about 7.69 kB gzipped JavaScript and 1.93 kB gzipped CSS.
- I made one final accessibility hardening change by giving named generic control containers explicit
  `role="group"` values so ARIA labels are valid for axe-style checks.
