# Recreate this site as a single HTML file: Earmark — app launch with a live 3D phone

You are an expert creative front-end developer. Produce one self-contained `index.html` that reproduces the launch page below exactly: same sections, copy, studio render, 3D phone, choreography and working demo. Pure HTML/CSS/JS, no build step, no framework. One `<script type="module">`; three.js is the only library and is loaded with dynamic `import()` so the page still works if it fails. Hardcode every value given here.

## What it is

The launch page for **Earmark**, a fictional "sound journal" app that records thirty seconds of a place, tags what it heard on-device, pins it to a map and keeps it. The hero is a **Blender Cycles studio render** (an oat-coloured sweep in late window light, a dark basalt plinth, an acoustic-foam panel, two pebbles) with **live three.js objects composited into it**: a procedural titanium phone floats over the plinth, and three real GLB props sit in the set — a whelk shell on the plinth, a pine cone half hidden behind it, a brass bicycle bell on the floor — lit to match, casting soft shadows onto the render and correctly occluded by the rendered plinth.

**Signature:** the phone's screen is a live `<canvas>` texture running the actual app UI. On scroll the phone leaves the plinth and **flies between sections**, turning a full revolution each time its screen changes (the screen swaps when its back — with the modelled camera bump — faces you). In the "Try it" section it docks beside a real recorder demo: pick a place, press record, a synthesized field recording plays (no microphone), the waveform draws live on the phone, tags pop in as it "listens", you keep or add tags, name it and save it to a journal. The 3D prop for that place floats next to the phone and twitches with the audio level. Clicking a prop in the hero (or the matching chip) makes it hop and switches the phone to that place.

Sections in order: **Preloader · Nav · 01 Hero (studio plate + live 3D) · 02 How it listens (sticky phone, 4 steps) · 03 Try it (working demo, dark) · 04 Field notes (social proof) · 05 Pricing (toggle + odometer) · 06 FAQ · 07 Launch CTA + footer · Notify dialog.**

## Page shell & libraries

```html
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Young+Serif&family=Hanken+Grotesk:wght@400;500;600;700&family=Martian+Mono:wght@400;500&display=swap">
<script type="importmap">
{ "imports": {
  "three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js",
  "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/" } }
</script>
```

- Addons used (same version): `loaders/GLTFLoader.js`, `libs/meshopt_decoder.module.js`, `environments/RoomEnvironment.js`.
- First script in `<head>` (before CSS): if not `prefers-reduced-motion: reduce` and not a crawler UA, set `html[data-preload]`; always add class `js`.
- `<title>Earmark — keep the sound of a place</title>`, `theme-color #655d54`, `viewport-fit=cover`. Preload `assets/studio-plate.webp`.
- Fixed layers: `.grain` (z 90, SVG feTurbulence noise, opacity .07, multiply, 6-step jitter 1.2 s), `#stage` WebGL canvas (fixed, inset 0, z 20, `pointer-events:none`, fades in over .8 s), nav (z 60), loader (z 150).

## Tokens

```css
--bone:#efe8dc; --paper:#f7f2ea; --ink:#1c1a17; --muted:#5d564c;
--wall:#655d54 (sampled from the render's back wall); --night:#161411; --night-2:#211e1a; --night-line:#38332d;
--on-night:#f1eadf; --on-night-dim:#b3aa9c; --signal:#ff5a1f (record red-orange; text on it is ink); --moss:#6f7d55;
--r-s:10px; --r-m:18px; --r-l:28px; --r-pill:999px; --gut:clamp(16px,4vw,56px); --maxw:1320px;
--ease-out:cubic-bezier(.16,1,.3,1); --ease-io:cubic-bezier(.65,0,.35,1);
```

- Type: **Young Serif 400** for every display line (h1 `clamp(46px,6.6vw,100px)`, h2 `clamp(36px,5.2vw,76px)`, h3 `clamp(26px,2.6vw,38px)`, line-height 1.02, tracking −.015em). **Hanken Grotesk** 400/500/600 body at 17px/1.55. **Martian Mono** 400/500 for every eyebrow, readout, spec chip and timer (.62–.72rem, uppercase, tracking .04–.08em).
- Eyebrows start with an 8px `--signal` dot with a 4px 18%-alpha halo.
- Focus: `2.5px solid var(--signal)`, offset 3px, everywhere.

The in-app (canvas) palette: bg `#12110f`, card `#1e1c19`, line `#2f2c27`, text `#f1eadf`, dim `#9c9488`, accent `#ff5a1f`, kept-green `#a9c07f`.

## Layout & structure

**Preloader** (only with `data-preload`): night field, "earmark" in Young Serif 28px, a row of 36 bars (4px wide, gap 4) and a mono "Tuning in 0%" counter. Bars light up in `--signal` and grow to `8 + envelope × 56` px as real progress arrives (8% when three.js is in, then 15–100% from the GLTF LoadingManager). At 100% it waits 380 ms and leaves with `clip-path: inset(0 0 100% 0)` over 1 s `--ease-io`; the hero h1 lines rise out of their masks (translateY 105% → 0, 1.1 s `--ease-out`). Hard timeout 6 s.

**Nav**: fixed; transparent with bone text over the hero, then `rgba(239,232,220,.9)` + 10px blur + ink text once past the hero. Wordmark = bookmark outline with three orange level bars + "earmark". Links: How it listens · Try it · Pricing · FAQ. A pill **Sound** toggle (`aria-pressed`, speaker icon with waves or ×) and a `--signal` "Get Earmark" button. Under 900px the links hide; under 420px the button hides.

**01 Hero** — `min-height:max(100svh,680px)`, background `--wall` fading to `#9a8c7d` in the last 240px. The plate `<img>` is absolutely positioned by JS (see Behaviour) with a 9% top mask fade; a scrim `linear-gradient(90deg, rgba(38,33,28,.55) 0, .28 38%, 0 62%)` keeps the copy readable. Copy column (bone): eyebrow "Sound journal · iPhone & Android · out 4 Dec 2026"; h1 "Keep the / sound of / *a place.*" (last line `#ffb48f`); lede "Earmark records thirty seconds of where you are — a shingle beach, a pine wood, a wet tram stop — tags what it heard, pins it to a map and keeps it. Photos remember how it looked. This remembers how it sounded."; two generic store badges (ink tiles, no store logos: a phone outline + "Out 4 Dec for / iPhone", a play-triangle + "Out 4 Dec for / Android") that open the Notify dialog. Bottom row: a mono readout "● Rec 00:16 · Gullhaven shingle · surf, gulls" (clock in sync with the phone), three toggle chips "Shore · whelk / Pine wood · cone / Tram stop · bell" (`aria-pressed`), and on desktop "Scroll — the phone comes with you ↓". Under 1000px the hero stacks: copy, then an empty `.hero-stage` box `clamp(440px,70vw,600px)` tall that the plate and 3D set are fitted into, then the chips.

**02 How it listens** — h2 "Four things it does. / Nothing it doesn’t." Two columns: left a sticky 100svh stage holding the phone slot (`aspect-ratio:.485; height:min(70svh,640px)`) and a rail "01 Record · 02 Tag · 03 Map · 04 Listen" (active item ink with a 34px orange dash); right four steps, each `min-height:96svh`:
1. **01 / Record** — "One tap. Thirty seconds. No settings." Specs: 48 kHz · 24-bit / Wind guard / Works offline.
2. **02 / Tag** — "It hears the gulls so you don’t have to type." Specs: 212 sound tags / On-device / No account needed.
3. **03 / Map** — "Your year, drawn as places you stopped." Specs: Offline map / Blur location on share.
4. **04 / Listen back** — "Play it in the dark, on purpose." plus a big "10:00 / A Quiet Hours reel from 9 places".
Under 860px the stage and steps share one grid cell: the slot sits sticky at the top (46svh tall), each step is 100svh with its card (paper @94%, blur 8px, radius 18) pinned to the bottom.

**03 Try it** (night) — h2 "Record something. / Right here." with the note that it plays a synthesized place sound and never asks for the microphone. Left: sticky phone slot. Right: panel of four steps separated by `--night-line` rules:
- **A Pick a place** — three radio cards (3:4 photos with a dark bottom gradient, Young Serif name + mono meta): Gullhaven shingle (Shore · 06:12), Old Pine Hollow (Forest · 07:40), Kestrel St. stop (City · 18:55). Checked card gets a 2.5px orange outline.
- **B Record up to 8 seconds** — 84px round button (2px bone ring, 58px orange disc that morphs to a 30px rounded square while recording, `aria-pressed`), mono timer "00:03 / of 00:08 · demo limit", a level meter (moss → yellow → signal gradient) and the Sound toggle. A polite status line narrates each state.
- **C Keep the tags that fit** — suggested tags pop in (scale .6 → 1, .45 s) as toggle buttons with their confidence; tags ≥ 50% start selected. "Add your own tag" field validates 2–20 letters/spaces/hyphens and rejects duplicates.
- **D Name it and keep it** — name field (≥ 2 chars, prefilled per place), "Keep it" button (disabled until a recording exists), quota "3 of 30 free recordings used" (+1 per save), and a journal list: 56px photo, name, mono meta, an SVG mini waveform of the actual recording, and a play button that replays the place sound.
Under 860px the phone slot sits above the panel (`min(60svh,520px)`).

**04 Field notes** — h2 "What people kept." A 1.25fr / 1fr grid: one big ink card spanning two rows (shore photo 16:10, quote "My dad’s beach, the week before we sold the house…", waveform, avatar initial R + "Ruth Okafor-Lind · Gullhaven · 31 s · surf, gulls"), and two paper cards (Tomás Vereda / Pine Hollow; Mina Haugland / Kestrel St.). Below: three count-up stats (2,418 places kept · 61 countries · 31 s median) and the line "Earmark, its beta testers, quotes and numbers are fictional — this page is a design demo."

**05 Pricing** (paper) — h2 "Free for thirty places." Left: phone slot showing the Field paywall screen. Right: a Monthly / Yearly radiogroup with a sliding ink thumb ("Yearly −39%"), then two unequal plans (1fr / 1.15fr): **Pocket €0 forever** (30 recordings, tags + map, AAC export) and **Field** on ink with a "Most kept" tag and an odometer price **€3.99 → €2.42 / month** ("Billed €29 once a year. That’s 39% less."), four orange-checked features, "Try Field free for 14 days". Under them a dashed strip "Kept for good — €79 once". Under 860px the phone slot is hidden and the phone flies away.

**06 FAQ** — h2 "Questions people ask out loud." Six native `<details>` (uploads, why thirty seconds, recording people, export formats, offline, what happens if you stop paying); a 28px round +/− icon that fills ink when open; the answer opens with `grid-template-rows: 0fr → 1fr` over .45 s.

**07 Launch** (wall colour) — h2 "Go and stand somewhere for thirty seconds.", a validated email form ("Send me the link" → inline confirmation), the two badges, and a phone slot showing the journal. Footer: wordmark, links, and "Earmark is a fictional app made for a design demo; no real app or store listing exists."

**Notify dialog** — native `<dialog>`: "Not in the store yet.", iPhone/Android radio pills, email with validation, success message, closes after 1.8 s; backdrop click and × close it.

## Behaviour & interaction

**Studio plate alignment (the key trick).** The plate was rendered from a Blender camera at (0, −1.05, 0.33) looking at (0, 0, 0.12), 50 mm lens, 36 mm sensor, 16:9 (three.js: position (0, .33, 1.05), lookAt (0, .12, 0), vertical FOV `2·atan(tan(atan(18/50))·9/16)` ≈ 22.9°). Plinth: radius .12, height .075, top centre at (.17, .075, −.04) in three.js units. On every layout:
- Desktop: `s = max(W/1920, min(heroH, 1.08·H)/1080)`, vertically centred; horizontally the plinth's projected x is put at 67% of the width (70% under 1200px), clamped so the image always covers.
- Stacked (< 1000px): `s = max(stageH/(0.6·1080), W/1920)`, `top = stageTop − 0.2·1080·s`, plinth centred.
- The `<img>` gets `width 1920s, height 1080s, left, top`; camera A gets `setViewOffset(1920s, 1080s, −left, −(heroRect.top + top), W, H)` every frame, so live objects stay glued to the render while the hero scrolls. A ResizeObserver on the hero re-runs layout.

