fablecut 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sequences.js ADDED
@@ -0,0 +1,216 @@
1
+ /* FableCut sequences — several timelines in one project. Zero dependencies.
2
+ Loaded by the editor as a plain script (global `FableCutSeq`) and required
3
+ by the MCP server, project-ops and the tests.
4
+
5
+ The OPEN sequence is the project's top level, as it always was: `clips`,
6
+ `tracks`, `markers`, the canvas, the mix and the delivery settings. Every
7
+ tool, agent and export keeps reading and writing those. The others are kept
8
+ in `project.sequences`, each with its own copy of the same keys:
9
+
10
+ "sequence": "main", // the open one
11
+ "sequences": [
12
+ { "id": "main", "name": "Main" }, // the open one: its timeline is the top level
13
+ { "id": "seq_v", "name": "Vertical", "width": 1080, "height": 1920, "fps": 30, "clips": [ … ], … }
14
+ ]
15
+
16
+ Opening another sequence parks the top-level keys in the open one's entry
17
+ and brings the other's up. Media, folders, collections and compositions
18
+ are the project's, shared by every sequence. A project with one sequence
19
+ has neither key: untouched projects stay byte-identical. */
20
+ (function (root, factory) {
21
+ const node = typeof module === "object" && module.exports;
22
+ const api = factory();
23
+ if (node) module.exports = api;
24
+ else root.FableCutSeq = api;
25
+ })(typeof self !== "undefined" ? self : this, function () {
26
+ "use strict";
27
+
28
+ /** What a sequence owns: its timeline, canvas, frame rate, mix and delivery. */
29
+ const KEYS = ["width", "height", "fps", "background", "exportFrame", "clips", "tracks", "markers", "inPoint", "outPoint",
30
+ "disabledTracks", "lockedTracks", "untargetedTracks", "master", "buses", "delivery", "outputs", "encodeProfile"];
31
+ const MAIN = { id: "main", name: "Main" };
32
+ const MAX = 64;
33
+ const isObj = (v) => v != null && typeof v === "object" && !Array.isArray(v);
34
+ const clone = (v) => (v === undefined ? undefined : JSON.parse(JSON.stringify(v)));
35
+ const uid = () => Math.random().toString(36).slice(2, 8);
36
+ const r2 = (v) => Math.round(v * 100) / 100;
37
+
38
+ /** The sequence entries, the open one included (a project without the key has one: Main). */
39
+ function entries(doc) {
40
+ return doc && Array.isArray(doc.sequences) && doc.sequences.length ? doc.sequences : [{ ...MAIN }];
41
+ }
42
+ function activeId(doc) {
43
+ const list = entries(doc);
44
+ return doc && list.some((s) => s.id === doc.sequence) ? doc.sequence : list[0].id;
45
+ }
46
+ function find(doc, id) { return entries(doc).find((s) => s.id === id) || null; }
47
+ /** The sequences that are not open: [{id, name, clips, …}] — media and comp usage scans read these too. */
48
+ function others(doc) {
49
+ const act = activeId(doc);
50
+ return entries(doc).filter((s) => s.id !== act);
51
+ }
52
+ const lengthOf = (clips) => (Array.isArray(clips) ? clips : []).reduce((m, c) => Math.max(m, (+c.start || 0) + (+c.duration || 0)), 0);
53
+
54
+ /** One row per sequence, in order: {id, name, active, width, height, fps, clips, duration}. */
55
+ function list(doc) {
56
+ const act = activeId(doc);
57
+ return entries(doc).map((s) => {
58
+ const src = s.id === act ? doc : s;
59
+ return { id: s.id, name: s.name || s.id, active: s.id === act, width: src.width, height: src.height, fps: src.fps,
60
+ clips: Array.isArray(src.clips) ? src.clips.length : 0, duration: r2(lengthOf(src.clips)) };
61
+ });
62
+ }
63
+
64
+ /** Check and tidy doc.sequences in place (throws on a bad entry). One sequence named Main → both keys go. */
65
+ function normalize(doc) {
66
+ if (doc.sequences == null) { delete doc.sequence; return doc; }
67
+ if (!Array.isArray(doc.sequences)) throw new Error("sequences must be a list of {id, name, …}");
68
+ if (doc.sequences.length > MAX) throw new Error(`a project holds up to ${MAX} sequences`);
69
+ const seen = new Set();
70
+ const out = [];
71
+ for (const s of doc.sequences) {
72
+ if (!isObj(s)) throw new Error("every sequence is an object {id, name, …}");
73
+ const id = typeof s.id === "string" ? s.id.trim().slice(0, 40) : "";
74
+ if (!id) throw new Error("every sequence needs an id");
75
+ if (seen.has(id)) throw new Error(`two sequences have the id ${id} — sequence ids must be unique`);
76
+ seen.add(id);
77
+ const name = typeof s.name === "string" && s.name.trim() ? s.name.trim().slice(0, 120) : id;
78
+ out.push({ ...s, id, name });
79
+ }
80
+ if (!out.length) { delete doc.sequences; delete doc.sequence; return doc; }
81
+ // without a valid `sequence`, the open one is an entry without a timeline of its own: never strip one that has one
82
+ const named = out.some((s) => s.id === doc.sequence);
83
+ const bare = out.find((s) => !KEYS.some((k) => s[k] !== undefined));
84
+ if (!named && !bare) throw new Error(`sequence must name the open sequence (${out.map((s) => s.id).join(", ")}): every entry carries a timeline of its own`);
85
+ const act = named ? doc.sequence : bare.id;
86
+ for (const s of out) {
87
+ if (s.id === act) { for (const k of KEYS) delete s[k]; continue; }
88
+ // a parked sequence carries its own timeline
89
+ if (s.clips == null) s.clips = [];
90
+ if (!Array.isArray(s.clips)) throw new Error(`sequence ${s.id}: clips must be a list`);
91
+ for (const c of s.clips) if (!isObj(c) || typeof c.id !== "string" || typeof c.start !== "number" || typeof c.duration !== "number")
92
+ throw new Error(`sequence ${s.id}: every clip needs id, numeric start and duration`);
93
+ for (const k of ["width", "height", "fps"]) if (s[k] != null && !(typeof s[k] === "number" && s[k] > 0)) throw new Error(`sequence ${s.id}: ${k} must be a positive number`);
94
+ }
95
+ if (out.length === 1 && out[0].id === MAIN.id && out[0].name === MAIN.name) { delete doc.sequences; delete doc.sequence; return doc; }
96
+ doc.sequences = out;
97
+ doc.sequence = act;
98
+ return doc;
99
+ }
100
+
101
+ /** Make the list explicit (before adding to it). */
102
+ function materialize(doc) {
103
+ if (!Array.isArray(doc.sequences) || !doc.sequences.length) doc.sequences = [{ ...MAIN }];
104
+ doc.sequence = activeId(doc);
105
+ return doc;
106
+ }
107
+ /** The open sequence's keys, copied out of the top level. */
108
+ function takeTop(doc) {
109
+ const out = {};
110
+ for (const k of KEYS) if (doc[k] !== undefined) out[k] = clone(doc[k]);
111
+ if (!Array.isArray(out.clips)) out.clips = [];
112
+ return out;
113
+ }
114
+
115
+ /** Open sequence `id`: the open one's timeline is parked in its entry, `id`'s comes up. */
116
+ function open(doc, id) {
117
+ const target = find(doc, id);
118
+ if (!target) throw new Error(`no sequence ${id} (${entries(doc).map((s) => s.id).join(", ")})`);
119
+ const act = activeId(doc);
120
+ if (id === act) return doc;
121
+ materialize(doc);
122
+ const parked = takeTop(doc);
123
+ const keep = { width: doc.width, height: doc.height, fps: doc.fps };
124
+ doc.sequences = doc.sequences.map((s) => {
125
+ if (s.id === act) return { id: s.id, name: s.name, ...parked };
126
+ if (s.id === id) return { id: s.id, name: s.name };
127
+ return s;
128
+ });
129
+ for (const k of KEYS) {
130
+ if (target[k] !== undefined) doc[k] = target[k];
131
+ else delete doc[k];
132
+ }
133
+ // a sequence always has a canvas and a timeline
134
+ for (const k of ["width", "height", "fps"]) if (!(doc[k] > 0)) doc[k] = keep[k];
135
+ if (!Array.isArray(doc.clips)) doc.clips = [];
136
+ doc.sequence = id;
137
+ return doc;
138
+ }
139
+
140
+ /** A new sequence: {name?, id?, from?: "empty" | "open" | <sequence id>, width?, height?, fps?}.
141
+ * Empty takes the open one's canvas, frame rate and background; a copy takes everything.
142
+ * It is added after the open one (or after `from`) and not opened. */
143
+ function add(doc, opts = {}) {
144
+ materialize(doc);
145
+ const from = opts.from || "empty";
146
+ const id = opts.id ? String(opts.id).trim().slice(0, 40) : "seq_" + uid();
147
+ if (!id) throw new Error("addSequence: the id is empty");
148
+ if (find(doc, id)) throw new Error(`addSequence: sequence ${id} already exists`);
149
+ if (doc.sequences.length >= MAX) throw new Error(`addSequence: a project holds up to ${MAX} sequences`);
150
+ const act = activeId(doc);
151
+ let body, after = act;
152
+ if (from === "empty") {
153
+ body = { width: doc.width, height: doc.height, fps: doc.fps, clips: [] };
154
+ if (doc.background) body.background = doc.background;
155
+ } else if (from === "open" || from === act) {
156
+ body = takeTop(doc);
157
+ } else {
158
+ const src = find(doc, from);
159
+ if (!src) throw new Error(`addSequence: no sequence ${from} to copy`);
160
+ const { id: _i, name: _n, ...rest } = clone(src);
161
+ body = rest;
162
+ after = src.id;
163
+ }
164
+ for (const k of ["width", "height", "fps"]) if (opts[k] != null) {
165
+ const v = +opts[k];
166
+ if (!(v > 0) || (k !== "fps" && (v < 16 || v > 8192)) || (k === "fps" && v > 240)) throw new Error(`addSequence: ${k} ${opts[k]} is out of range`);
167
+ body[k] = k === "fps" ? v : Math.round(v);
168
+ }
169
+ if (from !== "empty" && (opts.width != null || opts.height != null)) delete body.exportFrame; // the crop was for the other size
170
+ const srcName = from === "empty" ? null : (find(doc, from === "open" ? act : from) || {}).name;
171
+ const name = typeof opts.name === "string" && opts.name.trim() ? opts.name.trim().slice(0, 120)
172
+ : srcName ? `${srcName} copy` : `Sequence ${doc.sequences.length + 1}`;
173
+ const entry = { id, name, ...body };
174
+ const at = doc.sequences.findIndex((s) => s.id === after);
175
+ doc.sequences.splice(at + 1, 0, entry);
176
+ return entry;
177
+ }
178
+
179
+ /** Rename (the only thing set on an entry — the open one's timeline is edited at the top level). */
180
+ function rename(doc, id, name) {
181
+ const s = find(doc, id);
182
+ if (!s) throw new Error(`no sequence ${id}`);
183
+ const n = String(name == null ? "" : name).trim().slice(0, 120);
184
+ if (!n) throw new Error("a sequence needs a name");
185
+ materialize(doc);
186
+ doc.sequences = doc.sequences.map((x) => (x.id === id ? { ...x, name: n } : x));
187
+ return normalize(doc);
188
+ }
189
+ /** Move sequence `id` to position `index` (0-based) in the list. */
190
+ function move(doc, id, index) {
191
+ materialize(doc);
192
+ const i = doc.sequences.findIndex((s) => s.id === id);
193
+ if (i < 0) throw new Error(`no sequence ${id}`);
194
+ const [s] = doc.sequences.splice(i, 1);
195
+ doc.sequences.splice(Math.max(0, Math.min(doc.sequences.length, Math.round(+index) || 0)), 0, s);
196
+ return doc;
197
+ }
198
+ /** Delete sequence `id`. The last one stays; deleting the open one opens its neighbour first. */
199
+ function remove(doc, id) {
200
+ const list = entries(doc);
201
+ const i = list.findIndex((s) => s.id === id);
202
+ if (i < 0) throw new Error(`no sequence ${id}`);
203
+ if (list.length === 1) throw new Error("a project keeps at least one sequence");
204
+ if (activeId(doc) === id) open(doc, (list[i + 1] || list[i - 1]).id);
205
+ doc.sequences = doc.sequences.filter((s) => s.id !== id);
206
+ return normalize(doc);
207
+ }
208
+
209
+ /** One line per sequence, for status readouts. */
210
+ function describe(row) {
211
+ const t = Math.round(row.duration), m = Math.floor(t / 60), s = t % 60;
212
+ return `${row.id} "${row.name}"${row.active ? " (open)" : ""} ${row.width}x${row.height}@${row.fps}, ${row.clips} clip(s), ${m}:${String(s).padStart(2, "0")}`;
213
+ }
214
+
215
+ return { KEYS, MAIN, MAX, entries, activeId, find, others, list, normalize, materialize, open, add, rename, move, remove, describe };
216
+ });
package/server.js CHANGED
@@ -47,6 +47,8 @@ const { probeFile } = require("./media-probe");
47
47
  const MediaLib = require("./media-lib");
