Skip to content

Play a finished motion-graphics ad in sync with the rough drafts it grew from, and export the breakdown as MP4.

Build reference-driven launch editor promotion demo

wasely849533c84aff
diff --git a/.gitignore b/.gitignore
index f02301e..4c4ec0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,6 @@ coverage/
.artifacts/
.DS_Store
Thumbs.db
+.local-media/
+public/references/
+promo/
diff --git a/AGENTS.md b/AGENTS.md
index 00dcf45..bd60ba5 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -6,4 +6,6 @@ This is an independent public UI starter. Keep its history, configuration, and d
- Browser requests must use this project's origin. Never hardcode another local companion or copy personal databases, credentials, renders, or provider settings.
- Preserve the inherited interface. Verify UI changes in a real browser at narrow and wide widths.
- Generation, rendering, and Premiere are unconnected. Keep UI status honest until those services exist.
+- The launch editor is the homepage. Reference media is explicitly imported for the local promotion demo and stays in ignored `.local-media/` and `public/references/` directories. Do not publish it automatically.
+- Imported segments are non-destructive time ranges. Preserve the original source videos. The preview is browser composition, not AI generation.
- Preserve bundled third-party notices. Do not introduce a project license without the owner's decision.
diff --git a/README.md b/README.md
index af02dd9..2553b21 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
# Null
-A fresh public project using Null Motion's existing interface: a dark motion workspace, template gallery, prompt composer, reference and script pages, and render library layout.
+A launch-film concept editor built on Null Motion's visual foundation and MotionClone's reference-segment workflow. A large branded preview sits above a clip timeline and a library of reference moments.
-This first version is a **UI starter**. Template previews, navigation, local draft controls, and template selection work. AI generation, video rendering, template management, themes, and Premiere integration are not connected. Those actions return an explicit “not connected” message; no fake jobs or generated results are shown.
+This is a **promotion demo**, with working reference playback, in/out trimming, clip insertion, drag reordering, undo/redo, search, browser-local saving, and live brand controls. The film preview combines source clips with a browser-rendered brand composition. It is not an AI-reconstructed or exported video; generation and rendering are not connected.
+
+The original Null Motion gallery remains at `/index.html`.
## Run locally
@@ -14,6 +16,20 @@ npm start
Open <http://127.0.0.1:4343>. There are no runtime packages to install and no credentials to configure.
+## Bring in MotionClone references
+
+With Python, FFmpeg, and ffprobe installed:
+
+```sh
+python scripts/import-motionclone.py --source /path/to/MotionClone
+```
+
+The importer includes saved source videos and the standalone Nexa/Troovy reference folders. It creates non-destructive segments of roughly four seconds, extracts a thumbnail for each segment, and links the videos into `.local-media/`. The source and this project must be on the same filesystem for hard links. Original files are read only; no encoding or source cutting occurs. Full source videos remain playable and segment in/out points are editable.
+
+Media, reference titles, and extracted thumbnails stay local and are excluded from Git. The server supports byte ranges so seeking does not read entire videos into memory. A fresh checkout opens with an empty library until references are imported or uploaded. Browser uploads last for the current session.
+
+The current local library contains 21 references and 182 segments. These are reference clips, not claims of commissioned work. Public hosting needs separately supplied media you can distribute.
+
The optional `PORT` environment variable changes the port. `HOST` defaults to `127.0.0.1`; set it to your hosting environment's required bind address when deploying. This repository does not provision a hosted service.
## Develop
@@ -24,10 +40,11 @@ npm run check
npm test
```
-- `public/`: the inherited UI, styles, template previews, and artwork.
+- `public/editor.*` and `public/editor-model.mjs`: launch editor, interactions, and timeline operations.
+- `public/`: the inherited gallery, styles, template previews, and artwork.
- `data/template-catalog.json`: the bundled template definitions.
-- `server.js`: a standalone static server with read-only UI data routes.
-- `test/`: checks for previews, empty state data, disabled backend actions, and file isolation.
+- `server.js` and `media.js`: static UI data and streaming reference playback.
+- `test/`: timeline boundaries, clip order, video ranges, previews, and file isolation.
The browser calls this project's own origin. It does not connect to the original Null Motion companion. Build new authenticated backend routes before enabling generation or shared data storage.
@@ -35,6 +52,8 @@ The browser calls this project's own origin. It does not connect to the original
This project starts with fresh Git history. It contains no personal render history, database, provider configuration, local credentials, or Premiere extension. Drafts and UI preferences use this project's browser origin.
+Only selected source media and its reference catalog are imported locally; MotionClone job records, generated outputs, and account settings are not copied. Brand changes apply to the concept composition. Text and marks baked into source footage remain unchanged.
+
The original UI is retained to provide a starting point; inherited provider names, timing labels, and pipeline diagrams describe the future integration surface, not implemented service guarantees. External AI tools require their own accounts and may need to open in a separate tab.
## Third-party notices
diff --git a/docs/launch-editor.md b/docs/launch-editor.md
new file mode 100644
index 0000000..9cd185b
--- /dev/null
+++ b/docs/launch-editor.md
@@ -0,0 +1,24 @@
+# Launch editor
+
+The editor adapts MotionClone's reference selection, in/out ranges, ordered segments, and branding workflow into Null's dark interface. Source reference: MotionClone `web/editor.html`, `web/editor.js`, and `web/editor.css`. Account connection and generation calls were not imported.
+
+The promotion layout is arranged vertically:
+
+1. Large film preview, live identity controls, and concept/reference toggle.
+2. Clip timeline with source thumbnails, brand track, playhead, trimming, and undo/redo.
+3. Reference-video tabs and short selectable moments with hover playback and insertion controls.
+
+The first visit assembles a four-clip example from different references. Changes save in this browser. The Play concept control plays the selected source intervals in order while the brand composition updates. Present removes workspace controls for recording the concept. Escape restores the editor.
+
+The reference importer creates time ranges rather than rendering 182 separate files. This keeps original quality, storage use, and editability. Preview posters are extracted at each segment's midpoint. Byte-range streaming supports scrubbing large sources.
+
+## Verified locally
+
+- 21 reference videos and 182 segments imported.
+- Playback crosses from one source video to the next.
+- In/out validation, insert, reorder, remove, undo/redo, and saved restoration.
+- Brand name, message, palette, portrait/landscape/square modes, and presentation mode.
+- Reference dialog, search empty state, empty timeline and reinsertion, local video upload.
+- Desktop, tablet, and mobile layout; screenshots inspected.
+
+No AI generation, encoded final-video export, account system, or public media hosting is included in this pass.
diff --git a/media.js b/media.js
new file mode 100644
index 0000000..925a4d6
--- /dev/null
+++ b/media.js
@@ -0,0 +1,26 @@
+import { createReadStream } from 'node:fs';
+import { stat } from 'node:fs/promises';
+
+export function byteRange(value, size) {
+ const match = /^bytes=(\d*)-(\d*)$/.exec(value || '');
+ if (!match || (!match[1] && !match[2]) || size < 1) return null;
+ const start = match[1] ? Number(match[1]) : Math.max(0, size - Number(match[2]));
+ const end = match[1] && match[2] ? Math.min(size - 1, Number(match[2])) : size - 1;
+ return Number.isSafeInteger(start) && Number.isSafeInteger(end) && start >= 0 && start <= end && start < size ? { start, end } : null;
+}
+export async function streamVideo(request, response, filename) {
+ let size;
+ try { size = (await stat(filename)).size; } catch {
+ response.writeHead(404); response.end('Reference unavailable.'); return;
+ }
+ const range = request.headers.range ? byteRange(request.headers.range, size) : { start: 0, end: size - 1 };
+ if (!range) { response.writeHead(416, { 'Content-Range': `bytes */${size}` }); response.end(); return; }
+ const headers = { 'Content-Type': 'video/mp4', 'Accept-Ranges': 'bytes', 'Content-Length': range.end - range.start + 1, 'Cache-Control': 'private, max-age=3600' };
+ if (request.headers.range) headers['Content-Range'] = `bytes ${range.start}-${range.end}/${size}`;
+ response.writeHead(request.headers.range ? 206 : 200, headers);
+ if (request.method === 'HEAD') { response.end(); return; }
+ const stream = createReadStream(filename, range);
+ stream.on('error', () => response.destroy());
+ response.on('close', () => stream.destroy());
+ stream.pipe(response);
+}
diff --git a/package.json b/package.json
index d204bd3..0708f41 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "null",
"version": "0.1.0",
"private": true,
- "description": "A fresh public motion UI based on Null Motion.",
+ "description": "A launch-film concept editor combining reference moments with live branding.",
"type": "module",
"scripts": {
"start": "node server.js",
diff --git a/public/editor-model.mjs b/public/editor-model.mjs
new file mode 100644
index 0000000..26b1027
--- /dev/null
+++ b/public/editor-model.mjs
@@ -0,0 +1,27 @@
+export const sequenceDuration = clips => clips.reduce((sum, clip) => sum + clip.out - clip.in, 0);
+export function splitReference(reference, size = 4) {
+ const duration = Number(reference.duration);
+ if (!Number.isFinite(duration) || duration < 0.25 || !(size > 0)) return [];
+ const count = Math.max(1, Math.floor(duration / size));
+ return Array.from({ length: count }, (_, index) => ({
+ ref: reference.id, in: +(index * duration / count).toFixed(3),
+ out: index === count - 1 ? duration : +((index + 1) * duration / count).toFixed(3),
+ label: ['Opening', 'Build', 'Detail', 'Transition', 'Reveal', 'Close'][Math.min(index, 5)],
+ part: index + 1
+ }));
+}
+export function locateClip(clips, time) {
+ if (!clips.length) return null;
+ let remaining = Math.max(0, Math.min(Number(time) || 0, sequenceDuration(clips)));
+ for (let index = 0; index < clips.length; index++) {
+ const length = clips[index].out - clips[index].in;
+ if (remaining < length || index === clips.length - 1) return { index, local: clips[index].in + Math.min(remaining, length) };
+ remaining -= length;
+ }
+}
+export function moveClip(clips, from, to) {
+ const result = [...clips];
+ if (from < 0 || to < 0 || from >= clips.length || to >= clips.length) return result;
+ result.splice(to, 0, result.splice(from, 1)[0]);
+ return result;
+}
diff --git a/public/editor.css b/public/editor.css
new file mode 100644
index 0000000..0b538e0
--- /dev/null
+++ b/public/editor.css
@@ -0,0 +1,16 @@
+:root{color-scheme:dark;--bg:#101112;--panel:#151618;--surface:#1c1e20;--line:#2a2c2e;--text:#eeefec;--muted:#989b9e;--lime:#dbed91;--accent:#daef79;--paper:#eeefdf;font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;font-synthesis:none}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font-size:12px;-webkit-font-smoothing:antialiased}button,input,select,textarea{font:inherit}button,a,input,textarea,select{-webkit-tap-highlight-color:transparent}button{cursor:pointer}button:disabled{opacity:.35;cursor:default}button,a{color:inherit}a{text-decoration:none}button{border:0}svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}svg use[href="#i-play"]{fill:currentColor;stroke:none}.svg-library{position:absolute;width:0;height:0;overflow:hidden}button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid var(--lime);outline-offset:4px}.skip-link{position:fixed;top:-70px;z-index:100;background:var(--lime);color:#111;padding:12px}.skip-link:focus{top:5px}.topbar{height:65px;padding:0 24px;display:flex;align-items:center;gap:19px;border-bottom:1px solid var(--line);background:#131416}.logo{display:flex;gap:9px;align-items:center;font-size:24px;font-weight:650;letter-spacing:-1.2px}.logo-mark{display:grid;place-items:center;width:28px;height:28px;background:#ededdf;border-radius:7px;color:#17181b;font-size:18px;font-weight:850;letter-spacing:-2px}.logo-dot{color:var(--lime);margin-left:-8px}.top-divider{height:23px;width:1px;background:#37393a}.project-link,.crumb{color:#95989c;font-size:11px}.project-name{font-size:11px;font-weight:550}.project-caret{padding-left:14px;color:#a5a5a5}.save-state{font-size:10px;color:#969b95;display:flex;align-items:center;gap:6px}.save-state>span{width:5px;height:5px;background:#8baa82;border-radius:50%}.top-actions{margin-left:auto;display:flex;align-items:center;gap:12px}.demo-label{font:9px monospace;letter-spacing:1.1px;color:#888c90;margin-right:6px}.button{display:inline-flex;justify-content:center;align-items:center;gap:7px;padding:9px 13px;min-height:34px;border:1px solid var(--line);border-radius:7px;font-size:11px;font-weight:550;background:#222426;white-space:nowrap;transition:background .16s,transform .16s}.button:hover{background:#2e3133}.button.primary{color:#151810;background:var(--lime);border-color:var(--lime)}.button.primary:hover{background:#e9f6b2}.button.subtle{background:transparent}.button.subtle:hover{background:#252729}.button.small{min-height:27px;padding:4px 10px;font-size:10px}.button svg{width:14px;height:14px}.avatar{width:29px;height:29px;display:grid;place-items:center;font-size:10px;background:#363a33;border:1px solid #555c4b;border-radius:50%;color:#d9e5c2}.workspace{display:flex}.rail{width:73px;flex-shrink:0;border-right:1px solid var(--line);display:flex;flex-direction:column;align-items:center;padding-top:18px;gap:12px;position:sticky;top:0;height:calc(100vh - 65px)}.rail-item{width:55px;height:58px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7px;border-radius:8px;background:none;color:#8d9195;font-size:9px}.rail-item svg{width:19px;height:19px}.rail-item.active{background:#252922;color:#e1efb1}.rail-item:hover{background:#252729;color:#fff}.rail-bottom{margin-top:auto;margin-bottom:20px;font:8px monospace;color:#65686b;letter-spacing:1.4px}main{min-width:0;width:100%;max-width:1850px;margin:auto}.studio-heading{height:56px;padding:0 26px;display:flex;align-items:center;justify-content:space-between;gap:16px}.studio-title{display:flex;align-items:center;gap:9px;min-width:0}.studio-title h1{font-size:12px;font-weight:550;margin:0}.live-dot{width:6px;height:6px;border-radius:50%;background:var(--lime)}.subtle-label{font-size:10px;color:#74797e;margin-left:10px}.view-toggle{display:flex;align-items:center;background:#191b1d;border:1px solid var(--line);border-radius:6px;padding:3px}.view-toggle button{background:none;color:#9ca1a4;font-size:10px;padding:5px 13px;border-radius:4px}.view-toggle .active{background:#343739;color:#f3f4ee;box-shadow:0 1px 3px #0004}.upper-workspace{display:grid;grid-template-columns:minmax(0,1fr) 240px;padding:0 26px 0;gap:25px}.preview-area{min-width:0}.canvas-top{display:flex;align-items:center;justify-content:space-between;color:#858a8c;font:9px monospace;letter-spacing:1px;padding:3px 1px 13px}.canvas-sep{margin:0 9px;color:#55595a}.tiny-dot{display:inline-block;width:5px;height:5px;border-radius:50%;background:#b9c991;margin-right:4px}.canvas-wrap{display:flex;align-items:center;justify-content:center;background:#0b0c0d;border:1px solid #2e3131;border-radius:9px;position:relative;overflow:hidden;height:clamp(330px,30vw,485px);box-shadow:0 16px 45px #0002}.film-stage{container-type:inline-size;aspect-ratio:16/9;max-height:100%;width:100%;overflow:hidden;position:relative;background:var(--paper);color:#23261d;isolation:isolate}.stage-grain{position:absolute;inset:0;opacity:.045;z-index:5;pointer-events:none;background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.9' filter='url(%23noise)'/%3E%3C/svg%3E")}.stage-orbit{position:absolute;border:1px solid #343c2520;border-radius:50%;width:70%;aspect-ratio:1;right:-16%;top:-27%;z-index:-1}.orbit-two{width:88%;right:-25%;top:-44%}.film-brand{position:absolute;top:7%;left:6%;display:flex;gap:8px;align-items:center;font-size:2.1cqw;font-weight:700;letter-spacing:-.08em}.film-monogram{font-size:1.6cqw;display:grid;place-items:center;width:2.6cqw;height:2.6cqw;border-radius:.55cqw;background:#20281e;color:var(--paper);letter-spacing:-.15em;padding-right:.2em}.film-brand-plus{font-size:1cqw;align-self:start;letter-spacing:0}.film-copy{position:absolute;left:6%;top:27%;width:47%;z-index:2}.film-kicker{font-size:.82cqw;letter-spacing:.16em;font-weight:600;display:block;margin-bottom:2cqw;color:#596147}.film-copy h2{font-size:6.25cqw;line-height:.95;letter-spacing:-.075em;font-weight:650;margin:0 0 2cqw;overflow-wrap:anywhere;max-width:100%}.film-copy em{font-weight:500;font-family:Georgia,serif;letter-spacing:-.08em}.film-copy p{font-size:1.05cqw;color:#596147;margin:0 0 2.4cqw}.film-cta{display:inline-flex;gap:2.5cqw;font-size:.95cqw;font-weight:600;align-items:center;background:#262c21;color:var(--paper);padding:1cqw 1.3cqw;border-radius:4cqw}.film-cta>span{color:var(--accent)}.motion-window{position:absolute;width:49%;height:56%;right:-1.5%;top:26%;background:#111416;border-radius:1.1cqw;border:.6cqw solid #222724;box-shadow:-1.4cqw 2cqw 5cqw #3c482a35;transform:perspective(1000px) rotateY(-9deg) rotateZ(-4deg);overflow:hidden;transition:transform .7s cubic-bezier(.2,.65,.3,1),background .3s}.window-chrome{height:13%;display:flex;align-items:center;justify-content:space-between;padding:0 1cqw;background:#222724;color:#9fa99c;font-size:.68cqw}.window-dots{font-size:.55cqw;letter-spacing:.3cqw;color:#7c8771}.motion-window video{width:100%;height:87%;display:block;object-fit:cover;background:#151817}.video-loading{position:absolute;inset:13% 0 0;display:grid;place-items:center;color:#aaa;font-size:11px;background:#1b1d1a}.video-loading[hidden]{display:none}.film-footer{position:absolute;bottom:7%;left:6%;right:6%;display:flex;justify-content:space-between;font-size:.64cqw;letter-spacing:.14em;color:#6c745d}.film-timecode{position:absolute;transform:rotate(-90deg);transform-origin:0 0;right:-9%;top:72%;font-size:.6cqw;letter-spacing:.15em;color:#6c745d}.film-stage[data-scene="1"] .motion-window{transform:perspective(1000px) rotateY(5deg) rotateZ(3deg)}.film-stage[data-scene="2"] .motion-window{transform:perspective(1000px) rotateY(-4deg) rotateZ(-1deg);box-shadow:0 2cqw 5cqw #3c482a40}.film-stage[data-scene="3"] .motion-window{transform:perspective(1000px) rotateY(0) rotateZ(1deg)}.canvas-badge{position:absolute;right:12px;bottom:12px;display:flex;gap:5px;align-items:center;font-size:8px;color:#d8dfcf;background:#171b17db;border:1px solid #faffeb16;padding:5px 7px;border-radius:5px;z-index:6}.canvas-badge span{width:4px;height:4px;border-radius:50%;background:#bddf7a}.reference-mode .film-stage{background:#090a0b}.reference-mode .film-brand,.reference-mode .film-copy,.reference-mode .film-footer,.reference-mode .film-timecode,.reference-mode .stage-orbit,.reference-mode .stage-grain{display:none}.reference-mode .motion-window{inset:0;width:100%;height:100%;transform:none;border:0;border-radius:0;box-shadow:none}.reference-mode .window-chrome{display:none}.reference-mode .motion-window video{height:100%;object-fit:contain}.reference-mode .canvas-badge{display:none}.portrait .film-stage{aspect-ratio:9/16;width:auto;height:100%}.square .film-stage{aspect-ratio:1;width:auto;height:100%}.portrait .film-copy{top:25%;width:88%}.portrait .film-copy h2{font-size:10cqw}.portrait .motion-window{top:58%;width:80%;height:26%;right:10%}.portrait .film-brand{font-size:5cqw}.portrait .film-monogram{font-size:4cqw;width:6cqw;height:6cqw}.portrait .film-kicker{font-size:2cqw}.portrait .film-copy p,.portrait .film-cta{font-size:2.5cqw}.portrait .film-footer{font-size:1.2cqw}.square .film-copy{top:24%;width:55%}.square .film-copy h2{font-size:7cqw}.square .motion-window{height:45%;top:39%}.transport{height:48px;display:flex;align-items:center;justify-content:space-between;gap:8px}.transport-start,.transport-end{display:flex;align-items:center;gap:11px}.icon-button{width:29px;height:29px;display:inline-flex;justify-content:center;align-items:center;background:none;color:#9b9fa2;font-size:19px;border-radius:5px;position:relative}.icon-button:hover{background:#2b2e2f;color:#fff}.icon-button svg{width:15px;height:15px}.transport-play{width:30px;height:28px;display:grid;place-items:center;background:#2d3031;border-radius:5px;color:#eeefe9}.transport-play svg{width:14px;height:14px}.time-readout{display:flex;gap:8px;font:10px monospace;color:#818689}.time-readout strong{font-weight:400;color:#dcdfd8}.preview-description{font-size:9px;color:#7f8587}.mute-slash{position:absolute;width:19px;height:1px;background:#a0a4a0;transform:rotate(-45deg)}.brand-panel{padding:1px 0 0 23px;border-left:1px solid var(--line);min-width:0}.panel-title{display:flex;justify-content:space-between;align-items:center}.panel-title h2{font-size:12px;font-weight:600;margin:0}.panel-title svg{width:15px;height:15px;color:#aebc8e}.panel-description{font-size:11px;line-height:1.55;color:#92979a;margin:13px 0 18px}.field-label{display:block;font-size:10px;font-weight:500;color:#aaafb1;margin:14px 0 7px}.brand-panel input:not([type=color]),.brand-panel textarea,.brand-panel select{width:100%;border:1px solid #333638;background:#1d1f21;color:#e4e5e0;border-radius:6px;padding:9px 10px;font-size:11px;min-width:0}.brand-panel textarea{resize:vertical;line-height:1.5;min-height:52px}.brand-panel select{height:34px}.palette{display:flex;gap:9px;align-items:center;margin-top:10px}.swatch{background:var(--swatch);width:24px;height:24px;border-radius:50%;border:3px solid #151618;outline:1px solid transparent}.swatch.active{outline:1px solid #cbd2be}.custom-color{position:relative;width:23px;height:23px;border:1px dashed #6a7169;border-radius:50%;color:#abb2a5;display:grid;place-items:center;font-size:14px;overflow:hidden;cursor:pointer}.custom-color input{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}.brand-divider{height:1px;background:var(--line);margin:18px 0 12px}.direction-label{display:flex;align-items:center;justify-content:space-between;color:#868f7c}.direction-label .field-label{margin:0}.direction-copy{font-size:10px;color:#8d9395;line-height:1.65;margin:9px 0 13px}.concept-note{font-size:8px;color:#969d8f;line-height:1.6}.concept-note .tiny-dot{width:4px;height:4px}.timeline-panel{border-top:1px solid var(--line);border-bottom:1px solid var(--line);background:#151719}.timeline-toolbar{height:48px;display:flex;justify-content:space-between;align-items:center;padding:0 25px;gap:12px}.timeline-heading,.timeline-tools{display:flex;align-items:center;gap:10px}.timeline-heading svg{width:14px;height:14px;color:#a0a697}.timeline-heading h2{font-size:11px;font-weight:550;margin:0}.clip-count{font:9px monospace;color:#8f9596;border:1px solid #363b3c;border-radius:4px;padding:2px 5px}.timeline-hint{font-size:9px;color:#727a7e;margin-right:8px}.timeline-tools{gap:6px}.tool-divider{height:16px;width:1px;background:var(--line);margin:0 8px}.timeline-scroll{overflow-x:auto;padding:0 25px;scrollbar-width:thin;scrollbar-color:#464c44 transparent}.timeline-body{position:relative;min-width:650px;padding-top:23px}.ruler{position:absolute;top:0;left:77px;right:2px;display:flex;justify-content:space-between;color:#697378;font:8px monospace;height:21px;border-bottom:1px solid #33393b;background:repeating-linear-gradient(90deg,#0000 0,#0000 calc(2.5% - 1px),#384042 calc(2.5% - 1px),#384042 2.5%);background-size:100% 4px;background-repeat:no-repeat;background-position:bottom}.ruler span{padding:0 0 9px;background:#151719}.timeline-lane{display:flex;gap:14px;align-items:center}.lane-label{display:flex;align-items:center;gap:7px;width:63px;flex-shrink:0;font-size:9px;color:#848d8f;letter-spacing:.1px}.lane-label svg{width:14px;height:14px}.clips-track{display:flex;gap:4px;height:63px;flex:1;min-width:0;position:relative}.timeline-clip{min-width:42px;flex-shrink:1;position:relative;overflow:hidden;border:1px solid #798e64;border-radius:5px;padding:0;display:flex;align-items:end;background:#253022;cursor:grab;color:#ebf0e5;text-align:left}.timeline-clip:nth-child(2n){border-color:#636e86}.timeline-clip:nth-child(3n){border-color:#917866}.timeline-clip img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:.75;pointer-events:none}.timeline-clip::after{content:"";position:absolute;inset:0;background:linear-gradient(0deg,#121710e8,#12171005 90%)}.timeline-clip.selected{border:2px solid var(--lime);box-shadow:0 0 0 1px #121712}.timeline-clip.dragging{opacity:.4}.timeline-clip>span{z-index:1;font-size:9px;padding:6px 8px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;width:100%}.timeline-clip small{display:block;font:8px monospace;color:#c3cdbd;margin-bottom:4px}.empty-track{flex:1;border:1px dashed #59614f;border-radius:5px;color:#a3ac95;display:grid;place-items:center;font-size:11px}.brand-lane{display:flex;gap:14px;margin:7px 0 13px;height:23px}.brand-track{background:#252c20;border:1px solid #414c34;border-radius:4px;display:flex;align-items:center;gap:18px;flex:1;padding:0 9px;color:#a7b38e;font-size:8px}.brand-track-name{font-weight:600;color:#dce8c4}.brand-track-line{flex:1;height:1px;background:linear-gradient(90deg,#667547,#66754744)}.playhead{position:absolute;top:16px;bottom:1px;left:77px;width:1px;background:#ddedaa;z-index:3;pointer-events:none;box-shadow:0 0 3px #bddd6370}.playhead>span{position:absolute;width:8px;height:11px;top:-11px;left:-3.5px;background:#ddedaa;clip-path:polygon(0 0,100% 0,100% 65%,50% 100%,0 65%)}.timeline-scrubber{position:absolute;top:0;left:77px;width:calc(100% - 77px);height:23px;opacity:0;margin:0;cursor:ew-resize}.timeline-scrubber:focus-visible{opacity:.6}.clip-inspector{min-height:32px;padding:4px 26px;border-top:1px solid #252b2d;display:flex;justify-content:space-between;align-items:center;gap:10px;font-size:9px;color:#9ca4a2}.clip-inspector>div{display:flex;align-items:center;gap:13px}.clip-inspector label{display:flex;align-items:center;gap:6px;color:#707b80;font:9px monospace}.clip-inspector input{width:52px;background:#1e2325;border:1px solid #363e40;border-radius:3px;padding:3px 4px;color:#d5ddd6;font:9px monospace}.text-button{background:none;color:#9aa59a;padding:4px;font-size:10px;border-radius:3px;min-width:24px;min-height:24px}.text-button:hover{background:#343b31;color:#e8eddf}.remove-clip{color:#be9c8a}.library-panel{padding:25px 26px 20px}.library-heading{display:flex;justify-content:space-between;align-items:center;gap:20px;margin-bottom:20px}.library-title-row{display:flex;gap:12px;align-items:center}.library-heading h2{font-size:18px;letter-spacing:-.6px;font-weight:500;margin:0}.library-heading p{font-size:10px;color:#878e91;margin:8px 0 0}.library-count{color:#9da68c;background:#252b20;border:1px solid #373f2e;border-radius:4px;padding:3px 6px;font:8px monospace}.library-actions{display:flex;align-items:center;gap:10px}.search-box{height:32px;border:1px solid var(--line);background:#181a1c;display:flex;gap:7px;align-items:center;padding:0 10px;border-radius:6px;color:#7c8589}.search-box svg{width:13px;height:13px}.search-box input{background:none;border:0;outline:0;color:#ddd;font-size:10px;width:130px}.search-box:focus-within{border-color:#748258}.search-box input::placeholder{color:#788084}.upload-button{cursor:pointer;font-size:10px}.reference-tabs{display:flex;gap:8px;overflow:auto;scrollbar-width:thin;scrollbar-color:#414938 transparent;padding:2px 2px 10px;margin-bottom:12px}.reference-tab{background:#1b1e20;border:1px solid #303638;color:#a4adae;display:flex;align-items:center;gap:8px;padding:5px 10px 5px 5px;border-radius:6px;font-size:9px;white-space:nowrap;min-height:36px;max-width:230px;flex-shrink:0;text-align:left}.reference-tab img{width:36px;height:23px;object-fit:cover;border-radius:3px;filter:saturate(.7)}.reference-tab span{overflow:hidden;text-overflow:ellipsis}.reference-tab.active{color:#e1eccc;background:#292f23;border-color:#718252}.reference-tab:hover{border-color:#758263}.source-heading{display:flex;justify-content:space-between;align-items:center;gap:15px;font-size:10px;color:#adb4ae;margin:0 0 12px}.source-heading>span:last-child{font:9px monospace;color:#778184}.segment-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:13px}.segment-card{min-width:0;position:relative}.segment-visual{position:relative;aspect-ratio:16/10;border-radius:7px;overflow:hidden;background:#24292a;border:1px solid #353d3e}.segment-visual>img,.segment-visual>video{width:100%;height:100%;object-fit:cover;display:block}.segment-visual>video{position:absolute;inset:0;z-index:1;pointer-events:none}.segment-preview{position:absolute;inset:0;z-index:2;background:none;width:100%;height:100%;border:0;color:#fff;display:grid;place-items:center}.segment-preview svg{width:27px;height:27px;background:#151b18b5;border:1px solid #fff4;border-radius:50%;padding:6px;opacity:0;transition:opacity .2s}.segment-preview:hover svg,.segment-preview:focus-visible svg{opacity:1}.segment-number{position:absolute;z-index:3;top:7px;left:7px;font:8px monospace;color:#eee;background:#141918b8;border:1px solid #fff2;border-radius:3px;padding:3px 5px;pointer-events:none}.segment-length{position:absolute;z-index:3;bottom:7px;left:7px;font:8px monospace;color:#eee;background:#121915bb;border-radius:3px;padding:3px 5px;pointer-events:none}.segment-add{position:absolute;z-index:4;bottom:6px;right:6px;width:27px;height:27px;background:#e0eacb;color:#28301f;border:1px solid #f3f6d5aa;border-radius:5px;display:grid;place-items:center}.segment-add:hover{background:#efffcf}.segment-add svg{width:14px;height:14px}.segment-meta{display:flex;justify-content:space-between;align-items:center;margin-top:8px;gap:6px;font-size:10px;color:#d2d7cf}.segment-meta>span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.segment-meta small{font:8px monospace;white-space:nowrap;color:#8c9695}.segment-subtitle{font-size:8px;color:#768287;margin-top:5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.library-loading,.library-empty{grid-column:1/-1;padding:35px;text-align:center;background:#191d1d;border:1px dashed #414b3d;border-radius:8px;color:#a1ab96}.studio-footer{margin:10px 26px 0;border-top:1px solid #282f2f;min-height:54px;display:flex;align-items:center;justify-content:space-between;gap:20px;color:#697574;font-size:9px}.studio-footer>span{display:flex;align-items:center;gap:9px}.studio-footer>span:last-child{font:8px monospace;letter-spacing:.8px}.footer-mark{font-weight:800;color:#9ea99a;font-size:14px}.footer-dot{color:#869575}.toast{position:fixed;bottom:24px;left:50%;transform:translate(-50%,15px);background:#e8efd7;color:#25331e;box-shadow:0 10px 40px #0005;border:1px solid #f4f8e9;border-radius:8px;padding:11px 18px;font-size:12px;z-index:60;opacity:0;pointer-events:none;transition:opacity .18s,transform .18s;max-width:calc(100% - 32px);text-align:center}.toast.show{opacity:1;transform:translate(-50%,0)}dialog{width:min(840px,calc(100% - 30px));padding:22px;border:1px solid #414b41;border-radius:12px;background:#191d1b;color:#e1e7db;box-shadow:0 25px 100px #0009}dialog::backdrop{background:#070b0bc9;backdrop-filter:blur(7px)}.dialog-top,.dialog-bottom{display:flex;align-items:center;justify-content:space-between;gap:15px}.dialog-top{margin-bottom:17px}.dialog-top h2{font-size:17px;font-weight:500;margin:7px 0 0}.eyebrow{font:8px monospace;letter-spacing:1.6px;color:#a0b087}dialog video{width:100%;max-height:60vh;display:block;border-radius:6px;background:#080b0a}.dialog-bottom{margin-top:16px;color:#a9b2a2;font:11px monospace}.present-mode .topbar,.present-mode .rail,.present-mode .studio-heading,.present-mode .brand-panel,.present-mode .timeline-panel,.present-mode .library-panel,.present-mode .studio-footer,.present-mode .canvas-top{display:none}.present-mode .upper-workspace{display:block;padding:20px}.present-mode .canvas-wrap{height:calc(100vh - 95px)}.present-mode .preview-description::after{content:" · Esc to exit"}.canvas-wrap:fullscreen{height:100vh;width:100vw;border:0;border-radius:0}.canvas-wrap:fullscreen .film-stage{height:auto;width:100%;max-height:100vh}
+.canvas-wrap{height:clamp(300px,23vw,390px)}
+.film-stage{height:100%;width:auto;max-width:100%;max-height:100%;flex-shrink:1}
+.brand-panel .field-label{margin-top:10px;margin-bottom:6px}
+.panel-description{margin:10px 0 12px}
+.brand-divider{margin:13px 0}
+.direction-label,.direction-copy{display:none}
+.library-panel{padding-top:20px}
+.library-heading{margin-bottom:14px}
+.reference-tabs{margin-bottom:7px}
+.subtle-label,.timeline-hint,.preview-description,.ruler,.studio-footer,.rail-bottom{color:#939d9e}
+@media(min-width:1650px){.upper-workspace{grid-template-columns:minmax(0,1fr) 275px}.brand-panel{padding-left:27px}.brand-panel .field-label{margin-top:15px}.brand-panel input:not([type=color]),.brand-panel textarea{font-size:12px;padding:11px}.segment-grid{grid-template-columns:repeat(7,minmax(0,1fr))}}
+@media(max-width:1150px){.topbar{gap:12px;padding:0 18px}.save-state,.demo-label,.subtle-label{display:none}.upper-workspace{grid-template-columns:minmax(0,1fr) 205px;gap:18px;padding:0 20px}.brand-panel{padding-left:18px}.canvas-wrap{height:330px}.panel-description{margin-bottom:12px}.brand-panel .field-label{margin-top:11px}.brand-divider{margin:14px 0 9px}.direction-copy{margin:7px 0}.preview-description{display:none}.segment-grid{grid-template-columns:repeat(4,minmax(0,1fr))}.rail{width:62px}.rail-item{width:49px}.studio-heading{padding:0 20px}.library-panel{padding:22px 20px}.library-heading{align-items:start}.library-heading p{max-width:370px;line-height:1.5}.library-actions{flex-wrap:wrap;justify-content:end}.timeline-hint{display:none}.studio-footer{margin:10px 20px 0}}
+@media(max-width:800px){.upper-workspace{grid-template-columns:1fr}.brand-panel{border-left:0;border-top:1px solid var(--line);padding:15px 0 18px;display:grid;grid-template-columns:110px minmax(0,1fr) 110px;gap:8px 14px;align-items:center}.brand-panel .panel-title{grid-column:1/-1}.panel-description,.brand-divider,.direction-label,.direction-copy,.concept-note{display:none}.brand-panel>.field-label{margin:0}.brand-panel>input,.brand-panel>textarea{grid-column:2/-1}.brand-panel .palette{margin:0;grid-column:2/-1}.brand-panel select{grid-column:2/-1}.canvas-wrap{height:clamp(235px,50vw,400px)}.library-heading{flex-direction:column;gap:14px}.library-actions{width:100%;justify-content:space-between}.search-box{flex:1;max-width:300px}.search-box input{width:100%}.segment-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.studio-footer>span:last-child{display:none}.brand-panel textarea{min-height:45px}.project-link,.crumb{display:none}}
+@media(max-width:550px){.topbar{height:57px;padding:0 14px;gap:10px}.logo{font-size:22px}.logo-mark{width:25px;height:25px;font-size:16px}.top-divider,.project-name,.top-actions .subtle,.avatar{display:none}.top-actions{gap:5px}.button{font-size:10px;padding:8px 10px}.rail{display:none}.studio-heading{height:57px;padding:0 14px;gap:8px}.studio-title h1{font-size:11px}.view-toggle button{padding:5px 9px;font-size:9px}.upper-workspace{padding:0 14px;gap:4px}.canvas-top{font-size:8px;letter-spacing:.5px}.canvas-wrap{height:230px}.film-stage{min-height:0}.canvas-badge{font-size:7px;bottom:7px;right:7px}.brand-panel{grid-template-columns:82px 1fr;gap:9px 12px}.brand-panel .panel-title{margin:4px 0}.brand-panel input:not([type=color]),.brand-panel textarea{font-size:12px}.transport{height:47px}.transport-start{gap:7px}.time-readout{font-size:9px;gap:5px}.timeline-toolbar{padding:0 14px}.timeline-tools{gap:1px}.timeline-tools .tool-divider{margin:0 4px}.timeline-scroll{padding:0 14px}.clip-inspector{padding:8px 14px;flex-wrap:wrap;gap:7px}.clip-inspector>span{max-width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.clip-inspector>div{width:100%;justify-content:space-between;gap:6px}.library-panel{padding:24px 14px 12px}.library-title-row{gap:8px;flex-wrap:wrap}.library-heading h2{font-size:20px}.library-heading p{font-size:11px;line-height:1.6;margin-top:9px}.library-actions{gap:8px}.search-box{min-width:0;flex:1}.search-box input{min-width:0}.reference-tabs{margin-bottom:8px}.reference-tab{font-size:10px}.source-heading{font-size:10px;align-items:start}.source-heading>span:last-child{font-size:8px;max-width:130px;text-align:right;line-height:1.5}.segment-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:17px 11px}.segment-add{width:32px;height:32px}.segment-preview svg{opacity:.8}.segment-meta{font-size:10px}.segment-subtitle{font-size:9px}.studio-footer{margin:12px 14px 0;font-size:9px}.toast{font-size:11px}.canvas-wrap:fullscreen .film-stage{height:auto;width:100%}}
+@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}
diff --git a/public/editor.html b/public/editor.html
new file mode 100644
index 0000000..ec9d676
--- /dev/null
+++ b/public/editor.html
@@ -0,0 +1,71 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="theme-color" content="#101112"><title>Null — Launch Studio</title>
+ <link rel="icon" href="assets/null-logo.png"><link rel="stylesheet" href="editor.css">
+ <script type="module" src="editor.mjs"></script>
+</head>
+<body>
+<svg class="svg-library" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><defs>
+ <symbol id="i-play" viewBox="0 0 24 24"><path d="m9 5 11 7-11 7z"/></symbol>
+ <symbol id="i-plus" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></symbol>
+ <symbol id="i-grid" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></symbol>
+ <symbol id="i-spark" viewBox="0 0 24 24"><path d="m12 3 2.8 6.2L21 12l-6.2 2.8L12 21l-2.8-6.2L3 12l6.2-2.8z"/></symbol>
+ <symbol id="i-volume" viewBox="0 0 24 24"><path d="M11 4 6 8H3v8h3l5 4zM16 8a6 6 0 0 1 0 8M19 5a10 10 0 0 1 0 14"/></symbol>
+ <symbol id="i-search" viewBox="0 0 24 24"><circle cx="10.5" cy="10.5" r="6.5"/><path d="m16 16 5 5"/></symbol>
+ <symbol id="i-film" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M7 4v16M17 4v16M3 9h4M3 15h4M17 9h4M17 15h4"/></symbol>
+ <symbol id="i-back" viewBox="0 0 24 24"><path d="m14 6-6 6 6 6"/></symbol>
+ <symbol id="i-full" viewBox="0 0 24 24"><path d="M9 3H3v6M15 3h6v6M3 15v6h6M21 15v6h-6"/></symbol>
+ <symbol id="i-upload" viewBox="0 0 24 24"><path d="M12 16V3m-5 5 5-5 5 5M4 15v6h16v-6"/></symbol>
+</defs></svg>
+<a class="skip-link" href="#main">Skip to editor</a>
+<header class="topbar">
+ <a class="logo" href="/" aria-label="Null home"><span class="logo-mark">N</span>null<span class="logo-dot">.</span></a>
+ <span class="top-divider"></span><a class="project-link" href="index.html">Workspace</a><span class="crumb">/</span>
+ <span class="project-name">Your next big thing <span class="project-caret">⌄</span></span>
+ <span class="save-state" id="save-state"><span></span> Saved locally</span>
+ <div class="top-actions"><span class="demo-label">PROMOTION DEMO</span><button class="button subtle" id="present"><svg><use href="#i-full"/></svg>Present</button><button class="button primary" id="play-top"><svg><use href="#i-play"/></svg>Play concept</button><span class="avatar" aria-label="Your workspace">N</span></div>
+</header>
+<div class="workspace">
+<nav class="rail" aria-label="Tools"><button class="rail-item active" id="rail-references" aria-label="Reference library" title="Reference library"><svg><use href="#i-film"/></svg><span>Library</span></button><button class="rail-item" id="rail-brand" aria-label="Brand settings" title="Brand settings"><svg><use href="#i-spark"/></svg><span>Brand</span></button><a class="rail-item" href="index.html" title="Motion templates"><svg><use href="#i-grid"/></svg><span>Templates</span></a><span class="rail-bottom">N / 01</span></nav>
+<main id="main">
+<div class="studio-heading"><div class="studio-title"><span class="live-dot"></span><h1>Launch studio</h1><span class="subtle-label">A little inspiration. Entirely your direction.</span></div><div class="view-toggle" aria-label="Preview mode"><button id="mode-concept" class="active" aria-pressed="true">Your film</button><button id="mode-reference" aria-pressed="false">Reference</button></div></div>
+<section class="upper-workspace" aria-label="Film preview and brand settings">
+ <div class="preview-area">
+ <div class="canvas-top"><span id="canvas-label">CONCEPT PREVIEW</span><span><i class="tiny-dot"></i> <span id="format-label">1920 × 1080</span> <span class="canvas-sep">/</span> 30 FPS</span></div>
+ <div class="canvas-wrap" id="canvas-wrap">
+ <div class="film-stage" id="film-stage" data-scene="0">
+ <div class="stage-grain"></div><div class="stage-orbit orbit-one"></div><div class="stage-orbit orbit-two"></div>
+ <div class="film-brand"><span class="film-monogram">N</span><span id="film-brand-name">null</span><span class="film-brand-plus">®</span></div>
+ <div class="film-copy"><span class="film-kicker" id="film-kicker">MAKE SOMETHING THAT MOVES.</span><h2 id="film-headline">Good ideas.<br><em>Great motion.</em></h2><p id="film-subline">Your vision. Every frame.</p><span class="film-cta" id="film-cta">Meet your next big thing <span>↗</span></span></div>
+ <div class="motion-window" id="motion-window"><div class="window-chrome"><span class="window-dots">● ● ●</span><span id="window-label">a new perspective</span><span>↗</span></div><video id="preview-video" muted playsinline preload="metadata"></video><div class="video-loading" id="video-loading">Loading your reference…</div></div>
+ <div class="film-footer"><span>BUILT FROM INSPIRATION. MADE YOURS.</span><span id="film-progress">01 / 04</span></div><div class="film-timecode" aria-hidden="true">NULL® — A NEW POINT OF VIEW</div>
+ </div>
+ <div class="canvas-badge" id="canvas-badge"><span></span>Live brand preview</div>
+ </div>
+ <div class="transport"><div class="transport-start"><button class="icon-button" id="restart" aria-label="Restart sequence">↤</button><button class="transport-play" id="play" aria-label="Play sequence"><svg><use href="#i-play"/></svg></button><span class="time-readout"><strong id="time-current">00:00.00</strong><span>/</span><span id="time-total">00:00.00</span></span></div><span class="preview-description" id="preview-description">A concept assembled from your selected moments</span><div class="transport-end"><button class="icon-button" id="mute" aria-label="Unmute reference audio" aria-pressed="true"><svg><use href="#i-volume"/></svg><span class="mute-slash"></span></button><button class="icon-button" id="fullscreen" aria-label="Fullscreen preview"><svg><use href="#i-full"/></svg></button></div></div>
+ </div>
+ <aside class="brand-panel" id="brand-panel" aria-label="Brand settings"><div class="panel-title"><h2>Make it yours</h2><svg><use href="#i-spark"/></svg></div><p class="panel-description">Same inspiration.<br>A whole new identity.</p>
+ <label class="field-label" for="brand-name">Brand name</label><input id="brand-name" value="null" maxlength="30" autocomplete="off">
+ <label class="field-label" for="brand-message">Your message</label><textarea id="brand-message" rows="2" maxlength="80">Good ideas. Great motion.</textarea>
+ <span class="field-label">Brand palette</span><div class="palette"><button class="swatch active" data-accent="#daef79" data-paper="#eeefdf" style="--swatch:#daef79" aria-label="Citron palette" aria-pressed="true"></button><button class="swatch" data-accent="#b9b0fb" data-paper="#ece8f8" style="--swatch:#b9b0fb" aria-label="Lavender palette" aria-pressed="false"></button><button class="swatch" data-accent="#f4a98d" data-paper="#f7e9df" style="--swatch:#f4a98d" aria-label="Apricot palette" aria-pressed="false"></button><button class="swatch" data-accent="#9ed1e7" data-paper="#e4eef2" style="--swatch:#9ed1e7" aria-label="Glacier palette" aria-pressed="false"></button><label class="custom-color" title="Custom brand color"><input type="color" id="custom-color" value="#daef79" aria-label="Custom brand color"><span>+</span></label></div>
+ <label class="field-label" for="aspect">Canvas</label><select id="aspect"><option value="landscape">Landscape &nbsp; 16:9</option><option value="portrait">Portrait &nbsp; 9:16</option><option value="square">Square &nbsp; 1:1</option></select>
+ <div class="brand-divider"></div><div class="direction-label"><span class="field-label">Creative direction</span><span>↗</span></div><p class="direction-copy">Bold typography. Clean transitions. A launch worth watching.</p><div class="concept-note"><span class="tiny-dot"></span> Concept preview · AI rendering comes next</div>
+ </aside>
+</section>
+<section class="timeline-panel" aria-labelledby="timeline-title">
+ <div class="timeline-toolbar"><div class="timeline-heading"><svg><use href="#i-film"/></svg><h2 id="timeline-title">Your film</h2><span class="clip-count" id="clip-count">0 clips</span></div><div class="timeline-tools"><span class="timeline-hint">Drag to reorder · select to edit</span><button class="icon-button" id="undo" title="Undo" aria-label="Undo last timeline change">↶</button><button class="icon-button" id="redo" title="Redo" aria-label="Redo timeline change">↷</button><span class="tool-divider"></span><button class="button small subtle" id="reset-demo">Load demo</button></div></div>
+ <div class="timeline-scroll"><div class="timeline-body" id="timeline-body"><div class="ruler" id="ruler" aria-hidden="true"></div><div class="timeline-lane"><div class="lane-label"><svg><use href="#i-film"/></svg><span>Video</span></div><div class="clips-track" id="clips-track" aria-label="Film clips"></div></div><div class="brand-lane"><span class="lane-label">Aa <span>Brand</span></span><div class="brand-track"><span class="brand-track-name">null</span><span class="brand-track-line"></span><span>Your identity, throughout</span></div></div><div class="playhead" id="playhead"><span></span></div><input id="scrubber" class="timeline-scrubber" type="range" min="0" max="1" step="0.01" value="0" aria-label="Sequence playhead"></div></div>
+ <div class="clip-inspector" id="clip-inspector"><span id="selected-clip-name">Choose a clip to fine-tune</span><div><label>In <input id="clip-in" type="number" min="0" step="0.1" aria-label="Clip in point"></label><label>Out <input id="clip-out" type="number" min="0" step="0.1" aria-label="Clip out point"></label><button class="text-button" id="move-left" aria-label="Move selected clip earlier">←</button><button class="text-button" id="move-right" aria-label="Move selected clip later">→</button><button class="text-button remove-clip" id="remove-clip">Remove</button></div></div>
+</section>
+<section class="library-panel" id="library-panel" aria-labelledby="library-title"><div class="library-heading"><div><div class="library-title-row"><h2 id="library-title">Find your next moment.</h2><span class="library-count" id="library-count">Loading library…</span></div><p>Take the opening from one. The reveal from another. Make the whole thing yours.</p></div><div class="library-actions"><label class="search-box"><svg><use href="#i-search"/></svg><input id="search" type="search" placeholder="Find a reference…" aria-label="Search reference videos"></label><label class="button subtle upload-button"><svg><use href="#i-plus"/></svg>Add video<input id="upload" type="file" accept="video/*" hidden></label></div></div>
+ <div class="reference-tabs" id="reference-tabs" role="tablist" aria-label="Reference videos"></div>
+ <div class="source-heading"><span id="source-title">Your reference library</span><span id="source-detail">Every video, split into moments.</span></div>
+ <div class="segment-grid" id="segment-grid"><div class="library-loading">Preparing your references…</div></div>
+</section>
+<footer class="studio-footer"><span><span class="footer-mark">N</span> Start with a spark. Finish with something yours.</span><span>NULL / LAUNCH STUDIO <span class="footer-dot">·</span> CONCEPT 001</span></footer>
+</main></div>
+<div class="toast" id="toast" role="status" aria-live="polite"></div>
+<dialog id="reference-dialog"><div class="dialog-top"><div><span class="eyebrow">REFERENCE MOMENT</span><h2 id="dialog-title">Preview segment</h2></div><button class="icon-button" id="close-dialog" aria-label="Close reference preview">×</button></div><video id="dialog-video" controls playsinline preload="metadata"></video><div class="dialog-bottom"><span id="dialog-range"></span><button class="button primary" id="dialog-add"><svg><use href="#i-plus"/></svg>Add to film</button></div></dialog>
+</body></html>
diff --git a/public/editor.mjs b/public/editor.mjs
new file mode 100644
index 0000000..2e50e21
--- /dev/null
+++ b/public/editor.mjs
@@ -0,0 +1,376 @@
+import { splitReference, locateClip, moveClip, sequenceDuration } from './editor-model.mjs';
+
+const $ = id => document.getElementById(id);
+const video = $('preview-video');
+const STORAGE = 'null-launch-studio-v1';
+const state = { references: [], clips: [], selected: 0, activeReference: 'all', current: 0, playing: false, mode: 'concept', past: [], future: [], dragged: null, dialogSegment: null, initialized: false };
+const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
+let frame = 0, toastTimer = 0, hoveredVideo = null, dialogTrigger = null, savedTimer = 0;
+const refFor = id => state.references.find(reference => reference.id === id);
+const total = () => sequenceDuration(state.clips);
+const startOf = index => sequenceDuration(state.clips.slice(0, index));
+const seconds = n => `${Number(n).toFixed(1)}s`;
+function timecode(time) {
+ const centiseconds = Math.max(0, Math.round((Number(time) || 0) * 100));
+ return `${String(Math.floor(centiseconds / 6000)).padStart(2, '0')}:${String(Math.floor(centiseconds / 100) % 60).padStart(2, '0')}.${String(centiseconds % 100).padStart(2, '0')}`;
+}
+function element(tag, className, text) {
+ const node = document.createElement(tag);
+ if (className) node.className = className;
+ if (text !== undefined) node.textContent = text;
+ return node;
+}
+function toast(message) {
+ $('toast').textContent = message; $('toast').classList.add('show');
+ clearTimeout(toastTimer); toastTimer = setTimeout(() => $('toast').classList.remove('show'), 2800);
+}
+function persist() {
+ if (!state.initialized) return;
+ try {
+ localStorage.setItem(STORAGE, JSON.stringify({ clips: state.clips.filter(clip => !refFor(clip.ref)?.uploaded), brand: $('brand-name').value, message: $('brand-message').value, accent: getComputedStyle(document.documentElement).getPropertyValue('--accent').trim(), paper: getComputedStyle(document.documentElement).getPropertyValue('--paper').trim(), aspect: $('aspect').value }));
+ $('save-state').lastChild.textContent = ' Saved locally';
+ } catch { $('save-state').lastChild.textContent = ' Not saved'; }
+}
+function snapshot() {
+ state.past.push(structuredClone(state.clips));
+ if (state.past.length > 30) state.past.shift();
+ state.future = [];
+}
+function restoreHistory(direction) {
+ const source = direction === 'undo' ? state.past : state.future;
+ const destination = direction === 'undo' ? state.future : state.past;
+ if (!source.length) return;
+ pause(); destination.push(structuredClone(state.clips)); state.clips = source.pop();
+ state.selected = Math.max(0, Math.min(state.selected, state.clips.length - 1));
+ renderTimeline(); seek(startOf(state.selected)); persist();
+}
+function demoClips() {
+ const picks = [0, 1, 2, 4].filter(index => state.references[index]);
+ return picks.map((referenceIndex, index) => {
+ const reference = state.references[referenceIndex];
+ const segment = reference.segments[Math.min(index % 3, reference.segments.length - 1)];
+ return { ...segment, label: ['The opening', 'The build', 'The reveal', 'The close'][index] };
+ });
+}
+function loadDemo() {
+ if (!state.references.length) return toast('Add a reference video to begin.');
+ snapshot(); pause(); state.clips = demoClips(); state.selected = 0;
+ renderTimeline(); seek(0); persist(); toast('Four moments. One new direction.');
+}
+function brand() {
+ const name = $('brand-name').value.trim() || 'Your brand';
+ $('film-brand-name').textContent = name;
+ document.querySelector('.brand-track-name').textContent = name;
+ document.querySelector('.film-monogram').textContent = name[0].toUpperCase();
+ const message = $('brand-message').value.trim() || 'Good ideas. Great motion.';
+ const split = message.indexOf('. ');
+ const headline = $('film-headline'); headline.replaceChildren();
+ if (split > -1) headline.append(document.createTextNode(message.slice(0, split + 1)), document.createElement('br'), element('em', '', message.slice(split + 2)));
+ else headline.textContent = message;
+ clearTimeout(savedTimer); savedTimer = setTimeout(persist, 250);
+}
+function palette(accent, paper) {
+ document.documentElement.style.setProperty('--accent', accent);
+ document.documentElement.style.setProperty('--paper', paper);
+ document.querySelectorAll('.swatch').forEach(button => {
+ const active = button.dataset.accent.toLowerCase() === accent.toLowerCase();
+ button.classList.toggle('active', active); button.setAttribute('aria-pressed', active);
+ });
+ $('custom-color').value = accent;
+ persist();
+}
+function setAspect() {
+ $('canvas-wrap').classList.toggle('portrait', $('aspect').value === 'portrait');
+ $('canvas-wrap').classList.toggle('square', $('aspect').value === 'square');
+ $('format-label').textContent = { landscape: '1920 × 1080', portrait: '1080 × 1920', square: '1080 × 1080' }[$('aspect').value];
+ persist();
+}
+function renderTimeline() {
+ const track = $('clips-track'); track.replaceChildren();
+ if (!state.clips.length) track.append(element('div', 'empty-track', 'Your next film starts here. Add a moment below.'));
+ state.clips.forEach((clip, index) => {
+ const reference = refFor(clip.ref);
+ const button = element('button', `timeline-clip${index === state.selected ? ' selected' : ''}`);
+ button.style.flexGrow = clip.out - clip.in;
+ button.style.flexBasis = '0'; button.type = 'button'; button.draggable = true; button.dataset.index = index;
+ button.setAttribute('aria-label', `Clip ${index + 1}: ${reference?.name || 'Reference'}, ${seconds(clip.out - clip.in)}`);
+ button.setAttribute('aria-pressed', index === state.selected);
+ const image = element('img'); image.src = clip.poster || reference?.poster || ''; image.alt = ''; image.draggable = false;
+ const caption = element('span', '', clip.label || reference?.name || 'Reference');
+ caption.prepend(element('small', '', `${String(index + 1).padStart(2, '0')} · ${seconds(clip.out - clip.in)}`));
+ button.append(image, caption);
+ button.addEventListener('click', () => { state.selected = index; pause(); seek(startOf(index)); renderSelection(); });
+ button.addEventListener('dragstart', event => { state.dragged = { type: 'clip', index }; event.dataTransfer.effectAllowed = 'move'; event.dataTransfer.setData('text/plain', String(index)); button.classList.add('dragging'); });
+ button.addEventListener('dragend', () => { state.dragged = null; button.classList.remove('dragging'); });
+ track.append(button);
+ });
+ $('clip-count').textContent = `${state.clips.length} clips`;
+ $('time-total').textContent = timecode(total()); $('scrubber').max = Math.max(total(), .01);
+ $('ruler').replaceChildren(...Array.from({ length: 9 }, (_, i) => element('span', '', `${Math.round(total() * i / 8)}s`)));
+ $('undo').disabled = !state.past.length; $('redo').disabled = !state.future.length;
+ $('play').disabled = $('play-top').disabled = !state.clips.length;
+ renderSelection(); updatePlayhead();
+}
+function renderSelection() {
+ document.querySelectorAll('.timeline-clip').forEach((button, index) => {
+ button.classList.toggle('selected', index === state.selected); button.setAttribute('aria-pressed', index === state.selected);
+ });
+ const clip = state.clips[state.selected];
+ for (const id of ['clip-in', 'clip-out', 'move-left', 'move-right', 'remove-clip']) $(id).disabled = !clip;
+ $('selected-clip-name').textContent = clip ? `${String(state.selected + 1).padStart(2, '0')} / ${refFor(clip.ref)?.name || 'Reference'}` : 'Choose a reference moment below';
+ $('clip-in').value = clip ? clip.in.toFixed(2) : ''; $('clip-out').value = clip ? clip.out.toFixed(2) : '';
+ if (clip) {
+ $('clip-in').max = $('clip-out').max = refFor(clip.ref)?.duration || 0;
+ $('move-left').disabled = state.selected === 0; $('move-right').disabled = state.selected === state.clips.length - 1;
+ }
+}
+function updatePlayhead() {
+ const percent = total() ? state.current / total() : 0;
+ $('playhead').style.left = `calc(77px + (100% - 77px) * ${Math.min(1, percent)})`;
+ $('scrubber').value = state.current; $('time-current').textContent = timecode(state.current);
+}
+function updateScene(index) {
+ const clip = state.clips[index]; if (!clip) return;
+ $('film-stage').dataset.scene = index % 4;
+ $('film-progress').textContent = `${String(index + 1).padStart(2, '0')} / ${String(state.clips.length).padStart(2, '0')}`;
+ $('window-label').textContent = ['a new perspective', 'find your flow', 'made to stand out', 'your next chapter'][index % 4];
+ $('film-kicker').textContent = ['MAKE SOMETHING THAT MOVES.', 'A DIFFERENT KIND OF ENERGY.', 'EVERY DETAIL. YOUR DIRECTION.', 'READY FOR YOUR NEXT CHAPTER.'][index % 4];
+ $('film-subline').textContent = ['Your vision. Every frame.', 'One spark. Endless possibilities.', 'Built around your big idea.', 'This is where it begins.'][index % 4];
+ $('preview-description').textContent = `${clip.label || `Moment ${index + 1}`} · ${refFor(clip.ref)?.name || 'Reference'}`;
+}
+function seek(time) {
+ state.current = Math.max(0, Math.min(Number(time) || 0, total())); updatePlayhead();
+ const position = locateClip(state.clips, state.current);
+ if (!position) { video.pause(); video.removeAttribute('src'); delete video.dataset.reference; video.onloadedmetadata = null; video.load(); $('video-loading').hidden = false; $('video-loading').textContent = 'Add a reference moment to begin.'; return; }
+ state.selected = position.index;
+ const reference = refFor(state.clips[position.index].ref);
+ if (!reference) return;
+ updateScene(position.index); renderSelection();
+ if (video.dataset.reference !== reference.id) {
+ $('video-loading').hidden = false; $('video-loading').textContent = 'Loading your reference…';
+ video.dataset.reference = reference.id; video.src = reference.src;
+ }
+ const apply = () => { video.currentTime = position.local; if (state.playing) video.play().catch(() => { pause(); toast('Press play to start the preview.'); }); };
+ if (video.readyState >= 1) { video.onloadedmetadata = null; apply(); }
+ else video.onloadedmetadata = apply;
+}
+function playButtons() {
+ $('play').innerHTML = state.playing ? '<span aria-hidden="true">Ⅱ</span>' : '<svg><use href="#i-play"/></svg>';
+ $('play').setAttribute('aria-label', state.playing ? 'Pause sequence' : 'Play sequence');
+ $('play-top').innerHTML = state.playing ? 'Ⅱ &nbsp; Pause concept' : '<svg><use href="#i-play"/></svg>Play concept';
+}
+function tick() {
+ if (!state.playing) return;
+ const position = locateClip(state.clips, state.current);
+ const clip = position && state.clips[position.index];
+ if (!clip) return pause();
+ if (video.readyState >= 2 && !video.seeking) {
+ if (video.currentTime >= clip.out - .035 || video.ended) {
+ const next = position.index + 1;
+ if (next >= state.clips.length) { state.current = total(); updatePlayhead(); return pause(); }
+ seek(startOf(next) + .001);
+ } else { state.current = Math.min(total(), startOf(position.index) + Math.max(0, video.currentTime - clip.in)); updatePlayhead(); }
+ }
+ frame = requestAnimationFrame(tick);
+}
+function pause() { state.playing = false; video.pause(); cancelAnimationFrame(frame); playButtons(); }
+function togglePlay() {
+ if (state.playing) return pause();
+ if (!state.clips.length) return;
+ stopHover(); state.playing = true;
+ seek(state.current >= total() - .05 ? 0 : state.current);
+ playButtons(); cancelAnimationFrame(frame); frame = requestAnimationFrame(tick);
+}
+video.addEventListener('loadeddata', () => { $('video-loading').hidden = true; });
+video.addEventListener('error', () => { $('video-loading').hidden = false; $('video-loading').textContent = 'Reference unavailable. Choose another moment.'; pause(); });
+function addSegment(segment, index = state.clips.length) {
+ if (state.clips.length >= 24) return toast('This concept can hold up to 24 moments.');
+ snapshot(); pause(); state.clips.splice(index, 0, { ...segment }); state.selected = index;
+ renderTimeline(); seek(startOf(index)); persist(); toast(`Moment added · ${seconds(total())} in your film`);
+}
+function reorder(from, to) {
+ if (from === to || to < 0 || to >= state.clips.length) return;
+ snapshot(); pause(); state.clips = moveClip(state.clips, from, to); state.selected = to;
+ renderTimeline(); seek(startOf(to)); persist();
+}
+function removeClip() {
+ if (!state.clips.length) return;
+ snapshot(); pause(); state.clips.splice(state.selected, 1);
+ state.selected = Math.max(0, Math.min(state.selected, state.clips.length - 1));
+ renderTimeline(); seek(startOf(state.selected)); persist(); toast('Moment removed. Undo to bring it back.');
+}
+function trim() {
+ const clip = state.clips[state.selected]; if (!clip) return;
+ const start = Number($('clip-in').value), end = Number($('clip-out').value);
+ if (!Number.isFinite(start) || !Number.isFinite(end) || start < 0 || end - start < .25 || end > refFor(clip.ref).duration + .005) {
+ renderSelection(); return toast('Choose a valid segment at least 0.25 seconds long.');
+ }
+ snapshot(); pause(); clip.in = start; clip.out = end;
+ renderTimeline(); seek(startOf(state.selected)); persist();
+}
+function stopHover() {
+ if (hoveredVideo) { hoveredVideo.pause(); hoveredVideo.removeAttribute('src'); hoveredVideo.load(); hoveredVideo.remove(); hoveredVideo = null; }
+}
+function hoverPreview(card, segment) {
+ if (reducedMotion || state.playing || !matchMedia('(hover:hover)').matches) return;
+ stopHover();
+ const player = element('video'); player.muted = true; player.playsInline = true; player.preload = 'metadata';
+ player.src = refFor(segment.ref).src; hoveredVideo = player;
+ player.addEventListener('loadedmetadata', () => { if (hoveredVideo === player) { player.currentTime = segment.in; player.play().catch(() => {}); } });
+ player.addEventListener('timeupdate', () => { if (player.currentTime >= segment.out) player.currentTime = segment.in; });
+ card.querySelector('.segment-visual').append(player);
+}
+function openReference(segment, trigger) {
+ stopHover(); pause(); state.dialogSegment = segment; dialogTrigger = trigger;
+ const reference = refFor(segment.ref);
+ $('dialog-title').textContent = reference.name;
+ $('dialog-range').textContent = `${timecode(segment.in)} — ${timecode(segment.out)} · ${seconds(segment.out - segment.in)}`;
+ const player = $('dialog-video'); player.src = reference.src; player.currentTime = segment.in;
+ player.onloadedmetadata = () => { player.currentTime = segment.in; player.play().catch(() => {}); };
+ $('reference-dialog').showModal();
+}
+function closeReference() {
+ $('dialog-video').pause(); $('reference-dialog').close(); dialogTrigger?.focus();
+}
+function renderLibrary() {
+ stopHover();
+ const search = $('search').value.trim().toLowerCase();
+ const references = state.references.filter(reference => `${reference.name} ${reference.originalName || ''}`.toLowerCase().includes(search));
+ const tabs = $('reference-tabs'); tabs.replaceChildren();
+ const all = element('button', `reference-tab${state.activeReference === 'all' ? ' active' : ''}`, 'All references');
+ all.setAttribute('role', 'tab'); all.setAttribute('aria-selected', state.activeReference === 'all');
+ all.tabIndex = state.activeReference === 'all' ? 0 : -1;
+ all.addEventListener('click', () => chooseReference('all')); tabs.append(all);
+ references.forEach(reference => {
+ const tab = element('button', `reference-tab${state.activeReference === reference.id ? ' active' : ''}`);
+ tab.setAttribute('role', 'tab'); tab.setAttribute('aria-selected', state.activeReference === reference.id);
+ tab.tabIndex = state.activeReference === reference.id ? 0 : -1;
+ const image = element('img'); image.src = reference.poster; image.alt = ''; image.loading = 'lazy';
+ tab.append(image, element('span', '', reference.name));
+ tab.addEventListener('click', () => chooseReference(reference.id)); tabs.append(tab);
+ });
+ const active = state.activeReference === 'all' ? references : references.filter(reference => reference.id === state.activeReference);
+ let segments;
+ if (state.activeReference === 'all') {
+ // Interleave videos so the first row shows a mix of creative directions.
+ segments = [];
+ for (let i = 0; i < Math.max(0, ...active.map(reference => reference.segments.length)); i++) for (const reference of active) if (reference.segments[i]) segments.push(reference.segments[i]);
+ } else segments = active.flatMap(reference => reference.segments);
+ $('source-title').textContent = state.activeReference === 'all' ? 'A world of different directions' : active[0]?.name || 'No matching references';
+ $('source-detail').textContent = `${segments.length} moments · Hover to play · + to add`;
+ const grid = $('segment-grid'); grid.replaceChildren();
+ if (!segments.length) grid.append(element('div', 'library-empty', search ? 'No matching references. Try a different search.' : 'Your next idea starts with a reference. Add a video above.'));
+ segments.forEach(segment => {
+ const reference = refFor(segment.ref);
+ const card = element('article', 'segment-card'); card.draggable = true;
+ const visual = element('div', 'segment-visual');
+ const image = element('img'); image.src = segment.poster || reference.poster; image.alt = ''; image.loading = 'lazy'; image.draggable = false;
+ const preview = element('button', 'segment-preview'); preview.type = 'button'; preview.setAttribute('aria-label', `Preview ${reference.name}, part ${segment.part}`); preview.innerHTML = '<svg><use href="#i-play"/></svg>';
+ preview.addEventListener('click', () => openReference(segment, preview));
+ const add = element('button', 'segment-add'); add.type = 'button'; add.setAttribute('aria-label', `Add ${reference.name}, part ${segment.part} to film`); add.innerHTML = '<svg><use href="#i-plus"/></svg>';
+ add.addEventListener('click', () => addSegment(segment, state.clips.length ? state.selected + 1 : 0));
+ visual.append(image, preview, element('span', 'segment-number', `PART ${String(segment.part).padStart(2, '0')}`), element('span', 'segment-length', seconds(segment.out - segment.in)), add);
+ const meta = element('div', 'segment-meta'); meta.append(element('span', '', reference.name.split(' · ')[0]), element('small', '', `${segment.in.toFixed(1)}—${segment.out.toFixed(1)}`));
+ card.append(visual, meta, element('div', 'segment-subtitle', `${segment.part === 1 ? 'The opening' : segment.part === reference.segments.length ? 'The closing moment' : 'The story unfolds'} · Reference footage`));
+ card.addEventListener('mouseenter', () => hoverPreview(card, segment)); card.addEventListener('mouseleave', stopHover);
+ card.addEventListener('dragstart', event => { stopHover(); state.dragged = { type: 'segment', segment }; event.dataTransfer.effectAllowed = 'copy'; event.dataTransfer.setData('text/plain', reference.name); });
+ card.addEventListener('dragend', () => { state.dragged = null; });
+ grid.append(card);
+ });
+ $('library-count').textContent = `${state.references.length} videos · ${state.references.reduce((sum, reference) => sum + reference.segments.length, 0)} moments`;
+}
+function chooseReference(id) {
+ state.activeReference = id; renderLibrary();
+ $('reference-tabs').querySelector('[aria-selected="true"]')?.focus({ preventScroll: true });
+}
+$('reference-tabs').addEventListener('keydown', event => {
+ if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
+ const tabs = [...$('reference-tabs').querySelectorAll('[role="tab"]')];
+ const index = tabs.indexOf(event.target); if (index < 0) return;
+ event.preventDefault();
+ const next = event.key === 'Home' ? 0 : event.key === 'End' ? tabs.length - 1 : (index + (event.key === 'ArrowRight' ? 1 : -1) + tabs.length) % tabs.length;
+ tabs[next].click();
+ $('reference-tabs').querySelector('[aria-selected="true"]')?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
+});
+$('clips-track').addEventListener('dragover', event => { event.preventDefault(); event.dataTransfer.dropEffect = state.dragged?.type === 'clip' ? 'move' : 'copy'; });
+$('clips-track').addEventListener('drop', event => {
+ event.preventDefault();
+ const target = event.target.closest('.timeline-clip');
+ const index = target ? Number(target.dataset.index) : state.clips.length;
+ if (state.dragged?.type === 'segment') addSegment(state.dragged.segment, index);
+ else if (state.dragged?.type === 'clip') reorder(state.dragged.index, Math.min(index, state.clips.length - 1));
+ state.dragged = null;
+});
+for (const id of ['play', 'play-top']) $(id).addEventListener('click', togglePlay);
+$('restart').addEventListener('click', () => { pause(); seek(0); });
+$('scrubber').addEventListener('input', () => { pause(); seek(Number($('scrubber').value)); });
+$('mute').addEventListener('click', () => { video.muted = !video.muted; $('mute').setAttribute('aria-pressed', video.muted); $('mute').setAttribute('aria-label', video.muted ? 'Unmute reference audio' : 'Mute reference audio'); document.querySelector('.mute-slash').hidden = !video.muted; });
+$('fullscreen').addEventListener('click', () => { if (document.fullscreenElement) document.exitFullscreen(); else $('canvas-wrap').requestFullscreen?.().catch(() => toast('Fullscreen is unavailable in this browser.')); });
+$('present').addEventListener('click', () => { document.body.classList.add('present-mode'); toast('Presentation view · press Esc to exit'); });
+$('undo').addEventListener('click', () => restoreHistory('undo')); $('redo').addEventListener('click', () => restoreHistory('redo'));
+$('reset-demo').addEventListener('click', loadDemo);
+$('remove-clip').addEventListener('click', removeClip);
+$('move-left').addEventListener('click', () => reorder(state.selected, state.selected - 1)); $('move-right').addEventListener('click', () => reorder(state.selected, state.selected + 1));
+$('clip-in').addEventListener('change', trim); $('clip-out').addEventListener('change', trim);
+$('brand-name').addEventListener('input', brand); $('brand-message').addEventListener('input', brand);
+$('aspect').addEventListener('change', setAspect);
+document.querySelectorAll('.swatch').forEach(button => button.addEventListener('click', () => palette(button.dataset.accent, button.dataset.paper)));
+$('custom-color').addEventListener('input', event => palette(event.target.value, '#eef0e6'));
+$('search').addEventListener('input', () => { state.activeReference = 'all'; renderLibrary(); });
+$('rail-references').addEventListener('click', () => $('library-panel').scrollIntoView({ behavior: reducedMotion ? 'instant' : 'smooth', block: 'start' }));
+$('rail-brand').addEventListener('click', () => { $('brand-panel').scrollIntoView({ behavior: reducedMotion ? 'instant' : 'smooth', block: 'center' }); $('brand-name').focus({ preventScroll: true }); });
+for (const mode of ['concept', 'reference']) $(`mode-${mode}`).addEventListener('click', () => {
+ state.mode = mode; $('canvas-wrap').classList.toggle('reference-mode', mode === 'reference');
+ for (const option of ['concept', 'reference']) { $(`mode-${option}`).classList.toggle('active', option === mode); $(`mode-${option}`).setAttribute('aria-pressed', option === mode); }
+ $('canvas-label').textContent = mode === 'concept' ? 'CONCEPT PREVIEW' : 'ORIGINAL REFERENCE';
+});
+$('close-dialog').addEventListener('click', closeReference);
+$('reference-dialog').addEventListener('close', () => { $('dialog-video').pause(); dialogTrigger?.focus(); });
+$('dialog-video').addEventListener('timeupdate', () => { if (state.dialogSegment && $('dialog-video').currentTime >= state.dialogSegment.out) $('dialog-video').pause(); });
+$('dialog-add').addEventListener('click', () => { addSegment(state.dialogSegment, state.clips.length ? state.selected + 1 : 0); closeReference(); });
+document.addEventListener('keydown', event => {
+ if (event.key === 'Escape') document.body.classList.remove('present-mode');
+ if (/INPUT|TEXTAREA|SELECT/.test(event.target.tagName) || $('reference-dialog').open) return;
+ if (event.code === 'Space' && !event.target.closest('button,a')) { event.preventDefault(); togglePlay(); }
+ if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'z') { event.preventDefault(); restoreHistory(event.shiftKey ? 'redo' : 'undo'); }
+});
+document.addEventListener('visibilitychange', () => { if (document.hidden) { pause(); stopHover(); $('dialog-video').pause(); } });
+$('upload').addEventListener('change', async event => {
+ const file = event.target.files[0]; if (!file) return;
+ const src = URL.createObjectURL(file); const player = document.createElement('video'); player.muted = true; player.preload = 'metadata'; player.src = src;
+ try {
+ await new Promise((resolve, reject) => { player.onloadedmetadata = resolve; player.onerror = reject; });
+ if (!Number.isFinite(player.duration) || player.duration < .25) throw new Error('duration');
+ const id = `upload-${Date.now()}`;
+ player.currentTime = Math.min(.25, player.duration / 2);
+ await new Promise((resolve, reject) => { player.onseeked = resolve; player.onerror = reject; });
+ const canvas = document.createElement('canvas'); canvas.width = 480; canvas.height = Math.max(1, Math.round(480 * player.videoHeight / player.videoWidth));
+ canvas.getContext('2d').drawImage(player, 0, 0, canvas.width, canvas.height);
+ const poster = canvas.toDataURL('image/jpeg', .7);
+ const reference = { id, name: file.name.replace(/\.[^.]+$/, ''), duration: player.duration, src, poster, uploaded: true };
+ reference.segments = splitReference(reference).map(segment => ({ ...segment, poster }));
+ state.references.unshift(reference); state.activeReference = id; renderLibrary(); toast('Video added for this session. Pick your favorite moments.');
+ } catch { URL.revokeObjectURL(src); toast('This video could not be opened. Try an MP4 file.'); }
+ finally { player.removeAttribute('src'); player.load(); event.target.value = ''; }
+});
+async function initialize() {
+ try {
+ const response = await fetch('/api/references'); if (!response.ok) throw new Error('library');
+ const data = await response.json(); state.references = data.references || [];
+ let saved;
+ try { saved = JSON.parse(localStorage.getItem(STORAGE) || 'null'); } catch { saved = null; }
+ if (saved) {
+ state.clips = Array.isArray(saved.clips) ? saved.clips.filter(clip => refFor(clip.ref) && Number.isFinite(clip.in) && Number.isFinite(clip.out) && clip.in >= 0 && clip.out > clip.in && clip.out <= refFor(clip.ref).duration + .005).slice(0, 24) : [];
+ if (typeof saved.brand === 'string') $('brand-name').value = saved.brand.slice(0, 30);
+ if (typeof saved.message === 'string') $('brand-message').value = saved.message.slice(0, 80);
+ if (/^#[a-f\d]{6}$/i.test(saved.accent) && /^#[a-f\d]{6}$/i.test(saved.paper)) palette(saved.accent, saved.paper);
+ if (['landscape', 'portrait', 'square'].includes(saved.aspect)) $('aspect').value = saved.aspect;
+ } else state.clips = demoClips();
+ state.initialized = true;
+ renderLibrary(); brand(); setAspect(); renderTimeline(); seek(0);
+ } catch {
+ $('segment-grid').replaceChildren(element('div', 'library-empty', 'The reference library could not load. Reload to try again.'));
+ $('library-count').textContent = 'Library unavailable'; toast('Could not load references.');
+ }
+}
+initialize();
diff --git a/public/site-shell.js b/public/site-shell.js
index 35c6aac..55ba4e7 100644
--- a/public/site-shell.js
+++ b/public/site-shell.js
@@ -2,7 +2,8 @@
"use strict";
const pages = [
- { key: "templates", href: "./", label: "Templates", icon: '<rect x="4" y="4" width="16" height="16" rx="2"></rect><path d="M4 9h16M9 9v11"></path>' },
+ { key: "editor", href: "/editor", label: "Editor", icon: '<rect x="3" y="4" width="18" height="12" rx="2"></rect><path d="M3 20h18M10 8l4 2-4 2z"></path>' },
+ { key: "templates", href: "index.html", label: "Templates", icon: '<rect x="4" y="4" width="16" height="16" rx="2"></rect><path d="M4 9h16M9 9v11"></path>' },
{ key: "reference", href: "create.html", label: "Reference", icon: '<rect x="3" y="4" width="18" height="16" rx="2"></rect><circle cx="8.5" cy="9" r="1.5"></circle><path d="m21 15-4.2-4.2L8 19"></path>' },
{ key: "script", href: "script.html", label: "Script", icon: '<path d="M6 3h8l4 4v14H6z"></path><path d="M14 3v5h5M9 12h6M9 16h4"></path>' },
{ key: "pipeline", href: "system-map.html", label: "Pipeline", icon: '<circle cx="5" cy="12" r="2"></circle><circle cx="12" cy="5" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="12" cy="19" r="2"></circle><path d="m6.5 10.5 4-4m3 0 4 4m0 3-4 4m-3 0-4-4"></path>' },
diff --git a/scripts/check.js b/scripts/check.js
index f297ce3..2599096 100644
--- a/scripts/check.js
+++ b/scripts/check.js
@@ -1,16 +1,21 @@
import { readdir, readFile } from 'node:fs/promises';
import { Script } from 'node:vm';
import { spawnSync } from 'node:child_process';
+import { fileURLToPath } from 'node:url';
let count = 0;
async function check(directory) {
for (const entry of await readdir(directory, { withFileTypes: true })) {
const url = new URL(entry.name + (entry.isDirectory() ? '/' : ''), directory);
if (entry.isDirectory()) { await check(url); continue; }
- if (!/\.(?:html|js)$/.test(entry.name)) continue;
+ if (!/\.(?:html|mjs|js)$/.test(entry.name)) continue;
const source = await readFile(url, 'utf8');
if (/https?:\/\/(?:127\.0\.0\.1|localhost):424[23]/.test(source)) throw new Error(`Personal companion URL: ${url}`);
- if (entry.name.endsWith('.js')) new Script(source, { filename: url.pathname });
+ if (entry.name.endsWith('.mjs')) {
+ const result = spawnSync(process.execPath, ['--check', fileURLToPath(url)], { stdio: 'inherit' });
+ if (result.status) process.exit(result.status);
+ }
+ else if (entry.name.endsWith('.js')) new Script(source, { filename: url.pathname });
else for (const match of source.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)) {
if (/\bsrc\s*=|application\/json|application\/ld\+json/.test(match[1])) continue;
new Script(match[2], { filename: url.pathname });
@@ -19,7 +24,7 @@ async function check(directory) {
}
}
await check(new URL('../public/', import.meta.url));
-for (const filename of ['server.js', 'scripts/check.js']) {
+for (const filename of ['server.js', 'media.js', 'scripts/check.js']) {
const result = spawnSync(process.execPath, ['--check', filename], { stdio: 'inherit' });
if (result.status) process.exit(result.status);
}
diff --git a/scripts/import-motionclone.py b/scripts/import-motionclone.py
new file mode 100644
index 0000000..73d0c1b
--- /dev/null
+++ b/scripts/import-motionclone.py
@@ -0,0 +1,63 @@
+"""Import source references only. Videos stay local; no jobs, auth, or outputs are copied."""
+import argparse
+import json
+import math
+import os
+from pathlib import Path
+import subprocess
+
+parser = argparse.ArgumentParser()
+parser.add_argument('--source', required=True, type=Path, help='MotionClone project directory')
+args = parser.parse_args()
+target = Path(__file__).resolve().parent.parent
+media_root = target / '.local-media'
+thumb_root = target / 'public' / 'references'
+media_root.mkdir(exist_ok=True)
+thumb_root.mkdir(exist_ok=True)
+sources = []
+for directory in sorted((args.source / 'data').iterdir()):
+ if not directory.is_dir() or directory.name.startswith('.'):
+ continue
+ if (directory / 'source.mp4').exists():
+ job = json.loads((directory / 'job.json').read_text(encoding='utf-8'))
+ sources.append((directory.name, directory / 'source.mp4', job.get('name', 'Motion reference')))
+ elif directory.name in ('nexa-references', 'troovy-reference'):
+ for video in sorted(directory.glob('*.mp4')):
+ info_file = video.with_suffix('.info.json')
+ info = json.loads(info_file.read_text(encoding='utf-8')) if info_file.exists() else {}
+ sources.append((directory.name + '-' + video.stem, video, info.get('title', video.stem)))
+references = []
+for identifier, video, title in sources:
+ probe = subprocess.run(['ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=width,height:format=duration', '-of', 'json', str(video)], capture_output=True, text=True, check=True)
+ details = json.loads(probe.stdout)
+ duration = float(details['format']['duration'])
+ destination = media_root / (identifier + '.mp4')
+ if not destination.exists():
+ # Same-volume hard links preserve the source without duplicating large videos.
+ os.link(video, destination)
+ count = max(1, math.floor(duration / 4))
+ segments = []
+ for index in range(count):
+ start = round(index * duration / count, 3)
+ end = duration if index == count - 1 else round((index + 1) * duration / count, 3)
+ image = thumb_root / f'{identifier}-{index}.jpg'
+ if not image.exists():
+ subprocess.run(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-threads', '1', '-ss', str((start + end) / 2), '-i', str(video), '-frames:v', '1', '-vf', 'scale=480:-2', '-threads', '1', '-q:v', '4', str(image)], check=True, stdout=subprocess.DEVNULL)
+ segments.append({'ref': identifier, 'in': start, 'out': round(end, 3), 'part': index + 1, 'poster': f'/references/{image.name}'})
+ name = str(title).split(' - ', 1)[-1].split(' ')[0].strip()
+ aliases = {
+ '09a418cdd005': 'Leo · Ideas in motion', '09782d1f7c63': 'Claude × Milanote',
+ 'cf8c4707e634': 'HealthTech · Product reveal', '4d97811d6dae': 'Ask River · A better flow',
+ '919ebec37a3b': 'Troovy · Meet your next idea', '5fbdf5e42405': 'System prompts',
+ '3227c09daea3': 'Supahub · Product story', '0360df628fa3': 'Motion study 01',
+ '227b019e7968': 'SaaS · Launch sequence', '5db95a3a7c73': 'Motion study 08',
+ '5924a2f28506': 'Interface · Motion study'
+ }
+ references.append({'id': identifier, 'name': aliases.get(identifier, name[:85]), 'originalName': str(title)[:200],
+ 'duration': round(duration, 3), 'width': details['streams'][0]['width'], 'height': details['streams'][0]['height'],
+ 'src': f'/media/references/{identifier}.mp4', 'poster': segments[0]['poster'], 'segments': segments})
+ print(f'Imported {identifier}: {len(segments)} segments', flush=True)
+preferred = ['09a418cdd005', '09782d1f7c63', 'cf8c4707e634', '4d97811d6dae', '919ebec37a3b', '3227c09daea3']
+references.sort(key=lambda item: preferred.index(item['id']) if item['id'] in preferred else len(preferred))
+(thumb_root / 'catalog.json').write_text(json.dumps({'references': references}, indent=2, ensure_ascii=False), encoding='utf-8')
+print(f'Ready: {len(references)} references, {sum(len(r["segments"]) for r in references)} selectable segments.')
diff --git a/server.js b/server.js
index 9435295..1ca461a 100644
--- a/server.js
+++ b/server.js
@@ -2,6 +2,7 @@ import http from 'node:http';
import { readFile, realpath, stat } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
+import { streamVideo } from './media.js';
const root = fileURLToPath(new URL('./public/', import.meta.url));
const catalog = JSON.parse(await readFile(new URL('./data/template-catalog.json', import.meta.url), 'utf8'));
@@ -31,7 +32,7 @@ const readOnly = new Map([
['/api/v1/premiere-inbox', { items: [] }],
['/api/v1/premiere-actions', { actions: [] }]
]);
-const mime = { '.html': 'text/html; charset=utf-8', '.css': 'text/css; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.svg': 'image/svg+xml', '.png': 'image/png', '.json': 'application/json; charset=utf-8' };
+const mime = { '.html': 'text/html; charset=utf-8', '.css': 'text/css; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.mjs': 'text/javascript; charset=utf-8', '.svg': 'image/svg+xml', '.png': 'image/png', '.jpg': 'image/jpeg', '.json': 'application/json; charset=utf-8' };
function json(response, status, body) {
response.writeHead(status, { 'Content-Type': mime['.json'], 'Cache-Control': 'no-store' });
@@ -49,6 +50,13 @@ export function createApp() {
if (pathname.includes('\\') || pathname.includes('\0') || pathname.split('/').some(part => part.startsWith('.'))) {
return json(response, 403, { error: 'Forbidden.' });
}
+ if (pathname === '/api/references') {
+ try { return json(response, 200, JSON.parse(await readFile(new URL('./public/references/catalog.json', import.meta.url), 'utf8'))); }
+ catch { return json(response, 200, { references: [] }); }
+ }
+ const mediaMatch = pathname.match(/^\/media\/references\/([a-z0-9-]+)\.mp4$/);
+ if (mediaMatch) return streamVideo(request, response, fileURLToPath(new URL(`./.local-media/${mediaMatch[1]}.mp4`, import.meta.url)));
+ if (pathname === '/' || pathname === '/editor') pathname = '/editor.html';
if (readOnly.has(pathname)) return json(response, 200, readOnly.get(pathname));
const sourceMatch = pathname.match(/^\/api\/v1\/templates\/([^/]+)\/source$/);
if (sourceMatch) {
diff --git a/test/editor.test.js b/test/editor.test.js
new file mode 100644
index 0000000..a2aeb5e
--- /dev/null
+++ b/test/editor.test.js
@@ -0,0 +1,26 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { splitReference, locateClip, moveClip, sequenceDuration } from '../public/editor-model.mjs';
+
+test('reference segments cover the source with no gaps or tiny tails', () => {
+ const clips = splitReference({ id: 'sample', duration: 12.1 }, 4);
+ assert.equal(clips[0].in, 0);
+ assert.equal(clips.at(-1).out, 12.1);
+ assert.ok(clips.every(clip => clip.out - clip.in >= 0.25));
+ clips.slice(1).forEach((clip, i) => assert.equal(clip.in, clips[i].out));
+ assert.deepEqual(splitReference({ id: 'bad', duration: 0 }), []);
+});
+test('sequence seeking maps to the correct source moment at boundaries', () => {
+ const clips = [{ in: 2, out: 5 }, { in: 10, out: 14 }];
+ assert.equal(sequenceDuration(clips), 7);
+ assert.deepEqual(locateClip(clips, 3), { index: 1, local: 10 });
+ assert.deepEqual(locateClip(clips, 100), { index: 1, local: 14 });
+ assert.deepEqual(locateClip(clips, -4), { index: 0, local: 2 });
+ assert.equal(locateClip([], 0), null);
+});
+test('reordering preserves every clip and leaves the original unchanged', () => {
+ const clips = ['a', 'b', 'c'];
+ assert.deepEqual(moveClip(clips, 0, 2), ['b', 'c', 'a']);
+ assert.deepEqual(clips, ['a', 'b', 'c']);
+ assert.deepEqual(moveClip(clips, -1, 2), clips);
+});
diff --git a/test/media.test.js b/test/media.test.js
new file mode 100644
index 0000000..0fe945f
--- /dev/null
+++ b/test/media.test.js
@@ -0,0 +1,10 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { byteRange } from '../media.js';
+test('video byte ranges support seeking without loading whole sources', () => {
+ assert.deepEqual(byteRange('bytes=3-7', 10), { start: 3, end: 7 });
+ assert.deepEqual(byteRange('bytes=7-', 10), { start: 7, end: 9 });
+ assert.deepEqual(byteRange('bytes=-3', 10), { start: 7, end: 9 });
+ assert.deepEqual(byteRange('bytes=0-999', 10), { start: 0, end: 9 });
+ for (const value of ['bytes=10-', 'bytes=7-2', 'bytes=-0', 'bytes=a-b', 'bytes=0-2,4-6']) assert.equal(byteRange(value, 10), null);
+});
diff --git a/test/server.test.js b/test/server.test.js
index 9db7295..a4f5b63 100644
--- a/test/server.test.js
+++ b/test/server.test.js
@@ -12,7 +12,8 @@ test('public workspace is standalone, read-only, and serves its own previews', a
const home = await get('/');
assert.equal(home.status, 200);
- assert.match(await home.text(), /Template Gallery/);
+ assert.match(await home.text(), /Null.*Launch Studio/);
+ assert.match(await (await get('/index.html')).text(), /Template Gallery/);
const catalog = await (await get('/api/v1/templates')).json();
assert.ok(catalog.templates.length > 0);
for (const template of catalog.templates) {