(() => { if (window.SanxiaYoulunChatLoaded) return; window.SanxiaYoulunChatLoaded = true; const cfg = window.SanxiaYoulunChatConfig || window.DJJChatConfig || {}; const apiBase = (cfg.apiBase || '').replace(/\/$/, ''); const site = cfg.site || 'sanxia'; const deviceKey = 'sanxiayoulun_deviceid_' + site; const sessionKey = 'sanxiayoulun_sessionid_' + site; let deviceid = localStorage.getItem(deviceKey) || ('dev_' + Math.random().toString(16).slice(2)); localStorage.setItem(deviceKey, deviceid); let sessionid = localStorage.getItem(sessionKey) || ''; const css = ` #sanxiayoulun-chat-btn{position:fixed;right:22px;bottom:22px;z-index:999999;background:#111827;color:white;border-radius:999px;padding:14px 18px;box-shadow:0 10px 30px rgba(0,0,0,.25);cursor:pointer;font-family:Arial,"Microsoft YaHei",sans-serif;font-weight:700} #sanxiayoulun-chat-panel{position:fixed;right:22px;bottom:82px;width:360px;max-width:calc(100vw - 32px);height:520px;max-height:calc(100vh - 120px);z-index:999999;background:white;border-radius:18px;box-shadow:0 18px 60px rgba(0,0,0,.28);display:none;overflow:hidden;font-family:Arial,"Microsoft YaHei",sans-serif} #sanxiayoulun-head{background:#111827;color:white;padding:16px;font-weight:700}#sanxiayoulun-close{float:right;cursor:pointer}#sanxiayoulun-body{height:360px;overflow:auto;background:#f8fafc;padding:12px}.sanxiayoulun-msg{padding:10px 12px;border-radius:12px;margin:8px 0;line-height:1.45;font-size:14px}.sanxiayoulun-ai{background:#eef2ff;color:#111827}.sanxiayoulun-user{background:#111827;color:white;margin-left:45px}#sanxiayoulun-input{display:flex;gap:8px;padding:12px;border-top:1px solid #eee}#sanxiayoulun-text{flex:1;border:1px solid #d1d5db;border-radius:10px;padding:10px;font-size:14px}#sanxiayoulun-send{border:0;background:#111827;color:white;border-radius:10px;padding:0 14px;cursor:pointer}`; const style = document.createElement('style'); style.textContent = css; document.head.appendChild(style); const panel = document.createElement('div'); panel.id = 'sanxiayoulun-chat-panel'; panel.innerHTML = `