# 3D Ribbon Text Animation

Motionboard shot name: Folded Ribbon Text

A two-line title folds between its words into zig-zag 3D ribbons and multiplies into a field of rows, wide arrow bands sweep past the camera, the last band fills the frame and wipes to the product UI, and the film ends on the product wordmark.

- Position in a launch film: Opening
- Slug: 3d-ribbon-text-animation
- Preview video: https://media.motionboard.app/folded-ribbon.mp4
- Recipe page: https://motionboard.app/recipes/3d-ribbon-text-animation/
- License: MIT. Free to use in your own projects, including commercial launch films. https://github.com/krisyangdev/motionboard/blob/main/LICENSE

## How to use this recipe

You are a coding agent. The user wants this shot for their own product. Follow these steps.

1. **Know the product.** If the product is clear from the user's repo or conversation, ask nothing and start. Otherwise ask once for: product name, logo file, brand colors.
2. **Pick the output.** If the user's message says a video or their website, do that. Otherwise ask once which one they want.
   - **Video (HyperFrames).** Create a folder named `folded-ribbon`. Download every file under "Source files" below with the curl commands, keeping relative paths. Adapt `index.html` (see "What to adapt"). Run `npx --yes hyperframes@0.8.209 check` on the untouched copy first and note its result. Preview with `npx --yes hyperframes@0.8.209 preview`, render an MP4 with `npx --yes hyperframes@0.8.209 render` (into `renders/`, named with a timestamp). The same commands are in `package.json` as `dev`, `check`, `render`; pass flags after `--`, as in `npm run render -- --quality draft`. Rendering needs network access for web fonts and GSAP.
   - **Website motion.** Port the GSAP timeline in `index.html` into the user's site, using their stack (React, Vue, Svelte, plain HTML). Build the same DOM structure, keep the timeline's durations, delays and easings exactly, and start it when the element scrolls into view (IntersectionObserver or ScrollTrigger). Respect `prefers-reduced-motion: reduce`: show the final frame as a static state and skip the movement.
3. **What to adapt.**
   - **Brand layer** (product name, logo, colors, fonts, copy): replace directly with the user's.
   - **UI layer** (the product screens, cards, windows, controls shown in the shot): rebuild the user's real UI as clean DOM, from their codebase (components, design tokens) or from a screenshot used as reference only. Never paste a screenshot into the shot.
   - **Motion** (timing, easing, camera moves, layering, stagger, order of events): keep exactly as in the source. This is what the recipe is.
   - The timeline targets UI elements by id and class, and camera moves land on fixed coordinates. Keep the ids the timeline uses, keep row counts and text lengths close to the source, and when the layout moves, update the target coordinates without changing the times.
4. **Fonts.** HyperFrames fetches Google Fonts such as Inter on its own. Some sources use macOS local fonts (PingFang, Songti via `local()`). Use the user's brand font when it can be bundled; for a system font such as SF Pro, use Inter. Check that text still fits its boxes.
5. **Verify.** Compare the render with the preview video above at the beat times in the Timing row. The beats, timing and camera should match; only brand and UI content differ.

## Spec

| Item | Value |
| --- | --- |
| Timing | Film 10.5s. Title rises line by line through a mask 0–0.8s (expo.out, second line 0.12s later), accent color sweeps across both lines panel by panel 0.3–1.16s; fold 1.0–2.3s (1.3s, 39 frames), second line 0.1s later; row spacing opens from 176px to 340px (1.0–2.4s); 6 more rows multiply 2.25–3.38s (0.95s each, staggered 0.09s per ring); violet sweep over the rows 2.79–3.87s; the four wide bands enter at 3.0s, 3.3s, 3.55s and 3.75s and run to 5.05s; wipe 4.3–5.8s, full cover at 5.05s; editor from 5.05s, Rotate Y handle drag 6.25–7.3s, Distance slider drag 7.8–8.3s, editor dims 8.2–8.85s and the wordmark lands 8.35–9.35s, wordmark holds to 10.5s |
| Easing | Title rise expo.out; title fold easeInOut cubic; multiplying rows and editor settle expo.out; Rotate Y drag expo.out; band paths monotone cubic splines, fast then slow; wipe easeInOut cubic; Distance slider sine inOut; wordmark fades with easeOut cubic and rises with expo.out |
| Camera | Rows scene, perspective 2400px: camera pitches down 0°→26° (2.3s)→30° (3.3s)→34° (4.6s)→36° (5.05s), rolls −6°→−10°→−22° (4.6s)→−27° (5.05s), yaw within 4°; it pulls back 300px at 2.3s and 560px at 3.3s to fit more rows, then dollies in to +400px at 4.6s and about +617px at 5.05s. Bands scene, perspective 1100px: dolly 0→360px (3.0–5.1s), roll 0°→−8°. The editor settles from 1.14x scale, 7° tilt and −5° yaw to 1.0 in 1.15s (expo.out), pushes slowly from 6.0s with sine inOut to reach 1.05x at 8.35s, then pulls back to 0.97x as it dims and drifts back to 0.99x by 10.5s |
| Subject | Each row is a folded strip with one panel per word group, so creases fall only between words: PERSPECTIVE (865px) and FRAMES (545px) in line one, NOW (348px), IN (161px) and PLANAR (537px) in line two; each panel is its word width plus 18px each side (Inter 700, 128px, letter-spacing −0.035em). Neighbouring panels alternate ±37° with their edges joined; the two title rows overshoot to about 44° while folding (peak near 2.3–2.5s, second line 0.1s later) and settle back to 37° by 3.4s (second line 3.5s) so the zig-zag shows sooner; from 2.25s every row breathes ±3°, 34–44° in all; panels leaning away drop to 50% brightness. 8 rows in all, 4 of PERSPECTIVE FRAMES and 4 of NOW IN PLANAR, 340px apart. Bands are 300px, 230px, 420px and 160px high and 9000px wide with text scrolling along them (1100–1700px/s); the wipe band is 3000px thick and carries two lines of 620px type that cross the frame near 4.95s and 5.05s, so the cover frame still shows type, with a 150px white band and a 120px dark band beside it. The editor window is 1700x900 with three phone frames on the canvas |
| Sync | The last band fills the frame at 5.05s, the rows and bands scenes end on that frame and the editor shows underneath; during the Rotate Y drag the value, the Home frame on the canvas, the highlight box on the Y field and the tooltip above the frame (it follows the cursor sideways) change on the same frame, and the cursor stays on the handle; during the Distance drag the Distance field lights up and the frame's perspective distance changes from 1200px to 450px in step |
| Style | Background `#050507`, white type, violet accent `#6e56ff` (band gradient `#5b44f0` → `#7a65ff`, light violet type `#a597ff`); three band looks: white type on violet, black type on near-white, violet type on black; the editor is a dark UI with three light phone frames; at the end the editor drops to 20% opacity, a dark radial scrim fades in behind the mark (8.0–8.5s) and the Planar wordmark sits centered (120px icon, Inter 700 at 136px, fading in from 8.35s and growing 2.5% to 10.5s) |

## Why it works

The title is already rising on the first frame. Each word group gets its own panel, so every crease falls between words and every face shows a whole word, which keeps the title readable while it folds. The fold stays near 37° and the camera pitch is moderate, so no panel turns edge-on, and the multiplied rows sit 340px apart so no row crosses another. The wide bands carry arrow copy that names the feature (TILT → SKEW → ROTATE → PERSPECTIVE) and double as the transition: the editor appears on the frame where the last band covers the screen, with no extra transition element. In the editor one drag turns the frame and a second drag changes the perspective distance, then the editor dims and the wordmark holds at a large size to the end. The whole film uses black, white and one violet accent.

## Prompt

> Build a 10.5-second opening called Folded Ribbon Text for a design tool named Planar, 1920x1080, background #050507, white type and one violet accent #6e56ff, font Inter. From 0s a two-line title PERSPECTIVE FRAMES / NOW IN PLANAR rises line by line through a mask (0 to 0.8s, expo.out, second line 0.12s later) (Inter 700, 128px, letter-spacing -0.035em, PLANAR in #a597ff); from 0.3 to 1.16s the accent color #a597ff sweeps across both lines left to right, panel by panel. From 1.0 to 2.3s (easeInOut cubic, second line 0.1s later) split each line into one panel per word, each panel as wide as its word plus 18px on each side (line one: PERSPECTIVE 865px, FRAMES 545px; line two: NOW 348px, IN 161px, PLANAR 537px), so every crease falls between words; rotate neighbouring panels alternately by ±37° with their edges joined so the strip folds into a zig-zag, and drop panels that lean away to 50% brightness; the two title rows overshoot to about 44° (peak near 2.3–2.5s, second line 0.1s later) and settle back to 37° by 3.4s; the camera uses 2400px perspective, pitches down to 26° and rolls -6°. From 1.0 to 2.4s open the row spacing from 176px to 340px, and from 2.25 to 3.38s multiply 6 more rows (3 of PERSPECTIVE FRAMES above, 3 of NOW IN PLANAR below; 0.95s each, expo.out, fading in, staggered 0.09s per ring), with the fold angle breathing ±3°, the camera pulling back to 560px and pitching to 30° with -10° roll, and a violet sweep running across the rows from 2.79 to 3.87s. From 3.0 to 5.05s four wide bands (300, 230, 420 and 160px high, 9000px wide; white type on violet, black type on near-white, violet type on black, and a thin violet band; entering at 3.0, 3.3, 3.55 and 3.75s; text TILT → SKEW → ROTATE → PERSPECTIVE →, PERSPECTIVE → ROTATE → SKEW → TILT →, SKEW → TILT → ROTATE → PERSPECTIVE → and NOW IN PLANAR →, scrolling at 1500, 1300, 1100 and 1700px/s) fly in from off-screen in a second 3D scene with 1100px perspective that dollies in 360px and rolls -8°, while the rows camera reaches 34° pitch, -22° roll and +400px dolly at 4.6s and about 36° pitch, -27° roll and +617px dolly at 5.05s (yaw stays within 4°), and the rows fade to 32% between 3.4 and 4.5s. From 4.3 to 5.8s a 3000px-thick violet band (tilted -26°, with two lines of 620px type PERSPECTIVE → FRAMES → on it that cross the frame near 4.95s and 5.05s, and a 150px white band and a 120px dark band beside it) sweeps across with easeInOut cubic and fills the frame at 5.05s; on that frame swap the rows scene for the Planar editor (a 1700x900 dark window: layers on the left, three phone frames on the canvas, a properties panel on the right with a Perspective section). The window settles from 1.14x scale, 7° tilt and -5° yaw to 1.0 in 1.15s with expo.out, then from 6.0s pushes slowly with sine inOut to reach 1.05x at 8.35s. The cursor fades in at 5.5s and reaches the handle at the right-middle of the selected frame at 6.15s; from 6.25 to 7.3s it drags the handle and Rotate Y goes 0° to -38° with expo.out, with the frame, the value, the highlight box on the Y field and a Rotate Y -38° tooltip above the frame (following the cursor sideways) changing on the same frame; from 7.4 to 7.78s the cursor moves to the Distance slider and from 7.8 to 8.3s it drags it, the frame's perspective going 1200px to 450px with sine inOut and the Distance field lighting up. From 8.2 to 8.85s the editor drops to 20% opacity and pulls back to 0.97x (then drifts back to 0.99x by 10.5s), a dark radial scrim fades in behind the mark from 8.0 to 8.5s, and from 8.35s the Planar wordmark (a 120px violet icon and 136px Inter 700 text) fades in centered and rises 36px with expo.out until 9.35s, then holds to the end.

