html, body { width:100%; height:100%; margin:0; overflow:hidden; background:#11161b; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif; }
#renderCanvas { width:100%; height:100%; display:block; outline:none; }
#hud { position:fixed; left:50%; transform:translateX(-50%); top:62px; color:#fff; pointer-events:none; text-shadow:0 2px 12px rgba(0,0,0,.42); z-index:70; display:flex; flex-direction:column; align-items:center; }
.brand { font-weight:950; letter-spacing:.02em; font-size:20px; margin-bottom:10px; }
.brand span { font-weight:750; color:#d7e0cd; font-size:12px; margin-left:6px; opacity:.82; }
.model-load-notice { pointer-events:auto; width:340px; margin:0 0 10px; padding:12px 13px; border:1px solid rgba(196,255,123,.34); border-radius:15px; background:rgba(11,20,16,.94); box-shadow:0 16px 38px rgba(0,0,0,.38), inset 0 0 30px rgba(151,221,111,.04); backdrop-filter:blur(15px); transition:opacity .35s, transform .35s, max-height .35s, margin .35s, padding .35s, border-color .25s; overflow:hidden; max-height:260px; }
.model-load-notice.hidden { opacity:0; transform:translateY(-8px); max-height:0; margin:0; padding-top:0; padding-bottom:0; border-width:0; pointer-events:none; }
.model-load-notice.ready { border-color:rgba(139,239,174,.48); }
.model-load-notice.error { border-color:rgba(255,119,102,.58); }
.model-load-head { display:flex; align-items:center; gap:9px; }
.model-load-head > div { flex:1; min-width:0; display:flex; flex-direction:column; }
.model-load-head strong { font-size:12px; color:#efffe8; }
.model-load-head small { margin-top:1px; color:#9fb19f; font:9px/1.3 ui-monospace,monospace; text-shadow:none; }
.model-load-icon { width:10px; height:10px; flex:0 0 10px; border:2px solid rgba(215,255,154,.28); border-top-color:#d7ff9a; border-radius:50%; animation:model-spin .8s linear infinite; }
.ready .model-load-icon { border:0; background:#82e6a3; box-shadow:0 0 12px rgba(130,230,163,.8); animation:none; }
.error .model-load-icon { border:0; background:#ff7766; box-shadow:0 0 12px rgba(255,119,102,.7); animation:none; }
.consent .model-load-icon { border:0; background:#d7ff9a; box-shadow:0 0 14px rgba(215,255,154,.62); animation:none; }
#dismissModelLoad { display:none; flex:0 0 25px; width:25px; height:25px; padding:0; border-radius:50%; background:rgba(255,255,255,.08); color:#c9d4c6; font:18px/1 sans-serif; }
.ready #dismissModelLoad, .error #dismissModelLoad, .declined #dismissModelLoad { display:block; }
.model-progress-row { display:flex; align-items:center; gap:9px; margin-top:11px; }
.model-progress-track { position:relative; flex:1; height:3px; border-radius:99px; background:rgba(255,255,255,.08); box-shadow:inset 0 0 0 .5px rgba(255,255,255,.04); overflow:hidden; }
.consent .model-progress-row, .declined .model-progress-row { display:none; }
#modelProgressBar { position:absolute; left:0; top:0; bottom:0; width:32%; border-radius:inherit; background:linear-gradient(90deg,rgba(124,220,177,0),#7cdcb1 40%,#d7ff9a); box-shadow:0 0 8px rgba(196,255,140,.55); animation:model-indeterminate 1.35s cubic-bezier(.45,.05,.55,.95) infinite; }
.determinate #modelProgressBar { width:0; background:linear-gradient(90deg,#5fc9a0,#7cdcb1 55%,#d7ff9a); transition:width .35s cubic-bezier(.22,.8,.3,1); animation:none; }
.determinate #modelProgressBar::after { content:''; position:absolute; inset:0; border-radius:inherit; background:linear-gradient(90deg,transparent,rgba(255,255,255,.55),transparent); background-size:60px 100%; background-repeat:no-repeat; animation:model-sheen 1.6s linear infinite; }
.ready #modelProgressBar, .error #modelProgressBar { width:100% !important; animation:none; transition:width .35s ease, background .3s; }
.ready #modelProgressBar { background:#82e6a3; box-shadow:0 0 8px rgba(130,230,163,.5); }
.error #modelProgressBar { background:#ff7766; box-shadow:0 0 8px rgba(255,119,102,.5); }
.model-progress-pct { min-width:30px; text-align:right; color:#d7ff9a; font:600 10px/1 ui-monospace,monospace; font-variant-numeric:tabular-nums; text-shadow:none; }
.model-progress-pct:empty { display:none; }
#modelLoadText { margin:7px 0 0; color:#dce9d3; font:10px/1.35 ui-monospace,monospace; text-shadow:none; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.consent #modelLoadText { display:none; }
.model-consent[hidden] { display:none; }
.model-consent { margin-top:10px; animation:consent-rise .28s ease-out both; }
.model-consent p { margin:0 0 9px; color:#eff9e9; font:11px/1.45 ui-sans-serif,system-ui,sans-serif; text-shadow:none; }
.model-consent p strong { display:block; margin-bottom:2px; font-size:13px; color:#fff; }
.model-consent p b { color:#d7ff9a; }
.model-consent-facts { display:flex; gap:6px; margin-bottom:10px; color:#aebead; font:9px/1.3 ui-monospace,monospace; text-shadow:none; }
.model-consent-facts span { flex:1; padding:6px; border:1px solid rgba(255,255,255,.09); border-radius:8px; background:rgba(255,255,255,.035); }
.model-consent-actions { display:flex; gap:7px; }
#approveModelDownload { flex:1.45; color:#112016; background:linear-gradient(135deg,#d7ff9a,#78dbad); box-shadow:0 5px 18px rgba(120,219,173,.18); }
#approveModelDownload:hover { background:linear-gradient(135deg,#e4ffb9,#96e8c2); }
#declineModelDownload { flex:.75; color:#bec9ba; background:rgba(255,255,255,.08); }
@keyframes model-spin { to { transform:rotate(360deg); } }
@keyframes model-indeterminate { 0% { transform:translateX(-100%); } 100% { transform:translateX(320%); } }
@keyframes model-sheen { from { background-position:-60px 0; } to { background-position:calc(100% + 60px) 0; } }
@keyframes consent-rise { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.panel { pointer-events:auto; width:340px; max-height:calc(100vh - 60px); overflow-y:auto; background:rgba(16,20,25,.62); border:1px solid rgba(255,255,255,.15); box-shadow:0 18px 48px rgba(0,0,0,.34); backdrop-filter: blur(14px); border-radius:20px; padding:10px; }

.recordbar { display:grid; grid-template-columns:1fr 1.45fr; gap:7px; align-items:center; margin-bottom:8px; padding:8px; border:1px solid rgba(255,255,255,.12); border-radius:12px; background:rgba(0,0,0,.22); }
.recordbar button { padding:8px 7px; font-size:11px; }
#startRecording { background:rgba(190,45,48,.62); }
#startRecording.recording { background:rgba(235,52,58,.82); box-shadow:0 0 0 2px rgba(255,105,105,.22),0 0 18px rgba(255,40,40,.25); }
#recordingStatus { grid-column:1 / -1; font:10px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color:#dce9d3; text-align:center; text-shadow:none; }
.apng-state-drop { margin:9px 0; padding:11px 9px; border:1px dashed rgba(157,220,190,.55); border-radius:10px; background:rgba(18,45,35,.42); text-align:center; cursor:pointer; display:flex; flex-direction:column; gap:3px; outline:none; }
.apng-state-drop:hover, .apng-state-drop:focus, .apng-state-drop.dragover { border-color:#b9f3d3; background:rgba(34,78,59,.60); box-shadow:0 0 0 2px rgba(125,225,175,.12); }
.apng-state-drop strong { color:#e7fff0; font-size:12px; }
.apng-state-drop span { color:#c8ddce; font-size:11px; }
.apng-state-drop small { color:#91aa99; font:9px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.apng-state-drop.loading { opacity:.68; pointer-events:none; }

.panel-section { margin-bottom:6px; border:1px solid rgba(255,255,255,.10); border-radius:12px; padding:8px 10px; background:rgba(0,0,0,.15); }
.panel-section > summary { font-size:12px; font-weight:900; text-transform:uppercase; letter-spacing:.08em; cursor:pointer; opacity:.85; list-style:none; display:flex; align-items:center; gap:6px; user-select:none; }
.panel-section > summary::before { content:'\25BC'; font-size:9px; transition:transform .2s; }
.panel-section:not([open]) > summary::before { transform:rotate(-90deg); }
.panel-section > summary::-webkit-details-marker { display:none; }
.panel-section[open] > summary { margin-bottom:8px; }
.section-subtitle { font-size:10px; text-transform:uppercase; letter-spacing:.10em; opacity:.65; font-weight:900; margin:6px 0 5px; }

.row { display:flex; gap:7px; margin-bottom:7px; }
button { border:0; background:rgba(255,255,255,.13); color:#fff; border-radius:10px; padding:8px 10px; font-weight:850; cursor:pointer; flex:1; }
button:hover { background:rgba(255,255,255,.24); transform:translateY(-1px); }
button:disabled { opacity:.32; cursor:not-allowed; transform:none; }
.custom-grid { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin-bottom:6px; }
.custom-grid label { font-size:11px; font-weight:850; color:#eaf2df; display:flex; flex-direction:column; gap:4px; }
select, input[type="range"] { accent-color:#d7ff9a; border:1px solid rgba(255,255,255,.18); color:#fff; background:rgba(0,0,0,.28); border-radius:10px; padding:7px; font-weight:800; }
#allowedCommands { display:flex; flex-wrap:wrap; gap:6px; }
.cmdcheck { font-size:11px; font-weight:850; background:rgba(255,255,255,.09); border:1px solid rgba(255,255,255,.12); padding:5px 7px; border-radius:999px; display:flex; align-items:center; gap:4px; }

#log { max-height:200px; overflow-y:auto; font-size:11px; opacity:.94; }
.logline { background:rgba(0,0,0,.32); border-left:3px solid rgba(175,225,160,.9); padding:6px 9px; margin-bottom:5px; border-radius:8px; }

#hint { position:fixed; right:20px; bottom:18px; max-width:520px; color:#e8f1e4; background:rgba(16,20,25,.58); border:1px solid rgba(255,255,255,.14); border-radius:17px; padding:11px 15px; font-size:13px; backdrop-filter: blur(10px); box-shadow:0 10px 28px rgba(0,0,0,.25); }
code { color:#ffe0a0; }
.bubble { position:absolute; transform:translate(-50%, -100%); background:#fff6dc; color:#2a241c; border:2px solid rgba(40,30,20,.24); border-radius:16px; padding:7px 10px; font-weight:950; pointer-events:none; white-space:nowrap; box-shadow:0 10px 18px rgba(0,0,0,.25); }
.bubble.thought { background:rgba(232,240,255,.94); color:#3d4a66; border:2px dashed rgba(90,110,160,.45); border-radius:22px; font-weight:600; font-style:italic; font-size:.86em; white-space:normal; width:max-content; max-width:280px; line-height:1.3; }
.bubble.thought::before { content:'💭 '; font-style:normal; }
.bubble.thought.pending { opacity:.8; animation:thought-pulse 1.2s ease-in-out infinite; }
@keyframes thought-pulse { 50% { opacity:.45; } }
.badge { position:absolute; transform:translate(-50%, -50%); color:#fff6dc; font-weight:950; font-size:13px; text-shadow:0 2px 8px #000; pointer-events:none; }

.perception-controls { display:flex; gap:7px; align-items:end; margin-bottom:7px; }
.perception-controls label { flex:1; font-size:11px; font-weight:850; color:#eaf2df; display:flex; flex-direction:column; gap:4px; }
.perception-controls button { flex:0 0 72px; padding:7px 8px; }
#promptOut { width:calc(100% - 14px); min-height:80px; max-height:300px; overflow:auto; margin:0; padding:7px; border-radius:11px; border:1px solid rgba(255,255,255,.14); background:rgba(4,7,9,.46); color:#e9f6df; font: 10px/1.28 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-shadow:none; white-space:pre-wrap; word-break:break-word; }
#perfOut { width:calc(100% - 14px); min-height:60px; max-height:340px; overflow:auto; margin:0; padding:7px; border-radius:11px; border:1px solid rgba(255,255,255,.14); background:rgba(4,7,9,.46); color:#9fe8c8; font: 10px/1.28 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-shadow:none; white-space:pre-wrap; word-break:break-word; }

.turnbar { display:flex; align-items:center; gap:8px; margin-bottom:8px; background:rgba(0,0,0,.22); border:1px solid rgba(255,255,255,.12); border-radius:13px; padding:7px; }
.turnbar label { display:flex; align-items:center; gap:5px; font-size:11px; font-weight:900; color:#ecf7df; white-space:nowrap; }
#turnStatus { flex:1; font-size:11px; font-weight:900; color:#ffe1a8; text-align:center; }
#settleNow { flex:0 0 72px; padding:7px 8px; }

.brainbar { display:flex; flex-wrap:wrap; gap:7px; margin-bottom:7px; align-items:center; }
.brainbar button { padding:8px 9px; }
#brainStatus { font-size:11px; font-weight:850; color:#ffe1a8; background:rgba(0,0,0,.22); border:1px solid rgba(255,255,255,.11); border-radius:12px; padding:7px 9px; margin-bottom:8px; }
.setup-row button { min-width:0; }
.personality-label { display:flex; flex-direction:column; gap:5px; font-size:11px; font-weight:850; color:#eaf2df; margin:7px 0 8px; }
#agentPersonality, #agentQuest, #agentGoal { width:calc(100% - 16px); resize:vertical; border:1px solid rgba(255,255,255,.18); color:#fff; background:rgba(0,0,0,.28); border-radius:10px; padding:8px; font: 11px/1.25 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.custom-grid input[type="checkbox"] { width:18px; height:18px; accent-color:#d7ff9a; }

.cache-controls { display:flex; gap:7px; align-items:center; margin-bottom:8px; flex-wrap:wrap; }
.llm-endpoint { margin:4px 0 10px; font-size:12px; }
.llm-endpoint summary { cursor:pointer; margin-bottom:6px; }
.llm-endpoint label { display:flex; gap:6px; align-items:center; margin:4px 0; }
.llm-endpoint input, .llm-endpoint select { flex:1; min-width:0; }
.llm-endpoint label > button { flex:0 0 auto; width:auto; padding:2px 9px; }
.llm-endpoint input[type=checkbox] { flex:0 0 auto; margin-top:2px; }
.endpoint-pop .llm-endpoint label.spawn-mode-toggle { flex-wrap:nowrap; align-items:flex-start; }
.llm-endpoint-note { opacity:.7; margin-top:4px; line-height:1.35; }
.endpoint-pop { position:fixed; top:60px; left:clamp(16px, 22vw, 250px); z-index:120; width:min(460px, calc(100vw - 32px)); box-sizing:border-box; padding:12px 14px; border-radius:10px; background:rgba(13,17,21,.94); border:1px solid rgba(255,255,255,.16); color:#fff; box-shadow:0 10px 30px rgba(0,0,0,.45); }
.endpoint-pop[hidden] { display:none; }
.endpoint-pop-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:6px; }
.endpoint-pop-head button { flex:0 0 auto; width:auto; padding:5px 14px; }
.endpoint-pop .llm-endpoint label { font-weight:normal; }
.endpoint-pop .llm-endpoint summary { display:none; }
.endpoint-pop .llm-endpoint label { flex-wrap:wrap; }
.endpoint-pop .llm-endpoint select { max-width:100%; }
.cache-backend-label { font-size:11px; display:flex; gap:4px; align-items:center; }
.cache-backend-label select { padding:3px 5px; font-size:11px; }
#clearCache { padding:5px 8px; font-size:11px; }
#cacheStatus { font-size:10px; color:#aaa; }
.danger-btn { background:rgba(220,60,60,.32) !important; border:1px solid rgba(255,80,80,.4) !important; }
.danger-btn:hover { background:rgba(240,80,80,.5) !important; }
.clear-history-btn { width:100%; margin:-1px 0 8px; padding:7px 9px; background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.13); color:#dce9d7; font-size:11px; }
.clear-history-btn:hover { background:rgba(255,255,255,.16); }

.spawn-panel { display:flex; flex-direction:column; gap:7px; margin-bottom:8px; background:rgba(0,0,0,.22); border:1px solid rgba(255,255,255,.12); border-radius:12px; padding:8px; }
.spawn-mode-toggle { display:flex; align-items:center; gap:6px; font-size:11px; font-weight:850; color:#eaf2df; cursor:pointer; }
.spawn-mode-toggle input { width:18px; height:18px; accent-color:#d7ff9a; }
.spawn-panel select { width:100%; }
.spawn-panel select option { background:#1a1f25; color:#fff; }
.chat-input-section { margin-bottom: 8px; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 8px; }
.chat-name-label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 850; color: #eaf2df; margin-bottom: 6px; }
.chat-name-label input { flex: 1; border: 1px solid rgba(255,255,255,.18); color: #fff; background: rgba(0,0,0,.28); border-radius: 10px; padding: 6px 8px; font-weight: 800; font-size: 11px; }
.chat-send-row { display: flex; gap: 6px; }
.chat-send-row input { flex: 1; border: 1px solid rgba(255,255,255,.18); color: #fff; background: rgba(0,0,0,.28); border-radius: 10px; padding: 7px 8px; font-size: 12px; }
.chat-send-row button { flex: 0 0 60px; padding: 7px 8px; }

#compassHud { position:fixed; right:18px; top:18px; width:76px; height:76px; border:1px solid #b9d3a7; border-radius:50%; background:rgba(12,20,15,.78); z-index:30; pointer-events:none; box-shadow:0 2px 14px #0008; color:#dce8d4; font:700 12px/1 system-ui,sans-serif; }
#compassHud::after { content:""; position:absolute; left:50%; top:50%; width:5px; height:5px; transform:translate(-50%,-50%); border-radius:50%; background:#dce8d4; }
#compassHud span { position:absolute; left:50%; top:50%; width:16px; text-align:center; transform-origin:center; color:#dce8d4; }
#compassHud .compass-n { color:#ff826f; }
#compassHud small { position:absolute; right:0; top:82px; width:170px; padding:5px 7px; border-radius:5px; background:rgba(12,20,15,.78); font:600 10px/1.2 ui-monospace,monospace; text-align:right; color:#dce8d4; }

#ttsStatus { font-size:11px; font-weight:850; color:#ffe1a8; background:rgba(0,0,0,.22); border:1px solid rgba(255,255,255,.11); border-radius:10px; padding:7px 9px; margin:7px 0; }
#ttsTelemetry { font:600 10px/1.45 ui-monospace,monospace; color:#b9d8c5; overflow-wrap:anywhere; margin:-2px 3px 8px; }
#customVoiceName, #customVoiceFile { box-sizing:border-box; width:100%; margin-bottom:7px; border:1px solid rgba(255,255,255,.18); color:#fff; background:rgba(0,0,0,.28); border-radius:10px; padding:7px; font-size:11px; }
.tts-note { display:block; color:#aebead; font:9px/1.35 ui-monospace,monospace; }
.helpers-row { display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin:4px 0; }
.helpers-row .helpers-status { display:inline; color:#aebead; font:9px/1.35 ui-monospace,monospace; }

/* ---- confirm dialog (confirm-dialog.js) ---- */
.confirm-overlay { position:fixed; z-index:1100; display:flex; align-items:center; justify-content:center; padding:14px; border-radius:20px; background:rgba(8,12,10,.55); backdrop-filter:blur(6px) saturate(.9); animation:confirm-fade .16s ease-out both; }
.confirm-overlay-full { left:0 !important; top:0 !important; width:100% !important; height:100% !important; border-radius:0; }
.confirm-overlay.confirm-closing { animation:confirm-fade-out .14s ease-in both; }
.confirm-card { width:min(282px,100%); background:rgba(18,24,29,.94); border:1px solid rgba(255,255,255,.16); border-radius:16px; padding:15px 14px 12px; box-shadow:0 22px 60px rgba(0,0,0,.5); text-align:center; animation:confirm-pop .18s cubic-bezier(.2,1.4,.4,1) both; }
.confirm-icon { width:34px; height:34px; margin:0 auto 8px; border-radius:50%; background:rgba(215,255,154,.13); border:1px solid rgba(215,255,154,.4); display:flex; align-items:center; justify-content:center; }
.confirm-icon::before { content:'?'; font-size:17px; font-weight:950; color:#d7ff9a; }
.confirm-danger .confirm-icon { background:rgba(255,90,90,.13); border-color:rgba(255,90,90,.45); }
.confirm-danger .confirm-icon::before { content:'!'; color:#ff9d8f; }
.confirm-title { font-size:13px; font-weight:950; letter-spacing:.02em; color:#fff; margin-bottom:4px; }
.confirm-msg { font-size:11.5px; line-height:1.45; color:#cfe0c8; margin-bottom:12px; }
.confirm-actions { display:flex; gap:7px; }
.confirm-btn { padding:8px 10px; font-size:11px; }
.confirm-no { order:1; flex:1; color:#bec9ba; background:rgba(255,255,255,.08); }
.confirm-no:hover { background:rgba(255,255,255,.16); }
.confirm-yes { order:2; flex:1.35; color:#112016; background:linear-gradient(135deg,#d7ff9a,#78dbad); }
.confirm-yes:hover { background:linear-gradient(135deg,#e4ffb9,#96e8c2); }
.confirm-danger .confirm-yes { color:#2a0f0d; background:linear-gradient(135deg,#ffb199,#ff6f61); }
.confirm-danger .confirm-yes:hover { background:linear-gradient(135deg,#ffc4b0,#ff8578); }
.confirm-yes:focus-visible, .confirm-no:focus-visible { outline:2px solid #d7ff9a; outline-offset:2px; }
@keyframes confirm-fade { from { opacity:0; } to { opacity:1; } }
@keyframes confirm-fade-out { from { opacity:1; } to { opacity:0; } }
@keyframes confirm-pop { from { opacity:0; transform:scale(.92) translateY(6px); } to { opacity:1; transform:scale(1) translateY(0); } }

/* ---- toasts (toast.js) ---- */
#toastStack { position:fixed; left:18px; bottom:96px; width:322px; z-index:70; display:flex; flex-direction:column; gap:8px; pointer-events:none; }
.tablefolk-toast { pointer-events:auto; display:flex; gap:9px; align-items:flex-start; padding:10px 12px; border-radius:14px; background:rgba(14,19,23,.93); border:1px solid rgba(215,255,154,.28); box-shadow:0 12px 30px rgba(0,0,0,.42); backdrop-filter:blur(12px); color:#e6f0dd; font-size:11.5px; line-height:1.4; cursor:pointer; text-shadow:none; animation:toast-in .22s cubic-bezier(.2,1.3,.4,1) both; }
.tablefolk-toast.t-success { border-color:rgba(139,239,174,.5); }
.tablefolk-toast.t-warn { border-color:rgba(255,200,120,.45); }
.tablefolk-toast.t-error { border-color:rgba(255,119,102,.55); }
.tablefolk-toast.leaving { animation:toast-out .18s ease-in both; }
.toast-dot { width:8px; height:8px; border-radius:50%; margin-top:4px; flex:0 0 8px; background:#d7ff9a; }
.toast-body { flex:1; min-width:0; overflow-wrap:anywhere; }
.toast-action { flex:0 0 auto; align-self:center; padding:5px 12px; font-size:10px; border-radius:8px; color:#112016; background:linear-gradient(135deg,#d7ff9a,#78dbad); }
.toast-action:hover { background:linear-gradient(135deg,#e4ffb9,#96e8c2); }
@keyframes toast-in { from { opacity:0; transform:translateY(10px) scale(.96); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; transform:translateY(6px); } }

/* ---- slider value readouts (ui-polish.js) ---- */
.range-head { display:flex; justify-content:space-between; align-items:baseline; gap:6px; }
.range-val { font:10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color:#d7ff9a; flex:0 0 auto; }


/* ---- chat dock (always-visible chat, outside World setup) ---- */
#chatDock { position:fixed; left:18px; bottom:16px; width:340px; box-sizing:border-box; z-index:65; display:flex; flex-direction:column; gap:7px; padding:10px 12px; border-radius:16px; background:rgba(16,20,25,.62); border:1px solid rgba(255,255,255,.15); box-shadow:0 18px 48px rgba(0,0,0,.34); backdrop-filter:blur(14px); color:#fff; }
#chatDock .chat-target { font:10px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color:#ffe1a8; }
#chatDock #chatTo { font:inherit; font-size:12px; color:#ffe1a8; background:rgba(0,0,0,.35); border:1px solid rgba(255,225,168,.35); border-radius:8px; padding:2px 6px; margin-left:4px; }
#chatDock .chat-name-label { margin-bottom:0; }

/* ---- library rows ---- */
.lib-row { display:flex; gap:7px; margin-bottom:7px; }
.lib-row input { flex:1; min-width:0; border:1px solid rgba(255,255,255,.18); color:#fff; background:rgba(0,0,0,.28); border-radius:10px; padding:7px 8px; font-size:11px; }
.lib-row select { flex:1.2; min-width:0; }

/* ---- WebGPU compatibility gate (preflight.js) ---- */
.tablefolk-preflight-pending > :not(#compatibilityScreen):not(script) { visibility:hidden; }
.compatibility-screen[hidden] { display:none; }
.compatibility-screen { position:fixed; inset:0; z-index:1000; display:grid; place-items:center; box-sizing:border-box; overflow:auto; padding:24px; color:#edf5e8; background:radial-gradient(circle at 50% 15%,#24372d 0,#111a17 42%,#090d0c 100%); }
.compatibility-card { width:min(560px,100%); box-sizing:border-box; padding:34px; border:1px solid rgba(207,255,172,.25); border-radius:24px; background:rgba(15,23,20,.94); box-shadow:0 30px 90px #0009,inset 0 0 60px rgba(147,220,119,.035); }
.compatibility-mark { display:grid; place-items:center; width:50px; height:50px; margin-bottom:20px; border-radius:15px; color:#152017; background:linear-gradient(135deg,#ddffa7,#70d9aa); font:950 27px/1 system-ui,sans-serif; box-shadow:0 10px 28px rgba(114,220,170,.18); }
.compatibility-kicker { margin:0 0 8px; color:#a9cf9e; font:800 11px/1 ui-monospace,monospace; letter-spacing:.14em; text-transform:uppercase; }
.compatibility-card h1 { margin:0 0 14px; color:#f3f8ef; font:850 clamp(25px,5vw,38px)/1.08 system-ui,sans-serif; letter-spacing:-.035em; }
.compatibility-card > p { color:#c8d5c4; font:15px/1.55 system-ui,sans-serif; }
.compatibility-help { margin:22px 0; padding:17px 19px; border:1px solid rgba(255,255,255,.1); border-radius:15px; background:rgba(255,255,255,.035); font:14px/1.5 system-ui,sans-serif; }
.compatibility-help strong { color:#eaf5e2; }
.compatibility-help ul { margin:9px 0 0; padding-left:21px; color:#bdcbb8; }
.compatibility-detail { padding-top:4px; color:#8fa08c!important; font:11px/1.5 ui-monospace,monospace!important; overflow-wrap:anywhere; }
.compatibility-actions { display:flex; align-items:center; gap:12px; margin-top:22px; }
.compatibility-actions button,.compatibility-actions a { box-sizing:border-box; flex:0 0 auto; padding:10px 16px; border-radius:11px; text-decoration:none; font:800 13px/1 system-ui,sans-serif; }
.compatibility-actions button { color:#142019; background:linear-gradient(135deg,#d7ff9a,#78dbad); }
.compatibility-actions a { color:#d7e5d1; border:1px solid rgba(255,255,255,.16); }
.tablefolk-incompatible > :not(#compatibilityScreen):not(script) { display:none!important; }

/* ---- v15 shell: top bar + icon rail + tabbed side panel ---- */
#topBar { position:fixed; left:0; right:0; top:0; height:52px; z-index:60; display:flex; align-items:center; gap:10px; padding:0 14px; box-sizing:border-box; background:rgba(13,17,21,.72); border-bottom:1px solid rgba(255,255,255,.12); backdrop-filter:blur(14px); color:#fff; }
#topBar .brand { margin:0; font-size:17px; flex:0 0 auto; }
#topBar .topbar-group { display:flex; align-items:center; gap:6px; }
#topBar .topbar-group button { flex:0 0 auto; padding:7px 12px; font-size:11px; }
#topBar .topbar-model-select { flex:0 0 auto; padding:6px 8px; font-size:11px; background:rgba(10,18,16,.85); color:#cfe8dd; border:1px solid rgba(120,220,170,.35); border-radius:8px; max-width:150px; }
#topBar .topbar-spacer { flex:1; }
#topBar .top-pill { font:10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color:#ffe1a8; background:rgba(0,0,0,.30); border:1px solid rgba(255,255,255,.12); border-radius:999px; padding:6px 10px; white-space:nowrap; }
#topBar .top-toggle { display:flex; align-items:center; gap:5px; font-size:11px; font-weight:900; color:#ecf7df; white-space:nowrap; }
#topBar .top-toggle input { width:16px; height:16px; accent-color:#d7ff9a; }
#ttsTopToggle { flex:0 0 auto; width:36px; height:36px; padding:0; border-radius:50%; font-size:16px; background:rgba(255,255,255,.10); }
#ttsTopToggle.on { background:rgba(215,255,154,.22); box-shadow:0 0 10px rgba(215,255,154,.18); }
#ttsTopVolume { flex:0 0 auto; width:76px; accent-color:#d7ff9a; }
@media (max-width:640px){ #ttsTopVolume { width:52px; } }


#rail { position:fixed; left:10px; top:64px; z-index:60; display:flex; flex-direction:column; gap:6px; }
#rail .rail-btn { width:44px; height:44px; flex:0 0 44px; padding:0; border-radius:14px; font-size:19px; line-height:1; background:rgba(16,20,25,.62); border:1px solid rgba(255,255,255,.14); backdrop-filter:blur(12px); box-shadow:0 10px 24px rgba(0,0,0,.28); }
#rail .rail-btn:hover { background:rgba(255,255,255,.16); }
#rail .dev-toggle { font-size:11px; font-weight:800; letter-spacing:.04em; opacity:.6; margin-top:auto; }
#rail .dev-toggle[aria-pressed="true"] { opacity:1; color:#ffd479; border-color:rgba(255,212,121,.65); background:rgba(255,212,121,.16); }
#rail .rail-btn.active { background:rgba(215,255,154,.20); border-color:rgba(215,255,154,.5); box-shadow:0 0 14px rgba(215,255,154,.14); }

#sidePanel { position:fixed; left:62px; top:64px; bottom:16px; width:364px; z-index:59; display:none; overflow-y:auto; box-sizing:border-box; padding:12px; border-radius:20px; background:rgba(16,20,25,.62); border:1px solid rgba(255,255,255,.15); box-shadow:0 18px 48px rgba(0,0,0,.34); backdrop-filter:blur(14px); color:#fff; }
#sidePanel.open { display:block; }
#sidePanel .pane { display:none; }
#sidePanel .pane.active { display:block; }
#sidePanel .recordbar { margin-bottom:12px; }
#sidePanel .section-subtitle { margin:12px 0 6px; }
#sidePanel .spawn-mode-toggle { margin-bottom:7px; }
.pane-title { margin:2px 0 10px; font-size:13px; font-weight:950; text-transform:uppercase; letter-spacing:.09em; color:#efffe8; opacity:.9; }
.pane-note { display:block; color:#aebead; font:9px/1.4 ui-monospace,monospace; margin:4px 2px 8px; }

/* chat dock: bottom-right so it never collides with the left panel */
#chatDock { left:auto; right:18px; bottom:16px; width:360px; }
#hint { right:auto; left:50%; transform:translateX(-50%); bottom:14px; top:auto; max-width:420px; font-size:12px; text-align:center; }
#compassHud { top:64px; }
#toastStack { bottom:auto; top:120px; }

/* LFM2.5-230M demo chat panel (copied from test demo) */
.demo-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 90;
  width: 420px;
  max-width: 92vw;
  max-height: 80vh;
  background: rgba(17, 17, 17, 0.95);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 14px;
  color: #eee;
  font-family: system-ui, sans-serif;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.demo-panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.demo-panel-head strong { font-size: 1.05em; }
.demo-small { font-size: 0.75em; color: #999; }
.demo-device-badge { padding: 4px 10px; border-radius: 6px; font-weight: bold; width: fit-content; font-size: 0.85em; }
.demo-status { padding: 6px 10px; border-radius: 6px; background: #222; font-size: 0.85em; white-space: pre-wrap; min-height: 18px; }
.demo-progress-track { height: 6px; border-radius: 3px; background: #333; overflow: hidden; }
.demo-progress-bar { display: block; height: 100%; width: 0%; background: #2d6cdf; transition: width 0.2s; }
.demo-chat { border: 1px solid #333; border-radius: 8px; padding: 10px; height: 260px; overflow-y: auto; background: #181818; display: flex; flex-direction: column; gap: 6px; }
.demo-chat .msg { margin: 0; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; font-size: 0.9em; }
.demo-chat .user { background: #1e3a5f; text-align: right; align-self: flex-end; max-width: 85%; }
.demo-chat .bot { background: #2a2a2a; align-self: flex-start; max-width: 85%; }
.demo-chat .err { background: #5f1e1e; align-self: flex-start; max-width: 85%; }
.demo-input-row { display: flex; gap: 8px; }
.demo-input { flex: 1; padding: 10px; border-radius: 6px; border: 1px solid #444; background: #222; color: #eee; }
.demo-send-btn, .demo-load-btn { padding: 10px 16px; border-radius: 6px; border: none; background: #2d6cdf; color: #fff; cursor: pointer; }
.demo-send-btn:disabled, .demo-load-btn:disabled { background: #444; cursor: not-allowed; }
.demo-load-btn { width: 100%; }

/* ---- scenarios ---- */
#scenarioBanner { position:fixed; top:196px; right:16px; z-index:40; width:min(340px,calc(100vw - 32px)); background:rgba(18,28,34,.88); color:#eef6f2; border:1px solid rgba(159,232,200,.35); border-radius:14px; padding:8px 14px; box-shadow:0 8px 24px rgba(0,0,0,.35); text-align:center; backdrop-filter:blur(6px); }
#scenarioBanner .scn-title { font-weight:900; letter-spacing:.01em; }
#scenarioBanner .scn-goal { font-size:.92em; margin-top:2px; color:#cfeee2; }
#scenarioBanner .scn-meta { font-size:.78em; opacity:.75; margin-top:2px; }
.scn-actions { display:flex; gap:6px; justify-content:center; flex-wrap:wrap; margin-top:6px; }
.scn-actions button { font-size:.8em; padding:3px 10px; border-radius:999px; border:1px solid rgba(159,232,200,.45); background:rgba(159,232,200,.12); color:inherit; cursor:pointer; }
.scn-actions button:hover { background:rgba(159,232,200,.26); }
.scn-overlay { position:fixed; inset:0; z-index:60; display:flex; align-items:center; justify-content:center; background:rgba(6,12,16,.28); padding:16px; }
/* The intro is a card over the world, not a modal: no dimming, clicks pass through around it. */
.scn-overlay.intro { background:none; pointer-events:none; align-items:flex-start; padding-top:72px; }
.scn-overlay.intro .scn-card { pointer-events:auto; }
.scn-nointro { display:block; margin-top:8px; cursor:pointer; }
.scn-nointro input { vertical-align:middle; margin:0 4px 0 0; }
.scn-overlay[hidden] { display:none; }
.scn-card { max-width:420px; width:100%; background:#fff6dc; color:#2a241c; border-radius:18px; padding:18px 20px; box-shadow:0 18px 40px rgba(0,0,0,.4); text-align:center; }
.scn-card h2 { margin:0 0 8px; font-size:1.35em; }
.scn-card p { margin:6px 0; }
.scn-card .scn-goal-big { font-weight:800; }
.scn-card .scn-hint { font-size:.82em; opacity:.7; }
.scn-card .scn-score { font-size:1.1em; }
.scn-card .scn-actions button { border-color:rgba(40,30,20,.3); background:rgba(40,30,20,.06); }
.scn-overlay.won .scn-card { border:3px solid #6fcf97; }
.scn-overlay.lost .scn-card { border:3px solid #e8a07a; }
.scn-warnings { white-space:pre-wrap; font-size:.75em; opacity:.8; margin:4px 0; }
.scn-warnings:empty { display:none; }
.scn-results { width:100%; border-collapse:collapse; font-size:.8em; margin-top:4px; }
.scn-results th, .scn-results td { text-align:left; padding:3px 4px; border-bottom:1px solid rgba(159,232,200,.15); vertical-align:top; }
.scn-results pre { white-space:pre-wrap; font-size:.95em; margin:4px 0; max-height:260px; overflow:auto; }
.scn-safety { position:fixed; left:50%; bottom:150px; transform:translateX(-50%); z-index:65; max-width:min(560px,calc(100vw - 32px)); background:#fff6dc; color:#2a241c; border:3px solid #e8a07a; border-radius:14px; padding:12px 16px; box-shadow:0 12px 30px rgba(0,0,0,.4); font-size:.95em; line-height:1.4; }
.scn-safety[hidden] { display:none; }
.scn-safety a { color:#8a3b12; }
.scn-safety button { margin-left:8px; font-size:.8em; padding:2px 10px; border-radius:999px; border:1px solid rgba(40,30,20,.3); background:rgba(40,30,20,.06); cursor:pointer; }
#scenarioBanner { text-align:left; padding-right:30px; }
#scenarioBanner .scn-actions { justify-content:flex-start; }
#scenarioBanner .scn-collapse { position:absolute; top:6px; right:8px; width:20px; height:20px; padding:0; line-height:18px; border-radius:50%; border:1px solid rgba(159,232,200,.4); background:rgba(159,232,200,.1); color:inherit; cursor:pointer; }
#scenarioBanner.collapsed { width:auto; max-width:min(260px,calc(100vw - 32px)); padding:3px 4px 3px 10px; border-radius:999px; font-size:.82em; }
#scenarioBanner .scn-expand { display:flex; align-items:center; gap:7px; background:none; border:0; color:inherit; font:inherit; cursor:pointer; padding:0; max-width:100%; }
#scenarioBanner .scn-name { font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#scenarioBanner .scn-q { flex:none; width:18px; height:18px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-weight:900; font-size:.85em; background:rgba(159,232,200,.2); border:1px solid rgba(159,232,200,.5); }
#scenarioBanner .scn-expand:hover .scn-q { background:rgba(159,232,200,.38); }
@media (max-width:700px){ #scenarioBanner { top:auto; bottom:170px; } }

/* ---- monochrome rail icons ---- */
#rail .rail-btn svg { width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; display:block; margin:auto; }
#rail .rail-btn { color:#cfe3d6; }
#rail .rail-btn.active, #rail .rail-btn:hover { color:#9fe8c8; }

/* ---- side panel: no horizontal scrolling, thin themed scrollbars ---- */
#sidePanel { overflow-x:hidden; scrollbar-width:thin; scrollbar-color:rgba(159,232,200,.35) transparent; }
#sidePanel .pane, #sidePanel .pane * { max-width:100%; }
#sidePanel input:not([type=checkbox]):not([type=radio]), #sidePanel select, #sidePanel textarea { box-sizing:border-box; }
#sidePanel textarea, #sidePanel pre { max-width:100%; }
#sidePanel pre { white-space:pre-wrap; overflow-wrap:anywhere; }
#sidePanel textarea, #sidePanel pre, #log, #promptOut { scrollbar-width:thin; scrollbar-color:rgba(159,232,200,.3) transparent; }
#sidePanel::-webkit-scrollbar, #sidePanel *::-webkit-scrollbar { width:7px; height:7px; }
#sidePanel::-webkit-scrollbar-track, #sidePanel *::-webkit-scrollbar-track { background:transparent; }
#sidePanel::-webkit-scrollbar-thumb, #sidePanel *::-webkit-scrollbar-thumb { background:rgba(159,232,200,.3); border-radius:8px; }
#sidePanel::-webkit-scrollbar-thumb:hover, #sidePanel *::-webkit-scrollbar-thumb:hover { background:rgba(159,232,200,.5); }
#sidePanel::-webkit-scrollbar-corner { background:transparent; }
#agentGold, #agentItems, #scnJson, #scnMap, #scnTactics, #scnDescribe, #scnSeed, #scnTestRuns, #playerGold { width:100%; border:1px solid rgba(255,255,255,.18); color:#fff; background:rgba(0,0,0,.28); border-radius:10px; padding:7px 8px; font:11px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; resize:vertical; }
#scnSeed, #scnTestRuns { width:5em; }
#sidePanel::-webkit-scrollbar-button, #sidePanel *::-webkit-scrollbar-button { display:none; width:0; height:0; }

/* ---- player avatar ---- */
.bubble.player-bubble { background:#ffe7b0; border-color:rgba(160,110,30,.45); }
.fp-btn { display:flex; align-items:center; gap:6px; justify-content:center; padding:5px 10px; border-radius:999px; border:1px solid rgba(255,214,140,.45); background:rgba(255,200,110,.12); color:#ffe2ad; font-weight:800; font-size:12px; cursor:pointer; }
.fp-btn[hidden] { display:none; }
.fp-btn.active { background:rgba(255,200,110,.32); }
.fp-btn svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.view-btns { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.view-btns[hidden] { display:none; }
.view-btns > .fp-btn { min-width:0; white-space:nowrap; }
.view-btns[hidden] + .avatar-hint { display:none; }
.fp-btn kbd { font:700 10px/1 ui-monospace,monospace; padding:2px 4px; border-radius:4px; border:1px solid rgba(255,214,140,.4); opacity:.75; }
#chatDock .avatar-hint { margin:0 2px; }
.bubble.whisper { font-style:italic; font-size:.85em; opacity:.82; }
/* combat.js: the player's health and weapon in the chat dock */
.player-hp { display:flex; align-items:center; gap:8px; font-size:12px; margin:2px 0 4px; }
.player-hp .hp-label { font-weight:600; }
.player-hp .hp-bar { flex:1; height:8px; border-radius:4px; background:rgba(255,255,255,.12); overflow:hidden; min-width:60px; }
.player-hp .hp-bar span { display:block; height:100%; background:linear-gradient(90deg,#d84a3a,#e8b04a); transition:width .3s; }
.player-hp .hp-num { font-variant-numeric:tabular-nums; }
.player-hp .hp-weapon { opacity:.85; }
.player-hp.down .hp-bar span { background:#555; }
/* speech-input.js */
.mic-btn { min-width:38px; display:inline-flex; align-items:center; gap:4px; }
.mic-btn .mic-engine { font-size:10px; line-height:1.1; opacity:.75; white-space:nowrap; }
.mic-btn .mic-engine:empty { display:none; }
.mic-btn[data-state="rec"] { background:#c0392b; color:#fff; animation:micPulse 1s ease-in-out infinite; }
.mic-btn[data-state="busy"] { opacity:.6; }
@keyframes micPulse { 50% { box-shadow:0 0 0 6px rgba(192,57,43,.25); } }

/* ---- user / dev mode (tabs.js): dev-only things hide in user mode ---- */
body.user-mode .dev-only { display:none !important; }
body.user-mode #compassHud small, body.user-mode #spatialDebug { display:none !important; }

/* ---- side panel: slides in and out, collapse button, resize edge ---- */
#sidePanel { display:block; transform:translateX(-14px); opacity:0; visibility:hidden; pointer-events:none;
  transition:transform .18s ease, opacity .18s ease, visibility 0s linear .18s; }
#sidePanel.open { transform:none; opacity:1; visibility:visible; pointer-events:auto; transition:transform .18s ease, opacity .18s ease; }
#sidePanel.resizing { transition:none; user-select:none; }
#sidePanel .panel-tools { position:sticky; top:-12px; z-index:3; height:0; display:flex; justify-content:flex-end; }
#panelClose { width:30px; height:30px; padding:0; margin:-4px -4px 0 0; border-radius:10px; background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.14); color:#cfe3d6; cursor:pointer; }
#panelClose:hover { background:rgba(159,232,200,.2); color:#fff; }
#panelClose svg, #railToggle svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; display:block; margin:auto; }
#panelResize { position:absolute; top:18px; bottom:18px; right:-4px; width:9px; cursor:ew-resize; z-index:4; border-radius:6px; }
#panelResize:hover, #sidePanel.resizing #panelResize { background:rgba(159,232,200,.28); }
#sidePanel .pane-title { padding-right:36px; }
#rail .rail-toggle { margin-top:8px; opacity:.75; }
#rail .rail-toggle svg { transition:transform .18s ease; }
body.panel-open #rail .rail-toggle svg { transform:rotate(180deg); }

/* ---- Adventurer pane (play.js) ---- */
#advPane .adv-stat { display:flex; align-items:center; gap:10px; margin:6px 0; font-size:13px; color:#dfe9dc; }
#advPane .adv-stat > span:first-child { width:70px; color:#aebead; font-size:12px; }
#advPane .adv-stat .hp-bar { flex:1; height:9px; border-radius:6px; background:rgba(255,255,255,.1); overflow:hidden; }
#advPane .adv-stat .hp-bar > span { display:block; height:100%; background:linear-gradient(90deg,#e0503c,#f2b13c); }
#advPane .adv-gold { color:#ffd166; }
#advPane .adv-goal { font-size:12px; line-height:1.45; color:#e8f1e4; margin:4px 2px; }
#advPane .adv-items { list-style:none; margin:4px 0; padding:0; }
#advPane .adv-items li { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:6px 8px; margin:3px 0; border-radius:10px; background:rgba(255,255,255,.06); font-size:13px; }
#advPane .adv-items small { color:#aebead; }
#advPane .adv-acts { display:flex; gap:4px; }
#advPane .adv-acts button { padding:3px 8px; font-size:11px; border-radius:8px; }
#pane-adventurer .adv-keys { display:grid; grid-template-columns:1fr 1fr; gap:5px 10px; font-size:11px; color:#c7d4c4; }
#pane-adventurer kbd { display:inline-block; min-width:16px; padding:1px 4px; margin-right:2px; border-radius:5px; border:1px solid rgba(255,255,255,.25); background:rgba(255,255,255,.08); font:10px ui-monospace,monospace; text-align:center; color:#fff; }

/* ---- "skeleton's turn" while nearby characters act (play.js) ---- */
#npcTurnBanner { position:fixed; left:50%; top:70px; transform:translate(-50%,-8px); z-index:80; padding:8px 16px; border-radius:14px; font-size:13px; color:#f4f0e6;
  background:rgba(16,20,25,.78); border:1px solid rgba(255,214,140,.35); backdrop-filter:blur(10px); opacity:0; pointer-events:none; transition:opacity .15s, transform .15s; }
#npcTurnBanner.show { opacity:1; transform:translate(-50%,0); }
#sidePanel #panelClose { flex:0 0 30px; }
/* toasts sit beside the panel, not on it */
#toastStack { transition:left .18s ease; }
body.panel-open #toastStack { left:calc(var(--panel-w, 364px) + 78px); }
/* ---- Messages pane, hurt flash (play.js) ---- */
#msgPane { font-size:12.5px; line-height:1.45; max-height:calc(100vh - 160px); overflow-y:auto; }
#msgPane .msg { padding:4px 6px; border-radius:7px; margin:2px 0; color:#e3ece0; }
#msgPane .msg time { color:#8e9c8b; font:10px ui-monospace,monospace; margin-right:7px; }
#msgPane .m-fight { background:rgba(224,80,60,.12); }
#msgPane .m-loot { background:rgba(255,209,102,.10); }
#msgPane .m-talk { background:rgba(159,232,200,.07); }
#hurtFlash { position:fixed; inset:0; z-index:90; pointer-events:none; opacity:0; box-shadow:inset 0 0 140px 40px rgba(200,20,10,.75); }
#hurtFlash.on { animation:hurt .45s ease-out; }
@keyframes hurt { 0% { opacity:1; } 100% { opacity:0; } }
#defeatCard[hidden] { display:none; }
#adminLink { color:#cfe3d6; text-decoration:none; margin-right:8px; }
#adminLink:hover { color:#9fe8c8; }
/* someone with a brain is thinking; the player can keep moving */
#npcThinking { position:fixed; left:50%; top:70px; transform:translate(-50%,-8px); z-index:79; padding:5px 12px; border-radius:12px; font-size:12px; font-style:italic; color:#dfe6dc;
  background:rgba(16,20,25,.55); opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; }
#npcThinking.show { opacity:1; transform:translate(-50%,0); }
/* ---- tabletop view (?tabletop=1, tabletop.js) ---- */
html.tabletop body > *:not(#renderCanvas):not(#ttBar):not(#ttOverlay):not(#toastStack):not(#ttTip) { display:none !important; }
#ttTip { position:fixed; z-index:20; pointer-events:none; max-width:300px; background:rgba(20,18,16,.94); color:#f4eee4; border:1px solid #6b5b45; border-radius:8px; padding:6px 9px; font:12.5px/1.35 system-ui, sans-serif; box-shadow:0 4px 14px rgba(0,0,0,.4); }
#ttTip[hidden] { display:none; } #ttTip hr { border:0; border-top:1px solid #5a4c3a; margin:5px 0; } #ttTip .muted { color:#b9ab95; }
html.tabletop body { background:#1b1d1f; overflow:hidden; }
html.tabletop #renderCanvas, #ttOverlay { position:fixed; left:0; top:var(--tt-top, 44px); width:100vw; height:calc(100vh - var(--tt-top, 44px)); }
#ttOverlay { pointer-events:none; z-index:5; }
html.tabletop #renderCanvas { cursor:grab; touch-action:none; }
html.tabletop.tt-edit #renderCanvas { cursor:crosshair; }
html.tabletop.tt-panning #renderCanvas { cursor:grabbing; }
#ttBar { position:fixed; left:0; right:0; top:0; z-index:10; display:flex; flex-wrap:wrap; gap:6px 12px; align-items:center; padding:7px 12px; font:13px system-ui, sans-serif; color:#e9ece6;
  background:#24272b; border-bottom:1px solid #3a3e44; }
#ttBar label { display:inline-flex; gap:4px; align-items:center; cursor:pointer; white-space:nowrap; }
#ttBar button, #ttBar select { white-space:nowrap; width:auto; font:inherit; color:#e9ece6; background:#33373d; border:1px solid #4a4f57; border-radius:7px; padding:3px 9px; cursor:pointer; }
#ttBar button:hover { background:#3d4249; }
#ttBar button.hot { background:#2f6b3a; border-color:#4fa35f; }
#ttBar .sep { flex:1; }
#ttBar #ttStatus { color:#aab3a7; font-size:12px; }
#ttCharsBox { position:relative; }
#ttCharsBox summary { cursor:pointer; }
#ttChars { position:absolute; top:24px; left:0; min-width:180px; max-height:60vh; overflow:auto; padding:8px 10px; background:#24272b; border:1px solid #4a4f57; border-radius:9px; display:flex; flex-direction:column; gap:4px; z-index:12; }
#ttChars .hostile { color:#ff9a8a; }
#ttChars .row { display:flex; gap:5px; margin-top:4px; }
html:fullscreen #ttBar { display:none; }
#ttBar > * { flex:0 0 auto; }
/* giving (play.js): drag from the Adventurer pane onto a character */
#advPane .adv-drag[draggable="true"] { cursor:grab; }
#advPane .adv-drag[draggable="true"]:hover { background:rgba(255,255,255,.05); }
#giveHint { position:fixed; z-index:120; pointer-events:none; padding:4px 9px; border-radius:8px; font:600 12px system-ui, sans-serif; color:#fff; background:rgba(40,110,60,.92); opacity:0; transition:opacity .1s; }
#giveHint.show { opacity:1; } #giveHint.far { background:rgba(110,60,40,.92); }
#giveGold { position:fixed; z-index:121; display:flex; gap:6px; align-items:center; padding:8px 10px; border-radius:10px; font:13px system-ui, sans-serif; color:#eee; background:rgba(28,30,34,.96); border:1px solid #4a4f57; box-shadow:0 6px 20px rgba(0,0,0,.45); }
#giveGold input { width:5em; }
/* roles.js: a shopkeeper's offer the player can accept */
#shopOffer { position:fixed; z-index:121; left:50%; bottom:96px; transform:translateX(-50%); display:flex; gap:8px; align-items:center; padding:8px 12px; border-radius:10px; font:13px system-ui, sans-serif; color:#eee; background:rgba(28,30,34,.96); border:1px solid #4a4f57; box-shadow:0 6px 20px rgba(0,0,0,.45); }

/* registry.js: the Library pane's package list */
#pkgResults { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.pkg-row { border: 1px solid rgba(255,255,255,.12); border-radius: 8px; padding: 8px; background: rgba(255,255,255,.03); }
.pkg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pkg-tag { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,.1); }
.pkg-src-builtin, .pkg-src-official { background: rgba(120,200,140,.22); }
.pkg-code { background: rgba(230,170,80,.25); }
.pkg-desc { font-size: 12px; opacity: .85; margin: 4px 0; }
.pkg-ref { font-size: 11px; opacity: .75; overflow-wrap: anywhere; margin-bottom: 4px; }
.pkg-trust-row { display: flex; gap: 6px; align-items: center; font-size: 11px; overflow-wrap: anywhere; }

/* app.js tablefolkHoldRender: a note while the picture is held */
#renderHold { position:fixed; left:50%; top:42%; transform:translate(-50%,-50%); z-index:40; display:flex; gap:10px; align-items:center; padding:10px 16px; border-radius:12px;
  background:rgba(18,16,14,.82); color:#f2ebde; font:600 15px system-ui, sans-serif; box-shadow:0 6px 24px rgba(0,0,0,.45); opacity:0; pointer-events:none; transition:opacity .25s; }
#renderHold.show { opacity:1; }
#renderHold .spin { width:16px; height:16px; border-radius:50%; border:2px solid rgba(242,235,222,.3); border-top-color:#f2c26b; animation:renderHoldSpin .9s linear infinite; }
@keyframes renderHoldSpin { to { transform:rotate(360deg); } }

/* live.js: let them live */
.view-btns > .live-btn { grid-column:1 / -1; order:-1; padding:7px 10px; font-size:13px; background:rgba(120,220,140,.14); border-color:rgba(140,230,160,.45); color:#dfffe4; }
.live-btn.active { background:rgba(120,220,140,.22); border-color:rgba(140,230,160,.55); color:#d8ffe0; }
.live-status:empty { display:none; }
.live-status { color:#cfe9d4; font-style:italic; }
/* director.js: the narrator's line */
#narration { position:fixed; left:50%; top:74px; transform:translate(-50%,-8px); max-width:min(640px,86vw); padding:.55rem 1.1rem; border-radius:12px;
  background:rgba(22,18,14,.82); color:#f3e6cc; font:italic 500 15px/1.4 Georgia,serif; text-align:center; box-shadow:0 6px 20px rgba(0,0,0,.35);
  opacity:0; transition:opacity .35s, transform .35s; pointer-events:none; z-index:30; }
#narration.show { opacity:1; transform:translate(-50%,0); }
/* world-integration.js: what a character sees when it looks (vision brains) */
#sightCard { position:fixed; left:16px; bottom:120px; width:min(300px,70vw); margin:0; background:rgba(20,17,13,.9); border:1px solid rgba(255,220,160,.3); border-radius:12px; overflow:hidden;
  box-shadow:0 8px 24px rgba(0,0,0,.4); opacity:0; transform:translateY(8px); transition:opacity .3s, transform .3s; pointer-events:none; z-index:25; }
#sightCard.show { opacity:1; transform:none; }
#sightCard img { display:block; width:100%; aspect-ratio:448/320; object-fit:cover; }
#sightCard figcaption { padding:.5rem .7rem; color:#f1e6cf; font-size:13px; line-height:1.4; }
#sightCard b { color:#ffd98a; }
/* welcome.js: pick a world */
#welcome { position:fixed; inset:0; z-index:1000; display:flex; align-items:center; justify-content:center; padding:20px; background:rgba(8,10,12,.62); backdrop-filter:blur(6px); }
#welcome[hidden] { display:none; }
#welcome .wl-card { position:relative; width:min(980px,100%); max-height:100%; overflow:auto; background:#1b1814; color:#efe6d6; border:1px solid rgba(255,220,160,.18); border-radius:20px; padding:28px 30px 22px; box-shadow:0 24px 70px rgba(0,0,0,.55); }
#welcome header h1 { margin:0 0 6px; font:700 30px/1.1 Georgia,serif; color:#ffd98a; letter-spacing:.01em; }
#welcome header p { margin:0 0 20px; color:#cbbfa9; max-width:64ch; line-height:1.5; }
#welcome kbd { font:700 12px ui-monospace,monospace; padding:1px 6px; border:1px solid #6b5b45; border-radius:5px; }
#welcome .wl-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:14px; }
#welcome .wl-world { display:flex; flex-direction:column; gap:6px; text-align:left; padding:14px; border-radius:14px; border:1px solid rgba(255,220,160,.16); background:linear-gradient(180deg,rgba(255,220,160,.07),rgba(255,220,160,.02)); color:inherit; font:inherit; cursor:pointer; transition:transform .12s, border-color .12s, background .12s; }
#welcome .wl-world:hover, #welcome .wl-world:focus-visible { transform:translateY(-2px); border-color:rgba(255,217,138,.6); background:linear-gradient(180deg,rgba(255,220,160,.13),rgba(255,220,160,.04)); outline:none; }
#welcome .wl-who { display:flex; gap:0; height:76px; align-items:flex-end; overflow:hidden; margin:-4px -6px 0; }
#welcome .wl-who img { height:120px; width:auto; margin:0 -22px -16px; filter:drop-shadow(0 3px 4px rgba(0,0,0,.45)); }
#welcome .wl-who img:first-child { margin-left:-14px; }
#welcome .wl-world b { font-size:16px; color:#fff3dc; }
#welcome .wl-pitch { font-size:13.5px; color:#cbbfa9; line-height:1.4; }
#welcome .wl-tags { display:flex; flex-wrap:wrap; gap:4px; margin-top:2px; }
#welcome .wl-tags i { font-style:normal; font-size:11px; padding:1px 7px; border-radius:999px; background:rgba(255,217,138,.13); color:#ffd98a; }
#welcome footer { display:flex; gap:16px; align-items:center; flex-wrap:wrap; margin-top:20px; color:#9d917d; font-size:12.5px; }
#welcome .wl-build { padding:.55rem 1rem; border-radius:10px; background:#d9ae6f; color:#1b1814; font-weight:700; text-decoration:none; font-size:14px; }
#welcome .wl-build:hover { background:#e7c48e; }
#welcome .wl-x { position:absolute; top:12px; right:14px; width:34px; height:34px; border-radius:50%; border:0; background:rgba(255,255,255,.06); color:#cbbfa9; font-size:20px; cursor:pointer; }
#welcome .wl-x:hover { background:rgba(255,255,255,.14); }
.worlds-btn { flex:none; width:auto; margin-left:8px; padding:4px 12px; border-radius:999px; border:1px solid rgba(255,214,140,.4); background:rgba(255,200,110,.1); color:#ffe2ad; font-weight:700; font-size:12px; cursor:pointer; }
.worlds-btn:hover { background:rgba(255,200,110,.22); }
@media (max-width:600px) { #welcome .wl-card { padding:20px 16px; } #welcome header h1 { font-size:24px; } }

/* world-integration.js: the download question waits for the welcome screen and intro card */
#modelLoadNotice.ducked { display:none !important; }
/* phones: the top bar keeps the name, the worlds button and the brain's status */
@media (max-width:700px) {
  #topBar { gap:6px; padding:0 8px; }
  #topBar .brand { font-size:14px; }
  #topBar .topbar-brain { display:none; }
  #topBar #brainStatus { overflow:hidden; text-overflow:ellipsis; min-width:0; flex:1 1 auto; }
  #chatDock .avatar-hint { display:none; }
  #chatDock { max-height:46vh; overflow:auto; }
  #scenarioBanner { top:60px !important; bottom:auto !important; left:70px !important; right:8px !important; max-width:none !important; font-size:12px; }
}
/* live.js: how much happens */
.view-btns > .pace-pick { grid-column:1 / -1; order:-1; display:flex; align-items:center; justify-content:flex-end; gap:6px; margin:-2px 2px -2px 0; font-size:11px; color:#cfe9d4; }
.pace-pick select { font:inherit; font-size:11px; padding:2px 6px; border-radius:999px; border:1px solid rgba(140,230,160,.35); background:rgba(10,20,14,.6); color:#dfffe4; }

/* head-window.js: the webcam preview while the window view runs */
.head-window-preview { position:fixed; left:16px; bottom:16px; width:120px; height:90px; z-index:65; border-radius:8px; overflow:hidden; border:1px solid rgba(255,255,255,.25); box-shadow:0 4px 14px rgba(0,0,0,.4); opacity:.85; pointer-events:none; }
.head-window-preview i { position:absolute; left:50%; top:50%; width:8px; height:8px; margin:-4px 0 0 -4px; border-radius:50%; background:#d7ff9a; box-shadow:0 0 6px #d7ff9a; }

/* ---- "This browser" in the Graphics pane (browser-check.js) ---- */
.browser-check { width:100%; border-collapse:collapse; font:10px/1.35 ui-monospace,monospace; color:#d8e4d2; margin-bottom:6px; }
.browser-check td { padding:3px 4px; vertical-align:top; border-top:1px solid rgba(255,255,255,.06); }
.browser-check td:first-child { width:12px; font-weight:900; }
.browser-check td:nth-child(2) { font-weight:850; white-space:nowrap; }
.browser-check td:nth-child(3) { word-break:break-word; }
.browser-check .bc-enables { color:#8a9a88; font-size:9px; }
.browser-check tr.bc-ok td:first-child, .browser-runs .bc-ok { color:#8befae; }
.browser-check tr.bc-no td:first-child, .browser-runs .bc-no { color:#ffc878; }
.browser-check tr.bc-info td:first-child { color:#8a9a88; }
.browser-runs { list-style:none; margin:0 0 4px; padding:0 2px; font:10px/1.45 ui-monospace,monospace; }

/* video-recorder.js: the ⏺ button in the top bar */
#videoRecBtn { flex:0 0 auto; min-width:36px; height:36px; padding:0 10px; border-radius:18px; display:inline-flex; align-items:center; justify-content:center; gap:6px; background:rgba(255,255,255,.10); }
#videoRecBtn .rec-dot { width:12px; height:12px; border-radius:50%; background:#e0524a; box-shadow:0 0 0 2px rgba(255,255,255,.18); }
#videoRecBtn .rec-time { font:600 12px ui-monospace,monospace; color:#fff; }
#videoRecBtn .rec-time:empty { display:none; }
#videoRecBtn.recording { background:rgba(192,57,43,.85); }
#videoRecBtn.recording .rec-dot { border-radius:2px; background:#fff; animation:micPulse 1s ease-in-out infinite; }

/* ---- player's view (tabs.js user mode): two rail icons, a chat-only dock ---- */
body.dev-mode .user-only { display:none !important; }
body.user-mode #rail .rail-dev { display:none !important; }
/* Adventurer pane: the view buttons, moved here from the dock in user mode */
.adv-play:not(:has(#viewBtns:not([hidden]))) { display:none; }
#advPlaySlot .view-btns { margin-bottom:4px; }
/* Settings pane (user mode): your name, links to Voice / Graphics / Messages, developer mode */
#settingsNameSlot .chat-name-label { margin-bottom:4px; }
#settingsNameSlot .chat-name-label input { font-size:12px; padding:7px 9px; }
.settings-links { display:flex; flex-direction:column; gap:6px; }
.settings-links button { display:flex; flex-direction:column; align-items:flex-start; gap:2px; width:100%; padding:9px 12px; text-align:left; border-radius:12px;
  background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.12); color:#eaf2df; position:relative; }
.settings-links button::after { content:"›"; position:absolute; right:12px; top:50%; transform:translateY(-50%); font-size:18px; color:#9fe8c8; }
.settings-links button:hover { background:rgba(159,232,200,.12); border-color:rgba(159,232,200,.35); }
.settings-links b { font-size:13px; }
.settings-links small { font-size:11px; color:#aebead; font-weight:500; padding-right:16px; }
.settings-dev { width:100%; padding:8px 12px; border-radius:12px; font-size:12px; color:#ffd479; background:rgba(255,212,121,.10); border:1px solid rgba(255,212,121,.35); }
.settings-dev:hover { background:rgba(255,212,121,.2); }
.pane-back { display:inline-block; margin:0 0 6px; padding:3px 10px 3px 8px; border-radius:999px; font-size:11px; background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.13); color:#cfe3d6; }
.pane-back:hover { background:rgba(159,232,200,.16); color:#fff; }

/* chat dock: input, history, mic and send never overlap (the mic's engine label used to run under "send") */
.chat-send-row { align-items:stretch; min-width:0; }
.chat-send-row input { min-width:0; }
.chat-send-row > button { flex:0 0 auto; min-width:0; }
.chat-send-row > #chatSend { flex:0 0 auto; padding:7px 12px; }
.chat-send-row > .mic-btn { flex:0 1 auto; min-width:38px; max-width:110px; padding:5px 8px; overflow:hidden; justify-content:center; }
.chat-send-row > .mic-btn .mic-engine { overflow:hidden; text-overflow:ellipsis; }
.chat-icon-btn { width:34px; padding:0 !important; display:inline-flex; align-items:center; justify-content:center; background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.14); color:#cfe3d6; }
.chat-icon-btn svg { width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.chat-icon-btn:hover, .chat-icon-btn.active { color:#9fe8c8; background:rgba(159,232,200,.14); }
/* user mode: the dock is the conversation; the rest lives in the Adventurer and Settings panes */
body.user-mode #chatDock { width:380px; gap:6px; padding:8px 10px; }
body.user-mode #chatDock .avatar-hint, body.user-mode #chatDock .player-items { display:none; }
body.user-mode #chatDock #chatTarget.single { display:none; }
body.user-mode #chatDock .chat-send-row input { font-size:13px; padding:9px 10px; }
/* health in the dock only while it matters (hurt or down); the Adventurer pane always has it */
body.user-mode #playerHp.full:not(.down) { display:none; }
body.user-mode #playerHp { font-size:11px; }
@media (max-width:520px) {
  #chatDock, body.user-mode #chatDock { left:8px; right:8px; width:auto; bottom:8px; }
  .chat-send-row > .mic-btn .mic-engine { display:none; }
}
/* Voice pane: one column, long engine names and the helpers button stay inside the panel */
#pane-voice .custom-grid { grid-template-columns:minmax(0,1fr); }
#pane-voice .custom-grid > * { min-width:0; }
#pane-voice select, #pane-voice input[type="text"] { width:100%; min-width:0; max-width:100%; box-sizing:border-box; text-overflow:ellipsis; }
#pane-voice .helpers-row { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
#pane-voice .helpers-row button { white-space:normal; }
#pane-voice input[type="text"] { border:1px solid rgba(255,255,255,.18); color:#fff; background:rgba(0,0,0,.28); border-radius:10px; padding:6px 8px; font-size:11px; }
@media (max-width:520px) { #sidePanel { max-width:calc(100vw - 70px); } }
