.btn-xs { padding: 3px 7px; font-size: 11px; } .btn-sm { padding: 5px 9px; font-size: 11.5px; } /* ========================================================================== ONE-CLICK COPY DOCK, MOBILE STUDIO SWITCHER & STORAGE STATUS (v1.1.0) ========================================================================== */ .quick-copy-dock { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; padding: 10px 12px; background: #10131c; border-bottom: 1px solid var(--border); } .quick-copy-dock button { min-height: 36px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 6px 8px; } .shot-quick-copy-row { display: flex; gap: 4px; margin-top: 4px; padding-top: 5px; border-top: 1px dashed rgba(255,255,255,0.08); } .shot-quick-copy-row button { flex: 1; padding: 4px 5px; font-size: 10.5px; font-family: var(--font-mono); } .mobile-studio-bar { display: none; background: var(--bg-panel); border-bottom: 1px solid var(--border); padding: 6px 10px; gap: 6px; position: sticky; top: 0; z-index: 40; } .mobile-studio-bar button { flex: 1; min-height: 38px; font-size: 12px; font-weight: 600; background: var(--bg-input); color: var(--text-secondary); } .mobile-studio-bar button.active { background: rgba(20, 184, 166, 0.18); border-color: var(--c-shot); color: #ccfbf1; } .status-pill { font-family: var(--font-mono); font-size: 10.5px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-secondary); display: inline-flex; align-items: center; gap: 5px; cursor: pointer; } .status-pill.ok { border-color: rgba(34, 197, 94, 0.45); color: #86efac; } .status-pill.warn { border-color: rgba(245, 158, 11, 0.5); color: #fde68a; } .changelog-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; padding-right: 4px; } .changelog-entry { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 11.5px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; } @media (max-width: 960px) { .mobile-studio-bar { display: flex; } .studio-grid[data-mobile-pane="shots"] .pane-center, .studio-grid[data-mobile-pane="shots"] .pane-right { display: none; } .studio-grid[data-mobile-pane="compiler"] .pane-left, .studio-grid[data-mobile-pane="compiler"] .pane-right { display: none; } .studio-grid[data-mobile-pane="inspector"] .pane-left, .studio-grid[data-mobile-pane="inspector"] .pane-center { display: none; } .quick-copy-dock { grid-template-columns: repeat(2, minmax(0, 1fr)); } .quick-copy-dock .span-2-mobile { grid-column: span 2; } button, .btn { min-height: 36px; } .topbar { position: static; } } input[type="text"], input[type="url"], input[type="number"], select, textarea {
(function () { 'use strict'; const APP_VERSION = 'v1.1.0'; const STORAGE_KEY = 'slf_bk_04_orchestrator_v1'; const RELEASE_NOTES = [ { ver: 'v1.1.0', date: '2026-11-22', items: [ 'Added 1-Click Quick-Copy Dock (Nano Banana, Veo 3.1, Kling, Full Shot Pack, Negative) directly above the prompt viewer—no tab switching required.', 'Added 1-Click Copy buttons (NB / Veo / Pack) directly on every shot card in the Shot List and Cast Foundry.', 'Added Mobile Studio Sub-Switcher (1-Click Prompt | Shots | Edit Shot) and enlarged touch targets for phone use.', 'Hardened clipboard engine for iOS/Android/iFrame compatibility (execCommand primary with setSelectionRange + manual fallback modal).', 'Added Live Session Change Log with timestamps, version tracking, and 1-Click Copy Changelog.', 'Added Phone Persistence & Sync modal (1-Click Copy/Paste State Backup + localStorage health indicator).', 'Script Audit Fix: Added Extended Cut Shot 07A (Stripping Medicinal Bark & The Weaver/Fisherman Parables).', 'Script Audit Fix: Updated Shot 09 (Maloca Dissolve) from Cue 6 to Cue 7 opening swell, and Shot 11B (Purge & Dawn) from Cue 7 to Silence.' ] }, { ver: 'v1.0.0', date: '2026-11-22', items: [ 'Initial 7-Layer Cascading Prompt Orchestration Engine for SLF-BK-04.', 'Cast & Relic Foundry (Clara 4 stages, Thomas 2 stages, Mateo Asháninka lock, 42-hole Shadhavar Horn with anti-blowing lock).', '15 Trailer Seed + 3 Extended Cut shots, Batch Matrix, Reference Vault, and Sonic Conflict Validator.' ] } ]; const ASPECT_TAGS = [ function createDefaultState() { return { version: APP_VERSION, lastSavedAt: new Date().toISOString(), mobileStudioPane: 'compiler', changeLog: [ { ts: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }), ver: APP_VERSION, scope: 'System', msg: 'Initialized SLF-BK-04 Engine (v1.1.0) with 19 story beats (15 Trailer Seed + 4 Extended Cut).' } ], activeView: 'studio', motionDelta: 'Slow lateral dolly drift around the low hearth fire. Flickering orange embers cast dancing warm reflections across Clara\'s eyes and illuminate the translucent ivory curve of the 42-hole horn in Mateo\'s hands. Mateo tilts the horn gently so firelight glints through each perforation; Clara\'s parted lips close slowly.', negOverride: '' }, { id: '07A', act: 'Act II', cutTag: 'Extended Cut', timecode: 'EXT-II-A', title: 'Stripping Medicinal Bark & The Two Parables', placeId: 'medicinal_grove', timeId: 'noon_5600k', emotion: 'Awakened Recognition ("Grief Is the Trap")', scoreCue: 'cue5', audioDevice: 'Earbuds Hanging Around Neck (Unplugged)', cast: { clara: { active: true, state: 's2', tier: 'full' }, thomas: { active: false, state: 's1', tier: 'full' }, mateo: { active: true, state: 's1', tier: 'full' } }, hornPresent: true, hornWind: 0, bootsState: 'Barefoot on Maloca Floorboards', ringState: 'Silver Ring Cutting into Damp Finger', props: ['machete'], aspects: { framing: { mode: 'append', text: 'Two-shot medium frame among scarred medicinal tree trunks; Mateo speaking quietly while guiding Clara\'s hands peeling aromatic bark' }, camera: { mode: 'append', text: 'ARRI Alexa 35, 50mm Cooke Panchro at f/2.2, gentle observational drift following their hands' }, action: { mode: 'append', text: 'Clara peels pale strips of medicinal bark beside Mateo as he tells the parables of the desert weaver\'s heavy rug and the fisherman\'s forty-year boots; Clara\'s jaw softens slightly' }, prop: { mode: 'append', text: 'Curled aromatic bark strips falling onto damp moss; 42-hole ivory horn resting silently on Mateo\'s chest' }, light: { mode: 'append', text: 'Warm humid midday shafts filtering through emerald leaves onto copper and sun-weathered hands' }, texture: { mode: 'append', text: 'Fibrous wet inner bark, sap sheen, floating pollen in jungle clearing' } }, motionDelta: 'Gentle observational camera drift from Mateo\'s calm profile down to Clara\'s hands stripping pale medicinal bark with quiet focus. Curled bark ribbons fall onto wet forest moss as dappled canopy light shifts softly across them.', negOverride: '' }, { id: '07B', act: 'Act II', cutTag: 'Extended Cut', timecode: 'EXT-II-B', title: 'Midday Heat Return-Panic (Chicago Apartment Fear)', { id: '09', act: 'Act III', cutTag: 'Trailer Seed', timecode: '0:58-1:06', title: 'Maloca Dissolves into Madre de Dios', placeId: 'submerged_riverbed', timeId: 'biolum_underwater', emotion: 'Surrender to Ceremony & Threshold Breath', scoreCue: 'cue7', audioDevice: 'Pure Wind & Horn (No Electronic Device)', cast: { clara: { active: true, state: 's2', tier: 'full' }, thomas: { active: false, state: 's1', tier: 'full' }, mateo: { active: false, state: 's1', tier: 'full' } }, { id: '11B', act: 'Act III', cutTag: 'Extended Cut', timecode: 'EXT-III-A', title: 'The Ayahuasca Purge & Weeping Until Dawn', placeId: 'ashaninka_maloca', timeId: 'dawn_mist_5200k', emotion: 'Physical Purge & Weeping Until Dawn', scoreCue: 'silence', audioDevice: 'Pure Wind & Horn (No Electronic Device)', cast: { clara: { active: true, state: 's3', tier: 'full' }, thomas: { active: false, state: 's1', tier: 'full' }, mateo: { active: false, state: 's1', tier: 'full' } }, let state = loadState(); let storageHealthy = true; let vaultStagedImage = ''; // base64 for pending Vault addition let vaultScopeFilter = 'all'; let vaultAspectFilter = 'all'; let matrixSearchQuery = ''; function logChange(scope, msg) { if (!Array.isArray(state.changeLog)) state.changeLog = []; const ts = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' }); state.changeLog.unshift({ ts, ver: APP_VERSION, scope, msg }); if (state.changeLog.length > 80) state.changeLog.length = 80; updateTopStatusBadges(); } function updateTopStatusBadges() { const lc = document.getElementById('logCountBadge'); if (lc) lc.textContent = (state.changeLog || []).length; const st = document.getElementById('saveStatusText'); const sp = document.getElementById('btnPhoneSync'); if (st && sp) { if (storageHealthy) { const tStr = state.lastSavedAt ? new Date(state.lastSavedAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) : 'Now'; st.textContent = '● Saved ' + tStr; sp.classList.add('ok'); sp.classList.remove('warn'); } else { st.textContent = '⚠ Sandbox · Backup'; sp.classList.add('warn'); sp.classList.remove('ok'); } } const ms = document.getElementById('mShotCount'); if (ms) ms.textContent = state.shots.length; } function loadState() { try { const raw = localStorage.getItem(STORAGE_KEY); if (!raw) return createDefaultState(); const parsed = JSON.parse(raw); if (!parsed || !Array.isArray(parsed.shots) || !parsed.foundry) return createDefaultState(); // Graceful migration from v1.0.0 -> v1.1.0 if (!Array.isArray(parsed.changeLog)) parsed.changeLog = []; if (!parsed.mobileStudioPane) parsed.mobileStudioPane = 'compiler'; if (parsed.version !== APP_VERSION) { const defaults = createDefaultState(); if (!parsed.shots.some(s => s.id === '07A')) { const idx07B = parsed.shots.findIndex(s => s.id === '07B'); const shot07A = defaults.shots.find(s => s.id === '07A'); if (shot07A) { if (idx07B >= 0) parsed.shots.splice(idx07B, 0, shot07A); else parsed.shots.push(shot07A); } } parsed.version = APP_VERSION; parsed.changeLog.unshift({ ts: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }), ver: APP_VERSION, scope: 'Upgrade', msg: 'Migrated saved project cleanly to v1.1.0 (added Shot 07A, 1-Click Copy Dock, Mobile Switcher & Change Log).' }); } return parsed; } catch (e) { storageHealthy = false; return createDefaultState(); } } function saveState() { state.lastSavedAt = new Date().toISOString(); try { localStorage.setItem(STORAGE_KEY, JSON.stringify(state)); storageHealthy = true; } catch (e) { storageHealthy = false; showToast('Browser storage sandboxed/full — tap "Saved/Backup" to copy state.', 'warn'); } updateTopStatusBadges(); } function copyText(text, successMsg) { // Primary: iOS/Android/iFrame-safe execCommand('copy') const tryExecCommand = () => { const ta = document.createElement('textarea'); ta.value = text; ta.setAttribute('readonly', ''); ta.style.position = 'fixed'; ta.style.top = '0'; ta.style.left = '-9999px'; ta.style.opacity = '0'; document.body.appendChild(ta); ta.focus(); ta.select(); try { ta.setSelectionRange(0, text.length); } catch (_) {} let ok = false; try { ok = document.execCommand('copy'); } catch (_) { ok = false; } ta.remove(); return ok; }; if (tryExecCommand()) { showToast(successMsg || 'Copied to clipboard!'); return; } if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(text).then( () => showToast(successMsg || 'Copied to clipboard!'), () => openManualCopyModal(text, successMsg) ); } else { openManualCopyModal(text, successMsg); } } function openManualCopyModal(text, title) { openModal(`
Tap "Select All" & Copy (${escHtml(title || 'Prompt')})
`); const ta = document.getElementById('manualCopyTa'); ta.focus(); ta.select(); document.getElementById('btnCloseManualCopy').addEventListener('click', closeModal); } return { orderedSpans, deltaSpans, negativeText, lockedHeroes, refs, cue, windInfo, place, time, nanoCopyText: attachManifest(nanoProse, 'nano'), veoCopyText: attachManifest(veoProse, 'veo'), klingCopyText: attachManifest(klingProse, 'kling'), fullPackText: [ `=== SHOT ${shot.id} [${shot.act} · ${shot.timecode}] — ${shot.title} ===`, `Score: ${cue.label} | Horn Wind: ${shot.hornPresent ? windInfo.label : 'Absent'}`, `\n[NANO BANANA KEYFRAME]\n${attachManifest(nanoProse, 'nano')}`, `\n[VEO 3.1 I2V MOTION DELTA]\n${attachManifest(veoProse, 'veo')}`, `\n[KLING I2V + NEGATIVE]\n${attachManifest(klingProse, 'kling')}` ].join('\n') }; } function renderAll() { updateTopStatusBadges(); if (state.activeView === 'foundry') renderFoundry(); if (state.activeView === 'studio') renderStudio(); if (state.activeView === 'matrix') renderMatrix(); if (state.activeView === 'vault') renderVault(); }
function renderStudio() { const grid = document.getElementById('studioGrid'); if (grid) grid.dataset.mobilePane = state.mobileStudioPane || 'compiler'; document.querySelectorAll('#mobileStudioBar button').forEach(b => { b.classList.toggle('active', b.dataset.mpane === (state.mobileStudioPane || 'compiler')); }); renderLeftPane(); renderCenterPane(); renderRightPane(); }
${escHtml(s.timecode)} · ${escHtml(cueShort)} ${s.hornPresent ? `·Horn ${s.hornWind}%` : ''} ${refsCount ? `·${refsCount} ref` : ''}
`; }).join('')} `;
function openLightbox(src, title, externalUrl) { document.getElementById('btnCloseModal').addEventListener('click', closeModal); } /* -------------------------------------------------------------------------- VERSION & CHANGE LOG MODAL + PHONE SYNC / PERSISTENCE MODAL (v1.1.0) -------------------------------------------------------------------------- */ function openVersionLogModal() { const relHtml = RELEASE_NOTES.map(r => `
${escHtml(r.ver)} ${escHtml(r.date)}
    ${r.items.map(it => `
  • ${escHtml(it)}
  • `).join('')}
`).join(''); const logHtml = (state.changeLog || []).length ? state.changeLog.map(entry => `
${escHtml(entry.scope)} ${escHtml(entry.msg)}
${escHtml(entry.ts)}
`).join('') : '
No session edits logged yet.
'; openModal(`
Version History & Live Session Change Log (${APP_VERSION})
App Release Notes
${relHtml}
Your Live Edit History (${(state.changeLog || []).length})
${logHtml}
`); document.getElementById('btnCloseVerModal').addEventListener('click', closeModal); document.getElementById('btnCopyChangelog').addEventListener('click', () => { const txt = [ `# SLF-BK-04 Orchestrator Change Log (${APP_VERSION})`, ...(state.changeLog || []).map(e => `- [${e.ts}] (${e.scope}) ${e.msg}`) ].join('\n'); copyText(txt, 'Copied Change Log to clipboard!'); }); document.getElementById('btnClearSessionLog').addEventListener('click', () => { state.changeLog = []; saveState(); openVersionLogModal(); }); } function openPhoneSyncModal() { openModal(`
Phone Persistence & 1-Click Backup Sync
Storage Status: ${storageHealthy ? '● Active (Auto-saving to browser localStorage)' : '⚠ Sandboxed Preview (Export or Copy Backup before closing)'}
Best way to use permanently on your phone: Save this HTML file to a free static URL (GitHub Pages / Netlify Drop) and tap "Add to Home Screen". While testing inside Gemini Preview, use the 1-Click Backup button below to save your state to Notes before closing.
Restore from Pasted Backup JSON
`); document.getElementById('btnCloseSyncModal').addEventListener('click', closeModal); document.getElementById('btnCopyStateBackup').addEventListener('click', () => { copyText(JSON.stringify(state), 'Copied full project backup JSON! Paste into Notes to keep safe.'); }); document.getElementById('btnDownloadBackup').addEventListener('click', () => { document.getElementById('btnExportJSON').click(); }); document.getElementById('btnRestorePastedState').addEventListener('click', () => { try { const parsed = JSON.parse(document.getElementById('pasteStateInput').value.trim()); if (!parsed.shots || !parsed.foundry) throw new Error('Invalid'); state = parsed; logChange('Sync', 'Restored project state from pasted backup JSON.'); saveState(); closeModal(); setActiveView(state.activeView || 'studio'); showToast('Project backup restored successfully!'); } catch (_) { showToast('Invalid backup JSON. Make sure you copied the full text.', 'err'); } }); } inputEl.value = ''; logChange('Quick Instruct', `[${scope} · ${aspect}] "${directive}" -> updated ${affectedCount} shot(s).`); saveState(); renderAll(); showToast(`Instruction applied — Updated ${affectedCount}/${state.shots.length} shots.`); } state.shots.push(s); state.activeShotId = s.id; state.shotFilter = 'all'; logChange('Shots', `${cloneFrom ? 'Cloned' : 'Created'} Shot ${s.id} (${s.title}).`); saveState(); renderAll(); showToast(`Created Shot ${s.id}`); } // Top Nav View Tabs document.getElementById('mainNavTabs').addEventListener('click', (e) => { const btn = e.target.closest('.nav-tab'); if (btn) setActiveView(btn.dataset.view); }); // Version Log & Phone Sync Modals document.getElementById('btnVersionLog').addEventListener('click', openVersionLogModal); document.getElementById('btnPhoneSync').addEventListener('click', openPhoneSyncModal); // Mobile Studio Pane Switcher document.getElementById('mobileStudioBar').addEventListener('click', (e) => { const btn = e.target.closest('[data-mpane]'); if (!btn) return; state.mobileStudioPane = btn.dataset.mpane; saveState(); renderStudio(); }); // Quick Instruct // Foundry: Lock Toggle const lockBtn = t.closest('[data-toggle-lock]'); if (lockBtn) { const hid = lockBtn.dataset.toggleLock; state.foundry[hid].locked = !state.foundry[hid].locked; logChange('Foundry', `${state.foundry[hid].locked ? 'Locked' : 'Unlocked'} ${state.foundry[hid].refTag} (${state.foundry[hid].name}).`); saveState(); renderFoundry(); showToast(`${state.foundry[hid].refTag} ${state.foundry[hid].locked ? 'LOCKED — auto-injecting into active shots!' : 'UNLOCKED for editing.'}`); return; } // Foundry: Copy Turnaround Sheet Prompt & Copy Look-Lock const turnBtn = t.closest('[data-copy-turnaround]'); if (turnBtn) { const h = state.foundry[turnBtn.dataset.copyTurnaround]; copyText(buildTurnaroundPrompt(h), `Copied Nano Banana turnaround prompt for ${h.name}!`); return; } const llBtn = t.closest('[data-copy-looklock]'); if (llBtn) { const h = state.foundry[llBtn.dataset.copyLooklock]; const st = h.states[h.activeState] || Object.values(h.states)[0]; copyText(`${h.refTag} ${h.name} (${st.label}): ${st.desc}\nMacro: ${h.macroAnchor}\nNegative: ${h.negativeLock}`, `Copied Look-Lock for ${h.name}!`); return; } // Shot Card 1-Click Quick Copy (prevent selecting shot when tapping copy) const sqc = t.closest('[data-shot-qcopy]'); if (sqc) { e.stopPropagation(); const [sid, kind] = sqc.dataset.shotQcopy.split(':'); const s = state.shots.find(x => x.id === sid); if (!s) return; const c = compileShot(s); const txt = kind === 'nano' ? c.nanoCopyText : kind === 'veo' ? c.veoCopyText : c.fullPackText; const lbl = kind === 'nano' ? 'Nano Banana' : kind === 'veo' ? 'Veo 3.1' : 'Full Shot Pack'; copyText(txt, `Copied Shot ${sid} (${lbl})!`); return; } // 1-Click Copy Dock inside Center Compiler const dockCopy = t.closest('[data-dock-copy]'); if (dockCopy) { const s = getActiveShot(); if (!s) return; const c = compileShot(s); const mode = dockCopy.dataset.dockCopy; const map = { nano: [c.nanoCopyText, 'Nano Banana Keyframe'], veo: [c.veoCopyText, 'Veo 3.1 I2V Delta'], kling: [c.klingCopyText, 'Kling I2V + Negative'], neg: [c.negativeText, 'Negative Guardrails'], pack: [c.fullPackText, 'Full Shot Pack (NB+Veo+Kling)'] }; const [txt, lbl] = map[mode] || [c.nanoCopyText, 'Prompt']; copyText(txt, `Copied Shot ${s.id} (${lbl})!`); return; } // Select Shot const shotCard = t.closest('[data-select-shot]'); if (shotCard) { state.activeShotId = shotCard.dataset.selectShot; if (window.innerWidth <= 960) state.mobileStudioPane = 'compiler'; saveState(); renderStudio(); return; } // Conflict Quick-Fix Buttons if (t.id === 'btnFixSilenceHorn') { const s = getActiveShot(); if (s) { s.hornWind = 0; logChange('Conflict Fix', `Silenced Horn to 0% on Shot ${s.id}.`); saveState(); renderStudio(); showToast('Horn silenced to 0% — conflict resolved.'); } return; } if (t.id === 'btnFixMuteSong') { const s = getActiveShot(); if (s) { s.scoreCue = 'horn_solo'; logChange('Conflict Fix', `Switched Shot ${s.id} to Horn Solo.`); saveState(); renderStudio(); showToast('Switched to 42-Streamer Horn Solo — conflict resolved.'); } return; } window.addEventListener('DOMContentLoaded', () => { attachEvents(); updateTopStatusBadges(); setActiveView(state.activeView || 'studio'); }); })();