48
48
  const { createProxies } = require("./proxy");
49
49
  const Delivery = require("./delivery");
50
+ const { createProjects } = require("./projects");
51
+ const { createHistory } = require("./history");
50
52
 
51
53
  /* Static app files are served from the install dir; everything the user creates
52
54
  lives under DATA_DIR. The two are the same unless FABLECUT_DATA_DIR is set. */
@@ -96,6 +98,18 @@ const MIME = {
96
98
  };
97
99
 
98
100
  ensureDirs();
101
+ const projects = createProjects({ dataDir: DATA_DIR, projectFile: PROJECT_FILE, libraryDir: LIBRARY_DIR });
102
+ const history = createHistory({ projects, autoMinutes: Number(process.env.FABLECUT_AUTO_VERSION_MIN) || 10 });
103
+ /* project.json that can't be read at startup (a crash mid-write by another tool, a
104
+ bad hand edit): keep it aside and put back the newest good copy. */
105
+ if (fs.existsSync(PROJECT_FILE)) {
106
+ try { JSON.parse(fs.readFileSync(PROJECT_FILE, "utf8").replace(/^/, "")); }
107
+ catch (e) {
108
+ const r = history.recover(PROJECT_FILE);
109
+ console.warn(` ⚠ project.json could not be read (${e.message}); kept as ${path.basename(r.aside)}` +
110
+ (r.recovered ? ` and restored from ${r.from}` : " — starting a new project"));
111
+ }
112
+ }
99
113
  if (!fs.existsSync(PROJECT_FILE)) {
100
114
  fs.writeFileSync(PROJECT_FILE, JSON.stringify({
101
115
  name: "Untitled Project", width: 1280, height: 720, fps: 30,
@@ -581,10 +595,96 @@ const server = http.createServer(async (req, res) => {
581
595
  /* API: project */
582
596
  if (p === "/api/project" && req.method === "GET") {
583
597
  // strip UTF-8 BOM some editors/PowerShell prepend, which breaks JSON.parse
584
- try { sendJSON(res, 200, JSON.parse(fs.readFileSync(PROJECT_FILE, "utf8").replace(new RegExp("^\\uFEFF"), ""))); }
598
+ try {
599
+ const doc = JSON.parse(fs.readFileSync(PROJECT_FILE, "utf8").replace(new RegExp("^\\uFEFF"), ""));
600
+ // which project this is, once there are several: the editor resets undo when it changes
601
+ const id = projects.peekActive();
602
+ res.setHeader("X-FableCut-Projects", "1");
603
+ if (id) res.setHeader("X-FableCut-Project", id);
604
+ sendJSON(res, 200, doc);
605
+ }
585
606
  catch (e) { sendJSON(res, 500, { error: String(e) }); }
586
607
  return;
587
608
  }
609
+
610
+ /* API: projects — the dashboard. GET lists them (?archived=only|all) with the
611
+ project templates; POST {action, …} creates, opens, duplicates, renames,
612
+ archives, deletes, imports, and saves / deletes templates (projects.js).
613
+ GET / PUT /api/projects/thumb?id= is a project's JPEG thumbnail. */
614
+ if (p === "/api/projects" && req.method === "GET") {
615
+ try {
616
+ const archived = ["only", "all"].includes(url.searchParams.get("archived")) ? url.searchParams.get("archived") : "exclude";
617
+ sendJSON(res, 200, projects.act({ action: "list", archived }));
618
+ } catch (e) { sendJSON(res, 500, { error: e.message }); }
619
+ return;
620
+ }
621
+ if (p === "/api/projects" && req.method === "POST") {
622
+ let a;
623
+ try { a = JSON.parse((await readBody(req)).toString("utf8") || "{}"); }
624
+ catch { sendJSON(res, 400, { error: "body must be JSON {action, …}" }); return; }
625
+ try {
626
+ // a backup file (a project with its versions) imports through history.js
627
+ const out = a.action === "import" && a.project?.fablecut === "backup" ? history.importBackup(a.project, a) : projects.act(a);
628
+ broadcast("projects", JSON.stringify({ action: a.action, id: out.id || a.id || null, active: projects.activeId() }));
629
+ // opening, or renaming the open project, rewrites ./project.json: reload the tabs now, watcher or not
630
+ if (out.from || ((a.action === "update" || a.action === "rename") && out.project?.active)) onFsChange();
631
+ sendJSON(res, 200, out);
632
+ } catch (e) { sendJSON(res, /^no (project|saved template)/.test(e.message) ? 404 : 400, { error: e.message }); }
633
+ return;
634
+ }
635
+ /* API: versions (history.js) — GET ?project= lists them (default: the open project);
636
+ POST {action, project?, version?, …} saves, restores, compares, renames / marks
637
+ final, deletes; GET /api/versions/file?project=&version= is one version's document.
638
+ GET /api/projects/backup?id= is a project with all its versions, as one file. */
639
+ if (p === "/api/versions" && req.method === "GET") {
640
+ try { sendJSON(res, 200, history.list(url.searchParams.get("project") || null)); }
641
+ catch (e) { sendJSON(res, /^no project/.test(e.message) ? 404 : 400, { error: e.message }); }
642
+ return;
643
+ }
644
+ if (p === "/api/versions" && req.method === "POST") {
645
+ let a;
646
+ try { a = JSON.parse((await readBody(req)).toString("utf8") || "{}"); }
647
+ catch { sendJSON(res, 400, { error: "body must be JSON {action, …}" }); return; }
648
+ try {
649
+ const out = history.act(a);
650
+ if (a.action && a.action !== "list" && a.action !== "diff") broadcast("versions", JSON.stringify({ project: out.project, action: a.action }));
651
+ const isOpen = out.project === projects.peekActive();
652
+ if (a.action === "restore" && isOpen) onFsChange(); // the tabs load the restored document
653
+ sendJSON(res, 200, a.action === "restore" ? { ...out, open: isOpen } : out);
654
+ } catch (e) { sendJSON(res, /^no (project|version)/.test(e.message) ? 404 : 400, { error: e.message }); }
655
+ return;
656
+ }
657
+ if (p === "/api/versions/file" && req.method === "GET") {
658
+ try {
659
+ const doc = history.get(url.searchParams.get("project") || null, url.searchParams.get("version"));
660
+ res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store",
661
+ "Content-Disposition": `attachment; filename="${safeName(doc.name || "project")}-v${String(url.searchParams.get("version")).replace(/\D/g, "")}.json"` });
662
+ res.end(JSON.stringify(doc, null, 2));
663
+ } catch (e) { sendJSON(res, /^no (project|version)/.test(e.message) ? 404 : 400, { error: e.message }); }
664
+ return;
665
+ }
666
+ if (p === "/api/projects/backup" && req.method === "GET") {
667
+ try {
668
+ const b = history.backup(url.searchParams.get("id") || null);
669
+ res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store",
670
+ "Content-Disposition": `attachment; filename="${safeName(b.name || "project")}.fablecut-backup.json"` });
671
+ res.end(JSON.stringify(b));
672
+ } catch (e) { sendJSON(res, /^no project/.test(e.message) ? 404 : 400, { error: e.message }); }
673
+ return;
674
+ }
675
+ if (p === "/api/projects/thumb" && (req.method === "GET" || req.method === "PUT")) {
676
+ const id = url.searchParams.get("id") || "";
677
+ if (req.method === "GET") {
678
+ const file = projects.thumbPath(id);
679
+ if (!file) { res.writeHead(404); res.end(); return; }
680
+ res.writeHead(200, { "Content-Type": "image/jpeg", "Cache-Control": "no-store" });
681
+ fs.createReadStream(file).pipe(res);
682
+ return;
683
+ }
684
+ try { sendJSON(res, 200, projects.setThumb(id, await readBody(req))); }
685
+ catch (e) { sendJSON(res, /^no project/.test(e.message) ? 404 : 400, { error: e.message }); }
686
+ return;
687
+ }
588
688
  if (p === "/api/project" && req.method === "PUT") {
589
689
  try {
590
690
  const body = await readBody(req);
@@ -595,6 +695,12 @@ const server = http.createServer(async (req, res) => {
595
695
  ?force=1 skips the check for deliberate overwrites. */
596
696
  let cur = {};
597
697
  try { cur = JSON.parse(fs.readFileSync(PROJECT_FILE, "utf8").replace(new RegExp("^\\uFEFF"), "")); } catch {}
698
+ // a save the editor made for another project (it sends the id it loaded) never lands here
699
+ const meant = req.headers["x-fablecut-project"], open = projects.peekActive();
700
+ if (meant && open && meant !== open) {
701
+ sendJSON(res, 409, { error: "another project is open now", revision: cur.revision || 0, project: open });
702
+ return;
703
+ }
598
704
  if ((data.revision || 0) <= (cur.revision || 0) && url.searchParams.get("force") !== "1") {
599
705
  sendJSON(res, 409, { error: "stale revision — project changed since it was read", revision: cur.revision || 0 });
600
706
  return;
@@ -1268,6 +1374,15 @@ const server = http.createServer(async (req, res) => {
1268
1374
  serveFile(req, res, file);
1269
1375
  });
1270
1376
 
1377
+ /* Auto-save versions of the open project while it changes (every FABLECUT_AUTO_VERSION_MIN
1378
+ minutes at most, default 10), whoever edits it: the editor, an agent, a script. */
1379
+ setInterval(() => {
1380
+ try {
1381
+ const v = history.maybeAuto();
1382
+ if (v) broadcast("versions", JSON.stringify({ project: projects.peekActive(), action: "auto" }));
1383
+ } catch { }
1384
+ }, 60_000).unref();
1385
+
1271
1386
  server.listen(PORT, HOST, () => {
1272
1387
  console.log(`\n FableCut running → http://localhost:${PORT}\n`);
1273
1388
  if (!["127.0.0.1", "localhost", "::1"].includes(HOST))
package/style.css CHANGED
@@ -4086,3 +4086,259 @@ input[type="range"].cq-hue {
4086
4086
  .xq-list .xq-empty { justify-content: center; color: var(--muted, #9a9aaa); border-style: dashed; }
4087
4087
  .dialog.export-dialog p.dlv-tokens { margin-bottom: 8px; }
4088
4088
  .xq-list .xq-actions a.btn { text-decoration: none; }
4089
+
4090
+ /* ── Projects dashboard ── */
4091
+ .topbar-center.clickable { cursor: pointer; }
4092
+ .topbar-center.clickable:hover { color: var(--text); }
4093
+ .dialog.projects-dialog {
4094
+ width: min(1180px, 95vw);
4095
+ height: min(780px, 90vh);
4096
+ padding: 0;
4097
+ display: flex;
4098
+ flex-direction: column;
4099
+ overflow: hidden;
4100
+ outline: none;
4101
+ }
4102
+ .pj-head {
4103
+ display: flex;
4104
+ align-items: center;
4105
+ gap: 8px;
4106
+ padding: 14px 16px 12px 22px;
4107
+ border-bottom: 1px solid var(--border);
4108
+ flex-wrap: wrap;
4109
+ }
4110
+ .pj-head h2 { margin: 0 10px 0 0; }
4111
+ .pj-head .pj-search { flex: 1; min-width: 160px; }
4112
+ .pj-search, .pj-sort, .pj-field input, .pj-field textarea, .pj-field select, .pj-inline input {
4113
+ background: var(--panel-2);
4114
+ border: 1px solid var(--border);
4115
+ color: var(--text);
4116
+ border-radius: 6px;
4117
+ padding: 5px 9px;
4118
+ font: inherit;
4119
+ font-size: 12px;
4120
+ user-select: text;
4121
+ }
4122
+ .pj-search:focus, .pj-sort:focus, .pj-field input:focus, .pj-field textarea:focus, .pj-field select:focus, .pj-inline input:focus {
4123
+ outline: none;
4124
+ border-color: var(--accent);
4125
+ }
4126
+ .pj-views .btn.on, #pjNewBtn.on { border-color: var(--accent); color: #fff; }
4127
+ .pj-close { padding: 4px 9px; font-size: 14px; }
4128
+ .pj-body { flex: 1; display: flex; min-height: 0; }
4129
+ .pj-grid {
4130
+ flex: 1;
4131
+ overflow-y: auto;
4132
+ padding: 16px 18px 22px 22px;
4133
+ display: grid;
4134
+ grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
4135
+ gap: 14px;
4136
+ align-content: start;
4137
+ }
4138
+ .pj-card {
4139
+ display: flex;
4140
+ flex-direction: column;
4141
+ gap: 3px;
4142
+ text-align: left;
4143
+ background: var(--panel-2);
4144
+ border: 1px solid var(--border);
4145
+ border-radius: 9px;
4146
+ padding: 8px 8px 10px;
4147
+ color: var(--text);
4148
+ font: inherit;
4149
+ cursor: pointer;
4150
+ min-width: 0;
4151
+ transition: border-color .12s, background .12s;
4152
+ }
4153
+ .pj-card:hover { border-color: #43434f; background: #26262d; }
4154
+ .pj-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
4155
+ .pj-card.sel { border-color: var(--accent); background: #262536; }
4156
+ .pj-thumb {
4157
+ height: 118px;
4158
+ margin-bottom: 6px;
4159
+ border-radius: 6px;
4160
+ background: #121215;
4161
+ display: flex;
4162
+ align-items: center;
4163
+ justify-content: center;
4164
+ overflow: hidden;
4165
+ }
4166
+ .pj-thumb.big { height: 168px; margin-bottom: 12px; }
4167
+ .pj-frame {
4168
+ max-width: 100%;
4169
+ max-height: 100%;
4170
+ height: 100%;
4171
+ background: #000;
4172
+ display: flex;
4173
+ align-items: center;
4174
+ justify-content: center;
4175
+ overflow: hidden;
4176
+ }
4177
+ .pj-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
4178
+ .pj-frame span { font-size: 11px; color: #5c5c66; font-variant-numeric: tabular-nums; padding: 0 6px; }
4179
+ .pj-card-name {
4180
+ font-size: 13px;
4181
+ color: #ececf1;
4182
+ font-weight: 600;
4183
+ overflow: hidden;
4184
+ text-overflow: ellipsis;
4185
+ white-space: nowrap;
4186
+ }
4187
+ .pj-card-meta, .pj-card-when { font-size: 11px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4188
+ .pj-card-meta { color: #a9a9b3; }
4189
+ .pj-badge {
4190
+ display: inline-block;
4191
+ margin-left: 4px;
4192
+ padding: 0 6px;
4193
+ border-radius: 4px;
4194
+ font: 700 10px/1.6 "Segoe UI", sans-serif;
4195
+ vertical-align: 1px;
4196
+ background: #33305a;
4197
+ color: #cfc8ff;
4198
+ }
4199
+ .pj-empty { grid-column: 1 / -1; padding: 40px 0; text-align: center; font-size: 13px; }
4200
+ .pj-side {
4201
+ width: 330px;
4202
+ flex: none;
4203
+ border-left: 1px solid var(--border);
4204
+ padding: 16px 20px 20px;
4205
+ overflow-y: auto;
4206
+ display: flex;
4207
+ flex-direction: column;
4208
+ gap: 12px;
4209
+ }
4210
+ .pj-side h3 { font-size: 14px; color: #fff; margin: 0; }
4211
+ .pj-side > p { font-size: 12px; }
4212
+ .pj-field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--dim); }
4213
+ .pj-field > span { text-transform: uppercase; letter-spacing: .5px; font-size: 10px; }
4214
+ .pj-field input, .pj-field select { padding: 6px 9px; font-size: 13px; }
4215
+ .pj-field textarea { resize: vertical; min-height: 64px; font-size: 12px; line-height: 1.45; }
4216
+ .pj-sub { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; margin-top: 6px; }
4217
+ .pj-facts {
4218
+ display: grid;
4219
+ grid-template-columns: auto 1fr;
4220
+ gap: 4px 12px;
4221
+ margin: 0;
4222
+ font-size: 12px;
4223
+ }
4224
+ .pj-facts dt { color: var(--dim); }
4225
+ .pj-facts dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
4226
+ .pj-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
4227
+ .pj-actions .btn { font-size: 12px; padding: 5px 11px; }
4228
+ .pj-actions .btn:disabled { opacity: .45; cursor: default; transform: none; }
4229
+ .pj-actions .btn.primary:disabled { filter: saturate(.4); }
4230
+ .btn.danger-ghost { background: transparent; border-color: #5a2a2d; color: #ff9b9e; }
4231
+ .btn.danger-ghost:hover { background: #3a1c1f; border-color: var(--danger); }
4232
+ .btn.danger-ghost[data-armed="1"] { background: var(--danger); border-color: var(--danger); color: #fff; }
4233
+ .pj-inline { display: flex; gap: 6px; }
4234
+ .pj-inline input { flex: 1; min-width: 0; font-size: 12px; }
4235
+ .pj-tpls { display: flex; flex-direction: column; gap: 4px; }
4236
+ .pj-tpl {
4237
+ display: grid;
4238
+ grid-template-columns: 28px 1fr auto auto;
4239
+ align-items: center;
4240
+ gap: 2px 8px;
4241
+ text-align: left;
4242
+ background: var(--panel-2);
4243
+ border: 1px solid var(--border);
4244
+ border-radius: 6px;
4245
+ padding: 6px 8px;
4246
+ color: var(--text);
4247
+ font: inherit;
4248
+ font-size: 12px;
4249
+ cursor: pointer;
4250
+ }
4251
+ .pj-tpl:hover { border-color: #43434f; }
4252
+ .pj-tpl.on { border-color: var(--accent); background: #262536; }
4253
+ .pj-tpl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4254
+ .pj-tpl-meta { font-size: 11px; font-variant-numeric: tabular-nums; }
4255
+ .pj-shape { grid-row: span 1; justify-self: center; display: block; border: 1.5px solid #8b8b93; border-radius: 2px; }
4256
+ .pj-tpl.on .pj-shape { border-color: #cfc8ff; }
4257
+ .pj-tpl-del { font-size: 11px; color: var(--dim); padding: 0 4px; border-radius: 4px; }
4258
+ .pj-tpl-del:hover { color: #ff9b9e; }
4259
+ .pj-tpl-del[data-armed="1"] { color: #fff; background: var(--danger); }
4260
+ @media (max-width: 760px) {
4261
+ .pj-body { flex-direction: column; }
4262
+ .pj-side { width: auto; border-left: 0; border-top: 1px solid var(--border); max-height: 50%; }
4263
+ }
4264
+
4265
+ /* ── Versions (in the Projects dashboard) ── */
4266
+ .pj-grid.versions { display: block; }
4267
+ .ver-view { display: flex; flex-direction: column; gap: 10px; max-width: 860px; }
4268
+ .ver-head { display: flex; align-items: center; gap: 12px; }
4269
+ .ver-head h3 { font-size: 14px; color: #fff; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4270
+ .ver-save { display: flex; gap: 6px; flex-wrap: wrap; }
4271
+ .ver-save input {
4272
+ background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
4273
+ border-radius: 6px; padding: 6px 9px; font: inherit; font-size: 12px; user-select: text;
4274
+ }
4275
+ .ver-save input:focus, .ver-rename:focus { outline: none; border-color: var(--accent); }
4276
+ .ver-save #verName { flex: 1 1 200px; min-width: 0; }
4277
+ .ver-save #verNote { flex: 2 1 260px; min-width: 0; }
4278
+ .ver-hint { font-size: 11px; margin: 0; }
4279
+ .ver-row {
4280
+ border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2);
4281
+ padding: 9px 11px; display: flex; flex-direction: column; gap: 6px;
4282
+ }
4283
+ .ver-row.final { border-color: #8a6d1f; }
4284
+ .ver-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
4285
+ .ver-num { font: 700 11px/1.6 "Segoe UI", sans-serif; color: #cfc8ff; font-variant-numeric: tabular-nums; }
4286
+ .ver-name { color: #ececf1; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
4287
+ .ver-rename {
4288
+ background: var(--panel); border: 1px solid var(--border); color: var(--text);
4289
+ border-radius: 5px; padding: 2px 6px; font: inherit; font-size: 12px; width: 32ch; user-select: text;
4290
+ }
4291
+ .ver-badge { font: 700 10px/1.6 "Segoe UI", sans-serif; padding: 0 6px; border-radius: 4px; background: #2a2a33; color: var(--dim); }
4292
+ .ver-badge.final { background: #4a3a10; color: #ffd98a; }
4293
+ .ver-meta { font-size: 11px; font-variant-numeric: tabular-nums; margin-left: auto; }
4294
+ .ver-note { font-size: 12px; color: #b9b9c2; white-space: pre-wrap; overflow-wrap: anywhere; }
4295
+ .ver-diff { margin: 0; padding: 6px 10px 6px 24px; background: #17171b; border-radius: 6px; font-size: 12px; color: #c9c9d1; }
4296
+ .ver-diff li { margin: 2px 0; overflow-wrap: anywhere; }
4297
+ .ver-actions { display: flex; gap: 5px; flex-wrap: wrap; }
4298
+ .ver-actions .btn.tiny { font-size: 11px; }
4299
+ .ver-actions .btn:disabled { opacity: .45; cursor: default; }
4300
+ a.btn { text-decoration: none; }
4301
+
4302
+ /* ── Sequences: the menu at the left of the timeline toolbar ── */
4303
+ .seq-btn {
4304
+ max-width: 220px;
4305
+ gap: 4px;
4306
+ margin-right: 6px;
4307
+ }
4308
+ .seq-btn .seq-name {
4309
+ overflow: hidden;
4310
+ text-overflow: ellipsis;
4311
+ white-space: nowrap;
4312
+ max-width: 150px;
4313
+ font-weight: 600;
4314
+ }
4315
+ .seq-btn .seq-count:not(:empty) {
4316
+ padding: 0 5px;
4317
+ border-radius: 8px;
4318
+ background: #ffffff1f;
4319
+ font-size: 10px;
4320
+ line-height: 15px;
4321
+ }
4322
+ .seq-menu { min-width: 260px; }
4323
+ .seq-menu .ctx-item .seq-check {
4324
+ display: inline-block;
4325
+ width: 14px;
4326
+ color: var(--accent);
4327
+ }
4328
+ .seq-menu .ctx-item .seq-row-name {
4329
+ flex: 1;
4330
+ overflow: hidden;
4331
+ text-overflow: ellipsis;
4332
+ white-space: nowrap;
4333
+ max-width: 220px;
4334
+ }
4335
+ .seq-menu .ctx-item kbd { font-variant-numeric: tabular-nums; }
4336
+ .seq-new { min-width: 300px; }
4337
+ .seq-new select.bin-pop-input { width: 100%; }
4338
+ .seq-new .seq-new-copy {
4339
+ display: flex;
4340
+ align-items: center;
4341
+ gap: 6px;
4342
+ margin: 8px 0 2px;
4343
+ font-size: 12px;
4344
+ }