**Scene A (in the plate):** `RoomEnvironment` PMREM env at .55; warm key `DirectionalLight #ffdcb6 2.6` from (−1, .85, .55) (the Blender sun's direction), PCF soft shadows 1024², radius 6, ortho box ±.45; hemisphere `#c9d2e0/#6b5a47 .5`. `ShadowMaterial #2a1c10 @ .42` on the floor plane and on a disc on the plinth top; an invisible depth-only cylinder (`colorWrite:false`, renderOrder −1) stands in for the rendered plinth so the pine cone is hidden behind it. Shadow map updates only when a prop moves. A radial blob under the phone fades out as the phone leaves.

**GLB props** (meshopt + WebP textures): each is re-centred, scaled to its size and dropped onto its surface — shell .085 on the plinth top at (.10, .075, .015) lying on its side (pre-rotation (.25, 0, −1.28)), cone .082 at (.035, 0, −.15), bell .06 at (.255, 0, .12). Hover (raycast through camera A) wobbles a prop ±.08 rad and shows a pointer; clicking it or its hero chip fires a hop spring (k 60, damping 7, impulse 2.2) plus one full spin over ~.8 s, switches the hero phone to that place and, if sound is on, plays its sound for 2.6 s.

**The phone (scene B, camera B = same FOV, no offset):** extruded rounded rectangle 73.5 × 152 × 8.2 mm, corner radius 11.5 mm, bevel 1.2 mm × 5 segments; titanium `MeshPhysicalMaterial #9c9384, metalness 1, roughness .3, clearcoat .3`; satin back glass; a camera bump (31 mm square, 7 mm radius) with three lens rings and glass; three side buttons; the screen is a `ShapeGeometry` with UVs remapped to 0–1 carrying a `CanvasTexture` (600 × 1277, sRGB, max anisotropy, `toneMapped:false`) under a 14%-opacity clear-coated glass layer. Lights: warm key from upper left, cool rim from back right, env .9. Renderer: AgX tone mapping, exposure 1.05, alpha, DPR ≤ 2; scene A renders first, depth is cleared, then scene B.

**Choreography:** every section that holds the phone has an invisible `.slot` box with `data-rx/ry/rz`. A pose is `{x, y, h, rx, ry, rz}` in screen pixels: the hero pose is the projection of (.175, .2, −.04) through camera A with height ×1.12; a slot pose is its rect centre and 96% of its height; an "away" pose is (50% W, −55% H). For each following section (How, Try, Notes→away, Pricing, FAQ→away, Launch), `t = clamp((0.92H − sectionTop) / 0.72H)`, eased in-out-cubic, mixes the running pose toward that target and adds `sin(π·t)·1.1` rad of Y turn mid-flight. Pixel pose → world: `depth = 0.152·H / (2·h·tan(fov/2))`, then place on the NDC ray. Pointer tilt spring (stiffness 90, damping 12) up to ±.12 rad X and ±.22 rad Y; idle bob ±4 mm at 1.3 rad/s and ±.015 rad roll.

**Screen changes = flips:** whenever the dominant section (t > .5) or the active How step changes, the phone does one 2π Y turn over 900 ms (in-out cubic) and the canvas switches screens at the half-way point, when the back faces the viewer. Queued changes chain.

**App screens (canvas, redrawn only when dirty or animating, ≤ 30 fps):** status bar 9:41 + island + battery; *Record* (blinking REC, place name in Young Serif, coordinates, 54 scrolling level bars, big mono clock, "heard so far" chips, progress ring around the stop button); *Tag* (confidence bars animate in, 180 ms stagger); *Map* (contour lines, a coastline, pulsing orange pins, bottom sheet with the three photos); *Listen* (radial 120-bar ring around a round photo, progress bar, play/pause, Loop, Sleep 20m); *Demo idle / recording / review / kept*; *Plan* (follows the billing toggle); *Journal*. In the demo, tapping the record or "Keep it" areas on the 3D screen works too (raycast → UV → hit box).

**Audio (Web Audio, created on first user gesture, master gain 0 unless Sound is on, analyser always on):** shore = looped brown noise low-passed at 700 Hz with a .16 Hz swell LFO + high hiss + gull chirps (1850 → 1150 Hz); forest = brown noise at 420 Hz + random 2.6–5.4 kHz bird chirps + a woodpecker burst; tram = 180 Hz rumble + band-passed rain + 100 Hz wire hum + three bell strikes (1650/2390/3720 Hz partials). Level = RMS × 3.2 drives the meter, bars, a soft orange glow behind the phone and the floating prop's spin. Tags appear every 1.4 s; recording stops at 8 s (or on press; under .6 s it resets).

**Pricing odometer:** each digit is a 0–9 column translated by `−digit em` over .7 s `--ease-out`; a hidden `aria-live` line announces the price. Toggle supports arrow keys.

## Responsive

- **1440**: copy left, plate plinth at 67% width, phone ~410px tall over it; How/Try/Pricing two columns.
- **768**: hero stacks (copy → 560px stage → chips); How uses the sticky-top/card-bottom pattern; Try stacks; pricing phone hidden.
- **390**: badges stretch to two equal tiles, places grid stays 3-up with 16px names, journal rows 56px thumbnails, no horizontal scroll anywhere (`overflow-x:hidden` on body and every grid uses `minmax(0,…)`).

## Accessibility & reduced motion

- Skip link, landmarks, one h1, labelled sections, `aria-pressed` on every toggle, radiogroup semantics for billing, native radios for places and OS, `role="status"` narration of the recorder, form errors tied with `aria-describedby` and `aria-invalid`, dialog with real focus handling. The WebGL canvas is `aria-hidden`; everything it shows is also available as HTML.
- Reduced motion: no preloader, no flips (screens swap instantly), no tilt/bob/hops/spins, no grain jitter, reveals and counters static. Scroll-linked position still follows the user's own scrolling.
- Contrast: bone on the wall colour ≥ 4.8:1; muted text on bone ≥ 6:1; ink on signal ≥ 5:1.

## Fallbacks

- No WebGL, or three.js fails to load: `html.no-webgl`, the canvas is removed, the hero shows `assets/studio-poster.webp` (the same Cycles set with the phone rendered in), and every slot shows a CSS phone (titanium gradient frame) with a snapshot of its screen; the demo slot holds the live app canvas itself, so the whole demo, tags, journal and audio still work.
- Rendering pauses on hidden tabs and skips frames when neither the hero nor the phone is on screen.

## Assets

- `assets/studio-plate.webp` (1920×1080, ~18 KB) — Blender Cycles render: oat sweep, basalt plinth, foam panel, two pebbles, warm window-light streak; no phone.
- `assets/studio-poster.webp` (1600×900, ~17 KB) — same camera with the phone in place (no-WebGL poster).
- `assets/shell.glb` (~490 KB), `assets/cone.glb` (~910 KB), `assets/bell.glb` (~460 KB) — image→3D models (whelk shell, pine cone, brass bicycle bell), meshopt-compressed, 1024px WebP textures.
- `assets/place-shore.webp`, `assets/place-forest.webp`, `assets/place-tram.webp` (1000×750) — 35mm-film-look photos of a misty shingle beach with a groyne, a pine wood after rain, and a wet tram stop at blue hour. Used in the demo cards, the journal, the social-proof card and drawn into the app canvas.

## Make it yours

This prompt rebuilds one exact design. If everyone ships it unchanged, the sites will look alike. Change these lines before you paste it; the structure and interactions stay intact.

1. **App and offer.** Swap Earmark for your own app (a plant-care camera, a run logger, a recipe scanner…). Keep a single verb-led promise, four "How" steps, one demo flow with 3–4 steps and two plans plus one one-off strip so the columns stay balanced.
2. **The studio set.** Re-render the plate for your world with the same camera numbers (so the live objects still line up): a potting bench instead of a plinth, a kitchen counter, a running track kerb. Keep one hero surface at roughly the same place in frame and one window-light streak.
3. **The props.** Replace shell / cone / bell with three objects that stand for your app's three "modes" (pot / watering can / seed packet; shoe / bottle / watch). Generate each from a clean product photo with image→3D, compress with meshopt + WebP ≤ 1 MB, and keep one on the hero surface, one partly behind it, one on the floor.
4. **The phone screens.** Redraw the canvas screens for your app but keep the rule that each section owns one screen and every change is a full-turn flip. Keep the record/scan button and live data on the demo screen.
5. **Palette.** Replace `--wall` with a colour sampled from your render's back wall, `--signal` with your action colour, and the bone/ink pair with your neutrals. Keep bone-on-wall and muted-on-bone at ≥ 4.5:1.
6. **Type.** Swap Young Serif + Hanken Grotesk + Martian Mono for another warm display face, a plain grotesk and a mono with character. Keep the mono for every readout so the "instrument" feel survives.
7. **Sound.** Rewrite the three synth recipes for your app's moments (a watering can pour, a shutter, a heartbeat), or drop audio and keep the analyser driven by a procedural envelope.
8. **Copy voice.** Specific and physical: "Go and stand somewhere for thirty seconds", not "Unlock your potential". Keep the fictional-demo disclaimer if your people and numbers are invented.

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/mobile-app-launch-3d-phone/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, viewport-fit=cover">
<title>Earmark — keep the sound of a place</title>
<meta name="description" content="Earmark is a sound journal for your phone. Thirty seconds of a beach, a forest or a tram stop, tagged on-device, pinned to a map and kept.">
<meta name="theme-color" content="#655d54">
<script>
  // Preloader gate: reduced motion or a crawler opens the page at once.
  if (!matchMedia('(prefers-reduced-motion: reduce)').matches && !/lighthouse|googlebot|pagespeed|gtmetrix|bingbot/i.test(navigator.userAgent)) document.documentElement.dataset.preload = '';
  document.documentElement.classList.add('js');
</script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Young+Serif&family=Hanken+Grotesk:wght@400;500;600;700&family=Martian+Mono:wght@400;500&display=swap">
<link rel="preload" as="image" href="assets/studio-plate.webp">
<script type="importmap">
{ "imports": {
  "three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js",
  "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"
} }
</script>
<style>
:root{
  --bone:#efe8dc; --paper:#f7f2ea; --ink:#1c1a17; --ink-2:#2b2824; --muted:#5d564c;
  --wall:#655d54; --wall-2:#4f4841; --night:#161411; --night-2:#211e1a; --night-line:#38332d;
  --on-night:#f1eadf; --on-night-dim:#b3aa9c;
  --signal:#ff5a1f; --signal-ink:#1c1a17; --moss:#6f7d55;
  --f-display:"Young Serif", Georgia, serif;
  --f-sans:"Hanken Grotesk", system-ui, sans-serif;
  --f-mono:"Martian Mono", ui-monospace, monospace;
  --r-s:10px; --r-m:18px; --r-l:28px; --r-pill:999px;
  --gut:clamp(16px, 4vw, 56px);
  --maxw:1320px;
  --ease-out:cubic-bezier(.16,1,.3,1);
  --ease-io:cubic-bezier(.65,0,.35,1);
}
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
@media (prefers-reduced-motion: reduce){html{scroll-behavior:auto}}
body{margin:0;background:var(--bone);color:var(--ink);font:400 17px/1.55 var(--f-sans);overflow-x:hidden;-webkit-font-smoothing:antialiased}
img{max-width:100%;display:block}
a{color:inherit}
button,input{font:inherit;color:inherit}
:focus-visible{outline:2.5px solid var(--signal);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}
.skip{position:fixed;left:12px;top:-60px;z-index:200;background:var(--ink);color:var(--bone);padding:10px 16px;border-radius:var(--r-pill);text-decoration:none;font-weight:600}
.skip:focus{top:12px}
.wrap{max-width:var(--maxw);margin:0 auto;padding:0 var(--gut)}
.mono{font-family:var(--f-mono);font-size:.72rem;letter-spacing:.04em;text-transform:uppercase}
.eyebrow{font-family:var(--f-mono);font-size:.7rem;letter-spacing:.08em;text-transform:uppercase;display:inline-flex;gap:.7em;align-items:center}
.eyebrow::before{content:"";width:8px;height:8px;border-radius:50%;background:var(--signal);box-shadow:0 0 0 4px rgba(255,90,31,.18)}
h1,h2,h3{font-family:var(--f-display);font-weight:400;letter-spacing:-.015em;line-height:1.02;margin:0}
h2{font-size:clamp(36px,5.2vw,76px)}
h3{font-size:clamp(26px,2.6vw,38px);line-height:1.08}
p{margin:0}

/* film grain: one fixed layer for the whole page */
.grain{position:fixed;inset:-50%;z-index:90;pointer-events:none;opacity:.07;mix-blend-mode:multiply;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation:grain 1.2s steps(6) infinite}
@keyframes grain{0%{transform:translate(0,0)}20%{transform:translate(-3%,2%)}40%{transform:translate(2%,-3%)}60%{transform:translate(-2%,-1%)}80%{transform:translate(3%,3%)}100%{transform:translate(0,0)}}
@media (prefers-reduced-motion: reduce){.grain{animation:none}}

/* ---------- preloader ---------- */
#loader{display:none}
html[data-preload] #loader{display:grid}
#loader{position:fixed;inset:0;z-index:150;background:var(--night);color:var(--on-night);place-items:center;transition:clip-path 1s var(--ease-io);clip-path:inset(0 0 0 0)}
#loader.out{clip-path:inset(0 0 100% 0)}
.ld{display:grid;gap:22px;justify-items:center}
.ld-bars{display:flex;gap:4px;align-items:center;height:64px}
.ld-bars i{width:4px;border-radius:2px;background:var(--on-night-dim);height:4px;transition:height .35s var(--ease-out),background .3s}
.ld-bars i.on{background:var(--signal)}
.ld-row{display:flex;gap:18px;font-family:var(--f-mono);font-size:.72rem;letter-spacing:.08em;text-transform:uppercase;color:var(--on-night-dim)}
.ld-row b{color:var(--on-night);font-weight:500;min-width:4ch;text-align:right}
.ld-mark{font-family:var(--f-display);font-size:28px}

/* ---------- nav ---------- */
.nav{position:fixed;top:0;left:0;right:0;z-index:60;display:flex;align-items:center;gap:20px;padding:14px var(--gut);color:var(--on-night);transition:background .4s,color .4s,box-shadow .4s}
.nav.solid{background:rgba(239,232,220,.9);color:var(--ink);box-shadow:0 1px 0 rgba(28,26,23,.1);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;font-family:var(--f-display);font-size:23px;letter-spacing:-.01em}
.brand svg{width:26px;height:30px}
.nav ul{display:flex;gap:26px;list-style:none;margin:0 0 0 auto;padding:0}
.nav ul a{text-decoration:none;font-weight:500;font-size:15px;opacity:.86}
.nav ul a:hover{opacity:1;text-decoration:underline;text-underline-offset:4px}
.snd{display:inline-flex;align-items:center;gap:8px;border:1px solid currentColor;border-radius:var(--r-pill);padding:7px 12px;background:transparent;cursor:pointer;font-family:var(--f-mono);font-size:.66rem;letter-spacing:.06em;text-transform:uppercase}
.snd svg{width:16px;height:16px}
.snd[aria-pressed="true"] .x{display:none}
.snd[aria-pressed="false"] .w{display:none}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;border-radius:var(--r-pill);padding:12px 20px;font-weight:600;text-decoration:none;border:0;cursor:pointer;transition:transform .25s var(--ease-out),background .25s}
.btn:hover{transform:translateY(-1px)}
.btn:active{transform:translateY(1px) scale(.98)}
.btn-signal{background:var(--signal);color:var(--signal-ink)}
.btn-ink{background:var(--ink);color:var(--bone)}
.nav .btn{padding:9px 16px;font-size:15px}
@media (max-width:900px){.nav ul{display:none}.nav .snd{margin-left:auto}}
@media (max-width:420px){.nav .btn{display:none}}

/* ---------- 3D stage ---------- */
#stage{position:fixed;inset:0;z-index:20;pointer-events:none;width:100vw;height:100vh;opacity:0;transition:opacity .8s}
#stage.ready{opacity:1}

