BUILD REQUEST - PL-113 Brushwork - please build this now I'm sending you this as my request: please build the one-file HTML app described below. Start now and do the whole build in your answer to this message. - This is a build job, not a document to summarize, review or discuss. Don't ask me anything first: if a detail is unclear, pick the most sensible option and keep going. - The spec is everything between the BEGIN SPEC and END SPEC lines. Follow all of it exactly. - If your tool can create files, also save the finished file as PL-113-brushwork.html. ===== BEGIN SPEC ===== PL-113 — Brushwork: Upload Any Photo and Watch It Get Painted — Hard WHAT THIS TESTS: A real stroke-based painting algorithm (coarse to fine, curved brush strokes that follow the shapes), image processing on canvas, smooth animation of thousands of strokes, and honest similarity measurement. Build a web app called "Brushwork" that lets me upload ANY photo and then repaints it from scratch on a blank canvas, one visible brush stroke at a time, like a painter working from a reference. It should be fun to watch for 20–60 seconds and end with a picture that clearly looks like my photo, painted. LAYOUT (clean light studio look) Top bar: palette icon, title "Brushwork", subtitle "Painting study", and buttons: Upload Photo, Paint, Pause/Resume, Replay, Save PNG. Toolbar under it: "Brush" label, a size ladder showing 126 · 68 · 38 · 21 · 12 · 7 · 4 · 3 (the size in use right now is highlighted, the rest grey), and a "Color" swatch with the live hex code of the stroke being painted. Left: the big painting canvas. Bottom-left label shows the canvas size in px (for example "625 × 675 px"). Bottom-right shows progress in %. Right sidebar: a "Reference" panel showing my uploaded photo, and a "PAINTING PASS" list: Block-in → Form and color → Refinement → Fine details. The current pass is highlighted and finished passes get a check mark. Below the sidebar: Style picker (Oil, Impressionist dabs, Gouache flat), Speed (Slow, Normal, Fast, Instant), Detail (Low, Medium, High), and a live readout: strokes painted, current pass, and "Match" percentage. On a phone (390x844) the reference panel and controls stack under the canvas, the canvas fills the width, and every button is at least 44 px. UPLOADING (the main feature) Upload Photo button opens a file picker that works on iPhone Safari (camera roll and take photo). Also support drag-and-drop onto the canvas and paste from clipboard on desktop. Accept JPG, PNG, WEBP and HEIC if the browser can decode it. If a file can't be read, show a clear message, never a blank or broken app. Respect the photo's rotation (EXIF orientation) so iPhone portraits are not sideways. Fit it inside a max of 900 px on the long side, keep its aspect ratio, and size the painting canvas to match. The photo never leaves the device: no uploads, no network calls, no analytics. Say "Your photo stays on this device" under the button. Before any upload, show a built-in demo reference so the app works right away: a still life of a bowl of fruit on a table by a window, drawn by your own code (shapes plus gradients plus a soft shadow). No real people, logos or outside images. HOW THE PAINTING MUST WORK (the hard part) Use a real layered painterly rendering algorithm, in the spirit of Hertzmann-style stroke painting: for each brush size from largest to smallest, blur the reference to match that brush size, compare it to the current painting, and place strokes only where the painting is still wrong by more than a threshold. Big brushes block in the whole canvas; small brushes only touch edges and details. Map the passes to sizes: Block-in = 126 and 68, Form and color = 38 and 21, Refinement = 12 and 7, Fine details = 4 and 3. Strokes are curved, tapered brush marks that follow the image: their direction runs ALONG edges (perpendicular to the color gradient), they bend as the edge bends, and they stop when the color changes too much. Each stroke takes one color sampled from the blurred reference at its start, with tiny random variation. Brush texture: soft round edges, slight bristle streaks and a little opacity variation for Oil; short round dabs for Impressionist; flat crisp-edged strokes for Gouache. All three must look clearly different. Shuffle the stroke order inside each pass so it doesn't paint in visible rows. A small round brush cursor with a crosshair moves across the canvas and traces each stroke as it is laid down, so it looks like someone is painting. Use a seed so that the same photo, style and detail make the exact same painting every time. Replay repaints it from the saved stroke list. FAILURE MODES THAT COUNT AS A FAIL Copying or drawing the photo onto the painting canvas, even faintly or as a hidden underlayer. The painting must be built only from strokes. A mosaic of rectangles, squares or a pixel grid instead of curved brush strokes. Strokes all pointing one direction no matter what the picture shows. Painting top to bottom in rows, or all strokes appearing at once with no animation (except at Instant speed). A final painting that doesn't look like the photo, freezing on large photos, or an iPhone photo shown sideways. EXTRAS A Before/After slider that wipes between the reference and the painting. Save PNG saves the painting at full canvas resolution with no UI on it. Keep it smooth: paint in batches per animation frame, and target 60 fps at Normal speed. A full High-detail painting at Fast speed finishes in under 60 seconds on a laptop. BUILD CONTRACT Deliver ONE self-contained index.html with inline CSS and JS. Plain Canvas 2D or WebGL; libraries only from a public CDN with a pinned version if you truly need one. No other outside files. It must open straight from a file in desktop Chrome and on iPhone Safari. HONEST TESTING Expose read-only window.__paint with: canvas size, seed, current pass, brush size, stroke count per pass, and a strokes array (start point, points, size, color). Add ?test=1, which paints the demo still life at Instant speed and measures, logging PASS/FAIL to the console and window.__testResults: Match score = 100 − (mean per-pixel color difference between the finished painting and the reference, compared at 128 px wide, as a percent of 255). Report the number. It must go UP after every pass, and the final Medium-detail score must be at least 90%. Stroke count drops in area per pass: each smaller brush size covers less total area than the one before. Stroke direction check: on at least 70% of strokes longer than 3 points, the stroke direction is within 30° of the edge direction at its start. No-copy check: repaint by replaying only the strokes array onto a fresh canvas; the pixels must match the live painting (difference under 1%). Same seed twice gives identical stroke lists. Zero console errors. Then test uploading at least two real photos of different shapes (one tall, one wide) and report their Match scores. WORK LOOP AND OUTPUT Build, run, test, fix, and retest yourself. Take screenshots at 1280x720 and 390x844 at the end of each pass and look at them: the passes must look like a painting getting more detailed, not noise. Mark anything you could not run as UNMEASURED and never invent results. If you are chat-only: first list each checklist item with how your code meets it, then give one corrected complete file. Output ONE complete HTML code block, then the PASS/FAIL/UNMEASURED checklist with the measured numbers. No snippets. ===== END SPEC ===== Now build it. Reply with ONE complete HTML file in ONE code block.