# Recreate this site as a single HTML file: Quire — Invoice Financing for Agencies

## What it is

A calm, warm-paper landing page for *Quire*, a fictional invoice-financing product for small creative agencies: send an invoice, get 90% of it the next business day, the rest (minus one per-day fee) when the client pays. Everything is labelled as illustrative. The ground is cream paper with a faint dot grid, the ink is deep green and the only accent is one coral. The headline is "Stop waiting ~~sixty days~~ to get *paid.*", with a coral strike drawn through "sixty days". **Signature:** an interactive **12-week cash-flow simulator** in the hero. You drag four invoice chips onto a timeline and watch two balance lines redraw live while you drag: a dashed coral "Without" line that dips into a pink overdraft zone below €0, and a solid green "With Quire" line. Four odometer-rolling stats sit above the chart: lowest balance without, lowest balance with, weeks overdrawn (4 → 0) and fees. Every bar on the timeline spans the weeks you wait for the client to pay. The hero is always alive. A **halftone field** of paper dots sends slow "payment pulse" rings out from behind the headline, swells into a green lens under the cursor's trail, and throws a coral ripple wherever you click or drop an invoice. Inside the chart, **cash particles** stream along the With-Quire line into the end balance; they part around the cursor and burst up from the week an invoice is advanced. Below the hero: a **fee calculator** (sliders and segmented controls, a stacked split bar and the printed formula); a **scroll-scrubbed "How it works"** in which a **live three.js paper invoice** (canvas-textured, crease normals, soft shadow) is checked, stamped, **tri-folds into a 3D envelope** with a coral seal, and travels along a dashed path into a bank card whose balance rolls up; a dark-green security block; pricing with a Monthly/Yearly switch; a FAQ accordion; a validating "Check your limit" form; and a footer with a giant wordmark.

## Page shell & libraries

- One `index.html` with inline CSS and JS. No frameworks. Remote dependencies: **three.js 0.160.0** via an import map (`three` → `https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js`, `three/addons/` → `…/three@0.160.0/examples/jsm/`, used for `RoomEnvironment`), and Google Fonts:
  `https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300..600&family=Instrument+Sans:wght@400..600&family=JetBrains+Mono:wght@400;500&display=swap` (with preconnects).
- Structure: skip link → sticky `header.top` (logo, `nav#nav` with 6 anchor links, coral CTA, `.menu-btn`) → `main`, containing `section.hero` (with `.sim#simulator`), `#fees`, `#how` (with `#howTrack`), `#security`, `#pricing`, `#faq` and `#apply` → `footer`.
- A classic IIFE script runs everything except the 3D fold, which is a separate `<script type="module">` that reads `window.__howP` (scroll progress, already snapped under reduced motion) written by the IIFE. The page is fully usable if the module never loads. The simulator, chart, lane, tray, stats and data table are all rendered from one `INV` array and one `simulate()` function, so they always agree.

## Tokens

- **Colour:** paper `#f3ede2` (body, plus a `radial-gradient` dot grid of ink at 5%, 22px), paper-2 `#e9e1d2`, paper-3 `#ddd3c1`, card `#fbf8f2`, ink `#14261f`, ink-2 `#2b3d35`, muted `#55665d` (≥5:1 on paper), line `#d6ccba`, line-2 `#c4b8a3`, green `#1d4d3c`, green-2 `#2f6b53`, green-3 `#4f8a70`, mint `#cfe3d6`, mint-2 `#e3eee6`, **coral `#ff6a4d`** (fills only: CTA, strike, payroll dots, fee segment), coral-2 `#ffd5c9`, coral-ink `#b23d1d` (coral used as text: negative figures, "paid wk" labels).
- **Type:** Fraunces (opsz 144) for display: H1 `clamp(44px,7vw,104px)` weight 350, line-height .95, tracking −.04em, with an italic green-2 "paid." (54px at ≤560); H2 `clamp(34px,4.6vw,60px)`/1.02; H3 `clamp(22px,2vw,28px)`; figures 300–400 with −.03/−.04em tracking. Instrument Sans for UI (17px/1.55 body, 16 at ≤560). JetBrains Mono 500 for eyebrows (13px uppercase, .06em, preceded by an 8px coral square), labels, axis ticks and the formula.
- **Radii:** 10 / 16 / 24 / 32px, pills 999px. **Gutter:** `clamp(16px,4vw,56px)`. **Max width:** 1280px. **Section spacing:** `clamp(72px,10vw,140px)`; each section head opens with a 1px dashed `line-2` rule.
- **Easing:** `--ease: cubic-bezier(.2,.8,.2,1)`, `--ease-io: cubic-bezier(.65,0,.35,1)`.

## Layout & structure

1. **Header** (72px, sticky, paper at 86% + 10px backdrop blur; gains a hairline once `scrollY > 8`). Logo: a 30px green rounded envelope with a coral flap stroke (the flap flips with `scaleY(-1)` on hover), plus "Quire" in Fraunces 24px. Nav links: Simulator, Fees, How it works, Security, Pricing, FAQ. At the right, a small coral "Check your limit →" (42px).
2. **Hero head:** a grid of 1.25fr / 1fr, aligned to the bottom. Left: eyebrow + H1. Right: `figure.photo.grain` (16:7, radius 24, `assets/desk.webp` `object-fit: cover`, which settles from scale 1.06 → 1 over 1.6s; a dark mono caption pill "INV-0412 · €16,560 advanced next day" with a pinging coral dot), the 20px lead, a CTA row (coral "Check your limit →" + ghost "Work out a fee", 52px pills) and the fine-print line "Quire is a fictional product…".
3. **Simulator card** `.sim` (card colour, 1px line, radius 32, padding `clamp(16px,2.4vw,32px)`, soft long shadow):
   - Top row: H2 "Your next 12 weeks" + a mono tag "Example agency · illustrative" | two legend pill checkboxes ("With Quire": solid green swatch; "Without": dashed coral-ink swatch; unchecked = 50% opacity + strike).
   - `.sim-body`: at ≥1100 a grid of `232px 1fr` (gap 20) with `.stats` as a column of 4 equal-height tiles (values 34px) beside the chart, so the chart sits above the fold at 1440. Below 1100, `.stats` is a 4-up row (2×2 at ≤960) above the chart.
   - `.stats`: tiles in a 1px-gap grid. Each tile has a 13px key, a Fraunces `clamp(26px,3vw,40px)` odometer value (coral-ink when negative) and a 12.5px sub ("end of week 8").
   - `.chart` (270px, 210px at ≤560): a white gradient box holding an SVG `viewBox 0 0 1200 300 preserveAspectRatio=none`. Layers, in order: gridlines; the overdraft area (the Without line closed to the €0 line, clipped by a rect below zero, coral at 20%); the green area under With (a gradient from 22% to 0); the €0 line (coral-ink); the Without path (2.2px, dash 7 6); the With path (3.2px). All strokes use `vector-effect: non-scaling-stroke`. HTML overlays: y labels in mono at the right edge, two 12px end dots, a "Overdraft without Quire" badge top-left (only while the minimum is below 0), a dashed vertical guide and a dark readout tooltip.
   - `.weeks`: 12 mono labels ("W1…W12", digits only at ≤560). Payroll weeks (even) get a 5px coral dot.
   - `.lane`: a 12-column grid drawn with a `repeating-linear-gradient` of column rules, holding 4 rows (40px, 36px at ≤560), one per invoice. A placed invoice is a `button.bar` with `grid-column: issueWeek / span min(lagWeeks, 13 − issueWeek)`. The bar is white with a 1.5px green border and holds a green "90%" mono badge, "Client · €18.4k" (hidden at ≤560) and a coral-ink "paid wk 10" (or "wk 14 →" with a dashed coral end cap when payment falls past week 12). A 4px coral end cap marks payment day.
   - `.tray`: 4 `button.chip[aria-pressed]` (2 columns at ≤960). Each chip holds INV number, a status tag ("Not sent" / "Week 3"), client, amount in Fraunces 22px and "net 60". Unscheduled chips are dashed paper; scheduled chips are solid white with a green border.
   - Footer: a hint line, a ghost "Schedule all four" and a "Reset" link button; then `details.tbl` "Show the numbers as a table" (Week, Invoices paid by clients, Advanced by Quire, Balance without, Balance with; negatives in coral-ink).
4. **Fees** (`.sec-head`: eyebrow column 1fr | H2 + lead 2fr). Then `.calc`, 1fr / 1.1fr panels:
   - Left form: "Invoice amount" range (€1,000–€100,000, step 100, default 18,400; the output is in Fraunces 26px); "Payment terms" segmented radios 30/45/60/90 (60 checked); "Client pays late by" range 0–45 (7); "Plan" segmented Flex / Studio / Agency.
   - Right results: two big figures in Fraunces `clamp(36px,4.4vw,60px)` ("In your account tomorrow" = 90%, "When your client pays" = 10% − fee); a 16px split bar (green advance / mint remainder / coral fee, 3px gaps, animated `flex-grow`) with a legend; dashed rows for Days financed, Daily rate, Total fee and Fee as %; a mono formula box ("€18,400 × 0.040% × 67 days = €493.12", with "→ minimum €25 applies" or "→ capped at 4%" when relevant); and the disclaimer.
5. **How it works:** the section head, then `#howTrack` (460vh) containing a sticky `.how-sticky` (top 72px, height `100vh − 72px`, grid .9fr / 1.1fr):
   - Left: `ol.steps` with a 2px track and a green `.rail` scaled by progress. There are 4 steps (mono number + duration, H3, copy): "Send the invoice you already wrote", "We check the client, not you", "Sealed, with the fee on the front", "90% lands in your bank". Inactive steps sit at 42% opacity; done steps at 70% with a filled dot.
   - Right: `.stage-box` holding `.stage`, a fixed 640×440 card, absolutely centred and scaled by `min(1, boxW/640, boxH/440)`, with a left-fading dot texture. Inside the stage:
     - a dashed trail path `M180 214 C 250 350, 400 370, 494 300`;
     - three mono check rows at (340, 56);
     - a dark `.bank` card at right 28 / top 226 ("Your business account", an odometer balance €3,780, and a hidden transaction row "QUIRE ADV INV-0412 +€16,560");
     - `.pkg` (240×330 at 60, 48, perspective 1100px) with `.doc`: three 110px panels `.p1`/`.p2`/`.p3`, each with a white `.f` face and a paper-2 `.b` back (`rotateX(180deg)`, backface hidden). `.p1` holds the header, "Marlow / Bikes" and the round "VERIFIED BY QUIRE ✓" stamp. `.p2` holds the three line items. `.p3` holds "TOTAL DUE €18,400";
     - `.env`: a green envelope 280×130 with a back, an SVG front with two side triangles and a bottom triangle, a clip-path triangle flap (origin top), and the mono label "FEE €493 · SHOWN BEFORE YOU SEND".
6. **Security** (`.trust`): a green radius-32 block with a radial-masked mint dot cluster in the top right; eyebrow, H2 "Your client pays you. We never sit in the middle.", lead; four `.tcard`s (4 columns, 2 at ≤1100, 1 at ≤560), each with a 36px line icon (mint strokes, one coral detail), a 21px H3 and copy; a "Money path" row of outlined pills joined by coral arrows.
7. **Pricing:** section head; a Monthly [switch] Yearly row with a coral-2 "2 months free" tag; 3 `.plan` cards (Flex €0, featured ink Studio €39 → €32.50 yearly with a coral "Most agencies" pill, Agency €119 → €99). Each card shows the daily rate and a live "Example fee" on €18,400 at net 60, a check list and a CTA to `#apply`.
8. **FAQ:** 1fr / 2fr. The left column is sticky (eyebrow, H2, `assets/envelope.webp` at 4:3, radius 24, hidden at ≤960). The right column holds 6 `details` with Fraunces summaries and a 34px circular +/− that fills coral when open.
9. **Apply:** a coral radius-32 block, copy | form on paper (Work email, Agency name, monthly-invoicing select, ink submit) with a `role=status` result.
10. **Footer:** ink, a 4-column link grid (2 at ≤960), a giant "Quire" (Fraunces 300, `clamp(96px,22vw,320px)`, `#1f3a2f`) and a dashed legal row stating the product is fictional.

## Behaviour & interaction

- **Hero halftone field** (`canvas.field`, prepended to `.hero`, which gets a solid paper background):
  - The canvas covers the hero only down to the simulator's top + 140px and fades out over its last 120px with a mask. DPR is capped at 1.25, and dots under the simulator card are skipped.
  - Dots sit on a 22px grid. Each dot's radius is `.9 + wave·.45 + halo²·1.7 + pulse·1.9 + trail·2.6 + ripple·2.4`, and its alpha is `.05 + wave·.045 + halo·.1 + pulse·.3 + trail·.42 + ripple·.5`.
  - The wave is `sin((x·.55 + y)·.011 − t·.0011)`. The halo falls off linearly over 640px from a centre at 42% / 52% of the H1's box.
  - Two pulse rings leave that centre every 3.2s (offset 1.6s) at 230px/s, 54px wide, and fade out by 736px.
  - Cursor trail (fine pointers only): the last 28 points, each living 900ms, form a 120px lens.
  - Ripples come from a click on the hero background (not on controls, the sim or the photo) or from an invoice drop: 560px/s, 36px wide, 1.7s.
  - Colour: ink, turning green (`47,107,83`) inside the trail or pulse, and coral (`255,106,77`) on a ripple crest.
  - Drawing is batched into Path2D buckets (3 colours × 10 alpha steps), capped at ~33fps, and runs only while the hero intersects the viewport and the tab is visible.
- **Cash particles** (`canvas.cashflow` inside `.chart`, under the y labels):
  - 70 particles ride the tweened With line at speeds of .04–.09 of the width per second, each with a ±1–5px sine wobble. They are drawn as a green 1.3–3.2px coin with a mint highlight, and fade in and out at the ends.
  - At the end point they occasionally pop a small ring.
  - The cursor parts them within 80px (up to 18px of push) and swells them up to 2.3×.
  - Coral drips fall slowly from any stretch where the Without line is below €0.
  - `cashBurst(week, n)` fires gravity sparks (22% coral) and a 38px ring from the With line at that week: 7 per preview change while dragging, 24 on drop, 18 when a chip is clicked on, 8 per arrow-key move.
  - Runs only while the chart is on screen and the tab is visible; nothing runs under reduced motion.

- **Model** (constants): `START 21000`, retainers `IN 7200`/week, overheads `OUT 3600`/week, `PAYROLL 15200` on even weeks, `ADV .9`.
  - Invoices: 0412 Marlow Bikes €18,400 net 60 (default week 1), 0415 Tern Coffee €12,600 net 45 (week 2), 0419 Northfold Labs €24,000 net 60 (week 3), 0423 Pellmell Books €7,800 net 30 (week 5). On load, 0412 sits at week 1 and 0419 at week 3.
  - The client pays in week `issue + ceil(days/7)`. Without Quire, the full amount lands that week. With Quire, 90% lands in the issue week, and 10% − fee lands on payment.
  - Fee = `min(4% of amount, max(€25, amount × rate × days))`. Rates: Flex .040%/day, Studio .030%, Agency .022%. The simulator uses Flex.
- **Chart redraw:** the domain is `[floor((lo − 10% span)/step), ceil((hi + 16% span)/step)]·step`, with step 10k / 20k / 40k by span. Values and domain tween together over 560 ms easeOutCubic in one rAF (300 ms during drag, 380 ms for key moves). The rAF only runs while a tween is active. Gridlines and labels are rebuilt every frame from the tweened domain.
- **Drag:** pointer events on chips and bars (`touch-action: none` on those only).
  - After 6px of movement, a dark rotated `.dghost` follows the cursor ("Client · €18.4k / send in week 6 · client pays week 11").
  - While over the lane (24px tolerance), the lane tints mint and the week is `round((x − grabOffset − laneLeft)/colW) + 1`. The bar previews there and **the chart and stats redraw live**.
  - Dragging a bar off the lane previews it removed ("release to take it off").
  - On drop: place, move or remove, then a 420 ms redraw. A drop elsewhere from the tray is cancelled. The click that follows a drag is swallowed.
- **Keyboard / click:** clicking a chip toggles it (on → its default week). Bars respond to ←/→ (±1 week), Home/End (weeks 1/12) and Delete/Backspace (remove), and focus is restored after re-render. "Schedule all four" and "Reset" redraw over 800 ms.
- **Readout:** hover or focus on the chart shows the week guide and a tooltip with both balances. ←/→ step through weeks, and a polite live region announces them.
- **Odometer:** each digit is a 0–9 column in a 1.1em clipped box, moved with `translateY(−d × 1.1em)` over 1s `--ease`, staggered 30–40 ms per digit. Separators never move. The structure is rebuilt only when the digit/separator shape changes. An sr-only copy carries the real text.
- **Fee calculator:** recomputes on every `input`. Range fills come from a `--p` gradient. `aria-valuetext` is set on both ranges.
- **How it works, live 3D (three.js module):**
  - Renderer: 640×440 into `.stage` (scaled with it). ACES tone mapping at exposure .92, `PCFShadowMap` with radius 5, and a RoomEnvironment PMREM.
  - Camera: fov 28 at (0, 8.1, 3.5) looking at (0, 0, .15).
  - Lights: a key DirectionalLight `#fff1dc` at 2.3 casting shadows, a mint rim light, and a hemisphere fill.
  - The ground is a `ShadowMaterial` at opacity .2, so the HTML stage shows through.
  - **Sheet:** a 2.4×3.3 `PlaneGeometry(20,66)` laid in XZ. One mesh uses a FrontSide 768×1056 canvas texture of the invoice (fibre noise, mono header, "Marlow Bikes" in Fraunces, line items, "TOTAL DUE €18,400", faint fold marks). A second mesh shares the geometry with a BackSide fibre-paper texture.
  - Every frame the vertices are re-folded around creases at z = ±.55. The bottom panel turns θ₃ (0→π) and the top panel θ₁ (0→π), with tiny y offsets (.014 / .028) so the layers stack. Vertices near a crease get a .006 lift, there is a slight bow while flat and a breathing sine while idle, then `computeVertexNormals()` runs.
  - **Stamp:** a decal plane on the middle panel that scales in.
  - **Envelope:** 2.72×1.32. It has a back plane, a pocket `ShapeGeometry` (a V opening) carrying a canvas texture with the fee label, and a hinged flap triangle with a coral seal disc whose pivot runs −π → 0.
  - **Path:** the SVG trail's four Bézier points are raycast onto the ground to make a `CubicBezierCurve3`, so the package travels exactly over the dashed line, with arc height 1.5·sin(πt), scale 1 → .42 and a small yaw and roll.
  - Keyframes are the same bands as below.
  - The CSS 3D `.pkg` is hidden (`.stage.gl-on`) only once WebGL has initialised. Any exception removes the canvas and restores the CSS version.
  - The render loop runs only while `#howTrack` is within 25% of the viewport and the tab is visible. Under reduced motion it renders on scroll only.