## Often confused with

- [Wipe and Flash Transition](https://motionboard.app/r/wipe-flash-transition.md): Foreground Wipe & Flash hides the frame behind a foreground object and flashes to change scene; Folded Ribbon Text uses bands that carry feature copy as the transition and wipes straight to the product UI.
- [Kinetic Typography](https://motionboard.app/r/kinetic-typography.md): Scattered Spec Type places spec words around the lens; Folded Ribbon Text takes one title line, folds it into ribbons, multiplies it and sweeps bands over it.

## Source files

Runnable HyperFrames project, 3 files.

- https://motionboard.app/source/folded-ribbon/hyperframes.json (318 B)
- https://motionboard.app/source/folded-ribbon/index.html (59.7 KB)
- https://motionboard.app/source/folded-ribbon/package.json (302 B)

Download all of them:

```sh
curl -fsSL --create-dirs -o "folded-ribbon/hyperframes.json" "https://motionboard.app/source/folded-ribbon/hyperframes.json"
curl -fsSL --create-dirs -o "folded-ribbon/index.html" "https://motionboard.app/source/folded-ribbon/index.html"
curl -fsSL --create-dirs -o "folded-ribbon/package.json" "https://motionboard.app/source/folded-ribbon/package.json"
```

## index.html

```html
<!doctype html>
<html lang="en" data-resolution="landscape">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=1920, height=1080" />
    <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
    <style>
      :root {
        --bg: #050507;
        --ink: #f4f4f6;
        --acc: #6e56ff;
        --acc2: #a597ff;
        --u-win: #1c1c20;
        --u-panel: #232327;
        --u-line: rgba(255, 255, 255, 0.075);
        --u-txt: #e8e8ed;
        --u-mut: #8f8f9b;
        --u-dim: #63636d;
        --font-ui: "Inter", -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
      }
      * { margin: 0; padding: 0; box-sizing: border-box; }
      html, body { width: 1920px; height: 1080px; overflow: hidden; background: var(--bg); }
      #root {
        position: relative; width: 1920px; height: 1080px; overflow: hidden; background: var(--bg);
        font-family: var(--font-ui); color: var(--ink); -webkit-font-smoothing: antialiased;
        font-variant-numeric: tabular-nums;
      }
      .full { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; }
      svg { display: block; flex: none; }
      .ic { flex: none; display: block; }

      /* =============== ribbon stage =============== */
      #rib { background: var(--bg); overflow: hidden; z-index: 3; }
      .view { perspective: 1500px; perspective-origin: 50% 50%; overflow: hidden; }
      #rows.view { perspective: 2400px; }
      #bands.view { perspective: 1100px; }
      #cam3, #bw { transform-style: preserve-3d; }
      .pn {
        position: absolute; height: 150px; color: #fff;
        backface-visibility: visible; overflow: hidden;
      }
      .tx {
        position: absolute; left: 0; top: 0; width: 100%; height: 150px; line-height: 150px; white-space: nowrap; text-align: center;
        font-family: var(--font-ui); font-weight: 700; font-size: 128px; letter-spacing: -0.035em;
      }
      .tx b { font-weight: 700; color: var(--acc2); }
      .band { position: absolute; left: 0; top: 0; overflow: hidden; }
      .band .bt {
        position: absolute; left: 0; top: 0; white-space: nowrap; display: flex; align-items: center;
        font-family: var(--font-ui); font-weight: 800; letter-spacing: -0.035em;
      }
      .band.v { background: linear-gradient(90deg, #5b44f0 0%, #7a65ff 50%, #5b44f0 100%); color: #fff; }
      .band.w { background: linear-gradient(90deg, #dcdce2 0%, #f6f6f8 50%, #dcdce2 100%); color: #0a0a0c; }
      .band.d { background: #101013; color: #a597ff; box-shadow: inset 0 0 0 3px rgba(110, 86, 255, 0.9); }
      #wipe { z-index: 6; overflow: hidden; perspective: 1500px; }
      #wg { position: absolute; left: 960px; top: 540px; width: 0; height: 0; }
      #wg .band { left: -6000px; }

      /* =============== editor =============== */
      #ui { z-index: 1; overflow: hidden; perspective: 2200px; background: #060608; }
      #uiBg {
        background:
          radial-gradient(ellipse 60% 55% at 50% 52%, rgba(110, 86, 255, 0.16) 0%, rgba(110, 86, 255, 0) 70%),
          radial-gradient(ellipse 90% 80% at 50% 50%, #0b0b0f 0%, #040406 100%);
      }
      #uiCam { transform-origin: 960px 540px; }
      #win {
        position: absolute; left: 110px; top: 54px; width: 1700px; height: 900px; border-radius: 13px; overflow: hidden;
        background: var(--u-win); color: var(--u-txt); font-size: 12px;
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 2px 8px rgba(0, 0, 0, 0.5), 0 40px 100px rgba(0, 0, 0, 0.65), 0 100px 200px rgba(40, 20, 120, 0.25);
      }
      #win > * { position: absolute; }
      #tb { left: 0; top: 0; width: 1700px; height: 48px; border-bottom: 1px solid var(--u-line); background: #1f1f23; }
      #tb > * { position: absolute; }
      .tl2 { top: 18px; width: 12px; height: 12px; border-radius: 50%; }
      .tbtn { top: 8px; width: 32px; height: 32px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: #b4b4be; }
      .tbtn.on { background: rgba(255, 255, 255, 0.1); color: #fff; }
      .sepv { top: 14px; width: 1px; height: 20px; background: var(--u-line); }
      #crumb { left: 650px; top: 0; width: 400px; height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 500; color: #d9d9e0; white-space: nowrap; }
      #crumb .dm { color: var(--u-dim); font-weight: 400; }
      .pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); font-size: 11px; font-weight: 500; color: #b9b9c4; }
      .av { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 600; flex: none; }
      #share { left: 1530px; top: 9px; height: 30px; padding: 0 14px; border-radius: 7px; background: var(--acc); color: #fff; font-size: 13px; font-weight: 600; display: flex; align-items: center; }

      #lp { left: 0; top: 48px; width: 260px; height: 852px; background: var(--u-panel); border-right: 1px solid var(--u-line); overflow: hidden; }
      #lp > * { position: absolute; }
      .tab { top: 0; height: 40px; display: flex; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--u-dim); }
      .tab.on { color: #fff; }
      .sh { left: 14px; width: 232px; height: 28px; display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 600; color: #b9b9c4; letter-spacing: 0.01em; }
      .sh .ic { color: var(--u-mut); }
      .pg { left: 8px; width: 244px; height: 26px; border-radius: 6px; display: flex; align-items: center; gap: 8px; padding: 0 8px; font-size: 12.5px; color: #cfcfd8; }
      .pg.on { background: rgba(255, 255, 255, 0.07); color: #fff; font-weight: 500; }
      .pg i { width: 6px; height: 6px; border-radius: 50%; background: var(--acc2); }
      .hr { left: 0; width: 100%; height: 1px; background: var(--u-line); }
      .lr { left: 6px; width: 248px; height: 28px; border-radius: 6px; display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: #cfcfd8; white-space: nowrap; }
      .lr.sel { background: rgba(110, 86, 255, 0.28); color: #fff; }
      .lr.sub { background: rgba(110, 86, 255, 0.10); }
      .lr .ic { color: #8f8f9b; }
      .lr.sel .ic { color: #fff; }
      .lr .cv { color: var(--u-dim); margin-right: -3px; }
      .lr.ci .ic { color: var(--acc2); }
      .lr .ey { margin-left: auto; margin-right: 10px; color: #a597ff; opacity: 0.9; }

      #cvs {
        left: 260px; top: 48px; width: 1140px; height: 852px; overflow: hidden; background-color: #141418;
        background-image: radial-gradient(circle, rgba(255, 255, 255, 0.075) 1px, transparent 1.3px);
        background-size: 26px 26px; background-position: 13px 13px;
      }
      #cvs > * { position: absolute; }
      .flab { top: 94px; font-size: 12.5px; font-weight: 500; color: #8f8f9b; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
      .flab.sel { color: #a597ff; }
      .fw { width: 390px; height: 844px; transform-origin: 195px 422px; }
      .fw > * { position: absolute; }
      .fc { left: 0; top: 0; width: 390px; height: 844px; border-radius: 44px; overflow: hidden; background: #fff; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08); }
      .shade { left: 0; top: 0; width: 390px; height: 844px; border-radius: 44px; pointer-events: none; }
      .selb { left: -3px; top: -3px; width: 396px; height: 850px; border: 3px solid var(--acc); border-radius: 46px; }
      .hd { width: 13px; height: 13px; background: #fff; border: 2.5px solid var(--acc); border-radius: 3px; }
      .hdr { width: 15px; height: 15px; background: #fff; border: 3px solid var(--acc); border-radius: 50%; }
      .chip { height: 25px; padding: 0 10px; border-radius: 6px; background: var(--acc); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; white-space: nowrap; }
      #tip { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 7px; background: rgba(12, 12, 16, 0.96); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 8px 24px rgba(0, 0, 0, 0.5); font-size: 12px; font-weight: 500; color: #e8e8ed; white-space: nowrap; opacity: 0; z-index: 12; }
      #tip b { color: var(--acc2); font-weight: 600; }

      #rp { left: 1400px; top: 48px; width: 300px; height: 852px; background: var(--u-panel); border-left: 1px solid var(--u-line); overflow: hidden; }
      #rp > * { position: absolute; }
      .rt { left: 16px; font-size: 12px; font-weight: 600; color: #e8e8ed; display: flex; align-items: center; gap: 8px; }
      .rl { left: 16px; font-size: 12px; color: var(--u-mut); }
      .fld { height: 28px; border-radius: 6px; background: rgba(255, 255, 255, 0.055); display: flex; align-items: center; padding: 0 9px; gap: 8px; font-size: 12px; color: #e8e8ed; white-space: nowrap; }
      .fld .k { color: var(--u-dim); font-weight: 500; min-width: 12px; display: flex; align-items: center; }
      .fld .v { font-weight: 500; }
      .fld.hi { box-shadow: inset 0 0 0 1px rgba(110, 86, 255, 0.9); background: rgba(110, 86, 255, 0.14); }
      .new { height: 17px; padding: 0 6px; border-radius: 9px; background: rgba(110, 86, 255, 0.24); color: #b4a9ff; font-size: 10px; font-weight: 600; display: flex; align-items: center; }
      .ibt { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #a3a3ae; background: rgba(255, 255, 255, 0.055); }
      .ibt.on { background: rgba(255, 255, 255, 0.13); color: #fff; }
      #slTrack { left: 92px; top: 294px; width: 110px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.13); }
      #slFill { left: 92px; top: 294px; height: 4px; border-radius: 2px; background: var(--acc); }
      #slThumb { top: 289px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
      .og { width: 44px; height: 44px; border-radius: 6px; background: rgba(255, 255, 255, 0.055); }
      .og i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #6b6b76; }
      .og i.on { background: var(--acc2); box-shadow: 0 0 0 3px rgba(110, 86, 255, 0.3); }
      .sw { width: 18px; height: 18px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
      .tg { width: 28px; height: 16px; border-radius: 8px; background: rgba(255, 255, 255, 0.16); }
      .tg::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
      .tg.on { background: var(--acc); }
      .tg.on::after { left: 14px; }

      /* app screens (390 x 844, light) */
      .app { position: absolute; left: 0; top: 0; width: 390px; height: 844px; background: #fff; color: #15151a; font-size: 15px; }
      .app > * { position: absolute; }
      .sb { left: 0; top: 0; width: 390px; height: 50px; }
      .sb .tm { position: absolute; left: 34px; top: 15px; font-size: 16px; font-weight: 600; }
      .sb .st { position: absolute; right: 30px; top: 18px; display: flex; align-items: center; gap: 6px; }
      .hdt { left: 20px; top: 62px; width: 350px; height: 44px; }
      .hdt > * { position: absolute; }
      .ba { width: 40px; height: 40px; border-radius: 50%; }
      .bal { left: 20px; top: 120px; width: 350px; height: 196px; border-radius: 26px; background: linear-gradient(140deg, #7a64ff 0%, #5a42f0 100%); color: #fff; overflow: hidden; }
      .bal > * { position: absolute; }
      .qa { top: 334px; width: 76px; height: 86px; }
      .qa > * { position: absolute; }
      .qa i { left: 11px; top: 0; width: 54px; height: 54px; border-radius: 50%; background: #f2f2f6; display: flex; align-items: center; justify-content: center; color: #1a1a20; font-style: normal; }
      .qa span { left: 0; top: 62px; width: 76px; text-align: center; font-size: 12.5px; font-weight: 500; color: #3a3a44; }
      .sec { left: 20px; top: 442px; width: 350px; height: 24px; display: flex; align-items: center; justify-content: space-between; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
      .sec u { text-decoration: none; font-size: 13px; font-weight: 500; color: #6e56ff; }
      .tr { left: 20px; width: 350px; height: 56px; }
      .tr > * { position: absolute; }
      .tr .tile { left: 0; top: 8px; width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
      .tr .t1 { left: 54px; top: 10px; font-size: 15px; font-weight: 500; white-space: nowrap; }
      .tr .t2 { left: 54px; top: 31px; font-size: 12px; color: #8a8a96; white-space: nowrap; }
      .tr .am { right: 0; top: 10px; font-size: 15px; font-weight: 600; white-space: nowrap; }
      .tr .am2 { right: 0; top: 31px; font-size: 12px; color: #8a8a96; white-space: nowrap; }
      .gh2 { left: 20px; width: 350px; height: 20px; font-size: 12px; font-weight: 600; color: #8a8a96; letter-spacing: 0.02em; }
      .tbar { left: 0; top: 756px; width: 390px; height: 88px; border-top: 1px solid #ececf1; background: #fff; }
      .tbar > * { position: absolute; }
      .tbi { top: 10px; width: 97px; height: 46px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 500; color: #9a9aa6; }
      .tbi.on { color: #6e56ff; }
      .hi2 { left: 128px; top: 76px; width: 134px; height: 5px; border-radius: 3px; background: #15151a; }
      .ttl { left: 20px; top: 62px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
      .srch { left: 20px; top: 116px; width: 350px; height: 42px; border-radius: 12px; background: #f2f2f6; display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 14px; color: #9a9aa6; }
      .chp { top: 172px; height: 32px; padding: 0 13px; border-radius: 16px; background: #f2f2f6; font-size: 13px; font-weight: 500; color: #3a3a44; display: flex; align-items: center; white-space: nowrap; }
      .chp.on { background: #15151a; color: #fff; }
      .crd { left: 20px; top: 120px; width: 350px; height: 214px; border-radius: 24px; overflow: hidden; background: #131318; color: #fff; }
      .crd > * { position: absolute; }
      .lim { left: 20px; width: 350px; }
      .lim > * { position: absolute; }
      .srow { left: 20px; width: 350px; height: 50px; display: flex; align-items: center; justify-content: space-between; font-size: 15px; font-weight: 500; border-bottom: 1px solid #f0f0f4; }
      .srow small { display: block; font-size: 12px; font-weight: 400; color: #8a8a96; margin-top: 2px; }
      .tgl { position: relative; width: 44px; height: 26px; border-radius: 13px; background: #d9d9e0; flex: none; }
      .tgl::after { content: ""; position: absolute; left: 2px; top: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
      .tgl.on { background: #6e56ff; }
      .tgl.on::after { left: 20px; }

      /* cursor + comments */
      #cur { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; z-index: 30; }
      #curi { position: absolute; left: -2px; top: -2px; width: 24px; height: 28px; transform-origin: 2px 2px; }
      #curi svg { width: 24px; height: 28px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }
      .mc { position: absolute; z-index: 9; display: flex; align-items: flex-start; }
      .mc .nm { margin-left: 4px; margin-top: 14px; height: 20px; padding: 0 7px; border-radius: 4px 10px 10px 10px; color: #fff; font-size: 11px; font-weight: 600; line-height: 20px; }

      #mark { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; z-index: 40; opacity: 0; display: flex; align-items: center; justify-content: center; gap: 30px; font-weight: 700; font-size: 136px; line-height: 1; letter-spacing: -0.035em; color: #f4f4f6; }
      #scrim { z-index: 39; opacity: 0; background: radial-gradient(ellipse 800px 300px at 50% 50%, rgba(4, 4, 6, 0.85) 0%, rgba(4, 4, 6, 0.6) 55%, rgba(4, 4, 6, 0) 100%); }

      /* finish */
      #grain {
        z-index: 8; pointer-events: none; opacity: 0.07; background-size: 256px 256px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)'/%3E%3C/svg%3E");
      }
      #vig { z-index: 9; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 58%, rgba(0, 0, 0, 0.5) 100%); }
    </style>
  </head>
  <body>
    <div id="root" data-composition-id="main" data-start="0" data-duration="10.5" data-width="1920" data-height="1080">
      <div id="ui" class="clip full" data-start="5.05" data-duration="5.45" data-track-index="0">
        <div id="uiBg" class="full"></div>
        <div id="uiCam" class="full" data-layout-allow-overlap>
          <div id="win" data-layout-allow-overlap data-layout-ignore></div>
          <div id="cur">
            <div id="curi">
              <svg viewBox="0 0 24 28"><path d="M2 2 L2 22.5 L7.4 17.6 L11.4 26.4 L15 24.8 L11 16.2 L18.6 16.2 Z" fill="#111" stroke="#fff" stroke-width="2" stroke-linejoin="round"/></svg>
            </div>
          </div>
        </div>
        <div id="scrim" class="full"></div>
        <div id="mark" data-layout-allow-overflow>
          <svg width="120" height="120" viewBox="0 0 38 38"><defs><linearGradient id="mg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#8a78ff"/><stop offset="1" stop-color="#5a42f0"/></linearGradient></defs><rect width="38" height="38" rx="10" fill="url(#mg)"/><path d="M11 27 L16 11 H29 L24 27 Z" fill="none" stroke="#fff" stroke-width="2.6" stroke-linejoin="round"/></svg>
          Planar
        </div>
      </div>

      <div id="rib" class="clip full" data-start="0" data-duration="5.05" data-track-index="1">
        <div id="rows" class="view full" data-layout-allow-overlap>
          <div id="cam3" class="full" data-layout-allow-overlap></div>
        </div>
        <div id="bands" class="view full" data-layout-allow-overlap>
          <div id="bw" class="full" data-layout-allow-overlap></div>
        </div>
      </div>

      <div id="wipe" class="clip full" data-start="4.3" data-duration="1.5" data-track-index="2">
        <div id="wg" data-layout-allow-overlap></div>
      </div>

      <div id="grain" class="clip full" data-start="0" data-duration="10.5" data-track-index="3"></div>
      <div id="vig" class="clip full" data-start="0" data-duration="10.5" data-track-index="4"></div>
    </div>

    <script>
      /* ============================================================
         Folded Ribbon Text
         0.0-1.0   two-line title on black (one panel per word group)
         1.0-3.4   each line folds at its word breaks, the camera pitches and pulls back,
                   six more rows multiply the field
         3.0-5.05  wide arrow bands fly past, then a violet band wipes to the editor
         5.05-8.35 Planar editor: Rotate Y handle drag, then Distance slider drag
         8.35-10.5 editor dims and pulls back under the Planar lockup
         Everything 3D is a pure function of time: render(t).
         ============================================================ */
      const DUR = 10.5;
      const D2R = Math.PI / 180;
      const clamp = (x, a, b) => Math.min(b === undefined ? 1 : b, Math.max(a === undefined ? 0 : a, x));
      const lerp = (a, b, u) => a + (b - a) * u;
      const seg = (t, a, b) => clamp((t - a) / (b - a));
      const eExpoOut = (u) => (u >= 1 ? 1 : 1 - Math.pow(2, -10 * u));
      const eIO3 = (u) => (u < 0.5 ? 4 * u * u * u : 1 - Math.pow(-2 * u + 2, 3) / 2);
      const eOut3 = (u) => 1 - Math.pow(1 - u, 3);
      const eIO2 = (u) => 0.5 - 0.5 * Math.cos(Math.PI * u);

      /* monotone cubic keyframes: smooth, no overshoot, flat where neighbours are equal */
      function kf(t, k) {
        const n = k.length;
        if (t <= k[0][0]) return k[0][1];
        if (t >= k[n - 1][0]) return k[n - 1][1];
        let i = 0;
        while (t > k[i + 1][0]) i++;
        const d = [], m = [];
        for (let j = 0; j < n - 1; j++) d[j] = (k[j + 1][1] - k[j][1]) / (k[j + 1][0] - k[j][0]);
        m[0] = d[0]; m[n - 1] = d[n - 2];
        for (let j = 1; j < n - 1; j++) m[j] = d[j - 1] * d[j] <= 0 ? 0 : (d[j - 1] + d[j]) / 2;
        for (let j = 0; j < n - 1; j++) {
          if (d[j] === 0) { m[j] = 0; m[j + 1] = 0; continue; }
          const a = m[j] / d[j], b = m[j + 1] / d[j], s = a * a + b * b;
          if (s > 9) { const q = 3 / Math.sqrt(s); m[j] = q * a * d[j]; m[j + 1] = q * b * d[j]; }
        }
        const h = k[i + 1][0] - k[i][0], u = (t - k[i][0]) / h;
        const u2 = u * u, u3 = u2 * u;
        return (2 * u3 - 3 * u2 + 1) * k[i][1] + (u3 - 2 * u2 + u) * h * m[i] + (-2 * u3 + 3 * u2) * k[i + 1][1] + (u3 - u2) * h * m[i + 1];
      }

      /* ---------- icons (lucide-style, 24 grid) ---------- */
      const G = {
        home: '<path d="m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/>',
        card: '<rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/>',
        activity: '<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>',
        user: '<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',
        bell: '<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>',
        send: '<path d="M7 7h10v10"/><path d="M7 17 17 7"/>',
        recv: '<path d="M17 7 7 17"/><path d="M17 17H7V7"/>',
        plus: '<path d="M5 12h14"/><path d="M12 5v14"/>',
        more: '<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',
        search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',
        basket: '<path d="m15 11-1 9"/><path d="m19 11-4-7"/><path d="M2 11h20"/><path d="m3.5 11 1.6 7.4a2 2 0 0 0 2 1.6h9.8a2 2 0 0 0 2-1.6l1.7-7.4"/><path d="m5 11 4-7"/><path d="m9 11 1 9"/>',
        car: '<path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2"/><circle cx="7" cy="17" r="2"/><path d="M9 17h6"/><circle cx="17" cy="17" r="2"/>',
        tv: '<rect width="20" height="15" x="2" y="7" rx="2"/><polyline points="17 2 12 7 7 2"/>',
        coffee: '<path d="M10 2v2"/><path d="M14 2v2"/><path d="M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1"/><path d="M6 2v2"/>',
        brief: '<rect width="20" height="14" x="2" y="7" rx="2"/><path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"/>',
        dumb: '<path d="M14.4 14.4 9.6 9.6"/><path d="M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z"/><path d="m21.5 21.5-1.4-1.4"/><path d="M3.9 3.9 2.5 2.5"/><path d="M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z"/>',
        layers: '<path d="m12 2 10 5-10 5L2 7z"/><path d="m2 17 10 5 10-5"/><path d="m2 12 10 5 10-5"/>',
        pointer: '<path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/>',
        frame: '<line x1="22" x2="2" y1="6" y2="6"/><line x1="22" x2="2" y1="18" y2="18"/><line x1="6" x2="6" y1="2" y2="22"/><line x1="18" x2="18" y1="2" y2="22"/>',
        square: '<rect width="18" height="18" x="3" y="3" rx="2"/>',
        circle: '<circle cx="12" cy="12" r="9"/>',
        pen: '<path d="m12 19 7-7 3 3-7 7-3-3z"/><path d="m18 13-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="m2 2 7.586 7.586"/><circle cx="11" cy="11" r="2"/>',
        type: '<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/>',
        comment: '<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/>',
        chevd: '<path d="m6 9 6 6 6-6"/>',
        chevr: '<path d="m9 18 6-6-6-6"/>',
        eye: '<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>',
        lock: '<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',
        hand: '<path d="M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2"/><path d="M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2"/><path d="M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8"/><path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/>',
        comp: '<path d="M5.5 8.5 9 12l-3.5 3.5L2 12l3.5-3.5Z"/><path d="m12 2 3.5 3.5L12 9 8.5 5.5 12 2Z"/><path d="M18.5 8.5 22 12l-3.5 3.5L15 12l3.5-3.5Z"/><path d="m12 15 3.5 3.5L12 22l-3.5-3.5L12 15Z"/>',
        image: '<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>',
        play: '<polygon points="6 3 20 12 6 21 6 3"/>',
        rot3: '<path d="M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2"/><path d="m15.194 13.707 3.814 1.86-1.86 3.814"/><path d="M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4"/>',
        trend: '<polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/>',
        tabs: '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/>',
        right: '<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',
        down: '<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',
        wrap: '<path d="M3 6h18"/><path d="M3 12h15a3 3 0 1 1 0 6h-4"/><polyline points="16 16 14 18 16 20"/><path d="M3 18h7"/>',
        minus: '<path d="M5 12h14"/>',
        contact: '<path d="M6 8.32a7.43 7.43 0 0 1 0 7.36"/><path d="M9.46 6.21a11.76 11.76 0 0 1 0 11.58"/><path d="M12.91 4.1a15.91 15.91 0 0 1 .01 15.8"/><path d="M16.37 2a20.16 20.16 0 0 1 0 20"/>',
        share: '<path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><polyline points="16 6 12 2 8 6"/><line x1="12" x2="12" y1="2" y2="15"/>',
      };
      const ic = (n, s, w) => '<svg class="ic" width="' + s + '" height="' + s + '" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="' + (w || 1.7) + '" stroke-linecap="round" stroke-linejoin="round">' + G[n] + "</svg>";

      /* =====================================================
         RIBBON STAGE
         ===================================================== */
      /* Each row is one printed line cut at the word breaks: one panel per word group, so every crease
         falls between words. Panel widths are the measured word widths (Inter 700, 128px) plus 18px each side. */
      const ACC2 = [165, 151, 255];
      const PH = 150;
      const DEFS = [
        [["PERSPECTIVE", 865], ["FRAMES", 545]],
        [["NOW", 348], ["IN", 161], ["<b>PLANAR</b>", 537]],
      ];
      const SP_END = 340;
      const TH = 37;
      const ROW_J = [-3, -2, -1, 0, 1, 2, 3, 4];
      const XOFF = { "-3": 90, "-2": -90, "-1": 90, "0": 0, "1": 0, "2": -90, "3": 90, "4": -90 };
      const ROWS = ROW_J.map((j) => {
        const par = j <= 0 ? 0 : 1;
        const hero = j === 0 || j === 1;
        return { j, par, hero, def: DEFS[par], x0: XOFF[j], sgn: par ? -1 : 1, fd: 0.1 * par,
          ta: hero ? 0 : 2.25 + 0.09 * (Math.abs(j - 0.5) - 1.5) };
      });
      const camRows = {
        pitch: [[0, 0], [1.0, 0], [2.3, 26], [3.3, 30], [4.6, 34], [5.1, 36]],
        roll: [[0, 0], [1.0, 0], [2.3, -6], [3.3, -10], [4.6, -22], [5.1, -28]],
        yaw: [[0, 0], [1.0, 0], [2.3, 2], [3.3, 3], [4.6, -3], [5.1, -4]],
        z: [[0, 0], [1.0, 40], [2.3, -300], [3.3, -560], [4.6, 400], [5.1, 640]],
        y: [[0, 0], [1.0, 0], [2.3, -40], [3.3, -70], [4.6, -40], [5.1, -30]],
      };

      /* pure state of the rows scene at time t (no DOM) */
      function rowsState(t) {
        const cam = { pit: kf(t, camRows.pitch), rol: kf(t, camRows.roll), yaw: kf(t, camRows.yaw), z: kf(t, camRows.z), y: kf(t, camRows.y) };
        const dim = 1 - 0.68 * eIO2(seg(t, 3.4, 4.5));
        const breathe = seg(t, 2.25, 2.9);
        const SP = lerp(176, SP_END, eIO3(seg(t, 1.0, 2.4)));
        const rows = ROWS.map((r) => {
          const yTarget = (r.j - 0.5) * SP, yStart = (r.j < 0 ? r.j + 0.5 : r.j - 1.5) * SP;
          let yy = yTarget, xx = r.x0, op = 1;
          if (!r.hero) {
            const e = eExpoOut(seg(t, r.ta, r.ta + 0.95));
            yy = lerp(yStart, yTarget, e);
            xx = lerp(0, r.x0, e);
            op = Math.pow(clamp((t - r.ta) / 0.5), 2);
          }
          const fold = r.hero ? eIO3(seg(t, 1.0 + r.fd, 2.3 + r.fd)) : 1;
          const hb = r.hero ? 7 * eIO2(seg(t - r.fd, 1.1, 1.8)) * (1 - eIO2(seg(t - r.fd, 2.5, 3.4))) : 0;
          const th = (TH * fold + hb + 3 * Math.sin(((t - 2.0) / 3.4) * Math.PI * 2 + r.j * 0.9) * breathe) * D2R;
          let x = 0, zz = 0;
          const pn = [];
          r.def.forEach((d, i) => {
            const w = d[1];
            const a = r.sgn * (i % 2 ? -1 : 1) * th;
            const dx = Math.cos(a) * w, dz = -Math.sin(a) * w;
            pn.push({ w, x: x + dx / 2, z: zz + dz / 2, a });
            x += dx; zz += dz;
          });
          const ox = x / 2, oz = zz / 2;
          pn.forEach((p, i) => {
            p.x = p.x - ox + xx; p.y = yy; p.z = p.z - oz;
            const b = 1 - 0.5 * fold * (p.a > 0 ? 1 : 0);
            const wv = seg(t, 2.95 + 0.1 * i + 0.055 * r.j, 3.45 + 0.1 * i + 0.055 * r.j);
            const w0 = seg(t, 0.3 + 0.12 * i + 0.12 * r.j, 0.8 + 0.12 * i + 0.12 * r.j);
            p.m = Math.max(wv > 0 && wv < 1 ? Math.pow(Math.sin(Math.PI * wv), 1.4) : 0, r.hero && w0 > 0 && w0 < 1 ? Math.pow(Math.sin(Math.PI * w0), 1.4) : 0);
            p.b = b;
            p.rise = r.hero ? (1 - eExpoOut(seg(t, 0.12 * r.par, 0.8 + 0.12 * r.par))) * 170 : 0;
          });
          return { op: op * dim, pn };
        });
        return { cam, rows };
      }

      const cam3 = document.getElementById("cam3");
      const bw = document.getElementById("bw");
      ROWS.forEach((r) => {
        r.dom = r.def.map((d) => {
          const p = document.createElement("div");
          p.className = "pn";
          p.setAttribute("data-layout-allow-overflow", "");
          p.setAttribute("data-layout-allow-overlap", "");
          p.style.width = d[1] + "px";
          p.style.left = 960 - d[1] / 2 + "px";
          p.style.top = 540 - PH / 2 + "px";
          const tx = document.createElement("div");
          tx.className = "tx";
          tx.innerHTML = d[0];
          p.appendChild(tx);
          cam3.appendChild(p);
          return p;
        });
      });

      function renderRows(t) {
        const S = rowsState(t), c = S.cam;
        cam3.style.transform = "translate3d(0," + c.y.toFixed(2) + "px," + c.z.toFixed(2) + "px) rotateX(" + c.pit.toFixed(3) + "deg) rotateY(" + c.yaw.toFixed(3) + "deg) rotateZ(" + c.rol.toFixed(3) + "deg)";
        S.rows.forEach((rs, ri) => {
          rs.pn.forEach((q, i) => {
            const p = ROWS[ri].dom[i];
            p.style.opacity = rs.op.toFixed(3);
            p.firstChild.style.transform = "translateY(" + q.rise.toFixed(2) + "px)";
            p.style.transform = "translate3d(" + q.x.toFixed(2) + "px," + q.y.toFixed(2) + "px," + q.z.toFixed(2) + "px) rotateY(" + (q.a / D2R).toFixed(3) + "deg)";
            const R = lerp(255 * q.b, ACC2[0], q.m), Gc = lerp(255 * q.b, ACC2[1], q.m), B = lerp(255 * q.b, ACC2[2], q.m);
            p.style.color = "rgb(" + (R | 0) + "," + (Gc | 0) + "," + (B | 0) + ")";
          });
        });
      }

      /* ---------- bands ---------- */
      /* band text is set in fixed-width blocks (per = measured width of one copy, rounded up), so the scroll period never depends on font loading */
      const BANDS = [
        { cls: "v", bh: 300, txt: "TILT → SKEW → ROTATE → PERSPECTIVE → ", per: 3900, sp: 1500, fs: 190,
          k: [[3.0, -3000, 900, -420, 0, 22, -32], [3.9, -420, 150, -120, 0, 14, -29], [5.1, 760, -170, 140, 0, 8, -26]] },
        { cls: "w", bh: 230, txt: "PERSPECTIVE → ROTATE → SKEW → TILT → ", per: 3080, sp: -1300, fs: 150,
          k: [[3.3, 3000, 820, -700, -38, -26, 26], [4.2, -60, 260, -250, -30, -20, 23], [5.1, -760, 50, 90, -22, -16, 20]] },
        { cls: "d", bh: 420, txt: "SKEW → TILT → ROTATE → PERSPECTIVE → ", per: 5140, sp: 1100, fs: 250,
          k: [[3.55, 120, -2100, -520, 68, 0, -8], [4.4, 80, -480, -160, 60, 6, -7], [5.1, 40, -180, 90, 52, 10, -6]] },
        { cls: "v", bh: 160, txt: "NOW IN PLANAR → ", per: 912, sp: -1700, fs: 100,
          k: [[3.75, -2800, -520, -260, 0, -30, 42], [4.6, -260, -300, -40, 0, -24, 36], [5.1, 140, -250, 130, 0, -20, 33]] },
      ];
      BANDS.forEach((b) => {
        b.el = document.createElement("div");
        b.el.className = "band " + b.cls;
        b.el.setAttribute("data-layout-allow-overflow", "");
        b.el.setAttribute("data-layout-ignore", "");
        const BW = 9000;
        b.el.style.width = BW + "px";
        b.el.style.height = b.bh + "px";
        b.el.style.left = 960 - BW / 2 + "px";
        b.el.style.top = 540 - b.bh / 2 + "px";
        b.el.style.opacity = "0";
        const bt = document.createElement("div");
        bt.className = "bt";
        bt.style.height = b.bh + "px";
        bt.style.fontSize = b.fs + "px";
        bt.style.lineHeight = b.bh + "px";
        const one = '<span style="display:inline-block;flex:none;width:' + b.per + 'px">' + b.txt.replace(/ /g, "&nbsp;") + "</span>";
        bt.innerHTML = one.repeat(Math.ceil(BW / b.per) + 3);
        b.el.appendChild(bt);
        b.bt = bt;
        bw.appendChild(b.el);
      });
      const camBands = { z: [[3.0, 0], [5.1, 360]], r: [[3.0, 0], [5.1, -8]] };

      function renderBands(t) {
        bw.style.transform = "translateZ(" + kf(t, camBands.z).toFixed(2) + "px) rotateZ(" + kf(t, camBands.r).toFixed(3) + "deg)";
        BANDS.forEach((b) => {
          const k = b.k;
          const T = (i) => k.map((q) => [q[0], q[i]]);
          const x = kf(t, T(1)), y = kf(t, T(2)), z = kf(t, T(3)), rx = kf(t, T(4)), ry = kf(t, T(5)), rz = kf(t, T(6));
          b.el.style.opacity = t >= k[0][0] - 0.05 ? "1" : "0";
          b.el.style.transform = "translate3d(" + x.toFixed(2) + "px," + y.toFixed(2) + "px," + z.toFixed(2) + "px) rotateZ(" + rz.toFixed(3) + "deg) rotateX(" + rx.toFixed(3) + "deg) rotateY(" + ry.toFixed(3) + "deg)";
          let off = (b.sp * (t - 3.0)) % b.per;
          if (off < 0) off += b.per;
          b.bt.style.transform = "translateX(" + (-b.per - off).toFixed(2) + "px)";
        });
      }

      /* ---------- wipe ---------- */
      const wg = document.getElementById("wg");
      const WIPE = [
        { cls: "w", y: -1590, h: 150, txt: "→ ", fs: 120 },
        { cls: "v", y: 0, h: 3000, txt: "PERSPECTIVE → FRAMES → ", fs: 620, main: true },
        { cls: "d", y: 1560, h: 120, txt: "→ ", fs: 90 },
      ];
      WIPE.forEach((b) => {
        const e = document.createElement("div");
        e.className = "band " + b.cls;
        e.setAttribute("data-layout-allow-overflow", "");
        e.setAttribute("data-layout-ignore", "");
        e.style.width = "12000px";
        e.style.height = b.h + "px";
        e.style.top = b.y - b.h / 2 + "px";
        b.per = b.main ? 11000 : 220;
        /* the violet band carries two lines of giant type: one crosses the screen at about 4.95s and one at 5.05s, so the cover stays on type */
        b.lines = (b.main ? [{ dy: -1100, ph: 6700 }, { dy: 0, ph: 0 }] : [{ dy: 0, ph: 0 }]).map((ln) => {
          const bt = document.createElement("div");
          bt.className = "bt";
          bt.style.top = ln.dy + "px";
          bt.style.height = b.h + "px";
          bt.style.fontSize = b.fs + "px";
          bt.style.lineHeight = b.h + "px";
          bt.innerHTML = ('<span style="display:inline-block;width:' + b.per + 'px">' + b.txt.replace(/ /g, "&nbsp;") + "</span>").repeat(b.main ? 6 : 70);
          e.appendChild(bt);
          ln.bt = bt;
          return ln;
        });
        b.el = e;
        wg.appendChild(e);
      });
      function renderWipe(t) {
        const u = eIO3(seg(t, 4.3, 5.8));
        const s = lerp(3350, -3350, u);
        wg.style.transform = "rotateY(-9deg) rotateZ(-26deg) translateY(" + s.toFixed(2) + "px)";
        WIPE.forEach((b) => {
          const per = b.per;
          b.lines.forEach((ln) => {
            const off = (b.main ? 2600 : 900) * (t - 4.3) + ln.ph;
            ln.bt.style.transform = "translateX(" + (-(off % per) - per * 2).toFixed(2) + "px)";
          });
        });
      }

      /* =====================================================
         EDITOR
         ===================================================== */
      const win = document.getElementById("win");
      const SC = 0.74;
      const tile = (bg, col, g) => '<div class="tile" style="background:' + bg + ";color:" + col + '">' + ic(g, 20, 1.8) + "</div>";
      const TX = {
        mk: ["#e8f7ee", "#1f9d5c", "basket"], ride: ["#e8f0ff", "#3b6ef5", "car"], pay: ["#e8f8ef", "#1f9d5c", "brief"],
        tv: ["#fdeced", "#e5484d", "tv"], cof: ["#fff2de", "#c27a14", "coffee"], rent: ["#f0ecff", "#6e56ff", "home"], gym: ["#e6f6f8", "#0f8fa3", "dumb"],
      };
      const trow = (top, k, t1, t2, am, pos, am2) =>
        '<div class="tr" style="top:' + top + 'px">' + '<div class="tile" style="background:' + TX[k][0] + ";color:" + TX[k][1] + '">' + ic(TX[k][2], 20, 1.8) + "</div>" +
        '<div class="t1">' + t1 + '</div><div class="t2">' + t2 + '</div><div class="am"' + (pos ? ' style="color:#1f9d5c"' : "") + ">" + am + "</div>" + (am2 ? '<div class="am2">' + am2 + "</div>" : "") + "</div>";
      const statusBar = '<div class="sb"><div class="tm">9:41</div><div class="st">' +
        '<svg width="18" height="12" viewBox="0 0 18 12"><rect x="0" y="8" width="3" height="4" rx="1" fill="#15151a"/><rect x="5" y="5" width="3" height="7" rx="1" fill="#15151a"/><rect x="10" y="2.5" width="3" height="9.5" rx="1" fill="#15151a"/><rect x="15" y="0" width="3" height="12" rx="1" fill="#15151a"/></svg>' +
        '<svg width="17" height="12" viewBox="0 0 17 12" fill="none" stroke="#15151a" stroke-width="1.8" stroke-linecap="round"><path d="M1.5 4.2a10 10 0 0 1 14 0"/><path d="M4 7a6.4 6.4 0 0 1 9 0"/><circle cx="8.5" cy="10" r="1" fill="#15151a"/></svg>' +
        '<svg width="27" height="13" viewBox="0 0 27 13"><rect x="0.5" y="0.5" width="22" height="12" rx="3.5" fill="none" stroke="#15151a" opacity="0.4"/><rect x="2" y="2" width="19" height="9" rx="2.2" fill="#15151a"/><rect x="24" y="4" width="2" height="5" rx="1" fill="#15151a" opacity="0.4"/></svg></div></div>';
      const tabBar = (on) => {
        const t = [["home", "Home"], ["card", "Cards"], ["activity", "Activity"], ["user", "Profile"]];
        return '<div class="tbar">' + t.map((x, i) => '<div class="tbi' + (i === on ? " on" : "") + '" style="left:' + (i * 97.5) + 'px">' + ic(x[0], 24, i === on ? 2 : 1.7) + "<span>" + x[1] + "</span></div>").join("") + '<div class="hi2"></div></div>';
      };
      const spark = () => {
        const v = [38, 36, 40, 34, 31, 35, 29, 33, 27, 30, 24, 28, 22, 25, 19, 23, 17, 20, 13, 17, 11, 14, 8, 6];
        const W = 306, H = 56, n = v.length;
        const pts = v.map((y, i) => [(i / (n - 1)) * W, y + 8]);
        const d = pts.map((p, i) => (i ? "L" : "M") + p[0].toFixed(1) + " " + p[1].toFixed(1)).join(" ");
        return '<svg width="' + W + '" height="' + H + '" viewBox="0 0 ' + W + " " + H + '"><defs><linearGradient id="sg" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity="0.32"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient></defs>' +
          '<path d="' + d + " L" + W + " " + H + " L0 " + H + ' Z" fill="url(#sg)"/><path d="' + d + '" fill="none" stroke="#fff" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/><circle cx="' + pts[n - 1][0] + '" cy="' + pts[n - 1][1] + '" r="4" fill="#fff"/></svg>';
      };
      const appHome = () => '<div class="app">' + statusBar +
        '<div class="hdt"><div class="av ba" style="background:#f0a98d;font-size:14px">MC</div>' +
        '<div style="left:52px;top:2px;font-size:12.5px;color:#8a8a96">Good morning</div><div style="left:52px;top:19px;font-size:17px;font-weight:600;letter-spacing:-0.01em">Maya Chen</div>' +
        '<div style="right:0;top:0;width:40px;height:40px;border-radius:50%;background:#f2f2f6;display:flex;align-items:center;justify-content:center">' + ic("bell", 19, 1.8) + '<i style="position:absolute;right:10px;top:9px;width:8px;height:8px;border-radius:50%;background:#6e56ff;border:2px solid #f2f2f6"></i></div></div>' +
        '<div class="bal"><div style="left:22px;top:20px;font-size:13px;opacity:.8">Total balance</div><div style="right:22px;top:19px;font-size:12px;opacity:.8">Debit ••4821</div>' +
        '<div style="left:22px;top:42px;font-size:42px;font-weight:600;letter-spacing:-0.03em">$12,480<span style="font-size:26px;opacity:.7">.32</span></div>' +
        '<div style="left:22px;top:100px;height:26px;padding:0 10px;border-radius:13px;background:rgba(255,255,255,.2);font-size:12px;font-weight:600;display:flex;align-items:center;gap:5px">' + ic("trend", 13, 2.2) + '+2.4% this month</div>' +
        '<div style="left:22px;top:132px">' + spark() + "</div></div>" +
        [["send", "Send"], ["recv", "Request"], ["plus", "Top up"], ["more", "More"]].map((q, i) => '<div class="qa" style="left:' + (20 + i * 91.3) + 'px"><i>' + ic(q[0], 22, 1.8) + "</i><span>" + q[1] + "</span></div>").join("") +
        '<div class="sec">Recent transactions<u>See all</u></div>' +
        trow(474, "mk", "Greenleaf Market", "Groceries · 9:12 AM", "−$64.20") +
        trow(530, "ride", "Ridely", "Transport · 8:47 AM", "−$18.40") +
        trow(586, "pay", "Acme Studio payout", "Income · Yesterday", "+$2,400.00", true) +
        trow(642, "tv", "Streamly", "Subscriptions · Nov 24", "−$15.99") +
        trow(698, "cof", "Kettle Coffee", "Dining · Nov 24", "−$5.75") +
        tabBar(0) + "</div>";
      const appActivity = () => '<div class="app">' + statusBar + '<div class="ttl">Activity</div>' +
        '<div class="srch">' + ic("search", 17, 1.8) + "Search transactions</div>" +
        '<div class="chp on" style="left:20px">All</div><div class="chp" style="left:62px">Income</div><div class="chp" style="left:132px">Spending</div><div class="chp" style="left:214px">Subscriptions</div>' +
        '<div class="gh2" style="top:226px">TODAY · NOV 26</div>' +
        trow(250, "mk", "Greenleaf Market", "Groceries · 9:12 AM", "−$64.20") + trow(306, "ride", "Ridely", "Transport · 8:47 AM", "−$18.40") + trow(362, "cof", "Kettle Coffee", "Dining · 8:05 AM", "−$5.75") +
        '<div class="gh2" style="top:438px">YESTERDAY</div>' +
        trow(462, "pay", "Acme Studio payout", "Income · 4:30 PM", "+$2,400.00", true) + trow(518, "rent", "Rent · Maple St", "Housing · 9:00 AM", "−$1,850.00") + trow(574, "gym", "Cityfit Gym", "Health · 7:15 AM", "−$39.00") + trow(630, "tv", "Streamly", "Subscriptions · 6:02 AM", "−$15.99") +
        tabBar(2) + "</div>";
      const appCard = () => '<div class="app">' + statusBar + '<div class="ttl">Cards</div>' +
        '<div class="crd"><div style="left:-40px;top:-60px;width:300px;height:300px;border-radius:50%;background:radial-gradient(circle,rgba(110,86,255,.55),rgba(110,86,255,0) 68%)"></div>' +
        '<div style="left:24px;top:22px;display:flex;align-items:center;gap:8px;font-size:16px;font-weight:700;letter-spacing:-0.02em"><svg width="22" height="22" viewBox="0 0 38 38"><circle cx="19" cy="19" r="19" fill="#0f8fa3"/><path d="M12.5 27 V11 L25.5 27 V11" fill="none" stroke="#fff" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round"/></svg>Northpay</div>' +
        '<div style="right:24px;top:22px;opacity:.8">' + ic("contact", 22, 1.8) + "</div>" +
        '<div style="left:24px;top:116px;font-size:20px;letter-spacing:.14em;font-weight:500">•••• •••• •••• 4821</div>' +
        '<div style="left:24px;top:168px;font-size:12px;opacity:.7;letter-spacing:.04em">MAYA CHEN</div><div style="right:24px;top:168px;font-size:12px;opacity:.7">09/28</div></div>' +
        '<div class="srow" style="top:352px"><div>Freeze card<small>Block all payments instantly</small></div><div class="tgl"></div></div>' +
        '<div class="srow" style="top:404px"><div>Online payments<small>Allowed in 42 countries</small></div><div class="tgl on"></div></div>' +
        '<div class="srow" style="top:456px"><div>Contactless<small>Tap to pay up to $100</small></div><div class="tgl on"></div></div>' +
        '<div class="lim" style="top:532px"><div style="left:0;top:0;font-size:17px;font-weight:600;letter-spacing:-0.01em">Monthly limit</div><div style="right:0;top:3px;font-size:13px;color:#8a8a96">Resets Dec 1</div>' +
        '<div style="left:0;top:38px;font-size:28px;font-weight:600;letter-spacing:-0.02em">$3,240 <span style="font-size:14px;color:#8a8a96;font-weight:500">of $5,000</span></div>' +
        '<div style="left:0;top:82px;width:350px;height:8px;border-radius:4px;background:#f0f0f4"><div style="left:0;top:0;width:227px;height:8px;border-radius:4px;background:#6e56ff"></div></div>' +
        '<div style="left:0;top:104px;font-size:12px;color:#8a8a96">Groceries $820 · Transport $310 · Dining $460</div></div>' +
        tabBar(1) + "</div>";

      /* left panel */
      const LAYERS = [
        [0, "frame", "Home", "sel", "cv-d"], [1, "tabs", "Header", "sub", "cv-d"], [2, "circle", "Avatar", "sub"], [2, "type", "Greeting", "sub"], [1, "tabs", "Balance card", "sub", "cv-r"],
        [1, "tabs", "Quick actions", "sub", "cv-r"], [1, "comp", "Transaction row", "sub", "ci"], [1, "comp", "Tab bar", "sub", "ci"],
        [0, "frame", "Activity"], [0, "frame", "Card"], [0, "frame", "Card / Frozen"], [0, "frame", "Transfer"], [0, "frame", "Transfer / Confirm"], [0, "frame", "Onboarding 1"], [0, "frame", "Onboarding 2"], [0, "frame", "Empty state"],
      ];
      let lh = "";
      LAYERS.forEach((l, i) => {
        const cv = l[4] === "cv-d" ? '<span class="cv">' + ic("chevd", 12, 2) + "</span>" : l[4] === "cv-r" ? '<span class="cv">' + ic("chevr", 12, 2) + "</span>" : l[4] === "ci" ? "" : l[1] === "frame" ? '<span class="cv">' + ic("chevr", 12, 2) + "</span>" : "";
        const pad = 8 + l[0] * 16 + (cv ? 0 : 15);
        lh += '<div class="lr ' + (l[3] || "") + (l[4] === "ci" ? " ci" : "") + '" style="top:' + (224 + i * 28) + "px;padding-left:" + pad + 'px">' + cv + ic(l[1], 14, 1.7) + "<span>" + l[2] + "</span>" + (l[3] === "sel" ? '<span class="ey">' + ic("eye", 14, 1.7) + "</span>" : "") + "</div>";
      });
      const leftPanel = '<div id="lp"><div class="tab on" style="left:16px">Layers</div><div class="tab" style="left:78px">Assets</div><div style="left:222px;top:12px;color:#8f8f9b">' + ic("search", 16, 1.8) + "</div>" +
        '<div class="hr" style="top:40px"></div>' +
        '<div class="sh" style="top:48px">Pages' + ic("plus", 14, 1.8) + "</div>" +
        '<div class="pg" style="top:76px">Cover</div><div class="pg on" style="top:102px"><i></i>Home flows</div><div class="pg" style="top:128px">Components</div><div class="pg" style="top:154px">Archive</div>' +
        '<div class="hr" style="top:190px"></div><div class="sh" style="top:192px;height:26px">Layers</div>' + lh + "</div>";

      /* toolbar */
      const tbTools = [["pointer", 62, true], ["frame", 98], ["square", 134], ["pen", 170], ["type", 206], ["hand", 242]];
      const toolbar = '<div id="tb"><i class="tl2" style="left:18px;background:#ff5f57"></i><i class="tl2" style="left:38px;background:#febc2e"></i><i class="tl2" style="left:58px;background:#28c840"></i>' +
        tbTools.map((x) => '<div class="tbtn' + (x[2] ? " on" : "") + '" style="left:' + (x[1] + 30) + 'px">' + ic(x[0], 16, 1.8) + "</div>").join("") +
        '<div class="sepv" style="left:308px"></div><div class="tbtn" style="left:320px">' + ic("comp", 16, 1.8) + '</div><div class="tbtn" style="left:356px">' + ic("comment", 16, 1.8) + "</div>" +
        '<div id="crumb"><span style="color:#8f8f9b;font-weight:400">Northpay</span><span class="dm">/</span><span>Mobile v2.3</span><span class="pill">Draft</span></div>' +
        '<div style="left:1236px;top:12px;display:flex">' + [["MC", "#e5833b"], ["LO", "#3fa6a0"], ["PN", "#d6498b"]].map((a, i) => '<span class="av" style="width:24px;height:24px;font-size:9.5px;background:' + a[1] + ";margin-left:" + (i ? -3 : 0) + 'px;box-shadow:0 0 0 2px #1f1f23">' + a[0] + "</span>").join("") + "</div>" +
        '<div class="tbtn" style="left:1320px">' + ic("play", 15, 1.8) + '</div><div id="share">Share</div>' +
        '<div style="left:1622px;top:14px;display:flex;align-items:center;gap:4px;font-size:12.5px;font-weight:500;color:#d9d9e0">78%' + ic("chevd", 13, 2) + "</div></div>";

      /* right panel: every row has an explicit top */
      const rfld = (x, y, w, k, v, extra, id) => '<div' + (id ? ' id="' + id + '"' : "") + ' class="fld' + (extra || "") + '" style="left:' + x + "px;top:" + y + "px;width:" + w + 'px"><span class="k">' + k + '</span><span class="v">' + v + "</span></div>";
      let og = "";
      for (let r = 0; r < 3; r++) for (let c = 0; c < 3; c++) og += '<i class="' + (r === 1 && c === 1 ? "on" : "") + '" style="left:' + (8 + c * 15 + (c === 1 ? 0 : 0)) + "px;top:" + (8 + r * 15) + 'px"></i>';
      const rightPanel = '<div id="rp"><div class="tab on" style="left:16px">Design</div><div class="tab" style="left:80px">Prototype</div><div class="tab" style="left:158px">Inspect</div><div class="hr" style="top:40px"></div>' +
        '<div class="rt" style="top:54px">Frame</div>' +
        '<div class="fld" style="left:16px;top:80px;width:268px;justify-content:space-between"><span class="v">iPhone 15 Pro</span>' + ic("chevd", 14, 2) + "</div>" +
        rfld(16, 116, 130, "X", "425") + rfld(154, 116, 130, "Y", "130") + rfld(16, 150, 130, "W", "390") + rfld(154, 150, 130, "H", "844") +
        '<div class="hr" style="top:194px"></div>' +
        '<div class="rt" style="top:208px">Perspective<span class="new">New</span></div><div style="right:16px;top:208px;color:#8f8f9b">' + ic("minus", 14, 1.8) + "</div>" +
        '<div class="rl" style="top:244px">Rotate</div>' +
        rfld(92, 238, 56, "X", '<span id="vRX">0°</span>') + rfld(154, 238, 64, "Y", '<span id="vRY">0°</span>', "", "fldRY") + rfld(224, 238, 60, "Z", "0°") +
        '<div class="rl" style="top:288px">Distance</div><div id="slTrack"></div><div id="slFill"></div><div id="slThumb"></div>' +
        '<div class="fld" id="fldPP" style="left:220px;top:282px;width:64px"><span class="v" id="vPP">1200</span></div>' +
        '<div class="rl" style="top:342px">Origin</div><div class="og" style="left:92px;top:326px">' + og + "</div>" +
        '<div class="rl" style="left:152px;top:334px;color:#cfcfd8">Backface</div><div class="tg on" style="left:238px;top:334px"></div>' +
        '<div class="rl" style="left:152px;top:358px;color:#cfcfd8">Clip children</div><div class="tg" style="left:238px;top:358px"></div>' +
        '<div class="hr" style="top:394px"></div>' +
        '<div class="rt" style="top:408px">Auto layout</div><div style="right:16px;top:408px;color:#8f8f9b">' + ic("plus", 14, 1.8) + "</div>" +
        '<div class="ibt on" style="left:16px;top:438px">' + ic("down", 15, 1.8) + '</div><div class="ibt" style="left:50px;top:438px">' + ic("right", 15, 1.8) + '</div><div class="ibt" style="left:84px;top:438px">' + ic("wrap", 15, 1.8) + "</div>" +
        rfld(124, 438, 76, "Gap", "16") + rfld(208, 438, 76, "Pad", "24") +
        '<div class="hr" style="top:486px"></div>' +
        '<div class="rt" style="top:500px">Appearance</div>' +
        rfld(16, 528, 130, ic("eye", 13, 1.8), "100%") + rfld(154, 528, 130, ic("square", 13, 1.8), "44") +
        '<div class="hr" style="top:572px"></div>' +
        '<div class="rt" style="top:586px">Fill</div><div style="right:16px;top:586px;color:#8f8f9b">' + ic("plus", 14, 1.8) + "</div>" +
        '<div class="sw" style="left:16px;top:616px;background:#fff"></div><div class="fld" style="left:42px;top:611px;width:160px"><span class="v">FFFFFF</span></div><div class="fld" style="left:208px;top:611px;width:76px"><span class="v">100%</span></div>' +
        '<div class="hr" style="top:656px"></div>' +
        '<div class="rt" style="top:670px">Effects</div><div style="right:16px;top:670px;color:#8f8f9b">' + ic("plus", 14, 1.8) + "</div>" +
        '<div class="sw" style="left:16px;top:700px;background:#000"></div><div class="fld" style="left:42px;top:695px;width:242px;justify-content:space-between"><span class="v">Drop shadow</span><span style="color:#8f8f9b">0 30 90</span></div>' +
        '<div class="hr" style="top:740px"></div>' +
        '<div class="rt" style="top:754px">Export</div><div style="right:16px;top:754px;color:#8f8f9b">' + ic("plus", 14, 1.8) + "</div>" +
        '<div class="fld" style="left:16px;top:784px;width:268px;justify-content:space-between"><span class="v">2x · PNG</span>' + ic("share", 14, 1.8) + "</div></div>";

      /* canvas */
      const FC = [
        { id: "fAct", cx: 245, cy: 438, html: appActivity(), name: "Activity" },
        { id: "fHome", cx: 570, cy: 438, html: appHome(), name: "Home", sel: true },
        { id: "fCrd", cx: 895, cy: 438, html: appCard(), name: "Card" },
      ];
      let cvs = "";
      FC.forEach((f) => {
        const left = f.cx - 195, top = f.cy - 422;
        cvs += '<div class="flab' + (f.sel ? " sel" : "") + '" style="left:' + (f.cx - 144) + 'px">' + ic("frame", 12, 1.8) + f.name + "</div>";
        cvs += '<div class="fw" id="' + f.id + '" style="left:' + left + "px;top:" + top + "px;transform:scale(" + SC + ')"><div class="fc">' + f.html + '</div><div class="shade"></div>' +
          (f.sel ? '<div class="selb"></div><div class="hd" style="left:-6px;top:-6px"></div><div class="hd" style="left:383px;top:-6px"></div><div class="hd" style="left:-6px;top:837px"></div><div class="hd" style="left:383px;top:837px"></div>' +
            '<div class="hdr" id="hRot" style="left:381px;top:415px"></div>' : "") + "</div>";
      });
      cvs += '<div style="left:490px;top:769px;width:160px;display:flex;justify-content:center"><div class="chip">390 × 844</div></div>';
      cvs += '<div class="mc" style="left:34px;top:330px"><svg width="18" height="22" viewBox="0 0 24 28"><path d="M2 2 L2 22.5 L7.4 17.6 L11.4 26.4 L15 24.8 L11 16.2 L18.6 16.2 Z" fill="#3fa6a0" stroke="#fff" stroke-width="2" stroke-linejoin="round"/></svg><span class="nm" style="background:#3fa6a0">Liam</span></div>';
      cvs += '<div style="left:1050px;top:150px;z-index:9"><div class="av" style="width:30px;height:30px;font-size:11px;background:#d6498b;border-radius:15px 15px 15px 3px;box-shadow:0 0 0 2px #fff,0 6px 16px rgba(0,0,0,.4)">PN</div></div>';
            cvs += '<div style="left:14px;top:810px;display:flex;align-items:center;gap:6px;height:28px;padding:0 10px;border-radius:7px;background:#232327;box-shadow:0 0 0 1px rgba(255,255,255,.08);font-size:12px;font-weight:500;color:#cfcfd8">78%' + ic("chevd", 12, 2) + "</div>";
      cvs += '<div id="tip">' + ic("rot3", 14, 1.8) + 'Rotate Y <b id="tipV">0°</b></div>';
      const canvas = '<div id="cvs">' + cvs + "</div>";

      win.innerHTML = toolbar + leftPanel + canvas + rightPanel;

      const $ = (id) => document.getElementById(id);
      const uiCam = $("uiCam"), cur = $("cur"), curi = $("curi"), mark = $("mark"), scrim = $("scrim");
      const fHome = $("fHome"), tip = $("tip"), tipV = $("tipV"), vRY = $("vRY"), vPP = $("vPP"), vRX = $("vRX");
      const slFill = $("slFill"), slThumb = $("slThumb"), hRot = $("hRot");
      const shadeEl = fHome.querySelector(".shade");

      /* screen coordinates (inside #uiCam) */
      const HOME_C = [110 + 260 + 570, 54 + 48 + 438];   // centre of the Home frame
      const HALF = 195 * SC;                                // half width on screen
      const P0 = 1200, P1 = 450, RY1 = -38;
      const slX = (pp) => 110 + 1400 + 92 + ((pp - 200) / 1800) * 110;
      const SLY = 54 + 48 + 296;
      const fldRY = $("fldRY"), fldPP = $("fldPP");

      /* drag 1: Rotate Y handle 6.25-7.35, drag 2: Distance slider 7.8-8.3, lockup from 8.35 */
      function ryAt(t) { return RY1 * eExpoOut(seg(t, 6.25, 7.3)); }
      function ppAt(t) { return lerp(P0, P1, eIO2(seg(t, 7.8, 8.3))); }
      function handlePos(ry, pp) {
        const a = ry * D2R, u = HALF;
        const x = u * Math.cos(a), z = -u * Math.sin(a);
        const f = pp / (pp - z);
        return [HOME_C[0] + x * f, HOME_C[1]];
      }
      const H_START = handlePos(0, P0);
      const H_END = handlePos(RY1, P0);

      function renderUI(t) {
        const te = t - 5.05;
        const ry = ryAt(t), pp = ppAt(t);
        fHome.style.transform = "perspective(" + pp.toFixed(1) + "px) rotateY(" + ry.toFixed(3) + "deg) scale(" + SC + ")";
        const sh = clamp(Math.abs(ry) / 38);
        shadeEl.style.background = "linear-gradient(90deg, rgba(8,8,16," + (0.34 * sh).toFixed(3) + ") 0%, rgba(8,8,16,0) 55%, rgba(255,255,255," + (0.07 * sh).toFixed(3) + ") 100%)";
        const rtxt = (Math.round(ry) === 0 ? "0" : String(Math.round(ry)).replace("-", "−")) + "°";
        vRY.textContent = rtxt; tipV.textContent = rtxt; vRX.textContent = "0°";
        vPP.textContent = String(Math.round(pp));
        const fx = slX(pp) - 110 - 1400;
        slFill.style.width = (fx - 92) + "px";
        slThumb.style.left = fx - 7 + "px";

        /* camera: settles from a larger, tilted view, pushes slowly, then pulls back and dims under the lockup */
        const arr = eExpoOut(seg(te, 0, 1.15));
        const push = 0.05 * eIO2(seg(t, 6.0, 8.35));
        const dimU = eIO2(seg(t, 8.2, 8.85));
        const sc = lerp(1.14, 1.0, arr) + push - 0.08 * dimU + 0.02 * seg(t, 8.95, 10.5);
        const tilt = lerp(7, 0, arr);
        const tyaw = lerp(-5, 0, arr);
        uiCam.style.transform = "rotateX(" + tilt.toFixed(3) + "deg) rotateY(" + tyaw.toFixed(3) + "deg) scale(" + sc.toFixed(4) + ")";
        uiCam.style.opacity = (1 - 0.8 * dimU).toFixed(3);

        /* cursor: glides to the handle, drags it, glides to the slider, drags it, fades */
        const press1 = t >= 6.2 && t < 7.35, press2 = t >= 7.8 && t < 8.3;
        const hp = handlePos(ry, P0);
        let cx, cy;
        if (t < 6.2) {
          cx = kf(t, [[5.5, 1500], [6.15, H_START[0]]]);
          cy = kf(t, [[5.5, 780], [6.15, HOME_C[1]]]);
        } else if (t < 7.4) {
          cx = hp[0]; cy = HOME_C[1];
        } else if (t < 7.8) {
          const u = eIO2(seg(t, 7.4, 7.78));
          cx = lerp(H_END[0], slX(P0), u); cy = lerp(HOME_C[1], SLY, u);
        } else { cx = slX(pp); cy = SLY; }
        if (t >= 8.3) { const u = eIO2(seg(t, 8.3, 8.6)); cx += 40 * u; cy += 32 * u; }
        cur.style.opacity = Math.min(clamp((t - 5.5) / 0.3), 1 - clamp((t - 8.3) / 0.3)).toFixed(3);
        cur.style.transform = "translate(" + cx.toFixed(2) + "px," + cy.toFixed(2) + "px)";
        curi.style.transform = "scale(" + (press1 || press2 ? 0.86 : 1) + ")";
        hRot.style.transform = press1 ? "scale(1.35)" : "scale(1)";
        hRot.style.background = press1 ? "var(--acc)" : "#fff";
        fldRY.className = "fld" + (press1 ? " hi" : "");
        fldPP.className = "fld" + (press2 ? " hi" : "");

        /* tooltip chip sits above the selected frame (clear of phone content) and follows the cursor horizontally during the Rotate Y drag */
        tip.style.left = cx - 370 - 62 + "px";
        tip.style.top = 160 - 102 + "px";
        tip.style.opacity = (clamp((t - 6.25) / 0.15) * (1 - clamp((t - 7.35) / 0.2))).toFixed(3);

        /* lockup */
        mark.style.opacity = eOut3(seg(t, 8.35, 8.85)).toFixed(3);
        scrim.style.opacity = eIO2(seg(t, 8.0, 8.5)).toFixed(3);
        mark.style.transform = "translateY(" + ((1 - eExpoOut(seg(t, 8.35, 9.35))) * 36).toFixed(2) + "px) scale(" + (1 + 0.025 * seg(t, 9.0, 10.5)).toFixed(4) + ")";
      }

      /* ---------- timeline ---------- */
      function render(t) {
        if (t < 5.05) { renderRows(t); renderBands(t); }
        if (t >= 4.3 && t < 5.8) renderWipe(t);
        if (t >= 5.05) renderUI(t);
      }
      const tl = gsap.timeline({ paused: true });
      render(0);
      tl.to({ v: 0 }, { v: 1, duration: DUR, ease: "none", onUpdate: () => render(tl.time()) }, 0);

      window.__timelines = window.__timelines || {};
      window.__timelines["main"] = tl;
    </script>
  </body>
</html>
```
