Text to vertical video in 100+ styles: AI codes each scene (HTML/SVG/WebGL), renders a 9:16 MP4 with music and English/Vietnamese voice. MCP, CLI and REST for AI agents.
Studio: xem trước giống bản xuất, timeline đọc được chữ, cảm ứng, trả lại số trên đồ hoạ
Lumtek5763ca4e44c4
diff --git a/server/public/i18n.js b/server/public/i18n.jsindex f884666..4c98523 100644--- a/server/public/i18n.js+++ b/server/public/i18n.js@@ -683,6 +683,7 @@'st.addZoom': 'Thêm zoom tại đầu phát','st.zoomIn': 'Phóng to timeline','st.zoomOut': 'Thu nhỏ timeline',+ 'st.fitAll': 'Vừa khung: xem toàn bộ video','st.tlZoom': 'Độ phóng timeline (Ctrl + lăn chuột)','st.noMusic': 'Không nhạc','st.lineText': 'Sửa chữ dòng phụ đề',@@ -711,6 +712,8 @@'st.rFix': 'AI sửa', 'st.rFig': 'Số','st.rKeep': 'Giữ', 'st.rEdit': 'Sửa', 'st.rRevert': 'Trả lại','st.rNoRevert': 'Không trả lại được: dòng không còn chữ AI đã sửa',+ 'st.rNoGfx': 'Đồ hoạ có số này không còn trong bản (đã bị bỏ khi dựng).',+ 'st.rGfxCell': 'Ô {g}: “{cell}” → Trả lại thành “{to}” (số nghe được)','st.rStatus.keep': 'Đã giữ', 'st.rStatus.edit': 'Đã mở sửa', 'st.rStatus.revert': 'Đã trả lại chữ gốc','st.uploadMusic': 'Tải bài lên','st.gain': 'Âm lượng nhạc',@@ -1423,6 +1426,7 @@'st.addZoom': 'Add zoom at playhead','st.zoomIn': 'Zoom timeline in','st.zoomOut': 'Zoom timeline out',+ 'st.fitAll': 'Fit: show the whole video','st.tlZoom': 'Timeline zoom (Ctrl + wheel)','st.noMusic': 'No music','st.lineText': 'Edit caption text',@@ -1451,6 +1455,8 @@'st.rFix': 'AI fix', 'st.rFig': 'Number','st.rKeep': 'Keep', 'st.rEdit': 'Edit', 'st.rRevert': 'Revert','st.rNoRevert': 'Can’t revert: the line no longer has the AI-fixed words',+ 'st.rNoGfx': 'The graphic with this number is not in this version (dropped at build).',+ 'st.rGfxCell': '{g} cell: “{cell}” → Revert to “{to}” (what was heard)','st.rStatus.keep': 'Kept', 'st.rStatus.edit': 'Opened for editing', 'st.rStatus.revert': 'Reverted to what was heard','st.uploadMusic': 'Upload a track','st.gain': 'Music volume',diff --git a/server/public/studio/gfx-frame.html b/server/public/studio/gfx-frame.htmlnew file mode 100644index 0000000..0cc64ad--- /dev/null+++ b/server/public/studio/gfx-frame.html@@ -0,0 +1,19 @@+<!doctype html>+<html lang="vi">+<head>+<meta charset="UTF-8" />+<meta name="color-scheme" content="dark" />+<title>gfx</title>+<link rel="stylesheet" href="/fonts/fonts.css" />+<style>+ html, body { margin: 0; width: 1080px; height: 1920px; overflow: hidden; background: transparent; }+ #root { position: relative; width: 1080px; height: 1920px; overflow: hidden; background: transparent; }+</style>+<style id="gcss"></style>+</head>+<body>+<div id="root"></div>+<script src="/edit-runtime/gfx.js"></script>+<script src="/studio/gfx-frame.js"></script>+</body>+</html>diff --git a/server/public/studio/gfx-frame.js b/server/public/studio/gfx-frame.jsnew file mode 100644index 0000000..d217223--- /dev/null+++ b/server/public/studio/gfx-frame.js@@ -0,0 +1,23 @@+// Khung xem trước đồ hoạ của Studio: chạy trong <iframe sandbox="allow-scripts"> (origin rỗng: không đọc được cookie,+// API, trang cha). Nhận cảnh từ trang cha qua postMessage: {type:'scene', css, html, G} (HTML/CSS do edit/graphics.mjs+// dựng phía server, chữ đã escape — giống hệt lớp HyperFrames) rồi {type:'t', t} để vẽ đúng khung (gfxRender thuần theo t).+(() => {+ let G = []; let last = 0;+ const root = document.getElementById('root');+ const css = document.getElementById('gcss');+ window.addEventListener('message', (e) => {+ if (e.source !== window.parent) return; // chỉ nhận từ trang chứa khung+ const m = e.data;+ if (!m || typeof m !== 'object') return;+ if (m.type === 'scene' && typeof m.html === 'string' && typeof m.css === 'string' && Array.isArray(m.G)) {+ css.textContent = m.css;+ root.innerHTML = m.html; // trong sandbox; HTML từ server (đã escape) — không có dữ liệu chạy được ra ngoài khung+ G = m.G;+ try { window.gfxRender(last, G); } catch { /* cảnh chưa khớp */ }+ } else if (m.type === 't' && Number.isFinite(m.t)) {+ last = m.t;+ try { window.gfxRender(m.t, G); } catch { /* bỏ qua */ }+ }+ });+ window.parent.postMessage({ type: 'gfx-ready' }, '*');+})();diff --git a/server/public/studio/inspector.js b/server/public/studio/inspector.jsindex 5af28c5..bfd8fc0 100644--- a/server/public/studio/inspector.js+++ b/server/public/studio/inspector.js@@ -208,7 +208,13 @@ export class Inspector {const keep = tx('button', 'btn ghost', 'st.rKeep', { type: 'button' }); keep.addEventListener('click', () => R.resolve(cur, 'keep'));const fix = tx('button', 'btn ghost', 'st.rEdit', { type: 'button' }); fix.addEventListener('click', () => R.edit(cur));const back = tx('button', 'btn warn', 'st.rRevert', { type: 'button' }); back.addEventListener('click', () => R.revert(cur));- back.disabled = !R.canRevert(cur) || !!this.ctx.store.view?.readOnly; if (back.disabled) back.title = t('st.rNoRevert');+ back.disabled = !R.canRevert(cur) || !!this.ctx.store.view?.readOnly;+ if (back.disabled) back.title = t(cur.kind === 'fig' && !R.figTarget(cur) ? 'st.rNoGfx' : 'st.rNoRevert');+ if (cur.kind === 'fig') {+ const tg = R.figTarget(cur);+ const v = tg && R.figRevertValue(cur, tg);+ card.append(el('p', 'st-rwhy', tg ? t('st.rGfxCell', { g: t('gfx.' + tg.g.type), cell: String(tg.cur), to: v == null ? '–' : String(v) }) : t('st.rNoGfx')));+ }fix.disabled = !!this.ctx.store.view?.readOnly;acts.append(keep, fix, back);card.append(acts);diff --git a/server/public/studio/player.js b/server/public/studio/player.jsindex 8bad5e0..972399c 100644--- a/server/public/studio/player.js+++ b/server/public/studio/player.js@@ -1,243 +1,345 @@-// Player giữa Studio: video nền KHÔNG chữ (base.mp4) + lớp HTML vẽ phụ đề theo look đang chọn, thẻ đồ hoạ gần đúng,-// zoom xem trước bằng CSS transform, nhạc phát song song (<audio>, âm lượng theo dB, tự hạ khi có lời).-// Không có base (bản cũ / chưa dựng lại nền) hoặc bấm "Bản xuất" → phát thẳng MP4 đã xuất, không vẽ đè.-import { el, tx, icon, iconBtn, fmtT, tokens, clamp, t } from './util.js';--const FPS = 30;-const ease = (x) => { x = clamp(x, 0, 1); return x * x * (3 - 2 * x); };-/** Như lumedit Zooms.scale_at: punch (vào 0,08 s, giữ, ra 0,12 s) / push (đẩy chậm, lùi 0,3 s cuối). */-export function zoomScale(zs, tt) {- for (const z of zs) {- if (tt < z.at || tt >= z.at + z.dur) continue;- const u = tt - z.at; let k;- if (z.kind === 'punch') { k = u < 0.08 ? ease(u / 0.08) : 1; if (u > z.dur - 0.12) k = Math.min(k, ease((z.dur - u) / 0.12)); }- else { const back = Math.min(0.3, z.dur * 0.2); k = u < z.dur - back ? ease(u / (z.dur - back)) : ease((z.dur - u) / back); }- return 1 + (z.scale - 1) * k;- }- return 1;-}--export class Player {- constructor(ctx) {- this.ctx = ctx; // {store, onTime(t), onPlay(bool), getSel()}- this.root = el('section', 'st-stage');- this.box = el('div', 'st-vid');- this.video = el('video', null, null, { playsinline: true, preload: 'auto' });- this.video.playsInline = true;- this.zoomWrap = el('div', 'st-zw'); this.zoomWrap.append(this.video);- this.gfxLayer = el('div', 'st-gfx', null, { 'aria-hidden': 'true' });- this.capLayer = el('div', 'st-cap', null, { 'aria-hidden': 'true' });- this.capText = el('div', 'st-capt'); this.capLayer.append(this.capText);- this.capSel = el('div', 'st-capsel'); this.capSel.hidden = true;- this.badge = el('div', 'st-vbadge'); this.badge.hidden = true;- this.box.append(this.zoomWrap, this.gfxLayer, this.capLayer, this.capSel, this.badge);- this.audio = el('audio', null, null, { preload: 'auto' });- // điều khiển- const ctrl = el('div', 'st-ctrl');- this.tm = el('span', 'st-time mono');- this.tmNow = el('b', null, '0:00.0'); this.tmDur = el('span', null, '0:00.0');- this.tm.append(this.tmNow, ' / ', this.tmDur);- this.bPrev = iconBtn('prev', 'st.prevFrame', 'st-tbtn');- this.bPlay = el('button', 'st-play', null, { type: 'button' });- this.bNext = iconBtn('next', 'st.nextFrame', 'st-tbtn');- this.bRatio = el('span', 'st-pill mono', '9:16');- this.bOut = tx('button', 'st-pill st-outsw', 'st.viewOut', { type: 'button', 'aria-pressed': 'false' });- ctrl.append(this.tm, this.bPrev, this.bPlay, this.bNext, this.bRatio, this.bOut);- this.root.append(this.box, ctrl, this.audio);- this.paintPlay();- this.mode = 'edit'; // 'edit' (nền + vẽ đè) | 'out' (MP4 đã xuất)- this.src = { base: null, out: null };- this.lastCap = null; this.lastGfx = ''; this.raf = 0; this.musicDur = 0;- this.bPlay.addEventListener('click', () => this.toggle());- this.bPrev.addEventListener('click', () => this.step(-1 / FPS));- this.bNext.addEventListener('click', () => this.step(1 / FPS));- this.bOut.addEventListener('click', () => this.setMode(this.mode === 'out' ? 'edit' : 'out'));- this.box.addEventListener('click', () => this.toggle());- const v = this.video;- v.addEventListener('play', () => { this.paintPlay(); this.syncAudio(true); this.loop(); this.ctx.onPlay?.(true); });- v.addEventListener('pause', () => { this.paintPlay(); this.audio.pause(); this.ctx.onPlay?.(false); this.tick(); });- v.addEventListener('seeked', () => { this.syncAudio(true); this.tick(); });- v.addEventListener('loadedmetadata', () => { this.tick(); this.fit(); });- v.addEventListener('ended', () => this.paintPlay());- this.audio.addEventListener('loadedmetadata', () => { this.musicDur = this.audio.duration || 0; this.syncAudio(true); });- this.ro = new ResizeObserver(() => this.fit());- this.ro.observe(this.root);- }- get time() { return this.video.currentTime || 0; }- get duration() { return this.ctx.store.view?.duration || this.video.duration || 0; }- paintPlay() {- const playing = !this.video.paused && !this.video.ended;- this.bPlay.replaceChildren(icon(playing ? 'pause' : 'play'));- this.bPlay.setAttribute('aria-label', t(playing ? 'st.pause' : 'st.play'));- this.bPlay.title = `${t(playing ? 'st.pause' : 'st.play')} (Space)`;- }- /** Nạp nguồn: base (không chữ) nếu có, out (MP4 đã xuất). */- setSources({ base, out, music }) {- this.src = { base, out };- this.bOut.hidden = !base || !out;- this.setMode(base && this.mode !== 'out' ? 'edit' : 'out', true);- this.setMusic(music);- }- setMode(m, force) {- if (m === 'edit' && !this.src.base) m = 'out';- if (m === this.mode && !force) return;- const at = this.time; const was = !this.video.paused;- this.mode = m;- const url = m === 'edit' ? this.src.base : this.src.out;- this.bOut.setAttribute('aria-pressed', String(m === 'out'));- this.box.classList.toggle('raw', m === 'out');- if (url && this.video.getAttribute('src') !== url) {- this.video.src = url;- this.video.addEventListener('loadedmetadata', () => { this.video.currentTime = Math.min(at, this.video.duration || at); if (was) this.video.play().catch(() => {}); }, { once: true });- }- this.badge.hidden = m === 'edit' || !this.src.base;- this.badge.textContent = t('st.viewingOut'); this.badge.dataset.i18n = 'st.viewingOut';- this.lastCap = null; this.lastGfx = ''; this.tick();- }- setMusic(url) {- if (!url) { this.audio.pause(); this.audio.removeAttribute('src'); this.audio.load(); this.musicUrl = null; return; }- if (url === this.musicUrl) return;- this.musicUrl = url; this.audio.src = url; this.audio.load();- }- /** Nhả file (Windows giữ khoá file đang phát): trước khi server ghi đè base.mp4. */- release() {- this.video.pause(); this.video.removeAttribute('src'); this.video.load();- this.audio.pause(); this.audio.removeAttribute('src'); this.audio.load(); this.musicUrl = null;- this.src = { base: null, out: null };- }- toggle() { if (!this.video.getAttribute('src')) return; if (this.video.paused || this.video.ended) this.video.play().catch(() => {}); else this.video.pause(); }- pause() { this.video.pause(); }- seek(tt) {- const d = this.duration;- const x = clamp(tt, 0, Math.max(0, d - 1 / FPS / 2));- if (Number.isFinite(x)) this.video.currentTime = x;- this.tick(x);- }- step(dt) { this.pause(); this.seek(Math.round((this.time + dt) * FPS) / FPS); }-- // ---- nhạc song song: âm lượng theo dB (gần đúng), tự hạ khi có lời ----- musicVolume(tt) {- const m = this.ctx.store.doc?.music; if (!m || m.source === 'none' || this.mode !== 'edit') return 0;- let db = m.gainDb + 12; // nền tiếng gốc ~ −12 dBFS- if (m.duck && this.ctx.store.lineAt(tt) >= 0) db -= this.ctx.store.view?.music?.duckDb || 10;- const d = this.duration; if (m.fadeOut > 0 && tt > d - m.fadeOut) db += 20 * Math.log10(Math.max(0.001, (d - tt) / m.fadeOut));- return clamp(10 ** (db / 20), 0, 1);- }- syncAudio(hard) {- const a = this.audio; const m = this.ctx.store.doc?.music;- if (!this.musicUrl || !m || m.source === 'none' || this.mode !== 'edit') { a.pause(); return; }- const md = this.musicDur || a.duration || 0; if (!md) return;- const want = (m.start + this.time) % md;- if (hard || Math.abs(a.currentTime - want) > 0.25) a.currentTime = want;- a.volume = this.musicVolume(this.time);- const vg = this.ctx.store.doc?.voice?.gainDb || 0;- this.video.volume = clamp(10 ** (Math.min(0, vg) / 20), 0, 1);- if (!this.video.paused && a.paused) a.play().catch(() => {});- }- loop() {- cancelAnimationFrame(this.raf);- const f = () => { this.tick(); if (!this.video.paused && !this.video.ended) { this.syncAudio(false); this.raf = requestAnimationFrame(f); } };- this.raf = requestAnimationFrame(f);- }- /** Vẽ mỗi khung: giờ, lớp chữ (chỉ khi đổi dòng), zoom CSS, đồ hoạ. */- tick(at) {- const tt = at ?? this.time;- this.tmNow.textContent = fmtT(tt); this.tmDur.textContent = fmtT(this.duration);- this.ctx.onTime?.(tt);- const edit = this.mode === 'edit';- const doc = this.ctx.store.doc;- // zoom: nền đã có zoom của bản gốc → chỉ zoom mới/đổi mới phóng thêm bằng CSS- let s = 1;- if (edit && doc) {- const orig = this.ctx.store.orig?.zooms || [];- const fresh = doc.zooms.filter((z) => !orig.some((o) => o.n === z.n && Math.abs(o.at - z.at) < 0.005 && o.dur === z.dur && o.scale === z.scale && o.kind === z.kind));- s = zoomScale(fresh, tt);- }- this.zoomWrap.style.transform = s > 1.0005 ? `scale(${s.toFixed(4)})` : '';- this.paintCap(edit && doc ? doc.lines.findIndex((l) => tt >= l.start && tt < l.end) : -1);- this.paintGfx(edit && doc ? doc.gfx.filter((g) => tt >= g.at && tt < g.until) : []);- this.paintSel();- }- /** Khung chữ theo look: cỡ chữ (px trên 1080) × tỉ lệ khung đang hiện. */- fit() {- const w = this.box.clientWidth || 1;- this.k = w / 1080;- this.box.style.setProperty('--k', String(this.k));- this.lastCap = null; this.lastGfx = '';- this.tick();- }- lookCss() {- const s = this.ctx.store; const id = s.doc?.look;- return s.view?.captions.looks.find((l) => l.id === id)?.css || null;- }- paintCap(idx) {- const s = this.ctx.store; const L = s.doc?.lines || [];- const line = L[idx];- const look = this.lookCss();- const key = line ? `${line.u}|${line.text}|${s.doc.look}|${s.doc.hi}|${this.k}` : '';- if (key === this.lastCap) return;- this.lastCap = key;- const box = this.capText;- if (!line || !look) { box.replaceChildren(); box.hidden = true; return; }- box.hidden = false;- const k = this.k || 0.25;- box.style.fontFamily = `${look.font}, 'Be Vietnam Pro', sans-serif`;- box.style.fontWeight = String(look.weight);- box.style.fontSize = `${Math.round(look.size * k * 10) / 10}px`;- box.style.color = look.color;- box.style.textTransform = look.upper ? 'uppercase' : 'none';- box.style.top = `${look.cy * 100}%`;- const sw = (look.stroke ?? 8) * k;- box.style.webkitTextStroke = look.box ? '0' : `${sw.toFixed(2)}px rgba(0,0,0,.9)`;- box.style.textShadow = look.shadow || `0 ${(4 * k).toFixed(1)}px ${(14 * k).toFixed(1)}px rgba(0,0,0,.55)`;- box.classList.toggle('boxed', !!look.box);- box.style.background = look.box ? look.box.bg : '';- const kids = [];- if (look.box?.tag) { const tg = el('span', 'tag', look.box.tag); tg.style.background = look.box.tagBg || '#E8202A'; kids.push(tg); }- const ws = tokens(line.text);- ws.forEach((w, i) => {- if (i) kids.push(' ');- const sp = el('span', null, w.w);- if (w.hi && s.doc.hi) sp.style.color = look.hi;- kids.push(sp);- });- box.replaceChildren(...kids);- }- /** Khung chọn quanh dòng chữ đang chọn (như mẫu) — chỉ khi dòng đó đang hiện. */- paintSel() {- const sel = this.ctx.getSel?.();- const show = this.mode === 'edit' && sel?.kind === 'cap' && !this.capText.hidden && (this.lastCap || '').startsWith(sel.u + '|');- this.capSel.hidden = !show;- if (!show) return;- const b = this.box.getBoundingClientRect(); const r = this.capText.getBoundingClientRect();- this.capSel.style.transform = `translate(${(r.left - b.left - 6).toFixed(1)}px, ${(r.top - b.top - 4).toFixed(1)}px)`;- this.capSel.style.width = `${(r.width + 12).toFixed(1)}px`; this.capSel.style.height = `${(r.height + 8).toFixed(1)}px`;- }- /** Thẻ đồ hoạ gần đúng (bản ra mới vẽ bằng HyperFrames): khung tối, tiêu đề, các dòng. */- paintGfx(list) {- const key = list.map((g) => `${g.id}|${JSON.stringify(g.data)}|${JSON.stringify(g.box)}`).join('#') + '|' + this.k;- if (key === this.lastGfx) return;- this.lastGfx = key;- const k = this.k || 0.25;- this.gfxLayer.replaceChildren(...list.map((g) => {- const b = g.box || { x: 120, y: 200, w: 840, h: 300, scale: 1 };- const c = el('div', 'st-gcard st-g-' + g.type);- c.style.transform = `translate(${(b.x * k).toFixed(1)}px, ${(b.y * k).toFixed(1)}px)`;- c.style.width = `${(b.w * k).toFixed(1)}px`; c.style.minHeight = `${(b.h * k * 0.6).toFixed(1)}px`;- c.style.fontSize = `${(30 * b.scale * k).toFixed(2)}px`;- const d = g.data || {};- if (d.title || d.kicker) {- const h = el('div', 'h'); if (d.kicker) h.append(el('span', 'kick', d.kicker + ' '));- h.append(d.title || ''); if (d.unit) h.append(el('span', 'u', ' · ' + d.unit)); c.append(h);- }- const big = (txt) => c.append(el('div', 'big', txt));- if (g.type === 'sticker') big(d.text || '');- if (g.type === 'counter' || g.type === 'price_tag') { if (d.label) c.append(el('div', 'lbl', d.label)); big(`${d.prefix || ''}${d.value ?? ''}${d.suffix ? ' ' + d.suffix : ''}`); }- for (const r of d.rows || []) { const row = el('div', 'row'); row.append(el('span', null, r.label ?? ''), el('b', null, r.value ?? (r.a != null ? `${r.a} · ${r.b}` : ''))); c.append(row); }- for (const r of d.items || []) { const row = el('div', 'row'); row.append(el('span', null, (r.ok === false ? '✕ ' : r.ok ? '✓ ' : '') + (r.text ?? r.label ?? '')), el('b', null, r.value != null ? String(r.value) : '')); c.append(row); }- for (const r of d.points || []) { const row = el('div', 'row'); row.append(el('span', null, r.label ?? ''), el('b', null, String(r.value ?? ''))); c.append(row); }- return c;- }));- }- destroy() { cancelAnimationFrame(this.raf); this.ro.disconnect(); this.release(); }-}+// Player giữa Studio — xem trước tức thì, không render:+// · nền SẠCH (preview-clean.mp4: đã cắt + khung, CHƯA zoom/kính/chữ) → MỌI zoom (cũ lẫn mới) chạy bằng CSS transform+// theo EDL đang sửa, cùng công thức lumedit Zooms (punch/push, tâm đầu lúc zoom bắt đầu, khung đặt 0,42 chiều cao);+// · phụ đề HTML theo đúng tham số LOOKS (cỡ, stroke, bóng, cy, chữ hoa, bỏ dấu câu cuối) + hiệu ứng vào (GSAP ease+// tương đương) + karaoke theo giờ từng chữ — tính thuần theo t nên tua tới đâu đúng tới đó;+// · đồ hoạ: chính HTML/CSS/runtime của lớp HyperFrames trong <iframe sandbox="allow-scripts"> (postMessage), kính mờ+// dưới thẻ bằng backdrop-filter;+// · nhạc phát song song (<audio>, âm lượng theo dB, tự hạ khi có lời).+// Không có nền sạch → nền cũ (base.mp4, đã có zoom gốc: chỉ zoom mới chạy CSS). "Bản xuất" → phát MP4 đã xuất, không vẽ đè.+import { el, tx, icon, iconBtn, fmtT, tokens, clamp, t } from './util.js';++const FPS = 30; const W = 1080; const H = 1920;+const ease = (x) => { x = clamp(x, 0, 1); return x * x * (3 - 2 * x); };+// GSAP: powerN.out = 1 − (1 − x)^(N+1); back.out(c)+const pOut = (n) => (x) => 1 - (1 - clamp(x, 0, 1)) ** (n + 1);+const pIn = (n) => (x) => clamp(x, 0, 1) ** (n + 1);+const backOut = (c) => (x) => { x = clamp(x, 0, 1); return 1 + (c + 1) * (x - 1) ** 3 + c * (x - 1) ** 2; };++/** Như lumedit Zooms.scale_at: punch (vào 0,08 s, giữ, ra 0,12 s) / push (đẩy chậm, lùi 0,3 s cuối). Trả {s, z}. */+export function zoomAt(zs, tt) {+ for (const z of zs) {+ if (tt < z.at || tt >= z.at + z.dur) continue;+ const u = tt - z.at; let k;+ if (z.kind === 'punch') { k = u < 0.08 ? ease(u / 0.08) : 1; if (u > z.dur - 0.12) k = Math.min(k, ease((z.dur - u) / 0.12)); }+ else { const back = Math.min(0.3, z.dur * 0.2); k = u < z.dur - back ? ease(u / (z.dur - back)) : ease((z.dur - u) / back); }+ return { s: 1 + (z.scale - 1) * k, z };+ }+ return { s: 1, z: null };+}+export const zoomScale = (zs, tt) => zoomAt(zs, tt).s;++export class Player {+ constructor(ctx) {+ this.ctx = ctx; // {store, onTime(t), onPlay(bool), getSel(), gfxScene()}+ this.root = el('section', 'st-stage');+ this.box = el('div', 'st-vid');+ this.video = el('video', null, null, { playsinline: true, preload: 'auto' });+ this.video.playsInline = true;+ this.zoomWrap = el('div', 'st-zw'); this.zoomWrap.append(this.video);+ this.glassLayer = el('div', 'st-glass', null, { 'aria-hidden': 'true' });+ this.frame = el('iframe', 'st-gframe', null, { sandbox: 'allow-scripts', src: '/studio/gfx-frame.html', tabindex: '-1', 'aria-hidden': 'true', title: 'gfx' });+ this.capLayer = el('div', 'st-cap', null, { 'aria-hidden': 'true' });+ this.capText = el('div', 'st-capt'); this.capLayer.append(this.capText);+ this.capSel = el('div', 'st-capsel'); this.capSel.hidden = true;+ this.badge = el('div', 'st-vbadge'); this.badge.hidden = true;+ this.box.append(this.zoomWrap, this.glassLayer, this.frame, this.capLayer, this.capSel, this.badge);+ this.audio = el('audio', null, null, { preload: 'auto' });+ const ctrl = el('div', 'st-ctrl');+ this.tm = el('span', 'st-time mono');+ this.tmNow = el('b', null, '0:00.0'); this.tmDur = el('span', null, '0:00.0');+ this.tm.append(this.tmNow, ' / ', this.tmDur);+ this.bPrev = iconBtn('prev', 'st.prevFrame', 'st-tbtn');+ this.bPlay = el('button', 'st-play', null, { type: 'button' });+ this.bNext = iconBtn('next', 'st.nextFrame', 'st-tbtn');+ this.bRatio = el('span', 'st-pill mono', '9:16');+ this.bOut = tx('button', 'st-pill st-outsw', 'st.viewOut', { type: 'button', 'aria-pressed': 'false' });+ ctrl.append(this.tm, this.bPrev, this.bPlay, this.bNext, this.bRatio, this.bOut);+ this.root.append(this.box, ctrl, this.audio);+ this.paintPlay();+ this.mode = 'edit'; // 'edit' (nền + vẽ đè) | 'out' (MP4 đã xuất)+ this.src = { clean: null, base: null, out: null };+ this.cap = null; this.raf = 0; this.musicDur = 0; this.frameReady = false; this.gfxIds = []; this.lastGlass = '';+ this.bPlay.addEventListener('click', () => this.toggle());+ this.bPrev.addEventListener('click', () => this.step(-1 / FPS));+ this.bNext.addEventListener('click', () => this.step(1 / FPS));+ this.bOut.addEventListener('click', () => this.setMode(this.mode === 'out' ? 'edit' : 'out'));+ this.box.addEventListener('click', () => this.toggle());+ const v = this.video;+ v.addEventListener('play', () => { this.paintPlay(); this.syncAudio(true); this.loop(); this.ctx.onPlay?.(true); });+ v.addEventListener('pause', () => { this.paintPlay(); this.audio.pause(); this.ctx.onPlay?.(false); this.tick(); });+ v.addEventListener('seeked', () => { this.syncAudio(true); this.tick(); });+ v.addEventListener('loadedmetadata', () => { this.tick(); this.fit(); });+ v.addEventListener('ended', () => this.paintPlay());+ this.audio.addEventListener('loadedmetadata', () => { this.musicDur = this.audio.duration || 0; this.syncAudio(true); });+ window.addEventListener('message', (e) => {+ if (e.source !== this.frame.contentWindow || e.data?.type !== 'gfx-ready') return;+ this.frameReady = true; this.postScene(); this.tick();+ });+ this.ro = new ResizeObserver(() => this.fit());+ this.ro.observe(this.root);+ }+ get time() { return this.video.currentTime || 0; }+ get duration() { return this.ctx.store.view?.duration || this.video.duration || 0; }+ /** Nguồn đang vẽ đè: 'clean' (mọi zoom CSS) | 'base' (zoom gốc đã nằm trong nền) | null (MP4 đã xuất). */+ get layerSrc() { return this.mode !== 'edit' ? null : this.src.clean ? 'clean' : this.src.base ? 'base' : null; }+ paintPlay() {+ const playing = !this.video.paused && !this.video.ended;+ this.bPlay.replaceChildren(icon(playing ? 'pause' : 'play'));+ this.bPlay.setAttribute('aria-label', t(playing ? 'st.pause' : 'st.play'));+ this.bPlay.title = `${t(playing ? 'st.pause' : 'st.play')} (Space)`;+ }+ setSources({ clean = null, base = null, out, music }) {+ this.src = { clean, base, out };+ const edit = clean || base;+ this.bOut.hidden = !edit || !out;+ this.setMode(edit && this.mode !== 'out' ? 'edit' : 'out', true);+ if (music !== undefined) this.setMusic(music);+ }+ setMode(m, force) {+ if (m === 'edit' && !this.src.clean && !this.src.base) m = 'out';+ if (m === this.mode && !force) return;+ const at = this.time; const was = !this.video.paused;+ this.mode = m;+ const url = m === 'edit' ? this.src.clean || this.src.base : this.src.out;+ this.bOut.setAttribute('aria-pressed', String(m === 'out'));+ this.box.classList.toggle('raw', m === 'out');+ if (url && this.video.getAttribute('src') !== url) {+ this.video.src = url;+ this.video.addEventListener('loadedmetadata', () => { this.video.currentTime = Math.min(at, this.video.duration || at); if (was) this.video.play().catch(() => {}); }, { once: true });+ }+ this.badge.hidden = m === 'edit' || !(this.src.clean || this.src.base);+ this.badge.textContent = t('st.viewingOut'); this.badge.dataset.i18n = 'st.viewingOut';+ this.cap = null; this.lastGlass = ''; this.tick();+ }+ setMusic(url) {+ if (!url) { this.audio.pause(); this.audio.removeAttribute('src'); this.audio.load(); this.musicUrl = null; return; }+ if (url === this.musicUrl) return;+ this.musicUrl = url; this.audio.src = url; this.audio.load();+ }+ /** Nhả file (Windows giữ khoá file đang phát): trước khi server ghi đè base.mp4 / bản sạch. */+ release() {+ this.video.pause(); this.video.removeAttribute('src'); this.video.load();+ this.audio.pause(); this.audio.removeAttribute('src'); this.audio.load(); this.musicUrl = null;+ this.src = { clean: null, base: null, out: null };+ }+ toggle() { if (!this.video.getAttribute('src')) return; if (this.video.paused || this.video.ended) this.video.play().catch(() => {}); else this.video.pause(); }+ pause() { this.video.pause(); }+ seek(tt) {+ const d = this.duration;+ const x = clamp(tt, 0, Math.max(0, d - 1 / FPS / 2));+ if (Number.isFinite(x)) this.video.currentTime = x;+ this.tick(x);+ }+ step(dt) { this.pause(); this.seek(Math.round((this.time + dt) * FPS) / FPS); }++ // ---- nhạc song song: âm lượng theo dB (gần đúng), tự hạ khi có lời ----+ musicVolume(tt) {+ const m = this.ctx.store.doc?.music; if (!m || m.source === 'none' || this.mode !== 'edit') return 0;+ let db = m.gainDb + 12; // nền tiếng gốc ~ −12 dBFS+ if (m.duck && this.ctx.store.lineAt(tt) >= 0) db -= this.ctx.store.view?.music?.duckDb || 10;+ const d = this.duration; if (m.fadeOut > 0 && tt > d - m.fadeOut) db += 20 * Math.log10(Math.max(0.001, (d - tt) / m.fadeOut));+ return clamp(10 ** (db / 20), 0, 1);+ }+ syncAudio(hard) {+ const a = this.audio; const m = this.ctx.store.doc?.music;+ if (!this.musicUrl || !m || m.source === 'none' || this.mode !== 'edit') { a.pause(); return; }+ const md = this.musicDur || a.duration || 0; if (!md) return;+ const want = (m.start + this.time) % md;+ if (hard || Math.abs(a.currentTime - want) > 0.25) a.currentTime = want;+ a.volume = this.musicVolume(this.time);+ const vg = this.ctx.store.doc?.voice?.gainDb || 0;+ this.video.volume = clamp(10 ** (Math.min(0, vg) / 20), 0, 1);+ if (!this.video.paused && a.paused) a.play().catch(() => {});+ }+ loop() {+ cancelAnimationFrame(this.raf);+ const f = () => { this.tick(); if (!this.video.paused && !this.video.ended) { this.syncAudio(false); this.raf = requestAnimationFrame(f); } };+ this.raf = requestAnimationFrame(f);+ }+ /** Vẽ 1 khung theo t: giờ, zoom CSS, phụ đề, đồ hoạ (iframe), kính. */+ tick(at) {+ const tt = at ?? this.time;+ this.tmNow.textContent = fmtT(tt); this.tmDur.textContent = fmtT(this.duration);+ this.ctx.onTime?.(tt);+ const src = this.layerSrc; const doc = this.ctx.store.doc;+ this.paintZoom(src, doc, tt);+ this.paintCap(src && doc ? doc.lines.findIndex((l) => tt >= l.start && tt < l.end) : -1, tt);+ this.paintGfx(src && doc ? tt : null);+ this.paintSel();+ }+ /** Tâm zoom (px khung 1080×1920): tâm khung đầu lúc zoom bắt đầu (faces-out), không có mặt thì (540, 40%). */+ zoomCenter(z) {+ const f = this.ctx.store.view?.faces; let c = [W / 2, H * 0.4];+ if (f?.boxes?.length) {+ let best = null;+ for (const [ft, b] of f.boxes) if (b && (!best || Math.abs(ft - z.at) < Math.abs(best[0] - z.at))) best = [ft, b];+ if (best && Math.abs(best[0] - z.at) < 1) c = [(best[1][0] + best[1][2]) / 2, (best[1][1] + best[1][3]) / 2];+ }+ return c;+ }+ paintZoom(src, doc, tt) {+ let tr = '';+ if (src && doc) {+ let zs = doc.zooms;+ if (src === 'base') { const orig = this.ctx.store.orig?.zooms || []; zs = zs.filter((z) => !orig.some((o) => o.n === z.n && Math.abs(o.at - z.at) < 0.005 && o.dur === z.dur && o.scale === z.scale && o.kind === z.kind)); }+ const { s, z } = zoomAt(zs, tt);+ if (s > 1.0005) {+ const k = this.k || 0.25;+ if (src === 'clean') {+ // như lumedit: cửa sổ W/s × H/s, x0 = cx − W/2s, y0 = cy − 0,42·H/s, kẹp trong khung+ const [cx, cy] = this.zoomCenter(z);+ const x0 = clamp(cx - W / (2 * s), 0, W - W / s); const y0 = clamp(cy - (H * 0.42) / s, 0, H - H / s);+ tr = `translate(${(-x0 * s * k).toFixed(2)}px, ${(-y0 * s * k).toFixed(2)}px) scale(${s.toFixed(4)})`;+ } else tr = `translate(${((1 - s) * W * 0.5 * k).toFixed(2)}px, ${((1 - s) * H * 0.4 * k).toFixed(2)}px) scale(${s.toFixed(4)})`;+ }+ }+ if (this.zoomWrap.style.transform !== tr) this.zoomWrap.style.transform = tr;+ }+ fit() {+ const w = this.box.clientWidth || 1;+ this.k = w / W;+ this.box.style.setProperty('--k', String(this.k));+ this.frame.style.transform = `scale(${this.k})`;+ this.cap = null; this.lastGlass = '';+ this.tick();+ }+ lookCss() {+ const s = this.ctx.store; const id = s.doc?.look;+ return s.view?.captions.looks.find((l) => l.id === id)?.css || null;+ }++ // ---- phụ đề: dựng DOM khi đổi dòng, mỗi khung chỉ đổi transform/opacity/màu ----+ /** Giờ từng chữ: giờ karaoke gốc (co giãn theo giờ dòng mới) nếu chữ không đổi, không thì chia theo số ký tự như server. */+ wordTimes(line, ws) {+ const o = line.wo; const n = ws.length;+ if (Array.isArray(o) && o.length === n && line.wt === line.text && Number.isFinite(line.w0) && line.w1 > line.w0) {+ const f = (line.end - line.start) / (line.w1 - line.w0);+ return o.map((x) => line.start + (x - line.w0) * f);+ }+ const len = ws.map((w) => [...w.w].length); const tot = len.reduce((a, b) => a + b, 0) || 1;+ let acc = 0; return len.map((l) => { const x = line.start + ((line.end - line.start) * acc) / tot; acc += l; return x; });+ }+ buildCap(line, look) {+ const s = this.ctx.store; const k = this.k || 0.25;+ const box = this.capText; const ticker = look.enter === 'ticker' && look.box;+ const ws = tokens(line.text);+ const text = ws.map((w) => { const x = w.w.replace(/[,.;:]+$/u, '') || w.w; return look.upper ? x.toUpperCase() : x; });+ let size = look.size;+ if (ticker) { const nch = text.join(' ').length; size = Math.max(34, Math.min(look.size, Math.floor((960 - 300) / (nch * 0.46 + 0.4)))); }+ else if (ws.length === 1) size = Math.min(look.size, Math.floor(840 / (Math.max(...text.map((x) => x.length)) * 0.5 + 0.5)));+ const stroke = look.box ? (look.box.stroke ?? 0) : (look.stroke ?? (look.upper ? 10 : 8));+ const shadow = look.shadow || (ticker ? 'none' : '0 6px 18px rgba(0,0,0,.55)');+ box.className = 'st-capt' + (ticker ? ' ticker' : '');+ box.style.fontFamily = `${look.font}, 'Be Vietnam Pro', sans-serif`;+ box.style.fontWeight = String(look.weight);+ box.style.fontSize = `${(size * k).toFixed(2)}px`;+ box.style.color = look.color;+ box.style.top = `${(look.cy * H * k).toFixed(1)}px`;+ box.style.webkitTextStroke = stroke ? `${(stroke * k).toFixed(2)}px #000` : '0';+ box.style.textShadow = shadow === 'none' ? 'none' : shadow.replace(/(-?\d+(?:\.\d+)?)px/g, (m0, v) => `${(Number(v) * k).toFixed(2)}px`);+ box.style.background = ticker ? look.box.bg : '';+ const hiOn = !!s.doc.hi;+ const kids = []; const words = [];+ if (ticker && look.box.tag) { const tg = el('span', 'tag', look.box.tag); tg.style.background = look.box.tagBg || '#E8202A'; kids.push(tg); }+ ws.forEach((w, i) => {+ if (i) kids.push(' ');+ const sp = el('span', 'w');+ const base = w.hi && hiOn ? look.hi : look.color;+ if (look.enter === 'typewriter') for (const ch of [...text[i]]) sp.append(el('i', 'ch', ch)); else sp.textContent = text[i];+ sp.style.color = base;+ kids.push(sp); words.push({ el: sp, base });+ });+ box.replaceChildren(...kids);+ const wo = this.wordTimes(line, ws);+ const L = s.doc.lines; const idx = L.indexOf(line); const next = L[idx + 1]; const prev = L[idx - 1];+ const chars = [...box.querySelectorAll('.ch')];+ return { line, look, words, wo, chars, ticker, fadeOut: (!next || next.start - line.end >= 0.3) && line.end - line.start > 0.55,+ runStart: ticker && (!prev || line.start - prev.end > 0.5 || /[.?!…]$/.test(prev.text.trim())) };+ }+ paintCap(idx, tt) {+ const s = this.ctx.store; const L = s.doc?.lines || []; const line = L[idx]; const look = this.lookCss();+ const box = this.capText;+ if (!line || !look) { if (this.cap) { box.replaceChildren(); box.hidden = true; this.cap = null; } return; }+ const key = `${line.u}|${line.text}|${line.start}|${line.end}|${s.doc.look}|${s.doc.hi}|${this.k}`;+ if (!this.cap || this.cap.key !== key) { this.cap = this.buildCap(line, look); this.cap.key = key; }+ box.hidden = false;+ const c = this.cap; const u = tt - line.start; const k = this.k || 0.25;+ let x = 0; let y = 0; let sc = 1; let op = 1;+ switch (look.enter) {+ case 'pop': sc = 0.55 + 0.45 * backOut(3)(u / 0.18); break;+ case 'pop-soft': { const e = backOut(2.2)(u / 0.14); sc = 0.86 + 0.14 * e; op = clamp(e, 0, 1); break; }+ case 'slide-left': { const e = pOut(3)(u / 0.16); x = 80 * (1 - e); op = e; break; }+ case 'slam': {+ const e = pIn(4)(u / 0.12); sc = 1.6 - 0.6 * e; op = 0.4 + 0.6 * e;+ const sh = [6, -6, 6, 0]; let px = 0;+ for (let q = 0; q < 4; q++) { const a0 = 0.12 + q * 0.025; if (u >= a0) px = u >= a0 + 0.025 ? sh[q] : px + (sh[q] - px) * ((u - a0) / 0.025); }+ x = px; break;+ }+ case 'fade-slow': op = pOut(1)(u / 0.3); if (c.fadeOut && tt > line.end - 0.25) op *= 1 - pIn(1)((tt - (line.end - 0.25)) / 0.25); break;+ case 'typewriter': {+ const n = c.chars.length; const st = Math.min(0.035, ((line.end - line.start) * 0.6) / Math.max(1, n));+ c.chars.forEach((ch, q) => { const v = u >= q * st ? '1' : '0'; if (ch.style.opacity !== v) ch.style.opacity = v; });+ break;+ }+ case 'ticker': if (c.runStart) x = -W * (1 - pOut(3)(u / 0.2)); else op = clamp(u / 0.08, 0, 1); break;+ default: { const e = pOut(2)(u / 0.12); y = 18 * (1 - e); op = e; }+ }+ box.style.transform = `translate(${(x * k).toFixed(2)}px, ${(y * k).toFixed(2)}px) scale(${sc.toFixed(4)})`;+ box.style.opacity = op.toFixed(3);+ // karaoke: chữ đang nói tô màu nhấn+ if (look.karaoke && c.words.length > 1) {+ c.words.forEach((w, q) => {+ const a = c.wo[q]; const b = q + 1 < c.wo.length ? c.wo[q + 1] : line.end;+ const col = tt >= a && tt < b ? look.hi : w.base;+ if (w.el.style.color !== col) w.el.style.color = col;+ });+ }+ }+ /** Khung chọn quanh dòng chữ đang chọn (như mẫu) — chỉ khi dòng đó đang hiện. */+ paintSel() {+ const sel = this.ctx.getSel?.();+ const show = !!this.layerSrc && sel?.kind === 'cap' && !this.capText.hidden && this.cap?.line?.u === sel.u;+ this.capSel.hidden = !show;+ if (!show) return;+ const b = this.box.getBoundingClientRect(); const r = this.capText.getBoundingClientRect();+ this.capSel.style.transform = `translate(${(r.left - b.left - 6).toFixed(1)}px, ${(r.top - b.top - 4).toFixed(1)}px)`;+ this.capSel.style.width = `${(r.width + 12).toFixed(1)}px`; this.capSel.style.height = `${(r.height + 8).toFixed(1)}px`;+ }++ // ---- đồ hoạ: cảnh thật trong iframe sandbox + kính mờ ----+ /** Cảnh mới (server dựng từ đồ hoạ đang sửa): gửi vào khung. scene = {css, html, data} | null. */+ setGfxScene(scene) { this.gfxScene = scene; this.postScene(); this.tick(); }+ postScene() {+ if (!this.frameReady || !this.frame.contentWindow) return;+ const sc = this.gfxScene || { css: '', html: '', data: [] };+ // khung sandbox có origin rỗng → targetOrigin '*'; chỉ gửi cảnh đồ hoạ (không có gì bí mật)+ this.frame.contentWindow.postMessage({ type: 'scene', css: sc.css, html: sc.html, G: sc.data }, '*');+ }+ paintGfx(tt) {+ const on = tt != null && !!this.gfxScene?.data?.length;+ this.frame.hidden = !on;+ if (on && this.frameReady && tt !== this.lastGfxT) { this.lastGfxT = tt; this.frame.contentWindow.postMessage({ type: 't', t: tt }, '*'); }+ // kính mờ dưới thẻ (như bước ghép: tem giá / sticker / thẻ ghim không có kính)+ const doc = this.ctx.store.doc; const k = this.k || 0.25;+ const list = on && this.layerSrc === 'clean' ? doc.gfx.filter((g) => g.box && !['price_tag', 'sticker'].includes(g.type) && !g.data?.pin && tt >= g.at && tt < g.until) : [];+ const key = list.map((g) => `${g.u}|${JSON.stringify(g.box)}`).join('#') + k;+ if (key !== this.lastGlass) {+ this.lastGlass = key;+ this.glassLayer.replaceChildren(...list.map((g) => {+ const d = el('div', 'gl', null, { 'data-u': g.u }); const b = g.box;+ d.style.transform = `translate(${(b.x * k).toFixed(1)}px, ${(b.y * k).toFixed(1)}px)`;+ d.style.width = `${(b.w * k).toFixed(1)}px`; d.style.height = `${(b.h * k).toFixed(1)}px`;+ d.style.borderRadius = `${(38 * (b.scale ?? 1) * k).toFixed(1)}px`;+ d.style.backdropFilter = d.style.webkitBackdropFilter = `blur(${(24 * k).toFixed(1)}px)`;+ return d;+ }));+ }+ for (const d of this.glassLayer.children) {+ const g = doc.gfx.find((x) => x.u === d.dataset.u); if (!g) continue;+ const a = Math.min(ease((tt - g.at) / 0.15), ease((g.until - tt) / 0.22));+ d.style.opacity = a.toFixed(3);+ }+ }+ destroy() { cancelAnimationFrame(this.raf); this.ro.disconnect(); this.release(); }+}diff --git a/server/public/studio/store.js b/server/public/studio/store.jsindex 60796bf..d2601cf 100644--- a/server/public/studio/store.js+++ b/server/public/studio/store.js@@ -11,7 +11,7 @@ const nid = (p) => `${p}${++uid}`;/** View server → doc (đơn vị: giây bản ra). */function toDoc(v) {return {- lines: v.captions.lines.map((l) => ({ u: nid('l'), start: l.start, end: l.end, text: l.text })),+ lines: v.captions.lines.map((l) => ({ u: nid('l'), start: l.start, end: l.end, text: l.text, ...(Array.isArray(l.wo) ? { wo: l.wo, wt: l.text, w0: l.start, w1: l.end } : {}) })),look: v.captions.look, hi: !!v.captions.highlights,music: { source: v.music.on ? 'keep' : 'none', gainDb: v.music.gainDb, duck: !!v.music.duck, fadeOut: v.music.fadeOut, start: v.music.start || 0 },voice: { gainDb: v.voice.gainDb }, sfx: { on: !!v.sfx.on },diff --git a/server/public/studio/studio.css b/server/public/studio/studio.cssindex f938975..679b9cd 100644--- a/server/public/studio/studio.css+++ b/server/public/studio/studio.css@@ -1,323 +1,330 @@-/* Studio — trình edit toàn màn hình (mẫu _final/18-ui-edit-mau/1-studio.png). Token chung ở style.css + create.css. */-body.studio-on { overflow: hidden; }-body.studio-on > :not(.studio):not(script):not(dialog) { display: none !important; }-.studio { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; --tl-h: 290px; }-.studio[hidden] { display: none; }-.studio button { font: inherit; color: inherit; }-.studio .ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }-.studio .ic .fill { fill: currentColor; stroke: none; }-.studio :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }-.ib { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; border: 0; background: none; color: var(--ink-2); cursor: pointer; transition: background .12s, color .12s; }-.ib:hover:not(:disabled) { background: var(--panel-2); color: var(--ink); }-.ib:disabled { opacity: .35; cursor: default; }-.ib.mini { width: 30px; height: 30px; border-radius: 7px; background: var(--panel-3); }-.ib.mini .ic { width: 15px; height: 15px; }-.ib.mini.danger:hover:not(:disabled) { color: #FF8B8B; }--/* ---- thanh trên ---- */-.st-top { height: 56px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 12px; border-bottom: 1px solid var(--line); background: var(--bg-2); }-.st-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; max-width: 300px; }-.st-title b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }-.st-title span { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.st-vers { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-left: 10px; overflow-x: auto; max-width: 340px; scrollbar-width: none; }-.st-vers[hidden] { display: none; }-.st-vers button { min-width: 34px; height: 28px; padding: 0 11px; border-radius: 7px; border: 0; background: none; font-size: 12.5px; font-weight: 600; color: var(--ink-3); cursor: pointer; white-space: nowrap; }-.st-vers button:hover { color: var(--ink); }-.st-vers button.on { background: var(--panel-3); color: var(--ink); }-.st-mid { margin: 0 auto; display: flex; gap: 4px; }-.st-top .btn { min-height: 38px; }-.st-top .btn[hidden] { display: none; }-.st-revb .num { font-variant-numeric: tabular-nums; }-.st-revb[aria-pressed="true"] { background: rgba(242,201,76,.24); }-.st-dl.pri { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -6px rgba(255,107,44,.55); }-.st-pub { min-width: 0; }-.st-prog { height: 2px; flex: none; background: transparent; position: relative; margin-top: -2px; z-index: 3; }-.st-prog[hidden] { display: block; visibility: hidden; }-.st-prog i { position: absolute; inset: 0; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); transition: transform .5s ease-out; box-shadow: 0 0 10px rgba(255,107,44,.7); }--/* ---- giữa: cột icon · player · bảng ---- */-.st-main { flex: 1; min-height: 0; display: flex; }-.st-rail { width: 76px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding-top: 12px; gap: 4px; background: var(--bg-2); }-.st-rail button { width: 60px; height: 62px; border-radius: 12px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); position: relative; cursor: pointer; transition: background .12s, color .12s; }-.st-rail button .ic { width: 22px; height: 22px; }-.st-rail button:hover { color: var(--ink); background: var(--panel); }-.st-rail button.on { background: var(--accent-soft); color: var(--accent); }-.st-rail .l { line-height: 1.1; text-align: center; }-.st-rail .sep { width: 32px; height: 1px; background: var(--line); margin: 6px 0; }-.st-rail .dot { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; border-radius: 9px; background: var(--warn); color: #1b1503; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }-.st-rail .dot[hidden] { display: none; }--.st-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px; background: radial-gradient(ellipse at 50% 40%, #1a1815 0%, var(--bg) 70%); }-.st-vid { position: relative; height: min(100%, calc(100% - 54px)); aspect-ratio: 9 / 16; max-width: 100%; border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 30px 60px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06); cursor: pointer; flex: 1 1 auto; min-height: 0; }-.st-zw { position: absolute; inset: 0; transform-origin: 50% 40%; will-change: transform; }-.st-zw video { width: 100%; height: 100%; object-fit: cover; display: block; }-.st-cap, .st-gfx { position: absolute; inset: 0; pointer-events: none; }-.st-capt { position: absolute; left: calc(120 / 1080 * 100%); right: calc(120 / 1080 * 100%); transform: translateY(-50%); text-align: center; line-height: 1.12; paint-order: stroke fill; overflow-wrap: anywhere; }-.st-capt[hidden] { display: none; }-.st-capt.boxed { left: 0; right: 0; text-align: left; padding: .2em .5em; }-.st-capt .tag { display: inline-block; padding: 0 .35em; margin-right: .4em; color: #fff; font-size: .62em; vertical-align: middle; }-.st-capsel { position: absolute; left: 0; top: 0; border: 1.5px solid var(--accent); border-radius: 6px; pointer-events: none; }-.st-capsel::before, .st-capsel::after { content: ""; position: absolute; width: 8px; height: 8px; background: #fff; border: 1.5px solid var(--accent); border-radius: 2px; top: -5px; left: -5px; }-.st-capsel::after { left: auto; right: -5px; top: auto; bottom: -5px; }-.st-capsel[hidden] { display: none; }-.st-vbadge { position: absolute; top: 10px; left: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.7); font-size: 11.5px; font-weight: 600; color: var(--ink-2); }-.st-vbadge[hidden] { display: none; }-/* thẻ đồ hoạ xem trước (gần đúng thẻ HyperFrames) */-.st-gcard { position: absolute; left: 0; top: 0; border-radius: .7em; padding: .7em .9em; background: rgba(22,24,32,.86); color: #fff; box-shadow: 0 .4em 1.2em rgba(0,0,0,.4); font-family: 'Be Vietnam Pro', sans-serif; line-height: 1.25; }-.st-gcard .h { font-weight: 700; margin-bottom: .45em; }-.st-gcard .h .u, .st-gcard .kick { color: var(--violet); font-weight: 600; }-.st-gcard .row { display: flex; justify-content: space-between; gap: .6em; padding: .3em 0 .3em .5em; border-left: 2px solid rgba(255,255,255,.25); margin-top: .25em; font-size: .9em; }-.st-gcard .row b { font-variant-numeric: tabular-nums; }-.st-gcard .big { font: 800 2.2em/1.05 'Barlow Condensed', sans-serif; text-transform: uppercase; color: var(--accent); }-.st-gcard .lbl { font-size: .85em; color: rgba(255,255,255,.7); }-.st-ctrl { display: flex; align-items: center; gap: 16px; color: var(--ink-2); flex: none; }-.st-time { font-size: 13px; color: var(--ink-2); min-width: 122px; text-align: right; }-.st-time b { color: var(--ink); font-weight: 600; }-.st-play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; cursor: pointer; transition: transform .1s; }-.st-play:active { transform: scale(.94); }-.st-play .ic { width: 18px; height: 18px; }-.st-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--panel-2); color: var(--ink-2); border: 0; white-space: nowrap; }-.st-pill.warn { color: var(--warn); background: var(--warn-soft); }-button.st-pill { cursor: pointer; min-height: 30px; }-button.st-pill:hover { color: var(--ink); }-.st-outsw[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }-.st-outsw[hidden] { display: none; }--/* ---- bảng thuộc tính ---- */-.st-insp { width: 364px; flex: none; border-left: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }-.st-grab { display: none; }-.st-ih { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; padding: 16px 18px 12px; margin: 0; flex: none; }-.st-ih > .btn { margin-left: auto; }-.st-ib { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 16px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }-.st-ib > .st-seg { position: sticky; top: 0; z-index: 2; box-shadow: 0 -10px 0 var(--bg-2), 0 8px 10px -4px var(--bg-2); }-.st-seg { display: flex; margin: 0 8px; background: var(--panel); border-radius: 10px; padding: 3px; gap: 2px; flex: none; }-.st-seg button { flex: 1; min-height: 30px; border-radius: 7px; border: 0; background: none; font-size: 13px; font-weight: 500; color: var(--ink-3); cursor: pointer; }-.st-seg button.on { background: var(--panel-3); color: var(--ink); }-.st-seg.sm { margin: 0; }-.st-lines { list-style: none; margin: 0; padding: 2px 0 0; display: flex; flex-direction: column; gap: 2px; position: relative; }-.st-ln .row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; }-.st-ln .row:hover { background: var(--panel); }-.st-ln.now .row { color: var(--ink); background: rgba(255,255,255,.035); }-.st-ln .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }-.st-ln .tx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }-.st-ln em { font-style: normal; color: var(--accent); }-.st-ln .flag { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }-.st-ln.bad .row { box-shadow: inset 2px 0 0 var(--bad); }-.st-ln.sel { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; margin: 2px 0; }-.st-ledit { width: 100%; min-height: 40px; background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 0 12px; font-size: 15px; font-weight: 500; color: var(--ink); outline: none; }-.st-ledit:focus { box-shadow: 0 0 0 3px rgba(255,107,44,.18); }-.st-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }-.st-row .arrow { color: var(--ink-4); }-.st-acts { margin-left: auto; display: flex; gap: 6px; }-.st-tbox { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 9px; border-radius: 7px; background: var(--bg); border: 1px solid var(--line-2); color: var(--ink-2); }-.st-tbox .ic { width: 13px; height: 13px; }-.st-tbox input { width: 58px; border: 0; background: none; font-size: 12px; color: var(--ink-2); outline: none; -moz-appearance: textfield; }-.st-tbox input::-webkit-inner-spin-button { opacity: .4; }-.st-ainote { margin: 0; font-size: 12px; color: var(--warn); display: flex; gap: 6px; align-items: center; }-.st-ainote .ic { width: 14px; height: 14px; }-.st-err { margin: 0; font-size: 12px; color: var(--bad); }-.st-note { margin: 0 8px; font-size: 12.5px; color: var(--ink-3); background: var(--panel); border-radius: 8px; padding: 8px 10px; }-.st-note.warn { color: var(--warn); background: var(--warn-soft); }-.st-note:empty { display: none; }-.st-hint { margin: 0 8px; font-size: 12.5px; color: var(--ink-3); }-.st-empty { color: var(--ink-3); text-align: center; padding: 24px 8px; margin: 0; }-.st-lines .none, .st-blist .none { color: var(--ink-3); padding: 12px 10px; font-size: 13px; }-/* kiểu chữ */-.st-looks { padding: 4px 8px; display: flex; flex-direction: column; gap: 12px; }-.st-lookgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }-.st-look { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 6px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; text-align: center; }-.st-look:hover:not(:disabled) { border-color: var(--ink-4); }-.st-look.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,107,44,.25); }-.st-look .smp { height: 46px; display: grid; place-items: center; border-radius: 7px; background: #0b0b0a; font-size: 24px; color: #fff; grid-auto-flow: column; justify-content: center; gap: 1px; }-.st-look .nm { font-size: 11.5px; color: var(--ink-2); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }-.st-switch { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-2); }-.st-switch input { width: 34px; height: 20px; appearance: none; -webkit-appearance: none; border-radius: 20px; background: var(--panel-3); position: relative; cursor: pointer; flex: none; transition: background .15s; }-.st-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2); transition: transform .15s; }-.st-switch input:checked { background: var(--accent); }-.st-switch input:checked::after { transform: translateX(14px); background: #fff; }-.st-switch input:disabled { opacity: .4; }-.st-switch small { flex-basis: 100%; color: var(--ink-4); font-size: 12px; margin-top: -6px; padding-left: 44px; }-.st-switch.sm { min-height: 30px; }-/* ô chung */-.st-field { display: flex; flex-direction: column; gap: 6px; padding: 0 8px; font-size: 12.5px; color: var(--ink-3); }-.st-field > span, .st-field > label { font-weight: 600; }-.st-field input[type=text], .st-field input[type=number], .st-sel, .st-ai textarea { width: 100%; min-height: 36px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; font-size: 14px; color: var(--ink); }-.st-field input:focus, .st-sel:focus, .st-ai textarea:focus { border-color: var(--accent); outline: none; }-.st-slide { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; }-.st-slide label { grid-column: 1 / -1; }-.st-slide input { accent-color: var(--accent); width: 100%; height: 24px; }-.st-slide output { font-size: 12.5px; color: var(--ink); min-width: 56px; text-align: right; }-.st-ib > .st-row, .st-ib > .st-switch { padding: 0 8px; }-.st-ib hr { border: 0; border-top: 1px solid var(--line); margin: 4px 8px; width: auto; }-.st-card { margin: 0 8px; padding: 12px 4px; border-radius: 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); display: flex; flex-direction: column; gap: 12px; }-.st-card > .st-row, .st-card > .st-seg, .st-card > .btn, .st-card > .st-hint { margin: 0 8px; }-.st-card > .btn { align-self: flex-start; }-.st-gtype { font-size: 14px; }-.st-grow { margin: 0 8px; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 0 10px; display: flex; flex-direction: column; gap: 8px; }-.st-grow legend { font-size: 11.5px; color: var(--ink-4); padding: 0 6px; margin-left: 6px; }-.st-blist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }-.st-blist button { width: 100%; display: flex; gap: 12px; align-items: center; min-height: 36px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; }-.st-blist button:hover { background: var(--panel); }-.st-blist button.on { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }-.st-blist .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }-.st-blist .lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }-/* xem lại */-.st-review { display: flex; flex-direction: column; gap: 12px; }-.st-rcard { margin: 0 8px; padding: 12px; border-radius: 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px rgba(242,201,76,.35); display: flex; flex-direction: column; gap: 8px; }-.st-rtop { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-3); }-.st-rnav { margin-left: auto; display: flex; gap: 6px; }-.st-rwhat { margin: 0; font-size: 15px; }-.st-rwhat .k { font-size: 11.5px; color: var(--warn); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }-.st-rwhat s { color: var(--ink-3); }-.st-rwhy { margin: 0; font-size: 12px; color: var(--ink-3); }-.st-rdone { margin: 0; font-size: 12px; color: var(--ok); }-.st-racts { display: flex; gap: 6px; flex-wrap: wrap; }-.st-racts .btn { flex: 1; min-height: 34px; font-size: 13px; padding: 0 10px; }-.st-rlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }-.st-ritem { width: 100%; display: flex; gap: 10px; align-items: center; min-height: 34px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; font-size: 13px; }-.st-ritem:hover { background: var(--panel); }-.st-ritem.on { background: var(--panel-2); color: var(--ink); }-.st-ritem.done { color: var(--ink-4); }-.st-ritem .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }-.st-ritem .rx { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }-.st-ritem s { color: var(--ink-4); }-.st-ritem .ic { color: var(--ok); width: 15px; height: 15px; }-/* AI */-.st-ai { margin: 0 8px; display: flex; flex-direction: column; gap: 10px; }-.st-ai textarea { padding: 10px; min-height: 84px; resize: vertical; font-size: 14px; line-height: 1.45; }-.st-chips { display: flex; flex-wrap: wrap; gap: 6px; }-.st-chips .chip { min-height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--panel); font-size: 12.5px; color: var(--ink-2); }-.st-chips .chip:hover { color: var(--ink); }-.st-ai .btn { align-self: flex-start; }-.st-h4 { margin: 8px 8px 0; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }-.st-hist { margin: 0 8px; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-2); }-.st-hist li { padding: 8px 10px; background: var(--panel); border-radius: 8px; overflow-wrap: anywhere; }-.st-hist small { display: block; color: var(--ink-4); margin-top: 3px; }-.st-insp.ro .st-ln .row { cursor: pointer; }--/* ---- timeline ---- */-.st-tl { height: var(--tl-h); flex: none; border-top: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }-.tl-bar { height: 42px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 14px; border-bottom: 1px solid var(--line); }-.tl-bar .ib.mini { background: transparent; }-.tl-bar .ib.mini:hover:not(:disabled) { background: var(--panel-2); }-.tl-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }-.tl-hint { font-size: 12px; color: var(--ink-4); margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.tl-zoomer { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--ink-3); }-.tl-zoomer > .ic { width: 15px; height: 15px; }-.tl-zoomer input { width: 120px; accent-color: var(--ink-2); }-.tl-main { flex: 1; min-height: 0; display: flex; }-.tl-labs { width: 96px; flex: none; display: flex; flex-direction: column; }-.tl-labs .lab { display: flex; align-items: center; gap: 7px; padding-left: 16px; font-size: 12px; color: var(--ink-3); border: 0; background: none; text-align: left; cursor: pointer; transition: color .12s, opacity .12s; }-.tl-labs .lab .ic { width: 15px; height: 15px; }-.tl-labs .lab:hover { color: var(--ink); }-.tl-labs .lab.on { color: var(--accent); }-.tl-labs .lab.ruler { cursor: default; }-.tl-sc { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; position: relative; scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }-.tl-in { position: relative; height: 100%; min-width: 100%; }-/* chiều cao hàng: thước 26 · video 66 · phụ đề 34 · zoom 30 · đồ hoạ 32 · nhạc 50 */-.tl-labs .lab.ruler, .tl-ruler { height: 26px; flex: none; }-.tl-labs .lab[data-k="video"], .r-video { height: 66px; }-.tl-labs .lab[data-k="cap"], .r-cap { height: 34px; }-.tl-labs .lab[data-k="zoom"], .r-zoom { height: 30px; }-.tl-labs .lab[data-k="gfx"], .r-gfx { height: 32px; }-.tl-labs .lab[data-k="music"], .r-music { height: 50px; }-.tl-ruler { position: relative; cursor: pointer; }-.tl-ruler i { position: absolute; left: 0; bottom: 0; width: 1px; height: 5px; background: var(--line-2); }-.tl-ruler i.mj { height: 9px; background: var(--ink-4); }-.tl-ruler span { position: absolute; left: 0; top: 4px; font-size: 10.5px; color: var(--ink-4); pointer-events: none; }-.tl-row { position: relative; transition: opacity .15s; }-.st-tl[data-focus] .tl-row:not(.r-video) { opacity: .55; }-.st-tl[data-focus="cap"] .r-cap, .st-tl[data-focus="zoom"] .r-zoom, .st-tl[data-focus="gfx"] .r-gfx, .st-tl[data-focus="music"] .r-music { opacity: 1; }-.st-tl[data-focus="cap"] .lab[data-k="cap"], .st-tl[data-focus="zoom"] .lab[data-k="zoom"], .st-tl[data-focus="gfx"] .lab[data-k="gfx"], .st-tl[data-focus="music"] .lab[data-k="music"] { color: var(--accent); }-.st-tl[data-focus="cap"] .r-cap, .st-tl[data-focus="zoom"] .r-zoom, .st-tl[data-focus="gfx"] .r-gfx, .st-tl[data-focus="music"] .r-music { background: linear-gradient(90deg, rgba(255,107,44,.05), rgba(255,107,44,.02)); }-.tl-cv { position: sticky; left: 0; display: block; pointer-events: none; margin-top: 4px; z-index: 2; }-.blk { position: absolute; left: 0; top: 4px; bottom: 4px; border-radius: 7px; overflow: hidden; display: flex; align-items: center; padding: 0 7px; font-size: 11px; font-weight: 500; white-space: nowrap; cursor: grab; will-change: transform; touch-action: none; }-.blk .t { overflow: hidden; text-overflow: ellipsis; min-width: 0; pointer-events: none; }-.blk::before, .blk::after { content: ""; position: absolute; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }-.blk::before { left: 0; } .blk::after { right: 0; }-.blk.on::before, .blk.on::after { background: rgba(255,255,255,.35); }-.blk.drag { cursor: grabbing; z-index: 3; box-shadow: 0 6px 16px rgba(0,0,0,.45); }-.blk.narrow { padding: 0 3px; }-.blk.narrow .t { text-overflow: clip; }-.blk.ro { cursor: pointer; }-.blk.ro::before, .blk.ro::after { cursor: pointer; }-.blk.cap { background: #3B2A1F; border: 1px solid #5a3a25; color: #F5C9A8; }-.blk.cap.w { background: #3a3218; border-color: #6b5a1c; color: var(--warn); }-.blk.cap.bad { border-color: var(--bad); }-.blk.cap.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }-.blk.zoom { top: 4px; bottom: 4px; background: var(--sky-soft); border: 1px solid rgba(108,196,240,.45); color: var(--sky); font-weight: 600; }-.blk.zoom.on { background: rgba(108,196,240,.32); border-color: var(--sky); color: #fff; }-.blk.gfx { background: var(--violet-soft); border: 1px solid rgba(167,139,250,.45); color: #C9B8FF; font-weight: 600; }-.blk.gfx.on { background: rgba(167,139,250,.34); border-color: var(--violet); color: #fff; }-.blk.mu { top: 4px; bottom: 4px; background: rgba(93,211,158,.08); border: 1px solid rgba(93,211,158,.35); cursor: pointer; align-items: flex-start; padding-top: 3px; z-index: 1; }-.blk.mu.on { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }-.blk.mu::before, .blk.mu::after { display: none; }-.blk[hidden] { display: none; }-.tl-mlab { font-size: 11px; font-weight: 600; color: var(--ok); text-shadow: 0 1px 2px rgba(0,0,0,.6); }-.r-music.empty::after { content: attr(data-empty); position: sticky; left: 14px; top: 0; display: inline-block; padding: 16px 0 0 14px; font-size: 12px; color: var(--ink-4); }-.tl-head { position: absolute; top: 6px; bottom: 6px; left: 0; width: 2px; background: var(--accent); z-index: 6; cursor: ew-resize; touch-action: none; }-.tl-head .knob { position: absolute; top: -4px; left: -6px; width: 14px; height: 14px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%); }-.tl-head::after { content: ""; position: absolute; inset: 0 -6px; }-.tl-guide { position: absolute; top: 26px; bottom: 0; left: 0; width: 1px; background: #fff; opacity: .8; z-index: 5; pointer-events: none; }-.tl-guide[hidden] { display: none; }-.tl-tip { position: absolute; left: 0; top: 0; padding: 2px 6px; border-radius: 5px; background: #000; color: #fff; font: 600 11px/1.4 var(--mono); z-index: 7; pointer-events: none; white-space: nowrap; }-.tl-tip[hidden] { display: none; }-.tl-edit { position: absolute; left: 0; top: 0; height: 30px; z-index: 8; background: var(--bg); border: 1.5px solid var(--accent); border-radius: 7px; padding: 0 8px; font-size: 13px; color: var(--ink); outline: none; box-shadow: 0 8px 24px rgba(0,0,0,.5); }--/* ---- lớp chờ, thông báo ---- */-.st-wait { position: absolute; inset: 56px 0 0 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(14,13,11,.92); text-align: center; padding: 24px; }-.st-wait[hidden] { display: none; }-.st-wait p { margin: 0; font-size: 15px; color: var(--ink-2); max-width: 520px; }-.st-wbar { width: 280px; height: 3px; border-radius: 2px; background: var(--panel-3); overflow: hidden; }-.st-wbar[hidden] { display: none; }-.st-wbar i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); transition: transform .5s; }-.st-toast { position: absolute; left: 50%; bottom: calc(var(--tl-h) + 16px); transform: translateX(-50%); z-index: 30; max-width: min(640px, calc(100% - 32px)); padding: 10px 16px; border-radius: 10px; background: #26241f; color: var(--ink); box-shadow: 0 12px 30px rgba(0,0,0,.5); font-size: 13.5px; border: 1px solid var(--line-2); }-.st-toast[hidden] { display: none; }-.st-toast.ok { border-color: rgba(93,211,158,.5); color: var(--ok); }-.st-toast.bad { border-color: rgba(255,100,100,.5); color: #FFB0B0; }-.st-scrim { display: none; }--@media (max-width: 1180px) { .st-insp { width: 320px; } .st-title { max-width: 200px; } .st-reset { display: none; } }--/* ---- điện thoại < 768: player trên, công cụ ngang, timeline cuộn ngang, bảng thành sheet dưới ---- */-@media (max-width: 767px) {- .studio { --tl-h: 262px; }- .st-top { height: 52px; gap: 6px; padding: 0 8px 0 4px; }- .st-title { max-width: none; flex: 1; }- .st-title span { display: none; }- .st-vers { display: none; }- .st-mid { margin: 0; }- .st-mid .ib { width: 34px; }- .st-revb > span:not(.num), .st-dl span, .st-pub span { display: none; }- .st-top .btn { min-height: 36px; padding: 0 10px; }- .st-main { flex-direction: column; }- .st-rail { width: auto; height: 52px; flex-direction: row; justify-content: space-around; padding: 4px 6px; border-right: 0; border-top: 1px solid var(--line); order: 2; }- .st-rail button { width: auto; flex: 1; height: 46px; gap: 2px; font-size: 10.5px; border-radius: 10px; }- .st-rail .l { white-space: nowrap; }- .st-rail button .ic { width: 18px; height: 18px; }- .st-rail .sep { width: 1px; height: 24px; margin: 0 2px; }- .st-rail .dot { top: 1px; right: calc(50% - 20px); }- .st-stage { order: 1; flex: 1; min-height: 0; padding: 8px; gap: 8px; }- .st-ctrl { gap: 10px; }- .st-time { min-width: 0; font-size: 12px; }- .st-ratio, .st-ctrl .mono.st-pill { display: none; }- .st-insp { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 62vh; border-left: 0; border-top: 1px solid var(--line-2); border-radius: 16px 16px 0 0; z-index: 40; transform: translateY(105%); transition: transform .22s ease-out; box-shadow: 0 -16px 40px rgba(0,0,0,.5); padding-bottom: env(safe-area-inset-bottom); }- .st-insp.open { transform: none; }- .st-grab { display: block; width: 100%; height: 22px; border: 0; background: none; cursor: pointer; flex: none; position: relative; }- .st-grab::after { content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--ink-4); }- .st-ih { padding-top: 4px; }- .st-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }- .st-scrim.on { opacity: 1; pointer-events: auto; }- .tl-bar { padding: 0 8px; gap: 2px; overflow-x: auto; }- .tl-hint { display: none; }- .tl-zoomer input { width: 70px; }- .tl-labs { width: 40px; }- .tl-labs .lab { padding-left: 12px; }- .tl-labs .lab span { display: none; }- .r-video, .tl-labs .lab[data-k="video"] { height: 50px; }- .r-music, .tl-labs .lab[data-k="music"] { height: 40px; }- .st-toast { bottom: calc(var(--tl-h) + 60px); }-}-@media (prefers-reduced-motion: reduce) {- .st-prog i, .st-wbar i, .st-insp, .tl-row, .st-rail button { transition: none; }-}+/* Studio — trình edit toàn màn hình (mẫu _final/18-ui-edit-mau/1-studio.png). Token chung ở style.css + create.css. */+body.studio-on { overflow: hidden; }+body.studio-on > :not(.studio):not(script):not(dialog) { display: none !important; }+.studio { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; --tl-h: 290px; }+.studio[hidden] { display: none; }+.studio button { font: inherit; color: inherit; }+.studio .ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }+.studio .ic .fill { fill: currentColor; stroke: none; }+.studio :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }+.ib { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; border: 0; background: none; color: var(--ink-2); cursor: pointer; transition: background .12s, color .12s; }+.ib:hover:not(:disabled) { background: var(--panel-2); color: var(--ink); }+.ib:disabled { opacity: .35; cursor: default; }+.ib.mini { width: 30px; height: 30px; border-radius: 7px; background: var(--panel-3); }+.ib.mini .ic { width: 15px; height: 15px; }+.ib.mini.danger:hover:not(:disabled) { color: #FF8B8B; }++/* ---- thanh trên ---- */+.st-top { height: 56px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 12px; border-bottom: 1px solid var(--line); background: var(--bg-2); }+.st-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; max-width: 300px; }+.st-title b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.st-title span { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.st-vers { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-left: 10px; overflow-x: auto; max-width: 340px; scrollbar-width: none; }+.st-vers[hidden] { display: none; }+.st-vers button { min-width: 34px; height: 28px; padding: 0 11px; border-radius: 7px; border: 0; background: none; font-size: 12.5px; font-weight: 600; color: var(--ink-3); cursor: pointer; white-space: nowrap; }+.st-vers button:hover { color: var(--ink); }+.st-vers button.on { background: var(--panel-3); color: var(--ink); }+.st-mid { margin: 0 auto; display: flex; gap: 4px; }+.st-top .btn { min-height: 38px; }+.st-top .btn[hidden] { display: none; }+.st-revb .num { font-variant-numeric: tabular-nums; }+.st-revb[aria-pressed="true"] { background: rgba(242,201,76,.24); }+.st-dl.pri { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -6px rgba(255,107,44,.55); }+.st-pub { min-width: 0; }+.st-prog { height: 2px; flex: none; background: transparent; position: relative; margin-top: -2px; z-index: 3; }+.st-prog[hidden] { display: block; visibility: hidden; }+.st-prog i { position: absolute; inset: 0; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); transition: transform .5s ease-out; box-shadow: 0 0 10px rgba(255,107,44,.7); }++/* ---- giữa: cột icon · player · bảng ---- */+.st-main { flex: 1; min-height: 0; display: flex; }+.st-rail { width: 76px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding-top: 12px; gap: 4px; background: var(--bg-2); }+.st-rail button { width: 60px; height: 62px; border-radius: 12px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); position: relative; cursor: pointer; transition: background .12s, color .12s; }+.st-rail button .ic { width: 22px; height: 22px; }+.st-rail button:hover { color: var(--ink); background: var(--panel); }+.st-rail button.on { background: var(--accent-soft); color: var(--accent); }+.st-rail .l { line-height: 1.1; text-align: center; }+.st-rail .sep { width: 32px; height: 1px; background: var(--line); margin: 6px 0; }+.st-rail .dot { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; border-radius: 9px; background: var(--warn); color: #1b1503; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }+.st-rail .dot[hidden] { display: none; }++.st-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px; background: radial-gradient(ellipse at 50% 40%, #1a1815 0%, var(--bg) 70%); }+.st-vid { position: relative; height: min(100%, calc(100% - 54px)); aspect-ratio: 9 / 16; max-width: 100%; border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 30px 60px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06); cursor: pointer; flex: 1 1 auto; min-height: 0; }+.st-zw { position: absolute; inset: 0; transform-origin: 50% 40%; will-change: transform; }+.st-zw video { width: 100%; height: 100%; object-fit: cover; display: block; }+.st-cap, .st-gfx { position: absolute; inset: 0; pointer-events: none; }+.st-capt { position: absolute; left: calc(120 / 1080 * 100%); width: calc(840 / 1080 * 100%); margin-top: -0.6em; text-align: center; line-height: 1.18; paint-order: stroke fill; transform-origin: 50% 50%; will-change: transform, opacity; }+.st-capt[hidden] { display: none; }+.st-capt .w { display: inline-block; }+.st-capt .ch { font-style: normal; }+.st-capt.ticker { left: 0; width: 100%; height: 1.5em; margin-top: -0.75em; line-height: 1.5em; text-align: left; white-space: nowrap; overflow: hidden; padding-right: 1em; box-shadow: 0 .2em .6em rgba(0,0,0,.35); }+.st-capt .tag { display: inline-block; padding: 0 .35em; margin: 0 .5em 0 calc(60 / 1080 * 100vw * 0); color: #fff; font-size: .62em; vertical-align: middle; height: 100%; }+.st-glass { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }+.st-glass .gl { position: absolute; left: 0; top: 0; background: rgba(0,0,0,.001); }+.st-gframe { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; border: 0; transform-origin: 0 0; pointer-events: none; background: transparent; color-scheme: dark; }+.st-gframe[hidden] { display: none; }+.st-capsel { position: absolute; left: 0; top: 0; border: 1.5px solid var(--accent); border-radius: 6px; pointer-events: none; }+.st-capsel::before, .st-capsel::after { content: ""; position: absolute; width: 8px; height: 8px; background: #fff; border: 1.5px solid var(--accent); border-radius: 2px; top: -5px; left: -5px; }+.st-capsel::after { left: auto; right: -5px; top: auto; bottom: -5px; }+.st-capsel[hidden] { display: none; }+.st-vbadge { position: absolute; top: 10px; left: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.7); font-size: 11.5px; font-weight: 600; color: var(--ink-2); }+.st-vbadge[hidden] { display: none; }+/* thẻ đồ hoạ xem trước (gần đúng thẻ HyperFrames) */+.st-gcard { position: absolute; left: 0; top: 0; border-radius: .7em; padding: .7em .9em; background: rgba(22,24,32,.86); color: #fff; box-shadow: 0 .4em 1.2em rgba(0,0,0,.4); font-family: 'Be Vietnam Pro', sans-serif; line-height: 1.25; }+.st-gcard .h { font-weight: 700; margin-bottom: .45em; }+.st-gcard .h .u, .st-gcard .kick { color: var(--violet); font-weight: 600; }+.st-gcard .row { display: flex; justify-content: space-between; gap: .6em; padding: .3em 0 .3em .5em; border-left: 2px solid rgba(255,255,255,.25); margin-top: .25em; font-size: .9em; }+.st-gcard .row b { font-variant-numeric: tabular-nums; }+.st-gcard .big { font: 800 2.2em/1.05 'Barlow Condensed', sans-serif; text-transform: uppercase; color: var(--accent); }+.st-gcard .lbl { font-size: .85em; color: rgba(255,255,255,.7); }+.st-ctrl { display: flex; align-items: center; gap: 16px; color: var(--ink-2); flex: none; }+.st-time { font-size: 13px; color: var(--ink-2); min-width: 122px; text-align: right; }+.st-time b { color: var(--ink); font-weight: 600; }+.st-play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; cursor: pointer; transition: transform .1s; }+.st-play:active { transform: scale(.94); }+.st-play .ic { width: 18px; height: 18px; }+.st-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--panel-2); color: var(--ink-2); border: 0; white-space: nowrap; }+.st-pill.warn { color: var(--warn); background: var(--warn-soft); }+button.st-pill { cursor: pointer; min-height: 30px; }+button.st-pill:hover { color: var(--ink); }+.st-outsw[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }+.st-outsw[hidden] { display: none; }++/* ---- bảng thuộc tính ---- */+.st-insp { width: 364px; flex: none; border-left: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }+.st-grab { display: none; }+.st-ih { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; padding: 16px 18px 12px; margin: 0; flex: none; }+.st-ih > .btn { margin-left: auto; }+.st-ib { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 16px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }+.st-ib > .st-seg { position: sticky; top: 0; z-index: 2; box-shadow: 0 -10px 0 var(--bg-2), 0 8px 10px -4px var(--bg-2); }+.st-seg { display: flex; margin: 0 8px; background: var(--panel); border-radius: 10px; padding: 3px; gap: 2px; flex: none; }+.st-seg button { flex: 1; min-height: 30px; border-radius: 7px; border: 0; background: none; font-size: 13px; font-weight: 500; color: var(--ink-3); cursor: pointer; }+.st-seg button.on { background: var(--panel-3); color: var(--ink); }+.st-seg.sm { margin: 0; }+.st-lines { list-style: none; margin: 0; padding: 2px 0 0; display: flex; flex-direction: column; gap: 2px; position: relative; }+.st-ln .row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; }+.st-ln .row:hover { background: var(--panel); }+.st-ln.now .row { color: var(--ink); background: rgba(255,255,255,.035); }+.st-ln .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }+.st-ln .tx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.st-ln em { font-style: normal; color: var(--accent); }+.st-ln .flag { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }+.st-ln.bad .row { box-shadow: inset 2px 0 0 var(--bad); }+.st-ln.sel { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; margin: 2px 0; }+.st-ledit { width: 100%; min-height: 40px; background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 0 12px; font-size: 15px; font-weight: 500; color: var(--ink); outline: none; }+.st-ledit:focus { box-shadow: 0 0 0 3px rgba(255,107,44,.18); }+.st-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }+.st-row .arrow { color: var(--ink-4); }+.st-acts { margin-left: auto; display: flex; gap: 6px; }+.st-tbox { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 9px; border-radius: 7px; background: var(--bg); border: 1px solid var(--line-2); color: var(--ink-2); }+.st-tbox .ic { width: 13px; height: 13px; }+.st-tbox input { width: 58px; border: 0; background: none; font-size: 12px; color: var(--ink-2); outline: none; -moz-appearance: textfield; }+.st-tbox input::-webkit-inner-spin-button { opacity: .4; }+.st-ainote { margin: 0; font-size: 12px; color: var(--warn); display: flex; gap: 6px; align-items: center; }+.st-ainote .ic { width: 14px; height: 14px; }+.st-err { margin: 0; font-size: 12px; color: var(--bad); }+.st-note { margin: 0 8px; font-size: 12.5px; color: var(--ink-3); background: var(--panel); border-radius: 8px; padding: 8px 10px; }+.st-note.warn { color: var(--warn); background: var(--warn-soft); }+.st-note:empty { display: none; }+.st-hint { margin: 0 8px; font-size: 12.5px; color: var(--ink-3); }+.st-empty { color: var(--ink-3); text-align: center; padding: 24px 8px; margin: 0; }+.st-lines .none, .st-blist .none { color: var(--ink-3); padding: 12px 10px; font-size: 13px; }+/* kiểu chữ */+.st-looks { padding: 4px 8px; display: flex; flex-direction: column; gap: 12px; }+.st-lookgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }+.st-look { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 6px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; text-align: center; }+.st-look:hover:not(:disabled) { border-color: var(--ink-4); }+.st-look.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,107,44,.25); }+.st-look .smp { height: 46px; display: grid; place-items: center; border-radius: 7px; background: #0b0b0a; font-size: 24px; color: #fff; grid-auto-flow: column; justify-content: center; gap: 1px; }+.st-look .nm { font-size: 11.5px; color: var(--ink-2); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }+.st-switch { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-2); }+.st-switch input { width: 34px; height: 20px; appearance: none; -webkit-appearance: none; border-radius: 20px; background: var(--panel-3); position: relative; cursor: pointer; flex: none; transition: background .15s; }+.st-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2); transition: transform .15s; }+.st-switch input:checked { background: var(--accent); }+.st-switch input:checked::after { transform: translateX(14px); background: #fff; }+.st-switch input:disabled { opacity: .4; }+.st-switch small { flex-basis: 100%; color: var(--ink-4); font-size: 12px; margin-top: -6px; padding-left: 44px; }+.st-switch.sm { min-height: 30px; }+/* ô chung */+.st-field { display: flex; flex-direction: column; gap: 6px; padding: 0 8px; font-size: 12.5px; color: var(--ink-3); }+.st-field > span, .st-field > label { font-weight: 600; }+.st-field input[type=text], .st-field input[type=number], .st-sel, .st-ai textarea { width: 100%; min-height: 36px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; font-size: 14px; color: var(--ink); }+.st-field input:focus, .st-sel:focus, .st-ai textarea:focus { border-color: var(--accent); outline: none; }+.st-slide { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; }+.st-slide label { grid-column: 1 / -1; }+.st-slide input { accent-color: var(--accent); width: 100%; height: 24px; }+.st-slide output { font-size: 12.5px; color: var(--ink); min-width: 56px; text-align: right; }+.st-ib > .st-row, .st-ib > .st-switch { padding: 0 8px; }+.st-ib hr { border: 0; border-top: 1px solid var(--line); margin: 4px 8px; width: auto; }+.st-card { margin: 0 8px; padding: 12px 4px; border-radius: 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); display: flex; flex-direction: column; gap: 12px; }+.st-card > .st-row, .st-card > .st-seg, .st-card > .btn, .st-card > .st-hint { margin: 0 8px; }+.st-card > .btn { align-self: flex-start; }+.st-gtype { font-size: 14px; }+.st-grow { margin: 0 8px; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 0 10px; display: flex; flex-direction: column; gap: 8px; }+.st-grow legend { font-size: 11.5px; color: var(--ink-4); padding: 0 6px; margin-left: 6px; }+.st-blist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }+.st-blist button { width: 100%; display: flex; gap: 12px; align-items: center; min-height: 36px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; }+.st-blist button:hover { background: var(--panel); }+.st-blist button.on { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }+.st-blist .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }+.st-blist .lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+/* xem lại */+.st-review { display: flex; flex-direction: column; gap: 12px; }+.st-rcard { margin: 0 8px; padding: 12px; border-radius: 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px rgba(242,201,76,.35); display: flex; flex-direction: column; gap: 8px; }+.st-rtop { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-3); }+.st-rnav { margin-left: auto; display: flex; gap: 6px; }+.st-rwhat { margin: 0; font-size: 15px; }+.st-rwhat .k { font-size: 11.5px; color: var(--warn); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }+.st-rwhat s { color: var(--ink-3); }+.st-rwhy { margin: 0; font-size: 12px; color: var(--ink-3); }+.st-rdone { margin: 0; font-size: 12px; color: var(--ok); }+.st-racts { display: flex; gap: 6px; flex-wrap: wrap; }+.st-racts .btn { flex: 1; min-height: 34px; font-size: 13px; padding: 0 10px; }+.st-rlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }+.st-ritem { width: 100%; display: flex; gap: 10px; align-items: center; min-height: 34px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; font-size: 13px; }+.st-ritem:hover { background: var(--panel); }+.st-ritem.on { background: var(--panel-2); color: var(--ink); }+.st-ritem.done { color: var(--ink-4); }+.st-ritem .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }+.st-ritem .rx { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.st-ritem s { color: var(--ink-4); }+.st-ritem .ic { color: var(--ok); width: 15px; height: 15px; }+/* AI */+.st-ai { margin: 0 8px; display: flex; flex-direction: column; gap: 10px; }+.st-ai textarea { padding: 10px; min-height: 84px; resize: vertical; font-size: 14px; line-height: 1.45; }+.st-chips { display: flex; flex-wrap: wrap; gap: 6px; }+.st-chips .chip { min-height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--panel); font-size: 12.5px; color: var(--ink-2); }+.st-chips .chip:hover { color: var(--ink); }+.st-ai .btn { align-self: flex-start; }+.st-h4 { margin: 8px 8px 0; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }+.st-hist { margin: 0 8px; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-2); }+.st-hist li { padding: 8px 10px; background: var(--panel); border-radius: 8px; overflow-wrap: anywhere; }+.st-hist small { display: block; color: var(--ink-4); margin-top: 3px; }+.st-insp.ro .st-ln .row { cursor: pointer; }++/* ---- timeline ---- */+.st-tl { height: var(--tl-h); flex: none; border-top: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }+.tl-bar { height: 42px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 14px; border-bottom: 1px solid var(--line); }+.tl-bar .ib.mini { background: transparent; }+.tl-bar .ib.mini:hover:not(:disabled) { background: var(--panel-2); }+.tl-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }+.tl-hint { font-size: 12px; color: var(--ink-4); margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.tl-zoomer { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--ink-3); }+.tl-zoomer > .ic { width: 15px; height: 15px; }+.tl-zoomer input { width: 120px; accent-color: var(--ink-2); }+.tl-main { flex: 1; min-height: 0; display: flex; }+.tl-labs { width: 96px; flex: none; display: flex; flex-direction: column; }+.tl-labs .lab { display: flex; align-items: center; gap: 7px; padding-left: 16px; font-size: 12px; color: var(--ink-3); border: 0; background: none; text-align: left; cursor: pointer; transition: color .12s, opacity .12s; }+.tl-labs .lab .ic { width: 15px; height: 15px; }+.tl-labs .lab:hover { color: var(--ink); }+.tl-labs .lab.on { color: var(--accent); }+.tl-labs .lab.ruler { cursor: default; }+.tl-sc { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; position: relative; scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }+.tl-in { position: relative; height: 100%; min-width: 100%; }+/* chiều cao hàng: thước 26 · video 66 · phụ đề 34 · zoom 30 · đồ hoạ 32 · nhạc 50 */+.tl-labs .lab.ruler, .tl-ruler { height: 26px; flex: none; }+.tl-labs .lab[data-k="video"], .r-video { height: 66px; }+.tl-labs .lab[data-k="cap"], .r-cap { height: 34px; }+.tl-labs .lab[data-k="zoom"], .r-zoom { height: 30px; }+.tl-labs .lab[data-k="gfx"], .r-gfx { height: 32px; }+.tl-labs .lab[data-k="music"], .r-music { height: 50px; }+.tl-ruler { position: relative; cursor: pointer; touch-action: none; }+.tl-ruler i { position: absolute; left: 0; bottom: 0; width: 1px; height: 5px; background: var(--line-2); }+.tl-ruler i.mj { height: 9px; background: var(--ink-4); }+.tl-ruler span { position: absolute; left: 0; top: 4px; font-size: 10.5px; color: var(--ink-4); pointer-events: none; }+.tl-row { position: relative; transition: opacity .15s; }+.st-tl[data-focus] .tl-row:not(.r-video) { opacity: .55; }+.st-tl[data-focus="cap"] .r-cap, .st-tl[data-focus="zoom"] .r-zoom, .st-tl[data-focus="gfx"] .r-gfx, .st-tl[data-focus="music"] .r-music { opacity: 1; }+.st-tl[data-focus="cap"] .lab[data-k="cap"], .st-tl[data-focus="zoom"] .lab[data-k="zoom"], .st-tl[data-focus="gfx"] .lab[data-k="gfx"], .st-tl[data-focus="music"] .lab[data-k="music"] { color: var(--accent); }+.st-tl[data-focus="cap"] .r-cap, .st-tl[data-focus="zoom"] .r-zoom, .st-tl[data-focus="gfx"] .r-gfx, .st-tl[data-focus="music"] .r-music { background: linear-gradient(90deg, rgba(255,107,44,.05), rgba(255,107,44,.02)); }+.tl-cv { position: sticky; left: 0; display: block; pointer-events: none; margin-top: 4px; z-index: 2; }+.blk { position: absolute; left: 0; top: 4px; bottom: 4px; border-radius: 7px; overflow: hidden; display: flex; align-items: center; padding: 0 7px; font-size: 11px; font-weight: 500; white-space: nowrap; cursor: grab; will-change: transform; touch-action: none; }+.blk .t { overflow: hidden; text-overflow: ellipsis; min-width: 0; pointer-events: none; }+.blk::before, .blk::after { content: ""; position: absolute; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }+.blk::before { left: 0; } .blk::after { right: 0; }+.blk.on::before, .blk.on::after { background: rgba(255,255,255,.35); }+.blk.armed { box-shadow: 0 0 0 2px #fff; }+.blk.drag { cursor: grabbing; z-index: 3; box-shadow: 0 6px 16px rgba(0,0,0,.45); }+.blk.narrow { padding: 0 3px; }+.blk.narrow .t { text-overflow: clip; }+.blk.ro { cursor: pointer; }+.blk.ro::before, .blk.ro::after { cursor: pointer; }+.blk.cap { background: #3B2A1F; border: 1px solid #5a3a25; color: #F5C9A8; }+.blk.cap.w { background: #3a3218; border-color: #6b5a1c; color: var(--warn); }+.blk.cap.bad { border-color: var(--bad); }+.blk.cap.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }+.blk.zoom { top: 4px; bottom: 4px; background: var(--sky-soft); border: 1px solid rgba(108,196,240,.45); color: var(--sky); font-weight: 600; }+.blk.zoom.on { background: rgba(108,196,240,.32); border-color: var(--sky); color: #fff; }+.blk.gfx { background: var(--violet-soft); border: 1px solid rgba(167,139,250,.45); color: #C9B8FF; font-weight: 600; }+.blk.gfx.on { background: rgba(167,139,250,.34); border-color: var(--violet); color: #fff; }+.blk.mu { top: 4px; bottom: 4px; background: rgba(93,211,158,.08); border: 1px solid rgba(93,211,158,.35); cursor: pointer; align-items: flex-start; padding-top: 3px; z-index: 1; }+.blk.mu.on { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }+.blk.mu::before, .blk.mu::after { display: none; }+.blk[hidden] { display: none; }+.tl-mlab { font-size: 11px; font-weight: 600; color: var(--ok); text-shadow: 0 1px 2px rgba(0,0,0,.6); }+.r-music.empty::after { content: attr(data-empty); position: sticky; left: 14px; top: 0; display: inline-block; padding: 16px 0 0 14px; font-size: 12px; color: var(--ink-4); }+.tl-head { position: absolute; top: 6px; bottom: 6px; left: 0; width: 2px; background: var(--accent); z-index: 6; cursor: ew-resize; touch-action: none; }+.tl-head .knob { position: absolute; top: -4px; left: -6px; width: 14px; height: 14px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%); }+.tl-head::after { content: ""; position: absolute; inset: 0 -6px; }+.tl-guide { position: absolute; top: 26px; bottom: 0; left: 0; width: 1px; background: #fff; opacity: .8; z-index: 5; pointer-events: none; }+.tl-guide[hidden] { display: none; }+.tl-tip { position: absolute; left: 0; top: 0; padding: 2px 6px; border-radius: 5px; background: #000; color: #fff; font: 600 11px/1.4 var(--mono); z-index: 7; pointer-events: none; white-space: nowrap; }+.tl-tip[hidden] { display: none; }+.tl-edit { position: absolute; left: 0; top: 0; height: 30px; z-index: 8; background: var(--bg); border: 1.5px solid var(--accent); border-radius: 7px; padding: 0 8px; font-size: 13px; color: var(--ink); outline: none; box-shadow: 0 8px 24px rgba(0,0,0,.5); }++/* ---- lớp chờ, thông báo ---- */+.st-wait { position: absolute; inset: 56px 0 0 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(14,13,11,.92); text-align: center; padding: 24px; }+.st-wait[hidden] { display: none; }+.st-wait p { margin: 0; font-size: 15px; color: var(--ink-2); max-width: 520px; }+.st-wbar { width: 280px; height: 3px; border-radius: 2px; background: var(--panel-3); overflow: hidden; }+.st-wbar[hidden] { display: none; }+.st-wbar i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); transition: transform .5s; }+.st-toast { position: absolute; left: 50%; bottom: calc(var(--tl-h) + 16px); transform: translateX(-50%); z-index: 30; max-width: min(640px, calc(100% - 32px)); padding: 10px 16px; border-radius: 10px; background: #26241f; color: var(--ink); box-shadow: 0 12px 30px rgba(0,0,0,.5); font-size: 13.5px; border: 1px solid var(--line-2); }+.st-toast[hidden] { display: none; }+.st-toast.ok { border-color: rgba(93,211,158,.5); color: var(--ok); }+.st-toast.bad { border-color: rgba(255,100,100,.5); color: #FFB0B0; }+.st-scrim { display: none; }++@media (max-width: 1180px) { .st-insp { width: 320px; } .st-title { max-width: 200px; } .st-reset { display: none; } }++/* ---- điện thoại < 768: player trên, công cụ ngang, timeline cuộn ngang, bảng thành sheet dưới ---- */+@media (max-width: 767px) {+ .studio { --tl-h: 262px; }+ .st-top { height: 52px; gap: 6px; padding: 0 8px 0 4px; }+ .st-title { max-width: none; flex: 1; }+ .st-title span { display: none; }+ .st-vers { display: none; }+ .st-mid { margin: 0; }+ .st-mid .ib { width: 34px; }+ .st-revb > span:not(.num), .st-dl span, .st-pub span { display: none; }+ .st-top .btn { min-height: 36px; padding: 0 10px; }+ .st-main { flex-direction: column; }+ .st-rail { width: auto; height: 52px; flex-direction: row; justify-content: space-around; padding: 4px 6px; border-right: 0; border-top: 1px solid var(--line); order: 2; }+ .st-rail button { width: auto; flex: 1; height: 46px; gap: 2px; font-size: 10.5px; border-radius: 10px; }+ .st-rail .l { white-space: nowrap; }+ .st-rail button .ic { width: 18px; height: 18px; }+ .st-rail .sep { width: 1px; height: 24px; margin: 0 2px; }+ .st-rail .dot { top: 1px; right: calc(50% - 20px); }+ .st-stage { order: 1; flex: 1; min-height: 0; padding: 8px; gap: 8px; }+ .st-ctrl { gap: 10px; }+ .st-time { min-width: 0; font-size: 12px; }+ .st-ratio, .st-ctrl .mono.st-pill { display: none; }+ .st-insp { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 62vh; border-left: 0; border-top: 1px solid var(--line-2); border-radius: 16px 16px 0 0; z-index: 40; transform: translateY(105%); transition: transform .22s ease-out; box-shadow: 0 -16px 40px rgba(0,0,0,.5); padding-bottom: env(safe-area-inset-bottom); }+ .st-insp.open { transform: none; }+ .st-grab { display: block; width: 100%; height: 22px; border: 0; background: none; cursor: pointer; flex: none; position: relative; }+ .st-grab::after { content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--ink-4); }+ .st-ih { padding-top: 4px; }+ .st-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }+ .st-scrim.on { opacity: 1; pointer-events: auto; }+ .tl-bar { padding: 0 8px; gap: 2px; overflow-x: auto; }+ .tl-hint { display: none; }+ .tl-zoomer input { width: 70px; }+ .tl-labs { width: 40px; }+ .tl-labs .lab { padding-left: 12px; }+ .tl-labs .lab span { display: none; }+ .r-video, .tl-labs .lab[data-k="video"] { height: 50px; }+ .r-music, .tl-labs .lab[data-k="music"] { height: 40px; }+ .st-toast { bottom: calc(var(--tl-h) + 60px); }+}+@media (prefers-reduced-motion: reduce) {+ .st-prog i, .st-wbar i, .st-insp, .tl-row, .st-rail button { transition: none; }+}diff --git a/server/public/studio/studio.js b/server/public/studio/studio.jsindex 21fb494..a114452 100644--- a/server/public/studio/studio.js+++ b/server/public/studio/studio.js@@ -131,7 +131,7 @@ class Studio {const same = id === this.id;this.id = id; this.rev = rev;this.R.hidden = false; document.body.classList.add('studio-on');- if (!same) { this.sel = null; this.edl = null; this.player.release(); this.timeline.setStrip(null); this.timeline.setWave(null); this.review.reset(id); }+ if (!same) { this.zoomSet = false; this.sel = null; this.edl = null; this.player.release(); this.timeline.setStrip(null); this.timeline.setWave(null); this.review.reset(id); }try {this.job = await getJSON(`/api/edits/${encodeURIComponent(id)}`);} catch (e) { this.showWait(t('st.notFound', { e: I.srv(e.message) }), null); return; }@@ -149,8 +149,9 @@ class Studio {this.hideWait();this.store.load(id, v);if (this.sel && !this.findSel(this.sel)) this.sel = null;- this.player.setSources({ base: safeUrl(v.media.base), out: safeUrl(v.media.out), music: null });- this.timeline.fitAll();+ this.player.setSources({ clean: safeUrl(v.media.clean), base: safeUrl(v.media.base), out: safeUrl(v.media.out), music: null });+ this.gfxKey = null; this.refreshGfx(true);+ if (!this.zoomSet) { this.timeline.openDefault(); this.zoomSet = true; }this.loadMedia(v);if (!v.readOnly) this.loadEdl();this.repaintAll();@@ -246,9 +247,29 @@ class Studio {this.insp.render();this.player.lastCap = null; this.player.lastGfx = ''; this.player.tick();this.paintTop(); this.paintRail();+ this.refreshGfx();if (this.store.doc?.music.source !== this.waveSrc) this.loadWave();else this.player.syncAudio(false);}+ /** Cảnh đồ hoạ xem trước: server dựng HTML/CSS từ đồ hoạ đang sửa (giờ + ô chữ/số), khung sandbox vẽ theo t. */+ refreshGfx(now) {+ const v = this.store.view; const id = this.id;+ if (!v || v.readOnly) { this.player.setGfxScene(null); return; }+ const rows = (d) => Object.fromEntries(Object.entries(d || {}).map(([k, x]) => [k, Array.isArray(x) ? x.map((r, i) => ({ k: i, ...r })) : x]));+ const list = this.store.doc.gfx.map((g) => ({ id: g.id, at: r2(g.at), until: r2(g.until), data: rows(g.data) }));+ const key = JSON.stringify(list);+ if (key === this.gfxKey) return;+ this.gfxKey = key;+ clearTimeout(this.gfxT);+ const go = async () => {+ if (!list.length) { this.player.setGfxScene(null); return; }+ try {+ const sc = await postJSON(`/api/edits/${encodeURIComponent(id)}/gfx-preview`, { graphics: list });+ if (this.id === id && this.gfxKey === key) this.player.setGfxScene(sc);+ } catch { /* ô đang gõ dở (vd số rỗng): giữ cảnh trước */ }+ };+ if (now) go(); else this.gfxT = setTimeout(go, 160);+ }onTime(tt) { this.timeline.setTime(tt); this.insp.onTime(tt); }seek(tt) { this.player.seek(tt); }@@ -365,7 +386,7 @@ class Studio {}this.watchJob(true);}- reloadSources() { const v = this.store.view; if (!v) return; this.player.setSources({ base: safeUrl(v.media.base), out: safeUrl(v.media.out) }); this.loadWave(true); }+ reloadSources() { const v = this.store.view; if (!v) return; this.player.setSources({ clean: safeUrl(v.media.clean), base: safeUrl(v.media.base), out: safeUrl(v.media.out) }); this.loadWave(true); }async revise(text) {const id = this.id;this.player.release();@@ -472,7 +493,7 @@ class Studio {const w = words.get(f.word);out.push({ key: `fix:${f.word}`, kind: 'fix', at: toOut(w ? w.start : null), heard: heard.trim(), text: f.text || '', why: '' });}- for (const f of j.checks?.figures || []) out.push({ key: `fig:${f.at}:${f.text}`, kind: 'fig', at: toOut(f.at), heard: f.said || f.heard || '', text: f.text || '', why: f.why || '' });+ for (const f of j.checks?.figures || []) out.push({ key: `fig:${f.at}:${f.text}`, kind: 'fig', at: toOut(f.at), heard: f.said || f.heard || '', relisten: f.heard || '', text: f.text || '', why: f.why || '', gtype: f.type || null, where: f.where || null, value: f.value });list = out.filter((x) => x.at != null).sort((a, b) => a.at - b.at);idx = Math.max(0, list.findIndex((x) => !res[x.key]));},@@ -506,11 +527,66 @@ class Studio {S.seek(it.at); S.select({ kind: 'cap', u: l.u });S.paintTop(); S.paintRail();},+ /** Số trên đồ hoạ: ô đồ hoạ tương ứng {g, path, cur} (cùng loại, đang hiện quanh lúc đó) hoặc null. */+ figTarget(it) {+ if (it.kind !== 'fig' || !it.gtype || !it.where) return null;+ const gs = (S.store.doc?.gfx || []).filter((g) => g.type === it.gtype && it.at >= g.at - 0.6 && it.at <= g.until + 0.6)+ .sort((a, b) => Math.abs(a.at - it.at) - Math.abs(b.at - it.at));+ const w = String(it.where); let m;+ const pathOf = (g) => {+ if (w === 'value' || w === 'old') return [w];+ if ((m = /^(mục|điểm) (\d+)$/u.exec(w))) return [m[1] === 'mục' ? 'items' : 'points', +m[2], 'value'];+ if ((m = /^dòng (\d+)(?: ([ab]))?$/u.exec(w))) return ['rows', +m[1], m[2] || 'value'];+ if ((m = /^ý (\d+)$/u.exec(w))) return ['items', +m[1], 'text'];+ return null;+ };+ for (const g of gs) {+ const pth = pathOf(g); if (!pth) continue;+ let o = g.data; for (const k of pth) { if (o == null) break; o = o[k]; }+ if (typeof o === 'string' || typeof o === 'number') return { g, path: pth, cur: o };+ }+ return null;+ },+ /** Số nghe được (nghe lại riêng trước, rồi lời chép): "9 rưỡi" → 9,5. */+ heardNums(it) {+ const out = [];+ for (const src of [it.relisten, it.heard]) {+ const s0 = String(src || '').replace(/(\d+)\s+rư[ỡở]i/giu, (_, n) => `${n},5`);+ for (const x of s0.match(/\d+(?:[.,]\d+)?/g) || []) out.push(x);+ if (out.length) break;+ }+ return out;+ },+ /** Giá trị trả lại cho ô đồ hoạ: số nghe được đầu tiên khác số đang in. */+ figRevertValue(it, tg) {+ const nums = R.heardNums(it); const num = (x) => Number(String(x).replace(',', '.'));+ if (typeof tg.cur === 'number') { const x = nums.map(num).find((v) => Number.isFinite(v) && v !== tg.cur); return x ?? null; }+ // ô chữ ("22–23"): thay lần lượt từng số trong ô bằng số nghe được cùng vị trí (cửa sổ bắt đầu ở số trùng số đầu ô)+ const curNums = String(tg.cur).match(/\d+(?:[.,]\d+)?/g) || [];+ if (!curNums.length || !nums.length) return null;+ let i0 = nums.indexOf(curNums[0]); if (i0 < 0 || i0 + curNums.length > nums.length) i0 = Math.max(0, nums.length - curNums.length);+ let k = 0;+ const v = String(tg.cur).replace(/\d+(?:[.,]\d+)?/g, (x) => nums[i0 + k++] ?? x);+ return v === String(tg.cur) ? null : v;+ },canRevert(it) {+ if (it.kind === 'fig') { const tg = R.figTarget(it); return !!tg && R.figRevertValue(it, tg) != null; }if (!it.text || !it.heard) return false;const l = R.lineOf(it); return !!l && plain(l.text).toLowerCase().includes(it.text.toLowerCase());},revert(it) {+ if (it.kind === 'fig') {+ const tg = R.figTarget(it); if (!tg) return;+ const v = R.figRevertValue(it, tg); if (v == null) return;+ S.store.commit((d) => {+ const g = d.gfx.find((x) => x.u === tg.g.u); if (!g) return;+ let o = g.data; for (let k = 0; k < tg.path.length - 1; k++) o = o[tg.path[k]];+ o[tg.path[tg.path.length - 1]] = v;+ });+ S.select({ kind: 'gfx', u: tg.g.u }, { quiet: true });+ R.resolve(it, 'revert');+ return;+ }const l = R.lineOf(it); if (!l || !R.canRevert(it)) return;S.store.commit((d) => {const x = d.lines.find((y) => y.u === l.u); if (!x) return;diff --git a/server/public/studio/timeline.js b/server/public/studio/timeline.jsindex f19f12a..0cc43a5 100644--- a/server/public/studio/timeline.js+++ b/server/public/studio/timeline.js@@ -2,7 +2,7 @@// Khối phụ đề/zoom/đồ hoạ: kéo thân để dời, kéo mép để đổi giờ, không đè nhau, hít vào mép khối bên cạnh + đầu phát.// Mượt: khi kéo chỉ đổi transform/width của đúng 1 khối (rAF), thả tay mới ghi vào store (1 bước Undo) và vẽ lại track.// Dải ảnh + sóng nhạc vẽ trên canvas "dính" (sticky) đúng bề rộng khung nhìn, vẽ lại khi cuộn/phóng.-import { el, tx, icon, iconBtn, fmtT, fmtDb, plain, clamp, t } from './util.js';+import { el, tx, icon, iconBtn, fmtT, fmtDb, plain, clamp, t, tokens, store as ls } from './util.js';const PAD = 14;const ROWS = ['video', 'cap', 'zoom', 'gfx', 'music'];@@ -30,7 +30,8 @@ export class Timeline {this.range = el('input', null, null, { type: 'range', min: '0', max: '1000', step: '1', 'aria-label': t('st.tlZoom') });this.range.dataset.i18nAria = 'st.tlZoom';this.bInZ = iconBtn('plus', 'st.zoomIn', 'mini');- zm.append(icon('mag'), this.bOutZ, this.range, this.bInZ);+ this.bFit = iconBtn('fit', 'st.fitAll', 'mini');+ zm.append(icon('mag'), this.bOutZ, this.range, this.bInZ, this.bFit);this.hint = el('span', 'tl-hint');bar.append(this.bSplit, this.bMerge, this.bDel, sep, this.bAddZ, this.hint, zm);// ---- nhãn track + vùng cuộn ----@@ -82,8 +83,26 @@ export class Timeline {if (!quiet) this.sc.scrollLeft = Math.max(0, PAD + tAnchor * this.pps - ax);this.draw();}- /** Mở bản: ≥ 60 px/giây (đọc được chữ phụ đề), video ngắn thì vừa khung. */- fitAll() { const w = this.sc.clientWidth || 900; if (this.dur > 0) { this.setPps(Math.max(60, (w - PAD * 2 - 20) / this.dur), true); this.sc.scrollLeft = 0; } }+ /** Vừa khung: thấy toàn bộ video. */+ fitAll() { const w = this.sc.clientWidth || 900; if (this.dur > 0) { this.setPps((w - PAD * 2 - 20) / this.dur, true); this.sc.scrollLeft = 0; } }+ /**+ * Mức phóng khi mở: mức đã dùng lần trước trên máy này (localStorage), không có thì mức để khối phụ đề trung vị hiện+ * đủ 2 chữ đầu (~6,4 px/ký tự cỡ 11 px + lề 16 px). Video dài thì cuộn ngang.+ */+ openDefault() {+ const saved = Number(ls.get('lumreels.studio.pps'));+ let p = Number.isFinite(saved) && saved >= PPS_MIN && saved <= PPS_MAX ? saved : null;+ if (p == null) {+ const need = (this.ctx.store.doc?.lines || []).filter((l) => l.end - l.start > 0.05).map((l) => {+ const ws = tokens(l.text).slice(0, 2).map((w) => w.w).join(' ');+ return ([...ws].length * 6.4 + 18) / (l.end - l.start);+ }).sort((a, b) => a - b);+ p = need.length ? need[Math.floor(need.length / 2)] : 60;+ p = clamp(p, 40, PPS_MAX);+ }+ this.setPps(p, true); this.sc.scrollLeft = 0;+ }+ remember() { ls.set('lumreels.studio.pps', Math.round(this.pps * 10) / 10); }// ---- vẽ toàn bộ (nạp / đổi doc / phóng) ----layout() {@@ -231,14 +250,15 @@ export class Timeline {bind() {this.sc.addEventListener('scroll', () => this.draw(), { passive: true });new ResizeObserver(() => this.draw()).observe(this.sc);- this.range.addEventListener('input', () => this.setPps(this.rangeToPps(Number(this.range.value))));- this.bInZ.addEventListener('click', () => this.setPps(this.pps * 1.4));- this.bOutZ.addEventListener('click', () => this.setPps(this.pps / 1.4));+ this.range.addEventListener('input', () => { this.setPps(this.rangeToPps(Number(this.range.value))); this.remember(); });+ this.bInZ.addEventListener('click', () => { this.setPps(this.pps * 1.4); this.remember(); });+ this.bFit.addEventListener('click', () => this.fitAll());+ this.bOutZ.addEventListener('click', () => { this.setPps(this.pps / 1.4); this.remember(); });this.sc.addEventListener('wheel', (e) => {if (e.ctrlKey || e.metaKey) {e.preventDefault();const r = this.sc.getBoundingClientRect();- this.setPps(this.pps * Math.exp(-e.deltaY * 0.0022), false, e.clientX - r.left);+ this.setPps(this.pps * Math.exp(-e.deltaY * 0.0022), false, e.clientX - r.left); this.remember();} else if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) { e.preventDefault(); this.sc.scrollLeft += e.deltaY; }}, { passive: false });this.bSplit.addEventListener('click', () => this.ctx.splitAtHead?.());@@ -273,32 +293,49 @@ export class Timeline {// phím trên khối đang focus: Enter sửa chữ (thay bấm đúp)}/** Bắt đầu kéo 1 khối: mode l (mép trái) / r (mép phải) / move (thân). */+ /**+ * Bắt đầu kéo 1 khối: mode l (mép trái) / r (mép phải) / move (thân).+ * Cảm ứng: chạm nhanh = chọn; khối CHƯA chọn mà vuốt = cuộn timeline; khối đã chọn hoặc bấm giữ 350 ms = kéo+ * (mép rộng 16 px cho ngón tay).+ */down(e, b) {const kind = b.dataset.k; const u = b.dataset.u;const it = this.items(kind).find((x) => x.u === u); if (!it) return;const ro = !!this.ctx.store.view?.readOnly;+ const touch = e.pointerType === 'touch';const r = b.getBoundingClientRect(); const off = e.clientX - r.left;- const edge = Math.min(8, r.width / 3);+ const edge = Math.min(touch ? 16 : 8, r.width / 3);const mode = off <= edge ? 'l' : off >= r.width - edge ? 'r' : 'move';const sorted = this.items(kind).filter((x) => x.u !== u).sort((p, q) => p.a - q.a);const prev = sorted.filter((x) => x.b <= it.a + 1e-3).pop(); const next = sorted.find((x) => x.a >= it.b - 1e-3);const lo = prev ? prev.b : 0; const hi = next ? next.a : this.dur;const [minL, maxL] = LIMIT[kind];const snaps = [this.t, ...sorted.flatMap((x) => [x.a, x.b])];- const st = { kind, u, mode, x0: e.clientX, a0: it.a, b0: it.b, moved: false, lo, hi, minL, maxL, snaps, b, ref: it.ref };+ const sel = this.ctx.getSel?.();+ const st = { kind, u, mode, x0: e.clientX, a0: it.a, b0: it.b, moved: false, lo, hi, minL, maxL, snaps, b, ref: it.ref,+ armed: !touch || (sel?.kind === kind && sel.u === u), pan: false, sl0: this.sc.scrollLeft };b.setPointerCapture(e.pointerId);let raf = 0; let last = null;+ const hold = touch && !st.armed ? setTimeout(() => { if (!st.moved && !st.pan) { st.armed = true; b.classList.add('armed'); this.ctx.select({ kind, u }, { quiet: true }); navigator.vibrate?.(12); } }, 350) : 0;const mv = (ev) => {const dx = ev.clientX - st.x0;- if (!st.moved) { if (Math.abs(dx) < 3 || ro) return; st.moved = true; this.ctx.store.begin(); b.classList.add('drag'); this.ctx.select({ kind, u }, { quiet: true }); }+ if (st.pan) { this.sc.scrollLeft = st.sl0 - dx; return; }+ if (!st.moved) {+ if (Math.abs(dx) < (touch ? 6 : 3)) return;+ clearTimeout(hold);+ if (!st.armed) { st.pan = true; this.sc.scrollLeft = st.sl0 - dx; return; } // vuốt khối chưa chọn: cuộn+ if (ro) return;+ st.moved = true; this.ctx.store.begin(); b.classList.add('drag'); this.ctx.select({ kind, u }, { quiet: true });+ }last = dx;if (!raf) raf = requestAnimationFrame(() => { raf = 0; this.dragTo(st, last); });};const up = () => {+ clearTimeout(hold);b.removeEventListener('pointermove', mv); b.removeEventListener('pointerup', up); b.removeEventListener('pointercancel', up);- cancelAnimationFrame(raf);+ cancelAnimationFrame(raf); b.classList.remove('armed');if (st.moved) { if (last != null) this.dragTo(st, last); b.classList.remove('drag'); this.guide.hidden = true; this.tip.hidden = true; this.ctx.store.end(); }- else this.ctx.select({ kind, u });+ else if (!st.pan) this.ctx.select({ kind, u });};b.addEventListener('pointermove', mv); b.addEventListener('pointerup', up); b.addEventListener('pointercancel', up);}diff --git a/server/public/studio/util.js b/server/public/studio/util.jsindex 8b376df..aa734cb 100644--- a/server/public/studio/util.js+++ b/server/public/studio/util.js@@ -1,121 +1,122 @@-// Tiện ích chung của Studio + màn tạo mới. Chữ từ server chỉ vào DOM qua textContent (luật P2): el(tag, cls, text).-export const $ = (s, r = document) => r.querySelector(s);-export const $$ = (s, r = document) => [...r.querySelectorAll(s)];-export const I = window.I18N;-export const t = (k, v) => I.t(k, v);--/** Tạo phần tử; text đi qua textContent. attrs: {data-*, aria-*, type…} (giá trị là chuỗi, không phải HTML). */-export function el(tag, cls, text, attrs) {- const e = document.createElement(tag);- if (cls) e.className = cls;- if (text != null) e.textContent = text;- if (attrs) for (const [k, v] of Object.entries(attrs)) if (v != null && v !== false) e.setAttribute(k, v === true ? '' : String(v));- return e;-}-/** Phần tử có chữ dịch được: data-i18n (I18N.apply đổi lại khi đổi VI/EN). */-export function tx(tag, cls, key, attrs) { const e = el(tag, cls, t(key), attrs); e.dataset.i18n = key; return e; }--// bộ icon nét (Lucide-like), hằng số của app — không có dữ liệu người dùng-const P = {- back: 'M12 19l-7-7 7-7M19 12H5',- cap: 'M5 5h14a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3H5a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3zM7 14.5h4M14 14.5h3M7 10.5h2M12 10.5h5',- music: 'M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z',- zoom: 'M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7',- gfx: 'M6 3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3zM3 9h18M9 21V9',- ai: 'M11 3.5l1.8 5.2 5.2 1.8-5.2 1.8L11 17.5l-1.8-5.2L4 10.5l5.2-1.8zM19 15v5M16.5 17.5h5',- dl: 'M12 15V3M7 10l5 5 5-5M5 21h14',- warn: 'M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3zM12 9v4M12 17h.01',- pause: 'M8 5v14M16 5v14',- prev: 'M19 20L9 12l10-8zM5 19V5',- next: 'M5 4l10 8-10 8zM19 5v14',- undo: 'M9 14L4 9l5-5M4 9h11a5 5 0 0 1 0 10h-4',- redo: 'M15 14l5-5-5-5M20 9H9a5 5 0 0 0 0 10h4',- cut: 'M9 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM20 4L8.12 15.88M14.47 14.48L20 20M8.12 8.12L12 12',- trash: 'M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6',- merge: 'M7 4v4a4 4 0 0 0 4 4h2a4 4 0 0 1 4 4v4M17 4v4a4 4 0 0 1-4 4',- split: 'M12 3v18M7 8l-4 4 4 4M17 8l4 4-4 4',- plus: 'M12 5v14M5 12h14',- check: 'M20 6L9 17l-5-5',- x: 'M18 6L6 18M6 6l12 12',- upload: 'M12 15V3M17 8l-5-5-5 5M5 21h14',- film: 'M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zM7 3v18M17 3v18M3 7.5h4M3 12h18M3 16.5h4M17 7.5h4M17 16.5h4',- mag: 'M18 11a7 7 0 1 1-14 0 7 7 0 0 1 14 0zM21 21l-4.3-4.3',- clock: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0zM12 7v5l3 2',- minus: 'M5 12h14',- eye: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z',- pen: 'M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z',- rotate: 'M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5',- hi: 'M4 20h16M7 16l5-12 5 12M9 11h6',- right: 'M9 6l6 6-6 6',- left: 'M15 6l-6 6 6 6',- more: 'M5 12h.01M12 12h.01M19 12h.01',- send: 'M22 2L11 13M22 2l-7 20-4-9-9-4z',-};-const PLAY = 'M7 4.5v15l12.5-7.5z';-const NS = 'http://www.w3.org/2000/svg';-export function icon(name, cls) {- const s = document.createElementNS(NS, 'svg');- s.setAttribute('viewBox', '0 0 24 24'); s.setAttribute('aria-hidden', 'true'); s.setAttribute('focusable', 'false');- s.setAttribute('class', 'ic' + (cls ? ' ' + cls : ''));- const p = document.createElementNS(NS, 'path');- if (name === 'play') { p.setAttribute('d', PLAY); p.setAttribute('class', 'fill'); } else p.setAttribute('d', P[name] || '');- s.append(p);- return s;-}-/** Nút chỉ có icon: luôn có aria-label (+ title) dịch được. */-export function iconBtn(name, labelKey, cls, extra) {- const b = el('button', 'ib' + (cls ? ' ' + cls : ''), null, { type: 'button', ...(extra || {}) });- b.append(icon(name));- b.setAttribute('aria-label', t(labelKey)); b.title = t(labelKey);- b.dataset.i18nAria = labelKey; b.dataset.i18nTitle = labelKey;- return b;-}--export const clamp = (x, a, b) => Math.min(b, Math.max(a, x));-export const r2 = (x) => Math.round(x * 100) / 100;-/** 0:01.6 */-export const fmtT = (s) => { const x = Math.max(0, Math.round(s * 10) / 10); const m = Math.floor(x / 60); return `${m}:${(x - m * 60).toFixed(1).padStart(4, '0')}`; };-/** 0:36 */-export const fmtDur = (s) => { const x = Math.max(0, Math.round(s)); return `${Math.floor(x / 60)}:${String(x % 60).padStart(2, '0')}`; };-export const fmtDb = (x) => `${x > 0 ? '+' : x < 0 ? '−' : ''}${Math.abs(x)} dB`;-export const fmtMB = (b) => (b >= 1e9 ? (b / 1e9).toFixed(2) + ' GB' : Math.max(1, Math.round(b / 1e6)) + ' MB');-/** chỉ nhận đường dẫn cùng gốc ("/edits/…"), không nhận javascript:, //host… */-export const safeUrl = (u) => (typeof u === 'string' && /^\/(?!\/)/.test(u) ? u : null);-export const ID_RE = /^[\w-]{1,80}$/;--export async function getJSON(url) {- const r = await fetch(url, { cache: 'no-store' });- const j = await r.json().catch(() => ({}));- if (!r.ok) throw Object.assign(new Error(j.error || 'HTTP ' + r.status), { status: r.status });- return j;-}-export async function postJSON(url, body) {- const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });- const j = await r.json().catch(() => ({}));- if (!r.ok) throw Object.assign(new Error(j.error || 'HTTP ' + r.status), { status: r.status });- return j;-}-export const store = {- get(k, d = null) { try { const v = localStorage.getItem(k); return v == null ? d : JSON.parse(v); } catch { return d; } },- set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { /* đầy / riêng tư: bỏ qua */ } },- del(k) { try { localStorage.removeItem(k); } catch { /* bỏ qua */ } },-};-/** "*Giá* tăng" → [{w, hi}] (như edit/manual.mjs lineTokens) */-export function tokens(text) {- const out = []; const re = /\*([^*]+)\*|([^*]+)/g; let m;- while ((m = re.exec(String(text)))) { const hi = !!m[1]; for (const w of (m[1] || m[2]).split(/\s+/)) if (w.trim()) out.push({ w: w.trim(), hi }); }- return out;-}-export const untokens = (ws) => ws.map((w) => (w.hi ? `*${w.w}*` : w.w)).join(' ');-export const plain = (text) => String(text).replace(/\*/g, '');-/** Gắn chữ (có chữ nhấn) vào phần tử: chữ nhấn bọc <em>, tất cả qua textContent. */-export function paintWords(node, text, { hiClass = null } = {}) {- const ws = tokens(text);- node.replaceChildren();- ws.forEach((w, i) => {- if (i) node.append(' ');- if (w.hi) { const e = el('em', hiClass, w.w); node.append(e); } else node.append(w.w);- });-}-export const reduceMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;-export const narrow = () => window.matchMedia('(max-width: 767px)').matches;+// Tiện ích chung của Studio + màn tạo mới. Chữ từ server chỉ vào DOM qua textContent (luật P2): el(tag, cls, text).+export const $ = (s, r = document) => r.querySelector(s);+export const $$ = (s, r = document) => [...r.querySelectorAll(s)];+export const I = window.I18N;+export const t = (k, v) => I.t(k, v);++/** Tạo phần tử; text đi qua textContent. attrs: {data-*, aria-*, type…} (giá trị là chuỗi, không phải HTML). */+export function el(tag, cls, text, attrs) {+ const e = document.createElement(tag);+ if (cls) e.className = cls;+ if (text != null) e.textContent = text;+ if (attrs) for (const [k, v] of Object.entries(attrs)) if (v != null && v !== false) e.setAttribute(k, v === true ? '' : String(v));+ return e;+}+/** Phần tử có chữ dịch được: data-i18n (I18N.apply đổi lại khi đổi VI/EN). */+export function tx(tag, cls, key, attrs) { const e = el(tag, cls, t(key), attrs); e.dataset.i18n = key; return e; }++// bộ icon nét (Lucide-like), hằng số của app — không có dữ liệu người dùng+const P = {+ back: 'M12 19l-7-7 7-7M19 12H5',+ cap: 'M5 5h14a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3H5a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3zM7 14.5h4M14 14.5h3M7 10.5h2M12 10.5h5',+ music: 'M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z',+ zoom: 'M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7',+ gfx: 'M6 3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3zM3 9h18M9 21V9',+ ai: 'M11 3.5l1.8 5.2 5.2 1.8-5.2 1.8L11 17.5l-1.8-5.2L4 10.5l5.2-1.8zM19 15v5M16.5 17.5h5',+ dl: 'M12 15V3M7 10l5 5 5-5M5 21h14',+ warn: 'M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3zM12 9v4M12 17h.01',+ pause: 'M8 5v14M16 5v14',+ prev: 'M19 20L9 12l10-8zM5 19V5',+ next: 'M5 4l10 8-10 8zM19 5v14',+ undo: 'M9 14L4 9l5-5M4 9h11a5 5 0 0 1 0 10h-4',+ redo: 'M15 14l5-5-5-5M20 9H9a5 5 0 0 0 0 10h4',+ cut: 'M9 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM20 4L8.12 15.88M14.47 14.48L20 20M8.12 8.12L12 12',+ trash: 'M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6',+ merge: 'M7 4v4a4 4 0 0 0 4 4h2a4 4 0 0 1 4 4v4M17 4v4a4 4 0 0 1-4 4',+ split: 'M12 3v18M7 8l-4 4 4 4M17 8l4 4-4 4',+ plus: 'M12 5v14M5 12h14',+ check: 'M20 6L9 17l-5-5',+ x: 'M18 6L6 18M6 6l12 12',+ upload: 'M12 15V3M17 8l-5-5-5 5M5 21h14',+ film: 'M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zM7 3v18M17 3v18M3 7.5h4M3 12h18M3 16.5h4M17 7.5h4M17 16.5h4',+ mag: 'M18 11a7 7 0 1 1-14 0 7 7 0 0 1 14 0zM21 21l-4.3-4.3',+ clock: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0zM12 7v5l3 2',+ minus: 'M5 12h14',+ eye: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z',+ pen: 'M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z',+ rotate: 'M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5',+ hi: 'M4 20h16M7 16l5-12 5 12M9 11h6',+ right: 'M9 6l6 6-6 6',+ left: 'M15 6l-6 6 6 6',+ more: 'M5 12h.01M12 12h.01M19 12h.01',+ send: 'M22 2L11 13M22 2l-7 20-4-9-9-4z',+ fit: 'M3 8V5a2 2 0 0 1 2-2h3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M8 21H5a2 2 0 0 1-2-2v-3M8 12h8M8 12l2-2M8 12l2 2M16 12l-2-2M16 12l-2 2',+};+const PLAY = 'M7 4.5v15l12.5-7.5z';+const NS = 'http://www.w3.org/2000/svg';+export function icon(name, cls) {+ const s = document.createElementNS(NS, 'svg');+ s.setAttribute('viewBox', '0 0 24 24'); s.setAttribute('aria-hidden', 'true'); s.setAttribute('focusable', 'false');+ s.setAttribute('class', 'ic' + (cls ? ' ' + cls : ''));+ const p = document.createElementNS(NS, 'path');+ if (name === 'play') { p.setAttribute('d', PLAY); p.setAttribute('class', 'fill'); } else p.setAttribute('d', P[name] || '');+ s.append(p);+ return s;+}+/** Nút chỉ có icon: luôn có aria-label (+ title) dịch được. */+export function iconBtn(name, labelKey, cls, extra) {+ const b = el('button', 'ib' + (cls ? ' ' + cls : ''), null, { type: 'button', ...(extra || {}) });+ b.append(icon(name));+ b.setAttribute('aria-label', t(labelKey)); b.title = t(labelKey);+ b.dataset.i18nAria = labelKey; b.dataset.i18nTitle = labelKey;+ return b;+}++export const clamp = (x, a, b) => Math.min(b, Math.max(a, x));+export const r2 = (x) => Math.round(x * 100) / 100;+/** 0:01.6 */+export const fmtT = (s) => { const x = Math.max(0, Math.round(s * 10) / 10); const m = Math.floor(x / 60); return `${m}:${(x - m * 60).toFixed(1).padStart(4, '0')}`; };+/** 0:36 */+export const fmtDur = (s) => { const x = Math.max(0, Math.round(s)); return `${Math.floor(x / 60)}:${String(x % 60).padStart(2, '0')}`; };+export const fmtDb = (x) => `${x > 0 ? '+' : x < 0 ? '−' : ''}${Math.abs(x)} dB`;+export const fmtMB = (b) => (b >= 1e9 ? (b / 1e9).toFixed(2) + ' GB' : Math.max(1, Math.round(b / 1e6)) + ' MB');+/** chỉ nhận đường dẫn cùng gốc ("/edits/…"), không nhận javascript:, //host… */+export const safeUrl = (u) => (typeof u === 'string' && /^\/(?!\/)/.test(u) ? u : null);+export const ID_RE = /^[\w-]{1,80}$/;++export async function getJSON(url) {+ const r = await fetch(url, { cache: 'no-store' });+ const j = await r.json().catch(() => ({}));+ if (!r.ok) throw Object.assign(new Error(j.error || 'HTTP ' + r.status), { status: r.status });+ return j;+}+export async function postJSON(url, body) {+ const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });+ const j = await r.json().catch(() => ({}));+ if (!r.ok) throw Object.assign(new Error(j.error || 'HTTP ' + r.status), { status: r.status });+ return j;+}+export const store = {+ get(k, d = null) { try { const v = localStorage.getItem(k); return v == null ? d : JSON.parse(v); } catch { return d; } },+ set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { /* đầy / riêng tư: bỏ qua */ } },+ del(k) { try { localStorage.removeItem(k); } catch { /* bỏ qua */ } },+};+/** "*Giá* tăng" → [{w, hi}] (như edit/manual.mjs lineTokens) */+export function tokens(text) {+ const out = []; const re = /\*([^*]+)\*|([^*]+)/g; let m;+ while ((m = re.exec(String(text)))) { const hi = !!m[1]; for (const w of (m[1] || m[2]).split(/\s+/)) if (w.trim()) out.push({ w: w.trim(), hi }); }+ return out;+}+export const untokens = (ws) => ws.map((w) => (w.hi ? `*${w.w}*` : w.w)).join(' ');+export const plain = (text) => String(text).replace(/\*/g, '');+/** Gắn chữ (có chữ nhấn) vào phần tử: chữ nhấn bọc <em>, tất cả qua textContent. */+export function paintWords(node, text, { hiClass = null } = {}) {+ const ws = tokens(text);+ node.replaceChildren();+ ws.forEach((w, i) => {+ if (i) node.append(' ');+ if (w.hi) { const e = el('em', hiClass, w.w); node.append(e); } else node.append(w.w);+ });+}+export const reduceMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;+export const narrow = () => window.matchMedia('(max-width: 767px)').matches;diff --git a/server/server.mjs b/server/server.mjsindex f035878..4854cf0 100644--- a/server/server.mjs+++ b/server/server.mjs@@ -54,6 +54,8 @@ const ALLOWED_HOSTS = new Set([`127.0.0.1:${PORT}`, `localhost:${PORT}`]);// L9: trang chỉ chạy script của chính app (file ngoài, index.html không có script nội tuyến); chữ của gói không thành code được.const PAGE_CSP = "default-src 'self'; img-src 'self' data: blob:; media-src 'self' blob:; style-src 'self' 'unsafe-inline'; object-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'";+const FRAME_CSP = "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self'; connect-src 'none'; object-src 'none'; frame-ancestors 'self'; base-uri 'none'; form-action 'none'";+const MIME = {'.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.mjs': 'text/javascript; charset=utf-8','.css': 'text/css; charset=utf-8', '.json': 'application/json; charset=utf-8', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg',@@ -100,7 +102,8 @@ function serveFile(req, res, baseDir, rel) {const type = MIME[path.extname(file).toLowerCase()] || 'application/octet-stream';const range = req.headers.range && /bytes=(\d*)-(\d*)/.exec(req.headers.range);const headers = { 'Content-Type': type, 'Accept-Ranges': 'bytes', 'Cache-Control': 'no-cache', 'X-Content-Type-Options': 'nosniff' };- if (type.startsWith('text/html')) headers['Content-Security-Policy'] = PAGE_CSP;+ // khung xem trước đồ hoạ của Studio (studio/gfx-frame.html) được nhúng vào chính trang app (iframe sandbox): frame-ancestors 'self'+ if (type.startsWith('text/html')) headers['Content-Security-Policy'] = path.basename(file) === 'gfx-frame.html' ? FRAME_CSP : PAGE_CSP;if (range) {const start = range[1] ? Number(range[1]) : 0;const end = range[2] ? Math.min(Number(range[2]), st.size - 1) : st.size - 1;