- **How it works (shared progress):** progress `p = −rect.top / (trackHeight − innerHeight)`, read in a rAF that runs only while the track is within 20% of the viewport. Keyframes:
  - lines scale in 0.02–0.18;
  - checks fade in from 0.26, 0.04 apart, and out 0.62–0.70;
  - the stamp lands 0.34–0.42 (scale 1.8 → 1, then rotate −14°);
  - the bottom panel folds `rotateX 0→180°` 0.48–0.57 and the top panel `0→−180°` 0.56–0.65 (eased in-out);
  - the envelope appears 0.64–0.68 while the doc fades 0.66–0.69, and the flap closes `rotateX 180→0` 0.67–0.73;
  - the package follows the trail 0.76–0.92 (`getPointAtLength`), scaling 1 → .45 with a −6° arc tilt, and fades 0.90–0.94;
  - at p ≥ 0.92 the bank odometer rolls €3,780 → €20,340, the card gets a coral 6px ring and the transaction row slides in.
  - Active step thresholds: .24 / .46 / .74.
- **Pricing switch:** `role=switch` + `aria-checked`; prices and "/ month, billed yearly" swap.
- **FAQ:** Web Animations height + opacity, 380 ms open / 320 ms close.
- **Form:** on submit, checks the email regex, the name length (> 1) and the select. Invalid fields get `data-err`, `aria-invalid` and a visible message, and the first one is focused. On success, the status shows an illustrative limit (1.5 × monthly volume, rounded to €5k) and says nothing was sent.
- **Reveals:** IntersectionObserver adds `.in` (opacity + 32px rise, 0.8–0.9s). The hero strike draws `scaleX 0 → 1` 0.9s after a 0.5s delay. Buttons: a fill slides up from the bottom on hover/focus and the arrow nudges 3px.

## Responsive

- **1440:** as described. Header nav is inline. Calculator and How it works use 2 columns.
- **≤1100:** trust cards in 2 columns.
- **≤960 (768 check):**
  - the nav collapses to a 46px menu button whose three bars turn into an X, opening a dropdown sheet with dashed rows and the CTA (Esc closes it and returns focus);
  - the hero, calculator, FAQ, section heads and Apply stack to 1 column, with the FAQ column no longer sticky and the envelope photo hidden;
  - stats and tray go 2×2;
  - How it works shows the stage on top and only the active step's text under it, with no rail;
  - plans stack (max 560px).
- **≤560 (390 check):** H1 54px with the forced break removed; CTAs full width; chart 210px; bar names hidden (badge + due week only); week labels are digits only; trust cards in 1 column; result figures stack. No horizontal scroll at 390 / 768 / 1440 (the stage is absolutely positioned so its 640px box never adds width).

## Accessibility & reduced motion

- Semantic landmarks and a skip link. Every control is a real button, input or details element. Visible focus is a 3px coral outline.
- The chart is `role=img` with a live `aria-label` summary. Keyboard readout runs through a polite live region. A full data table sits in `details`.
- Chips use `aria-pressed` and descriptive labels; bars describe their week and payment week and explain the keys. Stats announce on change, de-duplicated so dragging does not spam.
- Contrast: muted text ≥5:1 on paper. Coral is never used for small text; coral-ink `#b23d1d` is used instead.
- `prefers-reduced-motion`: all transitions are ~0; odometers jump; the chart redraws without tweening; reveals are shown at once; the FAQ opens natively; How it works snaps to 4 discrete states (p = .18 / .42 / .70 / 1) instead of scrubbing. Everything stays operable.

## Fallbacks

- No WebGL, or three.js fails to load from the CDN: the full CSS 3D fold (three `.pnl` panels with front and back faces, a CSS envelope, a flap and a label) stays in place, driven by the same progress.
- No canvas: the simulator is SVG and keeps working; the ambient layers simply don't appear.
- Fonts fall back to Georgia / system-ui / ui-monospace with the same layout.
- Images carry width/height and sit on a paper-2 placeholder colour. The FAQ photo is lazy-loaded.
- Only scroll/resize listeners (passive) and on-demand rAF run; nothing animates per frame while idle except a 2.4s CSS ping on the caption dot.

## Assets

- Both photos share one grade, made with ImageMagick: saturation 84%, slightly lifted blacks, warm R/B levels, gentle sigmoidal contrast and Gaussian film grain. A CSS `.grain::after` overlay adds an SVG `feTurbulence` noise layer plus a soft vignette (multiply, .55).
- `assets/desk.webp` (1200×896, ~130 KB): an overhead still life on cream paper of a dark green envelope, a blank invoice with a coral paper clip, a brass letter opener and a cup of black coffee, in soft window light from the left.
- `assets/envelope.webp` (1000×747, ~87 KB): a sealed dark green envelope with a round coral sticker, tilted on deckle-edged cream paper.

## Make it yours

This prompt rebuilds one exact design. If everyone ships it unchanged, the sites will look alike.
Before you paste it, change these lines so the result is yours. Each change is one edit to the
prompt; the structure and the interactions stay intact.

1. **Brand and offer.** Swap "Quire" and invoice financing for your own cash-flow product: subscription revenue advances, payroll smoothing, supplier early-pay, rent bridging. Keep the four-figure stat row, three plans and six FAQs so the grid stays balanced.
2. **The ambient layer.** Re-theme the hero halftone's pulse as your product's heartbeat (sonar rings for monitoring, ink drops for a writing tool, coins for payments), and make the chart particles your unit of value (parcels, kilowatts, minutes). Keep the cursor lens, the click ripple and the off-screen pause.
3. **The simulator's cargo.** The draggable invoice chips are the signature. Re-theme what gets dragged and what the bar means: purchase orders that span to the supplier's due date, payroll runs, ad-spend bursts that pay back weeks later, rent days. Keep 4 items, one lane row each, a bar that spans the waiting period and the live redraw while dragging. Retune `START`, `IN`, `OUT` and `PAYROLL` so the "Without" line dips below zero by default.
4. **The 3D fold sequence.** Replace the three.js invoice → envelope → bank card with your own object's journey (redraw the canvas texture; keep the crease-fold vertex function, the raycast path and the soft shadow): a purchase order stamped and boxed into a parcel, a receipt rolled into a tube, a contract signed and sealed with wax. Keep the 4 scroll keyframe bands and the odometer landing.
5. **Palette.** Replace paper `#f3ede2`, green `#1d4d3c` and coral `#ff6a4d` with your own ground, ink and single accent (for example oat + navy + saffron, or grey-white + aubergine + lime). Keep the muted text and the accent-as-text colour at ≥ 4.5:1 on the ground, and use the bright accent only for fills.
6. **Type pairing.** Swap Fraunces + Instrument Sans + JetBrains Mono for another high-contrast display serif or grotesk, with a neutral sans and a mono for figures (for example Newsreader + Geist + Geist Mono). Keep tabular figures in the odometers.
7. **Photos.** Replace `assets/desk.webp` and `assets/envelope.webp` with two still lifes of your own product's world, in the same overhead or three-quarter soft-daylight style, shot in your palette, with no readable text or logos. Export as .webp under 250 KB.
8. **Copy and numbers.** Rewrite the headline's struck-through phrase for your audience's pain ("~~net 90~~", "~~month-end panic~~") and every rate, plan price and example figure. Keep every number labelled illustrative unless it is real.

Tell your AI: *"Build exactly as specified, but with these changes: …"*, then list your edits.

---

## Reference implementation (use verbatim)

The complete working `index.html`. Every number in the spec above is in this file; if the two ever seem to differ, the code wins. Images and models referenced as `assets/...` can be downloaded from https://copytheprompt.design/demos/fintech-landing-cash-flow-simulator/assets/ or replaced with your own (see Make it yours).

````html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Quire: get paid the day you invoice</title>
<meta name="description" content="Quire (a fictional product) advances 90% of an agency invoice the next business day. Drag invoices onto a 12-week timeline and see what it does to your cash.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300..600&family=Instrument+Sans:wght@400..600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root{
  --paper:#f3ede2; --paper-2:#e9e1d2; --paper-3:#ddd3c1; --card:#fbf8f2;
  --ink:#14261f; --ink-2:#2b3d35; --muted:#55665d; --line:#d6ccba; --line-2:#c4b8a3;
  --green:#1d4d3c; --green-2:#2f6b53; --green-3:#4f8a70; --mint:#cfe3d6; --mint-2:#e3eee6;
  --coral:#ff6a4d; --coral-2:#ffd5c9; --coral-ink:#b23d1d;
  --r-s:10px; --r:16px; --r-l:24px; --r-xl:32px;
  --gut:clamp(16px,4vw,56px); --max:1280px;
  --f-display:"Fraunces",Georgia,"Times New Roman",serif;
  --f-sans:"Instrument Sans",system-ui,-apple-system,"Segoe UI",sans-serif;
  --f-mono:"JetBrains Mono",ui-monospace,"SFMono-Regular",Menlo,monospace;
  --ease:cubic-bezier(.2,.8,.2,1); --ease-io:cubic-bezier(.65,0,.35,1);
}
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth;scroll-padding-top:84px}
body{margin:0;background:var(--paper);color:var(--ink);font:400 17px/1.55 var(--f-sans);overflow-x:hidden;
  background-image:radial-gradient(rgba(20,38,31,.05) 1px,transparent 1.2px);background-size:22px 22px}
