:root {
  --bg: #14122a; --panel: #1d1a38; --card: #252147; --line: #35305e;
  --text: #f1edff; --muted: #a59fcb; --accent: #ffb35c; --go: #4fd18b; --wait: #ffb35c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Nunito, 'Segoe UI', sans-serif; }
.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- scene ---------- */
.viewport { flex: 1; position: relative; overflow: hidden; background: radial-gradient(ellipse at 50% 30%, #2a2552, #14122a 70%); }
.stage { position: absolute; left: 0; top: 0; width: 1600px; height: 1000px; transform-origin: 0 0; }
.layer { position: absolute; inset: 0; }
#bg svg, #fg svg { display: block; }
#fg { pointer-events: none; }
#bubbles { pointer-events: none; }

.agent { position: absolute; left: 0; top: 0; width: 64px; height: 96px; cursor: pointer; transition: opacity .45s; will-change: transform; }
.agent.hidden { opacity: 0; pointer-events: none; }
.agent .flip { width: 64px; height: 96px; }
.agent svg { display: block; overflow: visible; }
.agent .tag {
  position: absolute; left: 50%; top: 100px; transform: translateX(-50%); white-space: nowrap;
  font: 700 12px Fredoka, sans-serif; color: #fff; background: #1d1a38cc; padding: 2px 8px; border-radius: 8px;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.agent:hover .tag, .agent.selected .tag { opacity: 1; }
.agent .ring { position: absolute; left: 8px; top: 88px; width: 48px; height: 12px; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; }
.agent.selected .ring { opacity: 1; animation: ring 1.2s ease-in-out infinite; }
@keyframes ring { 50% { transform: scale(1.15); opacity: .6; } }

/* character parts */
.legs-sit, .prop, .eyes-closed { display: none; }
.sit .legs-stand { display: none; }
.sit .legs-sit { display: inline; }
.sit .c-pos { transform: translateY(4px); }
.prop-cup .p-cup, .prop-can .p-can, .prop-phone .p-phone { display: inline; }
.relax .eyes-open { display: none; }
.relax .eyes-closed { display: inline; }

.leg-front { transform-origin: 35.5px 66px; }
.leg-back  { transform-origin: 28.5px 66px; }
.arm-front { transform-origin: 34.6px 47px; transform: rotate(-6deg); }
.arm-back  { transform-origin: 29.2px 47px; transform: rotate(6deg); }
.eyes-open { transform-origin: 41px 26px; animation: blink 4.6s infinite; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

.walk .leg-front { animation: swing .44s ease-in-out infinite alternate; }
.walk .leg-back  { animation: swing .44s ease-in-out infinite alternate-reverse; }
.walk .arm-front { animation: swing2 .44s ease-in-out infinite alternate-reverse; }
.walk .arm-back  { animation: swing2 .44s ease-in-out infinite alternate; }
.walk .c-bob     { animation: bob .22s ease-in-out infinite alternate; }
@keyframes swing  { from { transform: rotate(-24deg); } to { transform: rotate(24deg); } }
@keyframes swing2 { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-2.5px); } }

.idle .c-bob { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translateY(-1px); } }

.type .arm-front { animation: typeA .17s ease-in-out infinite alternate; }
.type .arm-back  { animation: typeB .21s ease-in-out infinite alternate; }
.type .head { animation: think 5s ease-in-out infinite; transform-origin: 32px 40px; }
@keyframes typeA { from { transform: rotate(-100deg); } to { transform: rotate(-110deg); } }
@keyframes typeB { from { transform: rotate(-86deg); } to { transform: rotate(-95deg); } }
@keyframes think { 0%, 70%, 100% { transform: rotate(0); } 80%, 90% { transform: rotate(-4deg); } }

.drink .arm-front { animation: sip 3.4s ease-in-out infinite; }
@keyframes sip { 0%, 55% { transform: rotate(-68deg); } 68%, 86% { transform: rotate(-135deg); } 100% { transform: rotate(-68deg); } }

.phone .arm-front { transform: rotate(-58deg); animation: scroll 1.8s ease-in-out infinite; }
@keyframes scroll { 50% { transform: rotate(-64deg); } }
.phone .head { transform: rotate(6deg); transform-origin: 32px 40px; }

.massage .c-bob { animation: vib .08s linear infinite alternate; }
@keyframes vib { from { transform: translate(-.7px, 0); } to { transform: translate(.7px, -.5px); } }

/* bubbles */
.bubble {
  position: absolute; left: 0; top: 0; max-width: 220px; width: max-content;
  background: #fff; color: #2a2340; font: 700 13px/1.3 Nunito, sans-serif; padding: 7px 11px; border-radius: 14px;
  box-shadow: 0 4px 0 #00000022; opacity: 0; transition: opacity .25s; text-align: center;
}
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fff; }
.bubble.show { opacity: 1; }

/* scene animations */
.ed-l, .ed-r { transition: transform .45s ease; }
.elev.open .ed-l { transform: translateX(-34px); }
.elev.open .ed-r { transform: translateX(34px); }
.desk .scr rect { animation: scr 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: left; }
@keyframes scr { 0% { transform: scaleX(.2); } 60%, 100% { transform: scaleX(1); } }
.desk .scr, .desk .scr-bg { transition: opacity .5s; }
.desk:not(.on) .scr { opacity: 0; }
.desk:not(.on) .scr-bg { opacity: .35; }
.bar { transform-box: fill-box; transform-origin: bottom; animation: bar 2.2s ease-in-out infinite alternate; }
@keyframes bar { from { transform: scaleY(.55); } to { transform: scaleY(1); } }
.led { animation: led 1s steps(2) infinite; }
@keyframes led { 50% { opacity: .25; } }
.rec { animation: led 1.4s steps(2) infinite; }
.vwave { transform-box: fill-box; transform-origin: center; animation: vwave .7s ease-in-out infinite alternate; }
@keyframes vwave { from { transform: scaleY(.25); } to { transform: scaleY(1.3); } }
.qawave { stroke-dasharray: 8 4; animation: dash 1.5s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -24; } }
.scan { animation: scan 3s linear infinite; }
@keyframes scan { from { transform: translateX(0); } to { transform: translateX(230px); } }
.heart { animation: heart 2.7s ease-out infinite; opacity: 0; }
@keyframes heart { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-60px); opacity: 0; } }
.steam path { animation: steam 1.8s ease-out infinite; opacity: 0; }
@keyframes steam { 0% { transform: translateY(4px); opacity: 0; } 30% { opacity: .9; } 100% { transform: translateY(-14px); opacity: 0; } }
.cctv { animation: cctv 2.2s linear infinite; }
@keyframes cctv { from { transform: translateY(0); } to { transform: translateY(23px); } }
.neon { animation: neon 6s infinite; }
@keyframes neon { 0%, 46%, 50%, 100% { opacity: 1; } 48% { opacity: .4; } }
.live { animation: led 1.6s steps(2) infinite; }
#stamp.pop { animation: stamp 2.6s ease forwards; transform-box: fill-box; transform-origin: center; }
@keyframes stamp { 0% { opacity: 0; transform: scale(2); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
.paused .stage * { animation-play-state: paused !important; }

/* ---------- panel ---------- */
.panel { width: 370px; flex-shrink: 0; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, #ffb35c, #e0564f); display: grid; place-items: center; font: 700 24px Fredoka, sans-serif; color: #fff; }
.brand h1 { margin: 0; font: 700 20px Fredoka, sans-serif; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.clock { margin-left: auto; font: 600 15px Fredoka, sans-serif; color: var(--accent); background: var(--card); padding: 6px 10px; border-radius: 10px; }
.chip { display: inline-block; white-space: nowrap; margin-top: 4px; font: 700 10px Nunito, sans-serif; letter-spacing: .5px; padding: 2px 7px; border-radius: 6px; }
.chip.demo { background: #ffb35c26; color: var(--accent); border: 1px solid #ffb35c66; cursor: help; }

.controls { display: flex; gap: 8px; }
.btn, .speed button { font: 700 13px Nunito, sans-serif; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; }
.btn:hover, .speed button:hover { border-color: var(--accent); }
.speed { display: flex; margin-left: auto; }
.speed button { border-radius: 0; margin-left: -1px; }
.speed button:first-child { border-radius: 10px 0 0 10px; }
.speed button:last-child { border-radius: 0 10px 10px 0; }
.speed button.on { background: var(--accent); color: #2a1d10; border-color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div { background: var(--card); border-radius: 12px; padding: 8px 6px; text-align: center; }
.stats b { display: block; font: 700 22px Fredoka, sans-serif; }
.stats span { font-size: 11px; color: var(--muted); font-weight: 700; }
.stats div:first-child b { color: var(--go); }

.card { background: var(--card); border-radius: 14px; padding: 12px 14px; }
.card.grow { flex: 1; min-height: 160px; display: flex; flex-direction: column; }
.card h2 { margin: 0 0 10px; font: 600 13px Fredoka, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }

.pipeline { display: flex; flex-direction: column; gap: 7px; }
.prow { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; border: 1px solid transparent; }
.prow.live { border-color: #4fd18b44; background: #4fd18b0d; }
.picon { width: 30px; height: 30px; border-radius: 9px; background: #ffffff10; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.pbody { flex: 1; min-width: 0; }
.ptop { display: flex; justify-content: space-between; font-size: 13px; }
.pstate { font-size: 11px; font-weight: 800; }
.pstate.go { color: var(--go); } .pstate.wait { color: var(--wait); } .pstate.idle { color: #6f6a96; }
.pjob { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 1px 0 4px; }
.pbar { height: 5px; background: #ffffff12; border-radius: 3px; overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffb35c, #4fd18b); border-radius: 3px; transition: width .25s linear; }

.agent-info { display: flex; gap: 12px; align-items: center; }
.agent-info.muted { color: var(--muted); font-size: 13px; }
.avatar { width: 72px; height: 84px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; overflow: hidden; }
.avatar svg { width: 64px; height: 96px; margin-top: 14px; }
.ainfo h3 { margin: 0; font: 700 18px Fredoka, sans-serif; }
.ainfo p { margin: 2px 0; font-size: 13px; }
.ainfo .role { font-weight: 800; }
.ainfo .aroom, .ainfo .adone { color: var(--muted); }
.astatus.work { color: var(--go); } .astatus.break { color: var(--wait); } .astatus.walk, .astatus.tour { color: #8fb7ff; }

.log { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; font-size: 12.5px; }
.log li { display: grid; grid-template-columns: 52px 20px 1fr; gap: 4px; padding: 5px 0; border-bottom: 1px solid #ffffff0d; }
.log time { color: #7d78a8; font-size: 11px; padding-top: 1px; }
.log p { margin: 0; color: #d8d3f2; }

@media (max-width: 900px) {
  .app { flex-direction: column; height: auto; }
  .viewport { height: 62vw; min-height: 300px; flex: none; }
  .panel { width: 100%; border-left: 0; }
}

/* voice room */
.vr-status { float: right; font: 800 10px Nunito, sans-serif; letter-spacing: .5px; padding: 2px 7px; border-radius: 6px; text-transform: none; }
.vr-status.on { background: #4fd18b22; color: var(--go); }
.vr-status.off { background: #ff7a7a22; color: #ff9b9b; }
.vr-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.vr-row select { flex: 1; min-width: 0; }
select, textarea { font: 600 13px Nunito, sans-serif; color: var(--text); background: #1b1836; border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; }
textarea { width: 100%; resize: vertical; margin-bottom: 8px; }
select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.vr-count { font-size: 12px; color: var(--muted); }
.btn.primary { margin-left: auto; background: var(--accent); color: #2a1d10; border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.vr-result audio { width: 100%; margin-top: 4px; }
.vr-result p { margin: 6px 0 0; font-size: 12px; }
.vr-result code { font-size: 11px; word-break: break-all; }
.ok { color: var(--go); } .err { color: #ff9b9b; } .muted { color: var(--muted); }
input[type=datetime-local]{font:600 13px Nunito,sans-serif;color:var(--text);background:#1b1836;border:1px solid var(--line);border-radius:10px;padding:6px 8px;color-scheme:dark}

/* library */
.lib-btn { flex: 1; }
.lib-count { background: var(--accent); color: #2a1d10; border-radius: 8px; padding: 0 6px; font-size: 11px; margin-left: 3px; }
.next-post { margin: -4px 0 8px; font-size: 12px; color: var(--muted); }
.next-post a { color: var(--accent); text-decoration: none; font-weight: 800; }
.lib { position: fixed; inset: 0; background: #0b0a1acc; backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 24px; }
.lib[hidden] { display: none; }
.lib-box { width: min(1180px, 100%); height: min(860px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px #0008; }
.lib-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.lib-head h2 { margin: 0; font: 700 20px Fredoka, sans-serif; white-space: nowrap; }
.lib-tabs { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.lib-tabs button { font: 700 13px Nunito, sans-serif; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.lib-tabs button.on { color: #2a1d10; background: var(--accent); border-color: var(--accent); }
.lib-tabs i { font-style: normal; opacity: .7; margin-left: 3px; }
.lib-sched { padding: 12px 16px 4px; background: var(--card); border-bottom: 1px solid var(--line); }
.sched-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.sched-row .grow { flex: 1; }
.tchip { display: inline-flex; align-items: center; background: #1b1836; border: 1px solid var(--line); border-radius: 10px; padding: 2px 2px 2px 6px; margin-right: 4px; }
.tchip input { background: transparent; border: 0; color: var(--text); font: 700 13px Nunito, sans-serif; color-scheme: dark; }
.tchip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 6px; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.sched-tip { margin: 8px 0; font-size: 12px; color: #d8d3f2; }
.sched-tip code, .lib-sched code { font-size: 11px; background: #ffffff10; padding: 1px 5px; border-radius: 5px; }
.lib-msg p { margin: 8px 16px 0; font-size: 13px; }
.lib-grid { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; align-content: start; }
.lib-empty { grid-column: 1 / -1; text-align: center; padding: 60px 0; color: #d8d3f2; font-size: 15px; line-height: 1.8; }
.lcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.thumb { position: relative; height: 300px; overflow: hidden; background: #000; display: grid; place-items: center; flex-shrink: 0; }
.thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.thumb .play { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%; border: 0; background: #ffffffd9; color: #2a2340; font-size: 20px; cursor: pointer; }
.thumb .dur { position: absolute; right: 8px; bottom: 8px; background: #000b; color: #fff; font: 700 11px Nunito, sans-serif; padding: 2px 6px; border-radius: 6px; }
.kchip { position: absolute; left: 8px; top: 8px; font: 800 10px Nunito, sans-serif; padding: 2px 7px; border-radius: 6px; letter-spacing: .4px; }
.kchip.reel { background: #ff7a6b; color: #fff; } .kchip.vid { background: #5aa9ff; color: #fff; }
.lbody { padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.ltitle { font: 700 14px Fredoka, sans-serif; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 3px 5px; margin: 0 -5px; }
.ltitle:hover:not(:disabled), .ltitle:focus { border-color: var(--line); background: #1b1836; outline: none; }
.lcap { margin: 0; font-size: 12px; }
.lmeta { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.schip { font: 800 10.5px Nunito, sans-serif; padding: 2px 8px; border-radius: 6px; }
.st-new { background: #ffffff14; color: #d8d3f2; } .st-queued { background: #ffb35c26; color: var(--accent); }
.st-sched { background: #5aa9ff26; color: #8fc4ff; } .st-posted { background: #4fd18b26; color: var(--go); }
.st-draft { background: #b28cff26; color: #cdb4ff; } .st-error { background: #ff7a7a26; color: #ff9b9b; }
.when { font-size: 12px; font-weight: 800; color: #d8d3f2; }
.lact { display: flex; gap: 6px; }
.lact select { flex: 1; min-width: 0; font-size: 12px; padding: 5px 6px; }
.small { font-size: 11px; margin: 0; }

.manual { padding: 0; }
.manual summary { cursor: pointer; padding: 12px 14px; font: 600 13px Fredoka, sans-serif; letter-spacing: .5px; list-style: none; }
.manual summary::-webkit-details-marker { display: none; }
.manual summary::before { content: '▸ '; color: var(--muted); }
.manual[open] summary::before { content: '▾ '; }
.manual summary .muted { font: 600 11px Nunito, sans-serif; letter-spacing: 0; }
.manual .voice-card { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.manual .voice-card h2 { margin: 10px 0; font: 600 13px Fredoka, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.sched-card .next-post { margin: 0; font-size: 13px; color: #d8d3f2; line-height: 1.6; }

/* login */
.login { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 30%, #2a2552, #0d0b1f 75%); }
.login-box { width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: 0 20px 60px #0008; }
.login-box .logo { margin: 0 auto; }
.login-box h1 { margin: 0; font: 700 22px Fredoka, sans-serif; }
.login-box p { margin: 0; color: var(--muted); font-size: 13px; }
.login-box input { font: 700 15px Nunito, sans-serif; color: var(--text); background: #1b1836; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box .btn { margin: 0; padding: 10px; font-size: 14px; }
.logout { color: var(--muted); font-size: 12px; }
.pipe-note { margin: -4px 0 10px; font-size: 12.5px; color: #d8d3f2; line-height: 1.45; }
.sit.idle .arm-front { transform: rotate(-40deg); }
.sit.idle .arm-back { transform: rotate(-30deg); }

/* autopilot switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { display: none; }
.switch span { width: 38px; height: 22px; border-radius: 11px; background: #ffffff22; position: relative; transition: background .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--go); }
.switch input:checked + span::after { transform: translateX(16px); }
.ap-note { font-size: 12px; }
.sched-row + .sched-row { margin-top: 8px; }
.sched-row select { font-size: 12px; padding: 4px 6px; }
.tag { font: 800 10.5px Nunito, sans-serif; color: #cdb4ff; }

/* analytics */
.lib-head .grow { flex: 1; }
.an-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.an-page { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.an-page h3 { margin: 0 0 12px; font: 700 18px Fredoka, sans-serif; }
.an-page h4 { margin: 0 0 8px; font: 600 13px Fredoka, sans-serif; letter-spacing: .5px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #1b1836; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi span { font-size: 11px; color: var(--muted); font-weight: 800; }
.kpi b { font: 700 24px Fredoka, sans-serif; }
.kpi i { font-style: normal; font-size: 10.5px; color: #7d78a8; }
.spark { width: 100%; height: 34px; display: block; margin-top: 2px; }
.an-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.an-top { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.an-top span { display: block; color: var(--muted); font-size: 12px; }
.tbar { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: center; font-size: 12px; margin-bottom: 6px; }
.tbar i { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #ffb35c, #ff5f7e); min-width: 4px; }
.tbar b { font-weight: 800; color: #d8d3f2; white-space: nowrap; }
@media (max-width: 900px) { .an-cols { grid-template-columns: 1fr; } }
