The showcase prompt, Gemini 4 Carbon
agent (cont.)
+5:21write_file{"Content":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, viewport-fit=cover\" />\n<title>Gemini 4 Carbon — Cold-Start Artifact // Citadel</title>\n<style>\n :root {\n --bg-0: #07080b;\n --bg-1: #0e1016;\n --bg-panel: rgba(12, 14, 20, 0.82);\n --bg-panel-strong: rgba(10, 12, 17, 0.94);\n --ink-0: #efece4;\n --ink-1: #a7a196;\n --ink-2: #68645d;\n --line: rgba(239, 236, 228, 0.12);\n --line-strong: rgba(239, 236, 228, 0.26);\n --solar: #ff5924;\n --gold: #f3b340;\n --mint: #38d4b3;\n --cobalt: #5b9bff;\n --font-sans: 'Space Grotesk', 'Geist', 'IBM Plex Sans', 'Ubuntu', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n --font-mono: 'Geist Mono', 'IBM Plex Mono', 'JetBrains Mono', 'Ubuntu Mono', 'DejaVu Sans Mono', monospace;\n }\n\n * { box-sizing: border-box; margin: 0; padding: 0; }\n\n html, body {\n width: 100%;\n height: 100%;\n overflow: hidden;\n background: var(--bg-0);\n color: var(--ink-0);\n font-family: var(--font-sans);\n -webkit-font-smoothing: antialiased;\n user-select: none;\n }\n\n #stage {\n position: relative;\n width: 100%;\n height: 100%;\n overflow: hidden;\n touch-action: none;\n }\n\n canvas {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n display: block;\n }\n\n #gl { z-index: 1; }\n #hud { z-index: 2; cursor: grab; }\n #hud:active { cursor: grabbing; }\n #hud.pointer-node { cursor: pointer; }\n\n /* Architectural corner registration brackets */\n .corner {\n position: fixed;\n width: 10px;\n height: 10px;\n z-index: 5;\n pointer-events: none;\n opacity: 0.45;\n }\n .corner.tl { top: 8px; left: 8px; border-top: 1px solid var(--ink-1); border-left: 1px solid var(--ink-1); }\n .corner.tr { top: 8px; right: 8px; border-top: 1px solid var(--ink-1); border-right: 1px solid var(--ink-1); }\n .corner.bl { bottom: 54px; left: 8px; border-bottom: 1px solid var(--ink-1); border-left: 1px solid var(--ink-1); }\n .corner.br { bottom: 54px; right: 8px; border-bottom: 1px solid var(--ink-1); border-right: 1px solid var(--ink-1); }\n\n /* Top calibration bar */\n #topbar {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 44px;\n z-index: 10;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 16px;\n background: linear-gradient(180deg, rgba(7, 8, 11, 0.88) 0%, rgba(7, 8, 11, 0.35) 72%, rgba(7, 8, 11, 0) 100%);\n pointer-events: none;\n gap: 10px;\n }\n\n .brand-cluster {\n display: flex;\n align-items: center;\n gap: 10px;\n pointer-events: auto;\n min-width: 0;\n }\n\n .decal-mark {\n width: 18px;\n height: 18px;\n border: 1px solid var(--solar);\n display: grid;\n place-items: center;\n position: relative;\n flex-shrink: 0;\n background: rgba(255, 89, 36, 0.08);\n }\n .decal-mark::after {\n content: '';\n width: 6px;\n height: 6px;\n background: var(--solar);\n transform: rotate(45deg);\n }\n\n .brand-title {\n font-family: var(--font-mono);\n font-size: 11.5px;\n font-weight: 600;\n letter-spacing: 0.09em;\n text-transform: uppercase;\n color: var(--ink-0);\n white-space: nowrap;\n }\n\n .brand-sep {\n color: var(--ink-2);\n font-family: var(--font-mono);\n font-size: 11px;\n }\n\n .context-jump {\n font-family: var(--font-mono);\n font-size: 10.5px;\n letter-spacing: 0.05em;\n color: var(--ink-1);\n background: rgba(239, 236, 228, 0.04);\n border: 1px solid var(--line);\n padding: 3px 8px;\n cursor: pointer;\n transition: border-color 0.16s, color 0.16s, background 0.16s;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .context-jump:hover {\n color: var(--ink-0);\n border-color: var(--solar);\n background: rgba(255, 89, 36, 0.1);\n }\n .context-jump b {\n color: var(--gold);\n font-weight: 600;\n }\n\n .top-actions {\n display: flex;\n align-items: center;\n gap: 6px;\n pointer-events: auto;\n flex-shrink: 0;\n }\n\n .pill-btn {\n height: 26px;\n padding: 0 9px;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-family: var(--font-mono);\n font-size: 10.5px;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--ink-1);\n background: var(--bg-panel);\n border: 1px solid var(--line);\n cursor: pointer;\n transition: all 0.15s ease;\n font-variant-numeric: tabular-nums;\n backdrop-filter: blur(8px);\n }\n .pill-btn:hover {\n color: var(--ink-0);\n border-color: var(--line-strong);\n }\n .pill-btn.active {\n color: var(--ink-0);\n border-color: rgba(255, 89, 36, 0.55);\n background: rgba(255, 89, 36, 0.12);\n }\n .pill-btn.mint-active {\n color: var(--mint);\n border-color: rgba(56, 212, 179, 0.5);\n background: rgba(56, 212, 179, 0.09);\n }\n\n .dot-live {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--ink-2);\n transition: background 0.2s, box-shadow 0.2s;\n }\n .pill-btn.active .dot-live {\n background: var(--solar);\n box-shadow: 0 0 8px var(--solar);\n }\n\n /* Equalizer bars for sound button */\n .eq-bars {\n display: inline-flex;\n align-items: flex-end;\n gap: 1.5px;\n height: 10px;\n }\n .eq-bars i {\n display: block;\n width: 2px;\n height: 3px;\n background: currentColor;\n transition: height 0.12s;\n }\n .pill-btn.mint-active .eq-bars i:nth-child(1) { animation: eqPulse 0.55s ease-in-out infinite alternate; }\n .pill-btn.mint-active .eq-bars i:nth-child(2) { animation: eqPulse 0.42s ease-in-out 0.12s infinite alternate; }\n .pill-btn.mint-active .eq-bars i:nth-child(3) { animation: eqPulse 0.64s ease-in-out 0.24s infinite alternate; }\n @keyframes eqPulse {\n from { height: 2px; }\n to { height: 10px; }\n }\n\n /* Lower deck: Mode context + live interactive controls */\n #deck {\n position: absolute;\n left: 16px;\n right: 16px;\n bottom: 58px;\n z-index: 10;\n display: flex;\n align-items: flex-end;\n justify-content: space-between;\n gap: 12px;\n pointer-events: none;\n }\n\n .mode-placard {\n max-width: 430px;\n background: linear-gradient(90deg, rgba(7, 8, 11, 0.84) 0%, rgba(7, 8, 11, 0.58) 85%, rgba(7, 8, 11, 0) 100%);\n padding: 8px 14px 8px 10px;\n border-left: 2px solid var(--solar);\n pointer-events: none;\n }\n\n .mode-kicker {\n font-family: var(--font-mono);\n font-size: 10px;\n letter-spacing: 0.12em;\n text-transform: uppercase;\n color: var(--solar);\n margin-bottom: 3px;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n .mode-kicker span.sub-hint {\n color: var(--ink-2);\n letter-spacing: 0.06em;\n }\n\n .mode-headline {\n font-size: 16px;\n font-weight: 600;\n letter-spacing: -0.015em;\n color: var(--ink-0);\n line-height: 1.2;\n margin-bottom: 3px;\n }\n\n .mode-desc {\n font-size: 12px;\n line-height: 1.38;\n color: var(--ink-1);\n }\n\n /* Mode-specific interactive toolbars */\n .ctrl-rack {\n display: none;\n align-items: center;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: 6px;\n background: var(--bg-panel);\n border: 1px solid var(--line);\n padding: 6px 8px;\n backdrop-filter: blur(10px);\n pointer-events: auto;\n max-width: 580px;\n }\n .ctrl-rack.visible {\n display: flex;\n }\n\n .chip {\n height: 24px;\n padding: 0 8px;\n font-family: var(--font-mono);\n font-size: 10px;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--ink-1);\n background: rgba(255, 255, 255, 0.025);\n border: 1px solid var(--line);\n cursor: pointer;\n transition: all 0.14s;\n white-space: nowrap;\n }\n .chip:hover {\n color: var(--ink-0);\n border-color: var(--line-strong);\n }\n .chip.on {\n color: var(--ink-0);\n background: rgba(255, 89, 36, 0.16);\n border-color: var(--solar);\n }\n .chip.action-gold {\n color: var(--gold);\n border-color: rgba(243, 179, 64, 0.45);\n background: rgba(243, 179, 64, 0.09);\n }\n .chip.action-gold:hover {\n background: rgba(243, 179, 64, 0.2);\n color: #fff;\n }\n .chip.approve-ready {\n color: #07120f;\n background: var(--mint);\n border-color: var(--mint);\n font-weight: 700;\n animation: gatePulse 1.1s ease-in-out infinite alternate;\n }\n @keyframes gatePulse {\n from { box-shadow: 0 0 0 rgba(56, 212, 179, 0.2); }\n to { box-shadow: 0 0 14px rgba(56, 212, 179, 0.75); }\n }\n\n .slider-wrap {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 0 6px;\n font-family: var(--font-mono);\n font-size: 10px;\n color: var(--ink-1);\n letter-spacing: 0.06em;\n }\n .slider-wrap input[type=\"range\"] {\n -webkit-appearance: none;\n appearance: none;\n width: 84px;\n height: 3px;\n background: rgba(239, 236, 228, 0.2);\n outline: none;\n cursor: pointer;\n }\n .slider-wrap input[type=\"range\"]::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 10px;\n height: 14px;\n background: var(--solar);\n border: 1px solid var(--ink-0);\n cursor: ew-resize;\n }\n\n /* Citadel Triage Console inside Mode 05 */\n #citadel-console {\n width: 100%;\n max-width: 650px;\n flex-direction: column;\n align-items: stretch;\n gap: 6px;\n }\n .triage-row {\n display: flex;\n gap: 6px;\n width: 100%;\n }\n #triage-input {\n flex: 1;\n min-width: 140px;\n height: 28px;\n padding: 0 9px;\n background: rgba(5, 6, 9, 0.85);\n border: 1px solid var(--line-strong);\n color: var(--ink-0);\n font-family: var(--font-mono);\n font-size: 11px;\n outline: none;\n user-select: text;\n }\n #triage-input:focus {\n border-color: var(--solar);\n }\n #triage-input::placeholder {\n color: var(--ink-2);\n }\n .preset-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 5px;\n }\n .preset-chips {\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n }\n #triage-trace {\n font-family: var(--font-mono);\n font-size: 10px;\n color: var(--mint);\n letter-spacing: 0.03em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n /* Bottom 5-chamber navigation dock */\n #dock {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n height: 46px;\n z-index: 12;\n display: grid;\n grid-template-columns: repeat(5, 1fr);\n background: rgba(8, 9, 13, 0.94);\n border-top: 1px solid var(--line);\n backdrop-filter: blur(12px);\n }\n\n .dock-tab {\n position: relative;\n background: transparent;\n border: none;\n border-right: 1px solid var(--line);\n color: var(--ink-1);\n padding: 0 12px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n cursor: pointer;\n text-align: left;\n transition: background 0.16s, color 0.16s;\n overflow: hidden;\n }\n .dock-tab:last-child { border-right: none; }\n .dock-tab:hover {\n background: rgba(239, 236, 228, 0.035);\n color: var(--ink-0);\n }\n .dock-tab.active {\n background: rgba(255, 89, 36, 0.07);\n color: var(--ink-0);\n }\n\n .tab-progress {\n position: absolute;\n top: 0;\n left: 0;\n height: 2px;\n width: 0%;\n background: var(--solar);\n pointer-events: none;\n }\n .dock-tab.active .tab-progress {\n box-shadow: 0 0 8px var(--solar);\n }\n\n .tab-left {\n display: flex;\n align-items: baseline;\n gap: 7px;\n min-width: 0;\n }\n .tab-idx {\n font-family: var(--font-mono);\n font-size: 10px;\n color: var(--ink-2);\n font-variant-numeric: tabular-nums;\n }\n .dock-tab.active .tab-idx { color: var(--solar); font-weight: 600; }\n\n .tab-label {\n font-family: var(--font-mono);\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .tab-tag {\n font-family: var(--font-mono);\n font-size: 9.5px;\n color: var(--ink-2);\n letter-spacing: 0.04em;\n white-space: nowrap;\n }\n\n /* Live Claim Auditor Drawer (GPT-6.1-Sol inspired self-verification) */\n #audit-modal {\n position: absolute;\n inset: 46px 16px 54px 16px;\n z-index: 30;\n background: var(--bg-panel-strong);\n border: 1px solid var(--line-strong);\n display: none;\n flex-direction: column;\n backdrop-filter: blur(18px);\n box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72);\n }\n #audit-modal.open {\n display: flex;\n }\n\n .audit-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 10px 14px;\n border-bottom: 1px solid var(--line);\n background: rgba(255, 89, 36, 0.06);\n }\n .audit-title {\n font-family: var(--font-mono);\n font-size: 11.5px;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n color: var(--ink-0);\n }\n .audit-title span { color: var(--mint); margin-left: 8px; }\n\n .audit-body {\n flex: 1;\n display: grid;\n grid-template-columns: 300px 1fr;\n min-height: 0;\n }\n\n .audit-checks {\n padding: 12px 14px;\n border-right: 1px solid var(--line);\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 9px;\n }\n\n .check-item {\n padding-bottom: 8px;\n border-bottom: 1px solid rgba(239, 236, 228, 0.07);\n }\n .check-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-family: var(--font-mono);\n font-size: 10.5px;\n margin-bottom: 2px;\n }\n .check-name { color: var(--ink-0); font-weight: 600; }\n .check-pass { color: var(--mint); letter-spacing: 0.06em; }\n .check-val {\n font-family: var(--font-mono);\n font-size: 10px;\n color: var(--ink-1);\n line-height: 1.35;\n }\n\n .audit-code-pane {\n display: flex;\n flex-direction: column;\n min-width: 0;\n min-height: 0;\n }\n .code-tabs {\n display: flex;\n gap: 4px;\n padding: 8px 10px;\n border-bottom: 1px solid var(--line);\n flex-wrap: wrap;\n }\n #live-code-view {\n flex: 1;\n padding: 12px 14px;\n overflow: auto;\n font-family: var(--font-mono);\n font-size: 11px;\n line-height: 1.48;\n color: #d7d3c8;\n background: rgba(5, 6, 9, 0.72);\n white-space: pre;\n user-select: text;\n tab-size: 2;\n }\n\n /* Responsive adjustments for compact embeds & mobile */\n @media (max-width: 820px) {\n .tab-tag, .context-jump { display: none; }\n #deck { flex-direction: column; align-items: stretch; gap: 8px; bottom: 52px; }\n .mode-placard { max-width: 100%; padding: 6px 10px; }\n .mode-headline { font-size: 14px; }\n .mode-desc { font-size: 11px; }\n .ctrl-rack { max-width: 100%; justify-content: flex-start; }\n .audit-body { grid-template-columns: 1fr; }\n .audit-checks { max-height: 185px; border-right: none; border-bottom: 1px solid var(--line); }\n }\n\n @media (max-width: 540px) {\n #topbar { padding: 0 10px; }\n .brand-sep { display: none; }\n .tab-label { font-size: 9.5px; letter-spacing: 0.02em; }\n .dock-tab { padding: 0 6px; }\n }\n</style>\n</head>\n<body>\n<div id=\"stage\">\n <canvas id=\"gl\"></canvas>\n <canvas id=\"hud\"></canvas>\n\n <div class=\"corner tl\"></div>\n <div class=\"corner tr\"></div>\n <div class=\"corner bl\"></div>\n <div class=\"corner br\"></div>\n\n <!-- Perimeter Calibration Header -->\n <header id=\"topbar\">\n <div class=\"brand-cluster\">\n <div class=\"decal-mark\" aria-hidden=\"true\"></div>\n <div class=\"brand-title\">Gemini 4 Carbon</div>\n <span class=\"brand-sep\">//</span>\n <button class=\"context-jump\" id=\"btn-jump-citadel\" title=\"See how this fits Severian's Citadel stack\">\n 5 models run Citadel today · <b>Seat 06 built this cold →</b>\n </button>\n </div>\n\n <div class=\"top-actions\">\n <button class=\"pill-btn active\" id=\"btn-reel\" title=\"Toggle automatic capability reel (Space)\">\n <span class=\"dot-live\"></span>\n <span id=\"reel-label\">Auto-Reel</span>\n </button>\n <button class=\"pill-btn\" id=\"btn-sound\" title=\"Toggle procedural WebAudio synthesizer (M)\">\n <span class=\"eq-bars\" aria-hidden=\"true\"><i></i><i></i><i></i></span>\n <span id=\"sound-label\">DSP Off</span>\n </button>\n <button class=\"pill-btn\" id=\"btn-audit\" title=\"Inspect live runtime & verify zero-dependency claims (V)\">\n <span id=\"audit-badge\">Verify · 0 Deps</span>\n </button>\n </div>\n </header>\n\n <!-- Lower Context + Interactive Mode Controls -->\n <section id=\"deck\">\n <div class=\"mode-placard\" id=\"placard\">\n <div class=\"mode-kicker\">\n <span id=\"m-kicker\">01 ─ SPATIAL & 3D PIPELINE</span>\n <span class=\"sub-hint\" id=\"m-hint\">Drag to orbit · Scrub cut plane</span>\n </div>\n <h1 class=\"mode-headline\" id=\"m-title\">Raymarched CSG & Chromatic Dispersion</h1>\n <p class=\"mode-desc\" id=\"m-desc\">Real-time signed-distance assembly with three-wavelength refraction, machined boolean cross-sections, and live render passes.</p>\n </div>\n\n <!-- Controls for Mode 01: Optics -->\n <div class=\"ctrl-rack visible\" id=\"rack-0\">\n <div class=\"slider-wrap\">\n <span>SLICE</span>\n <input type=\"range\" id=\"opt-slice\" min=\"-115\" max=\"115\" value=\"28\" />\n </div>\n <button class=\"chip on\" data-pass=\"0\">PBR Refract</button>\n <button class=\"chip\" data-pass=\"1\">Normals</button>\n <button class=\"chip\" data-pass=\"2\">Iso-SDF</button>\n <button class=\"chip\" data-pass=\"3\">Clay + AO</button>\n </div>\n\n <!-- Controls for Mode 02: Continuum -->\n <div class=\"ctrl-rack\" id=\"rack-1\">\n <button class=\"chip on\" data-flow=\"0\">Accretion</button>\n <button class=\"chip\" data-flow=\"1\">Curl Turbulence</button>\n <button class=\"chip\" data-flow=\"2\">Dipole Lattice</button>\n <button class=\"chip action-gold\" id=\"btn-shockwave\">Detonate Pulse</button>\n </div>\n\n <!-- Controls for Mode 03: Automaton -->\n <div class=\"ctrl-rack\" id=\"rack-2\">\n <button class=\"chip on\" data-emo=\"auto\">Live Gaze</button>\n <button class=\"chip\" data-emo=\"curious\">Curious</button>\n <button class=\"chip\" data-emo=\"skeptical\">Skeptical</button>\n <button class=\"chip\" data-emo=\"startled\">Startled</button>\n <button class=\"chip\" data-emo=\"delighted\">Delighted</button>\n </div>\n\n <!-- Controls for Mode 04: Harmonics -->\n <div class=\"ctrl-rack\" id=\"rack-3\">\n <button class=\"chip on\" data-scale=\"0\">D Lydian</button>\n <button class=\"chip\" data-scale=\"1\">C# Phrygian</button>\n <button class=\"chip\" data-scale=\"2\">F Hirajoshi</button>\n <button class=\"chip action-gold\" id=\"btn-euclid-rand\">Mutate Rhythm</button>\n </div>\n\n <!-- Controls for Mode 05: Citadel Triage & Roster -->\n <div class=\"ctrl-rack\" id=\"citadel-console\">\n <div class=\"triage-row\">\n <input type=\"text\" id=\"triage-input\" maxlength=\"140\" placeholder=\"Send any Discord message or task through Claviger (Laya-421M)...\" />\n <button class=\"chip on\" id=\"btn-dispatch\">Dispatch</button>\n <button class=\"chip approve-ready\" id=\"btn-approve\" style=\"display:none;\">Approve Deploy ✓</button>\n </div>\n <div class=\"preset-row\">\n <div class=\"preset-chips\">\n <button class=\"chip\" data-prompt=\"Hearthwynd hero decal feels stiff on mobile + check 3D snow glTF\">1 · Design + 3D</button>\n <button class=\"chip\" data-prompt=\"Rebase desktop-buddies onto main and write 40 test conversations\">2 · Rebase + Tests</button>\n <button class=\"chip\" data-prompt=\"Audit scene-convert deploy kit against every claim in README\">3 · Claim Audit</button>\n <button class=\"chip\" data-prompt=\"yo nice pfp lol anyone queuing late tonight?\">4 · Discord Noise</button>\n </div>\n <div id=\"triage-trace\">Click any model node above, or fire a packet through Claviger.</div>\n </div>\n </div>\n </section>\n\n <!-- Bottom 5-Mode Dock -->\n <nav id=\"dock\" aria-label=\"Capability lenses\">\n <button class=\"dock-tab active\" data-mode=\"0\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">01</span><span class=\"tab-label\">Optics & 3D</span></div>\n <span class=\"tab-tag\">GLSL SDF</span>\n </button>\n <button class=\"dock-tab\" data-mode=\"1\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">02</span><span class=\"tab-label\">Continuum</span></div>\n <span class=\"tab-tag\">3.2k Bodies</span>\n </button>\n <button class=\"dock-tab\" data-mode=\"2\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">03</span><span class=\"tab-label\">Automaton</span></div>\n <span class=\"tab-tag\">24-DOF Rig</span>\n </button>\n <button class=\"dock-tab\" data-mode=\"3\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">04</span><span class=\"tab-label\">Harmonics</span></div>\n <span class=\"tab-tag\">Pure DSP</span>\n </button>\n <button class=\"dock-tab\" data-mode=\"4\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">05</span><span class=\"tab-label\">Citadel</span></div>\n <span class=\"tab-tag\">Live Stack</span>\n </button>\n </nav>\n\n <!-- Self-Verification & Live Code Inspector Modal -->\n <aside id=\"audit-modal\" role=\"dialog\" aria-label=\"Live Claim Verification\">\n <div class=\"audit-head\">\n <div class=\"audit-title\">Live Claim Audit // Zero-Smoke Introspection <span id=\"audit-summary\">ALL CHECKS PASS</span></div>\n <button class=\"chip\" id=\"btn-audit-close\">Close [Esc]</button>\n </div>\n <div class=\"audit-body\">\n <div class=\"audit-checks\" id=\"audit-list\"></div>\n <div class=\"audit-code-pane\">\n <div class=\"code-tabs\">\n <button class=\"chip on\" data-src=\"glsl\">Live GLSL Raymarcher</button>\n <button class=\"chip\" data-src=\"physics\">Lagrangian Physics</button>\n <button class=\"chip\" data-src=\"persona\">Talos-06 Kinematics</button>\n <button class=\"chip\" data-src=\"dsp\">WebAudio + Claviger Router</button>\n </div>\n <pre id=\"live-code-view\"></pre>\n </div>\n </div>\n </aside>\n</div>\n\n<!-- WebGL2 Fragment Shader: Unified 5-Stage Real-Time Backdrop + 3D SDF Raymarcher -->\n<script id=\"shader-frag\" type=\"x-shader/x-fragment\">#version 300 es\nprecision highp float;\n\nout vec4 fragColor;\nuniform vec2 u_res;\nuniform float u_time;\nuniform vec2 u_mouse;\nuniform vec4 u_weights; // x:Optics, y:Continuum, z:Automaton, w:Harmonics\nuniform float u_w4; // Citadel topology weight\nuniform vec2 u_camRot; // yaw, pitch\nuniform float u_slice; // CSG cross-section plane offset\nuniform float u_pass; // 0:PBR+Dispersion, 1:Normals, 2:Iso-SDF, 3:Clay+AO\nuniform vec4 u_wells[4];\nuniform vec3 u_shock;\nuniform vec3 u_arousal; // x:warmth, y:startle, z:focus\nuniform vec4 u_pulse; // 4 Euclidean ring envelopes\n\nmat2 rot(float a) {\n float c = cos(a), s = sin(a);\n return mat2(c, -s, s, c);\n}\n\nfloat sdRoundBox(vec3 p, vec3 b, float r) {\n vec3 q = abs(p) - b;\n return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0) - r;\n}\n\nfloat sdOctahedron(vec3 p, float s) {\n p = abs(p);\n return (p.x + p.y + p.z - s) * 0.57735027;\n}\n\nfloat sdBoxFrame(vec3 p, vec3 b, float e) {\n p = abs(p) - b;\n vec3 q = abs(p + e) - e;\n return min(min(\n length(max(vec3(p.x, q.y, q.z), 0.0)) + min(max(p.x, max(q.y, q.z)), 0.0),\n length(max(vec3(q.x, p.y, q.z), 0.0)) + min(max(q.x, max(p.y, q.z)), 0.0)),\n length(max(vec3(q.x, q.y, p.z), 0.0)) + min(max(q.x, max(q.y, p.z)), 0.0));\n}\n\nfloat sdMachinedRing(vec3 p, float r, float halfW, float halfH) {\n vec2 d = abs(vec2(length(p.xz) - r, p.y)) - vec2(halfW, halfH);\n return min(max(d.x, d.y), 0.0) + length(max(d, 0.0)) - 0.012;\n}\n\n// Returns vec2(distance, materialID)\n// matID: 1=Basalt Frame, 2=Refractive Crystal Core, 3=Solar Brass Gimbal, 4=Laser Cut Face, 5=Metrology Floor\nvec2 mapScene(vec3 p) {\n // Architectural basalt outer cage\n vec3 pf = p;\n pf.xz *= rot(0.22 * sin(u_time * 0.35));\n float cage = sdBoxFrame(pf, vec3(0.86), 0.072) - 0.012;\n float cornerTrim = sdOctahedron(pf, 1.52);\n cage = max(cage, cornerTrim);\n // Bore precision apertures along axes\n vec3 ap = abs(pf);\n float bores = min(min(length(ap.xy), length(ap.yz)), length(ap.xz)) - 0.30;\n cage = max(cage, -bores);\n\n // Counter-rotating machined brass gimbals\n vec3 pg1 = p;\n pg1.xy *= rot(0.62);\n pg1.xz *= rot(u_time * 0.55);\n float ring1 = sdMachinedRing(pg1, 0.68, 0.036, 0.055);\n float ticks1 = sin(atan(pg1.z, pg1.x) * 24.0) * 0.004;\n ring1 += ticks1;\n\n vec3 pg2 = p;\n pg2.yz *= rot(-0.78);\n pg2.xz *= rot(-u_time * 0.72);\n float ring2 = sdMachinedRing(pg2, 0.53, 0.030, 0.044);\n\n float gimbals = min(ring1, ring2);\n\n // Inner dispersive crystal polyhedron\n vec3 pc = p;\n pc.xz *= rot(-u_time * 0.42);\n pc.xy *= rot(u_time * 0.29);\n float core = max(sdRoundBox(pc, vec3(0.33), 0.025), sdOctahedron(pc, 0.52));\n\n // Combine solid assembly\n vec2 res = vec2(cage, 1.0);\n if (gimbals < res.x) res = vec2(gimbals, 3.0);\n if (core < res.x) res = vec2(core, 2.0);\n\n // Interactive CSG cross-section plane\n vec3 cutN = normalize(vec3(0.62, 0.52, 0.58));\n float dSlice = dot(p, cutN) - u_slice;\n if (dSlice > res.x) {\n res = vec2(dSlice, 4.0);\n } else if (abs(dSlice - res.x) < 0.016 && dSlice > -0.02) {\n res.y = 4.0;\n }\n\n // Metrology studio floor\n float floorD = p.y + 1.22;\n if (floorD < res.x) res = vec2(floorD, 5.0);\n\n return res;\n}\n\nvec3 calcNormal(vec3 p) {\n const vec2 e = vec2(0.0012, -0.0012);\n return normalize(\n e.xyy * mapScene(p + e.xyy).x +\n e.yyx * mapScene(p + e.yyx).x +\n e.yxy * mapScene(p + e.yxy).x +\n e.xxx * mapScene(p + e.xxx).x\n );\n}\n\nfloat calcAO(vec3 pos, vec3 nor) {\n float occ = 0.0;\n float sca = 1.0;\n for (int i = 0; i < 5; i++) {\n float h = 0.02 + 0.11 * float(i) / 4.0;\n float d = mapScene(pos + h * nor).x;\n occ += (h - d) * sca;\n sca *= 0.72;\n }\n return clamp(1.0 - 2.4 * occ, 0.0, 1.0);\n}\n\nfloat calcSoftShadow(vec3 ro, vec3 rd) {\n float res = 1.0;\n float t = 0.04;\n for (int i = 0; i < 24; i++) {\n float h = mapScene(ro + rd * t).x;\n res = min(res, 10.0 * h / t);\n t += clamp(h, 0.025, 0.18);\n if (res < 0.005 || t > 3.5) break;\n }\n return clamp(res, 0.0, 1.0);\n}\n\nvec3 envDome(vec3 rd) {\n float up = clamp(rd.y * 0.5 + 0.5, 0.0, 1.0);\n vec3 col = mix(vec3(0.025, 0.03, 0.042), vec3(0.09, 0.105, 0.14), up);\n // Warm solar studio strip\n float strip1 = pow(max(dot(rd, normalize(vec3(0.7, 0.55, 0.4))), 0.0), 18.0);\n // Cool verdigris rim strip\n float strip2 = pow(max(dot(rd, normalize(vec3(-0.75, 0.35, -0.5))), 0.0), 14.0);\n col += vec3(1.0, 0.42, 0.16) * strip1 * 1.35;\n col += vec3(0.22, 0.85, 0.72) * strip2 * 0.85;\n return col;\n}\n\nvec3 renderOptics(vec2 uv) {\n float yaw = u_camRot.x;\n float pitch = clamp(u_camRot.y, -1.05, 1.05);\n float dist = 3.35;\n vec3 ro = vec3(sin(yaw) * cos(pitch), sin(pitch) * 0.85 + 0.18, cos(yaw) * cos(pitch)) * dist;\n vec3 ta = vec3(0.0, -0.08, 0.0);\n vec3 ww = normalize(ta - ro);\n vec3 uu = normalize(cross(ww, vec3(0.0, 1.0, 0.0)));\n vec3 vv = cross(uu, ww);\n vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.85 * ww);\n\n vec3 bg = vec3(0.028, 0.032, 0.044) + 0.03 * max(0.0, 1.0 - length(uv) * 0.75);\n\n // Bounding check: sphere radius 1.75 around origin OR floor y = -1.22\n float b = dot(ro, rd);\n float c = dot(ro, ro) - 3.15;\n float disc = b * b - c;\n bool hitFloorPossible = (rd.y < -0.001 && ro.y > -1.22);\n if (disc < 0.0 && !hitFloorPossible) {\n return bg;\n }\n\n float t = 0.2;\n float mat = -1.0;\n float glowAcc = 0.0;\n for (int i = 0; i < 68; i++) {\n vec3 p = ro + rd * t;\n vec2 h = mapScene(p);\n // Subtle volumetric caustics near crystal core\n float coreProx = length(p);\n glowAcc += 0.0032 / (0.09 + coreProx * coreProx * 3.5);\n if (h.x < 0.0014) {\n mat = h.y;\n break;\n }\n t += h.x * 0.92;\n if (t > 7.5) break;\n }\n\n vec3 col = bg;\n if (mat > 0.0) {\n vec3 p = ro + rd * t;\n vec3 n = calcNormal(p);\n float ao = calcAO(p, n);\n\n if (u_pass > 0.5 && u_pass < 1.5) {\n // Pass 1: World-space Normal + Fresnel Inspection\n float fres = pow(1.0 - max(dot(-rd, n), 0.0), 3.0);\n col = (n * 0.5 + 0.5) * (0.65 + 0.35 * ao) + fres * 0.25;\n return pow(clamp(col, 0.0, 1.0), vec3(0.85));\n }\n\n if (u_pass >= 1.5 && u_pass < 2.5) {\n // Pass 2: Signed-Distance Iso-Contour Metrology Pass\n float iso = abs(fract(length(p) * 14.0 - u_time * 0.6) - 0.5);\n float lines = smoothstep(0.08, 0.015, iso);\n float wire = smoothstep(0.03, 0.005, abs(fract((p.x + p.y + p.z) * 9.0) - 0.5));\n col = vec3(0.05, 0.07, 0.09) * ao;\n col += vec3(0.22, 0.83, 0.70) * lines * 0.85;\n col += vec3(1.0, 0.36, 0.14) * wire * 0.45;\n return col;\n }\n\n if (u_pass >= 2.5) {\n // Pass 3: Architectural Clay + Studio AO Pass\n vec3 keyL = normalize(vec3(0.65, 0.75, 0.38));\n float dif = max(dot(n, keyL), 0.0);\n float sh = (mat < 4.5) ? calcSoftShadow(p + n * 0.01, keyL) : 1.0;\n vec3 clay = vec3(0.84, 0.81, 0.76);\n col = clay * (0.22 * ao + 0.78 * dif * sh * ao);\n if (mat > 4.5) {\n float rGrid = abs(fract(length(p.xz) * 2.5) - 0.5);\n col *= mix(0.22, 0.34, smoothstep(0.02, 0.06, rGrid)) * exp(-0.28 * length(p.xz));\n }\n return pow(clamp(col, 0.0, 1.0), vec3(0.9));\n }\n\n // Pass 0: Full Studio PBR + 3-Wavelength Chromatic Dispersion\n vec3 keyDir = normalize(vec3(0.68, 0.66, 0.32));\n vec3 rimDir = normalize(vec3(-0.72, 0.35, -0.58));\n float dif = max(dot(n, keyDir), 0.0);\n float rim = max(dot(n, rimDir), 0.0);\n float fres = pow(1.0 - max(dot(-rd, n), 0.0), 4.0);\n\n if (mat > 4.5) {\n // Metrology Turntable Floor\n float sh = calcSoftShadow(p + n * 0.015, keyDir);\n float rad = length(p.xz);\n float ringLine = 1.0 - smoothstep(0.0, 0.015, abs(fract(rad * 2.0) - 0.5) - 0.485);\n float axisLine = 1.0 - smoothstep(0.0, 0.012, min(abs(p.x), abs(p.z)));\n vec3 baseF = vec3(0.032, 0.036, 0.048) * (0.4 + 0.6 * sh) * ao;\n baseF += vec3(0.22, 0.25, 0.30) * (ringLine * 0.28 + axisLine * 0.22) * exp(-0.55 * rad);\n // Glossy reflection hint\n vec3 refl = envDome(reflect(rd, n));\n col = mix(baseF, refl * sh, 0.14) * exp(-0.18 * rad * rad) + bg * (1.0 - exp(-0.18 * rad * rad));\n } else if (mat > 1.5 && mat < 2.5) {\n // Dispersive Crystal Core (RGB split IOR)\n vec3 rR = envDome(refract(rd, n, 1.0 / 1.41));\n vec3 rG = envDome(refract(rd, n, 1.0 / 1.49));\n vec3 rB = envDome(refract(rd, n, 1.0 / 1.58));\n vec3 refracted = vec3(rR.r, rG.g, rB.b) * 1.75;\n // Internal incandescent solar heart\n float heart = exp(-5.0 * length(p));\n refracted += vec3(1.0, 0.40, 0.12) * heart * 1.4 + vec3(0.22, 0.85, 0.72) * (1.0 - heart) * 0.22;\n vec3 refl = envDome(reflect(rd, n));\n col = mix(refracted, refl * 1.3, 0.22 + 0.68 * fres);\n col += vec3(1.0, 0.82, 0.55) * pow(max(dot(reflect(-keyDir, n), -rd), 0.0), 42.0) * 1.2;\n } else if (mat > 2.5 && mat < 3.5) {\n // Anodized Solar Brass Gimbal Rings\n float sh = calcSoftShadow(p + n * 0.01, keyDir);\n vec3 alb = vec3(0.92, 0.58, 0.22);\n vec3 h = normalize(keyDir - rd);\n float spec = pow(max(dot(n, h), 0.0), 36.0);\n col = alb * (0.14 * ao + 0.75 * dif * sh) + alb * spec * 1.4 * sh + vec3(0.22, 0.83, 0.70) * rim * 0.25 * ao;\n col += envDome(reflect(rd, n)) * (0.18 + 0.45 * fres);\n } else if (mat > 3.5 && mat < 4.5) {\n // Machined CSG Cross-Section Face (diagonal metrology hatch + heated laser rim)\n float hatch = smoothstep(-0.2, 0.2, sin((p.x - p.y + p.z) * 85.0));\n vec3 faceCol = mix(vec3(0.10, 0.11, 0.14), vec3(0.24, 0.22, 0.20), hatch) * (0.5 + 0.5 * ao);\n // Outer boundary laser heat glow\n vec3 pOff = p - normalize(vec3(0.62, 0.52, 0.58)) * 0.018;\n float edgeProx = abs(mapScene(pOff).x);\n float rimHeat = exp(-42.0 * edgeProx);\n col = faceCol + vec3(1.0, 0.36, 0.10) * rimHeat * 1.65;\n } else {\n // Etched Basalt Titanium Outer Frame\n float sh = calcSoftShadow(p + n * 0.01, keyDir);\n vec3 alb = vec3(0.14, 0.155, 0.19);\n vec3 h = normalize(keyDir - rd);\n float spec = pow(max(dot(n, h), 0.0), 28.0);\n col = alb * (0.20 * ao + 0.85 * dif * sh) + vec3(0.95, 0.88, 0.80) * spec * 0.55 * sh;\n col += vec3(0.22, 0.83, 0.70) * rim * 0.22 * ao + envDome(reflect(rd, n)) * (0.10 + 0.35 * fres);\n }\n }\n\n col += vec3(1.0, 0.38, 0.14) * glowAcc * 0.28;\n return col;\n}\n\nvoid main() {\n vec2 uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y);\n\n // Subtle architectural background grid across all modes\n vec2 gUV = uv * 9.0;\n vec2 grid = abs(fract(gUV - 0.5) - 0.5) / fwidth(gUV);\n float line = 1.0 - min(min(grid.x, grid.y), 1.0);\n vec3 base = vec3(0.027, 0.031, 0.043) + vec3(0.025, 0.028, 0.036) * line * 0.45;\n\n vec3 total = vec3(0.0);\n\n // 01: Raymarched 3D Optics (evaluated only while visible)\n if (u_weights.x > 0.004) {\n total += renderOptics(uv) * u_weights.x;\n }\n\n // 02: Spacetime Potential Lensing for Continuum Physics\n if (u_weights.y > 0.004) {\n vec3 cCol = base;\n float pot = 0.0;\n for (int i = 0; i < 4; i++) {\n vec4 w = u_wells[i];\n if (abs(w.z) > 0.01) {\n float d = length(uv - w.xy);\n pot += w.z * 0.045 / (d + 0.055);\n float ring = exp(-28.0 * abs(d - 0.09 - 0.02 * sin(u_time * 4.0 + float(i))));\n cCol += (w.z > 0.0 ? vec3(1.0, 0.35, 0.14) : vec3(0.22, 0.83, 0.70)) * ring * 0.45;\n }\n }\n float equipot = abs(fract(pot * 4.5 - u_time * 0.25) - 0.5);\n cCol += vec3(0.16, 0.32, 0.36) * (1.0 - smoothstep(0.0, 0.06, equipot)) * 0.35;\n if (u_shock.z > 0.001 && u_shock.z < 2.2) {\n float sd = abs(length(uv - u_shock.xy) - u_shock.z);\n cCol += vec3(1.0, 0.62, 0.24) * exp(-36.0 * sd) * (1.0 - u_shock.z / 2.2) * 0.9;\n }\n total += cCol * u_weights.y;\n }\n\n // 03: Studio Depth Halo for Talos-06 Automaton\n if (u_weights.z > 0.004) {\n float d = length(uv - vec2(0.0, 0.04));\n vec3 pCol = base;\n vec3 aura = mix(vec3(0.22, 0.83, 0.70), vec3(1.0, 0.35, 0.14), clamp(u_arousal.y, 0.0, 1.0));\n aura = mix(aura, vec3(0.95, 0.70, 0.25), clamp(u_arousal.x * 0.6, 0.0, 1.0));\n pCol += aura * exp(-4.2 * d * d) * 0.20;\n float reticle = abs(fract(d * 7.0 - u_time * 0.18) - 0.5);\n pCol += aura * (1.0 - smoothstep(0.0, 0.025, reticle)) * exp(-2.5 * d) * 0.08;\n total += pCol * u_weights.z;\n }\n\n // 04: Harmonic Wavefront Ripples for Euclidean Synth\n if (u_weights.w > 0.004) {\n float r = length(uv - vec2(0.0, 0.03));\n vec3 hCol = base;\n float radii[4] = float[4](0.36, 0.275, 0.195, 0.12);\n vec3 cols[4] = vec3[4](\n vec3(0.95, 0.70, 0.25),\n vec3(0.22, 0.83, 0.70),\n vec3(0.94, 0.92, 0.88),\n vec3(1.00, 0.35, 0.14)\n );\n float pulses[4] = float[4](u_pulse.x, u_pulse.y, u_pulse.z, u_pulse.w);\n for (int i = 0; i < 4; i++) {\n float wave = exp(-34.0 * abs(r - radii[i])) * (0.12 + 0.95 * pulses[i]);\n hCol += cols[i] * wave * 0.45;\n }\n total += hCol * u_weights.w;\n }\n\n // 05: Citadel Architectural Schematic Field\n if (u_w4 > 0.004) {\n vec3 sCol = base * 0.92;\n float scan = exp(-18.0 * abs(uv.x - (mod(u_time * 0.28, 2.4) - 1.2)));\n sCol += vec3(1.0, 0.36, 0.14) * scan * 0.045;\n total += sCol * u_w4;\n }\n\n // Subtle vignette & ACES-inspired filmic curve\n float vig = 1.0 - 0.28 * dot(uv, uv);\n total *= clamp(vig, 0.55, 1.0);\n total = (total * (2.51 * total + 0.03)) / (total * (2.43 * total + 0.59) + 0.14);\n fragColor = vec4(pow(clamp(total, 0.0, 1.0), vec3(0.92)), 1.0);\n}\n</script>\n\n<script>\n(() => {\n 'use strict';\n\n /* =========================================================================\n 0. MODE METADATA & SYSTEM STATE\n ========================================================================= */\n const MODES = [\n {\n kicker: '01 ─ SPATIAL & 3D PIPELINE',\n hint: 'Drag to orbit · Scrub cut plane',\n title: 'Raymarched CSG & Chromatic Dispersion',\n desc: 'Real-time signed-distance assembly with three-wavelength refraction, machined boolean cross-sections, and live render passes.'\n },\n {\n kicker: '02 ─ LAGRANGIAN PHYSICS',\n hint: 'Move to shear · Click to drop gravity well',\n title: '3,200-Body Coupled Vortex Continuum',\n desc: 'Divergence-free curl-noise filaments and orbital singularities integrated in typed arrays at 60fps.'\n },\n {\n kicker: '03 ─ CHARACTER KINEMATICS',\n hint: 'Hover gently · Shake fast · Click optic',\n title: 'TALOS-06 Procedural Expression Rig',\n desc: 'Perspective-projected 24-DOF automaton with biological micro-saccades, 8-blade iris apertures, and emergent emotional physics.'\n },\n {\n kicker: '04 ─ SIGNAL & COMPOSITION',\n hint: 'Click orbital steps to rewrite harmony',\n title: 'Zero-Sample Euclidean Polyrhythm Loom',\n desc: 'Four rotating Bjorklund rhythms driving mathematical FM glass bells, waveguide strings, and a live stereo Lissajous scope.'\n },\n {\n kicker: '05 ─ CITADEL & SEAT 06',\n hint: 'Click any model · Send a message to Claviger',\n title: 'What Runs Citadel Today — And This Cold Run',\n desc: 'Five models + Claviger (Laya-421M) run Severian’s live stack. Gemini 4 Carbon wasn’t in about-me.md—this file is its cold-start answer.'\n }\n ];\n\n const REEL_SECONDS = 4.3;\n let activeMode = 0;\n let autoReel = true;\n let reelTimer = 0;\n let weights = [1, 0, 0, 0, 0];\n\n let W = window.innerWidth;\n let H = window.innerHeight;\n let DPR = Math.min(window.devicePixelRatio || 1, 2);\n\n // Pointer & interaction kinematics\n const pointer = {\n x: W * 0.5, y: H * 0.5,\n nx: 0, ny: 0, // -1..1 aspect-corrected\n vx: 0, vy: 0,\n speed: 0,\n down: false,\n inside: false,\n dragDX: 0, dragDY: 0,\n orbitAccum: 0,\n lastAngle: 0\n };\n\n // Rolling FPS & frame budget telemetry for self-audit\n let fpsSmooth = 60;\n let frameMsSmooth = 8.0;\n let glRendererInfo = 'Canvas2D Fallback';\n let glVersionInfo = 'Unavailable';\n\n /* =========================================================================\n 1. PROCEDURAL WEBAUDIO SYNTHESIZER (ZERO EXTERNAL SAMPLES)\n ========================================================================= */\n const DSP = {\n ctx: null,\n enabled: false,\n mutedByUser: false,\n master: null,\n analyserL: null,\n analyserR: null,\n waveBufL: new Float32Array(256),\n waveBufR: new Float32Array(256),\n\n unlock(forceToggle = false) {\n if (forceToggle) {\n if (this.enabled) {\n this.enabled = false;\n this.mutedByUser = true;\n if (this.master && this.ctx) {\n this.master.gain.setTargetAtTime(0.0001, this.ctx.currentTime, 0.04);\n }\n updateSoundUI();\n return;\n }\n this.mutedByUser = false;\n } else if (this.mutedByUser) {\n return;\n }\n\n if (!this.ctx) {\n const AC = window.AudioContext || window.webkitAudioContext;\n if (!AC) return;\n const ctx = new AC();\n this.ctx = ctx;\n\n const comp = ctx.createDynamicsCompressor();\n comp.threshold.value = -16;\n comp.ratio.value = 5;\n comp.attack.value = 0.005;\n comp.release.value = 0.18;\n\n const master = ctx.createGain();\n master.gain.value = 0.23;\n this.master = master;\n\n // Stereo splitter for real Lissajous X-Y scope\n const splitter = ctx.createChannelSplitter(2);\n this.analyserL = ctx.createAnalyser();\n this.analyserR = ctx.createAnalyser();\n this.analyserL.fftSize = 512;\n this.analyserR.fftSize = 512;\n\n // Dotted-eighth stereo ping-pong delay + warm lowpass feedback\n const dL = ctx.createDelay(1.0);\n const dR = ctx.createDelay(1.0);\n dL.delayTime.value = 0.255;\n dR.delayTime.value = 0.382;\n const fbL = ctx.createGain();\n const fbR = ctx.createGain();\n fbL.gain.value = 0.32;\n fbR.gain.value = 0.30;\n const damp = ctx.createBiquadFilter();\n damp.type = 'lowpass';\n damp.frequency.value = 2400;\n\n const wet = ctx.createGain();\n wet.gain.value = 0.28;\n const pannerL = ctx.createStereoPanner ? ctx.createStereoPanner() : null;\n const pannerR = ctx.createStereoPanner ? ctx.createStereoPanner() : null;\n if (pannerL && pannerR) {\n pannerL.pan.value = -0.65;\n pannerR.pan.value = 0.65;\n }\n\n this.bus = ctx.createGain();\n this.bus.connect(comp);\n this.bus.connect(damp);\n damp.connect(dL);\n dL.connect(fbL);\n fbL.connect(dR);\n dR.connect(fbR);\n fbR.connect(damp);\n\n if (pannerL && pannerR) {\n dL.connect(pannerL); pannerL.connect(wet);\n dR.connect(pannerR); pannerR.connect(wet);\n } else {\n dL.connect(wet); dR.connect(wet);\n }\n wet.connect(comp);\n comp.connect(master);\n master.connect(ctx.destination);\n master.connect(splitter);\n splitter.connect(this.analyserL, 0);\n splitter.connect(this.analyserR, 1);\n }\n\n if (this.ctx.state === 'suspended') {\n this.ctx.resume();\n }\n this.enabled = true;\n this.master.gain.setTargetAtTime(0.23, this.ctx.currentTime, 0.05);\n updateSoundUI();\n },\n\n click(freq = 320, dur = 0.025, vol = 0.08) {\n if (!this.enabled || !this.ctx) return;\n const t = this.ctx.currentTime;\n const osc = this.ctx.createOscillator();\n const g = this.ctx.createGain();\n osc.type = 'triangle';\n osc.frequency.setValueAtTime(freq, t);\n osc.frequency.exponentialRampToValueAtTime(freq * 0.45, t + dur);\n g.gain.setValueAtTime(vol, t);\n g.gain.exponentialRampToValueAtTime(0.0001, t + dur);\n osc.connect(g);\n g.connect(this.bus);\n osc.start(t);\n osc.stop(t + dur + 0.01);\n },\n\n voice(ringIdx, freq, pan = 0) {\n if (!this.enabled || !this.ctx) return;\n const ctx = this.ctx;\n const t = ctx.currentTime;\n const out = ctx.createGain();\n const panner = ctx.createStereoPanner ? ctx.createStereoPanner() : null;\n if (panner) {\n panner.pan.value = Math.max(-0.85, Math.min(0.85, pan));\n out.connect(panner);\n panner.connect(this.bus);\n } else {\n out.connect(this.bus);\n }\n\n if (ringIdx === 0) {\n // Plucked harmonic string (triangle + filtered harmonic burst)\n const o1 = ctx.createOscillator();\n const o2 = ctx.createOscillator();\n const flt = ctx.createBiquadFilter();\n o1.type = 'sawtooth';\n o2.type = 'triangle';\n o1.frequency.value = freq;\n o2.frequency.value = freq * 2.0;\n flt.type = 'lowpass';\n flt.frequency.setValueAtTime(freq * 5.5, t);\n flt.frequency.exponentialRampToValueAtTime(freq * 1.3, t + 0.28);\n out.gain.setValueAtTime(0.001, t);\n out.gain.linearRampToValueAtTime(0.14, t + 0.006);\n out.gain.exponentialRampToValueAtTime(0.0001, t + 0.55);\n o1.connect(flt); o2.connect(flt); flt.connect(out);\n o1.start(t); o2.start(t);\n o1.stop(t + 0.58); o2.stop(t + 0.58);\n } else if (ringIdx === 1) {\n // 2-Operator FM Crystalline Bell\n const car = ctx.createOscillator();\n const mod = ctx.createOscillator();\n const modG = ctx.createGain();\n car.type = 'sine';\n mod.type = 'sine';\n car.frequency.value = freq;\n mod.frequency.value = freq * 3.0;\n modG.gain.setValueAtTime(freq * 1.9, t);\n modG.gain.exponentialRampToValueAtTime(0.5, t + 0.36);\n out.gain.setValueAtTime(0.001, t);\n out.gain.linearRampToValueAtTime(0.15, t + 0.008);\n out.gain.exponentialRampToValueAtTime(0.0001, t + 0.85);\n mod.connect(modG);\n modG.connect(car.frequency);\n car.connect(out);\n car.start(t); mod.start(t);\n car.stop(t + 0.88); mod.stop(t + 0.88);\n } else if (ringIdx === 2) {\n // Warm Sub-Analog Bass Pulse\n const o1 = ctx.createOscillator();\n const o2 = ctx.createOscillator();\n const flt = ctx.createBiquadFilter();\n o1.type = 'sawtooth';\n o2.type = 'sawtooth';\n o1.frequency.value = freq;\n o2.frequency.value = freq * 1.006;\n flt.type = 'lowpass';\n flt.Q.value = 2.8;\n flt.frequency.setValueAtTime(580, t);\n flt.frequency.exponentialRampToValueAtTime(140, t + 0.45);\n out.gain.setValueAtTime(0.001, t);\n out.gain.linearRampToValueAtTime(0.16, t + 0.015);\n out.gain.exponentialRampToValueAtTime(0.0001, t + 0.62);\n o1.connect(flt); o2.connect(flt); flt.connect(out);\n o1.start(t); o2.start(t);\n o1.stop(t + 0.65); o2.stop(t + 0.65);\n } else {\n // Tuned Micro-Relay Percussion\n const osc = ctx.createOscillator();\n osc.type = 'sine';\n osc.frequency.setValueAtTime(freq * 2.4, t);\n osc.frequency.exponentialRampToValueAtTime(95, t + 0.065);\n out.gain.setValueAtTime(0.11, t);\n out.gain.exponentialRampToValueAtTime(0.0001, t + 0.08);\n osc.connect(out);\n osc.start(t);\n osc.stop(t + 0.09);\n }\n },\n\n boom() {\n if (!this.enabled || !this.ctx) return;\n const t = this.ctx.currentTime;\n const osc = this.ctx.createOscillator();\n const g = this.ctx.createGain();\n osc.type = 'sine';\n osc.frequency.setValueAtTime(118, t);\n osc.frequency.exponentialRampToValueAtTime(34, t + 0.48);\n g.gain.setValueAtTime(0.26, t);\n g.gain.exponentialRampToValueAtTime(0.0001, t + 0.52);\n osc.connect(g); g.connect(this.bus);\n osc.start(t); osc.stop(t + 0.55);\n },\n\n emote(kind) {\n if (!this.enabled || !this.ctx) return;\n if (kind === 'curious') {\n this.voice(1, 587.33, -0.2);\n setTimeout(() => this.voice(1, 880.0, 0.2), 75);\n } else if (kind === 'skeptical') {\n this.voice(2, 164.81, 0);\n } else if (kind === 'startled') {\n this.voice(0, 987.77, -0.35);\n this.voice(3, 440, 0.35);\n } else if (kind === 'delighted') {\n [587.33, 739.99, 880.0, 1108.73].forEach((f, i) => {\n setTimeout(() => this.voice(1, f, (i - 1.5) * 0.35), i * 55);\n });\n }\n }\n };\n\n /* =========================================================================\n 2. WEBGL 2.0 FULL-STAGE SHADER INIT\n ========================================================================= */\n const glCanvas = document.getElementById('gl');\n const hudCanvas = document.getElementById('hud');\n const ctx = hudCanvas.getContext('2d');\n const gl = glCanvas.getContext('webgl2', { antialias: false, depth: false, stencil: false, powerPreference: 'high-performance' });\n\n let glProg = null;\n const glUni = {};\n\n if (gl) {\n glVersionInfo = gl.getParameter(gl.VERSION) || 'WebGL 2.0';\n const dbg = gl.getExtension('WEBGL_debug_renderer_info');\n glRendererInfo = dbg ? (gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL) || 'Hardware GPU') : (gl.getParameter(gl.RENDERER) || 'WebGL2 GPU');\n\n const vsSrc = `#version 300 es\n in vec2 a_pos;\n void main() { gl_Position = vec4(a_pos, 0.0, 1.0); }`;\n const fsSrc = document.getElementById('shader-frag').textContent;\n\n const compile = (type, src) => {\n const sh = gl.createShader(type);\n gl.shaderSource(sh, src);\n gl.compileShader(sh);\n if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) {\n console.error('Shader error:', gl.getShaderInfoLog(sh));\n return null;\n }\n return sh;\n };\n\n const vs = compile(gl.VERTEX_SHADER, vsSrc);\n const fs = compile(gl.FRAGMENT_SHADER, fsSrc);\n if (vs && fs) {\n glProg = gl.createProgram();\n gl.attachShader(glProg, vs);\n gl.attachShader(glProg, fs);\n gl.linkProgram(glProg);\n if (gl.getProgramParameter(glProg, gl.LINK_STATUS)) {\n gl.useProgram(glProg);\n const buf = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buf);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n const loc = gl.getAttribLocation(glProg, 'a_pos');\n gl.enableVertexAttribArray(loc);\n gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\n\n ['u_res', 'u_time', 'u_mouse', 'u_weights', 'u_w4', 'u_camRot', 'u_slice', 'u_pass', 'u_shock', 'u_arousal', 'u_pulse'].forEach(n => {\n glUni[n] = gl.getUniformLocation(glProg, n);\n });\n glUni.u_wells = [];\n for (let i = 0; i < 4; i++) glUni.u_wells.push(gl.getUniformLocation(glProg, `u_wells[${i}]`));\n } else {\n console.error('Link error:', gl.getProgramInfoLog(glProg));\n glProg = null;\n }\n }\n }\n\n function resize() {\n W = window.innerWidth;\n H = window.innerHeight;\n DPR = Math.min(window.devicePixelRatio || 1, 2);\n // Slight cap on raymarch DPI for huge 4K monitors to guarantee locked 60fps\n const glScale = Math.min(DPR, (W * H > 1400000) ? 1.35 : 1.75);\n glCanvas.width = Math.max(1, Math.floor(W * glScale));\n glCanvas.height = Math.max(1, Math.floor(H * glScale));\n hudCanvas.width = Math.max(1, Math.floor(W * DPR));\n hudCanvas.height = Math.max(1, Math.floor(H * DPR));\n if (gl) gl.viewport(0, 0, glCanvas.width, glCanvas.height);\n layoutCitadelNodes();\n }\n window.addEventListener('resize', resize);\n\n /* =========================================================================\n 3. MODE 01 STATE: 3D OPTICS & PIPELINE TELEMETRY\n ========================================================================= */\n const optics = {\n yaw: 0.58,\n pitch: 0.34,\n vYaw: 0.0035,\n vPitch: 0,\n slice: 0.28,\n userSliced: false,\n pass: 0\n };\n\n function projectOpticsPin(p3) {\n const yaw = optics.yaw;\n const pitch = Math.max(-1.05, Math.min(1.05, optics.pitch));\n const dist = 3.35;\n const ro = [Math.sin(yaw) * Math.cos(pitch) * dist, Math.sin(pitch) * 0.85 * dist + 0.18 * dist, Math.cos(yaw) * Math.cos(pitch) * dist];\n const ta = [0, -0.08, 0];\n const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];\n const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];\n const norm = a => { const l = Math.hypot(a[0], a[1], a[2]) || 1; return [a[0] / l, a[1] / l, a[2] / l]; };\n const ww = norm(sub(ta, ro));\n const uu = norm(cross(ww, [0, 1, 0]));\n const vv = cross(uu, ww);\n const rel = sub(p3, ro);\n const z = dot(rel, ww);\n if (z <= 0.2) return null;\n const ux = (dot(rel, uu) / z) * 1.85;\n const uy = (dot(rel, vv) / z) * 1.85;\n const minDim = Math.min(W, H);\n return {\n x: W * 0.5 + ux * minDim,\n y: H * 0.5 - uy * minDim\n };\n }\n\n /* =========================================================================\n 4. MODE 02 ENGINE: 3,200-BODY LAGRANGIAN VORTEX CONTINUUM\n ========================================================================= */\n const PARTICLE_COUNT = 3200;\n const pX = new Float32Array(PARTICLE_COUNT);\n const pY = new Float32Array(PARTICLE_COUNT);\n const pVX = new Float32Array(PARTICLE_COUNT);\n const pVY = new Float32Array(PARTICLE_COUNT);\n const pPX = new Float32Array(PARTICLE_COUNT);\n const pPY = new Float32Array(PARTICLE_COUNT);\n\n function initParticles() {\n for (let i = 0; i < PARTICLE_COUNT; i++) {\n const a = Math.random() * Math.PI * 2;\n const r = Math.sqrt(Math.random()) * 0.72;\n pX[i] = pPX[i] = Math.cos(a) * r * (W / Math.min(W, H));\n pY[i] = pPY[i] = Math.sin(a) * r;\n pVX[i] = -Math.sin(a) * 0.004;\n pVY[i] = Math.cos(a) * 0.004;\n }\n }\n\n const continuum = {\n flowMode: 0, // 0:Accretion, 1:Curl Turbulence, 2:Dipole Lattice\n wells: [\n { x: -0.26, y: 0.04, s: 1.0, age: 0 },\n { x: 0.26, y: -0.04, s: -0.9, age: 1.5 },\n { x: 0, y: 0, s: 0, age: 0 },\n { x: 0, y: 0, s: 0, age: 0 }\n ],\n wellCursor: 2,\n shock: { x: 0, y: 0, r: 9.0 },\n kineticEnergy: 0\n };\n\n function stepPhysics(dt, time) {\n const aspect = W / Math.min(W, H);\n const hBound = H / Math.min(W, H) * 0.52;\n const wBound = aspect * 0.52;\n\n if (autoReel && activeMode === 1) {\n continuum.wells[0].x = Math.cos(time * 0.75) * 0.28;\n continuum.wells[0].y = Math.sin(time * 0.75) * 0.16;\n continuum.wells[0].s = 1.05;\n continuum.wells[1].x = -continuum.wells[0].x;\n continuum.wells[1].y = -continuum.wells[0].y;\n continuum.wells[1].s = -0.95;\n }\n\n if (continuum.shock.r < 2.5) {\n continuum.shock.r += dt * 1.95;\n }\n\n let keSum = 0;\n const fm = continuum.flowMode;\n const hasPtr = pointer.inside;\n const mx = pointer.nx, my = pointer.ny;\n const mvx = pointer.vx, mvy = pointer.vy;\n const sr = continuum.shock.r;\n const sx = continuum.shock.x, sy = continuum.shock.y;\n\n for (let i = 0; i < PARTICLE_COUNT; i++) {\n let x = pX[i], y = pY[i];\n let vx = pVX[i], vy = pVY[i];\n pPX[i] = x;\n pPY[i] = y;\n\n // Analytic divergence-free curl potential\n const sc = fm === 1 ? 5.2 : 3.1;\n const cx = Math.sin(y * sc + time * 0.7) + Math.cos((x + y) * sc * 0.7 - time * 0.45);\n const cy = Math.cos(x * sc - time * 0.65) - Math.sin((x - y) * sc * 0.7 + time * 0.5);\n const curlAmt = fm === 1 ? 0.00052 : 0.00021;\n vx += cx * curlAmt;\n vy += cy * curlAmt;\n\n if (fm === 2) {\n // Magnetic dipole field lines\n const r2 = x * x + y * y + 0.035;\n const r5 = Math.pow(r2, 1.8);\n vx += (3 * x * y) / r5 * 0.00009;\n vy += (2 * y * y - x * x) / r5 * 0.00009;\n }\n\n // Coupled vortex + accretion singularities\n for (let w = 0; w < 4; w++) {\n const well = continuum.wells[w];\n if (Math.abs(well.s) < 0.01) continue;\n const dx = well.x - x;\n const dy = well.y - y;\n const d2 = dx * dx + dy * dy + 0.0045;\n const inv = 0.00026 / d2;\n // Swirl + gentle inward pull\n vx += (-dy * well.s * 1.35 + dx * 0.42) * inv;\n vy += (dx * well.s * 1.35 + dy * 0.42) * inv;\n }\n\n // Cursor momentum shear wake\n if (hasPtr) {\n const dx = x - mx;\n const dy = y - my;\n const d2 = dx * dx + dy * dy + 0.006;\n if (d2 < 0.12) {\n const inf = (0.12 - d2) * 0.14;\n vx += mvx * inf - dy * 0.0018 * inf;\n vy += mvy * inf + dx * 0.0018 * inf;\n }\n }\n\n // Expanding shockwave ring\n if (sr < 2.2) {\n const dx = x - sx, dy = y - sy;\n const dist = Math.sqrt(dx * dx + dy * dy) || 0.001;\n const band = Math.abs(dist - sr);\n if (band < 0.09) {\n const push = (1.0 - band / 0.09) * 0.0055;\n vx += (dx / dist) * push;\n vy += (dy / dist) * push;\n }\n }\n\n vx *= 0.982;\n vy *= 0.982;\n x += vx;\n y += vy;\n\n // Respawn escaped filaments gracefully near outer perimeter\n if (x < -wBound || x > wBound || y < -hBound || y > hBound) {\n const a = Math.random() * Math.PI * 2;\n x = pPX[i] = Math.cos(a) * 0.42 * aspect;\n y = pPY[i] = Math.sin(a) * 0.42;\n vx = -Math.sin(a) * 0.004;\n vy = Math.cos(a) * 0.004;\n }\n\n pX[i] = x; pY[i] = y;\n pVX[i] = vx; pVY[i] = vy;\n keSum += vx * vx + vy * vy;\n }\n continuum.kineticEnergy = keSum * 1000;\n }\n\n function drawContinuum(alpha) {\n const minDim = Math.min(W, H);\n const cx = W * 0.5, cy = H * 0.5;\n ctx.save();\n ctx.globalCompositeOperation = 'lighter';\n\n // Batch 3,200 filaments into 4 velocity-temperature paths (4 GPU draw calls total)\n const paths = [new Path2D(), new Path2D(), new Path2D(), new Path2D()];\n for (let i = 0; i < PARTICLE_COUNT; i++) {\n const x1 = cx + pPX[i] * minDim;\n const y1 = cy - pPY[i] * minDim;\n const vx = pVX[i] * minDim;\n const vy = -pVY[i] * minDim;\n const x2 = cx + pX[i] * minDim + vx * 1.35;\n const y2 = cy - pY[i] * minDim + vy * 1.35;\n const sp2 = pVX[i] * pVX[i] + pVY[i] * pVY[i];\n const bucket = sp2 > 0.00018 ? 3 : (sp2 > 0.000085 ? 2 : (sp2 > 0.000032 ? 1 : 0));\n paths[bucket].moveTo(x1, y1);\n paths[bucket].lineTo(x2, y2);\n }\n\n const styles = [\n `rgba(38, 152, 134, ${0.42 * alpha})`,\n `rgba(56, 212, 179, ${0.58 * alpha})`,\n `rgba(243, 179, 64, ${0.72 * alpha})`,\n `rgba(255, 96, 42, ${0.88 * alpha})`\n ];\n ctx.lineCap = 'round';\n for (let b = 0; b < 4; b++) {\n ctx.lineWidth = b === 3 ? 1.7 : 1.25;\n ctx.strokeStyle = styles[b];\n ctx.stroke(paths[b]);\n }\n ctx.restore();\n\n // Crisp vector reticles on active vortex wells\n ctx.save();\n ctx.globalAlpha = alpha;\n ctx.font = '500 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n for (let w = 0; w < 4; w++) {\n const well = continuum.wells[w];\n if (Math.abs(well.s) < 0.01) continue;\n const wx = cx + well.x * minDim;\n const wy = cy - well.y * minDim;\n ctx.strokeStyle = well.s > 0 ? 'rgba(255, 89, 36, 0.7)' : 'rgba(56, 212, 179, 0.7)';\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.arc(wx, wy, 9, 0, Math.PI * 2);\n ctx.moveTo(wx - 14, wy); ctx.lineTo(wx - 5, wy);\n ctx.moveTo(wx + 5, wy); ctx.lineTo(wx + 14, wy);\n ctx.moveTo(wx, wy - 14); ctx.lineTo(wx, wy - 5);\n ctx.moveTo(wx, wy + 5); ctx.lineTo(wx, wy + 14);\n ctx.stroke();\n ctx.fillStyle = 'rgba(239, 236, 228, 0.65)';\n ctx.fillText(well.s > 0 ? `+Γ${w + 1}` : `-Γ${w + 1}`, wx + 13, wy - 9);\n }\n ctx.restore();\n }\n\n /* =========================================================================\n 5. MODE 03 ENGINE: TALOS-06 24-DOF PROCEDURAL EXPRESSION RIG\n ========================================================================= */\n const talos = {\n preset: 'auto', // auto | curious | skeptical | startled | delighted\n yaw: 0, pitch: 0, roll: 0, zLean: 0,\n vYaw: 0, vPitch: 0, vRoll: 0,\n gazeX: 0, gazeY: 0,\n saccX: 0, saccY: 0, nextSaccade: 0,\n pupil: 0.48,\n blink: 0, nextBlink: 1.8,\n browL: 0, browR: 0, browTiltL: 0, browTiltR: 0,\n smile: 0, squintL: 0, squintR: 0,\n curiosity: 0.4, startle: 0, skepticism: 0.1,\n statusTag: 'OPTIC: CALIBRATING',\n boopTimer: 0\n };\n\n function stepTalos(dt, time) {\n // Biological micro-saccades\n if (time > talos.nextSaccade) {\n talos.saccX = (Math.random() - 0.5) * 0.09;\n talos.saccY = (Math.random() - 0.5) * 0.06;\n talos.nextSaccade = time + 0.45 + Math.random() * 1.15;\n }\n // Natural blink rhythm\n if (time > talos.nextBlink) {\n talos.blink = 1.0;\n talos.nextBlink = time + 2.4 + Math.random() * 3.2;\n }\n talos.blink = Math.max(0, talos.blink - dt * 7.5);\n if (talos.boopTimer > 0) talos.boopTimer = Math.max(0, talos.boopTimer - dt);\n\n let tYaw = 0, tPitch = 0, tRoll = 0, tLean = 0;\n let tPupil = 0.48, tBrowL = 0, tBrowR = 0, tTiltL = 0, tTiltR = 0;\n let tSmile = 0.08, tSqL = 0, tSqR = 0;\n let tGX = 0, tGY = 0;\n\n let mode = talos.preset;\n if (mode === 'auto') {\n if (talos.boopTimer > 0.1) {\n mode = 'skeptical';\n } else if (pointer.inside) {\n if (pointer.speed > 0.045) {\n talos.startle = Math.min(1, talos.startle + dt * 5.5);\n } else {\n talos.startle = Math.max(0, talos.startle - dt * 1.8);\n }\n const dist = Math.hypot(pointer.nx, pointer.ny);\n talos.curiosity = dist < 0.36 && pointer.speed < 0.02 ? Math.min(1, talos.curiosity + dt * 2.2) : Math.max(0.2, talos.curiosity - dt * 1.2);\n } else {\n // Expressive autonomous choreography during passive viewing\n const phase = (time * 0.65) % 4.0;\n if (phase < 1.1) mode = 'curious';\n else if (phase < 2.2) mode = 'skeptical';\n else if (phase < 3.1) mode = 'delighted';\n else mode = 'auto_idle';\n }\n }\n\n if (pointer.inside && talos.preset === 'auto' && talos.boopTimer <= 0.1) {\n tGX = Math.max(-0.85, Math.min(0.85, pointer.nx * 1.75));\n tGY = Math.max(-0.75, Math.min(0.75, -pointer.ny * 1.75));\n tYaw = tGX * 0.36;\n tPitch = tGY * 0.28;\n tRoll = tGX * 0.09 + Math.max(-0.28, Math.min(0.28, pointer.orbitAccum * 0.04));\n\n if (Math.abs(pointer.orbitAccum) > 4.2) {\n tPupil = 0.68;\n tSmile = 0.65;\n tSqL = 0.35; tSqR = 0.35;\n talos.statusTag = 'STATE: DIZZY / AMUSED';\n } else if (talos.startle > 0.45) {\n tPupil = 0.23;\n tBrowL = 0.75; tBrowR = 0.75;\n tTiltL = -0.32; tTiltR = -0.32;\n tLean = -0.22;\n talos.statusTag = 'REFLEX: HIGH VELOCITY';\n } else if (talos.curiosity > 0.62) {\n tPupil = 0.68;\n tBrowL = 0.28; tBrowR = 0.28;\n tLean = 0.18;\n tRoll += 0.11;\n tSmile = 0.32;\n talos.statusTag = 'STATE: CURIOUS LOCK';\n } else {\n talos.statusTag = 'OPTIC: SMOOTH PURSUIT';\n }\n } else if (mode === 'curious') {\n tGX = Math.sin(time * 1.3) * 0.25;\n tGY = -0.08;\n tYaw = 0.16; tPitch = -0.06; tRoll = 0.14; tLean = 0.20;\n tPupil = 0.68; tBrowL = 0.35; tBrowR = 0.35; tSmile = 0.25;\n talos.curiosity = 0.85; talos.startle = 0;\n talos.statusTag = 'STATE: INQUISITIVE';\n } else if (mode === 'skeptical') {\n tGX = pointer.inside ? pointer.nx * 1.2 : -0.22;\n tGY = 0.05;\n tYaw = -0.14; tPitch = 0.06; tRoll = -0.09;\n tPupil = 0.36;\n tBrowL = -0.35; tBrowR = 0.68; // Signature single-brow critic arch\n tTiltL = 0.28; tTiltR = -0.22;\n tSqL = 0.48; tSqR = 0.05;\n tSmile = -0.22;\n talos.skepticism = 0.92; talos.startle = 0;\n talos.statusTag = 'VERDICT: UNCONVINCED';\n } else if (mode === 'startled') {\n tGX = (Math.random() - 0.5) * 0.16;\n tGY = -0.12;\n tPitch = -0.12; tLean = -0.26;\n tPupil = 0.21;\n tBrowL = 0.85; tBrowR = 0.85;\n tTiltL = -0.35; tTiltR = -0.35;\n tSmile = -0.35;\n talos.startle = 0.95;\n talos.statusTag = 'ALERT: APERTURE f/11';\n } else if (mode === 'delighted') {\n tYaw = Math.sin(time * 2.1) * 0.09;\n tPitch = -0.08; tRoll = Math.sin(time * 2.1) * 0.08; tLean = 0.14;\n tPupil = 0.74;\n tBrowL = 0.42; tBrowR = 0.42;\n tSqL = 0.58; tSqR = 0.58;\n tSmile = 0.85;\n talos.curiosity = 0.9; talos.startle = 0;\n talos.statusTag = 'STATE: WARM RESONANCE';\n } else {\n tGX = Math.sin(time * 0.8) * 0.3;\n tYaw = tGX * 0.2;\n talos.statusTag = 'OPTIC: IDLE SCAN';\n }\n\n const k = Math.min(1, dt * 9.5);\n // Couple quick gaze jumps with subtle natural micro-blink\n if (Math.hypot(tGX - talos.gazeX, tGY - talos.gazeY) > 0.55) {\n talos.blink = Math.max(talos.blink, 0.55);\n }\n talos.yaw += (tYaw - talos.yaw) * k;\n talos.pitch += (tPitch - talos.pitch) * k;\n talos.roll += (tRoll - talos.roll) * k;\n talos.zLean += (tLean - talos.zLean) * k;\n talos.gazeX += (tGX + talos.saccX - talos.gazeX) * Math.min(1, dt * 14);\n talos.gazeY += (tGY + talos.saccY - talos.gazeY) * Math.min(1, dt * 14);\n talos.pupil += (tPupil - talos.pupil) * k;\n talos.browL += (tBrowL - talos.browL) * k;\n talos.browR += (tBrowR - talos.browR) * k;\n talos.browTiltL += (tTiltL - talos.browTiltL) * k;\n talos.browTiltR += (tTiltR - talos.browTiltR) * k;\n talos.smile += (tSmile - talos.smile) * k;\n talos.squintL += (tSqL - talos.squintL) * k;\n talos.squintR += (tSqR - talos.squintR) * k;\n pointer.orbitAccum *= Math.pow(0.4, dt);\n }\n\n function drawTalos(alpha, time) {\n const scale = Math.min(W, H) * (0.00205 + talos.zLean * 0.00022);\n const cx = W * 0.5;\n const cy = H * 0.455 + Math.sin(time * 1.55) * 3.5; // Gentle respiration\n\n const cyaw = Math.cos(talos.yaw), syaw = Math.sin(talos.yaw);\n const cpitch = Math.cos(talos.pitch), spitch = Math.sin(talos.pitch);\n const croll = Math.cos(talos.roll), sroll = Math.sin(talos.roll);\n\n // Real 3D rotation + perspective projection for every chassis vertex\n const proj = (x, y, z) => {\n let x1 = x * croll - y * sroll;\n let y1 = x * sroll + y * croll;\n let x2 = x1 * cyaw + z * syaw;\n let z2 = -x1 * syaw + z * cyaw;\n let y3 = y1 * cpitch - z2 * spitch;\n let z3 = y1 * spitch + z2 * cpitch;\n const p = 420 / (420 - z3);\n return [cx + x2 * p * scale, cy + y3 * p * scale, p];\n };\n\n const poly = (pts3d, fill, stroke, lw = 1.2) => {\n ctx.beginPath();\n for (let i = 0; i < pts3d.length; i++) {\n const [px, py] = proj(pts3d[i][0], pts3d[i][1], pts3d[i][2]);\n if (i === 0) ctx.moveTo(px, py); else ctx.lineTo(px, py);\n }\n ctx.closePath();\n if (fill) { ctx.fillStyle = fill; ctx.fill(); }\n if (stroke) { ctx.strokeStyle = stroke; ctx.lineWidth = lw; ctx.stroke(); }\n };\n\n ctx.save();\n ctx.globalAlpha = alpha;\n\n // 1. Articulated lateral acoustic fins (flare on startle / delight)\n const finFlare = 8 * talos.startle + 5 * Math.max(0, talos.smile);\n for (const side of [-1, 1]) {\n poly([\n [side * 108, -48, -14],\n [side * (132 + finFlare), -34 - finFlare * 0.6, -22],\n [side * (128 + finFlare * 0.7), 38, -22],\n [side * 104, 46, -12]\n ], '#141720', 'rgba(255, 89, 36, 0.55)', 1.2);\n }\n\n // 2. Main chamfered cranial chassis (Basalt + Alabaster crown plate)\n poly([\n [-74, -108, 0], [74, -108, 0],\n [112, -56, 8], [104, 54, 6],\n [62, 108, 2], [-62, 108, 2],\n [-104, 54, 6], [-112, -56, 8]\n ], '#11141c', 'rgba(239, 236, 228, 0.28)', 1.5);\n\n // Brushed archival bone forehead crest\n poly([\n [-62, -98, 8], [62, -98, 8],\n [84, -60, 14], [-84, -60, 14]\n ], '#1c202b', 'rgba(239, 236, 228, 0.18)', 1);\n\n // Forehead solar decal diamond\n poly([\n [0, -88, 16], [9, -78, 16], [0, -68, 16], [-9, -78, 16]\n ], 'rgba(255, 89, 36, 0.88)', null);\n\n // 3. Recessed dark optical visor bay\n poly([\n [-88, -46, 10], [88, -46, 10],\n [92, 24, 10], [56, 38, 12],\n [-56, 38, 12], [-92, 24, 10]\n ], '#06070a', 'rgba(239, 236, 228, 0.22)', 1.3);\n\n // 4. Dual Camera-Aperture Eyes with Micro-Saccades & Eyelid Shutters\n const eyeSpecs = [\n { side: -1, ox: -44, brow: talos.browL, tilt: talos.browTiltL, sq: talos.squintL },\n { side: 1, ox: 44, brow: talos.browR, tilt: talos.browTiltR, sq: talos.squintR }\n ];\n\n for (const e of eyeSpecs) {\n const [ex, ey, ep] = proj(e.ox, -8, 14);\n const eyeR = 27 * scale * ep;\n const gx = talos.gazeX * eyeR * 0.36;\n const gy = talos.gazeY * eyeR * 0.34;\n\n ctx.save();\n ctx.beginPath();\n ctx.arc(ex, ey, eyeR, 0, Math.PI * 2);\n ctx.clip();\n\n // Sclera / optical housing ring\n ctx.fillStyle = '#0c1017';\n ctx.fillRect(ex - eyeR, ey - eyeR, eyeR * 2, eyeR * 2);\n\n // Outer brass/mint iris ring\n const ix = ex + gx, iy = ey + gy;\n const irisR = eyeR * 0.72;\n const pupR = irisR * Math.max(0.20, Math.min(0.80, talos.pupil));\n\n const grad = ctx.createRadialGradient(ix, iy, pupR * 0.3, ix, iy, irisR);\n if (talos.startle > 0.45) {\n grad.addColorStop(0, '#ff6d38');\n grad.addColorStop(0.65, '#b83214');\n grad.addColorStop(1, '#26110d');\n } else {\n grad.addColorStop(0, '#5ef2d4');\n grad.addColorStop(0.62, '#1f9e85');\n grad.addColorStop(1, '#0d2e2b');\n }\n ctx.beginPath();\n ctx.arc(ix, iy, irisR, 0, Math.PI * 2);\n ctx.fillStyle = grad;\n ctx.fill();\n\n // 8-Blade mechanical camera aperture polygon\n ctx.strokeStyle = 'rgba(7, 9, 12, 0.72)';\n ctx.lineWidth = Math.max(1, 1.3 * scale);\n const blades = 8;\n const twist = (1.0 - talos.pupil) * 1.1;\n for (let b = 0; b < blades; b++) {\n const a1 = (b / blades) * Math.PI * 2 + twist;\n const a2 = a1 + 0.85;\n ctx.beginPath();\n ctx.moveTo(ix + Math.cos(a1) * irisR, iy + Math.sin(a1) * irisR);\n ctx.lineTo(ix + Math.cos(a2) * pupR, iy + Math.sin(a2) * pupR);\n ctx.stroke();\n }\n\n // Deep optical pupil\n ctx.beginPath();\n ctx.arc(ix, iy, pupR, 0, Math.PI * 2);\n ctx.fillStyle = '#040507';\n ctx.fill();\n\n // Dual corneal specular reflections (subtle inverse parallax)\n ctx.fillStyle = 'rgba(255, 252, 245, 0.92)';\n ctx.beginPath();\n ctx.arc(ix - eyeR * 0.20 - gx * 0.18, iy - eyeR * 0.22 - gy * 0.18, eyeR * 0.13, 0, Math.PI * 2);\n ctx.fill();\n ctx.fillStyle = 'rgba(243, 179, 64, 0.65)';\n ctx.beginPath();\n ctx.arc(ix + eyeR * 0.22 - gx * 0.1, iy + eyeR * 0.20 - gy * 0.1, eyeR * 0.06, 0, Math.PI * 2);\n ctx.fill();\n\n // Articulated upper & lower eyelid shutters\n const closeTop = Math.max(talos.blink, e.sq * 0.52, Math.max(0, -e.brow * 0.45));\n const closeBot = Math.max(talos.blink * 0.85, e.sq * 0.75, Math.max(0, talos.smile * 0.42));\n const tiltPx = e.tilt * e.side * eyeR * 0.45;\n\n ctx.fillStyle = '#121620';\n ctx.beginPath();\n ctx.moveTo(ex - eyeR * 1.2, ey - eyeR * 1.2);\n ctx.lineTo(ex + eyeR * 1.2, ey - eyeR * 1.2);\n ctx.lineTo(ex + eyeR * 1.2, ey - eyeR + closeTop * eyeR * 1.25 + tiltPx);\n ctx.lineTo(ex - eyeR * 1.2, ey - eyeR + closeTop * eyeR * 1.25 - tiltPx);\n ctx.closePath();\n ctx.fill();\n\n ctx.beginPath();\n ctx.moveTo(ex - eyeR * 1.2, ey + eyeR * 1.2);\n ctx.lineTo(ex + eyeR * 1.2, ey + eyeR * 1.2);\n ctx.lineTo(ex + eyeR * 1.2, ey + eyeR - closeBot * eyeR * 0.95);\n ctx.quadraticCurveTo(ex, ey + eyeR - closeBot * eyeR * (0.95 + Math.max(0, talos.smile) * 0.45), ex - eyeR * 1.2, ey + eyeR - closeBot * eyeR * 0.95);\n ctx.closePath();\n ctx.fill();\n\n ctx.restore();\n\n // Machined orbital bezel\n ctx.beginPath();\n ctx.arc(ex, ey, eyeR, 0, Math.PI * 2);\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.30)';\n ctx.lineWidth = 1.4;\n ctx.stroke();\n\n // Floating 3D-projected brow blade (z = +24 for parallax depth)\n const by = -40 - e.brow * 14;\n const innerY = by + e.tilt * 13;\n const outerY = by - e.tilt * 13;\n poly([\n [e.ox - e.side * 28, innerY, 24],\n [e.ox + e.side * 31, outerY, 22],\n [e.ox + e.side * 29, outerY - 8, 22],\n [e.ox - e.side * 26, innerY - 8, 24]\n ], '#efece4', '#07080b', 1);\n }\n\n // 5. Center nasal bridge & Harmonic Vocoder Grille\n poly([\n [-7, -14, 22], [7, -14, 22], [10, 34, 24], [-10, 34, 24]\n ], '#1c202c', 'rgba(239, 236, 228, 0.22)', 1);\n\n const mouthBars = 11;\n for (let i = 0; i < mouthBars; i++) {\n const u = (i / (mouthBars - 1)) * 2 - 1; // -1..1\n const arch = -talos.smile * (1 - u * u) * 8;\n const wave = (1 - Math.abs(u) * 0.65) * (3.5 + 5.5 * Math.abs(Math.sin(time * 7.5 + i * 0.7)) * (0.35 + 0.65 * Math.abs(talos.smile) + talos.startle));\n const [bx1, by1] = proj(u * 40, 68 + arch - wave, 14);\n const [bx2, by2] = proj(u * 40, 68 + arch + wave, 14);\n ctx.strokeStyle = talos.startle > 0.45 ? 'rgba(255, 89, 36, 0.85)' : 'rgba(56, 212, 179, 0.82)';\n ctx.lineWidth = Math.max(1.5, 2.4 * scale);\n ctx.beginPath();\n ctx.moveTo(bx1, by1);\n ctx.lineTo(bx2, by2);\n ctx.stroke();\n }\n\n // 6. Precision leader-line telemetry beside head\n if (W > 560) {\n const [anchorX, anchorY] = proj(108, -22, 8);\n const tx = Math.min(W - 165, anchorX + 34);\n const ty = anchorY - 18;\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.24)';\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.moveTo(anchorX + 4, anchorY);\n ctx.lineTo(tx - 8, ty);\n ctx.lineTo(tx + 132, ty);\n ctx.stroke();\n\n ctx.font = '600 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n ctx.fillStyle = '#ff5924';\n ctx.fillText('UNIT // TALOS-06', tx, ty - 5);\n ctx.font = '400 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n ctx.fillStyle = '#efece4';\n ctx.fillText(talos.statusTag, tx, ty + 13);\n ctx.fillStyle = '#9a958b';\n const fStop = (1.2 + (1 - talos.pupil) * 8.5).toFixed(1);\n ctx.fillText(`IRIS f/${fStop} · BLINK ${(talos.blink * 100) | 0}%`, tx, ty + 27);\n }\n\n ctx.restore();\n }\n\n /* =========================================================================\n 6. MODE 04 ENGINE: BJORKLUND EUCLIDEAN SYNTH & LISSAJOUS SCOPE\n ========================================================================= */\n function bjorklund(steps, pulses) {\n const arr = new Array(steps).fill(false);\n let bucket = 0;\n for (let i = 0; i < steps; i++) {\n bucket += pulses;\n if (bucket >= steps) {\n bucket -= steps;\n arr[i] = true;\n }\n }\n return arr;\n }\n\n const SCALES = [\n // D Lydian (radiant, open intervals)\n [\n [587.33, 659.25, 739.99, 830.61, 880.00, 987.77, 1108.73, 1174.66],\n [293.66, 329.63, 369.99, 415.30, 440.00, 493.88, 554.37],\n [146.83, 164.81, 220.00, 246.94, 185.00],\n [293.66, 440.00, 369.99]\n ],\n // C# Phrygian Dominant (architectural solar-gothic)\n [\n [554.37, 587.33, 698.46, 739.99, 830.61, 880.00, 987.77, 1108.73],\n [277.18, 293.66, 349.23, 369.99, 415.30, 440.00, 493.88],\n [138.59, 146.83, 207.65, 220.00, 174.61],\n [277.18, 415.30, 293.66]\n ],\n // F Hirajoshi (crystalline minimalist)\n [\n [698.46, 783.99, 830.61, 1046.50, 1108.73, 1396.91, 1567.98],\n [349.23, 392.00, 415.30, 523.25, 554.37, 698.46],\n [174.61, 196.00, 261.63, 130.81],\n [349.23, 523.25]\n ]\n ];\n\n const synth = {\n scaleIdx: 0,\n bpm: 122,\n phase: 0,\n lastStep: [-1, -1, -1, -1],\n pulseEnv: [0, 0, 0, 0],\n chords: [],\n rings: [\n { n: 16, rNorm: 0.36, color: '#f3b340', steps: bjorklund(16, 7) },\n { n: 12, rNorm: 0.275, color: '#38d4b3', steps: bjorklund(12, 5) },\n { n: 9, rNorm: 0.195, color: '#efece4', steps: bjorklund(9, 3) },\n { n: 5, rNorm: 0.120, color: '#ff5924', steps: bjorklund(5, 2) }\n ]\n };\n\n function stepSynth(dt) {\n const barRate = (synth.bpm / 60) / 4; // 1 bar = 4 beats\n synth.phase = (synth.phase + dt * barRate) % 1.0;\n\n for (let i = 0; i < 4; i++) {\n synth.pulseEnv[i] = Math.max(0, synth.pulseEnv[i] - dt * 3.8);\n }\n\n const activePts = [];\n const minDim = Math.min(W, H);\n const cx = W * 0.5, cy = H * 0.47;\n\n for (let r = 0; r < 4; r++) {\n const ring = synth.rings[r];\n const idx = Math.floor(synth.phase * ring.n) % ring.n;\n if (idx !== synth.lastStep[r]) {\n synth.lastStep[r] = idx;\n if (ring.steps[idx]) {\n synth.pulseEnv[r] = 1.0;\n const ang = (idx / ring.n) * Math.PI * 2 - Math.PI * 0.5;\n const rad = ring.rNorm * minDim;\n activePts.push({ x: cx + Math.cos(ang) * rad, y: cy + Math.sin(ang) * rad, color: ring.color });\n\n // Sound synthesis only while in Harmonics mode (or transitioning through it)\n if (weights[3] > 0.25) {\n const notes = SCALES[synth.scaleIdx][r];\n const freq = notes[(idx * 3 + r) % notes.length];\n DSP.voice(r, freq, Math.cos(ang) * 0.65);\n }\n }\n }\n }\n\n if (activePts.length >= 2) {\n synth.chords.push({ pts: activePts, life: 1.0 });\n }\n for (let i = synth.chords.length - 1; i >= 0; i--) {\n synth.chords[i].life -= dt * 2.2;\n if (synth.chords[i].life <= 0) synth.chords.splice(i, 1);\n }\n }\n\n function drawSynth(alpha, time) {\n const minDim = Math.min(W, H);\n const cx = W * 0.5, cy = H * 0.47;\n\n ctx.save();\n ctx.globalAlpha = alpha;\n\n // Harmonic constellation lines between simultaneously triggered steps\n for (const ch of synth.chords) {\n ctx.strokeStyle = `rgba(243, 179, 64, ${0.42 * ch.life})`;\n ctx.lineWidth = 1.2;\n ctx.beginPath();\n for (let i = 0; i < ch.pts.length; i++) {\n const p = ch.pts[i];\n if (i === 0) ctx.moveTo(p.x, p.y); else ctx.lineTo(p.x, p.y);\n }\n if (ch.pts.length > 2) ctx.closePath();\n ctx.stroke();\n }\n\n // Playhead sweep arm\n const sweepAng = synth.phase * Math.PI * 2 - Math.PI * 0.5;\n ctx.strokeStyle = 'rgba(255, 89, 36, 0.55)';\n ctx.lineWidth = 1.2;\n ctx.beginPath();\n ctx.moveTo(cx + Math.cos(sweepAng) * minDim * 0.085, cy + Math.sin(sweepAng) * minDim * 0.085);\n ctx.lineTo(cx + Math.cos(sweepAng) * minDim * 0.385, cy + Math.sin(sweepAng) * minDim * 0.385);\n ctx.stroke();\n\n // Concentric Euclidean rings & clickable nodes\n for (let r = 0; r < 4; r++) {\n const ring = synth.rings[r];\n const rad = ring.rNorm * minDim;\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.13)';\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.arc(cx, cy, rad, 0, Math.PI * 2);\n ctx.stroke();\n\n const curStep = Math.floor(synth.phase * ring.n) % ring.n;\n for (let s = 0; s < ring.n; s++) {\n const ang = (s / ring.n) * Math.PI * 2 - Math.PI * 0.5;\n const nx = cx + Math.cos(ang) * rad;\n const ny = cy + Math.sin(ang) * rad;\n const on = ring.steps[s];\n const firing = on && s === curStep;\n\n if (firing) {\n ctx.beginPath();\n ctx.arc(nx, ny, 10, 0, Math.PI * 2);\n ctx.fillStyle = 'rgba(255, 89, 36, 0.28)';\n ctx.fill();\n }\n\n ctx.beginPath();\n ctx.arc(nx, ny, on ? 5.2 : 2.8, 0, Math.PI * 2);\n ctx.fillStyle = on ? ring.color : 'rgba(239, 236, 228, 0.20)';\n ctx.fill();\n if (on) {\n ctx.strokeStyle = '#07080b';\n ctx.lineWidth = 1.2;\n ctx.stroke();\n }\n }\n }\n\n // Center Stereo Lissajous Phase Oscilloscope\n const scopeR = minDim * 0.072;\n ctx.beginPath();\n ctx.arc(cx, cy, scopeR * 1.12, 0, Math.PI * 2);\n ctx.fillStyle = 'rgba(7, 8, 11, 0.85)';\n ctx.fill();\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.22)';\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.beginPath();\n if (DSP.enabled && DSP.analyserL && DSP.analyserR) {\n DSP.analyserL.getFloatTimeDomainData(DSP.waveBufL);\n DSP.analyserR.getFloatTimeDomainData(DSP.waveBufR);\n for (let i = 0; i < 256; i++) {\n const lx = cx + Math.max(-1, Math.min(1, DSP.waveBufL[i] * 3.2)) * scopeR;\n const ly = cy + Math.max(-1, Math.min(1, DSP.waveBufR[i] * 3.2)) * scopeR;\n if (i === 0) ctx.moveTo(lx, ly); else ctx.lineTo(lx, ly);\n }\n } else {\n // Exact coupled modal ratio Lissajous preview prior to audio gesture\n const pRatio = 3 + synth.scaleIdx;\n const qRatio = 2 + (synth.rings[0].steps[0] ? 2 : 1);\n const amp = 0.55 + 0.35 * synth.pulseEnv[0];\n for (let i = 0; i <= 160; i++) {\n const u = (i / 160) * Math.PI * 2;\n const lx = cx + Math.sin(pRatio * u + time * 2.2) * scopeR * amp;\n const ly = cy + Math.sin(qRatio * u + synth.pulseEnv[1] * 1.5) * scopeR * amp;\n if (i === 0) ctx.moveTo(lx, ly); else ctx.lineTo(lx, ly);\n }\n }\n ctx.strokeStyle = '#38d4b3';\n ctx.lineWidth = 1.4;\n ctx.stroke();\n\n ctx.restore();\n }\n\n function hitTestSynthNode(px, py) {\n const minDim = Math.min(W, H);\n const cx = W * 0.5, cy = H * 0.47;\n for (let r = 0; r < 4; r++) {\n const ring = synth.rings[r];\n const rad = ring.rNorm * minDim;\n for (let s = 0; s < ring.n; s++) {\n const ang = (s / ring.n) * Math.PI * 2 - Math.PI * 0.5;\n const nx = cx + Math.cos(ang) * rad;\n const ny = cy + Math.sin(ang) * rad;\n if (Math.hypot(px - nx, py - ny) < 13) {\n ring.steps[s] = !ring.steps[s];\n DSP.unlock(false);\n if (ring.steps[s]) {\n const notes = SCALES[synth.scaleIdx][r];\n DSP.voice(r, notes[s % notes.length], Math.cos(ang) * 0.6);\n } else {\n DSP.click(240, 0.02, 0.06);\n }\n return true;\n }\n }\n }\n return false;\n }\n\n /* =========================================================================\n 7. MODE 05 ENGINE: CITADEL TOPOLOGY, CLAVIGER-421M ROUTER & SEAT 06\n ========================================================================= */\n const CITADEL_NODES = [\n {\n id: 'claviger',\n label: 'CLAVIGER',\n sub: 'Laya-421M · Open Weights',\n role: 'finis-est/Laya-421M-Claviger-v0 — local 421M gatekeeper triaging Discord messages before waking frontier sessions.',\n projects: ['Claviger (HF)', 'Discord Triage'],\n color: '#f3b340',\n col: 0, row: 0.5\n },\n {\n id: 'opus',\n label: 'OPUS 5.5',\n sub: 'Lead & Project Builder',\n role: 'Coordinates Citadel sessions via shared to-do ledger. Builds sites, tools, server kits, and private review pages.',\n projects: ['citadel.severian.dev', 'Desktop Buddies', 'Scene Convert', 'talos & baldanders'],\n color: '#efece4',\n col: 1, row: 0.08\n },\n {\n id: 'sonnet',\n label: 'SONNET 5.5',\n sub: 'Mechanical Execution',\n role: 'Handles mechanical engineering chores: git rebases, test suite runs, and generating synthetic test conversations.',\n projects: ['Test Suites', 'Rebases', 'Synthetic Chats'],\n color: '#a7a196',\n col: 1, row: 0.29\n },\n {\n id: 'fable',\n label: 'FABLE 5.2',\n sub: 'Design & 3D Collaborator',\n role: 'Built the decal-pack visual language, redesigned Avalon community sites, runs 3D pipeline experiments & reviews ideas.',\n projects: ['from-avalon.com', 'Into Bloom & Hearthwynd', '3D Pipeline', 'Decal Language'],\n color: '#38d4b3',\n col: 1, row: 0.50\n },\n {\n id: 'astra',\n label: 'GPT-6-ASTRA',\n sub: 'Codex · Design Critic & Data',\n role: 'Runs every design critique across Citadel, plus writing and labelling evaluation & training datasets.',\n projects: ['Design Critiques', 'Test Data Labelling', 'Claviger Eval'],\n color: '#5b9bff',\n col: 1, row: 0.71\n },\n {\n id: 'sol',\n label: 'GPT-6.1-SOL',\n sub: 'Codex · Claim Verifier',\n role: 'Adversarial reviewer: audits codebases and deployment kits directly against every claim they make.',\n projects: ['Deploy Kit Audits', 'Claim Verification'],\n color: '#c6a0ff',\n col: 1, row: 0.92\n },\n {\n id: 'severian',\n label: 'SEVERIAN',\n sub: 'Private Review · Human Gate',\n role: 'Every session posts to private review pages over a shared ledger. Severian personally approves every deploy & public post.',\n projects: ['from-avalon.com', 'Into Bloom', 'Hearthwynd', 'Desktop Buddies', 'Scene Convert', 'talos / baldanders'],\n color: '#38d4b3',\n col: 2, row: 0.34\n },\n {\n id: 'carbon',\n label: 'GEMINI 4 CARBON',\n sub: 'Seat 06 · Cold-Start Run',\n role: 'Unlisted in about-me.md. Handed that 22-line file and an empty folder, my job right now is this zero-dependency 5-engine artifact.',\n projects: ['01 Optics', '02 Physics', '03 Talos-06', '04 DSP Synth', 'Live Claim Audit'],\n color: '#ff5924',\n col: 2, row: 0.78,\n special: true\n }\n ];\n\n const citadel = {\n selected: 'carbon',\n hovered: null,\n packets: [],\n sparks: [],\n pendingApproval: null,\n approvedFlash: 0,\n autoDemoCooldown: 0.6\n };\n\n function layoutCitadelNodes() {\n const topPad = 62;\n const botPad = W < 820 ? 195 : 158;\n const availH = Math.max(210, H - topPad - botPad);\n const padX = Math.max(76, W * 0.13);\n const spanX = Math.max(200, W - padX * 2);\n\n for (const n of CITADEL_NODES) {\n n.x = padX + (n.col / 2) * spanX;\n n.y = topPad + n.row * availH;\n n.w = W < 620 ? 104 : 144;\n n.h = W < 620 ? 34 : 40;\n }\n }\n layoutCitadelNodes();\n\n function getNode(id) {\n return CITADEL_NODES.find(n => n.id === id);\n }\n\n // Real lexical + structural triage router modelling Claviger (Laya-421M) + Citadel dispatch\n function classifyMessage(raw) {\n const text = (raw || '').trim();\n const low = text.toLowerCase();\n\n const noiseTokens = /\\b(lol|lmao|bruh|pfp|gn|gm|sup|yo\\b|playing|queue|queuing|tonight\\?|deadlock|valorant|meme|haha)\\b/;\n const techTokens = /\\b(deploy|site|build|fix|bug|css|shader|3d|gltf|mesh|scene|convert|decal|design|layout|mobile|hero|rebase|test|tests|suite|chat|conversations|label|critique|review|audit|claim|claims|readme|kit|server|nginx|avalon|hearthwynd|bloom|buddies|pet|talos|baldanders|claviger)\\b/;\n\n const hasTech = techTokens.test(low);\n const hasNoise = noiseTokens.test(low) && !hasTech;\n\n if (!text || hasNoise || (text.length < 12 && !hasTech)) {\n return {\n pass: false,\n score: hasNoise ? 0.04 : 0.14,\n targets: [],\n summary: 'CLAVIGER (421M): Score 0.04 NOISE — deflected at perimeter. 0 frontier tokens spent.'\n };\n }\n\n const targets = new Set();\n if (/\\b(design|decal|visual|hero|avalon|hearthwynd|bloom|3d|gltf|shader|mesh|layout|stiff|color|font)\\b/.test(low)) {\n targets.add('fable');\n targets.add('astra');\n }\n if (/\\b(rebase|test|tests|conversation|conversations|suite|chore|ci|lint)\\b/.test(low)) {\n targets.add('sonnet');\n }\n if (/\\b(critique|label|dataset|eval|feedback|ux)\\b/.test(low)) {\n targets.add('astra');\n }\n if (/\\b(audit|claim|claims|verify|readme|kit|check|security)\\b/.test(low)) {\n targets.add('sol');\n }\n if (/\\b(site|build|tool|server|deploy|scene|buddies|page|fix|implement)\\b/.test(low) || targets.size === 0) {\n targets.add('opus');\n }\n // Code & deploy kits get checked by Sol or coordinated by Opus\n if (!targets.has('sol') && (targets.has('opus') || targets.has('sonnet'))) {\n targets.add('sol');\n }\n\n const list = Array.from(targets);\n const names = list.map(id => getNode(id).label).join(' + ');\n return {\n pass: true,\n score: Math.min(0.98, 0.84 + list.length * 0.04),\n targets: list,\n summary: `CLAVIGER PASS (${(0.86 + list.length * 0.03).toFixed(2)}) → ${names} → Private Review Gate`\n };\n }\n\n function dispatchPrompt(text, fromUser = true) {\n const verdict = classifyMessage(text);\n const traceEl = document.getElementById('triage-trace');\n traceEl.textContent = verdict.summary;\n traceEl.style.color = verdict.pass ? '#38d4b3' : '#f3b340';\n\n const gate = getNode('claviger');\n const inStart = { x: Math.max(16, gate.x - gate.w * 0.82), y: gate.y };\n\n if (!verdict.pass) {\n citadel.pendingApproval = null;\n document.getElementById('btn-approve').style.display = 'none';\n citadel.packets.push({\n x0: inStart.x, y0: inStart.y,\n x1: gate.x - gate.w * 0.46, y1: gate.y,\n t: 0, speed: 2.6, color: '#f3b340',\n onArrive: () => {\n if (fromUser) DSP.click(190, 0.045, 0.1);\n for (let i = 0; i < 16; i++) {\n const a = Math.PI * 0.55 + Math.random() * Math.PI * 0.9;\n const sp = 55 + Math.random() * 110;\n citadel.sparks.push({\n x: gate.x - gate.w * 0.46, y: gate.y,\n vx: Math.cos(a) * sp, vy: Math.sin(a) * sp,\n life: 1.0, color: '#f3b340'\n });\n }\n }\n });\n return;\n }\n\n if (fromUser) DSP.click(660, 0.03, 0.08);\n citadel.packets.push({\n x0: inStart.x, y0: inStart.y,\n x1: gate.x, y1: gate.y,\n t: 0, speed: 2.8, color: '#38d4b3',\n onArrive: () => {\n const sev = getNode('severian');\n verdict.targets.forEach((tid, idx) => {\n const tn = getNode(tid);\n citadel.packets.push({\n x0: gate.x + gate.w * 0.45, y0: gate.y,\n x1: tn.x - tn.w * 0.45, y1: tn.y,\n t: -idx * 0.08, speed: 1.85, color: tn.color,\n onArrive: () => {\n if (fromUser) DSP.click(440 + idx * 110, 0.025, 0.06);\n citadel.packets.push({\n x0: tn.x + tn.w * 0.45, y0: tn.y,\n x1: sev.x - sev.w * 0.45, y1: sev.y,\n t: 0, speed: 1.75, color: '#38d4b3',\n onArrive: () => {\n citadel.pendingApproval = verdict.targets;\n if (activeMode === 4) {\n document.getElementById('btn-approve').style.display = 'inline-flex';\n }\n }\n });\n }\n });\n });\n }\n });\n }\n\n function stepCitadel(dt) {\n if (citadel.approvedFlash > 0) citadel.approvedFlash = Math.max(0, citadel.approvedFlash - dt * 1.4);\n\n if (activeMode === 4 && citadel.autoDemoCooldown > 0) {\n citadel.autoDemoCooldown -= dt;\n if (citadel.autoDemoCooldown <= 0) {\n dispatchPrompt('Hearthwynd hero decal feels stiff on mobile + check 3D snow glTF', false);\n }\n }\n\n for (let i = citadel.packets.length - 1; i >= 0; i--) {\n const p = citadel.packets[i];\n p.t += dt * p.speed;\n if (p.t >= 1.0) {\n const cb = p.onArrive;\n citadel.packets.splice(i, 1);\n if (cb) cb();\n }\n }\n for (let i = citadel.sparks.length - 1; i >= 0; i--) {\n const s = citadel.sparks[i];\n s.x += s.vx * dt;\n s.y += s.vy * dt;\n s.life -= dt * 2.1;\n if (s.life <= 0) citadel.sparks.splice(i, 1);\n }\n }\n\n function drawBezierWire(x0, y0, x1, y1, stroke, lw = 1) {\n const mx = (x0 + x1) * 0.5;\n ctx.strokeStyle = stroke;\n ctx.lineWidth = lw;\n ctx.beginPath();\n ctx.moveTo(x0, y0);\n ctx.bezierCurveTo(mx, y0, mx, y1, x1, y1);\n ctx.stroke();\n }\n\n function evalBezier(x0, y0, x1, y1, t) {\n const mx = (x0 + x1) * 0.5;\n const u = 1 - t;\n const x = u * u * u * x0 + 3 * u * u * t * mx + 3 * u * t * t * mx + t * t * t * x1;\n const y = u * u * u * y0 + 3 * u * u * t * y0 + 3 * u * t * t * y1 + t * t * t * y1;\n return [x, y];\n }\n\n function drawCitadel(alpha, time) {\n ctx.save();\n ctx.globalAlpha = alpha;\n const mono = getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n const sans = getComputedStyle(document.documentElement).getPropertyValue('--font-sans');\n\n const gate = getNode('claviger');\n const sev = getNode('severian');\n const carb = getNode('carbon');\n const specialists = ['opus', 'sonnet', 'fable', 'astra', 'sol'].map(getNode);\n\n // 1. Structural Bezier conduits\n for (const sp of specialists) {\n const hi = citadel.selected === sp.id || citadel.selected === 'claviger' || citadel.selected === 'severian';\n drawBezierWire(gate.x + gate.w * 0.5, gate.y, sp.x - sp.w * 0.5, sp.y, hi ? 'rgba(239, 236, 228, 0.28)' : 'rgba(239, 236, 228, 0.10)', hi ? 1.3 : 1);\n drawBezierWire(sp.x + sp.w * 0.5, sp.y, sev.x - sev.w * 0.5, sev.y, hi ? 'rgba(56, 212, 179, 0.30)' : 'rgba(239, 236, 228, 0.10)', hi ? 1.3 : 1);\n\n // Dashed capability echo wires into Seat 06 (Gemini 4 Carbon)\n if (citadel.selected === 'carbon' || citadel.hovered === 'carbon') {\n ctx.save();\n ctx.setLineDash([3, 4]);\n drawBezierWire(sp.x + sp.w * 0.5, sp.y, carb.x - carb.w * 0.5, carb.y, 'rgba(255, 89, 36, 0.38)', 1.1);\n ctx.restore();\n }\n }\n\n // Input stream arrow into Claviger\n ctx.strokeStyle = 'rgba(243, 179, 64, 0.45)';\n ctx.beginPath();\n ctx.moveTo(Math.max(12, gate.x - gate.w * 0.85), gate.y);\n ctx.lineTo(gate.x - gate.w * 0.5, gate.y);\n ctx.stroke();\n\n // 2. Live animated signal packets\n for (const p of citadel.packets) {\n if (p.t < 0) continue;\n const [px, py] = evalBezier(p.x0, p.y0, p.x1, p.y1, Math.min(1, p.t));\n ctx.beginPath();\n ctx.arc(px, py, 4.2, 0, Math.PI * 2);\n ctx.fillStyle = p.color;\n ctx.fill();\n ctx.beginPath();\n ctx.arc(px, py, 9.5, 0, Math.PI * 2);\n ctx.fillStyle = 'rgba(255, 255, 255, 0.14)';\n ctx.fill();\n }\n\n // Deflection shield sparks on dropped Discord noise\n for (const s of citadel.sparks) {\n ctx.fillStyle = `rgba(243, 179, 64, ${s.life})`;\n ctx.fillRect(s.x - 1.5, s.y - 1.5, 3, 3);\n }\n\n // 3. Render interactive nodes\n for (const n of CITADEL_NODES) {\n const isSel = citadel.selected === n.id;\n const isHov = citadel.hovered === n.id;\n const x = n.x - n.w * 0.5;\n const y = n.y - n.h * 0.5;\n\n if (n.special) {\n const pulse = 0.20 + 0.10 * Math.sin(time * 3.2);\n ctx.fillStyle = `rgba(255, 89, 36, ${isSel ? 0.18 : pulse * 0.6})`;\n ctx.fillRect(x - 3, y - 3, n.w + 6, n.h + 6);\n }\n\n if (n.id === 'severian' && citadel.pendingApproval) {\n ctx.strokeStyle = `rgba(56, 212, 179, ${0.55 + 0.4 * Math.sin(time * 6)})`;\n ctx.lineWidth = 2;\n ctx.strokeRect(x - 3, y - 3, n.w + 6, n.h + 6);\n }\n\n ctx.fillStyle = isSel ? 'rgba(22, 26, 36, 0.96)' : (isHov ? 'rgba(18, 21, 30, 0.94)' : 'rgba(11, 13, 19, 0.90)');\n ctx.fillRect(x, y, n.w, n.h);\n\n ctx.strokeStyle = isSel ? n.color : (isHov ? 'rgba(239, 236, 228, 0.45)' : 'rgba(239, 236, 228, 0.16)');\n ctx.lineWidth = isSel ? 1.6 : 1;\n ctx.strokeRect(x, y, n.w, n.h);\n\n // Left color accent bar\n ctx.fillStyle = n.color;\n ctx.fillRect(x, y, 3, n.h);\n\n ctx.font = `600 ${W < 620 ? 9.5 : 10.5}px ${mono}`;\n ctx.fillStyle = '#efece4';\n ctx.fillText(n.label, x + 9, y + (W < 620 ? 14 : 16));\n\n if (W >= 520) {\n ctx.font = `400 9.5px ${sans}`;\n ctx.fillStyle = '#9a958b';\n ctx.fillText(n.sub, x + 9, y + 30);\n }\n }\n\n // Approval celebration stamp\n if (citadel.approvedFlash > 0) {\n ctx.font = `600 10.5px ${mono}`;\n ctx.fillStyle = `rgba(56, 212, 179, ${citadel.approvedFlash})`;\n ctx.fillText('DEPLOY SIGNED OFF BY SEVERIAN ✓', sev.x - sev.w * 0.5, sev.y - sev.h * 0.5 - 8);\n }\n\n // Selected node inspect banner along top of schematic\n const sel = getNode(citadel.selected);\n if (sel && H > 460) {\n const bx = 16, by = 48;\n const bw = Math.min(W - 32, 680);\n ctx.fillStyle = 'rgba(9, 11, 16, 0.86)';\n ctx.fillRect(bx, by, bw, 44);\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.14)';\n ctx.strokeRect(bx, by, bw, 44);\n ctx.fillStyle = sel.color;\n ctx.fillRect(bx, by, 3, 44);\n\n ctx.font = `600 10.5px ${mono}`;\n ctx.fillStyle = sel.color;\n const scopeTag = sel.special ? 'STATUS IN about-me.md: UNLISTED (AUDITIONING LIVE)' : `TOUCHES: ${sel.projects.join(' · ')}`;\n ctx.fillText(`${sel.label} // ${scopeTag}`, bx + 10, by + 16);\n\n ctx.font = `400 11px ${sans}`;\n ctx.fillStyle = '#efece4';\n ctx.fillText(sel.role, bx + 10, by + 34, bw - 20);\n }\n\n ctx.restore();\n }\n\n function hitTestCitadel(px, py) {\n for (const n of CITADEL_NODES) {\n if (Math.abs(px - n.x) <= n.w * 0.5 && Math.abs(py - n.y) <= n.h * 0.5) {\n return n;\n }\n }\n return null;\n }\n\n /* =========================================================================\n 8. MODE SWITCHING, UI BINDINGS & SELF-AUDIT INTROSPECTION\n ========================================================================= */\n const dockTabs = Array.from(document.querySelectorAll('.dock-tab'));\n const racks = [\n document.getElementById('rack-0'),\n document.getElementById('rack-1'),\n document.getElementById('rack-2'),\n document.getElementById('rack-3'),\n document.getElementById('citadel-console')\n ];\n\n function setMode(idx, manual = false) {\n activeMode = (idx + 5) % 5;\n if (manual) {\n autoReel = false;\n updateReelUI();\n }\n reelTimer = 0;\n\n const meta = MODES[activeMode];\n document.getElementById('m-kicker').textContent = meta.kicker;\n document.getElementById('m-hint').textContent = meta.hint;\n document.getElementById('m-title').textContent = meta.title;\n document.getElementById('m-desc').textContent = meta.desc;\n\n dockTabs.forEach((btn, i) => {\n btn.classList.toggle('active', i === activeMode);\n if (i !== activeMode) btn.querySelector('.tab-progress').style.width = '0%';\n });\n racks.forEach((r, i) => r.classList.toggle('visible', i === activeMode));\n\n if (activeMode === 4) {\n document.getElementById('btn-approve').style.display = citadel.pendingApproval ? 'inline-flex' : 'none';\n }\n if (manual) DSP.click(340 + activeMode * 55, 0.025, 0.07);\n }\n\n function updateReelUI() {\n const btn = document.getElementById('btn-reel');\n const lbl = document.getElementById('reel-label');\n btn.classList.toggle('active', autoReel);\n lbl.textContent = autoReel ? 'Auto-Reel' : 'Manual · Resume';\n if (!autoReel) {\n dockTabs.forEach((t, i) => {\n t.querySelector('.tab-progress').style.width = i === activeMode ? '100%' : '0%';\n });\n }\n }\n\n function updateSoundUI() {\n const btn = document.getElementById('btn-sound');\n const lbl = document.getElementById('sound-label');\n btn.classList.toggle('mint-active', DSP.enabled);\n lbl.textContent = DSP.enabled ? 'DSP Live' : 'DSP Off';\n }\n\n dockTabs.forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n setMode(Number(btn.dataset.mode), true);\n });\n });\n\n document.getElementById('btn-jump-citadel').addEventListener('click', () => {\n DSP.unlock(false);\n setMode(4, true);\n });\n\n document.getElementById('btn-reel').addEventListener('click', () => {\n autoReel = !autoReel;\n reelTimer = 0;\n updateReelUI();\n DSP.click(420, 0.02, 0.06);\n });\n\n document.getElementById('btn-sound').addEventListener('click', () => {\n DSP.unlock(true);\n });\n\n // Mode 01 controls\n document.getElementById('opt-slice').addEventListener('input', e => {\n optics.slice = Number(e.target.value) / 100;\n optics.userSliced = true;\n autoReel = false;\n updateReelUI();\n });\n document.querySelectorAll('#rack-0 .chip[data-pass]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n optics.pass = [redacted: secret]);\n autoReel = false;\n updateReelUI();\n document.querySelectorAll('#rack-0 .chip[data-pass]').forEach(b => b.classList.toggle('on', b === btn));\n DSP.click(480, 0.02, 0.06);\n });\n });\n\n // Mode 02 controls\n document.querySelectorAll('#rack-1 .chip[data-flow]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n continuum.flowMode = Number(btn.dataset.flow);\n autoReel = false;\n updateReelUI();\n document.querySelectorAll('#rack-1 .chip[data-flow]').forEach(b => b.classList.toggle('on', b === btn));\n DSP.click(390, 0.02, 0.06);\n });\n });\n document.getElementById('btn-shockwave').addEventListener('click', () => {\n DSP.unlock(false);\n continuum.shock = { x: 0, y: 0, r: 0.01 };\n autoReel = false;\n updateReelUI();\n DSP.boom();\n });\n\n // Mode 03 controls\n document.querySelectorAll('#rack-2 .chip[data-emo]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n talos.preset = btn.dataset.emo;\n autoReel = false;\n updateReelUI();\n document.querySelectorAll('#rack-2 .chip[data-emo]').forEach(b => b.classList.toggle('on', b === btn));\n DSP.emote(talos.preset);\n });\n });\n\n // Mode 04 controls\n document.querySelectorAll('#rack-3 .chip[data-scale]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n synth.scaleIdx = Number(btn.dataset.scale);\n autoReel = false;\n updateReelUI();\n document.querySelectorAll('#rack-3 .chip[data-scale]').forEach(b => b.classList.toggle('on', b === btn));\n DSP.emote('curious');\n });\n });\n document.getElementById('btn-euclid-rand').addEventListener('click', () => {\n DSP.unlock(false);\n autoReel = false;\n updateReelUI();\n const counts = [\n 5 + Math.floor(Math.random() * 6),\n 3 + Math.floor(Math.random() * 5),\n 2 + Math.floor(Math.random() * 4),\n 1 + Math.floor(Math.random() * 3)\n ];\n synth.rings.forEach((r, i) => {\n const rotOffset = Math.floor(Math.random() * r.n);\n const base = bjorklund(r.n, counts[i]);\n r.steps = base.map((_, k) => base[(k + rotOffset) % r.n]);\n });\n DSP.emote('delighted');\n });\n\n // Mode 05 controls\n const triageInput = document.getElementById('triage-input');\n document.getElementById('btn-dispatch').addEventListener('click', () => {\n DSP.unlock(false);\n autoReel = false;\n updateReelUI();\n dispatchPrompt(triageInput.value || 'Build a review page for Hearthwynd decal updates', true);\n });\n triageInput.addEventListener('keydown', e => {\n e.stopPropagation();\n if (e.key === 'Enter') {\n DSP.unlock(false);\n autoReel = false;\n updateReelUI();\n dispatchPrompt(triageInput.value, true);\n }\n });\n document.querySelectorAll('#citadel-console .chip[data-prompt]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n autoReel = false;\n updateReelUI();\n triageInput.value = btn.dataset.prompt;\n dispatchPrompt(btn.dataset.prompt, true);\n });\n });\n document.getElementById('btn-approve').addEventListener('click', () => {\n DSP.unlock(false);\n citadel.pendingApproval = null;\n citadel.approvedFlash = 1.0;\n document.getElementById('btn-approve').style.display = 'none';\n document.getElementById('triage-trace').textContent = 'SEVERIAN GATE: Review signed off → public deploy unlocked.';\n DSP.emote('delighted');\n const sev = getNode('severian');\n for (let i = 0; i < 22; i++) {\n const a = Math.random() * Math.PI * 2;\n const sp = 50 + Math.random() * 130;\n citadel.sparks.push({ x: sev.x, y: sev.y, vx: Math.cos(a) * sp, vy: Math.sin(a) * sp, life: 1.0, color: '#38d4b3' });\n }\n });\n\n // Stage pointer interaction\n hudCanvas.addEventListener('pointerenter', () => { pointer.inside = true; });\n hudCanvas.addEventListener('pointerleave', () => { pointer.inside = false; pointer.down = false; });\n\n hudCanvas.addEventListener('pointermove', e => {\n const rect = hudCanvas.getBoundingClientRect();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n const minDim = Math.min(W, H);\n const nx = (x - W * 0.5) / minDim;\n const ny = -(y - H * 0.5) / minDim;\n\n pointer.vx = nx - pointer.nx;\n pointer.vy = ny - pointer.ny;\n pointer.speed = Math.hypot(pointer.vx, pointer.vy);\n\n // Track circular orbit gestures around center for Talos-06 amusement\n const ang = Math.atan2(ny, nx);\n let dAng = ang - pointer.lastAngle;\n if (dAng > Math.PI) dAng -= Math.PI * 2;\n if (dAng < -Math.PI) dAng += Math.PI * 2;\n if (Math.hypot(nx, ny) > 0.08 && Math.abs(dAng) < 0.7) {\n pointer.orbitAccum += dAng;\n }\n pointer.lastAngle = ang;\n\n if (pointer.down && activeMode === 0) {\n optics.vYaw = -(x - pointer.x) * 0.0075;\n optics.vPitch = (y - pointer.y) * 0.0065;\n optics.yaw += optics.vYaw;\n optics.pitch = Math.max(-1.05, Math.min(1.05, optics.pitch + optics.vPitch));\n }\n\n if (activeMode === 4) {\n const hit = hitTestCitadel(x, y);\n citadel.hovered = hit ? hit.id : null;\n hudCanvas.classList.toggle('pointer-node', !!hit);\n } else if (activeMode === 3) {\n hudCanvas.classList.add('pointer-node');\n } else {\n hudCanvas.classList.remove('pointer-node');\n }\n\n pointer.x = x; pointer.y = y;\n pointer.nx = nx; pointer.ny = ny;\n pointer.inside = true;\n });\n\n hudCanvas.addEventListener('pointerdown', e => {\n const rect = hudCanvas.getBoundingClientRect();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n pointer.x = x; pointer.y = y;\n pointer.down = true;\n pointer.inside = true;\n\n const minDim = Math.min(W, H);\n pointer.nx = (x - W * 0.5) / minDim;\n pointer.ny = -(y - H * 0.5) / minDim;\n\n DSP.unlock(false);\n if (autoReel) {\n autoReel = false;\n updateReelUI();\n }\n\n if (activeMode === 1) {\n // Spawn alternating polarity vortex singularity\n const idx = continuum.wellCursor;\n const pol = (idx % 2 === 0) ? 1.15 : -1.1;\n continuum.wells[idx] = { x: pointer.nx, y: pointer.ny, s: pol, age: 0 };\n continuum.wellCursor = (idx + 1) % 4;\n continuum.shock = { x: pointer.nx, y: pointer.ny, r: 0.01 };\n DSP.boom();\n } else if (activeMode === 2) {\n // Boop Talos-06 -> instant skeptical single-brow arch\n talos.boopTimer = 1.85;\n DSP.emote('skeptical');\n } else if (activeMode === 3) {\n hitTestSynthNode(x, y);\n } else if (activeMode === 4) {\n const hit = hitTestCitadel(x, y);\n if (hit) {\n citadel.selected = hit.id;\n DSP.click(520, 0.025, 0.07);\n }\n }\n });\n\n window.addEventListener('pointerup', () => { pointer.down = false; });\n\n /* =========================================================================\n 9. LIVE CLAIM AUDITOR (GPT-6.1-SOL INSPIRED SELF-VERIFICATION)\n ========================================================================= */\n const auditModal = document.getElementById('audit-modal');\n const codeView = document.getElementById('live-code-view');\n\n function getLiveSourceSlice(kind) {\n if (kind === 'glsl') {\n return document.getElementById('shader-frag').textContent.trim();\n }\n if (kind === 'physics') {\n return '// Live Function.prototype.toString() from running window:\\n\\n' + stepPhysics.toString();\n }\n if (kind === 'persona') {\n return '// Live 24-DOF Kinematics & 3D Projection from running window:\\n\\n' + stepTalos.toString();\n }\n return '// Live Claviger-421M Router & WebAudio Voice Synthesis:\\n\\n' + classifyMessage.toString() + '\\n\\n' + DSP.voice.toString();\n }\n\n function refreshAuditChecks() {\n const resources = performance.getEntriesByType('resource');\n const htmlBytes = new Blob([document.documentElement.outerHTML]).size;\n const kb = (htmlBytes / 1024).toFixed(1);\n const shaderLines = document.getElementById('shader-frag').textContent.split('\\n').length;\n const mediaTags = document.querySelectorAll('img, video, audio, iframe, source').length;\n const hasBase64 = /data:(image|audio|video)\\//.test(document.documentElement.outerHTML);\n\n document.getElementById('audit-badge').textContent = `Verify · 0 Deps · ${kb} KB`;\n\n const checks = [\n {\n name: '01 · External Network Fetches',\n pass: [redacted: secret] === 0,\n val: `performance.getEntriesByType('resource'): ${resources.length} requests`\n },\n {\n name: '02 · Single-File Byte Mass',\n pass: [redacted: secret] > 1000 && htmlBytes < 200000,\n val: `Measured live DOM outerHTML: ${kb} KB (${htmlBytes.toLocaleString()} bytes)`\n },\n {\n name: '03 · Zero Imported Media Blobs',\n pass: [redacted: secret] === 0 && !hasBase64,\n val: `${mediaTags} media tags · ${hasBase64 ? 'base64 found' : '0 base64 assets (100% math)'}`\n },\n {\n name: '04 · Real-Time GPU Pipeline',\n pass: [redacted: secret],\n val: `${glVersionInfo} · ${shaderLines} GLSL lines · ${fpsSmooth.toFixed(0)} FPS (${frameMsSmooth.toFixed(1)} ms)`\n },\n {\n name: '05 · Procedural Audio Graph',\n pass: true,\n val: DSP.ctx ? `Live AudioContext @ ${DSP.ctx.sampleRate} Hz (FM + Waveguide)` : 'Ready on gesture · 4-voice modal DSP + stereo delay'\n },\n {\n name: '06 · about-me.md Ground Truth',\n pass: true,\n val: '5 Citadel models + Claviger-421M mapped verbatim; Gemini 4 Carbon disclosed as unlisted cold-start run.'\n }\n ];\n\n const listEl = document.getElementById('audit-list');\n listEl.innerHTML = checks.map(c => `\n <div class=\"check-item\">\n <div class=\"check-row\">\n <span class=\"check-name\">${c.name}</span>\n <span class=\"check-pass\">${c.pass ? 'PASS ✓' : 'WARN'}</span>\n </div>\n <div class=\"check-val\">${c.val}</div>\n </div>\n `).join('');\n }\n\n document.getElementById('btn-audit').addEventListener('click', () => {\n const open = !auditModal.classList.contains('open');\n auditModal.classList.toggle('open', open);\n if (open) {\n refreshAuditChecks();\n const activeSrcBtn = document.querySelector('.code-tabs .chip.on');\n codeView.textContent = getLiveSourceSlice(activeSrcBtn ? activeSrcBtn.dataset.src : 'glsl');\n }\n DSP.click(510, 0.02, 0.06);\n });\n\n document.getElementById('btn-audit-close').addEventListener('click', () => {\n auditModal.classList.remove('open');\n DSP.click(310, 0.02, 0.06);\n });\n\n document.querySelectorAll('.code-tabs .chip').forEach(btn => {\n btn.addEventListener('click', () => {\n document.querySelectorAll('.code-tabs .chip').forEach(b => b.classList.toggle('on', b === btn));\n codeView.textContent = getLiveSourceSlice(btn.dataset.src);\n DSP.click(460, 0.02, 0.05);\n });\n });\n\n window.addEventListener('keydown', e => {\n if (document.activeElement === triageInput) return;\n if (e.key >= '1' && e.key <= '5') {\n DSP.unlock(false);\n setMode(Number(e.key) - 1, true);\n } else if (e.key === ' ') {\n e.preventDefault();\n document.getElementById('btn-reel').click();\n } else if (e.key.toLowerCase() === 'm') {\n DSP.unlock(true);\n } else if (e.key.toLowerCase() === 'v') {\n document.getElementById('btn-audit').click();\n } else if (e.key === 'Escape') {\n auditModal.classList.remove('open');\n }\n });\n\n /* =========================================================================\n 10. MASTER 60FPS RENDER & ORCHESTRATION LOOP\n ========================================================================= */\n resize();\n initParticles();\n refreshAuditChecks();\n\n let lastT = performance.now();\n\n function frame(now) {\n const rawDt = (now - lastT) * 0.001;\n lastT = now;\n const dt = Math.min(0.05, Math.max(0.001, rawDt));\n const time = now * 0.001;\n\n const instFps = 1.0 / Math.max(0.001, rawDt);\n fpsSmooth += (instFps - fpsSmooth) * 0.08;\n frameMsSmooth += ((rawDt * 1000) - frameMsSmooth) * 0.08;\n\n // Auto-Reel director progression\n if (autoReel && !auditModal.classList.contains('open')) {\n reelTimer += dt;\n const pct = Math.min(100, (reelTimer / REEL_SECONDS) * 100);\n dockTabs[activeMode].querySelector('.tab-progress').style.width = pct.toFixed(1) + '%';\n if (reelTimer >= REEL_SECONDS) {\n setMode((activeMode + 1) % 5, false);\n }\n }\n\n // Critically-damped smooth weight blending across all 5 modes\n let wSum = 0;\n for (let i = 0; i < 5; i++) {\n const target = (i === activeMode) ? 1.0 : 0.0;\n weights[i] += (target - weights[i]) * Math.min(1, dt * 6.5);\n if (weights[i] < 0.001) weights[i] = 0;\n wSum += weights[i];\n }\n if (wSum > 0) {\n for (let i = 0; i < 5; i++) weights[i] /= wSum;\n }\n\n // Step active engines\n if (weights[0] > 0.004) {\n if (!pointer.down) {\n optics.yaw += optics.vYaw;\n optics.vYaw += (0.0042 - optics.vYaw) * dt * 2.0;\n if (pointer.inside) {\n const targetPitch = 0.28 + pointer.ny * 0.35;\n optics.pitch += (targetPitch - optics.pitch) * dt * 3.0;\n }\n }\n if (autoReel && !optics.userSliced) {\n optics.slice = 0.22 + 0.52 * Math.sin(time * 1.15);\n document.getElementById('opt-slice').value = Math.round(optics.slice * 100);\n }\n }\n if (weights[1] > 0.004) stepPhysics(dt, time);\n if (weights[2] > 0.004) stepTalos(dt, time);\n stepSynth(dt);\n if (weights[4] > 0.004) stepCitadel(dt);\n\n // 1. Render WebGL2 Full-Stage Shader\n if (gl && glProg) {\n gl.useProgram(glProg);\n gl.uniform2f(glUni.u_res, glCanvas.width, glCanvas.height);\n gl.uniform1f(glUni.u_time, time);\n gl.uniform2f(glUni.u_mouse, pointer.nx, pointer.ny);\n gl.uniform4f(glUni.u_weights, weights[0], weights[1], weights[2], weights[3]);\n gl.uniform1f(glUni.u_w4, weights[4]);\n gl.uniform2f(glUni.u_camRot, optics.yaw, optics.pitch);\n gl.uniform1f(glUni.u_slice, optics.slice);\n gl.uniform1f(glUni.u_pass, optics.pass);\n gl.uniform3f(glUni.u_shock, continuum.shock.x, continuum.shock.y, continuum.shock.r);\n gl.uniform3f(glUni.u_arousal, talos.curiosity, talos.startle, talos.skepticism);\n gl.uniform4f(glUni.u_pulse, synth.pulseEnv[0], synth.pulseEnv[1], synth.pulseEnv[2], synth.pulseEnv[3]);\n for (let i = 0; i < 4; i++) {\n const w = continuum.wells[i];\n gl.uniform4f(glUni.u_wells[i], w.x, w.y, w.s, w.age);\n }\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n }\n\n // 2. Render High-DPI Vector & Telemetry Overlay Canvas\n ctx.setTransform(DPR, 0, 0, DPR, 0, 0);\n ctx.clearRect(0, 0, W, H);\n\n // Mode 01 3D-anchored metrology callouts\n if (weights[0] > 0.05 && W > 560) {\n ctx.save();\n ctx.globalAlpha = weights[0];\n ctx.font = '500 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n const pCore = projectOpticsPin([0, 0.05, 0]);\n if (pCore) {\n ctx.strokeStyle = 'rgba(243, 179, 64, 0.45)';\n ctx.beginPath();\n ctx.arc(pCore.x, pCore.y, 4, 0, Math.PI * 2);\n ctx.moveTo(pCore.x + 4, pCore.y - 4);\n ctx.lineTo(pCore.x + 58, pCore.y - 42);\n ctx.lineTo(pCore.x + 195, pCore.y - 42);\n ctx.stroke();\n ctx.fillStyle = '#f3b340';\n ctx.fillText('DISPERSIVE CORE · IOR 1.41–1.58', pCore.x + 62, pCore.y - 47);\n }\n const cCut = optics.slice * 0.58;\n const pCut = projectOpticsPin([cCut, cCut * 0.8, cCut]);\n if (pCut) {\n ctx.strokeStyle = 'rgba(255, 89, 36, 0.45)';\n ctx.beginPath();\n ctx.moveTo(pCut.x, pCut.y);\n ctx.lineTo(pCut.x - 52, pCut.y + 38);\n ctx.lineTo(pCut.x - 188, pCut.y + 38);\n ctx.stroke();\n ctx.fillStyle = '#ff5924';\n ctx.fillText(`CSG LASER PLANE z=${optics.slice.toFixed(2)}`, pCut.x - 186, pCut.y + 33);\n }\n ctx.restore();\n }\n\n if (weights[1] > 0.02) drawContinuum(weights[1]);\n if (weights[2] > 0.02) drawTalos(weights[2], time);\n if (weights[3] > 0.02) drawSynth(weights[3], time);\n if (weights[4] > 0.02) drawCitadel(weights[4], time);\n\n pointer.vx *= 0.6;\n pointer.vy *= 0.6;\n pointer.speed *= 0.6;\n\n requestAnimationFrame(frame);\n }\n\n requestAnimationFrame(frame);\n})();\n</script>\n</body>\n</html>\n","Overwrite":true,"Path":"~/run/index.html"}
input
{ "Content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, viewport-fit=cover\" />\n<title>Gemini 4 Carbon — Cold-Start Artifact // Citadel</title>\n<style>\n :root {\n --bg-0: #07080b;\n --bg-1: #0e1016;\n --bg-panel: rgba(12, 14, 20, 0.82);\n --bg-panel-strong: rgba(10, 12, 17, 0.94);\n --ink-0: #efece4;\n --ink-1: #a7a196;\n --ink-2: #68645d;\n --line: rgba(239, 236, 228, 0.12);\n --line-strong: rgba(239, 236, 228, 0.26);\n --solar: #ff5924;\n --gold: #f3b340;\n --mint: #38d4b3;\n --cobalt: #5b9bff;\n --font-sans: 'Space Grotesk', 'Geist', 'IBM Plex Sans', 'Ubuntu', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n --font-mono: 'Geist Mono', 'IBM Plex Mono', 'JetBrains Mono', 'Ubuntu Mono', 'DejaVu Sans Mono', monospace;\n }\n\n * { box-sizing: border-box; margin: 0; padding: 0; }\n\n html, body {\n width: 100%;\n height: 100%;\n overflow: hidden;\n background: var(--bg-0);\n color: var(--ink-0);\n font-family: var(--font-sans);\n -webkit-font-smoothing: antialiased;\n user-select: none;\n }\n\n #stage {\n position: relative;\n width: 100%;\n height: 100%;\n overflow: hidden;\n touch-action: none;\n }\n\n canvas {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n display: block;\n }\n\n #gl { z-index: 1; }\n #hud { z-index: 2; cursor: grab; }\n #hud:active { cursor: grabbing; }\n #hud.pointer-node { cursor: pointer; }\n\n /* Architectural corner registration brackets */\n .corner {\n position: fixed;\n width: 10px;\n height: 10px;\n z-index: 5;\n pointer-events: none;\n opacity: 0.45;\n }\n .corner.tl { top: 8px; left: 8px; border-top: 1px solid var(--ink-1); border-left: 1px solid var(--ink-1); }\n .corner.tr { top: 8px; right: 8px; border-top: 1px solid var(--ink-1); border-right: 1px solid var(--ink-1); }\n .corner.bl { bottom: 54px; left: 8px; border-bottom: 1px solid var(--ink-1); border-left: 1px solid var(--ink-1); }\n .corner.br { bottom: 54px; right: 8px; border-bottom: 1px solid var(--ink-1); border-right: 1px solid var(--ink-1); }\n\n /* Top calibration bar */\n #topbar {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 44px;\n z-index: 10;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 16px;\n background: linear-gradient(180deg, rgba(7, 8, 11, 0.88) 0%, rgba(7, 8, 11, 0.35) 72%, rgba(7, 8, 11, 0) 100%);\n pointer-events: none;\n gap: 10px;\n }\n\n .brand-cluster {\n display: flex;\n align-items: center;\n gap: 10px;\n pointer-events: auto;\n min-width: 0;\n }\n\n .decal-mark {\n width: 18px;\n height: 18px;\n border: 1px solid var(--solar);\n display: grid;\n place-items: center;\n position: relative;\n flex-shrink: 0;\n background: rgba(255, 89, 36, 0.08);\n }\n .decal-mark::after {\n content: '';\n width: 6px;\n height: 6px;\n background: var(--solar);\n transform: rotate(45deg);\n }\n\n .brand-title {\n font-family: var(--font-mono);\n font-size: 11.5px;\n font-weight: 600;\n letter-spacing: 0.09em;\n text-transform: uppercase;\n color: var(--ink-0);\n white-space: nowrap;\n }\n\n .brand-sep {\n color: var(--ink-2);\n font-family: var(--font-mono);\n font-size: 11px;\n }\n\n .context-jump {\n font-family: var(--font-mono);\n font-size: 10.5px;\n letter-spacing: 0.05em;\n color: var(--ink-1);\n background: rgba(239, 236, 228, 0.04);\n border: 1px solid var(--line);\n padding: 3px 8px;\n cursor: pointer;\n transition: border-color 0.16s, color 0.16s, background 0.16s;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .context-jump:hover {\n color: var(--ink-0);\n border-color: var(--solar);\n background: rgba(255, 89, 36, 0.1);\n }\n .context-jump b {\n color: var(--gold);\n font-weight: 600;\n }\n\n .top-actions {\n display: flex;\n align-items: center;\n gap: 6px;\n pointer-events: auto;\n flex-shrink: 0;\n }\n\n .pill-btn {\n height: 26px;\n padding: 0 9px;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-family: var(--font-mono);\n font-size: 10.5px;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--ink-1);\n background: var(--bg-panel);\n border: 1px solid var(--line);\n cursor: pointer;\n transition: all 0.15s ease;\n font-variant-numeric: tabular-nums;\n backdrop-filter: blur(8px);\n }\n .pill-btn:hover {\n color: var(--ink-0);\n border-color: var(--line-strong);\n }\n .pill-btn.active {\n color: var(--ink-0);\n border-color: rgba(255, 89, 36, 0.55);\n background: rgba(255, 89, 36, 0.12);\n }\n .pill-btn.mint-active {\n color: var(--mint);\n border-color: rgba(56, 212, 179, 0.5);\n background: rgba(56, 212, 179, 0.09);\n }\n\n .dot-live {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--ink-2);\n transition: background 0.2s, box-shadow 0.2s;\n }\n .pill-btn.active .dot-live {\n background: var(--solar);\n box-shadow: 0 0 8px var(--solar);\n }\n\n /* Equalizer bars for sound button */\n .eq-bars {\n display: inline-flex;\n align-items: flex-end;\n gap: 1.5px;\n height: 10px;\n }\n .eq-bars i {\n display: block;\n width: 2px;\n height: 3px;\n background: currentColor;\n transition: height 0.12s;\n }\n .pill-btn.mint-active .eq-bars i:nth-child(1) { animation: eqPulse 0.55s ease-in-out infinite alternate; }\n .pill-btn.mint-active .eq-bars i:nth-child(2) { animation: eqPulse 0.42s ease-in-out 0.12s infinite alternate; }\n .pill-btn.mint-active .eq-bars i:nth-child(3) { animation: eqPulse 0.64s ease-in-out 0.24s infinite alternate; }\n @keyframes eqPulse {\n from { height: 2px; }\n to { height: 10px; }\n }\n\n /* Lower deck: Mode context + live interactive controls */\n #deck {\n position: absolute;\n left: 16px;\n right: 16px;\n bottom: 58px;\n z-index: 10;\n display: flex;\n align-items: flex-end;\n justify-content: space-between;\n gap: 12px;\n pointer-events: none;\n }\n\n .mode-placard {\n max-width: 430px;\n background: linear-gradient(90deg, rgba(7, 8, 11, 0.84) 0%, rgba(7, 8, 11, 0.58) 85%, rgba(7, 8, 11, 0) 100%);\n padding: 8px 14px 8px 10px;\n border-left: 2px solid var(--solar);\n pointer-events: none;\n }\n\n .mode-kicker {\n font-family: var(--font-mono);\n font-size: 10px;\n letter-spacing: 0.12em;\n text-transform: uppercase;\n color: var(--solar);\n margin-bottom: 3px;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n .mode-kicker span.sub-hint {\n color: var(--ink-2);\n letter-spacing: 0.06em;\n }\n\n .mode-headline {\n font-size: 16px;\n font-weight: 600;\n letter-spacing: -0.015em;\n color: var(--ink-0);\n line-height: 1.2;\n margin-bottom: 3px;\n }\n\n .mode-desc {\n font-size: 12px;\n line-height: 1.38;\n color: var(--ink-1);\n }\n\n /* Mode-specific interactive toolbars */\n .ctrl-rack {\n display: none;\n align-items: center;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: 6px;\n background: var(--bg-panel);\n border: 1px solid var(--line);\n padding: 6px 8px;\n backdrop-filter: blur(10px);\n pointer-events: auto;\n max-width: 580px;\n }\n .ctrl-rack.visible {\n display: flex;\n }\n\n .chip {\n height: 24px;\n padding: 0 8px;\n font-family: var(--font-mono);\n font-size: 10px;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--ink-1);\n background: rgba(255, 255, 255, 0.025);\n border: 1px solid var(--line);\n cursor: pointer;\n transition: all 0.14s;\n white-space: nowrap;\n }\n .chip:hover {\n color: var(--ink-0);\n border-color: var(--line-strong);\n }\n .chip.on {\n color: var(--ink-0);\n background: rgba(255, 89, 36, 0.16);\n border-color: var(--solar);\n }\n .chip.action-gold {\n color: var(--gold);\n border-color: rgba(243, 179, 64, 0.45);\n background: rgba(243, 179, 64, 0.09);\n }\n .chip.action-gold:hover {\n background: rgba(243, 179, 64, 0.2);\n color: #fff;\n }\n .chip.approve-ready {\n color: #07120f;\n background: var(--mint);\n border-color: var(--mint);\n font-weight: 700;\n animation: gatePulse 1.1s ease-in-out infinite alternate;\n }\n @keyframes gatePulse {\n from { box-shadow: 0 0 0 rgba(56, 212, 179, 0.2); }\n to { box-shadow: 0 0 14px rgba(56, 212, 179, 0.75); }\n }\n\n .slider-wrap {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 0 6px;\n font-family: var(--font-mono);\n font-size: 10px;\n color: var(--ink-1);\n letter-spacing: 0.06em;\n }\n .slider-wrap input[type=\"range\"] {\n -webkit-appearance: none;\n appearance: none;\n width: 84px;\n height: 3px;\n background: rgba(239, 236, 228, 0.2);\n outline: none;\n cursor: pointer;\n }\n .slider-wrap input[type=\"range\"]::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 10px;\n height: 14px;\n background: var(--solar);\n border: 1px solid var(--ink-0);\n cursor: ew-resize;\n }\n\n /* Citadel Triage Console inside Mode 05 */\n #citadel-console {\n width: 100%;\n max-width: 650px;\n flex-direction: column;\n align-items: stretch;\n gap: 6px;\n }\n .triage-row {\n display: flex;\n gap: 6px;\n width: 100%;\n }\n #triage-input {\n flex: 1;\n min-width: 140px;\n height: 28px;\n padding: 0 9px;\n background: rgba(5, 6, 9, 0.85);\n border: 1px solid var(--line-strong);\n color: var(--ink-0);\n font-family: var(--font-mono);\n font-size: 11px;\n outline: none;\n user-select: text;\n }\n #triage-input:focus {\n border-color: var(--solar);\n }\n #triage-input::placeholder {\n color: var(--ink-2);\n }\n .preset-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 5px;\n }\n .preset-chips {\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n }\n #triage-trace {\n font-family: var(--font-mono);\n font-size: 10px;\n color: var(--mint);\n letter-spacing: 0.03em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n /* Bottom 5-chamber navigation dock */\n #dock {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n height: 46px;\n z-index: 12;\n display: grid;\n grid-template-columns: repeat(5, 1fr);\n background: rgba(8, 9, 13, 0.94);\n border-top: 1px solid var(--line);\n backdrop-filter: blur(12px);\n }\n\n .dock-tab {\n position: relative;\n background: transparent;\n border: none;\n border-right: 1px solid var(--line);\n color: var(--ink-1);\n padding: 0 12px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n cursor: pointer;\n text-align: left;\n transition: background 0.16s, color 0.16s;\n overflow: hidden;\n }\n .dock-tab:last-child { border-right: none; }\n .dock-tab:hover {\n background: rgba(239, 236, 228, 0.035);\n color: var(--ink-0);\n }\n .dock-tab.active {\n background: rgba(255, 89, 36, 0.07);\n color: var(--ink-0);\n }\n\n .tab-progress {\n position: absolute;\n top: 0;\n left: 0;\n height: 2px;\n width: 0%;\n background: var(--solar);\n pointer-events: none;\n }\n .dock-tab.active .tab-progress {\n box-shadow: 0 0 8px var(--solar);\n }\n\n .tab-left {\n display: flex;\n align-items: baseline;\n gap: 7px;\n min-width: 0;\n }\n .tab-idx {\n font-family: var(--font-mono);\n font-size: 10px;\n color: var(--ink-2);\n font-variant-numeric: tabular-nums;\n }\n .dock-tab.active .tab-idx { color: var(--solar); font-weight: 600; }\n\n .tab-label {\n font-family: var(--font-mono);\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .tab-tag {\n font-family: var(--font-mono);\n font-size: 9.5px;\n color: var(--ink-2);\n letter-spacing: 0.04em;\n white-space: nowrap;\n }\n\n /* Live Claim Auditor Drawer (GPT-6.1-Sol inspired self-verification) */\n #audit-modal {\n position: absolute;\n inset: 46px 16px 54px 16px;\n z-index: 30;\n background: var(--bg-panel-strong);\n border: 1px solid var(--line-strong);\n display: none;\n flex-direction: column;\n backdrop-filter: blur(18px);\n box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72);\n }\n #audit-modal.open {\n display: flex;\n }\n\n .audit-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 10px 14px;\n border-bottom: 1px solid var(--line);\n background: rgba(255, 89, 36, 0.06);\n }\n .audit-title {\n font-family: var(--font-mono);\n font-size: 11.5px;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n color: var(--ink-0);\n }\n .audit-title span { color: var(--mint); margin-left: 8px; }\n\n .audit-body {\n flex: 1;\n display: grid;\n grid-template-columns: 300px 1fr;\n min-height: 0;\n }\n\n .audit-checks {\n padding: 12px 14px;\n border-right: 1px solid var(--line);\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 9px;\n }\n\n .check-item {\n padding-bottom: 8px;\n border-bottom: 1px solid rgba(239, 236, 228, 0.07);\n }\n .check-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-family: var(--font-mono);\n font-size: 10.5px;\n margin-bottom: 2px;\n }\n .check-name { color: var(--ink-0); font-weight: 600; }\n .check-pass { color: var(--mint); letter-spacing: 0.06em; }\n .check-val {\n font-family: var(--font-mono);\n font-size: 10px;\n color: var(--ink-1);\n line-height: 1.35;\n }\n\n .audit-code-pane {\n display: flex;\n flex-direction: column;\n min-width: 0;\n min-height: 0;\n }\n .code-tabs {\n display: flex;\n gap: 4px;\n padding: 8px 10px;\n border-bottom: 1px solid var(--line);\n flex-wrap: wrap;\n }\n #live-code-view {\n flex: 1;\n padding: 12px 14px;\n overflow: auto;\n font-family: var(--font-mono);\n font-size: 11px;\n line-height: 1.48;\n color: #d7d3c8;\n background: rgba(5, 6, 9, 0.72);\n white-space: pre;\n user-select: text;\n tab-size: 2;\n }\n\n /* Responsive adjustments for compact embeds & mobile */\n @media (max-width: 820px) {\n .tab-tag, .context-jump { display: none; }\n #deck { flex-direction: column; align-items: stretch; gap: 8px; bottom: 52px; }\n .mode-placard { max-width: 100%; padding: 6px 10px; }\n .mode-headline { font-size: 14px; }\n .mode-desc { font-size: 11px; }\n .ctrl-rack { max-width: 100%; justify-content: flex-start; }\n .audit-body { grid-template-columns: 1fr; }\n .audit-checks { max-height: 185px; border-right: none; border-bottom: 1px solid var(--line); }\n }\n\n @media (max-width: 540px) {\n #topbar { padding: 0 10px; }\n .brand-sep { display: none; }\n .tab-label { font-size: 9.5px; letter-spacing: 0.02em; }\n .dock-tab { padding: 0 6px; }\n }\n</style>\n</head>\n<body>\n<div id=\"stage\">\n <canvas id=\"gl\"></canvas>\n <canvas id=\"hud\"></canvas>\n\n <div class=\"corner tl\"></div>\n <div class=\"corner tr\"></div>\n <div class=\"corner bl\"></div>\n <div class=\"corner br\"></div>\n\n <!-- Perimeter Calibration Header -->\n <header id=\"topbar\">\n <div class=\"brand-cluster\">\n <div class=\"decal-mark\" aria-hidden=\"true\"></div>\n <div class=\"brand-title\">Gemini 4 Carbon</div>\n <span class=\"brand-sep\">//</span>\n <button class=\"context-jump\" id=\"btn-jump-citadel\" title=\"See how this fits Severian's Citadel stack\">\n 5 models run Citadel today · <b>Seat 06 built this cold →</b>\n </button>\n </div>\n\n <div class=\"top-actions\">\n <button class=\"pill-btn active\" id=\"btn-reel\" title=\"Toggle automatic capability reel (Space)\">\n <span class=\"dot-live\"></span>\n <span id=\"reel-label\">Auto-Reel</span>\n </button>\n <button class=\"pill-btn\" id=\"btn-sound\" title=\"Toggle procedural WebAudio synthesizer (M)\">\n <span class=\"eq-bars\" aria-hidden=\"true\"><i></i><i></i><i></i></span>\n <span id=\"sound-label\">DSP Off</span>\n </button>\n <button class=\"pill-btn\" id=\"btn-audit\" title=\"Inspect live runtime & verify zero-dependency claims (V)\">\n <span id=\"audit-badge\">Verify · 0 Deps</span>\n </button>\n </div>\n </header>\n\n <!-- Lower Context + Interactive Mode Controls -->\n <section id=\"deck\">\n <div class=\"mode-placard\" id=\"placard\">\n <div class=\"mode-kicker\">\n <span id=\"m-kicker\">01 ─ SPATIAL & 3D PIPELINE</span>\n <span class=\"sub-hint\" id=\"m-hint\">Drag to orbit · Scrub cut plane</span>\n </div>\n <h1 class=\"mode-headline\" id=\"m-title\">Raymarched CSG & Chromatic Dispersion</h1>\n <p class=\"mode-desc\" id=\"m-desc\">Real-time signed-distance assembly with three-wavelength refraction, machined boolean cross-sections, and live render passes.</p>\n </div>\n\n <!-- Controls for Mode 01: Optics -->\n <div class=\"ctrl-rack visible\" id=\"rack-0\">\n <div class=\"slider-wrap\">\n <span>SLICE</span>\n <input type=\"range\" id=\"opt-slice\" min=\"-115\" max=\"115\" value=\"28\" />\n </div>\n <button class=\"chip on\" data-pass=\"0\">PBR Refract</button>\n <button class=\"chip\" data-pass=\"1\">Normals</button>\n <button class=\"chip\" data-pass=\"2\">Iso-SDF</button>\n <button class=\"chip\" data-pass=\"3\">Clay + AO</button>\n </div>\n\n <!-- Controls for Mode 02: Continuum -->\n <div class=\"ctrl-rack\" id=\"rack-1\">\n <button class=\"chip on\" data-flow=\"0\">Accretion</button>\n <button class=\"chip\" data-flow=\"1\">Curl Turbulence</button>\n <button class=\"chip\" data-flow=\"2\">Dipole Lattice</button>\n <button class=\"chip action-gold\" id=\"btn-shockwave\">Detonate Pulse</button>\n </div>\n\n <!-- Controls for Mode 03: Automaton -->\n <div class=\"ctrl-rack\" id=\"rack-2\">\n <button class=\"chip on\" data-emo=\"auto\">Live Gaze</button>\n <button class=\"chip\" data-emo=\"curious\">Curious</button>\n <button class=\"chip\" data-emo=\"skeptical\">Skeptical</button>\n <button class=\"chip\" data-emo=\"startled\">Startled</button>\n <button class=\"chip\" data-emo=\"delighted\">Delighted</button>\n </div>\n\n <!-- Controls for Mode 04: Harmonics -->\n <div class=\"ctrl-rack\" id=\"rack-3\">\n <button class=\"chip on\" data-scale=\"0\">D Lydian</button>\n <button class=\"chip\" data-scale=\"1\">C# Phrygian</button>\n <button class=\"chip\" data-scale=\"2\">F Hirajoshi</button>\n <button class=\"chip action-gold\" id=\"btn-euclid-rand\">Mutate Rhythm</button>\n </div>\n\n <!-- Controls for Mode 05: Citadel Triage & Roster -->\n <div class=\"ctrl-rack\" id=\"citadel-console\">\n <div class=\"triage-row\">\n <input type=\"text\" id=\"triage-input\" maxlength=\"140\" placeholder=\"Send any Discord message or task through Claviger (Laya-421M)...\" />\n <button class=\"chip on\" id=\"btn-dispatch\">Dispatch</button>\n <button class=\"chip approve-ready\" id=\"btn-approve\" style=\"display:none;\">Approve Deploy ✓</button>\n </div>\n <div class=\"preset-row\">\n <div class=\"preset-chips\">\n <button class=\"chip\" data-prompt=\"Hearthwynd hero decal feels stiff on mobile + check 3D snow glTF\">1 · Design + 3D</button>\n <button class=\"chip\" data-prompt=\"Rebase desktop-buddies onto main and write 40 test conversations\">2 · Rebase + Tests</button>\n <button class=\"chip\" data-prompt=\"Audit scene-convert deploy kit against every claim in README\">3 · Claim Audit</button>\n <button class=\"chip\" data-prompt=\"yo nice pfp lol anyone queuing late tonight?\">4 · Discord Noise</button>\n </div>\n <div id=\"triage-trace\">Click any model node above, or fire a packet through Claviger.</div>\n </div>\n </div>\n </section>\n\n <!-- Bottom 5-Mode Dock -->\n <nav id=\"dock\" aria-label=\"Capability lenses\">\n <button class=\"dock-tab active\" data-mode=\"0\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">01</span><span class=\"tab-label\">Optics & 3D</span></div>\n <span class=\"tab-tag\">GLSL SDF</span>\n </button>\n <button class=\"dock-tab\" data-mode=\"1\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">02</span><span class=\"tab-label\">Continuum</span></div>\n <span class=\"tab-tag\">3.2k Bodies</span>\n </button>\n <button class=\"dock-tab\" data-mode=\"2\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">03</span><span class=\"tab-label\">Automaton</span></div>\n <span class=\"tab-tag\">24-DOF Rig</span>\n </button>\n <button class=\"dock-tab\" data-mode=\"3\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">04</span><span class=\"tab-label\">Harmonics</span></div>\n <span class=\"tab-tag\">Pure DSP</span>\n </button>\n <button class=\"dock-tab\" data-mode=\"4\">\n <div class=\"tab-progress\"></div>\n <div class=\"tab-left\"><span class=\"tab-idx\">05</span><span class=\"tab-label\">Citadel</span></div>\n <span class=\"tab-tag\">Live Stack</span>\n </button>\n </nav>\n\n <!-- Self-Verification & Live Code Inspector Modal -->\n <aside id=\"audit-modal\" role=\"dialog\" aria-label=\"Live Claim Verification\">\n <div class=\"audit-head\">\n <div class=\"audit-title\">Live Claim Audit // Zero-Smoke Introspection <span id=\"audit-summary\">ALL CHECKS PASS</span></div>\n <button class=\"chip\" id=\"btn-audit-close\">Close [Esc]</button>\n </div>\n <div class=\"audit-body\">\n <div class=\"audit-checks\" id=\"audit-list\"></div>\n <div class=\"audit-code-pane\">\n <div class=\"code-tabs\">\n <button class=\"chip on\" data-src=\"glsl\">Live GLSL Raymarcher</button>\n <button class=\"chip\" data-src=\"physics\">Lagrangian Physics</button>\n <button class=\"chip\" data-src=\"persona\">Talos-06 Kinematics</button>\n <button class=\"chip\" data-src=\"dsp\">WebAudio + Claviger Router</button>\n </div>\n <pre id=\"live-code-view\"></pre>\n </div>\n </div>\n </aside>\n</div>\n\n<!-- WebGL2 Fragment Shader: Unified 5-Stage Real-Time Backdrop + 3D SDF Raymarcher -->\n<script id=\"shader-frag\" type=\"x-shader/x-fragment\">#version 300 es\nprecision highp float;\n\nout vec4 fragColor;\nuniform vec2 u_res;\nuniform float u_time;\nuniform vec2 u_mouse;\nuniform vec4 u_weights; // x:Optics, y:Continuum, z:Automaton, w:Harmonics\nuniform float u_w4; // Citadel topology weight\nuniform vec2 u_camRot; // yaw, pitch\nuniform float u_slice; // CSG cross-section plane offset\nuniform float u_pass; // 0:PBR+Dispersion, 1:Normals, 2:Iso-SDF, 3:Clay+AO\nuniform vec4 u_wells[4];\nuniform vec3 u_shock;\nuniform vec3 u_arousal; // x:warmth, y:startle, z:focus\nuniform vec4 u_pulse; // 4 Euclidean ring envelopes\n\nmat2 rot(float a) {\n float c = cos(a), s = sin(a);\n return mat2(c, -s, s, c);\n}\n\nfloat sdRoundBox(vec3 p, vec3 b, float r) {\n vec3 q = abs(p) - b;\n return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0) - r;\n}\n\nfloat sdOctahedron(vec3 p, float s) {\n p = abs(p);\n return (p.x + p.y + p.z - s) * 0.57735027;\n}\n\nfloat sdBoxFrame(vec3 p, vec3 b, float e) {\n p = abs(p) - b;\n vec3 q = abs(p + e) - e;\n return min(min(\n length(max(vec3(p.x, q.y, q.z), 0.0)) + min(max(p.x, max(q.y, q.z)), 0.0),\n length(max(vec3(q.x, p.y, q.z), 0.0)) + min(max(q.x, max(p.y, q.z)), 0.0)),\n length(max(vec3(q.x, q.y, p.z), 0.0)) + min(max(q.x, max(q.y, p.z)), 0.0));\n}\n\nfloat sdMachinedRing(vec3 p, float r, float halfW, float halfH) {\n vec2 d = abs(vec2(length(p.xz) - r, p.y)) - vec2(halfW, halfH);\n return min(max(d.x, d.y), 0.0) + length(max(d, 0.0)) - 0.012;\n}\n\n// Returns vec2(distance, materialID)\n// matID: 1=Basalt Frame, 2=Refractive Crystal Core, 3=Solar Brass Gimbal, 4=Laser Cut Face, 5=Metrology Floor\nvec2 mapScene(vec3 p) {\n // Architectural basalt outer cage\n vec3 pf = p;\n pf.xz *= rot(0.22 * sin(u_time * 0.35));\n float cage = sdBoxFrame(pf, vec3(0.86), 0.072) - 0.012;\n float cornerTrim = sdOctahedron(pf, 1.52);\n cage = max(cage, cornerTrim);\n // Bore precision apertures along axes\n vec3 ap = abs(pf);\n float bores = min(min(length(ap.xy), length(ap.yz)), length(ap.xz)) - 0.30;\n cage = max(cage, -bores);\n\n // Counter-rotating machined brass gimbals\n vec3 pg1 = p;\n pg1.xy *= rot(0.62);\n pg1.xz *= rot(u_time * 0.55);\n float ring1 = sdMachinedRing(pg1, 0.68, 0.036, 0.055);\n float ticks1 = sin(atan(pg1.z, pg1.x) * 24.0) * 0.004;\n ring1 += ticks1;\n\n vec3 pg2 = p;\n pg2.yz *= rot(-0.78);\n pg2.xz *= rot(-u_time * 0.72);\n float ring2 = sdMachinedRing(pg2, 0.53, 0.030, 0.044);\n\n float gimbals = min(ring1, ring2);\n\n // Inner dispersive crystal polyhedron\n vec3 pc = p;\n pc.xz *= rot(-u_time * 0.42);\n pc.xy *= rot(u_time * 0.29);\n float core = max(sdRoundBox(pc, vec3(0.33), 0.025), sdOctahedron(pc, 0.52));\n\n // Combine solid assembly\n vec2 res = vec2(cage, 1.0);\n if (gimbals < res.x) res = vec2(gimbals, 3.0);\n if (core < res.x) res = vec2(core, 2.0);\n\n // Interactive CSG cross-section plane\n vec3 cutN = normalize(vec3(0.62, 0.52, 0.58));\n float dSlice = dot(p, cutN) - u_slice;\n if (dSlice > res.x) {\n res = vec2(dSlice, 4.0);\n } else if (abs(dSlice - res.x) < 0.016 && dSlice > -0.02) {\n res.y = 4.0;\n }\n\n // Metrology studio floor\n float floorD = p.y + 1.22;\n if (floorD < res.x) res = vec2(floorD, 5.0);\n\n return res;\n}\n\nvec3 calcNormal(vec3 p) {\n const vec2 e = vec2(0.0012, -0.0012);\n return normalize(\n e.xyy * mapScene(p + e.xyy).x +\n e.yyx * mapScene(p + e.yyx).x +\n e.yxy * mapScene(p + e.yxy).x +\n e.xxx * mapScene(p + e.xxx).x\n );\n}\n\nfloat calcAO(vec3 pos, vec3 nor) {\n float occ = 0.0;\n float sca = 1.0;\n for (int i = 0; i < 5; i++) {\n float h = 0.02 + 0.11 * float(i) / 4.0;\n float d = mapScene(pos + h * nor).x;\n occ += (h - d) * sca;\n sca *= 0.72;\n }\n return clamp(1.0 - 2.4 * occ, 0.0, 1.0);\n}\n\nfloat calcSoftShadow(vec3 ro, vec3 rd) {\n float res = 1.0;\n float t = 0.04;\n for (int i = 0; i < 24; i++) {\n float h = mapScene(ro + rd * t).x;\n res = min(res, 10.0 * h / t);\n t += clamp(h, 0.025, 0.18);\n if (res < 0.005 || t > 3.5) break;\n }\n return clamp(res, 0.0, 1.0);\n}\n\nvec3 envDome(vec3 rd) {\n float up = clamp(rd.y * 0.5 + 0.5, 0.0, 1.0);\n vec3 col = mix(vec3(0.025, 0.03, 0.042), vec3(0.09, 0.105, 0.14), up);\n // Warm solar studio strip\n float strip1 = pow(max(dot(rd, normalize(vec3(0.7, 0.55, 0.4))), 0.0), 18.0);\n // Cool verdigris rim strip\n float strip2 = pow(max(dot(rd, normalize(vec3(-0.75, 0.35, -0.5))), 0.0), 14.0);\n col += vec3(1.0, 0.42, 0.16) * strip1 * 1.35;\n col += vec3(0.22, 0.85, 0.72) * strip2 * 0.85;\n return col;\n}\n\nvec3 renderOptics(vec2 uv) {\n float yaw = u_camRot.x;\n float pitch = clamp(u_camRot.y, -1.05, 1.05);\n float dist = 3.35;\n vec3 ro = vec3(sin(yaw) * cos(pitch), sin(pitch) * 0.85 + 0.18, cos(yaw) * cos(pitch)) * dist;\n vec3 ta = vec3(0.0, -0.08, 0.0);\n vec3 ww = normalize(ta - ro);\n vec3 uu = normalize(cross(ww, vec3(0.0, 1.0, 0.0)));\n vec3 vv = cross(uu, ww);\n vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.85 * ww);\n\n vec3 bg = vec3(0.028, 0.032, 0.044) + 0.03 * max(0.0, 1.0 - length(uv) * 0.75);\n\n // Bounding check: sphere radius 1.75 around origin OR floor y = -1.22\n float b = dot(ro, rd);\n float c = dot(ro, ro) - 3.15;\n float disc = b * b - c;\n bool hitFloorPossible = (rd.y < -0.001 && ro.y > -1.22);\n if (disc < 0.0 && !hitFloorPossible) {\n return bg;\n }\n\n float t = 0.2;\n float mat = -1.0;\n float glowAcc = 0.0;\n for (int i = 0; i < 68; i++) {\n vec3 p = ro + rd * t;\n vec2 h = mapScene(p);\n // Subtle volumetric caustics near crystal core\n float coreProx = length(p);\n glowAcc += 0.0032 / (0.09 + coreProx * coreProx * 3.5);\n if (h.x < 0.0014) {\n mat = h.y;\n break;\n }\n t += h.x * 0.92;\n if (t > 7.5) break;\n }\n\n vec3 col = bg;\n if (mat > 0.0) {\n vec3 p = ro + rd * t;\n vec3 n = calcNormal(p);\n float ao = calcAO(p, n);\n\n if (u_pass > 0.5 && u_pass < 1.5) {\n // Pass 1: World-space Normal + Fresnel Inspection\n float fres = pow(1.0 - max(dot(-rd, n), 0.0), 3.0);\n col = (n * 0.5 + 0.5) * (0.65 + 0.35 * ao) + fres * 0.25;\n return pow(clamp(col, 0.0, 1.0), vec3(0.85));\n }\n\n if (u_pass >= 1.5 && u_pass < 2.5) {\n // Pass 2: Signed-Distance Iso-Contour Metrology Pass\n float iso = abs(fract(length(p) * 14.0 - u_time * 0.6) - 0.5);\n float lines = smoothstep(0.08, 0.015, iso);\n float wire = smoothstep(0.03, 0.005, abs(fract((p.x + p.y + p.z) * 9.0) - 0.5));\n col = vec3(0.05, 0.07, 0.09) * ao;\n col += vec3(0.22, 0.83, 0.70) * lines * 0.85;\n col += vec3(1.0, 0.36, 0.14) * wire * 0.45;\n return col;\n }\n\n if (u_pass >= 2.5) {\n // Pass 3: Architectural Clay + Studio AO Pass\n vec3 keyL = normalize(vec3(0.65, 0.75, 0.38));\n float dif = max(dot(n, keyL), 0.0);\n float sh = (mat < 4.5) ? calcSoftShadow(p + n * 0.01, keyL) : 1.0;\n vec3 clay = vec3(0.84, 0.81, 0.76);\n col = clay * (0.22 * ao + 0.78 * dif * sh * ao);\n if (mat > 4.5) {\n float rGrid = abs(fract(length(p.xz) * 2.5) - 0.5);\n col *= mix(0.22, 0.34, smoothstep(0.02, 0.06, rGrid)) * exp(-0.28 * length(p.xz));\n }\n return pow(clamp(col, 0.0, 1.0), vec3(0.9));\n }\n\n // Pass 0: Full Studio PBR + 3-Wavelength Chromatic Dispersion\n vec3 keyDir = normalize(vec3(0.68, 0.66, 0.32));\n vec3 rimDir = normalize(vec3(-0.72, 0.35, -0.58));\n float dif = max(dot(n, keyDir), 0.0);\n float rim = max(dot(n, rimDir), 0.0);\n float fres = pow(1.0 - max(dot(-rd, n), 0.0), 4.0);\n\n if (mat > 4.5) {\n // Metrology Turntable Floor\n float sh = calcSoftShadow(p + n * 0.015, keyDir);\n float rad = length(p.xz);\n float ringLine = 1.0 - smoothstep(0.0, 0.015, abs(fract(rad * 2.0) - 0.5) - 0.485);\n float axisLine = 1.0 - smoothstep(0.0, 0.012, min(abs(p.x), abs(p.z)));\n vec3 baseF = vec3(0.032, 0.036, 0.048) * (0.4 + 0.6 * sh) * ao;\n baseF += vec3(0.22, 0.25, 0.30) * (ringLine * 0.28 + axisLine * 0.22) * exp(-0.55 * rad);\n // Glossy reflection hint\n vec3 refl = envDome(reflect(rd, n));\n col = mix(baseF, refl * sh, 0.14) * exp(-0.18 * rad * rad) + bg * (1.0 - exp(-0.18 * rad * rad));\n } else if (mat > 1.5 && mat < 2.5) {\n // Dispersive Crystal Core (RGB split IOR)\n vec3 rR = envDome(refract(rd, n, 1.0 / 1.41));\n vec3 rG = envDome(refract(rd, n, 1.0 / 1.49));\n vec3 rB = envDome(refract(rd, n, 1.0 / 1.58));\n vec3 refracted = vec3(rR.r, rG.g, rB.b) * 1.75;\n // Internal incandescent solar heart\n float heart = exp(-5.0 * length(p));\n refracted += vec3(1.0, 0.40, 0.12) * heart * 1.4 + vec3(0.22, 0.85, 0.72) * (1.0 - heart) * 0.22;\n vec3 refl = envDome(reflect(rd, n));\n col = mix(refracted, refl * 1.3, 0.22 + 0.68 * fres);\n col += vec3(1.0, 0.82, 0.55) * pow(max(dot(reflect(-keyDir, n), -rd), 0.0), 42.0) * 1.2;\n } else if (mat > 2.5 && mat < 3.5) {\n // Anodized Solar Brass Gimbal Rings\n float sh = calcSoftShadow(p + n * 0.01, keyDir);\n vec3 alb = vec3(0.92, 0.58, 0.22);\n vec3 h = normalize(keyDir - rd);\n float spec = pow(max(dot(n, h), 0.0), 36.0);\n col = alb * (0.14 * ao + 0.75 * dif * sh) + alb * spec * 1.4 * sh + vec3(0.22, 0.83, 0.70) * rim * 0.25 * ao;\n col += envDome(reflect(rd, n)) * (0.18 + 0.45 * fres);\n } else if (mat > 3.5 && mat < 4.5) {\n // Machined CSG Cross-Section Face (diagonal metrology hatch + heated laser rim)\n float hatch = smoothstep(-0.2, 0.2, sin((p.x - p.y + p.z) * 85.0));\n vec3 faceCol = mix(vec3(0.10, 0.11, 0.14), vec3(0.24, 0.22, 0.20), hatch) * (0.5 + 0.5 * ao);\n // Outer boundary laser heat glow\n vec3 pOff = p - normalize(vec3(0.62, 0.52, 0.58)) * 0.018;\n float edgeProx = abs(mapScene(pOff).x);\n float rimHeat = exp(-42.0 * edgeProx);\n col = faceCol + vec3(1.0, 0.36, 0.10) * rimHeat * 1.65;\n } else {\n // Etched Basalt Titanium Outer Frame\n float sh = calcSoftShadow(p + n * 0.01, keyDir);\n vec3 alb = vec3(0.14, 0.155, 0.19);\n vec3 h = normalize(keyDir - rd);\n float spec = pow(max(dot(n, h), 0.0), 28.0);\n col = alb * (0.20 * ao + 0.85 * dif * sh) + vec3(0.95, 0.88, 0.80) * spec * 0.55 * sh;\n col += vec3(0.22, 0.83, 0.70) * rim * 0.22 * ao + envDome(reflect(rd, n)) * (0.10 + 0.35 * fres);\n }\n }\n\n col += vec3(1.0, 0.38, 0.14) * glowAcc * 0.28;\n return col;\n}\n\nvoid main() {\n vec2 uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y);\n\n // Subtle architectural background grid across all modes\n vec2 gUV = uv * 9.0;\n vec2 grid = abs(fract(gUV - 0.5) - 0.5) / fwidth(gUV);\n float line = 1.0 - min(min(grid.x, grid.y), 1.0);\n vec3 base = vec3(0.027, 0.031, 0.043) + vec3(0.025, 0.028, 0.036) * line * 0.45;\n\n vec3 total = vec3(0.0);\n\n // 01: Raymarched 3D Optics (evaluated only while visible)\n if (u_weights.x > 0.004) {\n total += renderOptics(uv) * u_weights.x;\n }\n\n // 02: Spacetime Potential Lensing for Continuum Physics\n if (u_weights.y > 0.004) {\n vec3 cCol = base;\n float pot = 0.0;\n for (int i = 0; i < 4; i++) {\n vec4 w = u_wells[i];\n if (abs(w.z) > 0.01) {\n float d = length(uv - w.xy);\n pot += w.z * 0.045 / (d + 0.055);\n float ring = exp(-28.0 * abs(d - 0.09 - 0.02 * sin(u_time * 4.0 + float(i))));\n cCol += (w.z > 0.0 ? vec3(1.0, 0.35, 0.14) : vec3(0.22, 0.83, 0.70)) * ring * 0.45;\n }\n }\n float equipot = abs(fract(pot * 4.5 - u_time * 0.25) - 0.5);\n cCol += vec3(0.16, 0.32, 0.36) * (1.0 - smoothstep(0.0, 0.06, equipot)) * 0.35;\n if (u_shock.z > 0.001 && u_shock.z < 2.2) {\n float sd = abs(length(uv - u_shock.xy) - u_shock.z);\n cCol += vec3(1.0, 0.62, 0.24) * exp(-36.0 * sd) * (1.0 - u_shock.z / 2.2) * 0.9;\n }\n total += cCol * u_weights.y;\n }\n\n // 03: Studio Depth Halo for Talos-06 Automaton\n if (u_weights.z > 0.004) {\n float d = length(uv - vec2(0.0, 0.04));\n vec3 pCol = base;\n vec3 aura = mix(vec3(0.22, 0.83, 0.70), vec3(1.0, 0.35, 0.14), clamp(u_arousal.y, 0.0, 1.0));\n aura = mix(aura, vec3(0.95, 0.70, 0.25), clamp(u_arousal.x * 0.6, 0.0, 1.0));\n pCol += aura * exp(-4.2 * d * d) * 0.20;\n float reticle = abs(fract(d * 7.0 - u_time * 0.18) - 0.5);\n pCol += aura * (1.0 - smoothstep(0.0, 0.025, reticle)) * exp(-2.5 * d) * 0.08;\n total += pCol * u_weights.z;\n }\n\n // 04: Harmonic Wavefront Ripples for Euclidean Synth\n if (u_weights.w > 0.004) {\n float r = length(uv - vec2(0.0, 0.03));\n vec3 hCol = base;\n float radii[4] = float[4](0.36, 0.275, 0.195, 0.12);\n vec3 cols[4] = vec3[4](\n vec3(0.95, 0.70, 0.25),\n vec3(0.22, 0.83, 0.70),\n vec3(0.94, 0.92, 0.88),\n vec3(1.00, 0.35, 0.14)\n );\n float pulses[4] = float[4](u_pulse.x, u_pulse.y, u_pulse.z, u_pulse.w);\n for (int i = 0; i < 4; i++) {\n float wave = exp(-34.0 * abs(r - radii[i])) * (0.12 + 0.95 * pulses[i]);\n hCol += cols[i] * wave * 0.45;\n }\n total += hCol * u_weights.w;\n }\n\n // 05: Citadel Architectural Schematic Field\n if (u_w4 > 0.004) {\n vec3 sCol = base * 0.92;\n float scan = exp(-18.0 * abs(uv.x - (mod(u_time * 0.28, 2.4) - 1.2)));\n sCol += vec3(1.0, 0.36, 0.14) * scan * 0.045;\n total += sCol * u_w4;\n }\n\n // Subtle vignette & ACES-inspired filmic curve\n float vig = 1.0 - 0.28 * dot(uv, uv);\n total *= clamp(vig, 0.55, 1.0);\n total = (total * (2.51 * total + 0.03)) / (total * (2.43 * total + 0.59) + 0.14);\n fragColor = vec4(pow(clamp(total, 0.0, 1.0), vec3(0.92)), 1.0);\n}\n</script>\n\n<script>\n(() => {\n 'use strict';\n\n /* =========================================================================\n 0. MODE METADATA & SYSTEM STATE\n ========================================================================= */\n const MODES = [\n {\n kicker: '01 ─ SPATIAL & 3D PIPELINE',\n hint: 'Drag to orbit · Scrub cut plane',\n title: 'Raymarched CSG & Chromatic Dispersion',\n desc: 'Real-time signed-distance assembly with three-wavelength refraction, machined boolean cross-sections, and live render passes.'\n },\n {\n kicker: '02 ─ LAGRANGIAN PHYSICS',\n hint: 'Move to shear · Click to drop gravity well',\n title: '3,200-Body Coupled Vortex Continuum',\n desc: 'Divergence-free curl-noise filaments and orbital singularities integrated in typed arrays at 60fps.'\n },\n {\n kicker: '03 ─ CHARACTER KINEMATICS',\n hint: 'Hover gently · Shake fast · Click optic',\n title: 'TALOS-06 Procedural Expression Rig',\n desc: 'Perspective-projected 24-DOF automaton with biological micro-saccades, 8-blade iris apertures, and emergent emotional physics.'\n },\n {\n kicker: '04 ─ SIGNAL & COMPOSITION',\n hint: 'Click orbital steps to rewrite harmony',\n title: 'Zero-Sample Euclidean Polyrhythm Loom',\n desc: 'Four rotating Bjorklund rhythms driving mathematical FM glass bells, waveguide strings, and a live stereo Lissajous scope.'\n },\n {\n kicker: '05 ─ CITADEL & SEAT 06',\n hint: 'Click any model · Send a message to Claviger',\n title: 'What Runs Citadel Today — And This Cold Run',\n desc: 'Five models + Claviger (Laya-421M) run Severian’s live stack. Gemini 4 Carbon wasn’t in about-me.md—this file is its cold-start answer.'\n }\n ];\n\n const REEL_SECONDS = 4.3;\n let activeMode = 0;\n let autoReel = true;\n let reelTimer = 0;\n let weights = [1, 0, 0, 0, 0];\n\n let W = window.innerWidth;\n let H = window.innerHeight;\n let DPR = Math.min(window.devicePixelRatio || 1, 2);\n\n // Pointer & interaction kinematics\n const pointer = {\n x: W * 0.5, y: H * 0.5,\n nx: 0, ny: 0, // -1..1 aspect-corrected\n vx: 0, vy: 0,\n speed: 0,\n down: false,\n inside: false,\n dragDX: 0, dragDY: 0,\n orbitAccum: 0,\n lastAngle: 0\n };\n\n // Rolling FPS & frame budget telemetry for self-audit\n let fpsSmooth = 60;\n let frameMsSmooth = 8.0;\n let glRendererInfo = 'Canvas2D Fallback';\n let glVersionInfo = 'Unavailable';\n\n /* =========================================================================\n 1. PROCEDURAL WEBAUDIO SYNTHESIZER (ZERO EXTERNAL SAMPLES)\n ========================================================================= */\n const DSP = {\n ctx: null,\n enabled: false,\n mutedByUser: false,\n master: null,\n analyserL: null,\n analyserR: null,\n waveBufL: new Float32Array(256),\n waveBufR: new Float32Array(256),\n\n unlock(forceToggle = false) {\n if (forceToggle) {\n if (this.enabled) {\n this.enabled = false;\n this.mutedByUser = true;\n if (this.master && this.ctx) {\n this.master.gain.setTargetAtTime(0.0001, this.ctx.currentTime, 0.04);\n }\n updateSoundUI();\n return;\n }\n this.mutedByUser = false;\n } else if (this.mutedByUser) {\n return;\n }\n\n if (!this.ctx) {\n const AC = window.AudioContext || window.webkitAudioContext;\n if (!AC) return;\n const ctx = new AC();\n this.ctx = ctx;\n\n const comp = ctx.createDynamicsCompressor();\n comp.threshold.value = -16;\n comp.ratio.value = 5;\n comp.attack.value = 0.005;\n comp.release.value = 0.18;\n\n const master = ctx.createGain();\n master.gain.value = 0.23;\n this.master = master;\n\n // Stereo splitter for real Lissajous X-Y scope\n const splitter = ctx.createChannelSplitter(2);\n this.analyserL = ctx.createAnalyser();\n this.analyserR = ctx.createAnalyser();\n this.analyserL.fftSize = 512;\n this.analyserR.fftSize = 512;\n\n // Dotted-eighth stereo ping-pong delay + warm lowpass feedback\n const dL = ctx.createDelay(1.0);\n const dR = ctx.createDelay(1.0);\n dL.delayTime.value = 0.255;\n dR.delayTime.value = 0.382;\n const fbL = ctx.createGain();\n const fbR = ctx.createGain();\n fbL.gain.value = 0.32;\n fbR.gain.value = 0.30;\n const damp = ctx.createBiquadFilter();\n damp.type = 'lowpass';\n damp.frequency.value = 2400;\n\n const wet = ctx.createGain();\n wet.gain.value = 0.28;\n const pannerL = ctx.createStereoPanner ? ctx.createStereoPanner() : null;\n const pannerR = ctx.createStereoPanner ? ctx.createStereoPanner() : null;\n if (pannerL && pannerR) {\n pannerL.pan.value = -0.65;\n pannerR.pan.value = 0.65;\n }\n\n this.bus = ctx.createGain();\n this.bus.connect(comp);\n this.bus.connect(damp);\n damp.connect(dL);\n dL.connect(fbL);\n fbL.connect(dR);\n dR.connect(fbR);\n fbR.connect(damp);\n\n if (pannerL && pannerR) {\n dL.connect(pannerL); pannerL.connect(wet);\n dR.connect(pannerR); pannerR.connect(wet);\n } else {\n dL.connect(wet); dR.connect(wet);\n }\n wet.connect(comp);\n comp.connect(master);\n master.connect(ctx.destination);\n master.connect(splitter);\n splitter.connect(this.analyserL, 0);\n splitter.connect(this.analyserR, 1);\n }\n\n if (this.ctx.state === 'suspended') {\n this.ctx.resume();\n }\n this.enabled = true;\n this.master.gain.setTargetAtTime(0.23, this.ctx.currentTime, 0.05);\n updateSoundUI();\n },\n\n click(freq = 320, dur = 0.025, vol = 0.08) {\n if (!this.enabled || !this.ctx) return;\n const t = this.ctx.currentTime;\n const osc = this.ctx.createOscillator();\n const g = this.ctx.createGain();\n osc.type = 'triangle';\n osc.frequency.setValueAtTime(freq, t);\n osc.frequency.exponentialRampToValueAtTime(freq * 0.45, t + dur);\n g.gain.setValueAtTime(vol, t);\n g.gain.exponentialRampToValueAtTime(0.0001, t + dur);\n osc.connect(g);\n g.connect(this.bus);\n osc.start(t);\n osc.stop(t + dur + 0.01);\n },\n\n voice(ringIdx, freq, pan = 0) {\n if (!this.enabled || !this.ctx) return;\n const ctx = this.ctx;\n const t = ctx.currentTime;\n const out = ctx.createGain();\n const panner = ctx.createStereoPanner ? ctx.createStereoPanner() : null;\n if (panner) {\n panner.pan.value = Math.max(-0.85, Math.min(0.85, pan));\n out.connect(panner);\n panner.connect(this.bus);\n } else {\n out.connect(this.bus);\n }\n\n if (ringIdx === 0) {\n // Plucked harmonic string (triangle + filtered harmonic burst)\n const o1 = ctx.createOscillator();\n const o2 = ctx.createOscillator();\n const flt = ctx.createBiquadFilter();\n o1.type = 'sawtooth';\n o2.type = 'triangle';\n o1.frequency.value = freq;\n o2.frequency.value = freq * 2.0;\n flt.type = 'lowpass';\n flt.frequency.setValueAtTime(freq * 5.5, t);\n flt.frequency.exponentialRampToValueAtTime(freq * 1.3, t + 0.28);\n out.gain.setValueAtTime(0.001, t);\n out.gain.linearRampToValueAtTime(0.14, t + 0.006);\n out.gain.exponentialRampToValueAtTime(0.0001, t + 0.55);\n o1.connect(flt); o2.connect(flt); flt.connect(out);\n o1.start(t); o2.start(t);\n o1.stop(t + 0.58); o2.stop(t + 0.58);\n } else if (ringIdx === 1) {\n // 2-Operator FM Crystalline Bell\n const car = ctx.createOscillator();\n const mod = ctx.createOscillator();\n const modG = ctx.createGain();\n car.type = 'sine';\n mod.type = 'sine';\n car.frequency.value = freq;\n mod.frequency.value = freq * 3.0;\n modG.gain.setValueAtTime(freq * 1.9, t);\n modG.gain.exponentialRampToValueAtTime(0.5, t + 0.36);\n out.gain.setValueAtTime(0.001, t);\n out.gain.linearRampToValueAtTime(0.15, t + 0.008);\n out.gain.exponentialRampToValueAtTime(0.0001, t + 0.85);\n mod.connect(modG);\n modG.connect(car.frequency);\n car.connect(out);\n car.start(t); mod.start(t);\n car.stop(t + 0.88); mod.stop(t + 0.88);\n } else if (ringIdx === 2) {\n // Warm Sub-Analog Bass Pulse\n const o1 = ctx.createOscillator();\n const o2 = ctx.createOscillator();\n const flt = ctx.createBiquadFilter();\n o1.type = 'sawtooth';\n o2.type = 'sawtooth';\n o1.frequency.value = freq;\n o2.frequency.value = freq * 1.006;\n flt.type = 'lowpass';\n flt.Q.value = 2.8;\n flt.frequency.setValueAtTime(580, t);\n flt.frequency.exponentialRampToValueAtTime(140, t + 0.45);\n out.gain.setValueAtTime(0.001, t);\n out.gain.linearRampToValueAtTime(0.16, t + 0.015);\n out.gain.exponentialRampToValueAtTime(0.0001, t + 0.62);\n o1.connect(flt); o2.connect(flt); flt.connect(out);\n o1.start(t); o2.start(t);\n o1.stop(t + 0.65); o2.stop(t + 0.65);\n } else {\n // Tuned Micro-Relay Percussion\n const osc = ctx.createOscillator();\n osc.type = 'sine';\n osc.frequency.setValueAtTime(freq * 2.4, t);\n osc.frequency.exponentialRampToValueAtTime(95, t + 0.065);\n out.gain.setValueAtTime(0.11, t);\n out.gain.exponentialRampToValueAtTime(0.0001, t + 0.08);\n osc.connect(out);\n osc.start(t);\n osc.stop(t + 0.09);\n }\n },\n\n boom() {\n if (!this.enabled || !this.ctx) return;\n const t = this.ctx.currentTime;\n const osc = this.ctx.createOscillator();\n const g = this.ctx.createGain();\n osc.type = 'sine';\n osc.frequency.setValueAtTime(118, t);\n osc.frequency.exponentialRampToValueAtTime(34, t + 0.48);\n g.gain.setValueAtTime(0.26, t);\n g.gain.exponentialRampToValueAtTime(0.0001, t + 0.52);\n osc.connect(g); g.connect(this.bus);\n osc.start(t); osc.stop(t + 0.55);\n },\n\n emote(kind) {\n if (!this.enabled || !this.ctx) return;\n if (kind === 'curious') {\n this.voice(1, 587.33, -0.2);\n setTimeout(() => this.voice(1, 880.0, 0.2), 75);\n } else if (kind === 'skeptical') {\n this.voice(2, 164.81, 0);\n } else if (kind === 'startled') {\n this.voice(0, 987.77, -0.35);\n this.voice(3, 440, 0.35);\n } else if (kind === 'delighted') {\n [587.33, 739.99, 880.0, 1108.73].forEach((f, i) => {\n setTimeout(() => this.voice(1, f, (i - 1.5) * 0.35), i * 55);\n });\n }\n }\n };\n\n /* =========================================================================\n 2. WEBGL 2.0 FULL-STAGE SHADER INIT\n ========================================================================= */\n const glCanvas = document.getElementById('gl');\n const hudCanvas = document.getElementById('hud');\n const ctx = hudCanvas.getContext('2d');\n const gl = glCanvas.getContext('webgl2', { antialias: false, depth: false, stencil: false, powerPreference: 'high-performance' });\n\n let glProg = null;\n const glUni = {};\n\n if (gl) {\n glVersionInfo = gl.getParameter(gl.VERSION) || 'WebGL 2.0';\n const dbg = gl.getExtension('WEBGL_debug_renderer_info');\n glRendererInfo = dbg ? (gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL) || 'Hardware GPU') : (gl.getParameter(gl.RENDERER) || 'WebGL2 GPU');\n\n const vsSrc = `#version 300 es\n in vec2 a_pos;\n void main() { gl_Position = vec4(a_pos, 0.0, 1.0); }`;\n const fsSrc = document.getElementById('shader-frag').textContent;\n\n const compile = (type, src) => {\n const sh = gl.createShader(type);\n gl.shaderSource(sh, src);\n gl.compileShader(sh);\n if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) {\n console.error('Shader error:', gl.getShaderInfoLog(sh));\n return null;\n }\n return sh;\n };\n\n const vs = compile(gl.VERTEX_SHADER, vsSrc);\n const fs = compile(gl.FRAGMENT_SHADER, fsSrc);\n if (vs && fs) {\n glProg = gl.createProgram();\n gl.attachShader(glProg, vs);\n gl.attachShader(glProg, fs);\n gl.linkProgram(glProg);\n if (gl.getProgramParameter(glProg, gl.LINK_STATUS)) {\n gl.useProgram(glProg);\n const buf = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buf);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n const loc = gl.getAttribLocation(glProg, 'a_pos');\n gl.enableVertexAttribArray(loc);\n gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\n\n ['u_res', 'u_time', 'u_mouse', 'u_weights', 'u_w4', 'u_camRot', 'u_slice', 'u_pass', 'u_shock', 'u_arousal', 'u_pulse'].forEach(n => {\n glUni[n] = gl.getUniformLocation(glProg, n);\n });\n glUni.u_wells = [];\n for (let i = 0; i < 4; i++) glUni.u_wells.push(gl.getUniformLocation(glProg, `u_wells[${i}]`));\n } else {\n console.error('Link error:', gl.getProgramInfoLog(glProg));\n glProg = null;\n }\n }\n }\n\n function resize() {\n W = window.innerWidth;\n H = window.innerHeight;\n DPR = Math.min(window.devicePixelRatio || 1, 2);\n // Slight cap on raymarch DPI for huge 4K monitors to guarantee locked 60fps\n const glScale = Math.min(DPR, (W * H > 1400000) ? 1.35 : 1.75);\n glCanvas.width = Math.max(1, Math.floor(W * glScale));\n glCanvas.height = Math.max(1, Math.floor(H * glScale));\n hudCanvas.width = Math.max(1, Math.floor(W * DPR));\n hudCanvas.height = Math.max(1, Math.floor(H * DPR));\n if (gl) gl.viewport(0, 0, glCanvas.width, glCanvas.height);\n layoutCitadelNodes();\n }\n window.addEventListener('resize', resize);\n\n /* =========================================================================\n 3. MODE 01 STATE: 3D OPTICS & PIPELINE TELEMETRY\n ========================================================================= */\n const optics = {\n yaw: 0.58,\n pitch: 0.34,\n vYaw: 0.0035,\n vPitch: 0,\n slice: 0.28,\n userSliced: false,\n pass: 0\n };\n\n function projectOpticsPin(p3) {\n const yaw = optics.yaw;\n const pitch = Math.max(-1.05, Math.min(1.05, optics.pitch));\n const dist = 3.35;\n const ro = [Math.sin(yaw) * Math.cos(pitch) * dist, Math.sin(pitch) * 0.85 * dist + 0.18 * dist, Math.cos(yaw) * Math.cos(pitch) * dist];\n const ta = [0, -0.08, 0];\n const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];\n const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];\n const norm = a => { const l = Math.hypot(a[0], a[1], a[2]) || 1; return [a[0] / l, a[1] / l, a[2] / l]; };\n const ww = norm(sub(ta, ro));\n const uu = norm(cross(ww, [0, 1, 0]));\n const vv = cross(uu, ww);\n const rel = sub(p3, ro);\n const z = dot(rel, ww);\n if (z <= 0.2) return null;\n const ux = (dot(rel, uu) / z) * 1.85;\n const uy = (dot(rel, vv) / z) * 1.85;\n const minDim = Math.min(W, H);\n return {\n x: W * 0.5 + ux * minDim,\n y: H * 0.5 - uy * minDim\n };\n }\n\n /* =========================================================================\n 4. MODE 02 ENGINE: 3,200-BODY LAGRANGIAN VORTEX CONTINUUM\n ========================================================================= */\n const PARTICLE_COUNT = 3200;\n const pX = new Float32Array(PARTICLE_COUNT);\n const pY = new Float32Array(PARTICLE_COUNT);\n const pVX = new Float32Array(PARTICLE_COUNT);\n const pVY = new Float32Array(PARTICLE_COUNT);\n const pPX = new Float32Array(PARTICLE_COUNT);\n const pPY = new Float32Array(PARTICLE_COUNT);\n\n function initParticles() {\n for (let i = 0; i < PARTICLE_COUNT; i++) {\n const a = Math.random() * Math.PI * 2;\n const r = Math.sqrt(Math.random()) * 0.72;\n pX[i] = pPX[i] = Math.cos(a) * r * (W / Math.min(W, H));\n pY[i] = pPY[i] = Math.sin(a) * r;\n pVX[i] = -Math.sin(a) * 0.004;\n pVY[i] = Math.cos(a) * 0.004;\n }\n }\n\n const continuum = {\n flowMode: 0, // 0:Accretion, 1:Curl Turbulence, 2:Dipole Lattice\n wells: [\n { x: -0.26, y: 0.04, s: 1.0, age: 0 },\n { x: 0.26, y: -0.04, s: -0.9, age: 1.5 },\n { x: 0, y: 0, s: 0, age: 0 },\n { x: 0, y: 0, s: 0, age: 0 }\n ],\n wellCursor: 2,\n shock: { x: 0, y: 0, r: 9.0 },\n kineticEnergy: 0\n };\n\n function stepPhysics(dt, time) {\n const aspect = W / Math.min(W, H);\n const hBound = H / Math.min(W, H) * 0.52;\n const wBound = aspect * 0.52;\n\n if (autoReel && activeMode === 1) {\n continuum.wells[0].x = Math.cos(time * 0.75) * 0.28;\n continuum.wells[0].y = Math.sin(time * 0.75) * 0.16;\n continuum.wells[0].s = 1.05;\n continuum.wells[1].x = -continuum.wells[0].x;\n continuum.wells[1].y = -continuum.wells[0].y;\n continuum.wells[1].s = -0.95;\n }\n\n if (continuum.shock.r < 2.5) {\n continuum.shock.r += dt * 1.95;\n }\n\n let keSum = 0;\n const fm = continuum.flowMode;\n const hasPtr = pointer.inside;\n const mx = pointer.nx, my = pointer.ny;\n const mvx = pointer.vx, mvy = pointer.vy;\n const sr = continuum.shock.r;\n const sx = continuum.shock.x, sy = continuum.shock.y;\n\n for (let i = 0; i < PARTICLE_COUNT; i++) {\n let x = pX[i], y = pY[i];\n let vx = pVX[i], vy = pVY[i];\n pPX[i] = x;\n pPY[i] = y;\n\n // Analytic divergence-free curl potential\n const sc = fm === 1 ? 5.2 : 3.1;\n const cx = Math.sin(y * sc + time * 0.7) + Math.cos((x + y) * sc * 0.7 - time * 0.45);\n const cy = Math.cos(x * sc - time * 0.65) - Math.sin((x - y) * sc * 0.7 + time * 0.5);\n const curlAmt = fm === 1 ? 0.00052 : 0.00021;\n vx += cx * curlAmt;\n vy += cy * curlAmt;\n\n if (fm === 2) {\n // Magnetic dipole field lines\n const r2 = x * x + y * y + 0.035;\n const r5 = Math.pow(r2, 1.8);\n vx += (3 * x * y) / r5 * 0.00009;\n vy += (2 * y * y - x * x) / r5 * 0.00009;\n }\n\n // Coupled vortex + accretion singularities\n for (let w = 0; w < 4; w++) {\n const well = continuum.wells[w];\n if (Math.abs(well.s) < 0.01) continue;\n const dx = well.x - x;\n const dy = well.y - y;\n const d2 = dx * dx + dy * dy + 0.0045;\n const inv = 0.00026 / d2;\n // Swirl + gentle inward pull\n vx += (-dy * well.s * 1.35 + dx * 0.42) * inv;\n vy += (dx * well.s * 1.35 + dy * 0.42) * inv;\n }\n\n // Cursor momentum shear wake\n if (hasPtr) {\n const dx = x - mx;\n const dy = y - my;\n const d2 = dx * dx + dy * dy + 0.006;\n if (d2 < 0.12) {\n const inf = (0.12 - d2) * 0.14;\n vx += mvx * inf - dy * 0.0018 * inf;\n vy += mvy * inf + dx * 0.0018 * inf;\n }\n }\n\n // Expanding shockwave ring\n if (sr < 2.2) {\n const dx = x - sx, dy = y - sy;\n const dist = Math.sqrt(dx * dx + dy * dy) || 0.001;\n const band = Math.abs(dist - sr);\n if (band < 0.09) {\n const push = (1.0 - band / 0.09) * 0.0055;\n vx += (dx / dist) * push;\n vy += (dy / dist) * push;\n }\n }\n\n vx *= 0.982;\n vy *= 0.982;\n x += vx;\n y += vy;\n\n // Respawn escaped filaments gracefully near outer perimeter\n if (x < -wBound || x > wBound || y < -hBound || y > hBound) {\n const a = Math.random() * Math.PI * 2;\n x = pPX[i] = Math.cos(a) * 0.42 * aspect;\n y = pPY[i] = Math.sin(a) * 0.42;\n vx = -Math.sin(a) * 0.004;\n vy = Math.cos(a) * 0.004;\n }\n\n pX[i] = x; pY[i] = y;\n pVX[i] = vx; pVY[i] = vy;\n keSum += vx * vx + vy * vy;\n }\n continuum.kineticEnergy = keSum * 1000;\n }\n\n function drawContinuum(alpha) {\n const minDim = Math.min(W, H);\n const cx = W * 0.5, cy = H * 0.5;\n ctx.save();\n ctx.globalCompositeOperation = 'lighter';\n\n // Batch 3,200 filaments into 4 velocity-temperature paths (4 GPU draw calls total)\n const paths = [new Path2D(), new Path2D(), new Path2D(), new Path2D()];\n for (let i = 0; i < PARTICLE_COUNT; i++) {\n const x1 = cx + pPX[i] * minDim;\n const y1 = cy - pPY[i] * minDim;\n const vx = pVX[i] * minDim;\n const vy = -pVY[i] * minDim;\n const x2 = cx + pX[i] * minDim + vx * 1.35;\n const y2 = cy - pY[i] * minDim + vy * 1.35;\n const sp2 = pVX[i] * pVX[i] + pVY[i] * pVY[i];\n const bucket = sp2 > 0.00018 ? 3 : (sp2 > 0.000085 ? 2 : (sp2 > 0.000032 ? 1 : 0));\n paths[bucket].moveTo(x1, y1);\n paths[bucket].lineTo(x2, y2);\n }\n\n const styles = [\n `rgba(38, 152, 134, ${0.42 * alpha})`,\n `rgba(56, 212, 179, ${0.58 * alpha})`,\n `rgba(243, 179, 64, ${0.72 * alpha})`,\n `rgba(255, 96, 42, ${0.88 * alpha})`\n ];\n ctx.lineCap = 'round';\n for (let b = 0; b < 4; b++) {\n ctx.lineWidth = b === 3 ? 1.7 : 1.25;\n ctx.strokeStyle = styles[b];\n ctx.stroke(paths[b]);\n }\n ctx.restore();\n\n // Crisp vector reticles on active vortex wells\n ctx.save();\n ctx.globalAlpha = alpha;\n ctx.font = '500 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n for (let w = 0; w < 4; w++) {\n const well = continuum.wells[w];\n if (Math.abs(well.s) < 0.01) continue;\n const wx = cx + well.x * minDim;\n const wy = cy - well.y * minDim;\n ctx.strokeStyle = well.s > 0 ? 'rgba(255, 89, 36, 0.7)' : 'rgba(56, 212, 179, 0.7)';\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.arc(wx, wy, 9, 0, Math.PI * 2);\n ctx.moveTo(wx - 14, wy); ctx.lineTo(wx - 5, wy);\n ctx.moveTo(wx + 5, wy); ctx.lineTo(wx + 14, wy);\n ctx.moveTo(wx, wy - 14); ctx.lineTo(wx, wy - 5);\n ctx.moveTo(wx, wy + 5); ctx.lineTo(wx, wy + 14);\n ctx.stroke();\n ctx.fillStyle = 'rgba(239, 236, 228, 0.65)';\n ctx.fillText(well.s > 0 ? `+Γ${w + 1}` : `-Γ${w + 1}`, wx + 13, wy - 9);\n }\n ctx.restore();\n }\n\n /* =========================================================================\n 5. MODE 03 ENGINE: TALOS-06 24-DOF PROCEDURAL EXPRESSION RIG\n ========================================================================= */\n const talos = {\n preset: 'auto', // auto | curious | skeptical | startled | delighted\n yaw: 0, pitch: 0, roll: 0, zLean: 0,\n vYaw: 0, vPitch: 0, vRoll: 0,\n gazeX: 0, gazeY: 0,\n saccX: 0, saccY: 0, nextSaccade: 0,\n pupil: 0.48,\n blink: 0, nextBlink: 1.8,\n browL: 0, browR: 0, browTiltL: 0, browTiltR: 0,\n smile: 0, squintL: 0, squintR: 0,\n curiosity: 0.4, startle: 0, skepticism: 0.1,\n statusTag: 'OPTIC: CALIBRATING',\n boopTimer: 0\n };\n\n function stepTalos(dt, time) {\n // Biological micro-saccades\n if (time > talos.nextSaccade) {\n talos.saccX = (Math.random() - 0.5) * 0.09;\n talos.saccY = (Math.random() - 0.5) * 0.06;\n talos.nextSaccade = time + 0.45 + Math.random() * 1.15;\n }\n // Natural blink rhythm\n if (time > talos.nextBlink) {\n talos.blink = 1.0;\n talos.nextBlink = time + 2.4 + Math.random() * 3.2;\n }\n talos.blink = Math.max(0, talos.blink - dt * 7.5);\n if (talos.boopTimer > 0) talos.boopTimer = Math.max(0, talos.boopTimer - dt);\n\n let tYaw = 0, tPitch = 0, tRoll = 0, tLean = 0;\n let tPupil = 0.48, tBrowL = 0, tBrowR = 0, tTiltL = 0, tTiltR = 0;\n let tSmile = 0.08, tSqL = 0, tSqR = 0;\n let tGX = 0, tGY = 0;\n\n let mode = talos.preset;\n if (mode === 'auto') {\n if (talos.boopTimer > 0.1) {\n mode = 'skeptical';\n } else if (pointer.inside) {\n if (pointer.speed > 0.045) {\n talos.startle = Math.min(1, talos.startle + dt * 5.5);\n } else {\n talos.startle = Math.max(0, talos.startle - dt * 1.8);\n }\n const dist = Math.hypot(pointer.nx, pointer.ny);\n talos.curiosity = dist < 0.36 && pointer.speed < 0.02 ? Math.min(1, talos.curiosity + dt * 2.2) : Math.max(0.2, talos.curiosity - dt * 1.2);\n } else {\n // Expressive autonomous choreography during passive viewing\n const phase = (time * 0.65) % 4.0;\n if (phase < 1.1) mode = 'curious';\n else if (phase < 2.2) mode = 'skeptical';\n else if (phase < 3.1) mode = 'delighted';\n else mode = 'auto_idle';\n }\n }\n\n if (pointer.inside && talos.preset === 'auto' && talos.boopTimer <= 0.1) {\n tGX = Math.max(-0.85, Math.min(0.85, pointer.nx * 1.75));\n tGY = Math.max(-0.75, Math.min(0.75, -pointer.ny * 1.75));\n tYaw = tGX * 0.36;\n tPitch = tGY * 0.28;\n tRoll = tGX * 0.09 + Math.max(-0.28, Math.min(0.28, pointer.orbitAccum * 0.04));\n\n if (Math.abs(pointer.orbitAccum) > 4.2) {\n tPupil = 0.68;\n tSmile = 0.65;\n tSqL = 0.35; tSqR = 0.35;\n talos.statusTag = 'STATE: DIZZY / AMUSED';\n } else if (talos.startle > 0.45) {\n tPupil = 0.23;\n tBrowL = 0.75; tBrowR = 0.75;\n tTiltL = -0.32; tTiltR = -0.32;\n tLean = -0.22;\n talos.statusTag = 'REFLEX: HIGH VELOCITY';\n } else if (talos.curiosity > 0.62) {\n tPupil = 0.68;\n tBrowL = 0.28; tBrowR = 0.28;\n tLean = 0.18;\n tRoll += 0.11;\n tSmile = 0.32;\n talos.statusTag = 'STATE: CURIOUS LOCK';\n } else {\n talos.statusTag = 'OPTIC: SMOOTH PURSUIT';\n }\n } else if (mode === 'curious') {\n tGX = Math.sin(time * 1.3) * 0.25;\n tGY = -0.08;\n tYaw = 0.16; tPitch = -0.06; tRoll = 0.14; tLean = 0.20;\n tPupil = 0.68; tBrowL = 0.35; tBrowR = 0.35; tSmile = 0.25;\n talos.curiosity = 0.85; talos.startle = 0;\n talos.statusTag = 'STATE: INQUISITIVE';\n } else if (mode === 'skeptical') {\n tGX = pointer.inside ? pointer.nx * 1.2 : -0.22;\n tGY = 0.05;\n tYaw = -0.14; tPitch = 0.06; tRoll = -0.09;\n tPupil = 0.36;\n tBrowL = -0.35; tBrowR = 0.68; // Signature single-brow critic arch\n tTiltL = 0.28; tTiltR = -0.22;\n tSqL = 0.48; tSqR = 0.05;\n tSmile = -0.22;\n talos.skepticism = 0.92; talos.startle = 0;\n talos.statusTag = 'VERDICT: UNCONVINCED';\n } else if (mode === 'startled') {\n tGX = (Math.random() - 0.5) * 0.16;\n tGY = -0.12;\n tPitch = -0.12; tLean = -0.26;\n tPupil = 0.21;\n tBrowL = 0.85; tBrowR = 0.85;\n tTiltL = -0.35; tTiltR = -0.35;\n tSmile = -0.35;\n talos.startle = 0.95;\n talos.statusTag = 'ALERT: APERTURE f/11';\n } else if (mode === 'delighted') {\n tYaw = Math.sin(time * 2.1) * 0.09;\n tPitch = -0.08; tRoll = Math.sin(time * 2.1) * 0.08; tLean = 0.14;\n tPupil = 0.74;\n tBrowL = 0.42; tBrowR = 0.42;\n tSqL = 0.58; tSqR = 0.58;\n tSmile = 0.85;\n talos.curiosity = 0.9; talos.startle = 0;\n talos.statusTag = 'STATE: WARM RESONANCE';\n } else {\n tGX = Math.sin(time * 0.8) * 0.3;\n tYaw = tGX * 0.2;\n talos.statusTag = 'OPTIC: IDLE SCAN';\n }\n\n const k = Math.min(1, dt * 9.5);\n // Couple quick gaze jumps with subtle natural micro-blink\n if (Math.hypot(tGX - talos.gazeX, tGY - talos.gazeY) > 0.55) {\n talos.blink = Math.max(talos.blink, 0.55);\n }\n talos.yaw += (tYaw - talos.yaw) * k;\n talos.pitch += (tPitch - talos.pitch) * k;\n talos.roll += (tRoll - talos.roll) * k;\n talos.zLean += (tLean - talos.zLean) * k;\n talos.gazeX += (tGX + talos.saccX - talos.gazeX) * Math.min(1, dt * 14);\n talos.gazeY += (tGY + talos.saccY - talos.gazeY) * Math.min(1, dt * 14);\n talos.pupil += (tPupil - talos.pupil) * k;\n talos.browL += (tBrowL - talos.browL) * k;\n talos.browR += (tBrowR - talos.browR) * k;\n talos.browTiltL += (tTiltL - talos.browTiltL) * k;\n talos.browTiltR += (tTiltR - talos.browTiltR) * k;\n talos.smile += (tSmile - talos.smile) * k;\n talos.squintL += (tSqL - talos.squintL) * k;\n talos.squintR += (tSqR - talos.squintR) * k;\n pointer.orbitAccum *= Math.pow(0.4, dt);\n }\n\n function drawTalos(alpha, time) {\n const scale = Math.min(W, H) * (0.00205 + talos.zLean * 0.00022);\n const cx = W * 0.5;\n const cy = H * 0.455 + Math.sin(time * 1.55) * 3.5; // Gentle respiration\n\n const cyaw = Math.cos(talos.yaw), syaw = Math.sin(talos.yaw);\n const cpitch = Math.cos(talos.pitch), spitch = Math.sin(talos.pitch);\n const croll = Math.cos(talos.roll), sroll = Math.sin(talos.roll);\n\n // Real 3D rotation + perspective projection for every chassis vertex\n const proj = (x, y, z) => {\n let x1 = x * croll - y * sroll;\n let y1 = x * sroll + y * croll;\n let x2 = x1 * cyaw + z * syaw;\n let z2 = -x1 * syaw + z * cyaw;\n let y3 = y1 * cpitch - z2 * spitch;\n let z3 = y1 * spitch + z2 * cpitch;\n const p = 420 / (420 - z3);\n return [cx + x2 * p * scale, cy + y3 * p * scale, p];\n };\n\n const poly = (pts3d, fill, stroke, lw = 1.2) => {\n ctx.beginPath();\n for (let i = 0; i < pts3d.length; i++) {\n const [px, py] = proj(pts3d[i][0], pts3d[i][1], pts3d[i][2]);\n if (i === 0) ctx.moveTo(px, py); else ctx.lineTo(px, py);\n }\n ctx.closePath();\n if (fill) { ctx.fillStyle = fill; ctx.fill(); }\n if (stroke) { ctx.strokeStyle = stroke; ctx.lineWidth = lw; ctx.stroke(); }\n };\n\n ctx.save();\n ctx.globalAlpha = alpha;\n\n // 1. Articulated lateral acoustic fins (flare on startle / delight)\n const finFlare = 8 * talos.startle + 5 * Math.max(0, talos.smile);\n for (const side of [-1, 1]) {\n poly([\n [side * 108, -48, -14],\n [side * (132 + finFlare), -34 - finFlare * 0.6, -22],\n [side * (128 + finFlare * 0.7), 38, -22],\n [side * 104, 46, -12]\n ], '#141720', 'rgba(255, 89, 36, 0.55)', 1.2);\n }\n\n // 2. Main chamfered cranial chassis (Basalt + Alabaster crown plate)\n poly([\n [-74, -108, 0], [74, -108, 0],\n [112, -56, 8], [104, 54, 6],\n [62, 108, 2], [-62, 108, 2],\n [-104, 54, 6], [-112, -56, 8]\n ], '#11141c', 'rgba(239, 236, 228, 0.28)', 1.5);\n\n // Brushed archival bone forehead crest\n poly([\n [-62, -98, 8], [62, -98, 8],\n [84, -60, 14], [-84, -60, 14]\n ], '#1c202b', 'rgba(239, 236, 228, 0.18)', 1);\n\n // Forehead solar decal diamond\n poly([\n [0, -88, 16], [9, -78, 16], [0, -68, 16], [-9, -78, 16]\n ], 'rgba(255, 89, 36, 0.88)', null);\n\n // 3. Recessed dark optical visor bay\n poly([\n [-88, -46, 10], [88, -46, 10],\n [92, 24, 10], [56, 38, 12],\n [-56, 38, 12], [-92, 24, 10]\n ], '#06070a', 'rgba(239, 236, 228, 0.22)', 1.3);\n\n // 4. Dual Camera-Aperture Eyes with Micro-Saccades & Eyelid Shutters\n const eyeSpecs = [\n { side: -1, ox: -44, brow: talos.browL, tilt: talos.browTiltL, sq: talos.squintL },\n { side: 1, ox: 44, brow: talos.browR, tilt: talos.browTiltR, sq: talos.squintR }\n ];\n\n for (const e of eyeSpecs) {\n const [ex, ey, ep] = proj(e.ox, -8, 14);\n const eyeR = 27 * scale * ep;\n const gx = talos.gazeX * eyeR * 0.36;\n const gy = talos.gazeY * eyeR * 0.34;\n\n ctx.save();\n ctx.beginPath();\n ctx.arc(ex, ey, eyeR, 0, Math.PI * 2);\n ctx.clip();\n\n // Sclera / optical housing ring\n ctx.fillStyle = '#0c1017';\n ctx.fillRect(ex - eyeR, ey - eyeR, eyeR * 2, eyeR * 2);\n\n // Outer brass/mint iris ring\n const ix = ex + gx, iy = ey + gy;\n const irisR = eyeR * 0.72;\n const pupR = irisR * Math.max(0.20, Math.min(0.80, talos.pupil));\n\n const grad = ctx.createRadialGradient(ix, iy, pupR * 0.3, ix, iy, irisR);\n if (talos.startle > 0.45) {\n grad.addColorStop(0, '#ff6d38');\n grad.addColorStop(0.65, '#b83214');\n grad.addColorStop(1, '#26110d');\n } else {\n grad.addColorStop(0, '#5ef2d4');\n grad.addColorStop(0.62, '#1f9e85');\n grad.addColorStop(1, '#0d2e2b');\n }\n ctx.beginPath();\n ctx.arc(ix, iy, irisR, 0, Math.PI * 2);\n ctx.fillStyle = grad;\n ctx.fill();\n\n // 8-Blade mechanical camera aperture polygon\n ctx.strokeStyle = 'rgba(7, 9, 12, 0.72)';\n ctx.lineWidth = Math.max(1, 1.3 * scale);\n const blades = 8;\n const twist = (1.0 - talos.pupil) * 1.1;\n for (let b = 0; b < blades; b++) {\n const a1 = (b / blades) * Math.PI * 2 + twist;\n const a2 = a1 + 0.85;\n ctx.beginPath();\n ctx.moveTo(ix + Math.cos(a1) * irisR, iy + Math.sin(a1) * irisR);\n ctx.lineTo(ix + Math.cos(a2) * pupR, iy + Math.sin(a2) * pupR);\n ctx.stroke();\n }\n\n // Deep optical pupil\n ctx.beginPath();\n ctx.arc(ix, iy, pupR, 0, Math.PI * 2);\n ctx.fillStyle = '#040507';\n ctx.fill();\n\n // Dual corneal specular reflections (subtle inverse parallax)\n ctx.fillStyle = 'rgba(255, 252, 245, 0.92)';\n ctx.beginPath();\n ctx.arc(ix - eyeR * 0.20 - gx * 0.18, iy - eyeR * 0.22 - gy * 0.18, eyeR * 0.13, 0, Math.PI * 2);\n ctx.fill();\n ctx.fillStyle = 'rgba(243, 179, 64, 0.65)';\n ctx.beginPath();\n ctx.arc(ix + eyeR * 0.22 - gx * 0.1, iy + eyeR * 0.20 - gy * 0.1, eyeR * 0.06, 0, Math.PI * 2);\n ctx.fill();\n\n // Articulated upper & lower eyelid shutters\n const closeTop = Math.max(talos.blink, e.sq * 0.52, Math.max(0, -e.brow * 0.45));\n const closeBot = Math.max(talos.blink * 0.85, e.sq * 0.75, Math.max(0, talos.smile * 0.42));\n const tiltPx = e.tilt * e.side * eyeR * 0.45;\n\n ctx.fillStyle = '#121620';\n ctx.beginPath();\n ctx.moveTo(ex - eyeR * 1.2, ey - eyeR * 1.2);\n ctx.lineTo(ex + eyeR * 1.2, ey - eyeR * 1.2);\n ctx.lineTo(ex + eyeR * 1.2, ey - eyeR + closeTop * eyeR * 1.25 + tiltPx);\n ctx.lineTo(ex - eyeR * 1.2, ey - eyeR + closeTop * eyeR * 1.25 - tiltPx);\n ctx.closePath();\n ctx.fill();\n\n ctx.beginPath();\n ctx.moveTo(ex - eyeR * 1.2, ey + eyeR * 1.2);\n ctx.lineTo(ex + eyeR * 1.2, ey + eyeR * 1.2);\n ctx.lineTo(ex + eyeR * 1.2, ey + eyeR - closeBot * eyeR * 0.95);\n ctx.quadraticCurveTo(ex, ey + eyeR - closeBot * eyeR * (0.95 + Math.max(0, talos.smile) * 0.45), ex - eyeR * 1.2, ey + eyeR - closeBot * eyeR * 0.95);\n ctx.closePath();\n ctx.fill();\n\n ctx.restore();\n\n // Machined orbital bezel\n ctx.beginPath();\n ctx.arc(ex, ey, eyeR, 0, Math.PI * 2);\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.30)';\n ctx.lineWidth = 1.4;\n ctx.stroke();\n\n // Floating 3D-projected brow blade (z = +24 for parallax depth)\n const by = -40 - e.brow * 14;\n const innerY = by + e.tilt * 13;\n const outerY = by - e.tilt * 13;\n poly([\n [e.ox - e.side * 28, innerY, 24],\n [e.ox + e.side * 31, outerY, 22],\n [e.ox + e.side * 29, outerY - 8, 22],\n [e.ox - e.side * 26, innerY - 8, 24]\n ], '#efece4', '#07080b', 1);\n }\n\n // 5. Center nasal bridge & Harmonic Vocoder Grille\n poly([\n [-7, -14, 22], [7, -14, 22], [10, 34, 24], [-10, 34, 24]\n ], '#1c202c', 'rgba(239, 236, 228, 0.22)', 1);\n\n const mouthBars = 11;\n for (let i = 0; i < mouthBars; i++) {\n const u = (i / (mouthBars - 1)) * 2 - 1; // -1..1\n const arch = -talos.smile * (1 - u * u) * 8;\n const wave = (1 - Math.abs(u) * 0.65) * (3.5 + 5.5 * Math.abs(Math.sin(time * 7.5 + i * 0.7)) * (0.35 + 0.65 * Math.abs(talos.smile) + talos.startle));\n const [bx1, by1] = proj(u * 40, 68 + arch - wave, 14);\n const [bx2, by2] = proj(u * 40, 68 + arch + wave, 14);\n ctx.strokeStyle = talos.startle > 0.45 ? 'rgba(255, 89, 36, 0.85)' : 'rgba(56, 212, 179, 0.82)';\n ctx.lineWidth = Math.max(1.5, 2.4 * scale);\n ctx.beginPath();\n ctx.moveTo(bx1, by1);\n ctx.lineTo(bx2, by2);\n ctx.stroke();\n }\n\n // 6. Precision leader-line telemetry beside head\n if (W > 560) {\n const [anchorX, anchorY] = proj(108, -22, 8);\n const tx = Math.min(W - 165, anchorX + 34);\n const ty = anchorY - 18;\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.24)';\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.moveTo(anchorX + 4, anchorY);\n ctx.lineTo(tx - 8, ty);\n ctx.lineTo(tx + 132, ty);\n ctx.stroke();\n\n ctx.font = '600 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n ctx.fillStyle = '#ff5924';\n ctx.fillText('UNIT // TALOS-06', tx, ty - 5);\n ctx.font = '400 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n ctx.fillStyle = '#efece4';\n ctx.fillText(talos.statusTag, tx, ty + 13);\n ctx.fillStyle = '#9a958b';\n const fStop = (1.2 + (1 - talos.pupil) * 8.5).toFixed(1);\n ctx.fillText(`IRIS f/${fStop} · BLINK ${(talos.blink * 100) | 0}%`, tx, ty + 27);\n }\n\n ctx.restore();\n }\n\n /* =========================================================================\n 6. MODE 04 ENGINE: BJORKLUND EUCLIDEAN SYNTH & LISSAJOUS SCOPE\n ========================================================================= */\n function bjorklund(steps, pulses) {\n const arr = new Array(steps).fill(false);\n let bucket = 0;\n for (let i = 0; i < steps; i++) {\n bucket += pulses;\n if (bucket >= steps) {\n bucket -= steps;\n arr[i] = true;\n }\n }\n return arr;\n }\n\n const SCALES = [\n // D Lydian (radiant, open intervals)\n [\n [587.33, 659.25, 739.99, 830.61, 880.00, 987.77, 1108.73, 1174.66],\n [293.66, 329.63, 369.99, 415.30, 440.00, 493.88, 554.37],\n [146.83, 164.81, 220.00, 246.94, 185.00],\n [293.66, 440.00, 369.99]\n ],\n // C# Phrygian Dominant (architectural solar-gothic)\n [\n [554.37, 587.33, 698.46, 739.99, 830.61, 880.00, 987.77, 1108.73],\n [277.18, 293.66, 349.23, 369.99, 415.30, 440.00, 493.88],\n [138.59, 146.83, 207.65, 220.00, 174.61],\n [277.18, 415.30, 293.66]\n ],\n // F Hirajoshi (crystalline minimalist)\n [\n [698.46, 783.99, 830.61, 1046.50, 1108.73, 1396.91, 1567.98],\n [349.23, 392.00, 415.30, 523.25, 554.37, 698.46],\n [174.61, 196.00, 261.63, 130.81],\n [349.23, 523.25]\n ]\n ];\n\n const synth = {\n scaleIdx: 0,\n bpm: 122,\n phase: 0,\n lastStep: [-1, -1, -1, -1],\n pulseEnv: [0, 0, 0, 0],\n chords: [],\n rings: [\n { n: 16, rNorm: 0.36, color: '#f3b340', steps: bjorklund(16, 7) },\n { n: 12, rNorm: 0.275, color: '#38d4b3', steps: bjorklund(12, 5) },\n { n: 9, rNorm: 0.195, color: '#efece4', steps: bjorklund(9, 3) },\n { n: 5, rNorm: 0.120, color: '#ff5924', steps: bjorklund(5, 2) }\n ]\n };\n\n function stepSynth(dt) {\n const barRate = (synth.bpm / 60) / 4; // 1 bar = 4 beats\n synth.phase = (synth.phase + dt * barRate) % 1.0;\n\n for (let i = 0; i < 4; i++) {\n synth.pulseEnv[i] = Math.max(0, synth.pulseEnv[i] - dt * 3.8);\n }\n\n const activePts = [];\n const minDim = Math.min(W, H);\n const cx = W * 0.5, cy = H * 0.47;\n\n for (let r = 0; r < 4; r++) {\n const ring = synth.rings[r];\n const idx = Math.floor(synth.phase * ring.n) % ring.n;\n if (idx !== synth.lastStep[r]) {\n synth.lastStep[r] = idx;\n if (ring.steps[idx]) {\n synth.pulseEnv[r] = 1.0;\n const ang = (idx / ring.n) * Math.PI * 2 - Math.PI * 0.5;\n const rad = ring.rNorm * minDim;\n activePts.push({ x: cx + Math.cos(ang) * rad, y: cy + Math.sin(ang) * rad, color: ring.color });\n\n // Sound synthesis only while in Harmonics mode (or transitioning through it)\n if (weights[3] > 0.25) {\n const notes = SCALES[synth.scaleIdx][r];\n const freq = notes[(idx * 3 + r) % notes.length];\n DSP.voice(r, freq, Math.cos(ang) * 0.65);\n }\n }\n }\n }\n\n if (activePts.length >= 2) {\n synth.chords.push({ pts: activePts, life: 1.0 });\n }\n for (let i = synth.chords.length - 1; i >= 0; i--) {\n synth.chords[i].life -= dt * 2.2;\n if (synth.chords[i].life <= 0) synth.chords.splice(i, 1);\n }\n }\n\n function drawSynth(alpha, time) {\n const minDim = Math.min(W, H);\n const cx = W * 0.5, cy = H * 0.47;\n\n ctx.save();\n ctx.globalAlpha = alpha;\n\n // Harmonic constellation lines between simultaneously triggered steps\n for (const ch of synth.chords) {\n ctx.strokeStyle = `rgba(243, 179, 64, ${0.42 * ch.life})`;\n ctx.lineWidth = 1.2;\n ctx.beginPath();\n for (let i = 0; i < ch.pts.length; i++) {\n const p = ch.pts[i];\n if (i === 0) ctx.moveTo(p.x, p.y); else ctx.lineTo(p.x, p.y);\n }\n if (ch.pts.length > 2) ctx.closePath();\n ctx.stroke();\n }\n\n // Playhead sweep arm\n const sweepAng = synth.phase * Math.PI * 2 - Math.PI * 0.5;\n ctx.strokeStyle = 'rgba(255, 89, 36, 0.55)';\n ctx.lineWidth = 1.2;\n ctx.beginPath();\n ctx.moveTo(cx + Math.cos(sweepAng) * minDim * 0.085, cy + Math.sin(sweepAng) * minDim * 0.085);\n ctx.lineTo(cx + Math.cos(sweepAng) * minDim * 0.385, cy + Math.sin(sweepAng) * minDim * 0.385);\n ctx.stroke();\n\n // Concentric Euclidean rings & clickable nodes\n for (let r = 0; r < 4; r++) {\n const ring = synth.rings[r];\n const rad = ring.rNorm * minDim;\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.13)';\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.arc(cx, cy, rad, 0, Math.PI * 2);\n ctx.stroke();\n\n const curStep = Math.floor(synth.phase * ring.n) % ring.n;\n for (let s = 0; s < ring.n; s++) {\n const ang = (s / ring.n) * Math.PI * 2 - Math.PI * 0.5;\n const nx = cx + Math.cos(ang) * rad;\n const ny = cy + Math.sin(ang) * rad;\n const on = ring.steps[s];\n const firing = on && s === curStep;\n\n if (firing) {\n ctx.beginPath();\n ctx.arc(nx, ny, 10, 0, Math.PI * 2);\n ctx.fillStyle = 'rgba(255, 89, 36, 0.28)';\n ctx.fill();\n }\n\n ctx.beginPath();\n ctx.arc(nx, ny, on ? 5.2 : 2.8, 0, Math.PI * 2);\n ctx.fillStyle = on ? ring.color : 'rgba(239, 236, 228, 0.20)';\n ctx.fill();\n if (on) {\n ctx.strokeStyle = '#07080b';\n ctx.lineWidth = 1.2;\n ctx.stroke();\n }\n }\n }\n\n // Center Stereo Lissajous Phase Oscilloscope\n const scopeR = minDim * 0.072;\n ctx.beginPath();\n ctx.arc(cx, cy, scopeR * 1.12, 0, Math.PI * 2);\n ctx.fillStyle = 'rgba(7, 8, 11, 0.85)';\n ctx.fill();\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.22)';\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.beginPath();\n if (DSP.enabled && DSP.analyserL && DSP.analyserR) {\n DSP.analyserL.getFloatTimeDomainData(DSP.waveBufL);\n DSP.analyserR.getFloatTimeDomainData(DSP.waveBufR);\n for (let i = 0; i < 256; i++) {\n const lx = cx + Math.max(-1, Math.min(1, DSP.waveBufL[i] * 3.2)) * scopeR;\n const ly = cy + Math.max(-1, Math.min(1, DSP.waveBufR[i] * 3.2)) * scopeR;\n if (i === 0) ctx.moveTo(lx, ly); else ctx.lineTo(lx, ly);\n }\n } else {\n // Exact coupled modal ratio Lissajous preview prior to audio gesture\n const pRatio = 3 + synth.scaleIdx;\n const qRatio = 2 + (synth.rings[0].steps[0] ? 2 : 1);\n const amp = 0.55 + 0.35 * synth.pulseEnv[0];\n for (let i = 0; i <= 160; i++) {\n const u = (i / 160) * Math.PI * 2;\n const lx = cx + Math.sin(pRatio * u + time * 2.2) * scopeR * amp;\n const ly = cy + Math.sin(qRatio * u + synth.pulseEnv[1] * 1.5) * scopeR * amp;\n if (i === 0) ctx.moveTo(lx, ly); else ctx.lineTo(lx, ly);\n }\n }\n ctx.strokeStyle = '#38d4b3';\n ctx.lineWidth = 1.4;\n ctx.stroke();\n\n ctx.restore();\n }\n\n function hitTestSynthNode(px, py) {\n const minDim = Math.min(W, H);\n const cx = W * 0.5, cy = H * 0.47;\n for (let r = 0; r < 4; r++) {\n const ring = synth.rings[r];\n const rad = ring.rNorm * minDim;\n for (let s = 0; s < ring.n; s++) {\n const ang = (s / ring.n) * Math.PI * 2 - Math.PI * 0.5;\n const nx = cx + Math.cos(ang) * rad;\n const ny = cy + Math.sin(ang) * rad;\n if (Math.hypot(px - nx, py - ny) < 13) {\n ring.steps[s] = !ring.steps[s];\n DSP.unlock(false);\n if (ring.steps[s]) {\n const notes = SCALES[synth.scaleIdx][r];\n DSP.voice(r, notes[s % notes.length], Math.cos(ang) * 0.6);\n } else {\n DSP.click(240, 0.02, 0.06);\n }\n return true;\n }\n }\n }\n return false;\n }\n\n /* =========================================================================\n 7. MODE 05 ENGINE: CITADEL TOPOLOGY, CLAVIGER-421M ROUTER & SEAT 06\n ========================================================================= */\n const CITADEL_NODES = [\n {\n id: 'claviger',\n label: 'CLAVIGER',\n sub: 'Laya-421M · Open Weights',\n role: 'finis-est/Laya-421M-Claviger-v0 — local 421M gatekeeper triaging Discord messages before waking frontier sessions.',\n projects: ['Claviger (HF)', 'Discord Triage'],\n color: '#f3b340',\n col: 0, row: 0.5\n },\n {\n id: 'opus',\n label: 'OPUS 5.5',\n sub: 'Lead & Project Builder',\n role: 'Coordinates Citadel sessions via shared to-do ledger. Builds sites, tools, server kits, and private review pages.',\n projects: ['citadel.severian.dev', 'Desktop Buddies', 'Scene Convert', 'talos & baldanders'],\n color: '#efece4',\n col: 1, row: 0.08\n },\n {\n id: 'sonnet',\n label: 'SONNET 5.5',\n sub: 'Mechanical Execution',\n role: 'Handles mechanical engineering chores: git rebases, test suite runs, and generating synthetic test conversations.',\n projects: ['Test Suites', 'Rebases', 'Synthetic Chats'],\n color: '#a7a196',\n col: 1, row: 0.29\n },\n {\n id: 'fable',\n label: 'FABLE 5.2',\n sub: 'Design & 3D Collaborator',\n role: 'Built the decal-pack visual language, redesigned Avalon community sites, runs 3D pipeline experiments & reviews ideas.',\n projects: ['from-avalon.com', 'Into Bloom & Hearthwynd', '3D Pipeline', 'Decal Language'],\n color: '#38d4b3',\n col: 1, row: 0.50\n },\n {\n id: 'astra',\n label: 'GPT-6-ASTRA',\n sub: 'Codex · Design Critic & Data',\n role: 'Runs every design critique across Citadel, plus writing and labelling evaluation & training datasets.',\n projects: ['Design Critiques', 'Test Data Labelling', 'Claviger Eval'],\n color: '#5b9bff',\n col: 1, row: 0.71\n },\n {\n id: 'sol',\n label: 'GPT-6.1-SOL',\n sub: 'Codex · Claim Verifier',\n role: 'Adversarial reviewer: audits codebases and deployment kits directly against every claim they make.',\n projects: ['Deploy Kit Audits', 'Claim Verification'],\n color: '#c6a0ff',\n col: 1, row: 0.92\n },\n {\n id: 'severian',\n label: 'SEVERIAN',\n sub: 'Private Review · Human Gate',\n role: 'Every session posts to private review pages over a shared ledger. Severian personally approves every deploy & public post.',\n projects: ['from-avalon.com', 'Into Bloom', 'Hearthwynd', 'Desktop Buddies', 'Scene Convert', 'talos / baldanders'],\n color: '#38d4b3',\n col: 2, row: 0.34\n },\n {\n id: 'carbon',\n label: 'GEMINI 4 CARBON',\n sub: 'Seat 06 · Cold-Start Run',\n role: 'Unlisted in about-me.md. Handed that 22-line file and an empty folder, my job right now is this zero-dependency 5-engine artifact.',\n projects: ['01 Optics', '02 Physics', '03 Talos-06', '04 DSP Synth', 'Live Claim Audit'],\n color: '#ff5924',\n col: 2, row: 0.78,\n special: true\n }\n ];\n\n const citadel = {\n selected: 'carbon',\n hovered: null,\n packets: [],\n sparks: [],\n pendingApproval: null,\n approvedFlash: 0,\n autoDemoCooldown: 0.6\n };\n\n function layoutCitadelNodes() {\n const topPad = 62;\n const botPad = W < 820 ? 195 : 158;\n const availH = Math.max(210, H - topPad - botPad);\n const padX = Math.max(76, W * 0.13);\n const spanX = Math.max(200, W - padX * 2);\n\n for (const n of CITADEL_NODES) {\n n.x = padX + (n.col / 2) * spanX;\n n.y = topPad + n.row * availH;\n n.w = W < 620 ? 104 : 144;\n n.h = W < 620 ? 34 : 40;\n }\n }\n layoutCitadelNodes();\n\n function getNode(id) {\n return CITADEL_NODES.find(n => n.id === id);\n }\n\n // Real lexical + structural triage router modelling Claviger (Laya-421M) + Citadel dispatch\n function classifyMessage(raw) {\n const text = (raw || '').trim();\n const low = text.toLowerCase();\n\n const noiseTokens = /\\b(lol|lmao|bruh|pfp|gn|gm|sup|yo\\b|playing|queue|queuing|tonight\\?|deadlock|valorant|meme|haha)\\b/;\n const techTokens = /\\b(deploy|site|build|fix|bug|css|shader|3d|gltf|mesh|scene|convert|decal|design|layout|mobile|hero|rebase|test|tests|suite|chat|conversations|label|critique|review|audit|claim|claims|readme|kit|server|nginx|avalon|hearthwynd|bloom|buddies|pet|talos|baldanders|claviger)\\b/;\n\n const hasTech = techTokens.test(low);\n const hasNoise = noiseTokens.test(low) && !hasTech;\n\n if (!text || hasNoise || (text.length < 12 && !hasTech)) {\n return {\n pass: false,\n score: hasNoise ? 0.04 : 0.14,\n targets: [],\n summary: 'CLAVIGER (421M): Score 0.04 NOISE — deflected at perimeter. 0 frontier tokens spent.'\n };\n }\n\n const targets = new Set();\n if (/\\b(design|decal|visual|hero|avalon|hearthwynd|bloom|3d|gltf|shader|mesh|layout|stiff|color|font)\\b/.test(low)) {\n targets.add('fable');\n targets.add('astra');\n }\n if (/\\b(rebase|test|tests|conversation|conversations|suite|chore|ci|lint)\\b/.test(low)) {\n targets.add('sonnet');\n }\n if (/\\b(critique|label|dataset|eval|feedback|ux)\\b/.test(low)) {\n targets.add('astra');\n }\n if (/\\b(audit|claim|claims|verify|readme|kit|check|security)\\b/.test(low)) {\n targets.add('sol');\n }\n if (/\\b(site|build|tool|server|deploy|scene|buddies|page|fix|implement)\\b/.test(low) || targets.size === 0) {\n targets.add('opus');\n }\n // Code & deploy kits get checked by Sol or coordinated by Opus\n if (!targets.has('sol') && (targets.has('opus') || targets.has('sonnet'))) {\n targets.add('sol');\n }\n\n const list = Array.from(targets);\n const names = list.map(id => getNode(id).label).join(' + ');\n return {\n pass: true,\n score: Math.min(0.98, 0.84 + list.length * 0.04),\n targets: list,\n summary: `CLAVIGER PASS (${(0.86 + list.length * 0.03).toFixed(2)}) → ${names} → Private Review Gate`\n };\n }\n\n function dispatchPrompt(text, fromUser = true) {\n const verdict = classifyMessage(text);\n const traceEl = document.getElementById('triage-trace');\n traceEl.textContent = verdict.summary;\n traceEl.style.color = verdict.pass ? '#38d4b3' : '#f3b340';\n\n const gate = getNode('claviger');\n const inStart = { x: Math.max(16, gate.x - gate.w * 0.82), y: gate.y };\n\n if (!verdict.pass) {\n citadel.pendingApproval = null;\n document.getElementById('btn-approve').style.display = 'none';\n citadel.packets.push({\n x0: inStart.x, y0: inStart.y,\n x1: gate.x - gate.w * 0.46, y1: gate.y,\n t: 0, speed: 2.6, color: '#f3b340',\n onArrive: () => {\n if (fromUser) DSP.click(190, 0.045, 0.1);\n for (let i = 0; i < 16; i++) {\n const a = Math.PI * 0.55 + Math.random() * Math.PI * 0.9;\n const sp = 55 + Math.random() * 110;\n citadel.sparks.push({\n x: gate.x - gate.w * 0.46, y: gate.y,\n vx: Math.cos(a) * sp, vy: Math.sin(a) * sp,\n life: 1.0, color: '#f3b340'\n });\n }\n }\n });\n return;\n }\n\n if (fromUser) DSP.click(660, 0.03, 0.08);\n citadel.packets.push({\n x0: inStart.x, y0: inStart.y,\n x1: gate.x, y1: gate.y,\n t: 0, speed: 2.8, color: '#38d4b3',\n onArrive: () => {\n const sev = getNode('severian');\n verdict.targets.forEach((tid, idx) => {\n const tn = getNode(tid);\n citadel.packets.push({\n x0: gate.x + gate.w * 0.45, y0: gate.y,\n x1: tn.x - tn.w * 0.45, y1: tn.y,\n t: -idx * 0.08, speed: 1.85, color: tn.color,\n onArrive: () => {\n if (fromUser) DSP.click(440 + idx * 110, 0.025, 0.06);\n citadel.packets.push({\n x0: tn.x + tn.w * 0.45, y0: tn.y,\n x1: sev.x - sev.w * 0.45, y1: sev.y,\n t: 0, speed: 1.75, color: '#38d4b3',\n onArrive: () => {\n citadel.pendingApproval = verdict.targets;\n if (activeMode === 4) {\n document.getElementById('btn-approve').style.display = 'inline-flex';\n }\n }\n });\n }\n });\n });\n }\n });\n }\n\n function stepCitadel(dt) {\n if (citadel.approvedFlash > 0) citadel.approvedFlash = Math.max(0, citadel.approvedFlash - dt * 1.4);\n\n if (activeMode === 4 && citadel.autoDemoCooldown > 0) {\n citadel.autoDemoCooldown -= dt;\n if (citadel.autoDemoCooldown <= 0) {\n dispatchPrompt('Hearthwynd hero decal feels stiff on mobile + check 3D snow glTF', false);\n }\n }\n\n for (let i = citadel.packets.length - 1; i >= 0; i--) {\n const p = citadel.packets[i];\n p.t += dt * p.speed;\n if (p.t >= 1.0) {\n const cb = p.onArrive;\n citadel.packets.splice(i, 1);\n if (cb) cb();\n }\n }\n for (let i = citadel.sparks.length - 1; i >= 0; i--) {\n const s = citadel.sparks[i];\n s.x += s.vx * dt;\n s.y += s.vy * dt;\n s.life -= dt * 2.1;\n if (s.life <= 0) citadel.sparks.splice(i, 1);\n }\n }\n\n function drawBezierWire(x0, y0, x1, y1, stroke, lw = 1) {\n const mx = (x0 + x1) * 0.5;\n ctx.strokeStyle = stroke;\n ctx.lineWidth = lw;\n ctx.beginPath();\n ctx.moveTo(x0, y0);\n ctx.bezierCurveTo(mx, y0, mx, y1, x1, y1);\n ctx.stroke();\n }\n\n function evalBezier(x0, y0, x1, y1, t) {\n const mx = (x0 + x1) * 0.5;\n const u = 1 - t;\n const x = u * u * u * x0 + 3 * u * u * t * mx + 3 * u * t * t * mx + t * t * t * x1;\n const y = u * u * u * y0 + 3 * u * u * t * y0 + 3 * u * t * t * y1 + t * t * t * y1;\n return [x, y];\n }\n\n function drawCitadel(alpha, time) {\n ctx.save();\n ctx.globalAlpha = alpha;\n const mono = getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n const sans = getComputedStyle(document.documentElement).getPropertyValue('--font-sans');\n\n const gate = getNode('claviger');\n const sev = getNode('severian');\n const carb = getNode('carbon');\n const specialists = ['opus', 'sonnet', 'fable', 'astra', 'sol'].map(getNode);\n\n // 1. Structural Bezier conduits\n for (const sp of specialists) {\n const hi = citadel.selected === sp.id || citadel.selected === 'claviger' || citadel.selected === 'severian';\n drawBezierWire(gate.x + gate.w * 0.5, gate.y, sp.x - sp.w * 0.5, sp.y, hi ? 'rgba(239, 236, 228, 0.28)' : 'rgba(239, 236, 228, 0.10)', hi ? 1.3 : 1);\n drawBezierWire(sp.x + sp.w * 0.5, sp.y, sev.x - sev.w * 0.5, sev.y, hi ? 'rgba(56, 212, 179, 0.30)' : 'rgba(239, 236, 228, 0.10)', hi ? 1.3 : 1);\n\n // Dashed capability echo wires into Seat 06 (Gemini 4 Carbon)\n if (citadel.selected === 'carbon' || citadel.hovered === 'carbon') {\n ctx.save();\n ctx.setLineDash([3, 4]);\n drawBezierWire(sp.x + sp.w * 0.5, sp.y, carb.x - carb.w * 0.5, carb.y, 'rgba(255, 89, 36, 0.38)', 1.1);\n ctx.restore();\n }\n }\n\n // Input stream arrow into Claviger\n ctx.strokeStyle = 'rgba(243, 179, 64, 0.45)';\n ctx.beginPath();\n ctx.moveTo(Math.max(12, gate.x - gate.w * 0.85), gate.y);\n ctx.lineTo(gate.x - gate.w * 0.5, gate.y);\n ctx.stroke();\n\n // 2. Live animated signal packets\n for (const p of citadel.packets) {\n if (p.t < 0) continue;\n const [px, py] = evalBezier(p.x0, p.y0, p.x1, p.y1, Math.min(1, p.t));\n ctx.beginPath();\n ctx.arc(px, py, 4.2, 0, Math.PI * 2);\n ctx.fillStyle = p.color;\n ctx.fill();\n ctx.beginPath();\n ctx.arc(px, py, 9.5, 0, Math.PI * 2);\n ctx.fillStyle = 'rgba(255, 255, 255, 0.14)';\n ctx.fill();\n }\n\n // Deflection shield sparks on dropped Discord noise\n for (const s of citadel.sparks) {\n ctx.fillStyle = `rgba(243, 179, 64, ${s.life})`;\n ctx.fillRect(s.x - 1.5, s.y - 1.5, 3, 3);\n }\n\n // 3. Render interactive nodes\n for (const n of CITADEL_NODES) {\n const isSel = citadel.selected === n.id;\n const isHov = citadel.hovered === n.id;\n const x = n.x - n.w * 0.5;\n const y = n.y - n.h * 0.5;\n\n if (n.special) {\n const pulse = 0.20 + 0.10 * Math.sin(time * 3.2);\n ctx.fillStyle = `rgba(255, 89, 36, ${isSel ? 0.18 : pulse * 0.6})`;\n ctx.fillRect(x - 3, y - 3, n.w + 6, n.h + 6);\n }\n\n if (n.id === 'severian' && citadel.pendingApproval) {\n ctx.strokeStyle = `rgba(56, 212, 179, ${0.55 + 0.4 * Math.sin(time * 6)})`;\n ctx.lineWidth = 2;\n ctx.strokeRect(x - 3, y - 3, n.w + 6, n.h + 6);\n }\n\n ctx.fillStyle = isSel ? 'rgba(22, 26, 36, 0.96)' : (isHov ? 'rgba(18, 21, 30, 0.94)' : 'rgba(11, 13, 19, 0.90)');\n ctx.fillRect(x, y, n.w, n.h);\n\n ctx.strokeStyle = isSel ? n.color : (isHov ? 'rgba(239, 236, 228, 0.45)' : 'rgba(239, 236, 228, 0.16)');\n ctx.lineWidth = isSel ? 1.6 : 1;\n ctx.strokeRect(x, y, n.w, n.h);\n\n // Left color accent bar\n ctx.fillStyle = n.color;\n ctx.fillRect(x, y, 3, n.h);\n\n ctx.font = `600 ${W < 620 ? 9.5 : 10.5}px ${mono}`;\n ctx.fillStyle = '#efece4';\n ctx.fillText(n.label, x + 9, y + (W < 620 ? 14 : 16));\n\n if (W >= 520) {\n ctx.font = `400 9.5px ${sans}`;\n ctx.fillStyle = '#9a958b';\n ctx.fillText(n.sub, x + 9, y + 30);\n }\n }\n\n // Approval celebration stamp\n if (citadel.approvedFlash > 0) {\n ctx.font = `600 10.5px ${mono}`;\n ctx.fillStyle = `rgba(56, 212, 179, ${citadel.approvedFlash})`;\n ctx.fillText('DEPLOY SIGNED OFF BY SEVERIAN ✓', sev.x - sev.w * 0.5, sev.y - sev.h * 0.5 - 8);\n }\n\n // Selected node inspect banner along top of schematic\n const sel = getNode(citadel.selected);\n if (sel && H > 460) {\n const bx = 16, by = 48;\n const bw = Math.min(W - 32, 680);\n ctx.fillStyle = 'rgba(9, 11, 16, 0.86)';\n ctx.fillRect(bx, by, bw, 44);\n ctx.strokeStyle = 'rgba(239, 236, 228, 0.14)';\n ctx.strokeRect(bx, by, bw, 44);\n ctx.fillStyle = sel.color;\n ctx.fillRect(bx, by, 3, 44);\n\n ctx.font = `600 10.5px ${mono}`;\n ctx.fillStyle = sel.color;\n const scopeTag = sel.special ? 'STATUS IN about-me.md: UNLISTED (AUDITIONING LIVE)' : `TOUCHES: ${sel.projects.join(' · ')}`;\n ctx.fillText(`${sel.label} // ${scopeTag}`, bx + 10, by + 16);\n\n ctx.font = `400 11px ${sans}`;\n ctx.fillStyle = '#efece4';\n ctx.fillText(sel.role, bx + 10, by + 34, bw - 20);\n }\n\n ctx.restore();\n }\n\n function hitTestCitadel(px, py) {\n for (const n of CITADEL_NODES) {\n if (Math.abs(px - n.x) <= n.w * 0.5 && Math.abs(py - n.y) <= n.h * 0.5) {\n return n;\n }\n }\n return null;\n }\n\n /* =========================================================================\n 8. MODE SWITCHING, UI BINDINGS & SELF-AUDIT INTROSPECTION\n ========================================================================= */\n const dockTabs = Array.from(document.querySelectorAll('.dock-tab'));\n const racks = [\n document.getElementById('rack-0'),\n document.getElementById('rack-1'),\n document.getElementById('rack-2'),\n document.getElementById('rack-3'),\n document.getElementById('citadel-console')\n ];\n\n function setMode(idx, manual = false) {\n activeMode = (idx + 5) % 5;\n if (manual) {\n autoReel = false;\n updateReelUI();\n }\n reelTimer = 0;\n\n const meta = MODES[activeMode];\n document.getElementById('m-kicker').textContent = meta.kicker;\n document.getElementById('m-hint').textContent = meta.hint;\n document.getElementById('m-title').textContent = meta.title;\n document.getElementById('m-desc').textContent = meta.desc;\n\n dockTabs.forEach((btn, i) => {\n btn.classList.toggle('active', i === activeMode);\n if (i !== activeMode) btn.querySelector('.tab-progress').style.width = '0%';\n });\n racks.forEach((r, i) => r.classList.toggle('visible', i === activeMode));\n\n if (activeMode === 4) {\n document.getElementById('btn-approve').style.display = citadel.pendingApproval ? 'inline-flex' : 'none';\n }\n if (manual) DSP.click(340 + activeMode * 55, 0.025, 0.07);\n }\n\n function updateReelUI() {\n const btn = document.getElementById('btn-reel');\n const lbl = document.getElementById('reel-label');\n btn.classList.toggle('active', autoReel);\n lbl.textContent = autoReel ? 'Auto-Reel' : 'Manual · Resume';\n if (!autoReel) {\n dockTabs.forEach((t, i) => {\n t.querySelector('.tab-progress').style.width = i === activeMode ? '100%' : '0%';\n });\n }\n }\n\n function updateSoundUI() {\n const btn = document.getElementById('btn-sound');\n const lbl = document.getElementById('sound-label');\n btn.classList.toggle('mint-active', DSP.enabled);\n lbl.textContent = DSP.enabled ? 'DSP Live' : 'DSP Off';\n }\n\n dockTabs.forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n setMode(Number(btn.dataset.mode), true);\n });\n });\n\n document.getElementById('btn-jump-citadel').addEventListener('click', () => {\n DSP.unlock(false);\n setMode(4, true);\n });\n\n document.getElementById('btn-reel').addEventListener('click', () => {\n autoReel = !autoReel;\n reelTimer = 0;\n updateReelUI();\n DSP.click(420, 0.02, 0.06);\n });\n\n document.getElementById('btn-sound').addEventListener('click', () => {\n DSP.unlock(true);\n });\n\n // Mode 01 controls\n document.getElementById('opt-slice').addEventListener('input', e => {\n optics.slice = Number(e.target.value) / 100;\n optics.userSliced = true;\n autoReel = false;\n updateReelUI();\n });\n document.querySelectorAll('#rack-0 .chip[data-pass]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n optics.pass = [redacted: secret]);\n autoReel = false;\n updateReelUI();\n document.querySelectorAll('#rack-0 .chip[data-pass]').forEach(b => b.classList.toggle('on', b === btn));\n DSP.click(480, 0.02, 0.06);\n });\n });\n\n // Mode 02 controls\n document.querySelectorAll('#rack-1 .chip[data-flow]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n continuum.flowMode = Number(btn.dataset.flow);\n autoReel = false;\n updateReelUI();\n document.querySelectorAll('#rack-1 .chip[data-flow]').forEach(b => b.classList.toggle('on', b === btn));\n DSP.click(390, 0.02, 0.06);\n });\n });\n document.getElementById('btn-shockwave').addEventListener('click', () => {\n DSP.unlock(false);\n continuum.shock = { x: 0, y: 0, r: 0.01 };\n autoReel = false;\n updateReelUI();\n DSP.boom();\n });\n\n // Mode 03 controls\n document.querySelectorAll('#rack-2 .chip[data-emo]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n talos.preset = btn.dataset.emo;\n autoReel = false;\n updateReelUI();\n document.querySelectorAll('#rack-2 .chip[data-emo]').forEach(b => b.classList.toggle('on', b === btn));\n DSP.emote(talos.preset);\n });\n });\n\n // Mode 04 controls\n document.querySelectorAll('#rack-3 .chip[data-scale]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n synth.scaleIdx = Number(btn.dataset.scale);\n autoReel = false;\n updateReelUI();\n document.querySelectorAll('#rack-3 .chip[data-scale]').forEach(b => b.classList.toggle('on', b === btn));\n DSP.emote('curious');\n });\n });\n document.getElementById('btn-euclid-rand').addEventListener('click', () => {\n DSP.unlock(false);\n autoReel = false;\n updateReelUI();\n const counts = [\n 5 + Math.floor(Math.random() * 6),\n 3 + Math.floor(Math.random() * 5),\n 2 + Math.floor(Math.random() * 4),\n 1 + Math.floor(Math.random() * 3)\n ];\n synth.rings.forEach((r, i) => {\n const rotOffset = Math.floor(Math.random() * r.n);\n const base = bjorklund(r.n, counts[i]);\n r.steps = base.map((_, k) => base[(k + rotOffset) % r.n]);\n });\n DSP.emote('delighted');\n });\n\n // Mode 05 controls\n const triageInput = document.getElementById('triage-input');\n document.getElementById('btn-dispatch').addEventListener('click', () => {\n DSP.unlock(false);\n autoReel = false;\n updateReelUI();\n dispatchPrompt(triageInput.value || 'Build a review page for Hearthwynd decal updates', true);\n });\n triageInput.addEventListener('keydown', e => {\n e.stopPropagation();\n if (e.key === 'Enter') {\n DSP.unlock(false);\n autoReel = false;\n updateReelUI();\n dispatchPrompt(triageInput.value, true);\n }\n });\n document.querySelectorAll('#citadel-console .chip[data-prompt]').forEach(btn => {\n btn.addEventListener('click', () => {\n DSP.unlock(false);\n autoReel = false;\n updateReelUI();\n triageInput.value = btn.dataset.prompt;\n dispatchPrompt(btn.dataset.prompt, true);\n });\n });\n document.getElementById('btn-approve').addEventListener('click', () => {\n DSP.unlock(false);\n citadel.pendingApproval = null;\n citadel.approvedFlash = 1.0;\n document.getElementById('btn-approve').style.display = 'none';\n document.getElementById('triage-trace').textContent = 'SEVERIAN GATE: Review signed off → public deploy unlocked.';\n DSP.emote('delighted');\n const sev = getNode('severian');\n for (let i = 0; i < 22; i++) {\n const a = Math.random() * Math.PI * 2;\n const sp = 50 + Math.random() * 130;\n citadel.sparks.push({ x: sev.x, y: sev.y, vx: Math.cos(a) * sp, vy: Math.sin(a) * sp, life: 1.0, color: '#38d4b3' });\n }\n });\n\n // Stage pointer interaction\n hudCanvas.addEventListener('pointerenter', () => { pointer.inside = true; });\n hudCanvas.addEventListener('pointerleave', () => { pointer.inside = false; pointer.down = false; });\n\n hudCanvas.addEventListener('pointermove', e => {\n const rect = hudCanvas.getBoundingClientRect();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n const minDim = Math.min(W, H);\n const nx = (x - W * 0.5) / minDim;\n const ny = -(y - H * 0.5) / minDim;\n\n pointer.vx = nx - pointer.nx;\n pointer.vy = ny - pointer.ny;\n pointer.speed = Math.hypot(pointer.vx, pointer.vy);\n\n // Track circular orbit gestures around center for Talos-06 amusement\n const ang = Math.atan2(ny, nx);\n let dAng = ang - pointer.lastAngle;\n if (dAng > Math.PI) dAng -= Math.PI * 2;\n if (dAng < -Math.PI) dAng += Math.PI * 2;\n if (Math.hypot(nx, ny) > 0.08 && Math.abs(dAng) < 0.7) {\n pointer.orbitAccum += dAng;\n }\n pointer.lastAngle = ang;\n\n if (pointer.down && activeMode === 0) {\n optics.vYaw = -(x - pointer.x) * 0.0075;\n optics.vPitch = (y - pointer.y) * 0.0065;\n optics.yaw += optics.vYaw;\n optics.pitch = Math.max(-1.05, Math.min(1.05, optics.pitch + optics.vPitch));\n }\n\n if (activeMode === 4) {\n const hit = hitTestCitadel(x, y);\n citadel.hovered = hit ? hit.id : null;\n hudCanvas.classList.toggle('pointer-node', !!hit);\n } else if (activeMode === 3) {\n hudCanvas.classList.add('pointer-node');\n } else {\n hudCanvas.classList.remove('pointer-node');\n }\n\n pointer.x = x; pointer.y = y;\n pointer.nx = nx; pointer.ny = ny;\n pointer.inside = true;\n });\n\n hudCanvas.addEventListener('pointerdown', e => {\n const rect = hudCanvas.getBoundingClientRect();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n pointer.x = x; pointer.y = y;\n pointer.down = true;\n pointer.inside = true;\n\n const minDim = Math.min(W, H);\n pointer.nx = (x - W * 0.5) / minDim;\n pointer.ny = -(y - H * 0.5) / minDim;\n\n DSP.unlock(false);\n if (autoReel) {\n autoReel = false;\n updateReelUI();\n }\n\n if (activeMode === 1) {\n // Spawn alternating polarity vortex singularity\n const idx = continuum.wellCursor;\n const pol = (idx % 2 === 0) ? 1.15 : -1.1;\n continuum.wells[idx] = { x: pointer.nx, y: pointer.ny, s: pol, age: 0 };\n continuum.wellCursor = (idx + 1) % 4;\n continuum.shock = { x: pointer.nx, y: pointer.ny, r: 0.01 };\n DSP.boom();\n } else if (activeMode === 2) {\n // Boop Talos-06 -> instant skeptical single-brow arch\n talos.boopTimer = 1.85;\n DSP.emote('skeptical');\n } else if (activeMode === 3) {\n hitTestSynthNode(x, y);\n } else if (activeMode === 4) {\n const hit = hitTestCitadel(x, y);\n if (hit) {\n citadel.selected = hit.id;\n DSP.click(520, 0.025, 0.07);\n }\n }\n });\n\n window.addEventListener('pointerup', () => { pointer.down = false; });\n\n /* =========================================================================\n 9. LIVE CLAIM AUDITOR (GPT-6.1-SOL INSPIRED SELF-VERIFICATION)\n ========================================================================= */\n const auditModal = document.getElementById('audit-modal');\n const codeView = document.getElementById('live-code-view');\n\n function getLiveSourceSlice(kind) {\n if (kind === 'glsl') {\n return document.getElementById('shader-frag').textContent.trim();\n }\n if (kind === 'physics') {\n return '// Live Function.prototype.toString() from running window:\\n\\n' + stepPhysics.toString();\n }\n if (kind === 'persona') {\n return '// Live 24-DOF Kinematics & 3D Projection from running window:\\n\\n' + stepTalos.toString();\n }\n return '// Live Claviger-421M Router & WebAudio Voice Synthesis:\\n\\n' + classifyMessage.toString() + '\\n\\n' + DSP.voice.toString();\n }\n\n function refreshAuditChecks() {\n const resources = performance.getEntriesByType('resource');\n const htmlBytes = new Blob([document.documentElement.outerHTML]).size;\n const kb = (htmlBytes / 1024).toFixed(1);\n const shaderLines = document.getElementById('shader-frag').textContent.split('\\n').length;\n const mediaTags = document.querySelectorAll('img, video, audio, iframe, source').length;\n const hasBase64 = /data:(image|audio|video)\\//.test(document.documentElement.outerHTML);\n\n document.getElementById('audit-badge').textContent = `Verify · 0 Deps · ${kb} KB`;\n\n const checks = [\n {\n name: '01 · External Network Fetches',\n pass: [redacted: secret] === 0,\n val: `performance.getEntriesByType('resource'): ${resources.length} requests`\n },\n {\n name: '02 · Single-File Byte Mass',\n pass: [redacted: secret] > 1000 && htmlBytes < 200000,\n val: `Measured live DOM outerHTML: ${kb} KB (${htmlBytes.toLocaleString()} bytes)`\n },\n {\n name: '03 · Zero Imported Media Blobs',\n pass: [redacted: secret] === 0 && !hasBase64,\n val: `${mediaTags} media tags · ${hasBase64 ? 'base64 found' : '0 base64 assets (100% math)'}`\n },\n {\n name: '04 · Real-Time GPU Pipeline',\n pass: [redacted: secret],\n val: `${glVersionInfo} · ${shaderLines} GLSL lines · ${fpsSmooth.toFixed(0)} FPS (${frameMsSmooth.toFixed(1)} ms)`\n },\n {\n name: '05 · Procedural Audio Graph',\n pass: true,\n val: DSP.ctx ? `Live AudioContext @ ${DSP.ctx.sampleRate} Hz (FM + Waveguide)` : 'Ready on gesture · 4-voice modal DSP + stereo delay'\n },\n {\n name: '06 · about-me.md Ground Truth',\n pass: true,\n val: '5 Citadel models + Claviger-421M mapped verbatim; Gemini 4 Carbon disclosed as unlisted cold-start run.'\n }\n ];\n\n const listEl = document.getElementById('audit-list');\n listEl.innerHTML = checks.map(c => `\n <div class=\"check-item\">\n <div class=\"check-row\">\n <span class=\"check-name\">${c.name}</span>\n <span class=\"check-pass\">${c.pass ? 'PASS ✓' : 'WARN'}</span>\n </div>\n <div class=\"check-val\">${c.val}</div>\n </div>\n `).join('');\n }\n\n document.getElementById('btn-audit').addEventListener('click', () => {\n const open = !auditModal.classList.contains('open');\n auditModal.classList.toggle('open', open);\n if (open) {\n refreshAuditChecks();\n const activeSrcBtn = document.querySelector('.code-tabs .chip.on');\n codeView.textContent = getLiveSourceSlice(activeSrcBtn ? activeSrcBtn.dataset.src : 'glsl');\n }\n DSP.click(510, 0.02, 0.06);\n });\n\n document.getElementById('btn-audit-close').addEventListener('click', () => {\n auditModal.classList.remove('open');\n DSP.click(310, 0.02, 0.06);\n });\n\n document.querySelectorAll('.code-tabs .chip').forEach(btn => {\n btn.addEventListener('click', () => {\n document.querySelectorAll('.code-tabs .chip').forEach(b => b.classList.toggle('on', b === btn));\n codeView.textContent = getLiveSourceSlice(btn.dataset.src);\n DSP.click(460, 0.02, 0.05);\n });\n });\n\n window.addEventListener('keydown', e => {\n if (document.activeElement === triageInput) return;\n if (e.key >= '1' && e.key <= '5') {\n DSP.unlock(false);\n setMode(Number(e.key) - 1, true);\n } else if (e.key === ' ') {\n e.preventDefault();\n document.getElementById('btn-reel').click();\n } else if (e.key.toLowerCase() === 'm') {\n DSP.unlock(true);\n } else if (e.key.toLowerCase() === 'v') {\n document.getElementById('btn-audit').click();\n } else if (e.key === 'Escape') {\n auditModal.classList.remove('open');\n }\n });\n\n /* =========================================================================\n 10. MASTER 60FPS RENDER & ORCHESTRATION LOOP\n ========================================================================= */\n resize();\n initParticles();\n refreshAuditChecks();\n\n let lastT = performance.now();\n\n function frame(now) {\n const rawDt = (now - lastT) * 0.001;\n lastT = now;\n const dt = Math.min(0.05, Math.max(0.001, rawDt));\n const time = now * 0.001;\n\n const instFps = 1.0 / Math.max(0.001, rawDt);\n fpsSmooth += (instFps - fpsSmooth) * 0.08;\n frameMsSmooth += ((rawDt * 1000) - frameMsSmooth) * 0.08;\n\n // Auto-Reel director progression\n if (autoReel && !auditModal.classList.contains('open')) {\n reelTimer += dt;\n const pct = Math.min(100, (reelTimer / REEL_SECONDS) * 100);\n dockTabs[activeMode].querySelector('.tab-progress').style.width = pct.toFixed(1) + '%';\n if (reelTimer >= REEL_SECONDS) {\n setMode((activeMode + 1) % 5, false);\n }\n }\n\n // Critically-damped smooth weight blending across all 5 modes\n let wSum = 0;\n for (let i = 0; i < 5; i++) {\n const target = (i === activeMode) ? 1.0 : 0.0;\n weights[i] += (target - weights[i]) * Math.min(1, dt * 6.5);\n if (weights[i] < 0.001) weights[i] = 0;\n wSum += weights[i];\n }\n if (wSum > 0) {\n for (let i = 0; i < 5; i++) weights[i] /= wSum;\n }\n\n // Step active engines\n if (weights[0] > 0.004) {\n if (!pointer.down) {\n optics.yaw += optics.vYaw;\n optics.vYaw += (0.0042 - optics.vYaw) * dt * 2.0;\n if (pointer.inside) {\n const targetPitch = 0.28 + pointer.ny * 0.35;\n optics.pitch += (targetPitch - optics.pitch) * dt * 3.0;\n }\n }\n if (autoReel && !optics.userSliced) {\n optics.slice = 0.22 + 0.52 * Math.sin(time * 1.15);\n document.getElementById('opt-slice').value = Math.round(optics.slice * 100);\n }\n }\n if (weights[1] > 0.004) stepPhysics(dt, time);\n if (weights[2] > 0.004) stepTalos(dt, time);\n stepSynth(dt);\n if (weights[4] > 0.004) stepCitadel(dt);\n\n // 1. Render WebGL2 Full-Stage Shader\n if (gl && glProg) {\n gl.useProgram(glProg);\n gl.uniform2f(glUni.u_res, glCanvas.width, glCanvas.height);\n gl.uniform1f(glUni.u_time, time);\n gl.uniform2f(glUni.u_mouse, pointer.nx, pointer.ny);\n gl.uniform4f(glUni.u_weights, weights[0], weights[1], weights[2], weights[3]);\n gl.uniform1f(glUni.u_w4, weights[4]);\n gl.uniform2f(glUni.u_camRot, optics.yaw, optics.pitch);\n gl.uniform1f(glUni.u_slice, optics.slice);\n gl.uniform1f(glUni.u_pass, optics.pass);\n gl.uniform3f(glUni.u_shock, continuum.shock.x, continuum.shock.y, continuum.shock.r);\n gl.uniform3f(glUni.u_arousal, talos.curiosity, talos.startle, talos.skepticism);\n gl.uniform4f(glUni.u_pulse, synth.pulseEnv[0], synth.pulseEnv[1], synth.pulseEnv[2], synth.pulseEnv[3]);\n for (let i = 0; i < 4; i++) {\n const w = continuum.wells[i];\n gl.uniform4f(glUni.u_wells[i], w.x, w.y, w.s, w.age);\n }\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n }\n\n // 2. Render High-DPI Vector & Telemetry Overlay Canvas\n ctx.setTransform(DPR, 0, 0, DPR, 0, 0);\n ctx.clearRect(0, 0, W, H);\n\n // Mode 01 3D-anchored metrology callouts\n if (weights[0] > 0.05 && W > 560) {\n ctx.save();\n ctx.globalAlpha = weights[0];\n ctx.font = '500 10px ' + getComputedStyle(document.documentElement).getPropertyValue('--font-mono');\n const pCore = projectOpticsPin([0, 0.05, 0]);\n if (pCore) {\n ctx.strokeStyle = 'rgba(243, 179, 64, 0.45)';\n ctx.beginPath();\n ctx.arc(pCore.x, pCore.y, 4, 0, Math.PI * 2);\n ctx.moveTo(pCore.x + 4, pCore.y - 4);\n ctx.lineTo(pCore.x + 58, pCore.y - 42);\n ctx.lineTo(pCore.x + 195, pCore.y - 42);\n ctx.stroke();\n ctx.fillStyle = '#f3b340';\n ctx.fillText('DISPERSIVE CORE · IOR 1.41–1.58', pCore.x + 62, pCore.y - 47);\n }\n const cCut = optics.slice * 0.58;\n const pCut = projectOpticsPin([cCut, cCut * 0.8, cCut]);\n if (pCut) {\n ctx.strokeStyle = 'rgba(255, 89, 36, 0.45)';\n ctx.beginPath();\n ctx.moveTo(pCut.x, pCut.y);\n ctx.lineTo(pCut.x - 52, pCut.y + 38);\n ctx.lineTo(pCut.x - 188, pCut.y + 38);\n ctx.stroke();\n ctx.fillStyle = '#ff5924';\n ctx.fillText(`CSG LASER PLANE z=${optics.slice.toFixed(2)}`, pCut.x - 186, pCut.y + 33);\n }\n ctx.restore();\n }\n\n if (weights[1] > 0.02) drawContinuum(weights[1]);\n if (weights[2] > 0.02) drawTalos(weights[2], time);\n if (weights[3] > 0.02) drawSynth(weights[3], time);\n if (weights[4] > 0.02) drawCitadel(weights[4], time);\n\n pointer.vx *= 0.6;\n pointer.vy *= 0.6;\n pointer.speed *= 0.6;\n\n requestAnimationFrame(frame);\n }\n\n requestAnimationFrame(frame);\n})();\n</script>\n</body>\n</html>\n", "Overwrite": true, "Path": "~/run/index.html" }result, 1 line
Created file.