/* ---------- hero ---------- */
.hero{position:relative;min-height:max(100svh,680px);background:linear-gradient(180deg,var(--wall) calc(100% - 240px),#9a8c7d);color:var(--on-night);overflow:hidden}
.hero .plate{position:absolute;left:0;top:0;width:100%;height:100%;object-fit:cover;object-position:70% 50%;user-select:none}
/* stacking: plate + scrim < 3D canvas (z 20) < page copy (z 30) */
main .wrap{position:relative;z-index:30}
.js .hero .plate.placed{width:auto;height:auto;max-width:none;object-fit:fill;-webkit-mask-image:linear-gradient(180deg,transparent,#000 9%);mask-image:linear-gradient(180deg,transparent,#000 9%)}
.hero-stage{display:none}
.hero::after{content:"";position:absolute;inset:0;pointer-events:none;
  background:linear-gradient(90deg,rgba(38,33,28,.55) 0%,rgba(38,33,28,.28) 38%,rgba(38,33,28,0) 62%),linear-gradient(180deg,rgba(38,33,28,.35),rgba(38,33,28,0) 22%)}
.hero-in{position:relative;padding-top:clamp(112px,15vh,170px);padding-bottom:48px;min-height:inherit;display:flex;flex-direction:column}
.hero h1{font-size:clamp(46px,6.6vw,100px);max-width:9.5ch;margin-top:22px}
.hero h1 .ln{display:block;overflow:hidden;padding-bottom:.06em}
.hero h1 .ln span{display:block;transition:transform 1.1s var(--ease-out),opacity 1.1s}
html.pre-intro .hero h1 .ln span{transform:translateY(105%);opacity:0}
.hero h1 em{font-style:normal;color:#ffb48f}
.lede{max-width:40ch;font-size:clamp(17px,1.35vw,20px);color:#e9e1d4;margin-top:24px}
.badges{display:flex;flex-wrap:wrap;gap:12px;margin-top:32px}
.badge{display:inline-flex;align-items:center;gap:12px;padding:10px 18px 10px 14px;border-radius:14px;background:var(--ink);color:var(--bone);text-decoration:none;border:1px solid rgba(255,255,255,.14);cursor:pointer;min-height:54px;transition:transform .25s var(--ease-out),background .25s}
.badge:hover{transform:translateY(-2px);background:#000}
.badge svg{width:24px;height:24px;flex:none}
.badge small{display:block;font-size:10.5px;letter-spacing:.06em;text-transform:uppercase;opacity:.75;line-height:1.2}
.badge strong{display:block;font-size:17px;font-weight:600;line-height:1.2}
.hero-foot{margin-top:auto;padding-top:48px;display:flex;flex-wrap:wrap;gap:14px 28px;align-items:flex-end}
.set{display:flex;flex-direction:column;gap:10px}
.set-row{display:flex;flex-wrap:wrap;gap:8px}
.chip{display:inline-flex;align-items:center;gap:8px;padding:8px 13px;border-radius:var(--r-pill);border:1px solid rgba(241,234,223,.35);background:rgba(28,26,23,.25);color:var(--on-night);cursor:pointer;font-size:14px;font-weight:500;transition:background .25s,border-color .25s}
.chip:hover{border-color:var(--on-night)}
.chip[aria-pressed="true"]{background:var(--on-night);color:var(--ink);border-color:var(--on-night)}
.chip .dot{width:7px;height:7px;border-radius:50%;background:currentColor;opacity:.6}
.readout{font-family:var(--f-mono);font-size:.68rem;letter-spacing:.06em;text-transform:uppercase;color:#e2d9cb;display:flex;gap:4px 14px;flex-wrap:wrap;align-items:center}
.readout .rec{color:#ffb48f}
.readout .rec::before{content:"";display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--signal);margin-right:7px;animation:blink 1.2s steps(2) infinite}
@keyframes blink{50%{opacity:.15}}
.scrollcue{font-family:var(--f-mono);font-size:.66rem;letter-spacing:.08em;text-transform:uppercase;color:#d9cfbf;margin-left:auto}
.no-webgl .hero .plate{content:url(assets/studio-poster.webp)}
@media (max-width:999px){
  .hero{min-height:0}
  .hero-in{padding-top:110px;padding-bottom:28px}
  .hero::after{background:linear-gradient(180deg,rgba(38,33,28,.4) 0%,rgba(38,33,28,0) 40%)}
  .hero-stage{display:block;height:clamp(440px,70vw,600px)}
  .hero-foot{padding-top:0;margin-top:0}
  .scrollcue{display:none}
  .no-webgl .hero-stage{height:78vw}
  .no-webgl .hero .plate{top:auto;bottom:0;height:auto;width:180%;max-width:none;left:-72%;-webkit-mask-image:linear-gradient(180deg,transparent,#000 14%);mask-image:linear-gradient(180deg,transparent,#000 14%)}
}
@media (max-width:760px){.badge{flex:1 1 150px}}

/* ---------- sections ---------- */
section{position:relative}
.sec-head{display:grid;gap:18px;max-width:780px}
.sec-head p{color:var(--muted);font-size:clamp(17px,1.3vw,19px);max-width:56ch}
.reveal{opacity:0;transform:translateY(26px);transition:opacity .9s var(--ease-out),transform .9s var(--ease-out)}
.reveal.in{opacity:1;transform:none}
@media (prefers-reduced-motion: reduce){.reveal{opacity:1;transform:none;transition:none}}
.no-js .reveal{opacity:1;transform:none}

/* slots: invisible boxes the live phone flies into */
.slot{position:relative;aspect-ratio:.485;height:min(70svh,640px);margin:0 auto}
.mock{display:none}
.no-webgl .mock{display:block;position:absolute;inset:0;border-radius:13% / 6.2%;padding:3.2%;background:linear-gradient(145deg,#b5ab9c,#7f776c 40%,#cfc5b6 70%,#8c8378);box-shadow:0 30px 60px -20px rgba(0,0,0,.45)}
.no-webgl .mock img,.no-webgl .mock canvas{width:100%;height:100%;border-radius:11% / 5.2%;background:#12110f;object-fit:cover}

/* how it listens */
.how{padding:clamp(90px,12vw,160px) 0 40px}
.how-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0 var(--gut);margin-top:64px}
.how-stage{position:sticky;top:0;height:100svh;display:grid;place-items:center}
.how-rail{position:absolute;left:0;top:50%;transform:translateY(-50%);display:grid;gap:14px}
.how-rail span{display:flex;align-items:center;gap:10px;font-family:var(--f-mono);font-size:.64rem;letter-spacing:.08em;color:var(--muted);transition:color .3s}
.how-rail span::before{content:"";width:18px;height:2px;background:currentColor;opacity:.4;transition:width .4s var(--ease-out),opacity .3s}
.how-rail span.on{color:var(--ink)}
.how-rail span.on::before{width:34px;opacity:1;background:var(--signal)}
.steps{display:grid}
.step{min-height:96svh;display:flex;flex-direction:column;justify-content:center;gap:18px;padding:40px 0;max-width:520px}
.step .num{font-family:var(--f-mono);font-size:.7rem;letter-spacing:.08em;color:var(--muted)}
.step .num b{color:var(--signal);font-weight:500}
.step p{color:var(--muted);font-size:18px}
.specs{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px;padding:0;list-style:none}
.specs li{font-family:var(--f-mono);font-size:.64rem;letter-spacing:.05em;text-transform:uppercase;padding:7px 10px;border:1px solid rgba(28,26,23,.22);border-radius:6px}
.step .big{font-family:var(--f-display);font-size:clamp(56px,6vw,92px);line-height:1;color:var(--ink)}
.step .big small{font-family:var(--f-mono);font-size:.7rem;letter-spacing:.06em;color:var(--muted);display:block;margin-top:8px;text-transform:uppercase}
@media (max-width:860px){
  .how-grid{grid-template-columns:1fr;margin-top:24px}
  .how-stage{grid-area:1/1;align-items:start;padding-top:9svh;z-index:0}
  .how-stage .slot{height:46svh}
  .how-rail{display:none}
  .steps{grid-area:1/1;position:relative;z-index:1}
  .step{min-height:100svh;justify-content:flex-end;padding:0 0 6svh}
  .step-card{background:rgba(247,242,234,.94);border:1px solid rgba(28,26,23,.1);border-radius:var(--r-m);padding:20px;display:grid;gap:12px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}
  .step p{font-size:16px}
}
@media (min-width:861px){.step-card{display:grid;gap:18px}}

/* demo */
.try{background:var(--night);color:var(--on-night);padding:clamp(90px,11vw,150px) 0;margin-top:60px}
.try .sec-head p{color:var(--on-night-dim)}
.try-grid{display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr);gap:var(--gut);margin-top:56px;align-items:start}
.try-stage{position:sticky;top:96px;display:grid;justify-items:center;align-items:start}
.panel{display:grid;gap:30px}
.pstep{display:grid;gap:14px;padding-bottom:28px;border-bottom:1px solid var(--night-line)}
.pstep:last-child{border-bottom:0}
.pstep h3{font-family:var(--f-sans);font-weight:600;font-size:15px;letter-spacing:.01em;display:flex;gap:12px;align-items:baseline}
.pstep h3 i{font-style:normal;font-family:var(--f-mono);font-size:.66rem;color:var(--signal);letter-spacing:.06em}
.places{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;border:0;margin:0;padding:0}
.place{position:relative;display:block;cursor:pointer;border-radius:var(--r-m);overflow:hidden;aspect-ratio:3/4;background:#2a2622}
.place input{position:absolute;opacity:0;pointer-events:none}
.place img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;filter:saturate(.85) contrast(1.02);transition:transform .8s var(--ease-out)}
.place:hover img{transform:scale(1.04)}
.place::after{content:"";position:absolute;inset:0;background:linear-gradient(180deg,rgba(0,0,0,0) 40%,rgba(10,9,8,.82));}
.place span{position:absolute;left:12px;right:12px;bottom:10px;z-index:1;display:grid;gap:2px}
.place b{font-family:var(--f-display);font-weight:400;font-size:19px;line-height:1.1}
.place small{font-family:var(--f-mono);font-size:.58rem;letter-spacing:.05em;text-transform:uppercase;color:#d8cfc1}
.place:has(input:checked){outline:2.5px solid var(--signal);outline-offset:3px}
.place:has(input:focus-visible){outline:2.5px solid #fff;outline-offset:3px}
.recrow{display:flex;align-items:center;gap:18px;flex-wrap:wrap}
.recbtn{width:84px;height:84px;border-radius:50%;border:2px solid var(--on-night);background:transparent;display:grid;place-items:center;cursor:pointer;position:relative;flex:none}
.recbtn::before{content:"";width:58px;height:58px;border-radius:50%;background:var(--signal);transition:all .35s var(--ease-out)}
.recbtn[aria-pressed="true"]::before{width:30px;height:30px;border-radius:7px}
.recbtn:disabled{opacity:.4;cursor:not-allowed}
.timer{font-family:var(--f-mono);font-size:28px;letter-spacing:.02em;font-variant-numeric:tabular-nums}
.timer small{display:block;font-size:.62rem;letter-spacing:.08em;color:var(--on-night-dim);text-transform:uppercase;margin-top:4px}
.meter{flex:1 1 160px;height:8px;border-radius:4px;background:var(--night-2);overflow:hidden}
.meter i{display:block;height:100%;width:0;background:linear-gradient(90deg,var(--moss),#d9c35c 70%,var(--signal));transition:width .08s linear}
.tags{display:flex;flex-wrap:wrap;gap:8px;min-height:40px}
.tag{display:inline-flex;gap:8px;align-items:center;padding:8px 12px;border-radius:var(--r-pill);border:1px solid var(--night-line);background:var(--night-2);color:var(--on-night);cursor:pointer;font-size:14px;animation:pop .45s var(--ease-out)}
.tag[aria-pressed="true"]{background:var(--on-night);color:var(--ink);border-color:var(--on-night)}
.tag em{font-style:normal;font-family:var(--f-mono);font-size:.6rem;opacity:.7}
@keyframes pop{from{transform:scale(.6);opacity:0}}
.hint{font-size:14px;color:var(--on-night-dim)}
.addtag{display:flex;gap:8px;flex-wrap:wrap}
.field{display:grid;gap:6px;flex:1 1 200px}
.field label{font-size:13px;color:var(--on-night-dim)}
.inp{width:100%;padding:12px 14px;border-radius:12px;border:1px solid var(--night-line);background:var(--night-2);color:var(--on-night)}
.inp:focus-visible{outline:2.5px solid var(--signal);outline-offset:1px}
.inp[aria-invalid="true"]{border-color:#ff8a6b}
.err{font-size:13px;color:#ffab93;min-height:1.2em}
.btn-ghost{background:transparent;border:1px solid var(--night-line);color:var(--on-night)}
.btn:disabled{opacity:.4;cursor:not-allowed;transform:none}
.journal{list-style:none;margin:0;padding:0;display:grid;gap:10px}
.journal li{display:grid;grid-template-columns:56px minmax(0,1fr) auto;gap:14px;align-items:center;padding:10px;border-radius:14px;background:var(--night-2);border:1px solid transparent}
.journal li.new{border-color:var(--signal);animation:pop .5s var(--ease-out)}
.journal img{width:56px;height:56px;border-radius:10px;object-fit:cover}
.journal b{font-weight:600;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.journal small{font-family:var(--f-mono);font-size:.6rem;letter-spacing:.05em;color:var(--on-night-dim);text-transform:uppercase}
.journal svg{display:block;width:100%;height:18px;margin-top:4px}
.playbtn{width:40px;height:40px;border-radius:50%;border:1px solid var(--night-line);background:transparent;color:var(--on-night);display:grid;place-items:center;cursor:pointer}
.playbtn svg{width:14px;height:14px;margin:0}
.quota{font-family:var(--f-mono);font-size:.62rem;letter-spacing:.06em;text-transform:uppercase;color:var(--on-night-dim)}
.try .snd{color:var(--on-night)}
@media (max-width:860px){
  .try-grid{grid-template-columns:1fr;margin-top:32px}
  .try-stage{position:relative;top:0;min-height:0;padding:10px 0 20px}
  .try-stage .slot{height:min(60svh,520px)}
  .places{gap:8px}
  .place b{font-size:16px}
}

/* social proof */
.notes{padding:clamp(90px,11vw,150px) 0}
.notes-grid{display:grid;grid-template-columns:1.25fr 1fr;gap:20px;margin-top:56px}
.note{border-radius:var(--r-l);background:var(--paper);border:1px solid rgba(28,26,23,.1);padding:28px;display:grid;gap:18px;align-content:start}
.note.big{grid-row:span 2;padding:0;overflow:hidden;background:var(--ink);color:var(--bone)}
.note.big figure{margin:0;position:relative;aspect-ratio:16/10}
.note.big figure img{width:100%;height:100%;object-fit:cover;filter:saturate(.85)}
.note.big .body{padding:28px 32px 34px;display:grid;gap:18px}
.note blockquote{margin:0;font-family:var(--f-display);font-size:clamp(22px,2.1vw,30px);line-height:1.2}
.note.small blockquote{font-size:clamp(20px,1.6vw,24px)}
.who{display:flex;gap:12px;align-items:center;font-size:14px}
.who .av{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;font-family:var(--f-display);background:var(--moss);color:#fff;flex:none}
.who small{display:block;font-family:var(--f-mono);font-size:.6rem;letter-spacing:.05em;text-transform:uppercase;opacity:.7}
.note svg.wf{width:100%;height:36px;display:block}
.stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px;margin-top:20px;border-top:1px solid rgba(28,26,23,.15);padding-top:28px}
.stat b{font-family:var(--f-display);font-weight:400;font-size:clamp(40px,4.4vw,64px);line-height:1;display:block}
.stat span{font-size:15px;color:var(--muted)}
.disclaim{font-size:13px;color:var(--muted);margin-top:18px}
@media (max-width:860px){.notes-grid{grid-template-columns:1fr}.note.big{grid-row:auto}.stats{grid-template-columns:1fr;gap:16px}}

/* pricing */
.pricing{padding:clamp(90px,11vw,150px) 0;background:var(--paper);border-top:1px solid rgba(28,26,23,.08)}
.price-grid{display:grid;grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr);gap:var(--gut);align-items:center;margin-top:48px}
.price-stage{display:grid;place-items:center}
.price-stage .slot{height:min(62svh,560px)}
.toggle{display:inline-flex;border-radius:var(--r-pill);background:var(--bone);border:1px solid rgba(28,26,23,.15);padding:4px;position:relative}
.toggle button{position:relative;z-index:1;border:0;background:transparent;padding:10px 18px;border-radius:var(--r-pill);cursor:pointer;font-weight:600;font-size:15px;transition:color .3s}
.toggle button[aria-checked="true"]{color:var(--bone)}
.toggle .thumb{position:absolute;top:4px;bottom:4px;left:4px;border-radius:var(--r-pill);background:var(--ink);transition:transform .45s var(--ease-out),width .45s var(--ease-out)}
.toggle .save{font-family:var(--f-mono);font-size:.58rem;letter-spacing:.04em;color:var(--signal);margin-left:6px}
.toggle button[aria-checked="true"] .save{color:#ffb48f}
.plans{display:grid;grid-template-columns:1fr 1.15fr;gap:16px;margin-top:22px}
.plan{border-radius:var(--r-l);padding:28px;display:grid;gap:16px;align-content:start;border:1px solid rgba(28,26,23,.14);background:var(--bone)}
.plan.field{background:var(--ink);color:var(--bone);border-color:var(--ink);position:relative}
.plan .pname{display:flex;justify-content:space-between;align-items:center;font-weight:600}
.plan .pname span{font-family:var(--f-mono);font-size:.6rem;letter-spacing:.06em;text-transform:uppercase;padding:5px 8px;border-radius:6px;background:var(--signal);color:var(--ink)}
.amount{display:flex;align-items:baseline;gap:6px;font-family:var(--f-display);font-size:clamp(46px,4.6vw,64px);line-height:1}
.amount small{font-family:var(--f-sans);font-size:15px;opacity:.75}
.odo{display:inline-flex;overflow:hidden;height:1em;line-height:1}
.odo .col{display:inline-flex;flex-direction:column;transition:transform .7s var(--ease-out)}
.odo .col span{height:1em;display:block}
.odo .pt{display:inline-block}
.billed{font-size:14px;opacity:.75;min-height:1.4em}
.plan ul{list-style:none;margin:0;padding:0;display:grid;gap:10px;font-size:15.5px}
.plan li{display:grid;grid-template-columns:18px 1fr;gap:10px}
.plan li svg{width:16px;height:16px;margin-top:4px}
.plan .btn{width:100%}
.lifetime{margin-top:16px;border-radius:var(--r-m);border:1px dashed rgba(28,26,23,.35);padding:18px 22px;display:flex;flex-wrap:wrap;gap:12px 24px;align-items:center;justify-content:space-between}
.lifetime b{font-family:var(--f-display);font-weight:400;font-size:24px}
.lifetime p{color:var(--muted);font-size:15px}
.lifetime .btn{background:transparent;border:1px solid var(--ink);color:var(--ink)}
@media (max-width:860px){.price-grid{grid-template-columns:1fr}.price-stage{display:none}.plans{grid-template-columns:1fr}}

/* faq */
.faq{padding:clamp(90px,11vw,150px) 0}
.faq-grid{display:grid;grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr);gap:var(--gut)}
.faq details{border-top:1px solid rgba(28,26,23,.18)}
.faq details:last-child{border-bottom:1px solid rgba(28,26,23,.18)}
.faq summary{list-style:none;cursor:pointer;display:flex;justify-content:space-between;gap:20px;padding:22px 0;font-weight:600;font-size:clamp(17px,1.4vw,20px)}
.faq summary::-webkit-details-marker{display:none}
.faq summary i{flex:none;width:28px;height:28px;border-radius:50%;border:1px solid rgba(28,26,23,.3);position:relative;transition:transform .4s var(--ease-out),background .3s}
.faq summary i::before,.faq summary i::after{content:"";position:absolute;left:50%;top:50%;width:11px;height:1.6px;background:currentColor;transform:translate(-50%,-50%)}
.faq summary i::after{transform:translate(-50%,-50%) rotate(90deg);transition:transform .4s var(--ease-out)}
.faq details[open] summary i{background:var(--ink);color:var(--bone)}
.faq details[open] summary i::after{transform:translate(-50%,-50%) rotate(0)}
.faq .ans{display:grid;grid-template-rows:0fr;transition:grid-template-rows .45s var(--ease-out)}
.faq details[open] .ans{grid-template-rows:1fr}
.faq .ans > div{overflow:hidden}
.faq .ans p{padding:0 0 24px;color:var(--muted);max-width:62ch}
@media (max-width:860px){.faq-grid{grid-template-columns:1fr}}

/* final cta */
.get{background:var(--wall);color:var(--on-night);padding:clamp(90px,10vw,140px) 0 0;overflow:hidden}
.get-grid{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,.9fr);gap:var(--gut);align-items:center}
.get h2{font-size:clamp(40px,6vw,92px);max-width:11ch}
.get p{color:#e9e1d4;max-width:44ch;margin-top:22px;font-size:18px}
.notify{display:flex;flex-wrap:wrap;gap:10px;margin-top:28px;max-width:520px}
.notify .inp{flex:1 1 240px;background:rgba(28,26,23,.35);border-color:rgba(241,234,223,.35)}
.notify .inp::placeholder{color:#cfc5b6}
.notify .err{flex-basis:100%;color:#ffd0c0}
.ok{flex-basis:100%;font-family:var(--f-mono);font-size:.7rem;letter-spacing:.05em;text-transform:uppercase;color:#d9f0b8}
.get-stage{display:grid;place-items:center;padding:40px 0}
.get-stage .slot{height:min(64svh,560px)}
footer{margin-top:clamp(60px,8vw,110px);border-top:1px solid rgba(241,234,223,.2);padding:30px 0 40px;display:flex;flex-wrap:wrap;gap:16px 28px;align-items:center;font-size:14px;color:#ddd3c4}
footer nav{display:flex;gap:20px;flex-wrap:wrap}
footer nav a{text-decoration:none}
footer nav a:hover{text-decoration:underline}
footer .fine{margin-left:auto;max-width:52ch;font-size:13px;color:#d0c6b6}
@media (max-width:860px){.get-grid{grid-template-columns:1fr}.get-stage .slot{height:min(56svh,480px)}footer .fine{margin-left:0}}

/* dialog */
dialog{border:0;border-radius:var(--r-l);padding:0;max-width:min(460px,calc(100vw - 32px));width:100%;background:var(--paper);color:var(--ink);box-shadow:0 40px 80px -20px rgba(0,0,0,.5)}
dialog::backdrop{background:rgba(22,20,17,.6);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}
.dlg{padding:30px;display:grid;gap:16px}
.dlg h2{font-size:32px}
.dlg p{color:var(--muted)}
.dlg .inp{background:#fff;color:var(--ink);border-color:rgba(28,26,23,.25)}
.dlg .err{color:#b3261e}
.dlg .ok{color:#3c6b1f}
.dlg .row{display:flex;gap:10px;flex-wrap:wrap}
.dlg .x{position:absolute;right:14px;top:14px;width:38px;height:38px;border-radius:50%;border:1px solid rgba(28,26,23,.2);background:transparent;cursor:pointer;font-size:20px;line-height:1}
.seg{display:flex;gap:8px}
.seg label{flex:1;display:flex;gap:8px;align-items:center;padding:10px 12px;border-radius:12px;border:1px solid rgba(28,26,23,.2);cursor:pointer}
.seg label:has(input:checked){border-color:var(--ink);background:var(--bone)}
</style>
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
<div class="grain" aria-hidden="true"></div>

<div id="loader" aria-hidden="true">
  <div class="ld">
    <div class="ld-mark">earmark</div>
    <div class="ld-bars" id="ldBars"></div>
    <div class="ld-row"><span>Tuning in</span><b id="ldPct">0%</b></div>
  </div>
</div>

<canvas id="stage" aria-hidden="true"></canvas>

<header class="nav" id="nav">
  <a class="brand" href="#top" aria-label="Earmark, back to top">
    <svg viewBox="0 0 26 30" aria-hidden="true"><path d="M3 2.5h20v25l-10-6.5-10 6.5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M9 9v6M13 7v10M17 10v4" stroke="#ff5a1f" stroke-width="2" stroke-linecap="round"/></svg>
    earmark
  </a>
  <ul>
    <li><a href="#how">How it listens</a></li>
    <li><a href="#try">Try it</a></li>
    <li><a href="#pricing">Pricing</a></li>
    <li><a href="#faq">FAQ</a></li>
  </ul>
  <button class="snd" type="button" aria-pressed="false" data-sound>
    <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 6h3l4-3v10l-4-3H2z" fill="currentColor"/><path class="w" d="M11 5.5c1 .8 1 4.2 0 5M12.8 4c2 1.7 2 6.3 0 8" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/><path class="x" d="M11 6l4 4M15 6l-4 4" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>
    <span>Sound</span><span class="sr-only"> (plays synthesized place sounds)</span>
  </button>
  <a class="btn btn-signal" href="#get">Get Earmark</a>
</header>

<main id="main">
<section class="hero" id="top" aria-labelledby="h-hero">
  <img class="plate" id="plate" src="assets/studio-plate.webp" width="1920" height="1080" alt="A studio set in late window light: a dark basalt plinth on an oat-coloured sweep, an acoustic foam panel behind it and two pebbles on the floor.">
  <div class="wrap hero-in">
    <span class="eyebrow">Sound journal · iPhone &amp; Android · out 4 Dec 2026</span>
    <h1 id="h-hero"><span class="ln"><span>Keep the</span></span><span class="ln"><span>sound of</span></span><span class="ln"><span><em>a place.</em></span></span></h1>
    <p class="lede">Earmark records thirty seconds of where you are — a shingle beach, a pine wood, a wet tram stop — tags what it heard, pins it to a map and keeps it. Photos remember how it looked. This remembers how it sounded.</p>
    <div class="badges">
      <button class="badge" type="button" data-notify="iphone"><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="6" y="2" width="12" height="20" rx="3" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M10 5h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg><span><small>Out 4 Dec for</small><strong>iPhone</strong></span></button>
      <button class="badge" type="button" data-notify="android"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3l15 9-15 9z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/></svg><span><small>Out 4 Dec for</small><strong>Android</strong></span></button>
    </div>
    <div class="hero-stage" id="heroStage" aria-hidden="true"></div>
    <div class="hero-foot">
      <div class="set">
        <span class="readout"><span class="rec" id="heroRec">Rec 00:00</span><span id="heroPlace">Gullhaven shingle · surf, gulls</span></span>
        <div class="set-row" role="group" aria-label="Pick a place for the phone in the studio">
          <button class="chip" type="button" data-hero="shore" aria-pressed="true"><span class="dot"></span>Shore · whelk</button>
          <button class="chip" type="button" data-hero="forest" aria-pressed="false"><span class="dot"></span>Pine wood · cone</button>
          <button class="chip" type="button" data-hero="tram" aria-pressed="false"><span class="dot"></span>Tram stop · bell</button>
        </div>
      </div>
      <span class="scrollcue" aria-hidden="true">Scroll — the phone comes with you ↓</span>
    </div>
  </div>
</section>

<section class="how" id="how" aria-labelledby="h-how">
  <div class="wrap">
    <div class="sec-head reveal">
      <span class="eyebrow">How it listens</span>
      <h2 id="h-how">Four things it does.<br>Nothing it doesn’t.</h2>
    </div>
    <div class="how-grid">
      <div class="how-stage">
        <div class="how-rail" aria-hidden="true"><span class="on">01 Record</span><span>02 Tag</span><span>03 Map</span><span>04 Listen</span></div>
        <div class="slot" id="slotHow" data-ry="0.42" data-rx="-0.04" data-rz="-0.03"><div class="mock"><img alt="Earmark app screen for the current step" data-mock="how"></div></div>
      </div>
      <div class="steps">
        <article class="step" data-step="rec">
          <div class="step-card">
            <span class="num"><b>01</b> / Record</span>
            <h3>One tap. Thirty seconds. No settings.</h3>
            <p>Earmark records 30 seconds by default — long enough to remember a place, short enough that you actually do it. A level meter and a wind guard. That’s the whole recorder.</p>
            <ul class="specs"><li>48 kHz · 24-bit</li><li>Wind guard</li><li>Works offline</li></ul>
          </div>
        </article>
        <article class="step" data-step="tag">
          <div class="step-card">
            <span class="num"><b>02</b> / Tag</span>
            <h3>It hears the gulls so you don’t have to type.</h3>
            <p>While you record, an on-device model suggests up to five tags — surf, gulls, wind in pines, a tram bell. Keep them, drop them, add your own. Nothing is uploaded to be tagged.</p>
            <ul class="specs"><li>212 sound tags</li><li>On-device</li><li>No account needed</li></ul>
          </div>
        </article>
        <article class="step" data-step="map">
          <div class="step-card">
            <span class="num"><b>03</b> / Map</span>
            <h3>Your year, drawn as places you stopped.</h3>
            <p>Every recording pins itself where you stood. Zoom out and a year reads like a coastline, a commute and one very loud wedding. Location stays on your phone unless you share it.</p>
            <ul class="specs"><li>Offline map</li><li>Blur location on share</li></ul>
          </div>
        </article>
        <article class="step" data-step="listen">
          <div class="step-card">
            <span class="num"><b>04</b> / Listen back</span>
            <h3>Play it in the dark, on purpose.</h3>
            <p>Quiet Hours stitches your calmest recordings into a ten-minute reel with a sleep timer. Or loop one place all night: the tram stop in the rain is a surprising favourite.</p>
            <div class="big">10:00<small>A Quiet Hours reel from 9 places</small></div>
          </div>
        </article>
      </div>
    </div>
  </div>
</section>

<section class="try" id="try" aria-labelledby="h-try">
  <div class="wrap">
    <div class="sec-head reveal">
      <span class="eyebrow">Try it</span>
      <h2 id="h-try">Record something.<br>Right here.</h2>
      <p>This demo runs the real app flow on the phone beside it. It plays a synthesized sound of the place you pick — it never asks for your microphone. Turn sound on to hear it.</p>
    </div>
    <div class="try-grid">
      <div class="try-stage">
        <div class="slot" id="slotTry" data-ry="0.3" data-rx="-0.02" data-rz="0.02"><div class="mock" id="tryMock"></div></div>
      </div>
      <div class="panel">
        <div class="pstep">
          <h3><i>A</i>Pick a place</h3>
          <fieldset class="places" id="places">
            <legend class="sr-only">Place to record</legend>
            <label class="place"><input type="radio" name="place" value="shore" checked><img src="assets/place-shore.webp" alt="" loading="lazy" width="1000" height="750"><span><b>Gullhaven shingle</b><small>Shore · 06:12</small></span></label>
            <label class="place"><input type="radio" name="place" value="forest"><img src="assets/place-forest.webp" alt="" loading="lazy" width="1000" height="750"><span><b>Old Pine Hollow</b><small>Forest · 07:40</small></span></label>
            <label class="place"><input type="radio" name="place" value="tram"><img src="assets/place-tram.webp" alt="" loading="lazy" width="1000" height="750"><span><b>Kestrel St. stop</b><small>City · 18:55</small></span></label>
          </fieldset>
        </div>
        <div class="pstep">
          <h3><i>B</i>Record up to 8 seconds</h3>
          <div class="recrow">
            <button class="recbtn" id="recBtn" type="button" aria-pressed="false"><span class="sr-only" id="recLbl">Start recording</span></button>
            <div class="timer" aria-live="off"><span id="timer">00:00</span><small>of 00:08 · demo limit</small></div>
            <div class="meter" aria-hidden="true"><i id="meter"></i></div>
            <button class="snd" type="button" aria-pressed="false" data-sound><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 6h3l4-3v10l-4-3H2z" fill="currentColor"/><path class="w" d="M11 5.5c1 .8 1 4.2 0 5M12.8 4c2 1.7 2 6.3 0 8" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/><path class="x" d="M11 6l4 4M15 6l-4 4" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg><span>Sound</span></button>
          </div>
          <p class="hint" id="recStatus" role="status">Press the red button. Tags appear while it listens.</p>
        </div>
        <div class="pstep">
          <h3><i>C</i>Keep the tags that fit</h3>
          <div class="tags" id="tags" role="group" aria-label="Suggested tags"></div>
          <form class="addtag" id="tagForm" novalidate>
            <div class="field"><label for="tagIn">Add your own tag</label><input class="inp" id="tagIn" maxlength="20" placeholder="e.g. first swim" aria-describedby="tagErr"><span class="err" id="tagErr"></span></div>
            <button class="btn btn-ghost" type="submit" style="align-self:center">Add tag</button>
          </form>
        </div>
        <div class="pstep">
          <h3><i>D</i>Name it and keep it</h3>
          <form class="addtag" id="saveForm" novalidate>
            <div class="field"><label for="nameIn">Name</label><input class="inp" id="nameIn" maxlength="40" value="Gullhaven, before breakfast" aria-describedby="nameErr"><span class="err" id="nameErr"></span></div>
            <button class="btn btn-signal" id="saveBtn" type="submit" style="align-self:center" disabled>Keep it</button>
          </form>
          <p class="quota" id="quota">3 of 30 free recordings used</p>
          <ul class="journal" id="journal" aria-label="Your journal"></ul>
        </div>
      </div>
    </div>
  </div>
</section>

<section class="notes" id="notes" aria-labelledby="h-notes">
  <div class="wrap">
    <div class="sec-head reveal">
      <span class="eyebrow">Field notes from the beta</span>
      <h2 id="h-notes">What people kept.</h2>
    </div>
    <div class="notes-grid">
      <article class="note big reveal">
        <figure><img src="assets/place-shore.webp" alt="A misty pebble beach at low tide with a wooden groyne running into the sea." loading="lazy" width="1000" height="750"></figure>
        <div class="body">
          <blockquote>“My dad’s beach, the week before we sold the house. I have nine hundred photos of it and this is the one I play.”</blockquote>
          <svg class="wf" data-seed="3" viewBox="0 0 300 36" preserveAspectRatio="none" aria-hidden="true"></svg>
          <div class="who"><span class="av">R</span><span>Ruth Okafor-Lind<small>Gullhaven · 31 s · surf, gulls</small></span></div>
        </div>
      </article>
      <article class="note small reveal">
        <blockquote>“I record the first five minutes of every hike. The wren in Pine Hollow is louder than I am.”</blockquote>
        <svg class="wf" data-seed="11" viewBox="0 0 300 36" preserveAspectRatio="none" aria-hidden="true"></svg>
        <div class="who"><span class="av" style="background:#8b6b4a">T</span><span>Tomás Vereda<small>Old Pine Hollow · 30 s · wren, wind</small></span></div>
      </article>
      <article class="note small reveal">
        <blockquote>“Commute recordings sound like nothing until you move cities. Now Kestrel Street at 6 pm is the most homesick sound I own.”</blockquote>
        <svg class="wf" data-seed="27" viewBox="0 0 300 36" preserveAspectRatio="none" aria-hidden="true"></svg>
        <div class="who"><span class="av" style="background:#4d5f6b">M</span><span>Mina Haugland<small>Kestrel St. · 29 s · tram bell, rain</small></span></div>
      </article>
    </div>
    <div class="stats reveal">
      <div class="stat"><b data-count="2418">2,418</b><span>places kept during the beta</span></div>
      <div class="stat"><b data-count="61">61</b><span>countries, mostly coastlines</span></div>
      <div class="stat"><b data-count="31" data-suffix=" s">31 s</b><span>median recording, by choice</span></div>
    </div>
    <p class="disclaim">Earmark, its beta testers, quotes and numbers are fictional — this page is a design demo.</p>
  </div>
</section>

<section class="pricing" id="pricing" aria-labelledby="h-price">
  <div class="wrap">
    <div class="sec-head reveal">
      <span class="eyebrow">Pricing</span>
      <h2 id="h-price">Free for thirty places.</h2>
      <p>Most people start free and upgrade the day they hit thirty. The thirty stay yours either way.</p>
    </div>
    <div class="price-grid">
      <div class="price-stage"><div class="slot" id="slotPrice" data-ry="-0.38" data-rx="-0.03" data-rz="0.04"><div class="mock"><img alt="Earmark Field plan screen" data-mock="plan"></div></div></div>
      <div>
        <div class="toggle" role="radiogroup" aria-label="Billing period" id="bill">
          <span class="thumb" aria-hidden="true"></span>
          <button type="button" role="radio" aria-checked="true" data-bill="m">Monthly</button>
          <button type="button" role="radio" aria-checked="false" data-bill="y">Yearly <span class="save">−39%</span></button>
        </div>
        <div class="plans">
          <article class="plan">
            <div class="pname">Pocket</div>
            <div class="amount">€0<small>forever</small></div>
            <p class="billed">No card, no account.</p>
            <ul>
              <li><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8.5l4 4 8-9" fill="none" stroke="currentColor" stroke-width="1.8"/></svg>30 recordings, 30 s each</li>
              <li><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8.5l4 4 8-9" fill="none" stroke="currentColor" stroke-width="1.8"/></svg>On-device tags and the map</li>
              <li><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8.5l4 4 8-9" fill="none" stroke="currentColor" stroke-width="1.8"/></svg>AAC export</li>
            </ul>
            <a class="btn btn-ink" href="#get">Start free</a>
          </article>
          <article class="plan field">
            <div class="pname">Field <span>Most kept</span></div>
            <div class="amount" aria-live="polite"><span class="sr-only" id="priceSr">€3.99 per month</span><span aria-hidden="true">€<span class="odo" id="odo"></span></span><small aria-hidden="true">/ month</small></div>
            <p class="billed" id="billed">Billed monthly. Cancel in two taps.</p>
            <ul>
              <li><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8.5l4 4 8-9" fill="none" stroke="#ff5a1f" stroke-width="1.8"/></svg>Unlimited recordings, up to 10 min</li>
              <li><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8.5l4 4 8-9" fill="none" stroke="#ff5a1f" stroke-width="1.8"/></svg>Lossless WAV and FLAC export</li>
              <li><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8.5l4 4 8-9" fill="none" stroke="#ff5a1f" stroke-width="1.8"/></svg>Quiet Hours reels and sleep timer</li>
              <li><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8.5l4 4 8-9" fill="none" stroke="#ff5a1f" stroke-width="1.8"/></svg>Encrypted backup to your own cloud</li>
            </ul>
            <a class="btn btn-signal" href="#get">Try Field free for 14 days</a>
          </article>
        </div>
        <div class="lifetime">
          <div><b>Kept for good — €79 once</b><p>Everything in Field, no subscription. Limited to the first 2,000 people.</p></div>
          <a class="btn" href="#get">Reserve one</a>
        </div>
      </div>
    </div>
  </div>
</section>

<section class="faq" id="faq" aria-labelledby="h-faq">
  <div class="wrap faq-grid">
    <div class="sec-head reveal">
      <span class="eyebrow">FAQ</span>
      <h2 id="h-faq">Questions people ask out loud.</h2>
    </div>
    <div>
      <details><summary>Does Earmark upload my recordings?<i aria-hidden="true"></i></summary><div class="ans"><div><p>No. Recording, tagging and the map all run on your phone. Field adds an optional backup to your own iCloud or Google Drive, encrypted before it leaves the device.</p></div></div></details>
      <details><summary>Why thirty seconds?<i aria-hidden="true"></i></summary><div class="ans"><div><p>Because you will actually do it. Thirty seconds is long enough for a place to settle — the gull comes back, the tram arrives — and short enough not to feel like a chore. Field lets you go up to ten minutes.</p></div></div></details>
      <details><summary>Can I record people talking?<i aria-hidden="true"></i></summary><div class="ans"><div><p>Earmark is built for places, not conversations. Speech is detected and lowered by default, and the app reminds you to ask before recording anyone up close.</p></div></div></details>
      <details><summary>What formats can I export?<i aria-hidden="true"></i></summary><div class="ans"><div><p>AAC on Pocket. WAV and FLAC at 48 kHz / 24-bit on Field and Kept for good, with tags and coordinates written into the file metadata.</p></div></div></details>
      <details><summary>Does it work without signal?<i aria-hidden="true"></i></summary><div class="ans"><div><p>Yes. The recorder, tags and the offline map tiles for your area all work in airplane mode. That beach with no bars is the point.</p></div></div></details>
      <details><summary>What happens to my recordings if I stop paying?<i aria-hidden="true"></i></summary><div class="ans"><div><p>They stay. You keep listening to and exporting everything you recorded; you just can’t add more than thirty in total until you upgrade again.</p></div></div></details>
    </div>
  </div>
</section>

<section class="get" id="get" aria-labelledby="h-get">
  <div class="wrap">
    <div class="get-grid">
      <div>
        <span class="eyebrow">4 December 2026</span>
        <h2 id="h-get" style="margin-top:18px">Go and stand somewhere for thirty seconds.</h2>
        <p>Earmark lands on iPhone and Android on 4 December. Leave an email and we’ll send one message with the link. Then nothing else, ever.</p>
        <form class="notify" id="notifyForm" novalidate>
          <label class="sr-only" for="mail">Email address</label>
          <input class="inp" id="mail" type="email" autocomplete="email" placeholder="you@example.com" aria-describedby="mailErr">
          <button class="btn btn-signal" type="submit">Send me the link</button>
          <span class="err" id="mailErr" role="alert"></span>
        </form>
        <div class="badges">
          <button class="badge" type="button" data-notify="iphone"><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="6" y="2" width="12" height="20" rx="3" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M10 5h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg><span><small>Out 4 Dec for</small><strong>iPhone</strong></span></button>
          <button class="badge" type="button" data-notify="android"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3l15 9-15 9z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/></svg><span><small>Out 4 Dec for</small><strong>Android</strong></span></button>
        </div>
      </div>
      <div class="get-stage"><div class="slot" id="slotGet" data-ry="-0.32" data-rx="-0.05" data-rz="-0.05"><div class="mock"><img alt="Earmark journal screen listing kept places" data-mock="journal"></div></div></div>
    </div>
    <footer>
      <a class="brand" href="#top" aria-label="Earmark, back to top"><svg viewBox="0 0 26 30" aria-hidden="true"><path d="M3 2.5h20v25l-10-6.5-10 6.5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M9 9v6M13 7v10M17 10v4" stroke="#ff5a1f" stroke-width="2" stroke-linecap="round"/></svg>earmark</a>
      <nav aria-label="Footer"><a href="#how">How it listens</a><a href="#try">Try it</a><a href="#pricing">Pricing</a><a href="#faq">FAQ</a></nav>
      <p class="fine">Earmark is a fictional app made for a design demo; no real app or store listing exists. Studio set rendered in Blender Cycles; shell, pine cone and bell are real-time 3D models. © 2026</p>
    </footer>
  </div>
</section>
</main>

<dialog id="dlg" aria-labelledby="dlgT">
  <form class="dlg" id="dlgForm" method="dialog" novalidate>
    <button class="x" type="button" id="dlgX" aria-label="Close">×</button>
    <h2 id="dlgT">Not in the store yet.</h2>
    <p>Earmark lands on 4 December. Pick your phone and we’ll email the link on the day.</p>
    <div class="seg" role="radiogroup" aria-label="Your phone">
      <label><input type="radio" name="os" value="iphone" checked> iPhone</label>
      <label><input type="radio" name="os" value="android"> Android</label>
    </div>
    <label class="sr-only" for="dlgMail">Email address</label>
    <input class="inp" id="dlgMail" type="email" autocomplete="email" placeholder="you@example.com" aria-describedby="dlgErr">
    <span class="err" id="dlgErr" role="alert"></span>
    <div class="row"><button class="btn btn-ink" type="submit" id="dlgGo">Email me the link</button></div>
  </form>
</dialog>

<script type="module">
/* =========================================================================
   Earmark — shared state, app-screen renderer, audio, demo, page UI.
   The 3D stage is loaded afterwards with dynamic import(); if it fails,
   the page keeps working with poster + CSS phone mocks.
   ========================================================================= */
const RM = matchMedia('(prefers-reduced-motion: reduce)');
const $ = (s, r = document) => r.querySelector(s);
const $$ = (s, r = document) => [...r.querySelectorAll(s)];
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const lerp = (a, b, t) => a + (b - a) * t;

const PLACES = {
  shore:  { name: 'Gullhaven shingle', short: 'Gullhaven', kind: 'Shore', time: '06:12', coord: '52.10°N  1.62°E', img: 'assets/place-shore.webp',
            tags: [['surf', .94], ['gulls', .81], ['shingle drag', .66], ['wind', .52], ['foghorn', .31]], seed: 3, def: 'Gullhaven, before breakfast' },
  forest: { name: 'Old Pine Hollow', short: 'Pine Hollow', kind: 'Forest', time: '07:40', coord: '57.21°N  3.83°W', img: 'assets/place-forest.webp',
            tags: [['wren', .91], ['wind in pines', .84], ['drip', .63], ['woodpecker', .44], ['footsteps', .38]], seed: 11, def: 'Pine Hollow after rain' },
  tram:   { name: 'Kestrel St. stop', short: 'Kestrel St.', kind: 'City', time: '18:55', coord: '59.33°N 18.06°E', img: 'assets/place-tram.webp',
            tags: [['tram bell', .92], ['rain', .88], ['wire hum', .57], ['bicycle', .41], ['distant talk', .33]], seed: 27, def: 'Kestrel Street, 6 pm rain' }
};
const IMGS = {};
for (const k in PLACES) { const im = new Image(); im.src = PLACES[k].img; im.onload = () => UI.dirty = true; IMGS[k] = im; }

/* seeded random + waveform envelopes */
function rng(seed) { let s = seed * 9301 + 49297; return () => ((s = (s * 9301 + 49297) % 233280) / 233280); }
function envelope(seed, n) { const r = rng(seed); const out = []; let v = .4;
  for (let i = 0; i < n; i++) { v = clamp(v + (r() - .5) * .35, .08, 1); const sw = .5 + .5 * Math.sin(i * .21 + seed); out.push(clamp(v * (.45 + .55 * sw) * (.7 + r() * .3), .05, 1)); } return out; }

/* =========================== App screen (canvas) ======================== */
const SW = 600, SH = 1277;
const UI = {
  cv: document.createElement('canvas'), dirty: true, mode: 'rec', place: 'shore', t0: performance.now(),
  hist: [], demo: { phase: 'idle', tags: [], selected: new Set(), env: [], elapsed: 0, level: 0 }, billing: 'm', entries: [], hot: null,
  set(mode) { if (this.mode !== mode) { this.mode = mode; this.t0 = performance.now(); this.dirty = true; } }
};
UI.cv.width = SW; UI.cv.height = SH;
const g = UI.cv.getContext('2d');
const C = { bg: '#12110f', card: '#1e1c19', line: '#2f2c27', text: '#f1eadf', dim: '#9c9488', acc: '#ff5a1f', moss: '#a9c07f' };
const F = { d: '"Young Serif", Georgia, serif', s: '"Hanken Grotesk", system-ui, sans-serif', m: '"Martian Mono", ui-monospace, monospace' };
function rr(x, y, w, h, r) { g.beginPath(); g.roundRect ? g.roundRect(x, y, w, h, r) : g.rect(x, y, w, h); }
function txt(s, x, y, font, color, align = 'left') { g.font = font; g.fillStyle = color; g.textAlign = align; g.fillText(s, x, y); }
function cover(img, x, y, w, h, r) {
  if (!img || !img.complete || !img.naturalWidth) { g.fillStyle = '#2a2622'; rr(x, y, w, h, r); g.fill(); return; }
  g.save(); rr(x, y, w, h, r); g.clip(); const s = Math.max(w / img.naturalWidth, h / img.naturalHeight);
  const iw = img.naturalWidth * s, ih = img.naturalHeight * s; g.drawImage(img, x + (w - iw) / 2, y + (h - ih) / 2, iw, ih); g.restore();
}
function bars(arr, x, y, w, h, color, gap = 3, from = 0) {
  const n = arr.length; if (!n) return; const bw = (w - gap * (n - 1)) / n; g.fillStyle = color;
  for (let i = 0; i < n; i++) { const a = arr[i] * h; rr(x + i * (bw + gap), y - a / 2, Math.max(bw, 1), Math.max(a, 3), Math.min(bw / 2, 4)); g.fill(); if (i === from - 1) g.fillStyle = C.dim; }
}
function mm(sec) { sec = Math.floor(sec); return String(Math.floor(sec / 60)).padStart(2, '0') + ':' + String(sec % 60).padStart(2, '0'); }
function chrome() {
  g.fillStyle = C.bg; g.fillRect(0, 0, SW, SH);
  txt('9:41', 58, 64, `600 26px ${F.s}`, C.text);
  g.fillStyle = '#000'; rr(SW / 2 - 92, 24, 184, 52, 26); g.fill();
  g.strokeStyle = C.text; g.lineWidth = 2; rr(SW - 104, 44, 44, 22, 6); g.stroke(); g.fillStyle = C.text; rr(SW - 100, 48, 30, 14, 3); g.fill();
  g.fillStyle = C.text; for (let i = 0; i < 4; i++) { rr(SW - 170 + i * 11, 64 - (8 + i * 5), 7, 8 + i * 5, 2); g.fill(); }
  g.fillStyle = '#5a554d'; rr(SW / 2 - 90, SH - 28, 180, 8, 4); g.fill();
}
function recButton(cx, cy, prog, recording) {
  g.strokeStyle = C.line; g.lineWidth = 8; g.beginPath(); g.arc(cx, cy, 82, 0, Math.PI * 2); g.stroke();
  g.strokeStyle = C.acc; g.beginPath(); g.arc(cx, cy, 82, -Math.PI / 2, -Math.PI / 2 + Math.PI * 2 * prog); g.stroke();
  g.fillStyle = C.acc; if (recording) { rr(cx - 26, cy - 26, 52, 52, 10); g.fill(); } else { g.beginPath(); g.arc(cx, cy, 58, 0, Math.PI * 2); g.fill(); }
}
function chips(list, x, y, maxW, sel) {
  let cx = x, cy = y; g.font = `500 24px ${F.s}`;
  for (const [label] of list) { const w = g.measureText(label).width + 40; if (cx + w > x + maxW) { cx = x; cy += 58; }
    const on = !sel || sel.has(label); g.fillStyle = on ? C.text : C.card; rr(cx, cy, w, 46, 23); g.fill();
    if (!on) { g.strokeStyle = C.line; g.lineWidth = 2; g.stroke(); }
    txt(label, cx + 20, cy + 31, `500 24px ${F.s}`, on ? C.bg : C.text); cx += w + 10; }
  return cy + 46;
}
function placeEnv(place, t) { // procedural amplitude per place for non-demo screens
  const s = t * 1;
  if (place === 'shore') return clamp(.25 + .55 * Math.pow(.5 + .5 * Math.sin(s * .9), 2.5) + Math.random() * .18 + (Math.sin(s * 7.3) > .97 ? .3 : 0));
  if (place === 'forest') return clamp(.12 + Math.random() * .12 + (Math.sin(s * 3.1) * Math.sin(s * 1.7) > .55 ? .55 + Math.random() * .3 : 0));
  return clamp(.2 + .15 * Math.sin(s * .5) + Math.random() * .16 + ((s % 6) < .35 ? .7 : 0));
}
function drawRec(now, live) {
  const P = PLACES[UI.place], t = (now - UI.t0) / 1000;
  const elapsed = live ? UI.demo.elapsed : (t % 30);
  const blink = Math.floor(t * 1.6) % 2 === 0;
  g.fillStyle = blink ? C.acc : '#5c2a17'; g.beginPath(); g.arc(66, 152, 9, 0, Math.PI * 2); g.fill();
  txt('RECORDING', 86, 160, `500 20px ${F.m}`, C.acc);
  txt(P.kind.toUpperCase() + ' · ' + P.time, SW - 50, 160, `400 19px ${F.m}`, C.dim, 'right');
  txt(P.name, 50, 250, `400 58px ${F.d}`, C.text);
  txt(P.coord, 50, 296, `400 20px ${F.m}`, C.dim);
  // waveform (scrolling history)
  const N = 54;
  if (!live) { while (UI.hist.length < N) UI.hist.push(placeEnv(UI.place, t)); if (now - (UI._lp || 0) > 70) { UI.hist.push(placeEnv(UI.place, t)); UI._lp = now; } }
  while (UI.hist.length > N) UI.hist.shift();
  g.strokeStyle = C.line; g.lineWidth = 2; g.beginPath(); g.moveTo(50, 520); g.lineTo(SW - 50, 520); g.stroke();
  bars(UI.hist, 50, 520, SW - 100, 300, C.acc, 4);
  txt(mm(elapsed), SW / 2, 760, `500 84px ${F.m}`, C.text, 'center');
  txt(live ? 'OF 00:08 · DEMO' : 'OF 00:30', SW / 2, 800, `400 19px ${F.m}`, C.dim, 'center');
  const shown = live ? UI.demo.tags : P.tags.slice(0, 1 + Math.floor((elapsed % 30) / 6));
  txt('HEARD SO FAR', 50, 872, `500 18px ${F.m}`, C.dim);
  chips(shown, 50, 892, SW - 100, live ? null : null);
  recButton(SW / 2, 1130, live ? elapsed / 8 : elapsed / 30, true);
}
function drawTag(now) {
  const P = PLACES[UI.place], t = (now - UI.t0) / 1000;
  txt('TAGS', 50, 160, `500 20px ${F.m}`, C.acc);
  txt(P.name, 50, 240, `400 52px ${F.d}`, C.text);
  bars(envelope(P.seed, 60), 50, 340, SW - 100, 110, C.dim, 3);
  txt('WHAT IT HEARD · ON-DEVICE', 50, 460, `500 18px ${F.m}`, C.dim);
  P.tags.forEach(([label, conf], i) => {
    const y = 510 + i * 96, k = clamp((t - i * .18) / .9); const e = 1 - Math.pow(1 - k, 3);
    txt(label, 50, y + 30, `600 30px ${F.s}`, C.text);
    txt(Math.round(conf * 100 * e) + '%', SW - 50, y + 30, `400 22px ${F.m}`, C.dim, 'right');
    g.fillStyle = C.line; rr(50, y + 50, SW - 100, 10, 5); g.fill();
    g.fillStyle = i < 3 ? C.acc : C.dim; rr(50, y + 50, (SW - 100) * conf * e, 10, 5); g.fill();
  });
  g.fillStyle = C.text; rr(50, 1050, SW - 100, 92, 46); g.fill();
  txt('Keep 3 tags', SW / 2, 1108, `600 30px ${F.s}`, C.bg, 'center');
  return t < 2;
}
function drawMap(now) {
  const t = (now - UI.t0) / 1000;
  g.fillStyle = '#191814'; g.fillRect(0, 100, SW, SH - 100);
  g.save(); g.beginPath(); g.rect(0, 100, SW, SH - 100); g.clip();
  g.strokeStyle = '#26241f'; g.lineWidth = 2;
  for (let k = 0; k < 14; k++) { g.beginPath(); for (let x = -20; x <= SW + 20; x += 20) { const y = 140 + k * 52 + Math.sin(x * .012 + k * .7) * 26 + Math.sin(x * .031 + k) * 9; x === -20 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke(); }
  g.fillStyle = '#24221d'; g.beginPath(); g.moveTo(0, 100);
  for (let y = 100; y <= 860; y += 20) g.lineTo(190 + Math.sin(y * .02) * 50 + Math.sin(y * .053) * 22, y);
  g.lineTo(0, 860); g.closePath(); g.fill();
  g.strokeStyle = '#4a453c'; g.lineWidth = 3; g.beginPath();
  for (let y = 100; y <= 860; y += 20) { const x = 190 + Math.sin(y * .02) * 50 + Math.sin(y * .053) * 22; y === 100 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke();
  g.restore();
  const pins = [[250, 300, 'shore'], [420, 520, 'forest'], [330, 700, 'tram'], [480, 260], [270, 610], [520, 760], [380, 380]];
  pins.forEach(([x, y, k], i) => { const p = (t * .8 + i * .3) % 1;
    g.strokeStyle = `rgba(255,90,31,${(1 - p) * .6})`; g.lineWidth = 3; g.beginPath(); g.arc(x, y, 12 + p * 34, 0, Math.PI * 2); g.stroke();
    g.fillStyle = k ? C.acc : '#c66a45'; g.beginPath(); g.arc(x, y, k ? 13 : 8, 0, Math.PI * 2); g.fill(); });
  g.fillStyle = C.card; rr(270, 230, 250, 54, 12); g.fill();
  txt('Gullhaven · 06:12', 290, 266, `500 22px ${F.s}`, C.text);
  txt('YOUR YEAR · 14 PLACES', 50, 160, `500 20px ${F.m}`, C.acc);
  g.fillStyle = C.bg; rr(0, 850, SW, SH - 850, 40); g.fill();
  g.fillStyle = '#4a453c'; rr(SW / 2 - 40, 866, 80, 8, 4); g.fill();
  ['shore', 'forest', 'tram'].forEach((k, i) => { const P = PLACES[k], y = 900 + i * 112;
    cover(IMGS[k], 50, y, 88, 88, 16); txt(P.name, 160, y + 36, `600 28px ${F.s}`, C.text);
    txt(P.kind.toUpperCase() + ' · 30 S · ' + P.tags[0][0].toUpperCase(), 160, y + 72, `400 17px ${F.m}`, C.dim); });
  return true;
}
function drawListen(now) {
  const t = (now - UI.t0) / 1000, cx = SW / 2, cy = 470;
  txt('QUIET HOURS', 50, 160, `500 20px ${F.m}`, C.acc);
  const env = envelope(41, 120);
  for (let i = 0; i < 120; i++) { const a = i / 120 * Math.PI * 2 + t * .15, r0 = 150, r1 = r0 + env[i] * 90;
    g.strokeStyle = i / 120 < ((t * .05) % 1) ? C.acc : '#4a453c'; g.lineWidth = 5; g.lineCap = 'round';
    g.beginPath(); g.moveTo(cx + Math.cos(a) * r0, cy + Math.sin(a) * r0); g.lineTo(cx + Math.cos(a) * r1, cy + Math.sin(a) * r1); g.stroke(); }
  cover(IMGS.forest, cx - 120, cy - 120, 240, 240, 120);
  txt('Nine places, ten minutes', SW / 2, 800, `400 40px ${F.d}`, C.text, 'center');
  txt('SHORE → PINE WOOD → RAIN', SW / 2, 846, `400 19px ${F.m}`, C.dim, 'center');
  const p = (t * .05) % 1; g.fillStyle = C.line; rr(50, 905, SW - 100, 8, 4); g.fill(); g.fillStyle = C.text; rr(50, 905, (SW - 100) * p, 8, 4); g.fill();
  g.beginPath(); g.arc(50 + (SW - 100) * p, 909, 13, 0, Math.PI * 2); g.fill();
  txt(mm(p * 600), 50, 960, `400 20px ${F.m}`, C.dim); txt('10:00', SW - 50, 960, `400 20px ${F.m}`, C.dim, 'right');
  g.fillStyle = C.text; g.beginPath(); g.arc(cx, 1080, 62, 0, Math.PI * 2); g.fill();
  g.fillStyle = C.bg; rr(cx - 20, 1056, 14, 48, 3); g.fill(); rr(cx + 6, 1056, 14, 48, 3); g.fill();
  g.fillStyle = C.card; rr(SW - 220, 1052, 170, 56, 28); g.fill(); txt('Sleep 20m', SW - 135, 1088, `500 22px ${F.s}`, C.text, 'center');
  g.fillStyle = C.card; rr(50, 1052, 120, 56, 28); g.fill(); txt('Loop', 110, 1088, `500 22px ${F.s}`, C.text, 'center');
  return true;
}
function drawDemoIdle() {
  const P = PLACES[UI.place];
  txt('NEW RECORDING', 50, 160, `500 20px ${F.m}`, C.acc);
  cover(IMGS[UI.place], 40, 190, SW - 80, 520, 36);
  const gr = g.createLinearGradient(0, 450, 0, 710); gr.addColorStop(0, 'rgba(18,17,15,0)'); gr.addColorStop(1, 'rgba(18,17,15,.9)');
  g.fillStyle = gr; rr(40, 190, SW - 80, 520, 36); g.fill();
  txt(P.name, 70, 660, `400 50px ${F.d}`, C.text);
  txt(P.coord, 70, 694, `400 18px ${F.m}`, '#d8cfc1');
  txt('Tap record.', SW / 2, 840, `400 44px ${F.d}`, C.text, 'center');
  txt('8 SECONDS IN THE DEMO · 30 IN THE APP', SW / 2, 884, `400 17px ${F.m}`, C.dim, 'center');
  recButton(SW / 2, 1110, 0, false);
}
function drawDemoReview() {
  const P = PLACES[UI.place], d = UI.demo;
  txt('REVIEW', 50, 160, `500 20px ${F.m}`, C.acc);
  txt(P.name, 50, 240, `400 52px ${F.d}`, C.text);
  txt(mm(d.elapsed) + ' · ' + P.coord, 50, 284, `400 19px ${F.m}`, C.dim);
  const env = d.env.length ? d.env : envelope(P.seed, 60);
  const n = 70, arr = [], mx = Math.max(...env, .2);
  for (let i = 0; i < n; i++) { const f = i / (n - 1) * (env.length - 1), a = env[Math.floor(f)], b = env[Math.ceil(f)];
    arr.push(clamp((a + (b - a) * (f % 1)) / mx * (.82 + .18 * Math.abs(Math.sin(i * 2.7))), .05, 1)); }
  const pp = d.playing ? clamp((performance.now() - d.playT0) / 1000 / Math.max(d.elapsed, .5)) : 0;
  bars(arr, 50, 470, SW - 100, 240, C.acc, 3, d.playing ? Math.floor(pp * n) : 0);
  txt('TAGS · TAP TO KEEP', 50, 660, `500 18px ${F.m}`, C.dim);
  const all = [...d.tags, ...d.custom.map(c => [c, 1])];
  const yEnd = chips(all, 50, 684, SW - 100, d.selected);
  g.fillStyle = C.acc; rr(50, 1050, SW - 100, 92, 46); g.fill();
  txt('Keep it', SW / 2, 1108, `600 32px ${F.s}`, C.bg, 'center');
  UI.hot = { save: [50 / SW, 1050 / SH, (SW - 50) / SW, 1142 / SH] };
  return d.playing;
}
function drawJournal(now, highlight) {
  txt(highlight ? 'KEPT' : 'JOURNAL', 50, 160, `500 20px ${F.m}`, C.acc);
  const list = [...UI.entries.map(e => ({ ...e, mine: true })), { place: 'shore', name: 'Gullhaven, low tide', meta: 'SHORE · 31 S · SURF' }, { place: 'forest', name: 'Pine Hollow, the wren', meta: 'FOREST · 30 S · WREN' }, { place: 'tram', name: 'Kestrel St., first snow', meta: 'CITY · 29 S · TRAM BELL' }];
  txt(`${12 + UI.entries.length} places`, 50, 240, `400 56px ${F.d}`, C.text);
  list.slice(0, 5).forEach((e, i) => { const y = 300 + i * 172, k = highlight && e.mine && i === 0;
    g.fillStyle = k ? '#2a1a12' : C.card; rr(40, y, SW - 80, 150, 26); g.fill();
    if (k) { g.strokeStyle = C.acc; g.lineWidth = 3; g.stroke(); }
    cover(IMGS[e.place], 60, y + 20, 110, 110, 18);
    g.save(); g.font = `600 27px ${F.s}`; let nm = e.name; while (g.measureText(nm).width > 330 && nm.length > 4) nm = nm.slice(0, -2); if (nm !== e.name) nm += '…'; g.restore();
    txt(nm, 192, y + 52, `600 27px ${F.s}`, C.text);
    txt(e.meta, 192, y + 86, `400 16px ${F.m}`, C.dim);
    bars(envelope(PLACES[e.place].seed + i, 30), 192, y + 118, 330, 26, k ? C.acc : '#4a453c', 3); });
}
function drawPlan() {
  const y = UI.billing === 'y';
  txt('EARMARK FIELD', 50, 160, `500 20px ${F.m}`, C.acc);
  txt('Keep', 50, 270, `400 92px ${F.d}`, C.text); txt('everything.', 50, 370, `400 92px ${F.d}`, C.text);
  ['Unlimited places', 'Ten-minute recordings', 'WAV + FLAC export', 'Quiet Hours reels'].forEach((s, i) => {
    g.strokeStyle = C.acc; g.lineWidth = 5; g.beginPath(); g.moveTo(56, 470 + i * 70); g.lineTo(70, 484 + i * 70); g.lineTo(94, 456 + i * 70); g.stroke();
    txt(s, 120, 482 + i * 70, `500 30px ${F.s}`, C.text); });
  g.fillStyle = C.card; rr(40, 790, SW - 80, 180, 28); g.fill();
  txt(y ? '€2.42' : '€3.99', 70, 890, `400 76px ${F.d}`, C.text);
  txt('/ MONTH', 300, 890, `400 20px ${F.m}`, C.dim);
  txt(y ? 'BILLED €29 YEARLY · SAVE 39%' : 'BILLED MONTHLY', 70, 940, `400 18px ${F.m}`, y ? C.moss : C.dim);
  g.fillStyle = C.acc; rr(40, 1040, SW - 80, 96, 48); g.fill(); txt('Try free for 14 days', SW / 2, 1100, `600 30px ${F.s}`, C.bg, 'center');
}
UI.draw = function (now) {
  chrome(); UI.hot = null; let anim = false;
  switch (UI.mode) {
    case 'rec': drawRec(now, false); anim = true; break;
    case 'tag': anim = drawTag(now); break;
    case 'map': anim = drawMap(now); break;
    case 'listen': anim = drawListen(now); break;
    case 'demo': {
      const ph = UI.demo.phase;
      if (ph === 'idle') { drawDemoIdle(); UI.hot = { rec: [.25, .78, .75, .96] }; }
      else if (ph === 'rec') { drawRec(now, true); anim = true; UI.hot = { rec: [.25, .78, .75, .96] }; }
      else if (ph === 'review') anim = drawDemoReview();
      else drawJournal(now, true);
      break; }
    case 'plan': drawPlan(); break;
    case 'journal': drawJournal(now, false); break;
  }
  return anim;
};
/* screen → hit (from the 3D raycast: uv in 0..1, v from top) */
UI.hit = function (u, v) {
  const h = UI.hot; if (!h) return false;
  const inside = r => u >= r[0] && u <= r[2] && v >= r[1] && v <= r[3];
  if (h.rec && inside(h.rec)) { Demo.toggleRec(); return true; }
  if (h.save && inside(h.save)) { $('#saveForm').requestSubmit(); return true; }
  return false;
};

/* =============================== Audio ================================== */
const Audio = {
  ctx: null, on: false, master: null, analyser: null, buf: null, live: null,
  ensure() {
    if (this.ctx) return this.ctx;
    const AC = window.AudioContext || window.webkitAudioContext; if (!AC) return null;
    this.ctx = new AC(); this.master = this.ctx.createGain(); this.master.gain.value = this.on ? .7 : 0; this.master.connect(this.ctx.destination);
    this.analyser = this.ctx.createAnalyser(); this.analyser.fftSize = 1024; this.analyser.connect(this.master);
    this.buf = new Float32Array(this.analyser.fftSize);
    const len = this.ctx.sampleRate * 2, nb = this.ctx.createBuffer(1, len, this.ctx.sampleRate), d = nb.getChannelData(0);
    let b = 0; for (let i = 0; i < len; i++) { const w = Math.random() * 2 - 1; b = (b + .02 * w) / 1.02; d[i] = b * 3.5; } // brown noise
    this.brown = nb;
    const wb = this.ctx.createBuffer(1, len, this.ctx.sampleRate), wd = wb.getChannelData(0); for (let i = 0; i < len; i++) wd[i] = Math.random() * 2 - 1; this.white = wb;
    return this.ctx;
  },
  setOn(v) { this.on = v; if (this.master) this.master.gain.setTargetAtTime(v ? .7 : 0, this.ctx.currentTime, .05); $$('[data-sound]').forEach(b => b.setAttribute('aria-pressed', String(v))); },
  noise(type, freq, q = .7, gain = .5, ftype = 'lowpass') {
    const c = this.ctx, s = c.createBufferSource(); s.buffer = type === 'brown' ? this.brown : this.white; s.loop = true;
    const f = c.createBiquadFilter(); f.type = ftype; f.frequency.value = freq; f.Q.value = q; const gn = c.createGain(); gn.gain.value = gain;
    s.connect(f); f.connect(gn); s.start(); return { s, f, g: gn };
  },
  chirp(out, t, f0, f1, dur, vol) { const c = this.ctx, o = c.createOscillator(), gn = c.createGain(); o.type = 'sine';
    o.frequency.setValueAtTime(f0, t); o.frequency.exponentialRampToValueAtTime(f1, t + dur);
    gn.gain.setValueAtTime(0, t); gn.gain.linearRampToValueAtTime(vol, t + .01); gn.gain.exponentialRampToValueAtTime(.0001, t + dur);
    o.connect(gn); gn.connect(out); o.start(t); o.stop(t + dur + .05); },
  bell(out, t, vol = .25) { [1650, 2390, 3720].forEach((f, i) => { const c = this.ctx, o = c.createOscillator(), gn = c.createGain(); o.frequency.value = f;
    gn.gain.setValueAtTime(vol / (i + 1), t); gn.gain.exponentialRampToValueAtTime(.0001, t + 1.6 - i * .3); o.connect(gn); gn.connect(out); o.start(t); o.stop(t + 1.7); }); },
  /* start a looping synthesized place; returns stop() */
  start(place, dur = 8) {
    const c = this.ensure(); if (!c) return null; c.resume && c.resume();
    const bus = c.createGain(); bus.gain.value = 0; bus.connect(this.analyser); bus.gain.linearRampToValueAtTime(1, c.currentTime + .25);
    const nodes = [], t0 = c.currentTime;
    if (place === 'shore') {
      const n = this.noise('brown', 700, .5, .9); n.g.connect(bus); nodes.push(n.s);
      const lfo = c.createOscillator(), lg = c.createGain(); lfo.frequency.value = .16; lg.gain.value = .55; lfo.connect(lg); lg.connect(n.g.gain); lfo.start(); nodes.push(lfo);
      const h = this.noise('white', 5200, .3, .05, 'highpass'); h.g.connect(bus); nodes.push(h.s);
      for (let k = 0; k < dur; k += 2.3) { this.chirp(bus, t0 + 1 + k + Math.random(), 1850, 1150, .35, .07); this.chirp(bus, t0 + 1.45 + k + Math.random() * .4, 1700, 1250, .28, .05); }
    } else if (place === 'forest') {
      const n = this.noise('brown', 420, .4, .45); n.g.connect(bus); nodes.push(n.s);
      for (let k = 0; k < dur * 3.2; k++) { const tt = t0 + .4 + k * .31 + Math.random() * .2; if (Math.random() < .65) this.chirp(bus, tt, 3800 + Math.random() * 1600, 2600 + Math.random() * 900, .07 + Math.random() * .06, .05); }
      for (let k = 0; k < 6; k++) { const tt = t0 + 2.5 + k * .065; this.chirp(bus, tt, 900, 700, .04, .08); }
    } else {
      const n = this.noise('brown', 180, .7, 1.0); n.g.connect(bus); nodes.push(n.s);
      const r = this.noise('white', 3000, .4, .09, 'bandpass'); r.g.connect(bus); nodes.push(r.s);
      const o = c.createOscillator(), og = c.createGain(); o.frequency.value = 100; og.gain.value = .018; o.connect(og); og.connect(bus); o.start(); nodes.push(o);
      this.bell(bus, t0 + 1.6); this.bell(bus, t0 + 2.0); this.bell(bus, t0 + 5.8, .18);
    }
    const stop = () => { const tt = c.currentTime; bus.gain.cancelScheduledValues(tt); bus.gain.setValueAtTime(bus.gain.value, tt); bus.gain.linearRampToValueAtTime(0, tt + .3);
      setTimeout(() => { nodes.forEach(n => { try { n.stop(); } catch (e) {} }); bus.disconnect(); }, 400); };
    return { stop };
  },
  level() { if (!this.analyser) return null; this.analyser.getFloatTimeDomainData(this.buf); let s = 0; for (const v of this.buf) s += v * v; return Math.sqrt(s / this.buf.length); }
};
$$('[data-sound]').forEach(b => b.addEventListener('click', () => { Audio.ensure(); Audio.setOn(b.getAttribute('aria-pressed') !== 'true'); }));

/* ================================ Demo ================================== */
const Demo = {
  timer: null, snd: null,
  els: { rec: $('#recBtn'), lbl: $('#recLbl'), time: $('#timer'), meter: $('#meter'), status: $('#recStatus'), tags: $('#tags'), save: $('#saveBtn'), name: $('#nameIn'), journal: $('#journal'), quota: $('#quota') },
  setPlace(k) { if (UI.demo.phase === 'rec') this.stop(); UI.place = k; UI.demo.phase = 'idle'; UI.demo.tags = []; UI.demo.custom = []; UI.demo.selected = new Set(); UI.demo.env = []; UI.hist = [];
    this.els.tags.innerHTML = ''; this.els.save.disabled = true; this.els.name.value = PLACES[k].def; this.els.time.textContent = '00:00';
    this.els.status.textContent = `${PLACES[k].name} selected. Press the red button.`; UI.dirty = true; window.dispatchEvent(new CustomEvent('em:place', { detail: k })); },
  toggleRec() { UI.demo.phase === 'rec' ? this.stop() : this.start(); },
  start() {
    const d = UI.demo, P = PLACES[UI.place]; d.phase = 'rec'; d.tags = []; d.custom = d.custom || []; d.selected = new Set(); d.env = []; d.elapsed = 0; UI.hist = []; this.els.tags.innerHTML = '';
    this.els.rec.setAttribute('aria-pressed', 'true'); this.els.lbl.textContent = 'Stop recording'; this.els.status.textContent = `Recording ${P.name}…`;
    this.snd = Audio.start(UI.place); const t0 = performance.now(); let lastPush = 0;
    const tick = (now) => {
      if (d.phase !== 'rec') return;
      d.elapsed = (now - t0) / 1000;
      let lv = Audio.level(); lv = lv == null ? placeEnv(UI.place, d.elapsed) * .5 : clamp(lv * 3.2);
      if (!Audio.ctx || Audio.ctx.state !== 'running') lv = placeEnv(UI.place, d.elapsed) * .55;
      d.level = lv; if (now - lastPush > 60) { const v = clamp(lv * 1.6 + .04); UI.hist.push(v); d.env.push(v); lastPush = now; }
      this.els.time.textContent = mm(d.elapsed); this.els.meter.style.width = (clamp(lv * 1.4) * 100).toFixed(0) + '%';
      const want = Math.min(P.tags.length, Math.floor(d.elapsed / 1.4)); while (d.tags.length < want) this.addSuggest(P.tags[d.tags.length]);
      UI.dirty = true; window.dispatchEvent(new CustomEvent('em:level', { detail: lv }));
      if (d.elapsed >= 8) return this.stop(); this.timer = requestAnimationFrame(tick);
    };
    this.timer = requestAnimationFrame(tick); UI.dirty = true; window.dispatchEvent(new CustomEvent('em:rec', { detail: true }));
  },
  stop() {
    const d = UI.demo; if (d.phase !== 'rec') return; cancelAnimationFrame(this.timer); this.snd && this.snd.stop(); this.snd = null;
    while (d.tags.length < Math.min(3, PLACES[UI.place].tags.length)) this.addSuggest(PLACES[UI.place].tags[d.tags.length]);
    d.phase = d.elapsed < .6 ? 'idle' : 'review'; this.els.meter.style.width = '0%';
    this.els.rec.setAttribute('aria-pressed', 'false'); this.els.lbl.textContent = 'Record again';
    this.els.save.disabled = d.phase !== 'review';
    this.els.status.textContent = d.phase === 'review' ? `Recorded ${mm(d.elapsed)}. Keep the tags that fit, then press Keep it.` : 'Too short — hold on a moment longer.';
    UI.dirty = true; window.dispatchEvent(new CustomEvent('em:rec', { detail: false }));
  },
  addSuggest([label, conf]) { const d = UI.demo; d.tags.push([label, conf]); if (conf > .5) d.selected.add(label); this.chip(label, conf > .5, Math.round(conf * 100) + '%'); },
  chip(label, on, note) { const b = document.createElement('button'); b.type = 'button'; b.className = 'tag'; b.setAttribute('aria-pressed', String(on));
    b.innerHTML = `<span></span>${note ? `<em>${note}</em>` : ''}`; b.firstChild.textContent = label;
    b.addEventListener('click', () => { const s = UI.demo.selected; s.has(label) ? s.delete(label) : s.add(label); b.setAttribute('aria-pressed', String(s.has(label))); UI.dirty = true; });
    this.els.tags.appendChild(b); },
  save() {
    const d = UI.demo, n = this.els.name, err = $('#nameErr'); const v = n.value.trim();
    if (d.phase !== 'review') { err.textContent = 'Record something first.'; return; }
    if (v.length < 2) { n.setAttribute('aria-invalid', 'true'); err.textContent = 'Give it a name of at least 2 characters.'; n.focus(); return; }
    n.removeAttribute('aria-invalid'); err.textContent = '';
    const P = PLACES[UI.place], tags = [...d.selected];
    const e = { place: UI.place, name: v, meta: `${P.kind.toUpperCase()} · ${Math.round(d.elapsed)} S · ${(tags[0] || 'untagged').toUpperCase()}`, env: d.env.slice(), dur: d.elapsed };
    UI.entries.unshift(e); d.phase = 'saved'; this.els.save.disabled = true;
    const li = document.createElement('li'); li.className = 'new';
    li.innerHTML = `<img src="${P.img}" alt=""><div><b></b><small></small>${svgWave(e.env, 300, 18)}</div><button class="playbtn" type="button"><svg viewBox="0 0 14 14" aria-hidden="true"><path d="M3 1.5l9 5.5-9 5.5z" fill="currentColor"/></svg><span class="sr-only">Play ${escapeHtml(v)}</span></button>`;
    li.querySelector('b').textContent = v; li.querySelector('small').textContent = e.meta;
    li.querySelector('.playbtn').addEventListener('click', () => this.play(e));
    $$('.journal li.new').forEach(x => x.classList.remove('new')); this.els.journal.prepend(li);
    this.els.quota.textContent = `${3 + UI.entries.length} of 30 free recordings used`;
    this.els.status.textContent = `Kept “${v}”. It’s in your journal below and on the phone.`;
    UI.dirty = true; window.dispatchEvent(new CustomEvent('em:saved'));
  },
  play(e) { const s = Audio.start(e.place); if (s) setTimeout(() => s.stop(), Math.max(1500, e.dur * 1000)); window.dispatchEvent(new CustomEvent('em:ping', { detail: e.place })); }
};
function escapeHtml(s) { return s.replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c])); }
function svgWave(env, w, h) { const n = 50, bw = w / n, mx = Math.max(...env, .15); let p = '';
  for (let i = 0; i < n; i++) { const v = (env[Math.floor(i / n * env.length)] || .1) / mx * (.8 + .2 * Math.abs(Math.sin(i * 2.7))), a = Math.max(1.5, v * h); p += `<rect x="${(i * bw).toFixed(1)}" y="${((h - a) / 2).toFixed(1)}" width="${(bw * .6).toFixed(1)}" height="${a.toFixed(1)}" rx="1"/>`; }
  return `<svg viewBox="0 0 ${w} ${h}" preserveAspectRatio="none" aria-hidden="true" fill="#ff5a1f">${p}</svg>`; }
$$('#places input').forEach(r => r.addEventListener('change', () => Demo.setPlace(r.value)));
Demo.els.rec.addEventListener('click', () => { Audio.ensure(); Demo.toggleRec(); });
$('#saveForm').addEventListener('submit', e => { e.preventDefault(); Demo.save(); });
$('#tagForm').addEventListener('submit', e => { e.preventDefault(); const i = $('#tagIn'), err = $('#tagErr'), v = i.value.trim().toLowerCase();
  if (!/^[\p{L}][\p{L} '\-]{1,19}$/u.test(v)) { i.setAttribute('aria-invalid', 'true'); err.textContent = 'Use 2–20 letters (spaces and hyphens are fine).'; return; }
  const d = UI.demo; d.custom = d.custom || []; if (d.custom.includes(v) || d.tags.some(t => t[0] === v)) { err.textContent = 'That tag is already there.'; return; }
  i.removeAttribute('aria-invalid'); err.textContent = ''; d.custom.push(v); d.selected.add(v); Demo.chip(v, true, 'yours'); i.value = ''; UI.dirty = true; });
UI.demo.custom = [];
// seed journal with two kept places so the list never looks empty
[['forest', 'Pine Hollow, the wren', 'FOREST · 30 S · WREN'], ['tram', 'Kestrel St., first snow', 'CITY · 29 S · TRAM BELL']].forEach(([k, n, m], i) => {
  const li = document.createElement('li'); const env = envelope(PLACES[k].seed + 5, 60);
  li.innerHTML = `<img src="${PLACES[k].img}" alt=""><div><b>${n}</b><small>${m}</small>${svgWave(env, 300, 18)}</div><button class="playbtn" type="button"><svg viewBox="0 0 14 14" aria-hidden="true"><path d="M3 1.5l9 5.5-9 5.5z" fill="currentColor"/></svg><span class="sr-only">Play ${n}</span></button>`;
  li.querySelector('.playbtn').addEventListener('click', () => Demo.play({ place: k, dur: 4 })); Demo.els.journal.appendChild(li); });
$$('svg.wf').forEach(s => { const env = envelope(+s.dataset.seed, 60); s.outerHTML = svgWave(env, 300, 36).replace('<svg ', '<svg class="wf" '); });

/* ============================ Hero place set ============================ */
let heroPlace = 'shore';
function setHeroPlace(k, fromUser) {
  heroPlace = k; $$('[data-hero]').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.hero === k)));
  const P = PLACES[k]; $('#heroPlace').textContent = `${P.name} · ${P.tags[0][0]}, ${P.tags[1][0]}`;
  if (CUR.key === 'hero' || CUR.key === 'how') { UI.place = k; UI.hist = []; UI.dirty = true; }
  if (fromUser) { window.dispatchEvent(new CustomEvent('em:ping', { detail: k })); if (Audio.on) { const s = Audio.start(k); s && setTimeout(() => s.stop(), 2600); } }
}
$$('[data-hero]').forEach(b => b.addEventListener('click', () => { Audio.ensure(); setHeroPlace(b.dataset.hero, true); }));
window.addEventListener('em:pick', e => { Audio.ensure(); setHeroPlace(e.detail, true); });
setInterval(() => { if (document.hidden) return; const s = ((performance.now() - UI.t0) / 1000) % 30; $('#heroRec').textContent = 'Rec ' + mm(s); }, 500);

/* ======================= Which screen is on the phone ==================== */
const CUR = { key: 'hero', step: 'rec' };
function screenFor(key) { return key === 'hero' ? 'rec' : key === 'how' ? CUR.step : key === 'try' ? 'demo' : key === 'pricing' ? 'plan' : key === 'get' ? 'journal' : UI.mode; }
window.EM = { UI, PLACES, IMGS, CUR, Demo, Audio, RM, screenFor, get heroPlace() { return heroPlace; } };
function applyScreen(key) { // called by 3D (mid-flip) or by the fallback directly
  const m = screenFor(key);
  if (m === 'rec' || key === 'how') { if (UI.place !== heroPlace && UI.demo.phase !== 'rec' && key !== 'try') UI.place = heroPlace; }
  if (key === 'try') UI.place = $('#places input:checked').value;
  UI.set(m); UI.hist = m === 'rec' ? UI.hist : UI.hist; UI.dirty = true;
}
window.EM.applyScreen = applyScreen;

const stepEls = $$('.step'); const railEls = $$('.how-rail span');
const stepIO = new IntersectionObserver(es => { es.forEach(e => { if (e.isIntersecting) { const s = e.target.dataset.step; if (CUR.step !== s) { CUR.step = s; railEls.forEach((r, i) => r.classList.toggle('on', stepEls[i].dataset.step === s)); window.dispatchEvent(new CustomEvent('em:screen')); } } }); }, { rootMargin: '-45% 0px -45% 0px' });
stepEls.forEach(s => stepIO.observe(s));

/* =============================== Pricing ================================ */
const odo = $('#odo');
function buildOdo(str) { odo.innerHTML = ''; for (const ch of str) { if (ch === '.') { const s = document.createElement('span'); s.className = 'pt'; s.textContent = '.'; odo.appendChild(s); continue; }
  const col = document.createElement('span'); col.className = 'col'; col.innerHTML = [...'0123456789'].map(d => `<span>${d}</span>`).join(''); col.dataset.d = ch; odo.appendChild(col); } setOdo(str); }
function setOdo(str) { const cols = $$('.col', odo); let i = 0; for (const ch of str) { if (ch === '.') continue; cols[i++].style.transform = `translateY(${-+ch}em)`; } }
buildOdo('3.99');
const billBtns = $$('#bill [role=radio]'), thumb = $('#bill .thumb');
function placeThumb() { const on = billBtns.find(b => b.getAttribute('aria-checked') === 'true'); thumb.style.width = on.offsetWidth + 'px'; thumb.style.transform = `translateX(${on.offsetLeft - 4}px)`; }
function setBill(v, focus) { billBtns.forEach(b => { const on = b.dataset.bill === v; b.setAttribute('aria-checked', String(on)); b.tabIndex = on ? 0 : -1; if (on && focus) b.focus(); });
  UI.billing = v; setOdo(v === 'y' ? '2.42' : '3.99'); $('#priceSr').textContent = v === 'y' ? '€2.42 per month, billed €29 yearly' : '€3.99 per month';
  $('#billed').textContent = v === 'y' ? 'Billed €29 once a year. That’s 39% less.' : 'Billed monthly. Cancel in two taps.'; placeThumb(); if (UI.mode === 'plan') UI.dirty = true; }
billBtns.forEach(b => { b.addEventListener('click', () => setBill(b.dataset.bill)); b.addEventListener('keydown', e => { if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key)) { e.preventDefault(); setBill(UI.billing === 'm' ? 'y' : 'm', true); } }); });
setBill('m'); addEventListener('resize', placeThumb); document.fonts && document.fonts.ready.then(placeThumb);

/* ============================ Forms & dialog ============================ */
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
$('#notifyForm').addEventListener('submit', e => { e.preventDefault(); const i = $('#mail'), err = $('#mailErr'), f = e.currentTarget;
  if (!EMAIL.test(i.value.trim())) { i.setAttribute('aria-invalid', 'true'); err.textContent = 'That doesn’t look like an email address yet.'; i.focus(); return; }
  i.removeAttribute('aria-invalid'); err.textContent = ''; f.innerHTML = `<p class="ok" role="status">Done. One email on 4 December to ${escapeHtml(i.value.trim())}. That’s it.</p>`; });
const dlg = $('#dlg');
$$('[data-notify]').forEach(b => b.addEventListener('click', () => { const r = $(`#dlg input[value=${b.dataset.notify}]`); if (r) r.checked = true; $('#dlgErr').textContent = '';
  if (dlg.showModal) dlg.showModal(); else location.hash = '#get'; }));
$('#dlgX').addEventListener('click', () => dlg.close());
dlg.addEventListener('click', e => { if (e.target === dlg) dlg.close(); });
$('#dlgForm').addEventListener('submit', e => { const i = $('#dlgMail'), err = $('#dlgErr');
  if (e.submitter && e.submitter.id !== 'dlgGo') return;
  if (!EMAIL.test(i.value.trim())) { e.preventDefault(); i.setAttribute('aria-invalid', 'true'); err.textContent = 'Please enter a valid email address.'; i.focus(); return; }
  e.preventDefault(); i.removeAttribute('aria-invalid'); const os = $('#dlg input[name=os]:checked').value === 'iphone' ? 'iPhone' : 'Android';
  err.className = 'ok'; err.textContent = `Saved. We’ll email the ${os} link on 4 December.`; setTimeout(() => { dlg.close(); err.className = 'err'; err.textContent = ''; }, 1800); });

/* =========================== Nav, reveals, counts ======================= */
const nav = $('#nav'), hero = $('#top');
function onScrollNav() { nav.classList.toggle('solid', scrollY > hero.offsetHeight - 80); }
addEventListener('scroll', onScrollNav, { passive: true }); onScrollNav();
const rio = new IntersectionObserver(es => es.forEach(e => { if (e.isIntersecting) { e.target.classList.add('in'); rio.unobserve(e.target); } }), { rootMargin: '0px 0px -12% 0px' });
$$('.reveal').forEach(el => rio.observe(el));
const cio = new IntersectionObserver(es => es.forEach(e => { if (!e.isIntersecting) return; cio.unobserve(e.target); const el = e.target, to = +el.dataset.count, suf = el.dataset.suffix || '';
  if (RM.matches) return; const t0 = performance.now(); const step = now => { const k = clamp((now - t0) / 1400), v = Math.round(to * (1 - Math.pow(1 - k, 4))); el.textContent = v.toLocaleString('en-GB') + suf; if (k < 1) requestAnimationFrame(step); }; requestAnimationFrame(step); }), { threshold: .6 });
$$('[data-count]').forEach(el => cio.observe(el));

/* =========================== Preloader ================================= */
const loader = $('#loader'), bars_ = $('#ldBars'), pct = $('#ldPct');
const LB = 36; for (let i = 0; i < LB; i++) bars_.appendChild(document.createElement('i'));
const barEls = [...bars_.children]; const benv = envelope(7, LB);
let loadP = 0, intro = false;
window.EM.progress = p => { loadP = Math.max(loadP, p); const on = Math.round(loadP * LB); barEls.forEach((b, i) => { b.classList.toggle('on', i < on); b.style.height = (i < on ? 8 + benv[i] * 56 : 4) + 'px'; }); pct.textContent = Math.round(loadP * 100) + '%'; };
function doIntro() { if (intro) return; intro = true; window.EM.progress(1);
  const go = () => { loader.classList.add('out'); document.documentElement.classList.remove('pre-intro'); setTimeout(() => { loader.remove(); delete document.documentElement.dataset.preload; }, 1100); };
  if (document.documentElement.dataset.preload !== undefined) setTimeout(go, 380); else { document.documentElement.classList.remove('pre-intro'); loader.remove(); } }
window.EM.done = doIntro;
if (document.documentElement.dataset.preload !== undefined) document.documentElement.classList.add('pre-intro');
setTimeout(doIntro, 6000); // never hold the page hostage

/* ================== Screen loop shared by 3D and fallback ================ */
const fontsReady = document.fonts ? Promise.race([document.fonts.ready, new Promise(r => setTimeout(r, 2500))]) : Promise.resolve();
window.EM.fontsReady = fontsReady;

/* ============================ 3D stage ================================== */
let has3D = false;
try {
  const test = document.createElement('canvas'); has3D = !!(test.getContext('webgl2') || test.getContext('webgl'));
} catch (e) { has3D = false; }
async function boot() {
  await fontsReady;
  if (has3D) {
    try { const mod = await import3D(); await mod.start(); return; }
    catch (err) { console.warn('3D stage unavailable, using poster fallback.', err); }
  }
  fallback();
}
function fallback() {
  document.documentElement.classList.add('no-webgl'); $('#stage').remove();
  const tryMock = $('#tryMock'); tryMock.appendChild(UI.cv); UI.cv.setAttribute('role', 'img'); UI.cv.setAttribute('aria-label', 'Earmark app screen for the demo');
  UI.cv.addEventListener('click', e => { const r = UI.cv.getBoundingClientRect(); UI.hit((e.clientX - r.left) / r.width, (e.clientY - r.top) / r.height); });
  const snap = (mode, el) => { const keep = UI.mode; UI.set(mode); UI.draw(performance.now() + 4000); el.src = UI.cv.toDataURL('image/webp', .8); UI.set(keep); };
  const refresh = () => { snap(CUR.step, $('[data-mock=how]')); snap('plan', $('[data-mock=plan]')); snap('journal', $('[data-mock=journal]')); UI.set('demo'); UI.dirty = true; };
  refresh(); window.addEventListener('em:screen', refresh); window.addEventListener('em:saved', refresh);
  const loop = now => { if (!document.hidden && (UI.dirty || UI.mode === 'demo' && UI.demo.phase === 'rec')) { UI.draw(now); UI.dirty = false; } requestAnimationFrame(loop); };
  UI.set('demo'); requestAnimationFrame(loop);
  const bill = () => { snap('plan', $('[data-mock=plan]')); UI.set('demo'); }; billBtns.forEach(b => b.addEventListener('click', bill));
  doIntro();
}
function import3D() { return STAGE(); }
boot();

/* The 3D stage lives in this function so the page stays one file. */
async function STAGE() {
  const THREE = await import('three');
  const { GLTFLoader } = await import('three/addons/loaders/GLTFLoader.js');
  const { MeshoptDecoder } = await import('three/addons/libs/meshopt_decoder.module.js');
  const { RoomEnvironment } = await import('three/addons/environments/RoomEnvironment.js');
  return { start: () => runStage(THREE, GLTFLoader, MeshoptDecoder, RoomEnvironment) };
}

async function runStage(THREE, GLTFLoader, MeshoptDecoder, RoomEnvironment) {
  const canvas = $('#stage');
  const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true, powerPreference: 'high-performance' });
  renderer.setClearColor(0x000000, 0);
  renderer.toneMapping = THREE.AgXToneMapping; renderer.toneMappingExposure = 1.05;
  renderer.outputColorSpace = THREE.SRGBColorSpace;
  renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap;
  renderer.shadowMap.autoUpdate = false; renderer.shadowMap.needsUpdate = true; // props only cast when they move
  renderer.autoClear = false;
  const pmrem = new THREE.PMREMGenerator(renderer); const envTex = pmrem.fromScene(new RoomEnvironment(), .04).texture;

  /* --- camera A: matches the Blender camera that rendered the plate --- */
  const VFOV = 2 * Math.atan(Math.tan(Math.atan(18 / 50)) * 9 / 16) * 180 / Math.PI; // 50 mm lens, 36 mm sensor, 16:9
  const camA = new THREE.PerspectiveCamera(VFOV, 16 / 9, .01, 20);
  camA.position.set(0, .33, 1.05); camA.lookAt(0, .12, 0); camA.updateMatrixWorld();
  const camB = new THREE.PerspectiveCamera(VFOV, 1, .01, 20); camB.position.set(0, 0, 0); camB.lookAt(0, 0, -1);

  /* --- scene A: props that sit IN the rendered plate --- */
  const sA = new THREE.Scene(); sA.environment = envTex; sA.environmentIntensity = .55;
  const key = new THREE.DirectionalLight(0xffdcb6, 2.6); key.position.set(-1.0, .85, .55); key.target.position.set(.15, 0, 0);
  key.castShadow = true; key.shadow.mapSize.set(1024, 1024); key.shadow.radius = 6; key.shadow.bias = -.0004;
  Object.assign(key.shadow.camera, { left: -.45, right: .45, top: .45, bottom: -.45, near: .1, far: 3 });
  sA.add(key, key.target, new THREE.HemisphereLight(0xc9d2e0, 0x6b5a47, .5));
  const shadowMat = new THREE.ShadowMaterial({ color: 0x2a1c10, opacity: .42 });
  const floor = new THREE.Mesh(new THREE.PlaneGeometry(3, 3), shadowMat); floor.rotation.x = -Math.PI / 2; floor.receiveShadow = true; sA.add(floor);
  const PL = new THREE.Vector3(.17, .075, -.04), PR = .12;
  const top = new THREE.Mesh(new THREE.CircleGeometry(PR - .004, 64), shadowMat); top.rotation.x = -Math.PI / 2; top.position.copy(PL).y += .0005; top.receiveShadow = true; sA.add(top);
  const occ = new THREE.Mesh(new THREE.CylinderGeometry(PR, PR, .075, 64), new THREE.MeshBasicMaterial({ colorWrite: false }));
  occ.position.set(PL.x, .0375, PL.z); occ.renderOrder = -1; sA.add(occ);
  // soft phone shadow on the plinth (blob)
  const blobTex = (() => { const c = document.createElement('canvas'); c.width = c.height = 128; const x = c.getContext('2d'); const gr = x.createRadialGradient(64, 64, 0, 64, 64, 64); gr.addColorStop(0, 'rgba(30,20,12,.55)'); gr.addColorStop(1, 'rgba(30,20,12,0)'); x.fillStyle = gr; x.fillRect(0, 0, 128, 128); return new THREE.CanvasTexture(c); })();
  const blob = new THREE.Mesh(new THREE.PlaneGeometry(.11, .05), new THREE.MeshBasicMaterial({ map: blobTex, transparent: true, depthWrite: false, toneMapped: false }));
  blob.rotation.x = -Math.PI / 2; blob.position.set(PL.x + .01, PL.y + .001, PL.z + .005); sA.add(blob);

  /* --- scene B: the phone (screen-space choreography) --- */
  const sB = new THREE.Scene(); sB.environment = envTex; sB.environmentIntensity = .9;
  const kB = new THREE.DirectionalLight(0xffe2c4, 2.2); kB.position.set(-2, 2.2, 2); sB.add(kB);
  const rB = new THREE.DirectionalLight(0xbcd0ff, 1.4); rB.position.set(2.5, .6, -1.5); sB.add(rB);
  sB.add(new THREE.AmbientLight(0xffffff, .15));

  const PW = .0735, PH = .152, PD = .0082, PRAD = .0115;
  function rrShape(w, h, r) { const s = new THREE.Shape(), x = -w / 2, y = -h / 2;
    s.moveTo(x + r, y); s.lineTo(x + w - r, y); s.quadraticCurveTo(x + w, y, x + w, y + r); s.lineTo(x + w, y + h - r); s.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
    s.lineTo(x + r, y + h); s.quadraticCurveTo(x, y + h, x, y + h - r); s.lineTo(x, y + r); s.quadraticCurveTo(x, y, x + r, y); return s; }
  const phone = new THREE.Group(); const spinner = new THREE.Group(); spinner.add(phone); sB.add(spinner);
  const titanium = new THREE.MeshPhysicalMaterial({ color: 0x9c9384, metalness: 1, roughness: .3, clearcoat: .3, clearcoatRoughness: .4 });
  const bodyGeo = new THREE.ExtrudeGeometry(rrShape(PW - .0024, PH - .0024, PRAD - .0012), { depth: PD - .0024, bevelEnabled: true, bevelThickness: .0012, bevelSize: .0012, bevelSegments: 5, curveSegments: 18 });
  bodyGeo.translate(0, 0, -(PD - .0024) / 2);
  const body = new THREE.Mesh(bodyGeo, titanium); phone.add(body);
  const backMat = new THREE.MeshPhysicalMaterial({ color: 0x8f877a, metalness: .2, roughness: .55, clearcoat: .6, clearcoatRoughness: .5 });
  const back = new THREE.Mesh(new THREE.ShapeGeometry(rrShape(PW - .004, PH - .004, PRAD - .002), 18), backMat); back.position.z = -PD / 2 - .00125; back.rotation.y = Math.PI; phone.add(back);
  // camera bump
  const bump = new THREE.Mesh(new THREE.ExtrudeGeometry(rrShape(.031, .031, .007), { depth: .0012, bevelEnabled: true, bevelThickness: .0004, bevelSize: .0004, bevelSegments: 3, curveSegments: 12 }), titanium);
  bump.position.set(PW / 2 - .021, PH / 2 - .021, -PD / 2 - .0026); phone.add(bump);
  const lensGlass = new THREE.MeshPhysicalMaterial({ color: 0x050608, metalness: .1, roughness: .05, clearcoat: 1 });
  const ringMat = new THREE.MeshStandardMaterial({ color: 0x2a2824, metalness: .9, roughness: .35 });
  [[-.0075, .0075], [-.0075, -.0075], [.0075, 0]].forEach(([x, y]) => { const ring = new THREE.Mesh(new THREE.CylinderGeometry(.0052, .0055, .0018, 32), ringMat); ring.rotation.x = Math.PI / 2; ring.position.set(bump.position.x + x, bump.position.y + y, -PD / 2 - .0036); phone.add(ring);
    const lens = new THREE.Mesh(new THREE.CircleGeometry(.0038, 32), lensGlass); lens.position.set(ring.position.x, ring.position.y, -PD / 2 - .0046); lens.rotation.y = Math.PI; phone.add(lens); });
  // side buttons
  const btnGeo = new THREE.BoxGeometry(.0012, .012, .0034); [[PW / 2 + .0004, .03], [-PW / 2 - .0004, .036], [-PW / 2 - .0004, .02]].forEach(([x, y]) => { const b = new THREE.Mesh(btnGeo, titanium); b.position.set(x, y, 0); phone.add(b); });
  // screen with the live app texture
  const tex = new THREE.CanvasTexture(UI.cv); tex.colorSpace = THREE.SRGBColorSpace; tex.anisotropy = renderer.capabilities.getMaxAnisotropy();
  const SWm = PW - .0042, SHm = PH - .0042; const scrGeo = new THREE.ShapeGeometry(rrShape(SWm, SHm, PRAD - .0024), 18);
  { const uv = scrGeo.attributes.uv, pos = scrGeo.attributes.position; for (let i = 0; i < uv.count; i++) uv.setXY(i, pos.getX(i) / SWm + .5, pos.getY(i) / SHm + .5); }
  const screen = new THREE.Mesh(scrGeo, new THREE.MeshBasicMaterial({ map: tex, toneMapped: false })); screen.position.z = PD / 2 + .0004; phone.add(screen);
  const glass = new THREE.Mesh(new THREE.ShapeGeometry(rrShape(PW - .0026, PH - .0026, PRAD - .0016), 18), new THREE.MeshPhysicalMaterial({ color: 0x000000, metalness: 0, roughness: .06, transparent: true, opacity: .14, clearcoat: 1, envMapIntensity: 1.4 }));
  glass.position.z = PD / 2 + .0007; phone.add(glass);
  // recording glow (soft halo behind the phone)
  const glowTex = (() => { const c = document.createElement('canvas'); c.width = c.height = 128; const x = c.getContext('2d'); const gr = x.createRadialGradient(64, 64, 0, 64, 64, 64); gr.addColorStop(0, 'rgba(255,110,50,.55)'); gr.addColorStop(1, 'rgba(255,90,31,0)'); x.fillStyle = gr; x.fillRect(0, 0, 128, 128); return new THREE.CanvasTexture(c); })();
  const glow = new THREE.Mesh(new THREE.PlaneGeometry(.2, .26), new THREE.MeshBasicMaterial({ map: glowTex, transparent: true, depthWrite: false, opacity: 0, toneMapped: false }));
  glow.position.z = -.02; phone.add(glow);

  /* --- GLB props (Meshy image→3D, meshopt + webp) --- */
  const manager = new THREE.LoadingManager(); manager.onProgress = (u, a, b) => window.EM.progress(.15 + .85 * a / b);
  const loader = new GLTFLoader(manager); loader.setMeshoptDecoder(MeshoptDecoder);
  const PROPS = {
    shore:  { url: 'assets/shell.glb', size: .085, pos: [.1, PL.y, .015], rot: [0, .5, 0], pre: [.25, 0, -1.28] },
    forest: { url: 'assets/cone.glb',  size: .082, pos: [.035, 0, -.15], rot: [0, .4, 0] },
    tram:   { url: 'assets/bell.glb',  size: .06,  pos: [.255, 0, .12], rot: [0, -.7, 0] }
  };
  window.EM.progress(.08);
  const loaded = await Promise.all(Object.entries(PROPS).map(([k, p]) => loader.loadAsync(p.url).then(gl => [k, gl.scene]).catch(() => [k, null])));
  const props = {}, ghosts = {};
  for (const [k, sc] of loaded) { if (!sc) continue; const p = PROPS[k];
    sc.traverse(o => { if (o.isMesh) { o.castShadow = true; o.receiveShadow = true; if (o.material) { o.material.envMapIntensity = .8; } } });
    if (p.pre) { sc.rotation.set(...p.pre); sc.updateMatrixWorld(true); }
    const box = new THREE.Box3().setFromObject(sc), size = box.getSize(new THREE.Vector3()), s = p.size / Math.max(size.x, size.y, size.z);
    const c = box.getCenter(new THREE.Vector3());
    const inner = new THREE.Group(); sc.position.set(-c.x, -box.min.y, -c.z); inner.add(sc); inner.scale.setScalar(s);
    const holder = new THREE.Group(); holder.add(inner); holder.position.set(...p.pos); holder.rotation.set(...p.rot); sA.add(holder);
    props[k] = { holder, inner, base: holder.position.clone(), rot: holder.rotation.clone(), hop: 0, hopV: 0, spin: 0 };
    // a second copy floats next to the phone in the demo
    const ghost = new THREE.Group(); const gi = inner.clone(true); gi.position.y = -p.size * .5; ghost.add(gi); ghost.scale.setScalar(0); sB.add(ghost); ghosts[k] = { g: ghost, k: 0, size: p.size };
  }

  /* --- plate layout: place <img> and offset camera A to match --- */
  const plate = $('#plate'); plate.classList.add('placed');
  const tmp = new THREE.Vector3();
  const camFull = camA.clone(); camFull.aspect = 16 / 9; camFull.updateProjectionMatrix(); camFull.updateMatrixWorld(true);
  const plinthPx = (() => { tmp.copy(PL).project(camFull); return (tmp.x * .5 + .5) * 1920; })();
  const tanH = Math.tan(VFOV * Math.PI / 360);
  const PHONE_HERO = new THREE.Vector3(PL.x + .005, .2, PL.z), HERO_SCALE = 1.12;
  const HERO_DIST = -PHONE_HERO.clone().applyMatrix4(camFull.matrixWorldInverse).z;
  const HERO_FY = (() => { tmp.copy(PHONE_HERO).project(camFull); return -tmp.y * .5 + .5; })();
  const L = { s: 1, left: 0, top: 0, W: innerWidth, H: innerHeight };
  function layout() {
    const W = document.documentElement.clientWidth, H = innerHeight, Hh = hero.offsetHeight, stacked = W < 1000;
    let s = Math.max(W / 1920, Math.min(Hh, H * 1.08) / 1080), top = (Hh - 1080 * s) / 2;
    if (stacked) { // fit the phone (not the plate) to the stage box under the copy
      const st = $('#heroStage'), sh = st.offsetHeight, sy = st.getBoundingClientRect().top - hero.getBoundingClientRect().top;
      const hp = .5 * sh; s = Math.max(W / 1920, hp * 2 * HERO_DIST * tanH / (HERO_SCALE * PH * 1080));
      const hpx = HERO_SCALE * PH * 1080 * s / (2 * HERO_DIST * tanH);
      top = sy + .03 * sh + hpx / 2 - HERO_FY * 1080 * s; }
    const target = stacked ? W * .5 : W * (W < 1200 ? .7 : .67);
    const left = clamp(target - plinthPx * s, W - 1920 * s, 0);
    Object.assign(L, { s, left, top, W, H });
    plate.style.width = 1920 * s + 'px'; plate.style.height = 1080 * s + 'px'; plate.style.left = left + 'px'; plate.style.top = top + 'px';
    renderer.setPixelRatio(Math.min(devicePixelRatio, 2)); renderer.setSize(W, H, false); canvas.style.width = W + 'px'; canvas.style.height = H + 'px';
    camB.aspect = W / H; camB.updateProjectionMatrix();
    needs = true;
  }
  let needs = true;
  addEventListener('resize', layout); layout();
  if (window.ResizeObserver) new ResizeObserver(() => layout()).observe(hero);

  /* --- pose helpers --- */
  function heroPose() {
    const hr = hero.getBoundingClientRect();
    camA.setViewOffset(1920 * L.s, 1080 * L.s, -L.left, -(hr.top + L.top), L.W, L.H); camA.updateMatrixWorld();
    tmp.copy(PHONE_HERO).project(camA);
    const dist = PHONE_HERO.clone().applyMatrix4(camA.matrixWorldInverse).z * -1;
    const h = HERO_SCALE * PH * 1080 * L.s / (2 * dist * tanH);
    return { x: (tmp.x * .5 + .5) * L.W, y: (-tmp.y * .5 + .5) * L.H, h, rx: .06, ry: -.5, rz: .05 };
  }
  function slotPose(el) { const r = el.getBoundingClientRect(); const d = el.dataset;
    return { x: r.left + r.width / 2, y: r.top + r.height / 2, h: r.height * .96, rx: +d.rx || 0, ry: +d.ry || 0, rz: +d.rz || 0, hidden: !el.offsetParent }; }
  const away = () => ({ x: L.W * .5, y: -L.H * .55, h: L.H * .4, rx: .8, ry: 0, rz: .1 });
  const SEQ = [
    { key: 'how', sec: $('#how'), el: $('#slotHow') },
    { key: 'try', sec: $('#try'), el: $('#slotTry') },
    { key: 'notes', sec: $('#notes'), away: true },
    { key: 'pricing', sec: $('#pricing'), el: $('#slotPrice') },
    { key: 'faq', sec: $('#faq'), away: true },
    { key: 'get', sec: $('#get'), el: $('#slotGet') }
  ];
  const ease = t => t < .5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
  function mix(a, b, t) { return { x: lerp(a.x, b.x, t), y: lerp(a.y, b.y, t), h: lerp(a.h, b.h, t), rx: lerp(a.rx, b.rx, t), ry: lerp(a.ry, b.ry, t), rz: lerp(a.rz, b.rz, t) }; }
  function currentPose() {
    let pose = heroPose(), key = 'hero', turn = 0;
    for (const s of SEQ) {
      const top = s.sec.getBoundingClientRect().top;
      const t = clamp((L.H * .92 - top) / (L.H * .72)); if (t <= 0) break;
      let target = s.away ? away() : slotPose(s.el); if (target.hidden) target = away();
      const e = ease(t); pose = mix(pose, target, e); turn += Math.sin(Math.PI * e) * 1.1; if (t > .5) key = s.key;
    }
    pose.ry += turn; return { pose, key };
  }
  function place(pose) { // screen px + px height → world transform in camera B
    const d = PH * L.H / (2 * Math.max(pose.h, 1) * tanH);
    const nx = pose.x / L.W * 2 - 1, ny = -(pose.y / L.H * 2 - 1);
    spinner.position.set(nx * d * tanH * camB.aspect, ny * d * tanH, -d);
    return d;
  }

  /* --- springs: pointer tilt, flip-to-change-screen, prop hops --- */
  const ptr = { x: 0, y: 0 }; const tilt = { x: 0, y: 0, vx: 0, vy: 0 };
  addEventListener('pointermove', e => { ptr.x = e.clientX / L.W * 2 - 1; ptr.y = e.clientY / L.H * 2 - 1; hoverTest(e); }, { passive: true });
  let flip = null, shownKey = null, glowK = 0, recOn = false, level = 0, dMain = 1;
  const FLIP_MS = 900;
  function requestScreen(key) {
    if (key === shownKey && !flip) return;
    if (RM.matches || shownKey === null) { shownKey = key; window.EM.applyScreen(key); return; }
    if (flip) { flip.next = key; return; }
    flip = { t0: performance.now(), key, swapped: false };
  }
  addEventListener('em:screen', () => { if (shownKey === 'how') { if (RM.matches) window.EM.applyScreen('how'); else flip = flip || { t0: performance.now(), key: 'how', swapped: false }; } });
  addEventListener('em:rec', e => { recOn = e.detail; });
  addEventListener('em:level', e => { level = e.detail; });
  addEventListener('em:place', e => { const p = props[e.detail]; if (p) p.hopV = 1.6; });
  addEventListener('em:ping', e => { const p = props[e.detail]; if (p) { p.hopV = 2.2; p.spin = 1; } });

  /* hover + click on hero props (raycast through camera A) and on the phone screen (camera B) */
  const ray = new THREE.Raycaster(), ndc = new THREE.Vector2(); let hoverKey = null;
  function propAt(e) { if (hero.getBoundingClientRect().bottom < 0) return null; ndc.set(e.clientX / L.W * 2 - 1, -(e.clientY / L.H) * 2 + 1); ray.setFromCamera(ndc, camA);
    for (const k in props) { if (ray.intersectObject(props[k].holder, true).length) return k; } return null; }
  function hoverTest(e) { if (e.pointerType === 'touch') return; const k = propAt(e); if (k !== hoverKey) { hoverKey = k; document.body.style.cursor = k ? 'pointer' : ''; } }
  addEventListener('click', e => {
    if (e.target.closest('a,button,input,label,summary,dialog')) return;
    const k = propAt(e); if (k) { window.dispatchEvent(new CustomEvent('em:pick', { detail: k })); return; }
    if (CUR.key === 'try') { ndc.set(e.clientX / L.W * 2 - 1, -(e.clientY / L.H) * 2 + 1); ray.setFromCamera(ndc, camB); const hit = ray.intersectObject(screen)[0];
      if (hit && hit.uv) { Audio.ensure(); UI.hit(hit.uv.x, 1 - hit.uv.y); } }
  });

  /* --- main loop --- */
  let last = performance.now(), running = true, firstFrame = true, blank = false;
  document.addEventListener('visibilitychange', () => { if (!document.hidden) { last = performance.now(); if (!running) { running = true; requestAnimationFrame(frame); } } });
  function frame(now) {
    if (document.hidden) { running = false; return; }
    requestAnimationFrame(frame);
    const dt = Math.min(.05, (now - last) / 1000); last = now; const rm = RM.matches;
    const { pose, key } = currentPose();
    if (key !== CUR.key) { CUR.key = key; requestScreen(key); }
    if (shownKey === null) requestScreen(key);
    // flip animation: one full turn, screen swaps when the back faces the camera
    let flipRot = 0;
    if (flip) { const k = clamp((now - flip.t0) / FLIP_MS); flipRot = ease(k) * Math.PI * 2;
      if (!flip.swapped && k > .5) { flip.swapped = true; shownKey = flip.key; window.EM.applyScreen(flip.key); }
      if (k >= 1) { const nx = flip.next; flip = null; if (nx && nx !== shownKey) requestScreen(nx); } }
    // pointer tilt spring (stiffness 90, damping 12)
    const tx = rm ? 0 : -ptr.y * .12, ty = rm ? 0 : ptr.x * .22;
    tilt.vx += (90 * (tx - tilt.x) - 12 * tilt.vx) * dt; tilt.vy += (90 * (ty - tilt.y) - 12 * tilt.vy) * dt; tilt.x += tilt.vx * dt; tilt.y += tilt.vy * dt;
    const bob = rm ? 0 : Math.sin(now / 1000 * 1.3) * .004;
    dMain = place(pose); spinner.position.y += bob * (pose.h / 300);
    spinner.rotation.set(pose.rx + tilt.x, pose.ry + tilt.y + flipRot, pose.rz + (rm ? 0 : Math.sin(now / 1000 * .9) * .015));
    // glow while recording, pulses with level
    glowK = lerp(glowK, recOn ? .55 + level * 1.2 : 0, .12); glow.material.opacity = glowK; glow.scale.setScalar(1 + level * .6);
    // hero visibility, blob shadow
    const hr = hero.getBoundingClientRect(), heroVis = hr.bottom > 0; const heroW = clamp(1 - clamp((L.H * .92 - $('#how').getBoundingClientRect().top) / (L.H * .4)));
    blob.material.opacity = heroW * (.9 - bob * 20);
    // props: idle life + hop springs
    for (const k in props) { const p = props[k];
      p.hopV += (-60 * p.hop - 7 * p.hopV) * dt; p.hop += p.hopV * dt; if (rm) { p.hop = 0; p.hopV = 0; }
      p.holder.position.y = p.base.y + Math.max(0, p.hop) * .03;
      p.spin = Math.max(0, p.spin - dt * 1.2); p.holder.rotation.y = p.rot.y + (rm ? 0 : ease(1 - p.spin) * Math.PI * 2 * (p.spin > 0 ? 1 : 0)) + (k === hoverKey && !rm ? Math.sin(now / 160) * .08 : 0);
      p.holder.rotation.z = (k === 'tram' && !rm) ? Math.sin(now / 90) * .05 * Math.max(0, p.hop) : 0;
      if (Math.abs(p.hopV) > .01 || p.spin > 0 || k === hoverKey) renderer.shadowMap.needsUpdate = true; }
    // demo ghost prop beside the phone
    const demoK = CUR.key === 'try' ? UI.place : null;
    for (const k in ghosts) { const gh = ghosts[k]; gh.k = lerp(gh.k, k === demoK ? 1 : 0, .08);
      const sc = gh.k * 1.05; gh.g.scale.setScalar(sc); gh.g.visible = gh.k > .01;
      if (gh.g.visible) { gh.g.position.copy(spinner.position).add(new THREE.Vector3(-(PW * .5 + .045), -PH * .3 + Math.sin(now / 700) * .006, .03));
        gh.g.rotation.set(.25, now / 1000 * .5 + (recOn ? level * 2 : 0), 0); } }
    // screen texture
    const animScreen = UI.draw && (UI.dirty || UI._anim);
    if (animScreen && (now - (UI._lt || 0) > 33 || UI.dirty)) { UI._anim = UI.draw(now); UI.dirty = false; UI._lt = now; tex.needsUpdate = true; }
    // render (skip when nothing is on screen)
    const phoneVis = pose.y + pose.h > -40 && pose.y - pose.h < L.H + 40;
    if (!phoneVis && !heroVis && !needs) { if (!blank) { renderer.clear(); blank = true; } return; }
    needs = false; blank = false;
    renderer.clear();
    if (heroVis) { renderer.render(sA, camA); renderer.clearDepth(); }
    if (phoneVis) renderer.render(sB, camB);
    if (firstFrame) { firstFrame = false; canvas.classList.add('ready'); window.EM.done(); }
  }
  UI._anim = true; UI.dirty = true;
  requestAnimationFrame(frame);
}
</script>
</body>
</html>

````