img,svg{display:block;max-width:100%}
a{color:inherit}
button,input,select{font:inherit;color:inherit}
:focus-visible{outline:3px solid var(--coral);outline-offset:3px;border-radius:6px}
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.wrap{max-width:var(--max);margin:0 auto;padding-inline:var(--gut)}
.skip{position:absolute;left:12px;top:-60px;z-index:100;background:var(--ink);color:#fff;padding:10px 16px;border-radius:10px;text-decoration:none}
.skip:focus{top:12px}
.mono{font-family:var(--f-mono);font-feature-settings:"zero" 0}
.eyebrow{display:inline-flex;align-items:center;gap:8px;font:500 13px/1 var(--f-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--green)}
.eyebrow::before{content:"";width:8px;height:8px;border-radius:2px;background:var(--coral)}
h1,h2,h3{font-family:var(--f-display);font-weight:400;letter-spacing:-.025em;margin:0;font-variation-settings:"opsz" 144}
h2{font-size:clamp(34px,4.6vw,60px);line-height:1.02}
h3{font-size:clamp(22px,2vw,28px);line-height:1.1;font-variation-settings:"opsz" 48}
p{margin:0}
.lead{font-size:clamp(17px,1.4vw,20px);color:var(--muted);max-width:56ch}
.tag-ill{display:inline-block;font:500 11px/1 var(--f-mono);letter-spacing:.05em;text-transform:uppercase;padding:6px 8px;border-radius:6px;background:var(--paper-2);color:var(--muted)}

/* buttons */
.btn{--bg:var(--ink);--fg:#fff;position:relative;display:inline-flex;align-items:center;justify-content:center;gap:10px;min-height:52px;padding:0 22px;border-radius:999px;border:1.5px solid var(--bg);background:var(--bg);color:var(--fg);font-weight:600;font-size:16px;text-decoration:none;cursor:pointer;overflow:hidden;isolation:isolate;transition:transform .35s var(--ease),color .25s}
.btn::after{content:"";position:absolute;inset:-2px;z-index:-1;background:var(--fill,var(--coral));border-radius:inherit;transform:translateY(102%);transition:transform .45s var(--ease)}
.btn .arr{transition:transform .35s var(--ease)}
.btn:hover::after,.btn:focus-visible::after{transform:none}
.btn:hover,.btn:focus-visible{color:var(--fg-h,var(--ink))}
.btn:hover .arr,.btn:focus-visible .arr{transform:translateX(3px)}
.btn:active{transform:scale(.98)}
.btn.coral{--bg:var(--coral);--fg:var(--ink);--fill:var(--ink);--fg-h:#fff}
.btn.ghost{--bg:transparent;--fg:var(--ink);border-color:var(--ink);--fill:var(--ink);--fg-h:#fff}
.btn.light{--bg:var(--paper);--fg:var(--ink);--fill:var(--coral)}
.btn.sm{min-height:42px;padding:0 16px;font-size:15px}

/* header */
.top{position:sticky;top:0;z-index:50;background:color-mix(in srgb,var(--paper) 86%,transparent);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid transparent;transition:border-color .3s}
.top.scrolled{border-bottom-color:var(--line)}
.top .wrap{display:flex;align-items:center;gap:24px;height:72px}
.logo{display:inline-flex;align-items:center;gap:10px;text-decoration:none;font:500 24px/1 var(--f-display);letter-spacing:-.03em}
.logo svg{width:30px;height:30px}
.logo .flap{transform-origin:15px 9px;transition:transform .5s var(--ease)}
.logo:hover .flap{transform:scaleY(-1)}
.nav{display:flex;gap:4px;margin-left:auto}
.nav a{padding:10px 12px;border-radius:10px;text-decoration:none;font-weight:500;color:var(--ink-2);font-size:15px}
.nav a:hover{background:var(--paper-2)}
.top .btn{margin-left:8px}
.nav .btn{display:none}
.menu-btn{display:none;margin-left:auto;width:46px;height:46px;border-radius:12px;border:1.5px solid var(--ink);background:transparent;cursor:pointer;flex-direction:column;align-items:center;justify-content:center;padding:0}
.menu-btn span{display:block;width:18px;height:2px;background:var(--ink);margin:2px 0;transition:transform .3s var(--ease),opacity .2s}
.menu-btn[aria-expanded="true"] span:nth-child(1){transform:translateY(6px) rotate(45deg)}
.menu-btn[aria-expanded="true"] span:nth-child(2){opacity:0}
.menu-btn[aria-expanded="true"] span:nth-child(3){transform:translateY(-6px) rotate(-45deg)}

/* hero */
.hero{padding:clamp(24px,4vw,48px) 0 40px}
.hero-head{display:grid;grid-template-columns:1.25fr 1fr;gap:clamp(24px,4vw,64px);align-items:end}
.hero h1{font-size:clamp(44px,7vw,104px);line-height:.95;letter-spacing:-.04em;font-weight:350;margin-top:18px}
.hero h1 em{font-style:italic;color:var(--green-2);font-weight:300}
.hero h1 .strike{position:relative;white-space:nowrap}
.hero h1 .strike::after{content:"";position:absolute;left:-2%;right:-2%;top:54%;height:.07em;background:var(--coral);transform-origin:left;transform:scaleX(var(--s,1));transition:transform .9s .5s var(--ease)}
.hero-side{display:grid;gap:22px;padding-bottom:6px}
.cta-row{display:flex;flex-wrap:wrap;gap:12px}
.fine{font-size:13px;color:var(--muted)}
.photo{margin:0;position:relative;border-radius:var(--r-l);overflow:hidden;aspect-ratio:16/7;background:var(--paper-2)}
.photo img{width:100%;height:100%;object-fit:cover;object-position:50% 55%;transform:scale(1.06);transition:transform 1.6s var(--ease)}
.photo.in img,.photo:hover img{transform:scale(1)}
.photo figcaption{position:absolute;left:12px;bottom:12px;display:flex;align-items:center;gap:8px;background:rgba(20,38,31,.88);color:#fff;font:500 12px/1 var(--f-mono);padding:9px 12px;border-radius:999px;backdrop-filter:blur(6px);white-space:nowrap;z-index:1}
.photo .dot{width:8px;height:8px;border-radius:50%;background:var(--coral);box-shadow:0 0 0 0 rgba(255,106,77,.6);animation:ping 2.4s var(--ease) infinite}
@keyframes ping{70%{box-shadow:0 0 0 8px rgba(255,106,77,0)}100%{box-shadow:0 0 0 0 rgba(255,106,77,0)}}
.faq-side{position:sticky;top:100px;align-self:start}
.faq-img{margin-top:28px;border-radius:var(--r-l);width:100%;max-width:420px;aspect-ratio:4/3;object-fit:cover;display:block}
.faq-fig{position:relative;margin:28px 0 0;max-width:420px;border-radius:var(--r-l);overflow:hidden}
.faq-fig .faq-img{margin:0}
.grain::after{content:"";position:absolute;inset:0;pointer-events:none;border-radius:inherit;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .08 0 0 0 0 .15 0 0 0 0 .12 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),radial-gradient(120% 90% at 30% 40%,transparent 55%,rgba(20,38,31,.28));mix-blend-mode:multiply;opacity:.55}
.hero{position:relative;background:var(--paper);isolation:isolate}
.hero>.wrap{position:relative;z-index:1}
canvas.field{position:absolute;left:0;top:0;width:100%;z-index:0;pointer-events:none;-webkit-mask:linear-gradient(#000 calc(100% - 120px),transparent);mask:linear-gradient(#000 calc(100% - 120px),transparent)}
.chart canvas.cashflow{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.stage canvas.gl{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.stage.gl-on .pkg{display:none}

/* simulator */
.sim{margin-top:clamp(28px,4vw,48px);background:var(--card);border:1px solid var(--line);border-radius:var(--r-xl);padding:clamp(16px,2.4vw,32px);box-shadow:0 1px 0 #fff inset,0 30px 60px -40px rgba(20,38,31,.35)}
.sim-top{display:flex;flex-wrap:wrap;gap:12px 24px;align-items:center;justify-content:space-between}
.sim-title{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap}
.sim-title h2{font-size:clamp(24px,2.4vw,32px)}
.legend{display:flex;flex-wrap:wrap;gap:8px}
.lg{display:inline-flex;align-items:center;gap:8px;padding:8px 12px;border-radius:999px;border:1.5px solid var(--line);background:#fff;cursor:pointer;font-size:14px;font-weight:500;user-select:none}
.lg input{position:absolute;opacity:0;pointer-events:none}
.lg .sw{width:22px;height:0;border-top:3px solid var(--green)}
.lg.wo .sw{border-top:3px dashed var(--coral-ink)}
.lg:has(input:not(:checked)){opacity:.5;text-decoration:line-through}
.lg:has(input:focus-visible){outline:3px solid var(--coral);outline-offset:2px}
@media (min-width:1100px){.sim-body{display:grid;grid-template-columns:232px 1fr;gap:20px;margin-top:20px}.sim-body .stats{grid-template-columns:1fr;grid-auto-rows:1fr;margin:0}.sim-body .stat .v{font-size:34px}}
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:1px;background:var(--line);border:1px solid var(--line);border-radius:var(--r);overflow:hidden;margin:20px 0 18px}
.stat{background:var(--card);padding:14px 16px}
.stat .k{font-size:13px;color:var(--muted);display:flex;align-items:center;gap:8px}
.stat .k i{width:14px;height:0;border-top:3px solid var(--green);display:inline-block}
.stat.wo .k i{border-top:3px dashed var(--coral-ink)}
.stat .v{font:400 clamp(26px,3vw,40px)/1.1 var(--f-display);letter-spacing:-.03em;margin-top:6px;font-variant-numeric:tabular-nums}
.stat .v.neg{color:var(--coral-ink)}
.stat .s{font-size:12.5px;color:var(--muted)}

.odo{display:inline-flex;white-space:nowrap}
.odo .od{display:inline-block;height:1.1em;overflow:hidden;vertical-align:top;position:relative}
.odo .col{display:flex;flex-direction:column;transition:transform 1s var(--ease)}
.odo .col span{height:1.1em;line-height:1.1em;text-align:center}
.odo .os{display:inline-block;height:1.1em;line-height:1.1em}

.chart-wrap{position:relative}
.chart{position:relative;height:270px;border-radius:var(--r);background:linear-gradient(#fff,#fdfbf7);border:1px solid var(--line);overflow:hidden;cursor:crosshair}
.chart svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.chart .ylab{position:absolute;right:8px;transform:translateY(-110%);font:500 11.5px/1 var(--f-mono);color:var(--muted);background:rgba(255,255,255,.8);padding:2px 4px;border-radius:4px;pointer-events:none}
.chart .ylab.zero{color:var(--coral-ink)}
.endpt{position:absolute;width:12px;height:12px;margin:-6px 0 0 -6px;border-radius:50%;background:var(--green);border:2.5px solid #fff;box-shadow:0 0 0 1px var(--green);pointer-events:none}
.endpt.wo{background:var(--coral);box-shadow:0 0 0 1px var(--coral-ink)}
.readout{position:absolute;top:10px;min-width:180px;background:var(--ink);color:#fff;border-radius:12px;padding:10px 12px;font-size:13px;pointer-events:none;opacity:0;transform:translateY(4px);transition:opacity .2s,transform .2s}
.readout.on{opacity:1;transform:none}
.readout b{font:500 12px/1 var(--f-mono);letter-spacing:.04em;color:var(--mint);display:block;margin-bottom:6px}
.readout div{display:flex;justify-content:space-between;gap:16px;font-variant-numeric:tabular-nums}
.vguide{position:absolute;top:0;bottom:0;width:0;border-left:1px dashed var(--ink-2);opacity:0;pointer-events:none}
.vguide.on{opacity:.5}
.od-badge{position:absolute;left:12px;top:12px;font:500 12px/1 var(--f-mono);color:var(--coral-ink);background:var(--coral-2);padding:7px 9px;border-radius:7px;opacity:0;transition:opacity .3s;pointer-events:none}
.od-badge.on{opacity:1}

.weeks,.lane-row{display:grid;grid-template-columns:repeat(12,1fr)}
.weeks{margin:8px 0 6px}
.weeks span{font:500 11.5px/1 var(--f-mono);color:var(--muted);text-align:center;position:relative;padding-bottom:9px}
.weeks span.pay::after{content:"";position:absolute;left:50%;bottom:0;width:5px;height:5px;margin-left:-2.5px;border-radius:50%;background:var(--coral)}
.lane{position:relative;border-radius:var(--r);background:repeating-linear-gradient(90deg,transparent 0 calc(100%/12 - 1px),var(--line) calc(100%/12 - 1px) calc(100%/12));background-color:var(--paper);border:1px solid var(--line);padding:6px 0;transition:background-color .2s,border-color .2s}
.lane.over{background-color:var(--mint-2);border-color:var(--green-3)}
.lane-row{height:40px;position:relative}
.lane-row+.lane-row{margin-top:4px}
.bar{position:relative;z-index:1;margin:0 3px;display:flex;align-items:center;gap:8px;min-width:0;border-radius:10px;background:#fff;border:1.5px solid var(--green);padding:0 10px 0 6px;font-size:13px;font-weight:600;cursor:grab;touch-action:none;user-select:none;overflow:hidden;white-space:nowrap;transition:transform .25s var(--ease),box-shadow .25s}
.bar:hover{box-shadow:0 6px 16px -8px rgba(20,38,31,.5);transform:translateY(-1px)}
.bar.dragging{opacity:.55;cursor:grabbing}
.bar .adv{flex:none;font:500 10.5px/1 var(--f-mono);background:var(--green);color:#fff;padding:5px 5px;border-radius:6px}
.bar .nm{overflow:hidden;text-overflow:ellipsis;min-width:0}
.bar .due{margin-left:auto;flex:none;font:500 11px/1 var(--f-mono);color:var(--coral-ink)}
.bar::after{content:"";position:absolute;right:0;top:0;bottom:0;width:4px;background:var(--coral)}
.bar.open::after{background:repeating-linear-gradient(180deg,var(--coral) 0 4px,transparent 4px 8px)}
.lane-empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--muted);pointer-events:none}
.tray{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-top:14px}
.chip{position:relative;text-align:left;border:1.5px dashed var(--line-2);background:var(--paper);border-radius:14px;padding:12px 14px 12px 14px;cursor:grab;touch-action:none;user-select:none;transition:border-color .2s,background .2s,transform .25s var(--ease)}
.chip:hover{border-color:var(--ink);transform:translateY(-2px)}
.chip[aria-pressed="true"]{border-style:solid;border-color:var(--green);background:#fff}
.chip .row1{display:flex;justify-content:space-between;align-items:center;gap:8px;font:500 11.5px/1 var(--f-mono);color:var(--muted)}
.chip .st{padding:4px 6px;border-radius:5px;background:var(--paper-2)}
.chip[aria-pressed="true"] .st{background:var(--mint);color:var(--green)}
.chip .nm{display:block;font-weight:600;font-size:15px;margin:8px 0 2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chip .amt{font:400 22px/1.1 var(--f-display);letter-spacing:-.02em}
.chip .terms{font-size:13px;color:var(--muted)}
.dghost{position:fixed;z-index:80;pointer-events:none;left:0;top:0;padding:10px 14px;border-radius:12px;background:var(--ink);color:#fff;font-weight:600;font-size:14px;box-shadow:0 20px 40px -12px rgba(20,38,31,.6);transform:translate(-50%,-50%) rotate(-3deg);white-space:nowrap}
.dghost small{display:block;font:500 11px/1.3 var(--f-mono);color:var(--mint)}
.sim-foot{display:flex;flex-wrap:wrap;justify-content:space-between;gap:12px;align-items:center;margin-top:16px}
.sim-foot .acts{display:flex;gap:8px;flex-wrap:wrap}
.linkbtn{background:none;border:0;padding:8px 4px;font-weight:600;text-decoration:underline;text-underline-offset:3px;cursor:pointer}
details.tbl{margin-top:12px;border-top:1px dashed var(--line-2);padding-top:12px}
details.tbl summary{cursor:pointer;font-weight:600;font-size:15px;width:max-content}
.tbl-scroll{overflow-x:auto;margin-top:10px}
.tbl table{border-collapse:collapse;width:100%;font:400 13px/1.3 var(--f-mono);min-width:560px}
.tbl th,.tbl td{text-align:right;padding:7px 8px;border-bottom:1px solid var(--line)}
.tbl th:first-child,.tbl td:first-child{text-align:left}
.tbl td.neg{color:var(--coral-ink)}

/* sections */
section{position:relative}
.sec{padding:clamp(72px,10vw,140px) 0 0}
.sec-head{display:grid;grid-template-columns:1fr 2fr;gap:24px 48px;align-items:start;border-top:1px dashed var(--line-2);padding-top:24px;margin-bottom:clamp(32px,4vw,56px)}
.sec-head .lead{margin-top:16px}
.reveal{opacity:0;transform:translateY(32px);transition:opacity .8s var(--ease),transform .9s var(--ease)}
.reveal.in{opacity:1;transform:none}

/* fee calculator */
.calc{display:grid;grid-template-columns:1fr 1.1fr;gap:20px}
.panel{background:var(--card);border:1px solid var(--line);border-radius:var(--r-l);padding:clamp(18px,2.4vw,32px)}
.field{margin-bottom:26px}
.field:last-child{margin-bottom:0}
.field-top{display:flex;justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:10px}
.field label,.field legend{font-weight:600;font-size:15px}
.field output{font:400 26px/1 var(--f-display);letter-spacing:-.02em;font-variant-numeric:tabular-nums}
fieldset{border:0;margin:0;padding:0;min-width:0}
input[type=range]{-webkit-appearance:none;appearance:none;width:100%;height:28px;background:transparent;cursor:pointer;--p:50%}
input[type=range]::-webkit-slider-runnable-track{height:6px;border-radius:6px;background:linear-gradient(90deg,var(--green) var(--p),var(--paper-3) var(--p))}
input[type=range]::-moz-range-track{height:6px;border-radius:6px;background:linear-gradient(90deg,var(--green) var(--p),var(--paper-3) var(--p))}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:24px;height:24px;border-radius:50%;background:#fff;border:2.5px solid var(--ink);margin-top:-9px;box-shadow:0 2px 6px rgba(0,0,0,.15)}
input[type=range]::-moz-range-thumb{width:20px;height:20px;border-radius:50%;background:#fff;border:2.5px solid var(--ink)}
input[type=range]:focus-visible{outline:none}
input[type=range]:focus-visible::-webkit-slider-thumb{outline:3px solid var(--coral);outline-offset:2px}
input[type=range]:focus-visible::-moz-range-thumb{outline:3px solid var(--coral);outline-offset:2px}
.scale{display:flex;justify-content:space-between;font:500 11.5px/1 var(--f-mono);color:var(--muted);margin-top:2px}
.seg{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;background:var(--paper-2);border-radius:12px;padding:4px;gap:4px;position:relative}
.seg input{position:absolute;opacity:0;pointer-events:none}
.seg label{position:relative;z-index:1;text-align:center;padding:10px 6px;border-radius:9px;cursor:pointer;font-weight:600;font-size:14.5px;transition:background .25s,color .25s}
.seg input:checked+label{background:#fff;box-shadow:0 1px 4px rgba(20,38,31,.12)}
.seg input:focus-visible+label{outline:3px solid var(--coral);outline-offset:1px}
.res{display:flex;flex-direction:column;gap:18px}
.res-big{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.res-big .k{font-size:14px;color:var(--muted)}
.res-big .v{font:350 clamp(36px,4.4vw,60px)/1.05 var(--f-display);letter-spacing:-.04em;margin-top:6px;font-variant-numeric:tabular-nums}
.res-big .w{font-size:13px;color:var(--muted);margin-top:4px}
.split{display:flex;height:16px;border-radius:8px;overflow:hidden;gap:3px}
.split span{display:block;height:100%;transition:flex-grow .7s var(--ease)}
.split .a{background:var(--green)}.split .b{background:var(--mint);}.split .c{background:var(--coral)}
.split-leg{display:flex;flex-wrap:wrap;gap:6px 18px;font-size:13px;color:var(--muted)}
.split-leg i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:6px;vertical-align:-1px}
.lines{border-top:1px dashed var(--line-2)}
.lines div{display:flex;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px dashed var(--line-2);font-size:15px}
.lines div b{font-weight:600;font-variant-numeric:tabular-nums}
.formula{font:400 13px/1.5 var(--f-mono);background:var(--paper);border-radius:10px;padding:12px 14px;color:var(--ink-2);overflow-wrap:anywhere}

/* how it works */
.how{height:460vh}
.how-sticky{position:sticky;top:72px;height:calc(100vh - 72px);display:grid;grid-template-columns:.9fr 1.1fr;gap:40px;align-items:center}
.steps{list-style:none;margin:0;padding:0 0 0 28px;position:relative}
.steps::before{content:"";position:absolute;left:6px;top:8px;bottom:8px;width:2px;background:var(--paper-3);border-radius:2px}
.steps .rail{position:absolute;left:6px;top:8px;width:2px;background:var(--green);border-radius:2px;height:calc((100% - 16px)*var(--p,0))}
.step{position:relative;padding:14px 0;opacity:.42;transition:opacity .4s}
.step::before{content:"";position:absolute;left:-28px;top:20px;width:14px;height:14px;border-radius:50%;background:var(--paper);border:2px solid var(--paper-3);transition:background .3s,border-color .3s}
.step.on{opacity:1}
.step.on::before,.step.done::before{background:var(--green);border-color:var(--green)}
.step.done{opacity:.7}
.step .n{font:500 12px/1 var(--f-mono);color:var(--green);letter-spacing:.06em}
.step h3{margin:6px 0 6px}
.step p{color:var(--muted);font-size:16px;max-width:42ch}
.stage-box{position:relative;height:min(470px,70vh);min-width:0;overflow:hidden}
.stage{position:absolute;left:50%;top:50%;width:640px;height:440px;transform-origin:center;border-radius:var(--r-xl);background:var(--card);border:1px solid var(--line);overflow:hidden}
.stage::before{content:"";position:absolute;inset:0;background-image:radial-gradient(rgba(29,77,60,.16) 1.2px,transparent 1.4px);background-size:20px 20px;-webkit-mask:linear-gradient(90deg,#000,transparent 70%);mask:linear-gradient(90deg,#000,transparent 70%)}
.trail{position:absolute;inset:0;pointer-events:none}
.pkg{position:absolute;left:60px;top:48px;width:240px;height:330px;transform-origin:50% 50%;perspective:1100px;will-change:transform}
.doc{position:absolute;inset:0;transform-style:preserve-3d}
.pnl{position:absolute;left:0;width:100%;height:110px;transform-style:preserve-3d}
.pnl .f,.pnl .b{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden}
.pnl .f{background:#fff;border:1px solid var(--line);padding:14px 18px}
.pnl .b{background:var(--paper-2);border:1px solid var(--line-2);transform:rotateX(180deg)}
.p1{top:0;transform-origin:50% 100%}.p1 .f{border-radius:10px 10px 0 0;border-bottom:1px dashed var(--line)}
.p2{top:110px}.p2 .f{border-top:0;border-bottom:1px dashed var(--line)}
.p3{top:220px;transform-origin:50% 0}.p3 .f{border-radius:0 0 10px 10px;border-top:0}
.p1 .b{border-radius:10px 10px 0 0}.p3 .b{border-radius:0 0 10px 10px}
.doc .hd{display:flex;justify-content:space-between;align-items:center;font:500 11px/1 var(--f-mono);color:var(--muted)}
.doc .ttl{font:400 25px/.95 var(--f-display);letter-spacing:-.02em;margin-top:12px}
.doc .ln{height:7px;border-radius:4px;background:var(--paper-2);margin-top:9px;transform-origin:left;transform:scaleX(var(--k,1))}
.doc .row{display:flex;justify-content:space-between;font:400 12px/1 var(--f-mono);color:var(--ink-2);margin-top:12px}
.doc .total{display:flex;justify-content:space-between;align-items:baseline;margin-top:16px;border-top:1.5px solid var(--ink);padding-top:10px}
.doc .total b{font:400 28px/1 var(--f-display);letter-spacing:-.03em}
.stamp{position:absolute;right:12px;top:22px;width:80px;height:80px;background:rgba(255,255,255,.6);border-radius:50%;border:2.5px solid var(--green-2);color:var(--green-2);display:grid;place-items:center;text-align:center;font:600 11px/1.15 var(--f-mono);letter-spacing:.06em;transform:rotate(-14deg) scale(var(--sc,0));opacity:var(--o,0)}
.env{position:absolute;left:-20px;right:-20px;top:100px;height:130px;opacity:0;pointer-events:none}
.env .back{position:absolute;inset:0;background:var(--green);border-radius:10px}
.env .front{position:absolute;inset:0;border-radius:10px;overflow:hidden}
.env .front svg{width:100%;height:100%}
.env .flapw{position:absolute;left:0;right:0;top:0;height:78px;perspective:800px}
.env .flap{position:absolute;inset:0;transform-origin:50% 0;clip-path:polygon(0 0,100% 0,50% 100%);background:var(--green-2)}
.env .lbl{position:absolute;left:18px;bottom:14px;font:500 11px/1.3 var(--f-mono);color:var(--mint)}
.bank{position:absolute;right:28px;top:226px;width:236px;border-radius:20px;background:var(--ink);color:#fff;padding:18px;transition:box-shadow .4s}
.bank.hit{box-shadow:0 0 0 6px rgba(255,106,77,.35)}
.bank .k{font:500 11px/1 var(--f-mono);color:var(--mint);letter-spacing:.05em;text-transform:uppercase}
.bank .v{font:350 34px/1.1 var(--f-display);letter-spacing:-.03em;margin-top:12px}
.bank .s{font-size:12.5px;color:#c9d6ce;margin-top:6px}
.bank .tx{margin-top:14px;border-top:1px dashed rgba(255,255,255,.25);padding-top:10px;font:400 12px/1.4 var(--f-mono);display:flex;justify-content:space-between;opacity:var(--txo,0);transform:translateY(calc((1 - var(--txo,0))*8px))}
.checks{position:absolute;left:340px;top:56px;display:grid;gap:10px}
.checks div{display:flex;align-items:center;gap:10px;font-size:14px;font-weight:500;opacity:var(--o,0);transform:translateX(calc((1 - var(--o,0))*-10px))}
.checks div::before{content:"✓";display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--mint);color:var(--green);font-size:13px;font-weight:700}
.stage-cap{position:absolute;left:24px;bottom:18px;font:500 11.5px/1 var(--f-mono);color:var(--muted)}

/* trust */
.trust{background:var(--green);color:#f2efe7;border-radius:var(--r-xl);padding:clamp(28px,5vw,72px);position:relative;overflow:hidden;margin-top:0}
.trust::before{content:"";position:absolute;right:-120px;top:-120px;width:520px;height:520px;background-image:radial-gradient(rgba(207,227,214,.28) 1.4px,transparent 1.6px);background-size:18px 18px;-webkit-mask:radial-gradient(circle,#000 20%,transparent 68%);mask:radial-gradient(circle,#000 20%,transparent 68%)}
.trust .eyebrow{color:var(--mint)}
.trust h2{max-width:16ch;margin-top:16px}
.trust .lead{color:#cfdcd3;margin-top:16px}
.trust-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-top:clamp(32px,4vw,56px);position:relative}
.tcard{border:1px solid rgba(255,255,255,.18);border-radius:var(--r);padding:20px;background:rgba(255,255,255,.04)}
.tcard svg{width:36px;height:36px;margin-bottom:28px}
.tcard h3{font-size:21px}
.tcard p{font-size:15px;color:#cfdcd3;margin-top:8px}
.flow{margin-top:20px;display:flex;align-items:center;gap:10px;flex-wrap:wrap;font:500 13px/1 var(--f-mono);color:var(--mint);position:relative}
.flow span{border:1px solid rgba(255,255,255,.25);padding:9px 12px;border-radius:999px;color:#fff}
.flow i{font-style:normal;color:var(--coral)}

/* pricing */
.bill{display:inline-flex;align-items:center;gap:12px;font-weight:600;font-size:15px;margin-bottom:24px}
.switch{position:relative;width:54px;height:30px;border-radius:999px;background:var(--paper-3);border:0;cursor:pointer;transition:background .3s}
.switch::after{content:"";position:absolute;left:3px;top:3px;width:24px;height:24px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.2);transition:transform .35s var(--ease)}
.switch[aria-checked="true"]{background:var(--green)}
.switch[aria-checked="true"]::after{transform:translateX(24px)}
.save{font:500 12px/1 var(--f-mono);background:var(--coral-2);color:var(--coral-ink);padding:6px 8px;border-radius:6px}
.plans{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.plan{background:var(--card);border:1px solid var(--line);border-radius:var(--r-l);padding:28px;display:flex;flex-direction:column;gap:18px}
.plan.feat{background:var(--ink);color:#f2efe7;border-color:var(--ink)}
.plan.feat .muted,.plan.feat li{color:#c9d6ce}
.plan .nm{display:flex;justify-content:space-between;align-items:center;font-weight:600}
.plan .pill{font:500 11px/1 var(--f-mono);background:var(--coral);color:var(--ink);padding:6px 8px;border-radius:6px}
.plan .price{font:350 54px/1 var(--f-display);letter-spacing:-.04em}
.plan .price small{font:400 15px var(--f-sans);letter-spacing:0;color:var(--muted)}
.plan.feat .price small{color:#c9d6ce}
.plan .rate{font:500 14px/1.4 var(--f-mono);border-top:1px dashed var(--line-2);border-bottom:1px dashed var(--line-2);padding:12px 0}
.plan.feat .rate{border-color:rgba(255,255,255,.25)}
.plan ul{margin:0;padding:0;list-style:none;display:grid;gap:9px;font-size:15px;color:var(--ink-2)}
.plan li{padding-left:22px;position:relative}
.plan li::before{content:"";position:absolute;left:2px;top:9px;width:10px;height:5px;border-left:2px solid var(--green-3);border-bottom:2px solid var(--green-3);transform:rotate(-45deg)}
.plan .btn{margin-top:auto}
.muted{color:var(--muted)}

/* faq */
.faq{display:grid;grid-template-columns:1fr 2fr;gap:24px 48px}
.faq-list{border-top:1px solid var(--line-2)}
.faq details{border-bottom:1px solid var(--line-2)}
.faq summary{list-style:none;display:flex;justify-content:space-between;align-items:center;gap:18px;padding:22px 0;cursor:pointer;font:400 clamp(19px,1.8vw,24px)/1.25 var(--f-display);letter-spacing:-.015em}
.faq summary::-webkit-details-marker{display:none}
.faq summary .pm{flex:none;width:34px;height:34px;border-radius:50%;border:1.5px solid var(--ink);position:relative;transition:background .25s,transform .35s var(--ease)}
.faq summary .pm::before,.faq summary .pm::after{content:"";position:absolute;left:50%;top:50%;width:12px;height:1.8px;margin:-.9px 0 0 -6px;background:var(--ink);transition:transform .35s var(--ease)}
.faq summary .pm::after{transform:rotate(90deg)}
.faq details[open] .pm{background:var(--coral);border-color:var(--coral)}
.faq details[open] .pm::after{transform:rotate(0)}
.faq .ans{overflow:hidden}
.faq .ans p{padding:0 48px 24px 0;color:var(--muted);max-width:64ch}

/* apply */
.apply{display:grid;grid-template-columns:1fr 1fr;gap:clamp(24px,4vw,64px);background:var(--coral);border-radius:var(--r-xl);padding:clamp(24px,5vw,64px);position:relative;overflow:hidden}
.apply h2{max-width:12ch}
.apply .lead{color:var(--ink-2);margin-top:16px}
.apply .eyebrow{color:var(--ink)}
.apply .eyebrow::before{background:var(--ink)}
form.ap{background:var(--paper);border-radius:var(--r-l);padding:clamp(18px,2.4vw,28px);display:grid;gap:14px;position:relative}
.inp label{display:block;font-weight:600;font-size:14.5px;margin-bottom:6px}
.inp input,.inp select{width:100%;height:52px;border-radius:12px;border:1.5px solid var(--line-2);background:#fff;padding:0 14px;font-size:16px}
.inp input:focus,.inp select:focus{outline:none;border-color:var(--green);box-shadow:0 0 0 3px rgba(47,107,83,.25)}
.inp[data-err] input,.inp[data-err] select{border-color:var(--coral-ink)}
.inp .err{display:none;color:var(--coral-ink);font-size:13.5px;margin-top:6px;font-weight:500}
.inp[data-err] .err{display:block}
.ok{display:none;background:var(--mint);border-radius:12px;padding:14px 16px;font-size:15px}
.ok.on{display:block}

/* footer */
footer{margin-top:clamp(72px,10vw,140px);background:var(--ink);color:#d9e2dc;padding:56px 0 28px;overflow:hidden}
.ft{display:grid;grid-template-columns:2fr 1fr 1fr 1fr;gap:32px}
.ft h4{margin:0 0 14px;font:500 12px/1 var(--f-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--mint)}
.ft ul{list-style:none;margin:0;padding:0;display:grid;gap:8px}
.ft a{text-decoration:none;color:#f2efe7}
.ft a:hover{text-decoration:underline}
.ft .logo{color:#f2efe7}
.ft p{color:#b9c7bf;font-size:15px;margin-top:14px;max-width:38ch}
.word{font:300 clamp(96px,22vw,320px)/.8 var(--f-display);letter-spacing:-.06em;color:#1f3a2f;margin:40px 0 0;white-space:nowrap;user-select:none}
.legal{display:flex;flex-wrap:wrap;justify-content:space-between;gap:12px;border-top:1px dashed rgba(255,255,255,.2);padding-top:20px;margin-top:20px;font-size:13.5px;color:#b9c7bf}

/* responsive */
@media (max-width:1100px){
  .nav a{padding:10px 8px}
  .trust-grid{grid-template-columns:repeat(2,1fr)}
}
@media (max-width:960px){
  .nav,.top .btn{display:none}
  .menu-btn{display:flex}
  .nav.open{display:flex;position:absolute;left:0;right:0;top:72px;flex-direction:column;background:var(--paper);border-bottom:1px solid var(--line);padding:8px var(--gut) 18px;gap:0}
  .nav.open a{padding:14px 4px;border-bottom:1px dashed var(--line-2);font-size:17px;border-radius:0}
  .nav.open .btn{display:inline-flex;margin:14px 0 0}
  .hero-head{grid-template-columns:1fr}
  .calc{grid-template-columns:1fr}
  .stats{grid-template-columns:repeat(2,1fr)}
  .tray{grid-template-columns:repeat(2,1fr)}
  .how-sticky{grid-template-columns:1fr;grid-template-rows:auto auto;gap:20px;align-content:center;align-items:start}
  .stage-box{height:min(360px,46vh);order:-1}
  .steps{padding-left:0}
  .steps::before,.steps .rail,.step::before{display:none}
  .step{display:none;padding:0}
  .step.on{display:block}
  .plans{grid-template-columns:1fr;max-width:560px}
  .faq,.sec-head,.apply{grid-template-columns:1fr}
  .faq-side{position:static}
  .faq-fig{display:none}
  .ft{grid-template-columns:1fr 1fr}
  .ft>div:first-child{grid-column:1/-1}
}
@media (max-width:560px){
  body{font-size:16px}
  .hero h1{font-size:54px}
  .hero h1 br{display:none}
  .cta-row .btn{flex:1 1 100%}
  .chart{height:210px}
  .stat{padding:12px}
  .lane-row{height:36px}
  .bar{font-size:12px;padding:0 6px 0 4px;gap:5px}
  .bar .nm{display:none}
  .bar .adv{font-size:10px;padding:4px}
  .tray{gap:8px}
  .chip{padding:10px}
  .chip .amt{font-size:19px}
  .chip .nm{font-size:14px}
  .weeks span{font-size:10.5px}
  .trust-grid{grid-template-columns:1fr}
  .res-big{grid-template-columns:1fr}
  .faq .ans p{padding-right:0}
  .readout{min-width:160px}
}
@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  *,*::before,*::after{transition-duration:.01ms!important;animation-duration:.01ms!important}
  .reveal{opacity:1;transform:none}
}
</style>
</head>
<body>
<a class="skip" href="#main">Skip to content</a>

<header class="top" id="top">
  <div class="wrap">
    <a class="logo" href="#top" aria-label="Quire, home">
      <svg viewBox="0 0 30 30" aria-hidden="true"><rect x="1" y="5" width="28" height="20" rx="5" fill="#1d4d3c"/><path class="flap" d="M3 7l12 9 12-9" fill="none" stroke="#ff6a4d" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
      Quire
    </a>
    <nav class="nav" id="nav" aria-label="Main">
      <a href="#simulator">Simulator</a>
      <a href="#fees">Fees</a>
      <a href="#how">How it works</a>
      <a href="#security">Security</a>
      <a href="#pricing">Pricing</a>
      <a href="#faq">FAQ</a>
      <a class="btn coral sm" href="#apply">Check your limit <span class="arr" aria-hidden="true">→</span></a>
    </nav>
    <a class="btn coral sm" href="#apply">Check your limit <span class="arr" aria-hidden="true">→</span></a>
    <button class="menu-btn" aria-expanded="false" aria-controls="nav" aria-label="Open menu"><span></span><span></span><span></span></button>
  </div>
</header>

<main id="main">
<section class="hero" aria-labelledby="h1">
  <div class="wrap">
    <div class="hero-head">
      <div>
        <span class="eyebrow">Invoice financing for small agencies</span>
        <h1 id="h1">Stop waiting <span class="strike">sixty days</span> <br>to get <em>paid.</em></h1>
      </div>
      <div class="hero-side">
        <figure class="photo grain"><img src="assets/desk.webp" width="1200" height="896" alt="An invoice with a coral paper clip beside a dark green envelope, a brass letter opener and a cup of coffee on cream paper." fetchpriority="high"><figcaption><span class="dot" aria-hidden="true"></span>INV-0412 · €16,560 advanced next day</figcaption></figure>
        <p class="lead">Send an invoice, get 90% of it in your account the next business day. The rest arrives when your client pays, minus one fee you can see before you send.</p>
        <div class="cta-row">
          <a class="btn coral" href="#apply">Check your limit <span class="arr" aria-hidden="true">→</span></a>
          <a class="btn ghost" href="#fees">Work out a fee</a>
        </div>
        <p class="fine">Quire is a fictional product. Every figure on this page is an illustrative example.</p>
      </div>
    </div>

    <div class="sim" id="simulator" aria-labelledby="sim-h">
      <div class="sim-top">
        <div class="sim-title">
          <h2 id="sim-h">Your next 12 weeks</h2>
          <span class="tag-ill">Example agency · illustrative</span>
        </div>
        <div class="legend" role="group" aria-label="Lines shown on the chart">
          <label class="lg"><input type="checkbox" id="showWith" checked><span class="sw" aria-hidden="true"></span>With Quire</label>
          <label class="lg wo"><input type="checkbox" id="showWo" checked><span class="sw" aria-hidden="true"></span>Without</label>
        </div>
      </div>

      <div class="sim-body">
      <div class="stats" aria-live="off">
        <div class="stat wo"><div class="k"><i aria-hidden="true"></i>Lowest balance, without</div><div class="v" id="stLoWo"></div><div class="s" id="stLoWoW">&nbsp;</div></div>
        <div class="stat"><div class="k"><i aria-hidden="true"></i>Lowest balance, with Quire</div><div class="v" id="stLoW"></div><div class="s" id="stLoWW">&nbsp;</div></div>
        <div class="stat"><div class="k">Weeks overdrawn</div><div class="v" id="stOd"></div><div class="s">without → with Quire</div></div>
        <div class="stat"><div class="k">Fees, all in</div><div class="v" id="stFee"></div><div class="s" id="stFeeS">on Flex pricing</div></div>
      </div>
      <p class="sr-only" id="simLive" aria-live="polite"></p>

      <div class="chart-wrap">
        <div class="chart" id="chart" tabindex="0" role="img" aria-roledescription="interactive chart" aria-describedby="chartHelp">
          <svg viewBox="0 0 1200 300" preserveAspectRatio="none" aria-hidden="true">
            <defs><clipPath id="below"><rect id="belowRect" x="0" y="0" width="1200" height="300"/></clipPath>
              <linearGradient id="gw" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#2f6b53" stop-opacity=".22"/><stop offset="1" stop-color="#2f6b53" stop-opacity="0"/></linearGradient></defs>
            <g id="grid"></g>
            <path id="odArea" fill="#ff6a4d" fill-opacity=".2" clip-path="url(#below)"/>
            <path id="wArea" fill="url(#gw)"/>
            <line id="zeroLine" x1="0" x2="1200" stroke="#b23d1d" stroke-width="1.2" vector-effect="non-scaling-stroke"/>
            <path id="woLine" fill="none" stroke="#b23d1d" stroke-width="2.2" stroke-dasharray="7 6" vector-effect="non-scaling-stroke" stroke-linejoin="round"/>
            <path id="wLine" fill="none" stroke="#1d4d3c" stroke-width="3.2" vector-effect="non-scaling-stroke" stroke-linejoin="round"/>
          </svg>
          <div id="ylabs"></div>
          <span class="endpt wo" id="epWo"></span><span class="endpt" id="epW"></span>
          <span class="od-badge" id="odBadge">Overdraft without Quire</span>
          <div class="vguide" id="vguide"></div>
          <div class="readout" id="readout" aria-hidden="true"></div>
        </div>
        <p class="sr-only" id="chartHelp">Balance at the end of each week, with and without Quire. Focus the chart and use the left and right arrow keys to read each week. A data table follows the simulator.</p>
        <div class="weeks" aria-hidden="true" id="weeks"></div>
        <div class="lane" id="lane" aria-label="Timeline: the week each invoice is sent. A bar runs until the client pays." role="group"></div>
      </div>
      </div>

      <div class="tray" id="tray" role="group" aria-label="Invoices to schedule"></div>

      <div class="sim-foot">
        <p class="fine" id="simHint">Drag an invoice onto the week you send it, or tap it. On the timeline, focus a bar and use ← → to move it, Delete to take it off. Coral dots mark payroll (€15,200, every other Friday).</p>
        <div class="acts">
          <button class="btn ghost sm" type="button" id="allBtn">Schedule all four</button>
          <button class="linkbtn" type="button" id="resetBtn">Reset</button>
        </div>
      </div>
      <details class="tbl">
        <summary>Show the numbers as a table</summary>
        <div class="tbl-scroll"><table>
          <caption class="sr-only">Weekly cash for the example agency, in euros</caption>
          <thead><tr><th scope="col">Week</th><th scope="col">Invoices paid by clients</th><th scope="col">Advanced by Quire</th><th scope="col">Balance without</th><th scope="col">Balance with Quire</th></tr></thead>
          <tbody id="tbody"></tbody>
        </table></div>
      </details>
    </div>
  </div>
</section>

<section class="sec" id="fees" aria-labelledby="fees-h">
  <div class="wrap">
    <div class="sec-head reveal">
      <span class="eyebrow">Fee calculator</span>
      <div>
        <h2 id="fees-h">One fee, per day, on the money you actually used.</h2>
        <p class="lead">No setup fee, no monthly minimum on Flex, no charge if your client pays early. Move the sliders; the maths is printed under the result.</p>
      </div>
    </div>
    <div class="calc reveal">
      <form class="panel" id="calcForm" onsubmit="return false">
        <div class="field">
          <div class="field-top"><label for="amt">Invoice amount</label><output id="amtO" for="amt">€18,400</output></div>
          <input type="range" id="amt" min="1000" max="100000" step="100" value="18400">
          <div class="scale" aria-hidden="true"><span>€1k</span><span>€100k</span></div>
        </div>
        <fieldset class="field">
          <legend>Payment terms</legend>
          <div class="seg" style="margin-top:10px">
            <input type="radio" name="terms" id="t30" value="30"><label for="t30">30 days</label>
            <input type="radio" name="terms" id="t45" value="45"><label for="t45">45</label>
            <input type="radio" name="terms" id="t60" value="60" checked><label for="t60">60</label>
            <input type="radio" name="terms" id="t90" value="90"><label for="t90">90</label>
          </div>
        </fieldset>
        <div class="field">
          <div class="field-top"><label for="late">Client pays late by</label><output id="lateO" for="late">7 days</output></div>
          <input type="range" id="late" min="0" max="45" step="1" value="7">
          <div class="scale" aria-hidden="true"><span>on time</span><span>45 days</span></div>
        </div>
        <fieldset class="field">
          <legend>Plan</legend>
          <div class="seg" style="margin-top:10px">
            <input type="radio" name="plan" id="pFlex" value="flex" checked><label for="pFlex">Flex</label>
            <input type="radio" name="plan" id="pStudio" value="studio"><label for="pStudio">Studio</label>
            <input type="radio" name="plan" id="pAgency" value="agency"><label for="pAgency">Agency</label>
          </div>
        </fieldset>
      </form>
      <div class="panel res" aria-live="polite" aria-atomic="false">
        <div class="res-big">
          <div><div class="k">In your account tomorrow</div><div class="v" id="cAdv"></div><div class="w">90% of the invoice</div></div>
          <div><div class="k">When your client pays</div><div class="v" id="cRest"></div><div class="w" id="cRestW">the last 10%, minus the fee</div></div>
        </div>
        <div>
          <div class="split" aria-hidden="true"><span class="a" id="sA"></span><span class="b" id="sB"></span><span class="c" id="sC"></span></div>
          <div class="split-leg" style="margin-top:10px"><span><i style="background:var(--green)"></i>Advance</span><span><i style="background:var(--mint)"></i>Balance on payment</span><span><i style="background:var(--coral)"></i>Our fee</span></div>
        </div>
        <div class="lines">
          <div><span>Days financed</span><b id="cDays"></b></div>
          <div><span>Daily rate</span><b id="cRate"></b></div>
          <div><span>Total fee</span><b id="cFee"></b></div>
          <div><span>Fee as a share of the invoice</span><b id="cPct"></b></div>
        </div>
        <p class="formula" id="cFormula"></p>
        <p class="fine">Illustrative example rates for a fictional product, not an offer of credit. Minimum fee €25, capped at 4% of the invoice.</p>
      </div>
    </div>
  </div>
</section>

<section class="sec" id="how" aria-labelledby="how-h">
  <div class="wrap">
    <div class="sec-head reveal" style="margin-bottom:0">
      <span class="eyebrow">How it works</span>
      <h2 id="how-h">From sent to spendable in one business day.</h2>
    </div>
  </div>
  <div class="how" id="howTrack">
    <div class="wrap how-sticky">
      <ol class="steps" id="steps">
        <span class="rail" aria-hidden="true"></span>
        <li class="step on"><span class="n">01 · TWO MINUTES</span><h3>Send the invoice you already wrote</h3><p>Forward it, or pick it from your invoicing tool. Nothing about it changes, and it still has your name on it.</p></li>
        <li class="step"><span class="n">02 · ABOUT AN HOUR</span><h3>We check the client, not you</h3><p>We look at who owes the money and whether the work matches. No personal guarantee, no credit check on the founders.</p></li>
        <li class="step"><span class="n">03 · SAME DAY</span><h3>Sealed, with the fee on the front</h3><p>You see the exact fee before you confirm. Your client pays you as usual, into an account in your name that we can read.</p></li>
        <li class="step"><span class="n">04 · NEXT BUSINESS DAY</span><h3>90% lands in your bank</h3><p>The other 10%, less the fee, follows the day your client pays. If they pay early, you pay less.</p></li>
      </ol>
      <div class="stage-box" id="stageBox">
        <div class="stage" id="stage" aria-hidden="true">
          <svg class="trail" viewBox="0 0 640 440"><path id="trailPath" d="M180 214 C 250 350, 400 370, 494 300" fill="none" stroke="#c4b8a3" stroke-width="2" stroke-dasharray="4 7"/></svg>
          <div class="checks" id="checks">
            <div>Client: Marlow Bikes Ltd</div>
            <div>Paid 14 of 14 past invoices</div>
            <div>Work matches the contract</div>
          </div>
          <div class="bank" id="bank">
            <div class="k">Your business account</div>
            <div class="v"><span class="odo" id="bankV"></span></div>
            <div class="s">Available balance</div>
            <div class="tx"><span>QUIRE ADV INV-0412</span><span>+€16,560</span></div>
          </div>
          <div class="pkg" id="pkg">
            <div class="doc" id="doc">
              <div class="pnl p1" id="p1"><div class="f">
                <div class="hd"><span>INVOICE · INV-0412 · NET 60</span></div>
                <div class="ttl">Marlow<br>Bikes</div>
                <div class="ln" style="width:44%"></div>
                <div class="stamp" id="stamp">VERIFIED<br>BY QUIRE<br>✓</div>
              </div><div class="b"></div></div>
              <div class="pnl p2" id="p2"><div class="f">
                <div class="row"><span>Brand system</span><span>€11,200</span></div>
                <div class="row"><span>Launch site</span><span>€5,600</span></div>
                <div class="row"><span>Art direction</span><span>€1,600</span></div>
                <div class="ln" style="width:84%"></div>
              </div><div class="b"></div></div>
              <div class="pnl p3" id="p3"><div class="f">
                <div class="total"><span class="mono" style="font-size:12px">TOTAL DUE</span><b>€18,400</b></div>
                <div class="ln" style="width:60%;margin-top:16px"></div><div class="ln" style="width:36%"></div>
              </div><div class="b"></div></div>
            </div>
            <div class="env" id="env">
              <div class="back"></div>
              <div class="front"><svg viewBox="0 0 280 130" preserveAspectRatio="none"><path d="M0 130 L140 62 L280 130 Z" fill="#245a46"/><path d="M0 0 L0 130 L120 72 Z M280 0 L280 130 L160 72 Z" fill="#2a6250"/></svg></div>
              <div class="flapw"><div class="flap" id="flap"></div></div>
              <div class="lbl" id="envLbl">FEE €493 · SHOWN BEFORE YOU SEND</div>
            </div>
          </div>
          <span class="stage-cap">Example invoice · illustrative</span>
        </div>
      </div>
    </div>
  </div>
</section>

<section class="sec" id="security" aria-labelledby="sec-h">
  <div class="wrap">
    <div class="trust reveal">
      <span class="eyebrow">Security</span>
      <h2 id="sec-h">Your client pays you. We never sit in the middle.</h2>
      <p class="lead">Payments land in an account titled to your company. We get read access to see when an invoice clears, nothing more.</p>
      <div class="trust-grid">
        <div class="tcard">
          <svg viewBox="0 0 36 36" fill="none" stroke="#cfe3d6" stroke-width="1.8" aria-hidden="true"><rect x="6" y="15" width="24" height="16" rx="3"/><path d="M11 15v-4a7 7 0 0 1 14 0v4"/><circle cx="18" cy="23" r="2" fill="#ff6a4d" stroke="none"/></svg>
          <h3>Read-only bank access</h3><p>We can see balances and incoming payments. We cannot move money out of your account.</p>
        </div>
        <div class="tcard">
          <svg viewBox="0 0 36 36" fill="none" stroke="#cfe3d6" stroke-width="1.8" aria-hidden="true"><path d="M18 4l12 5v8c0 8-5 13-12 15C11 30 6 25 6 17V9z"/><path d="M13 18l4 4 7-8" stroke="#ff6a4d"/></svg>
          <h3>No personal guarantee</h3><p>The invoice is the security. Your house, savings and founders' credit files stay out of it.</p>
        </div>
        <div class="tcard">
          <svg viewBox="0 0 36 36" fill="none" stroke="#cfe3d6" stroke-width="1.8" aria-hidden="true"><circle cx="18" cy="14" r="6"/><path d="M6 31c2-6 7-9 12-9s10 3 12 9"/><path d="M27 6l4 4" stroke="#ff6a4d"/></svg>
          <h3>Your client never knows</h3><p>Confidential by default. Your branding, your bank details, your usual reminders.</p>
        </div>
        <div class="tcard">
          <svg viewBox="0 0 36 36" fill="none" stroke="#cfe3d6" stroke-width="1.8" aria-hidden="true"><rect x="6" y="6" width="24" height="24" rx="4"/><path d="M11 13h14M11 18h14M11 23h8"/><circle cx="25" cy="23" r="2.4" fill="#ff6a4d" stroke="none"/></svg>
          <h3>Every fee on paper</h3><p>Each advance comes with a one-page statement: amount, days, rate, fee. Exportable for your accountant.</p>
        </div>
      </div>
      <div class="flow" aria-label="Where the money goes">
        Money path: <span>Your client</span><i aria-hidden="true">→</i><span>Your account, in your name</span><i aria-hidden="true">→</i><span>Quire is repaid automatically</span>
      </div>
    </div>
  </div>
</section>

<section class="sec" id="pricing" aria-labelledby="pr-h">
  <div class="wrap">
    <div class="sec-head reveal">
      <span class="eyebrow">Pricing</span>
      <div>
        <h2 id="pr-h">Pay per invoice, or lower the rate with a plan.</h2>
        <p class="lead">Each card works out the fee on the same example: an €18,400 invoice on 60-day terms, paid on time.</p>
      </div>
    </div>
    <div class="bill reveal">
      <span id="lblM">Monthly</span>
      <button class="switch" role="switch" aria-checked="false" id="billSw" aria-labelledby="lblM lblY"></button>
      <span id="lblY">Yearly</span> <span class="save">2 months free</span>
    </div>
    <div class="plans reveal">
      <article class="plan">
        <div class="nm">Flex</div>
        <div class="price"><span>€0</span> <small>/ month</small></div>
        <p class="muted">For the odd slow-paying client.</p>
        <div class="rate">0.040% per day<br><span class="muted">Example fee: <b data-fee="flex"></b></span></div>
        <ul><li>Up to €50k advanced at once</li><li>Advance 90% next business day</li><li>Cancel by not using it</li></ul>
        <a class="btn ghost" href="#apply">Start on Flex</a>
      </article>
      <article class="plan feat">
        <div class="nm">Studio <span class="pill">Most agencies</span></div>
        <div class="price"><span data-price="studio">€39</span> <small data-per>/ month</small></div>
        <p class="muted">For teams of 5–25 with steady retainers.</p>
        <div class="rate">0.030% per day<br><span class="muted">Example fee: <b data-fee="studio"></b></span></div>
        <ul><li>Up to €200k advanced at once</li><li>Auto-advance chosen clients</li><li>Statements for your accountant</li></ul>
        <a class="btn coral" href="#apply">Choose Studio <span class="arr" aria-hidden="true">→</span></a>
      </article>
      <article class="plan">
        <div class="nm">Agency</div>
        <div class="price"><span data-price="agency">€119</span> <small data-per>/ month</small></div>
        <p class="muted">For networks and holding groups.</p>
        <div class="rate">0.022% per day<br><span class="muted">Example fee: <b data-fee="agency"></b></span></div>
        <ul><li>Up to €750k advanced at once</li><li>Multiple entities and currencies</li><li>A named person, not a queue</li></ul>
        <a class="btn ghost" href="#apply">Talk to us</a>
      </article>
    </div>
    <p class="fine" style="margin-top:16px">Illustrative example pricing for a fictional product.</p>
  </div>
</section>

<section class="sec" id="faq" aria-labelledby="faq-h">
  <div class="wrap faq">
    <div class="reveal faq-side"><span class="eyebrow">Questions</span><h2 id="faq-h" style="margin-top:16px">The fine print, in plain words.</h2><figure class="faq-fig grain"><img class="faq-img" src="assets/envelope.webp" width="1000" height="747" loading="lazy" alt="A sealed dark green envelope with a round coral sticker on textured cream paper."></figure></div>
    <div class="faq-list reveal">
      <details><summary>What happens if my client pays late?<span class="pm" aria-hidden="true"></span></summary><div class="ans"><p>The daily rate keeps running, so the fee grows a little each day, but it stops at 4% of the invoice. Try it in the fee calculator: the late-payment slider shows the cost of every extra day.</p></div></details>
      <details><summary>What if my client never pays?<span class="pm" aria-hidden="true"></span></summary><div class="ans"><p>After 90 days past due we talk about a plan. On Studio and Agency, approved clients can be covered by credit insurance, so the loss is not yours. On Flex you repay the advance over up to six months.</p></div></details>
      <details><summary>Does my client find out?<span class="pm" aria-hidden="true"></span></summary><div class="ans"><p>No. Invoices go out with your name and your bank details. Your client pays you exactly as before.</p></div></details>
      <details><summary>Do I have to finance every invoice?<span class="pm" aria-hidden="true"></span></summary><div class="ans"><p>No. You choose invoice by invoice. Plenty of agencies only use it for the one client on 90-day terms.</p></div></details>
      <details><summary>How big a limit can I get?<span class="pm" aria-hidden="true"></span></summary><div class="ans"><p>Usually around one and a half months of what you invoice, growing as your clients pay on time. The form below gives you an illustrative figure.</p></div></details>
      <details><summary>Is this a loan?<span class="pm" aria-hidden="true"></span></summary><div class="ans"><p>It is an advance against money you are already owed. It does not show up as a term loan, and nothing is owed until the invoice is paid, except in the rare case above.</p></div></details>
    </div>
  </div>
</section>

<section class="sec" id="apply" aria-labelledby="ap-h">
  <div class="wrap">
    <div class="apply reveal">
      <div>
        <span class="eyebrow">Check your limit</span>
        <h2 id="ap-h" style="margin-top:16px">See what you could draw, in a minute.</h2>
        <p class="lead">No credit check, no call booked unless you ask. This is a demo, so nothing is sent anywhere.</p>
      </div>
      <form class="ap" id="apForm" novalidate>
        <div class="inp" id="fEmail"><label for="email">Work email</label><input id="email" name="email" type="email" autocomplete="email" placeholder="you@studio.com" aria-describedby="eEmail"><p class="err" id="eEmail">Enter an email like name@studio.com.</p></div>
        <div class="inp" id="fName"><label for="agency">Agency name</label><input id="agency" name="agency" type="text" autocomplete="organization" placeholder="Fieldnote Studio" aria-describedby="eName"><p class="err" id="eName">Tell us what your agency is called.</p></div>
        <div class="inp" id="fVol"><label for="vol">What you invoice in a typical month</label>
          <select id="vol" name="vol" aria-describedby="eVol"><option value="">Choose a range</option><option value="20000">Under €30k</option><option value="50000">€30k – €75k</option><option value="110000">€75k – €150k</option><option value="220000">Over €150k</option></select>
          <p class="err" id="eVol">Pick a range so we can estimate.</p></div>
        <button class="btn" type="submit">See my limit <span class="arr" aria-hidden="true">→</span></button>
        <div class="ok" id="apOk" role="status" tabindex="-1"></div>
      </form>
    </div>
  </div>
</section>
</main>

<footer>
  <div class="wrap">
    <div class="ft">
      <div>
        <a class="logo" href="#top" aria-label="Quire, back to top">
          <svg viewBox="0 0 30 30" aria-hidden="true"><rect x="1" y="5" width="28" height="20" rx="5" fill="#cfe3d6"/><path class="flap" d="M3 7l12 9 12-9" fill="none" stroke="#ff6a4d" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/></svg>Quire</a>
        <p>Cash for the work you have already done. Built for studios and agencies of 2 to 200 people.</p>
      </div>
      <div><h4>Product</h4><ul><li><a href="#simulator">Simulator</a></li><li><a href="#fees">Fee calculator</a></li><li><a href="#pricing">Pricing</a></li></ul></div>
      <div><h4>Trust</h4><ul><li><a href="#how">How it works</a></li><li><a href="#security">Security</a></li><li><a href="#faq">FAQ</a></li></ul></div>
      <div><h4>Start</h4><ul><li><a href="#apply">Check your limit</a></li><li><a href="#top">Back to top ↑</a></li></ul></div>
    </div>
    <p class="word" aria-hidden="true">Quire</p>
    <div class="legal"><span>Quire is a fictional company made for a design demo. All rates, partners and figures are illustrative examples, not an offer of credit.</span><span>© 2026 Quire</span></div>
  </div>
</footer>

<script>
(()=>{
"use strict";
const $=(s,r=document)=>r.querySelector(s), $$=(s,r=document)=>[...r.querySelectorAll(s)];
const RM=matchMedia("(prefers-reduced-motion: reduce)");
let reduced=RM.matches; RM.addEventListener?.("change",e=>reduced=e.matches);
const clamp=(v,a,b)=>Math.min(b,Math.max(a,v));
const eo=t=>1-Math.pow(1-t,3);
const eio=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;
const seg=(p,a,b)=>clamp((p-a)/(b-a),0,1);
const fmtE=v=>{const n=Math.round(Math.abs(v));const s=String(n).replace(/\B(?=(\d{3})+(?!\d))/g,",");return (v<-0.5?"−":"")+"€"+s};
const fmtK=v=>{const a=Math.abs(v);const s=a>=1000?(Math.round(a/100)/10).toString().replace(/\.0$/,"")+"k":String(Math.round(a));return (v<0?"−":"")+"€"+s};
const fmtC=v=>"€"+v.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,",");

/* ---------- odometer ---------- */
function odo(el,text){
  if(!el) return;
  el.classList.add("odo");
  const sr=el.querySelector(".sr-only")||Object.assign(document.createElement("span"),{className:"sr-only"});
  sr.textContent=text;
  let vis=el.querySelector(".ov");
  const shape=text.replace(/\d/g,"0");
  if(!vis||vis.dataset.shape!==shape){
    const old=vis; vis=document.createElement("span"); vis.className="ov"; vis.setAttribute("aria-hidden","true"); vis.dataset.shape=shape; vis.style.display="inline-flex";
    for(const ch of text){
      if(/\d/.test(ch)){const d=document.createElement("span");d.className="od";const c=document.createElement("span");c.className="col";
        for(let i=0;i<10;i++){const s=document.createElement("span");s.textContent=i;c.appendChild(s)}d.appendChild(c);vis.appendChild(d)}
      else{const s=document.createElement("span");s.className="os";s.textContent=ch;vis.appendChild(s)}
    }
    if(old) old.replaceWith(vis); else {el.textContent="";el.appendChild(vis)}
    if(!sr.isConnected) el.appendChild(sr);
    const cols=$$(".col",vis), digits=text.replace(/\D/g,"");
    if(reduced){cols.forEach((c,i)=>{c.style.transition="none";c.style.transform=`translateY(${-digits[i]*1.1}em)`});return}
    void vis.offsetWidth;
    requestAnimationFrame(()=>cols.forEach((c,i)=>{c.style.transitionDelay=(i*40)+"ms";c.style.transform=`translateY(${-digits[i]*1.1}em)`}));
    return;
  }
  const digits=text.replace(/\D/g,"");
  $$(".col",vis).forEach((c,i)=>{c.style.transitionDelay=(i*30)+"ms";c.style.transform=`translateY(${-digits[i]*1.1}em)`});
}

/* ---------- header ---------- */
const top=$("#top"), nav=$("#nav"), mb=$(".menu-btn");
addEventListener("scroll",()=>top.classList.toggle("scrolled",scrollY>8),{passive:true});
function setMenu(o){nav.classList.toggle("open",o);mb.setAttribute("aria-expanded",o);mb.setAttribute("aria-label",o?"Close menu":"Open menu");if(o) nav.querySelector("a").focus()}
mb.addEventListener("click",()=>setMenu(!nav.classList.contains("open")));
nav.addEventListener("click",e=>{if(e.target.closest("a")) setMenu(false)});
addEventListener("keydown",e=>{if(e.key==="Escape"&&nav.classList.contains("open")){setMenu(false);mb.focus()}});
matchMedia("(min-width: 961px)").addEventListener?.("change",e=>{if(e.matches) setMenu(false)});

/* ---------- reveal ---------- */
const io=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting){e.target.classList.add("in");io.unobserve(e.target)}}),{rootMargin:"0px 0px -8% 0px"});
$$(".reveal").forEach(el=>io.observe(el));
$(".strike").style.setProperty("--s","0"); requestAnimationFrame(()=>$(".photo").classList.add("in")); requestAnimationFrame(()=>requestAnimationFrame(()=>$(".strike").style.setProperty("--s","1")));

/* ===================================================================
   CASH-FLOW SIMULATOR
   =================================================================== */
const W=12, START=21000, IN=7200, OUT=3600, PAYROLL=15200, ADV=.9;
const PLANS={flex:{rate:.0004,m:0,y:0,name:"Flex"},studio:{rate:.0003,m:39,y:32.5,name:"Studio"},agency:{rate:.00022,m:119,y:99.17,name:"Agency"}};
const feeFor=(amt,days,rate)=>Math.min(amt*.04,Math.max(25,amt*rate*days));
const INV=[
  {id:"0412",client:"Marlow Bikes",amt:18400,days:60,def:1},
  {id:"0415",client:"Tern Coffee",amt:12600,days:45,def:2},
  {id:"0419",client:"Northfold Labs",amt:24000,days:60,def:3},
  {id:"0423",client:"Pellmell Books",amt:7800,days:30,def:5},
];
const DEFAULT_PLACED={"0412":1,"0419":3};
const state={placed:{...DEFAULT_PLACED},preview:null};
const lagW=d=>Math.ceil(d/7);

function simulate(placed){
  const wo=[START],wi=[START],rows=[];let bo=START,bi=START,fees=0;
  for(let w=1;w<=W;w++){
    let base=IN-OUT-(w%2===0?PAYROLL:0),paid=0,adv=0,rest=0;
    for(const inv of INV){const iw=placed[inv.id];if(!iw) continue;const pw=iw+lagW(inv.days);const fee=feeFor(inv.amt,inv.days,PLANS.flex.rate);
      if(w===iw){adv+=inv.amt*ADV;fees+=fee}
      if(w===pw){paid+=inv.amt;rest+=inv.amt*(1-ADV)-fee}}
    bo+=base+paid; bi+=base+adv+rest; wo.push(bo); wi.push(bi);
    rows.push({w,paid,adv,bo,bi});
  }
  return {wo,wi,rows,fees};
}

const chart=$("#chart"), lane=$("#lane"), tray=$("#tray");
const el={woLine:$("#woLine"),wLine:$("#wLine"),wArea:$("#wArea"),odArea:$("#odArea"),zero:$("#zeroLine"),below:$("#belowRect"),grid:$("#grid"),ylabs:$("#ylabs"),epW:$("#epW"),epWo:$("#epWo"),badge:$("#odBadge")};
const show={w:true,wo:true};

/* week labels */
$("#weeks").innerHTML=Array.from({length:W},(_,i)=>`<span class="${(i+1)%2===0?"pay":""}">${innerWidth<560?i+1:"W"+(i+1)}</span>`).join("");

function niceDomain(arr){
  let lo=Math.min(0,...arr), hi=Math.max(...arr);
  const span=hi-lo||1; const step=span>120000?40000:span>60000?20000:10000;
  lo=Math.floor((lo-span*.1)/step)*step; hi=Math.ceil((hi+span*.16)/step)*step;
  return {lo,hi,step};
}
let cur=null, tw=null;
function target(){const s=simulate(state.preview?{...state.placed,...state.preview}:state.placed);
  const vis=[...(show.wo?s.wo:[]),...(show.w?s.wi:[])]; const d=niceDomain(vis.length?vis:[0,START]);
  return {wo:s.wo,wi:s.wi,lo:d.lo,hi:d.hi,step:d.step,sim:s};}
function lerp(a,b,t){return a+(b-a)*t}
function animateTo(t,dur=560){
  if(!cur||reduced||dur<=0){cur={...t};drawChart(cur);return}
  const from={wo:[...cur.wo],wi:[...cur.wi],lo:cur.lo,hi:cur.hi}; const t0=performance.now();
  cur.step=t.step;
  if(tw) cancelAnimationFrame(tw);
  const tick=now=>{const k=eo(clamp((now-t0)/dur,0,1));
    cur.wo=from.wo.map((v,i)=>lerp(v,t.wo[i],k)); cur.wi=from.wi.map((v,i)=>lerp(v,t.wi[i],k)); cur.lo=lerp(from.lo,t.lo,k); cur.hi=lerp(from.hi,t.hi,k);
    drawChart(cur); if(k<1) tw=requestAnimationFrame(tick); else tw=null};
  tw=requestAnimationFrame(tick);
}
const X=i=>i*100;
function drawChart(c){
  const H=300, Y=v=>H-(v-c.lo)/(c.hi-c.lo)*H;
  const line=a=>a.map((v,i)=>(i?"L":"M")+X(i)+" "+Y(v).toFixed(2)).join("");
  const z=Y(0);
  el.woLine.setAttribute("d",line(c.wo)); el.wLine.setAttribute("d",line(c.wi));
  el.wArea.setAttribute("d",line(c.wi)+`L1200 ${H} L0 ${H}Z`);
  el.odArea.setAttribute("d",line(c.wo)+`L1200 ${z} L0 ${z}Z`);
  el.below.setAttribute("y",z); el.below.setAttribute("height",Math.max(0,H-z));
  el.zero.setAttribute("y1",z); el.zero.setAttribute("y2",z);
  el.woLine.style.display=el.odArea.style.display=el.epWo.style.display=show.wo?"":"none";
  el.wLine.style.display=el.wArea.style.display=el.epW.style.display=show.w?"":"none";
  let g="",labs="";
  for(let v=Math.ceil(c.lo/c.step)*c.step; v<=c.hi; v+=c.step){
    const y=Y(v); if(y<2||y>H-2) continue;
    if(v!==0) g+=`<line x1="0" x2="1200" y1="${y}" y2="${y}" stroke="#e6ddcd" stroke-width="1" vector-effect="non-scaling-stroke"/>`;
    labs+=`<span class="ylab${v===0?" zero":""}" style="top:${y/H*100}%">${v===0?"€0":fmtK(v)}</span>`;
  }
  el.grid.innerHTML=g; el.ylabs.innerHTML=labs;
  el.epW.style.left="100%"; el.epW.style.top=(Y(c.wi[W])/H*100)+"%";
  el.epWo.style.left="100%"; el.epWo.style.top=(Y(c.wo[W])/H*100)+"%";
  el.epW.style.left=el.epWo.style.left="calc(100% - 7px)";
  el.badge.classList.toggle("on",show.wo&&Math.min(...c.wo)<0);
  if(readW) readout(readW);
}

/* stats + table */
let lastSig="";
function updateStats(s){
  const minO=Math.min(...s.wo), minW=Math.min(...s.wi);
  const wkO=s.wo.indexOf(minO), wkW=s.wi.indexOf(minW);
  const odO=s.wo.slice(1).filter(v=>v<0).length, odW=s.wi.slice(1).filter(v=>v<0).length;
  odo($("#stLoWo"),fmtE(minO)); $("#stLoWo").classList.toggle("neg",minO<0);
  odo($("#stLoW"),fmtE(minW)); $("#stLoW").classList.toggle("neg",minW<0);
  $("#stLoWoW").textContent=wkO?`end of week ${wkO}`:"at the start";
  $("#stLoWW").textContent=wkW?`end of week ${wkW}`:"at the start";
  odo($("#stOd"),`${odO} → ${odW}`);
  odo($("#stFee"),fmtE(s.fees));
  const n=Object.keys(state.placed).length;
  $("#stFeeS").textContent=n?`on ${n} invoice${n>1?"s":""}, Flex pricing`:"nothing scheduled";
  const sig=`${minO}|${minW}|${odO}|${odW}`;
  if(sig!==lastSig){lastSig=sig;$("#simLive").textContent=`Lowest balance without Quire ${fmtE(minO)}, with Quire ${fmtE(minW)}. Weeks overdrawn: ${odO} without, ${odW} with. Fees ${fmtE(s.fees)}.`}
  $("#tbody").innerHTML=s.rows.map(r=>`<tr><th scope="row">Week ${r.w}${r.w%2===0?" (payroll)":""}</th><td>${r.paid?fmtE(r.paid):"–"}</td><td>${r.adv?fmtE(r.adv):"–"}</td><td class="${r.bo<0?"neg":""}">${fmtE(r.bo)}</td><td class="${r.bi<0?"neg":""}">${fmtE(r.bi)}</td></tr>`).join("");
  chart.setAttribute("aria-label",`Cash balance chart. Lowest balance without Quire ${fmtE(minO)} in week ${wkO}; with Quire ${fmtE(minW)}.`);
}

/* lane + tray */
function renderLane(){
  const placed={...state.placed,...(state.preview||{})};
  lane.innerHTML=INV.map(inv=>{
    const w=placed[inv.id]; if(!w) return `<div class="lane-row" data-row="${inv.id}"></div>`;
    const len=lagW(inv.days), end=w+len, span=Math.min(len,W-w+1), open=end>W;
    const dueTxt=open?`wk ${end} →`:`paid wk ${end}`;
    return `<div class="lane-row" data-row="${inv.id}"><button type="button" class="bar${open?" open":""}${state.preview&&state.preview[inv.id]?" dragging":""}" data-id="${inv.id}" style="grid-column:${w} / span ${span}" aria-label="Invoice ${inv.id}, ${inv.client}, ${fmtE(inv.amt)}, sent week ${w}, client pays ${open?"after the 12 weeks, week "+end:"week "+end}. Arrow keys move it, Delete removes it."><span class="adv">90%</span><span class="nm">${inv.client} · ${fmtK(inv.amt)}</span><span class="due">${dueTxt}</span></button></div>`;
  }).join("") + (Object.keys(placed).length?"":`<div class="lane-empty">Drop invoices here</div>`);
}
function renderTray(){
  tray.innerHTML=INV.map(inv=>{const w=state.placed[inv.id];
    return `<button type="button" class="chip" data-id="${inv.id}" aria-pressed="${!!w}" aria-label="${inv.client}, ${fmtE(inv.amt)}, net ${inv.days}. ${w?"Scheduled in week "+w+". Press to take it off the timeline.":"Not scheduled. Press to send it in week "+inv.def+", or drag it onto a week."}">
      <span class="row1"><span>INV-${inv.id}</span><span class="st">${w?"Week "+w:"Not sent"}</span></span>
      <span class="nm">${inv.client}</span><span class="amt">${fmtE(inv.amt)}</span> <span class="terms">net ${inv.days}</span></button>`}).join("");
}
function refresh(dur){renderLane();if(!state.preview) renderTray();const t=target();animateTo(t,dur);updateStats(t.sim)}

/* keyboard / click */
tray.addEventListener("click",e=>{const c=e.target.closest(".chip");if(!c||suppressClick) return;const id=c.dataset.id;
  if(state.placed[id]) delete state.placed[id]; else {state.placed[id]=INV.find(i=>i.id===id).def;setTimeout(()=>cashBurst(state.placed[id],18),200)}
  refresh(); tray.querySelector(`[data-id="${id}"]`)?.focus()});
lane.addEventListener("keydown",e=>{const b=e.target.closest(".bar");if(!b) return;const id=b.dataset.id;let w=state.placed[id];
  if(e.key==="ArrowLeft"||e.key==="ArrowRight"){e.preventDefault();w=clamp(w+(e.key==="ArrowRight"?1:-1),1,W);state.placed[id]=w;refresh(380);cashBurst(w,8);lane.querySelector(`[data-id="${id}"]`)?.focus()}
  else if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault();delete state.placed[id];refresh();tray.querySelector(`[data-id="${id}"]`)?.focus()}
  else if(e.key==="Home"||e.key==="End"){e.preventDefault();state.placed[id]=e.key==="Home"?1:W;refresh(380);lane.querySelector(`[data-id="${id}"]`)?.focus()}});
$("#allBtn").addEventListener("click",()=>{INV.forEach(i=>{if(!state.placed[i.id]) state.placed[i.id]=i.def});refresh(800)});
$("#resetBtn").addEventListener("click",()=>{state.placed={...DEFAULT_PLACED};refresh(800)});
$("#showWith").addEventListener("change",e=>{show.w=e.target.checked;refresh()});
$("#showWo").addEventListener("change",e=>{show.wo=e.target.checked;refresh()});

/* pointer drag */
let drag=null, suppressClick=false;
function weekFromX(x,offX){const r=lane.getBoundingClientRect();const colW=r.width/W;return clamp(Math.round((x-offX-r.left)/colW)+1,1,W)}
function overRect(elm,x,y,pad=0){const r=elm.getBoundingClientRect();return x>=r.left-pad&&x<=r.right+pad&&y>=r.top-pad&&y<=r.bottom+pad}
function startDrag(e,src){
  if(e.button!==undefined&&e.button!==0) return;
  const id=src.dataset.id, inv=INV.find(i=>i.id===id), r=src.getBoundingClientRect();
  const fromLane=src.classList.contains("bar");
  drag={id,inv,sx:e.clientX,sy:e.clientY,offX:fromLane?e.clientX-r.left:Math.min(30,e.clientX-r.left),moved:false,fromLane,pid:e.pointerId,ghost:null};
  src.setPointerCapture?.(e.pointerId);
}
function moveDrag(e){
  if(!drag||e.pointerId!==drag.pid) return;
  const dx=e.clientX-drag.sx, dy=e.clientY-drag.sy;
  if(!drag.moved&&Math.hypot(dx,dy)<6) return;
  if(!drag.moved){drag.moved=true;const g=document.createElement("div");g.className="dghost";g.innerHTML=`${drag.inv.client} · ${fmtK(drag.inv.amt)}<small>net ${drag.inv.days} · drop on a week</small>`;document.body.appendChild(g);drag.ghost=g;document.body.style.cursor="grabbing"}
  drag.ghost.style.left=e.clientX+"px"; drag.ghost.style.top=(e.clientY-26)+"px";
  const over=overRect(lane,e.clientX,e.clientY,24);
  lane.classList.toggle("over",over);
  const pw=over?weekFromX(e.clientX,drag.offX):null;
  const prevKey=JSON.stringify(state.preview);
  if(over){state.preview={[drag.id]:pw}; drag.ghost.querySelector("small").textContent=`send in week ${pw} · client pays week ${pw+lagW(drag.inv.days)}`}
  else{state.preview=null; const p={...state.placed}; if(drag.fromLane) delete p[drag.id]; state.preview=drag.fromLane?{[drag.id]:0}:null; drag.ghost.querySelector("small").textContent=drag.fromLane?"release to take it off":"net "+drag.inv.days+" · drop on a week"}
  if(JSON.stringify(state.preview)!==prevKey) previewRefresh();
}
function previewRefresh(){
  // preview value 0 = removed
  const merged={...state.placed}; if(state.preview) for(const k in state.preview){if(state.preview[k]) merged[k]=state.preview[k]; else delete merged[k]}
  const saved=state.placed, savedPrev=state.preview; state.placed=merged; state.preview=null;
  renderLane(); const t=target(); state.placed=saved; state.preview=savedPrev;
  lane.querySelector(`[data-id="${drag.id}"]`)?.classList.add("dragging");
  animateTo(t,300); updateStats(t.sim);
  const pv=state.preview&&state.preview[drag.id]; if(pv) cashBurst(pv,7);
}
function endDrag(e){
  if(!drag||e.pointerId!==drag.pid) return;
  const d=drag; drag=null; lane.classList.remove("over"); document.body.style.cursor="";
  if(d.ghost) d.ghost.remove();
  if(d.moved){
    suppressClick=true; setTimeout(()=>suppressClick=false,0);
    if(overRect(lane,e.clientX,e.clientY,24)){const w=weekFromX(e.clientX,d.offX);state.placed[d.id]=w;setTimeout(()=>cashBurst(w,24),120);heroRipple(e.clientX,e.clientY)}
    else if(d.fromLane) delete state.placed[d.id];
    state.preview=null; refresh(420);
  }
}
for(const host of [tray,lane]){
  host.addEventListener("pointerdown",e=>{const s=e.target.closest(".chip,.bar");if(s) startDrag(e,s)});
}
addEventListener("pointermove",moveDrag); addEventListener("pointerup",endDrag);
addEventListener("pointercancel",e=>{if(drag){drag.ghost?.remove();drag=null;state.preview=null;lane.classList.remove("over");refresh()}});
lane.addEventListener("click",e=>{if(suppressClick) e.preventDefault()},true);
tray.addEventListener("click",e=>{if(suppressClick){e.stopImmediatePropagation()}},true);

/* ===================================================================
   AMBIENT LAYER 1: cash flowing along the With-Quire line
   =================================================================== */
const fc=document.createElement("canvas"); fc.className="cashflow"; fc.setAttribute("aria-hidden","true");
chart.insertBefore(fc,$("#ylabs"));
const fx=fc.getContext("2d");
let fW=0,fH=0,fVis=false,fRaf=0,fLast=0;
function fSize(){const d=Math.min(2,devicePixelRatio||1);fW=chart.clientWidth;fH=chart.clientHeight;fc.width=Math.round(fW*d);fc.height=Math.round(fH*d);fx.setTransform(d,0,0,d,0,0)}
const valAt=(arr,f)=>{const k=clamp(f,0,1)*W, i=Math.min(W-1,Math.floor(k));return lerp(arr[i],arr[i+1],k-i)};
const yOf=v=>fH*(1-(v-cur.lo)/(cur.hi-cur.lo));
const FLOW_N=70;
const parts=Array.from({length:FLOW_N},(_,i)=>({s:i/FLOW_N,sp:.04+Math.random()*.05,ph:Math.random()*6.283,off:1+Math.random()*4,r:1.3+Math.random()*1.9}));
const sparks=[], rings=[], fm={x:-999,y:-999,on:false};
chart.addEventListener("pointermove",e=>{const r=chart.getBoundingClientRect();fm.x=e.clientX-r.left;fm.y=e.clientY-r.top;fm.on=true});
chart.addEventListener("pointerleave",()=>{fm.on=false});
function cashBurst(week,n=16){
  if(reduced||!cur||!week) return;
  const f=week/W, x=f*fW-(week===W?7:0), y=yOf(valAt(cur.wi,f));
  for(let i=0;i<n;i++){const a=-Math.PI/2+(Math.random()-.5)*1.7, v=70+Math.random()*130;
    sparks.push({x,y,vx:Math.cos(a)*v,vy:Math.sin(a)*v,life:1,r:1.4+Math.random()*2.2,c:Math.random()<.22?"#ff6a4d":"#2f6b53"})}
  rings.push({x,y,t:0,small:0}); ensureFlow();
}
function ensureFlow(){if(!fRaf&&fVis&&!document.hidden&&!reduced){fLast=performance.now();fRaf=requestAnimationFrame(fFrame)}}
function fFrame(now){
  fRaf=0; const dt=Math.min(.05,(now-fLast)/1000); fLast=now;
  fx.clearRect(0,0,fW,fH);
  if(cur){
    if(show.w){
      for(const p of parts){
        p.s+=p.sp*dt; if(p.s>1){p.s-=1; if(Math.random()<.3) rings.push({x:fW-7,y:yOf(cur.wi[W]),t:0,small:1})}
        let x=p.s*fW, y=yOf(valAt(cur.wi,p.s))+Math.sin(now*.002+p.ph)*p.off-3, r=p.r, a=Math.min(1,p.s*14,(1-p.s)*30)*.7;
        if(fm.on&&!drag){const dx=x-fm.x, dy=y-fm.y, d=Math.hypot(dx,dy)||1; if(d<80){const k=1-d/80; y+=dy/d*k*18; x+=dx/d*k*6; r*=1+k*1.3; a=Math.min(1,a+k*.5)}}
        fx.globalAlpha=a; fx.fillStyle="#1d4d3c"; fx.beginPath(); fx.arc(x,y,r,0,6.283); fx.fill();
        fx.globalAlpha=a*.9; fx.fillStyle="#cfe3d6"; fx.beginPath(); fx.arc(x-r*.3,y-r*.3,r*.36,0,6.283); fx.fill();
      }
    }
    if(show.wo&&Math.random()<dt*9){const f=Math.random(), v=valAt(cur.wo,f); if(v<0) sparks.push({x:f*fW,y:yOf(v),vx:0,vy:10+Math.random()*14,life:1,r:1+Math.random()*1.2,c:"#b23d1d",drip:1})}
  }
  for(let i=sparks.length-1;i>=0;i--){const s=sparks[i]; s.life-=dt*(s.drip?.55:1.1); if(s.life<=0){sparks.splice(i,1);continue}
    if(!s.drip) s.vy+=240*dt; s.x+=s.vx*dt; s.y+=s.vy*dt; fx.globalAlpha=s.life*.85; fx.fillStyle=s.c; fx.beginPath(); fx.arc(s.x,s.y,s.r,0,6.283); fx.fill()}
  for(let i=rings.length-1;i>=0;i--){const g=rings[i]; g.t+=dt*(g.small?1.3:1.1); if(g.t>=1){rings.splice(i,1);continue}
    fx.globalAlpha=(1-g.t)*.55; fx.strokeStyle="#2f6b53"; fx.lineWidth=1.5; fx.beginPath(); fx.arc(g.x,g.y,(g.small?5:6)+eo(g.t)*(g.small?14:38),0,6.283); fx.stroke()}
  fx.globalAlpha=1;
  ensureFlow();
}
new IntersectionObserver(es=>{fVis=es[0].isIntersecting; ensureFlow()}).observe(chart);

/* ===================================================================
   AMBIENT LAYER 2: hero halftone field (wave + cursor trail + ripples)
   =================================================================== */
const heroEl=$(".hero"), hc=document.createElement("canvas"); hc.className="field"; hc.setAttribute("aria-hidden","true"); heroEl.prepend(hc);
const hx=hc.getContext("2d"), PITCH=22, TRAIL_MS=900, LENS=120, trail=[], ripples=[];
let hW=0,hH=0,hVis=false,hRaf=0,simBox=null,pc={x:300,y:300};
const fine=matchMedia("(hover:hover) and (pointer:fine)");
function hSize(){const d=Math.min(1.25,devicePixelRatio||1);hW=heroEl.clientWidth;const st=$("#simulator").getBoundingClientRect().top-heroEl.getBoundingClientRect().top;hH=Math.min(heroEl.clientHeight,Math.max(200,st+140));hc.style.height=hH+"px";hc.width=Math.round(hW*d);hc.height=Math.round(hH*d);hx.setTransform(d,0,0,d,0,0);
  const hr=heroEl.getBoundingClientRect(), h1r=$("#h1").getBoundingClientRect(); pc={x:h1r.left-hr.left+h1r.width*.42,y:h1r.top-hr.top+h1r.height*.52};
  const sr=$("#simulator").getBoundingClientRect(); simBox={l:sr.left-hr.left+8,r:sr.right-hr.left-8,t:sr.top-hr.top+8,b:sr.bottom-hr.top-8};
  if(reduced) hDraw(0)}
heroEl.addEventListener("pointermove",e=>{if(!fine.matches||drag) return;const r=heroEl.getBoundingClientRect();trail.push({x:e.clientX-r.left,y:e.clientY-r.top,t:performance.now()});if(trail.length>28) trail.shift()});
heroEl.addEventListener("pointerdown",e=>{if(e.target.closest("a,button,input,label,summary,details,.sim,figure")) return; heroRipple(e.clientX,e.clientY)});
function heroRipple(cx,cy){if(reduced) return;const r=heroEl.getBoundingClientRect();ripples.push({x:cx-r.left,y:cy-r.top,t:performance.now()})}
function hDraw(now){
  hx.clearRect(0,0,hW,hH);
  const tr=trail.filter(p=>now-p.t<TRAIL_MS);
  for(let i=ripples.length-1;i>=0;i--) if(now-ripples[i].t>1700) ripples.splice(i,1);
  const sb=simBox, AQ=10, COLS=["20,38,31","47,107,83","255,106,77"], B=COLS.map(()=>Array.from({length:AQ},()=>new Path2D()));
  for(let y=PITCH/2;y<hH;y+=PITCH){
    for(let x=PITCH/2;x<hW;x+=PITCH){
      if(sb&&x>sb.l&&x<sb.r&&y>sb.t&&y<sb.b) continue;
      const w=reduced?.4:Math.sin((x*.55+y)*.011-now*.0011)*.5+.5;
      let k=0, rk=0, pk=0; const d0=Math.hypot(x-pc.x,y-pc.y), halo=Math.max(0,1-d0/640);
      if(!reduced) for(let j=0;j<2;j++){const R=((now/1000+j*1.6)%3.2)*230, dd=Math.abs(d0-R); if(dd<54){const v=(1-dd/54)*Math.max(0,1-R/736); if(v>pk) pk=v}}
      for(const p of tr){const dx=x-p.x, dy=y-p.y; if(dx>LENS||dx<-LENS||dy>LENS||dy<-LENS) continue; const d=Math.hypot(dx,dy); if(d<LENS){const v=(1-d/LENS)*(1-(now-p.t)/TRAIL_MS); if(v>k) k=v}}
      for(const q of ripples){const age=(now-q.t)/1000, d=Math.abs(Math.hypot(x-q.x,y-q.y)-age*560); if(d<36){const v=(1-d/36)*(1-age/1.7); if(v>rk) rk=v}}
      const r=.9+w*.45+halo*halo*1.7+pk*1.9+k*2.6+rk*2.4, a=.05+w*.045+halo*.1+pk*.3+k*.42+rk*.5;
      const ci=rk>k&&rk>.12?2:(k>.08||pk>.18)?1:0, ai=Math.min(AQ-1,Math.round(a*AQ*1.4));
      const path=B[ci][ai]; path.moveTo(x+r,y); path.arc(x,y,r,0,6.283);
    }
  }
  for(let c=0;c<3;c++) for(let i=0;i<AQ;i++){hx.fillStyle=`rgba(${COLS[c]},${(i+.5)/(AQ*1.4)})`; hx.fill(B[c][i])}
}
let hLast=0;
function hFrame(now){hRaf=0; if(now-hLast>30){hLast=now; hDraw(now)} if(hVis&&!document.hidden&&!reduced) hRaf=requestAnimationFrame(hFrame)}
function ensureField(){if(!hRaf&&hVis&&!document.hidden&&!reduced) hRaf=requestAnimationFrame(hFrame)}
new IntersectionObserver(es=>{hVis=es[0].isIntersecting; ensureField()}).observe(heroEl);
document.addEventListener("visibilitychange",()=>{ensureFlow();ensureField()});
RM.addEventListener?.("change",()=>{hSize();ensureFlow();ensureField()});
addEventListener("resize",()=>{fSize();hSize()});
fSize(); hSize();

/* readout */
let readW=0; const ro=$("#readout"), vg=$("#vguide");
function readout(w){
  if(!cur) return; readW=w; const s=simulate(state.placed);
  const x=(w/W)*100; vg.style.left=x+"%"; vg.classList.add("on");
  ro.innerHTML=`<b>END OF WEEK ${w}${w%2===0?" · PAYROLL":""}</b>${show.w?`<div><span>With Quire</span><span>${fmtE(s.wi[w])}</span></div>`:""}${show.wo?`<div><span>Without</span><span>${fmtE(s.wo[w])}</span></div>`:""}`;
  ro.classList.add("on");
  const cw=chart.clientWidth, rw=ro.offsetWidth; let left=x/100*cw+12; if(left+rw>cw-8) left=x/100*cw-rw-12; ro.style.left=clamp(left,8,cw-rw-8)+"px";
}
function hideReadout(){readW=0;ro.classList.remove("on");vg.classList.remove("on")}
chart.addEventListener("pointermove",e=>{if(drag) return;const r=chart.getBoundingClientRect();readout(clamp(Math.round((e.clientX-r.left)/r.width*W),1,W))});
chart.addEventListener("pointerleave",hideReadout);
chart.addEventListener("blur",hideReadout);
chart.addEventListener("focus",()=>readout(readW||1));
chart.addEventListener("keydown",e=>{if(e.key==="ArrowRight"||e.key==="ArrowLeft"){e.preventDefault();readout(clamp((readW||1)+(e.key==="ArrowRight"?1:-1),1,W));
  const s=simulate(state.placed);$("#simLive").textContent=`Week ${readW}: with Quire ${fmtE(s.wi[readW])}, without ${fmtE(s.wo[readW])}.`}});
addEventListener("resize",()=>{if(readW) readout(readW)});

refresh();

/* ===================================================================
   FEE CALCULATOR
   =================================================================== */
const amt=$("#amt"), late=$("#late");
function rangeFill(r){r.style.setProperty("--p",((r.value-r.min)/(r.max-r.min)*100)+"%")}
function calc(){
  const A=+amt.value, terms=+$('input[name="terms"]:checked').value, L=+late.value, plan=$('input[name="plan"]:checked').value;
  const days=terms+L, P=PLANS[plan], raw=A*P.rate*days, fee=feeFor(A,days,P.rate);
  const adv=A*ADV, rest=A-adv-fee;
  $("#amtO").textContent=fmtE(A); $("#lateO").textContent=L?`${L} day${L>1?"s":""}`:"on time";
  amt.setAttribute("aria-valuetext",fmtE(A)); late.setAttribute("aria-valuetext",L?L+" days late":"on time");
  odo($("#cAdv"),fmtE(adv)); odo($("#cRest"),fmtE(rest));
  $("#cRestW").textContent=`about ${days} days from now, minus the fee`;
  $("#sA").style.flexGrow=adv; $("#sB").style.flexGrow=Math.max(0,rest); $("#sC").style.flexGrow=fee;
  $("#cDays").textContent=`${days} (${terms} terms + ${L} late)`;
  $("#cRate").textContent=`${(P.rate*100).toFixed(3)}% on ${P.name}`;
  $("#cFee").textContent=fmtC(fee); $("#cPct").textContent=(fee/A*100).toFixed(2)+"%";
  let note=""; if(fee>raw+.001) note=" → minimum €25 applies"; else if(fee<raw-.001) note=` → capped at 4% (${fmtC(A*.04)})`;
  $("#cFormula").textContent=`${fmtE(A)} × ${(P.rate*100).toFixed(3)}% × ${days} days = ${fmtC(raw)}${note}`;
  [amt,late].forEach(rangeFill);
}
$("#calcForm").addEventListener("input",calc); calc();

/* pricing */
const sw=$("#billSw");
function priceFees(){$$("[data-fee]").forEach(b=>{const P=PLANS[b.dataset.fee];b.textContent=fmtC(feeFor(18400,60,P.rate))})}
function billing(y){sw.setAttribute("aria-checked",y);
  $("[data-price=studio]").textContent="€"+(y?32.5:39).toString().replace(".5",".50");
  $("[data-price=agency]").textContent="€"+(y?99:119);
  $$("[data-per]").forEach(s=>s.textContent=y?"/ month, billed yearly":"/ month");}
sw.addEventListener("click",()=>billing(sw.getAttribute("aria-checked")!=="true"));
priceFees();

/* faq: smooth open/close */
$$(".faq details").forEach(d=>{const s=d.querySelector("summary"),a=d.querySelector(".ans");
  s.addEventListener("click",e=>{if(reduced) return;e.preventDefault();
    if(d.open){const h=a.scrollHeight;a.animate([{height:h+"px",opacity:1},{height:"0px",opacity:0}],{duration:320,easing:"cubic-bezier(.2,.8,.2,1)"}).onfinish=()=>d.open=false}
    else{d.open=true;const h=a.scrollHeight;a.animate([{height:"0px",opacity:0},{height:h+"px",opacity:1}],{duration:380,easing:"cubic-bezier(.2,.8,.2,1)"})}})});

/* apply form */
$("#apForm").addEventListener("submit",e=>{e.preventDefault();
  const em=$("#email"), ag=$("#agency"), vo=$("#vol"); let first=null;
  const chk=(wrap,ok,inp)=>{if(ok){wrap.removeAttribute("data-err");inp.removeAttribute("aria-invalid")}else{wrap.setAttribute("data-err","");inp.setAttribute("aria-invalid","true");first=first||inp}};
  chk($("#fEmail"),/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(em.value.trim()),em);
  chk($("#fName"),ag.value.trim().length>1,ag);
  chk($("#fVol"),!!vo.value,vo);
  const ok=$("#apOk");
  if(first){ok.classList.remove("on");first.focus();return}
  const lim=Math.round(+vo.value*1.5/5000)*5000;
  ok.innerHTML=`<b>${ag.value.trim().replace(/[<>&]/g,"")}</b>: agencies invoicing in that range typically start around <b>${fmtE(lim)}</b> of available limit. Illustrative only. This demo did not send anything.`;
  ok.classList.add("on"); ok.focus();
});
$$("#apForm input,#apForm select").forEach(i=>i.addEventListener("input",()=>i.closest(".inp").removeAttribute("data-err")));

/* ===================================================================
   HOW IT WORKS: scroll-scrubbed fold & travel
   =================================================================== */
const track=$("#howTrack"), stage=$("#stage"), box=$("#stageBox"), pkg=$("#pkg"), steps=$$(".step"), rail=$(".steps .rail");
const p1=$("#p1"),p3=$("#p3"),stamp=$("#stamp"),env=$("#env"),flap=$("#flap"),bank=$("#bank"),checks=$$("#checks div"),lns=$$(".doc .ln");
const trailPath=$("#trailPath"); const trailLen=trailPath.getTotalLength(); trailPath.style.strokeDasharray="4 7";
let bankShown=null, howVisible=false, howRaf=0;
function fitStage(){const s=Math.min(1,box.clientWidth/640,box.clientHeight/440);stage.style.transform=`translate(-50%,-50%) scale(${s})`}
function howProgress(){const r=track.getBoundingClientRect();const total=r.height-innerHeight;return clamp(-r.top/Math.max(1,total),0,1)}
const SNAP=[.18,.42,.7,1];
function renderHow(){
  howRaf=0;
  let p=howProgress();
  const stepI=p<.24?0:p<.46?1:p<.74?2:3;
  if(reduced) p=SNAP[stepI];
  window.__howP=p;
  steps.forEach((s,i)=>{s.classList.toggle("on",i===stepI);s.classList.toggle("done",i<stepI)});
  rail.style.setProperty("--p",p);
  // 1: doc in, lines draw
  const a=eo(seg(p,0,.16));
  lns.forEach((l,i)=>l.style.setProperty("--k",eo(seg(p,.02+i*.02,.12+i*.02))));
  // 2: checks + stamp
  checks.forEach((c,i)=>c.style.setProperty("--o",eo(seg(p,.26+i*.04,.32+i*.04))*(1-seg(p,.62,.7))));
  const st=seg(p,.34,.42); stamp.style.setProperty("--sc",st?1+(1-eo(st))*.8:0); stamp.style.setProperty("--o",st?Math.min(1,st*2):0);
  // 3: fold
  const f3=eio(seg(p,.48,.57)), f1=eio(seg(p,.56,.65));
  p3.style.transform=`rotateX(${f3*180}deg) translateZ(${f3*1}px)`;
  p1.style.transform=`rotateX(${-f1*180}deg) translateZ(${f1*2}px)`;
  const e=seg(p,.64,.68); env.style.opacity=e;
  flap.style.transform=`rotateX(${(1-eio(seg(p,.67,.73)))*180}deg)`;
  $("#doc").style.opacity=1-seg(p,.66,.69);
  // 4: travel
  const tr=eio(seg(p,.76,.92));
  const pt=trailPath.getPointAtLength(trailLen*tr);
  const sx=pt.x-180, sy=pt.y-214;
  const sc=1-.55*tr;
  pkg.style.opacity=a*(1-seg(p,.9,.94));
  pkg.style.transform=`translate(${sx}px,${sy+(1-a)*40}px) scale(${sc}) rotate(${Math.sin(tr*Math.PI)*-6}deg)`;
  trailPath.style.opacity=.35+.65*seg(p,.72,.78);
  const landed=p>=.92;
  if(landed!==bankShown){bankShown=landed;odo($("#bankV"),landed?"€20,340":"€3,780");bank.classList.toggle("hit",landed);bank.style.setProperty("--txo",landed?1:0)}
}
function onScrollHow(){if(howVisible&&!howRaf) howRaf=requestAnimationFrame(renderHow)}
new IntersectionObserver(es=>{howVisible=es[0].isIntersecting;if(howVisible) onScrollHow()},{rootMargin:"20% 0px"}).observe(track);
addEventListener("scroll",onScrollHow,{passive:true});
addEventListener("resize",()=>{fitStage();onScrollHow()});
fitStage(); renderHow();
document.fonts?.ready.then(()=>{refresh(0);fSize();hSize()});
})();
</script>
<script type="importmap">{"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"}}</script>
<script type="module">
/* ===================================================================
   HOW IT WORKS in real 3D: a paper invoice tri-folds into an envelope
   (three.js r160). The CSS 3D version above stays as the fallback.
   =================================================================== */
import * as THREE from "three";
import {RoomEnvironment} from "three/addons/environments/RoomEnvironment.js";
const stage=document.getElementById("stage"), track=document.getElementById("howTrack");
const RM=matchMedia("(prefers-reduced-motion: reduce)");
const clamp=(v,a,b)=>Math.min(b,Math.max(a,v)), seg=(p,a,b)=>clamp((p-a)/(b-a),0,1);
const eo=t=>1-Math.pow(1-t,3), eio=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;
const DW=640, DH=440;
let renderer=null;
try{
  const probe=document.createElement("canvas");
  if(probe.getContext("webgl2")||probe.getContext("webgl")) renderer=new THREE.WebGLRenderer({antialias:true,alpha:true,powerPreference:"low-power"});
}catch(e){renderer=null}
if(renderer){ document.fonts.ready.then(()=>{try{init()}catch(e){console.warn("3D fold disabled:",e);stage.classList.remove("gl-on");renderer.domElement.remove()}}) }

function paperCanvas(w,h,draw){const c=document.createElement("canvas");c.width=w;c.height=h;const g=c.getContext("2d");draw(g,w,h);const t=new THREE.CanvasTexture(c);t.colorSpace=THREE.SRGBColorSpace;t.anisotropy=8;return t}
function fibres(g,w,h,n,col){g.fillStyle=col;for(let i=0;i<n;i++){g.globalAlpha=Math.random()*.06;g.fillRect(Math.random()*w,Math.random()*h,1+Math.random()*2,1)}g.globalAlpha=1}

function init(){
  renderer.setPixelRatio(Math.min(2,devicePixelRatio||1)); renderer.setSize(DW,DH,false);
  renderer.outputColorSpace=THREE.SRGBColorSpace; renderer.toneMapping=THREE.ACESFilmicToneMapping; renderer.toneMappingExposure=.92;
  renderer.shadowMap.enabled=true; renderer.shadowMap.type=THREE.PCFShadowMap;
  const cv=renderer.domElement; cv.className="gl"; cv.setAttribute("aria-hidden","true");
  const scene=new THREE.Scene();
  const pm=new THREE.PMREMGenerator(renderer); scene.environment=pm.fromScene(new RoomEnvironment(),.04).texture; pm.dispose();
  const cam=new THREE.PerspectiveCamera(28,DW/DH,.1,60); cam.position.set(0,8.1,3.5); cam.lookAt(0,0,.15); cam.updateMatrixWorld(true);
  const key=new THREE.DirectionalLight(0xfff1dc,2.3); key.position.set(-3.5,8,2.6); key.castShadow=true;
  key.shadow.mapSize.set(1024,1024); key.shadow.radius=5; key.shadow.bias=-.0005; key.shadow.normalBias=.02;
  Object.assign(key.shadow.camera,{left:-6,right:6,top:5,bottom:-5,near:1,far:20}); scene.add(key);
  const rim=new THREE.DirectionalLight(0xd8efe2,.7); rim.position.set(4,3,-4); scene.add(rim);
  scene.add(new THREE.HemisphereLight(0xfffaf0,0xcabda6,.45));
  const ground=new THREE.Mesh(new THREE.PlaneGeometry(40,40),new THREE.ShadowMaterial({opacity:.2,color:0x14261f}));
  ground.rotation.x=-Math.PI/2; ground.receiveShadow=true; scene.add(ground);

  /* --- invoice sheet: 2.4 x 3.3, tri-fold creases at z = -0.55 / +0.55 --- */
  const SW=2.4, SH=3.3, C1=-.55, C2=.55;
  const inv=paperCanvas(768,1056,(g,w,h)=>{
    g.fillStyle="#fffdf8";g.fillRect(0,0,w,h);fibres(g,w,h,5000,"#7a6a50");
    const serif='"Fraunces",Georgia,serif', mono='"JetBrains Mono",ui-monospace,monospace';
    g.fillStyle="#2b3d35";g.font=`500 26px ${mono}`;g.fillText("INVOICE · INV-0412 · NET 60",56,76);
    g.fillStyle="#0c1a14";g.font=`500 84px ${serif}`;g.fillText("Marlow Bikes",50,176);
    g.fillStyle="#e9e1d2";g.fillRect(56,206,300,14);g.fillRect(56,236,200,14);
    g.fillStyle="#1d4d3c";g.font=`500 20px ${mono}`;g.fillText("FROM FIELDNOTE STUDIO",56,300);
    const rows=[["Brand system","€11,200"],["Launch site","€5,600"],["Art direction","€1,600"]];
    g.font=`500 32px ${mono}`;rows.forEach((r,i)=>{const y=430+i*66;g.fillStyle="#14261f";g.fillText(r[0],56,y);g.textAlign="right";g.fillText(r[1],w-56,y);g.textAlign="left";g.fillStyle="#efe8dc";g.fillRect(56,y+22,w-112,2)});
    g.fillStyle="#e9e1d2";g.fillRect(56,650,420,14);
    g.fillStyle="#14261f";g.fillRect(56,770,w-112,4);
    g.font=`500 28px ${mono}`;g.fillStyle="#2b3d35";g.fillText("TOTAL DUE",56,850);
    g.font=`500 92px ${serif}`;g.fillStyle="#0c1a14";g.textAlign="right";g.fillText("€18,400",w-56,866);g.textAlign="left";
    g.fillStyle="#e9e1d2";g.fillRect(56,920,330,12);g.fillRect(56,946,220,12);
    g.setLineDash([6,10]);g.strokeStyle="rgba(20,38,31,.12)";g.lineWidth=2;[352,704].forEach(y=>{g.beginPath();g.moveTo(0,y);g.lineTo(w,y);g.stroke()});
  });
  const back=paperCanvas(256,352,(g,w,h)=>{g.fillStyle="#f4efe5";g.fillRect(0,0,w,h);fibres(g,w,h,1800,"#6b5c44")});
  const geo=new THREE.PlaneGeometry(SW,SH,20,66); geo.rotateX(-Math.PI/2);
  const rest=geo.attributes.position.array.slice();
  const paperF=new THREE.MeshStandardMaterial({map:inv,roughness:.92,metalness:0,side:THREE.FrontSide});
  const paperB=new THREE.MeshStandardMaterial({map:back,roughness:.95,metalness:0,side:THREE.BackSide});
  const sheet=new THREE.Group();
  const mF=new THREE.Mesh(geo,paperF), mB=new THREE.Mesh(geo,paperB);
  [mF,mB].forEach(m=>{m.castShadow=true;m.receiveShadow=true;sheet.add(m)});
  // stamp decal on the middle panel
  const stampT=paperCanvas(256,256,(g)=>{g.translate(128,128);g.rotate(-.25);g.strokeStyle="#2f6b53";g.fillStyle="#2f6b53";g.lineWidth=7;g.beginPath();g.arc(0,0,112,0,6.283);g.stroke();g.lineWidth=2.5;g.beginPath();g.arc(0,0,96,0,6.283);g.stroke();
    g.textAlign="center";g.font='600 30px "JetBrains Mono",monospace';g.fillText("VERIFIED",0,-18);g.fillText("BY QUIRE",0,20);g.font='700 34px sans-serif';g.fillText("✓",0,62)});
  const stamp=new THREE.Mesh(new THREE.PlaneGeometry(.92,.92),new THREE.MeshStandardMaterial({map:stampT,transparent:true,roughness:1,polygonOffset:true,polygonOffsetFactor:-2,depthWrite:false}));
  stamp.rotation.x=-Math.PI/2; stamp.position.set(.58,.006,.02); sheet.add(stamp);

  /* --- envelope (back, pocket with label, hinged flap with coral seal) --- */
  const EW=2.72, EH=1.32, env=new THREE.Group();
  const envMats=[];
  const mk=(color,extra={})=>{const m=new THREE.MeshStandardMaterial({color,roughness:.82,metalness:0,side:THREE.DoubleSide,transparent:true,opacity:0,...extra});envMats.push(m);return m};
  const backM=new THREE.Mesh(new THREE.PlaneGeometry(EW,EH),mk(0x1d4d3c)); backM.rotation.x=-Math.PI/2; backM.position.y=.002; backM.receiveShadow=true; env.add(backM);
  const pShape=new THREE.Shape(); pShape.moveTo(-EW/2,-EH/2); pShape.lineTo(EW/2,-EH/2); pShape.lineTo(EW/2,EH/2); pShape.lineTo(0,-.02); pShape.lineTo(-EW/2,EH/2); pShape.closePath();
  const pocketT=paperCanvas(544,264,(g,w,h)=>{g.fillStyle="#245a46";g.fillRect(0,0,w,h);fibres(g,w,h,2500,"#cfe3d6");
    g.strokeStyle="rgba(10,30,22,.35)";g.lineWidth=2;g.beginPath();g.moveTo(0,0);g.lineTo(w/2,h*.51);g.lineTo(w,0);g.stroke();
    g.fillStyle="#cfe3d6";g.font='500 15px "JetBrains Mono",monospace';g.fillText("FEE €493 · SHOWN BEFORE YOU SEND",22,h-22)});
  pocketT.repeat.set(1/EW,1/EH); pocketT.offset.set(.5,.5);
  const pocket=new THREE.Mesh(new THREE.ShapeGeometry(pShape),mk(0xffffff,{map:pocketT})); pocket.rotation.x=-Math.PI/2; pocket.position.y=.07; pocket.castShadow=true; env.add(pocket);
  const fShape=new THREE.Shape(); fShape.moveTo(-EW/2,0); fShape.lineTo(EW/2,0); fShape.lineTo(.12,-.8); fShape.quadraticCurveTo(0,-.88,-.12,-.8); fShape.closePath();
  const flapPivot=new THREE.Group(); flapPivot.position.set(0,.078,-EH/2); env.add(flapPivot);
  const flap=new THREE.Mesh(new THREE.ShapeGeometry(fShape),mk(0x2f6b53)); flap.rotation.x=-Math.PI/2; flap.castShadow=true; flapPivot.add(flap);
  const seal=new THREE.Mesh(new THREE.CircleGeometry(.17,40),mk(0xff6a4d,{roughness:.55})); seal.rotation.x=-Math.PI/2; seal.position.set(0,.004,.7); flapPivot.add(seal);

  const pkg=new THREE.Group(); pkg.add(sheet); pkg.add(env); scene.add(pkg);

  /* --- stage coords -> ground points so the 3D path matches the dashed SVG trail --- */
  const ray=new THREE.Raycaster(), plane=new THREE.Plane(new THREE.Vector3(0,1,0),0);
  const toGround=(sx,sy)=>{ray.setFromCamera(new THREE.Vector2(sx/DW*2-1,-(sy/DH)*2+1),cam);const v=new THREE.Vector3();ray.ray.intersectPlane(plane,v);return v};
  const curve=new THREE.CubicBezierCurve3(toGround(180,214),toGround(250,350),toGround(400,370),toGround(494,300));
  const home=curve.getPoint(0);

  const pos=geo.attributes.position;
  function fold(a1,a3,t){
    const th1=a1*Math.PI, th3=a3*Math.PI;
    for(let i=0;i<pos.count;i++){
      const x=rest[i*3], z0=rest[i*3+2];
      let y=0, z=z0;
      const bow=.035*(1-(x/(SW/2))**2)*(1-Math.max(a1,a3)); // a slight natural bow while flat
      if(z0>C2){const d=z0-C2; z=C2+d*Math.cos(th3); y=d*Math.sin(th3)+.014*a3;}
      else if(z0<C1){const d=C1-z0; z=C1-d*Math.cos(th1); y=d*Math.sin(th1)+.028*a1;}
      // soft crease: lift vertices close to a hinge a hair so normals round over
      const nc=Math.min(Math.abs(z0-C1),Math.abs(z0-C2)); if(nc<.06) y+=.006*(1-nc/.06)*Math.max(a1,a3);
      pos.setXYZ(i,x,y+bow+Math.sin(t*1.3+x*1.7)*.008*(1-Math.max(a1,a3)),z);
    }
    pos.needsUpdate=true; geo.computeVertexNormals();
  }

  stage.appendChild(cv); stage.classList.add("gl-on");
  let vis=false, raf=0, lastP=-1;
  function frame(now){
    raf=0;
    const reduced=RM.matches, t=reduced?0:now/1000;
    const p=window.__howP??0;
    const a=eo(seg(p,0,.16));
    const st=seg(p,.34,.42);
    stamp.material.opacity=st?Math.min(1,st*2):0; const ss=st?1+(1-eo(st))*.9:1; stamp.scale.set(ss,ss,ss);
    const f1=eio(seg(p,.56,.65)), f3=eio(seg(p,.48,.57)); fold(f1,f3,t);
    stamp.position.y=.01+.035*(1-(.58/1.2)**2)*(1-Math.max(f1,f3));
    const e=seg(p,.62,.67); envMats.forEach(m=>{m.opacity=e;m.depthWrite=e>.98});
    env.visible=e>0;
    flapPivot.rotation.x=-Math.PI*(1-eio(seg(p,.67,.74)));
    sheet.visible=p<.72;
    const tr=eio(seg(p,.76,.92)), pt=curve.getPoint(tr);
    const idle=p<.46&&!reduced?Math.sin(t*1.6)*.05+.05:0;
    pkg.position.set(pt.x,(1-a)*2.4+Math.sin(tr*Math.PI)*1.5+idle,pt.z);
    const s=1-.58*tr; pkg.scale.set(s,s,s);
    pkg.rotation.set((1-a)*-.5+Math.sin(tr*Math.PI)*-.18,(1-a)*.4-tr*.35+(reduced?0:Math.sin(t*.7)*.025*(1-tr)),Math.sin(tr*Math.PI)*.12);
    pkg.visible=p<.935;
    renderer.render(scene,cam);
    lastP=p;
    if(vis&&!document.hidden&&!reduced) raf=requestAnimationFrame(frame);
  }
  const kick=()=>{if(!raf&&vis&&!document.hidden) raf=requestAnimationFrame(frame)};
  new IntersectionObserver(es=>{vis=es[0].isIntersecting;kick()},{rootMargin:"25% 0px"}).observe(track);
  addEventListener("scroll",()=>{if(RM.matches) kick()},{passive:true});
  document.addEventListener("visibilitychange",kick);
  RM.addEventListener?.("change",kick);
  renderer.render(scene,cam); kick();
}
</script>
</body>
</html>

````
