:root{
  --bg:#1F1F1E; --surface:#2B2B29; --userBubble:#2E2E2C; --userText:#ECEBE6; --text:#ECEBE6;
  --muted:#9B988F; --accent:#D97757; --border:#3A3A37; --bubbleR:16px;
}
*{box-sizing:border-box}
html,body{margin:0}
body{font-family:Inter,system-ui,sans-serif;background:#121211;color:#ECEAE4;min-height:100vh}
button{font:inherit;cursor:pointer}

/* ---------- layout ---------- */
.top{display:flex;align-items:center;gap:12px;padding:14px 18px;border-bottom:1px solid #2a2925}
.brand{font-weight:600;letter-spacing:.18em;font-size:13px}
.brand small{display:block;font-weight:400;letter-spacing:.04em;color:#8d8a82;font-size:11px;margin-top:2px}
.app{display:grid;grid-template-columns:minmax(0,1fr) 350px;gap:18px;padding:18px}
/* desktop: page never scrolls; chat stays put, the side panel scrolls on its own */
@media(min-width:901px){
  html,body{height:100%;overflow:hidden}
  body{display:flex;flex-direction:column}
  .top{flex:0 0 auto}
  .app{flex:1;min-height:0;grid-template-rows:minmax(0,1fr)}
  .stage{justify-content:center;min-height:0;height:100%}
  .frame{height:min(72vh,600px,calc(100% - 64px))}
  .frame.phone{height:min(800px,calc(100% - 64px))}
  .app .panel{align-self:stretch;overflow-y:auto;overscroll-behavior:contain;min-height:0}
}
/* phone / narrow: chat sticks to the top, the panel scrolls underneath */
@media(max-width:900px){
  .app{grid-template-columns:1fr;padding:10px;gap:10px}
  .top{padding:10px 14px}
  .stage{position:sticky;top:0;z-index:20;background:#121211;padding:8px 0 10px;margin:0 -10px;box-shadow:0 10px 18px -8px rgba(0,0,0,.6)}
  .frame,.frame.phone{height:50vh;max-height:540px}
  .controls{gap:6px}
  .controls .btn{padding:7px 10px;font-size:12px}
  .seg button{padding:7px 9px}
}
.stage{display:flex;flex-direction:column;align-items:center;gap:12px;min-width:0}

/* ---------- chat frame ---------- */
.frame{width:100%;max-width:780px;height:min(72vh,600px);background:var(--bg);color:var(--text);
  border-radius:14px;overflow:hidden;display:flex;flex-direction:column;position:relative;
  box-shadow:0 20px 60px rgba(0,0,0,.5);outline:1px solid #2a2925;transition:background .3s,color .3s,max-width .3s,height .3s}
.frame.phone{max-width:390px;height:min(80vh,800px);border-radius:28px}
.frame:fullscreen{max-width:none;height:100vh;border-radius:0}
.fhead{height:52px;flex:0 0 52px;display:flex;align-items:center;gap:10px;padding:0 16px}
.menuI{width:20px;height:20px;color:var(--muted);flex:0 0 20px}
.logoSlot{width:26px;height:26px;border-radius:7px;cursor:pointer;overflow:hidden;flex:0 0 26px}
.logoSlot:not(.has){display:none}
.logoSlot img,.av img{width:100%;height:100%;object-fit:contain;display:block}
.ftitle{font-size:15px;outline:none;border-radius:4px;padding:2px 4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.frame.serif .ftitle{font-family:"Source Serif 4",Georgia,serif}
.ftitle:focus{background:var(--userBubble)}
.badge{margin-left:4px;font-size:9.5px;letter-spacing:.14em;padding:3px 8px;border-radius:99px;border:1px solid var(--border);color:var(--muted);flex:0 0 auto}
.badge.off{display:none}

.msgs{flex:1;overflow-y:auto;padding:14px 0 18px;scrollbar-width:none}
.msgs::-webkit-scrollbar{display:none}
.col{max-width:680px;margin:0 auto;padding:0 18px;display:flex;flex-direction:column;gap:18px}
.stamp{align-self:center;font-size:12px;color:var(--muted);margin:-4px 0 -6px}
.stamp b{font-weight:600}
.frame:not(.ts) .stamp{display:none}
.user{align-self:flex-end;background:var(--userBubble);color:var(--userText);padding:11px 15px;border-radius:var(--bubbleR);max-width:85%;
  font-size:15px;line-height:1.45;white-space:pre-wrap;animation:pop .28s cubic-bezier(.2,.9,.3,1.2)}
@keyframes pop{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}
.turn{display:flex;gap:12px;align-items:flex-start}
.av{width:24px;height:24px;flex:0 0 24px;border-radius:7px;background:var(--accent);overflow:hidden;margin-top:2px}
.av.has{background:transparent}
.frame.noav .av{display:none}
.tw{flex:1;min-width:0;display:flex;flex-direction:column;gap:14px}


/* header buttons */
.tgroup{display:flex;align-items:center;gap:8px;min-width:0;flex:0 1 auto}
.fsub{font-size:15px;color:var(--muted);outline:none;white-space:nowrap;margin-left:-4px}
.fsub:empty{display:none}
.frame.notitle .ftitle,.frame.notitle .fsub,.frame.notitle .tchev{display:none}
.hright{margin-left:auto;display:flex;align-items:center;gap:10px;flex:0 0 auto}
.hbtn{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;color:var(--text);flex:0 0 38px}
.hbtn svg,.hpill svg{width:20px;height:20px}
.hpill{height:38px;border-radius:19px;display:flex;align-items:center;gap:22px;padding:0 14px;color:var(--text)}
.hpill span{display:grid;place-items:center}
.mi,.ei{display:none!important}
.frame.menu-3 .mi-3,.frame.menu-2 .mi-2,.frame.menu-eq .mi-eq{display:block!important}
.frame.edit-sq .ei-sq,.frame.edit-arc .ei-arc{display:grid!important}
.frame:not(.hdevice) #hDevice{display:none}
.frame:not(.hright-on) .hright{display:none}
/* floating glass header */
.frame.hfloat .fhead{position:absolute;top:0;left:0;right:0;z-index:5;height:66px;
  background:linear-gradient(to bottom,var(--bg) 35%,color-mix(in srgb,var(--bg) 0%,transparent));padding:0 12px}
.frame.hfloat .msgs{padding-top:72px}
.frame.hfloat .hbtn,.frame.hfloat .hpill{background:color-mix(in srgb,var(--text) 9%,var(--bg));
  border:1px solid color-mix(in srgb,var(--text) 9%,transparent);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
  box-shadow:0 4px 14px rgba(0,0,0,.25)}
.frame.hfloat .hbtn{width:44px;height:44px;flex-basis:44px}
.frame.hfloat .hpill{height:44px;border-radius:22px;padding:0 16px}
.frame.hfloat .tgroup{margin-left:6px}

/* status rows */
.row{display:flex;flex-direction:column;animation:fade .3s ease}
@keyframes fade{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}
.rhead{display:flex;align-items:center;gap:9px;background:none;border:none;padding:0;color:var(--muted);
  font-size:13.5px;text-align:left;max-width:100%;min-width:0}
.ricon{width:16px;height:16px;flex:0 0 16px;display:grid;place-items:center;color:var(--muted)}
.ricon:empty{display:none}
.ricon svg{width:15px;height:15px}
.dots{display:flex;gap:2.5px}
.dots i{width:3.5px;height:3.5px;border-radius:50%;background:var(--accent);animation:dot 1.1s ease-in-out infinite}
.dots i:nth-child(2){animation-delay:.15s}.dots i:nth-child(3){animation-delay:.3s}
@keyframes dot{0%,100%{opacity:.35;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}
.rlabel{position:relative;min-width:0;flex:0 1 auto;overflow:hidden;white-space:nowrap}
.rlabel span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:opacity .35s, filter .35s}
.rlabel span.out{position:absolute;inset:0;opacity:0;filter:blur(2px)}
.live .rlabel span:not(.out){background:linear-gradient(90deg,var(--muted) 0%,var(--muted) 35%,var(--text) 50%,var(--muted) 65%,var(--muted) 100%);
  background-size:250% 100%;-webkit-background-clip:text;background-clip:text;color:transparent;animation:shim 1.8s linear infinite}
@keyframes shim{from{background-position:100% 0}to{background-position:-50% 0}}
.chev{flex:0 0 auto;transition:transform .25s;font-size:16px;line-height:1;margin-left:2px}
.row.open .chev{transform:rotate(90deg)}
.row.nochev .chev{display:none}
.rbody{overflow:hidden;max-height:0;opacity:0;transition:max-height .45s ease,opacity .3s,padding .3s;
  border-left:2px solid var(--border);margin:0 0 0 7px;padding:0 0 0 14px;font-size:13.5px;line-height:1.55;color:var(--muted)}
.row.open .rbody{max-height:300px;opacity:1;padding:8px 0 4px 14px}
.rows{display:flex;flex-direction:column;gap:8px}

/* pending dot */
.pdot{width:13px;height:13px;border-radius:50%;background:var(--accent);animation:pd 1.2s ease-in-out infinite;margin:4px 0}
@keyframes pd{0%,100%{transform:scale(.8);opacity:.75}50%{transform:scale(1.05);opacity:1}}

.orbit{width:22px;height:22px;position:relative;margin:2px 0;animation:sp 1.4s linear infinite}
.orbit i{position:absolute;width:5px;height:5px;border-radius:50%;background:var(--accent);left:50%;top:50%;margin:-2.5px}
.orbit i:nth-child(1){transform:translate(0,-7px)}
.orbit i:nth-child(2){transform:translate(6px,4px);opacity:.7}
.orbit i:nth-child(3){transform:translate(-6px,4px);opacity:.45}
.disc{font-size:11.5px;color:var(--muted);margin-top:-4px;animation:fade .4s ease}
.frame:not(.disc-on) .disc{display:none}
.tchev{width:14px;height:14px;color:var(--muted);flex:0 0 14px;margin-left:-6px}
.frame:not(.tchev-on) .tchev{display:none}

/* tool chip */
.tool{display:inline-flex;align-self:flex-start;align-items:center;gap:8px;font-size:13px;padding:6px 11px;border-radius:9px;
  background:var(--surface);border:1px solid var(--border);animation:fade .25s ease}
.tool .res{color:var(--muted)}
.spin{width:12px;height:12px;border-radius:50%;border:2px solid var(--border);border-top-color:var(--accent);animation:sp .7s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}
.check{width:13px;height:13px;color:var(--accent)}

/* answer */
.answer{font-size:16px;line-height:1.55}
.frame.serif .answer{font-family:"Source Serif 4",Georgia,serif;font-size:17px}
.answer p,.answer ul,.answer ol{margin:0 0 .7em}
.answer > :last-child{margin-bottom:0}
.answer h3{font-size:1.12em;font-weight:600;margin:.2em 0 .45em;line-height:1.3}
.answer ul,.answer ol{padding-left:1.3em}
.answer li{margin:.2em 0}
.answer strong{font-weight:600}
.answer .w{opacity:0;transition:opacity var(--fadeMs,250ms) ease}
.answer .w.in{opacity:1}

/* action row */
.acts{display:flex;align-items:center;gap:15px;color:var(--muted);animation:fade .4s ease;margin-top:-2px}
.acts svg{width:17px;height:17px}
.srcs{display:flex;align-items:center;gap:6px;font-size:13px}
.srcs i{width:13px;height:13px;border-radius:50%;border:1.5px solid var(--bg);margin-left:-6px;display:block}
.srcs i:first-child{margin-left:0}
.frame:not(.acts-on) .acts{display:none}

/* composer */
.composer{padding:8px 12px 14px;flex:0 0 auto}
.cbox{max-width:680px;margin:0 auto;background:var(--surface);border:1px solid var(--border);border-radius:30px;
  min-height:54px;display:flex;align-items:center;gap:6px;padding:6px}
.cbtn{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;flex:0 0 40px;color:var(--text);transition:background .2s,color .2s,opacity .2s}
.frame.cbtn-bg .cbtn{background:color-mix(in srgb,var(--text) 7%,transparent)}
.cbtn svg{width:19px;height:19px}
.ctext{flex:1;font-size:15.5px;line-height:1.4;padding:4px 2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.ctext.typing{white-space:pre-wrap}
.ph{color:var(--muted)}
.ccaret{display:inline-block;width:1.5px;height:1.05em;background:var(--accent);vertical-align:-.15em;animation:blink 1s steps(1) infinite}
@keyframes blink{50%{opacity:0}}
#actBtn .ico{display:none}
#actBtn[data-s="send"]{background:var(--accent);color:#fff}
#actBtn[data-s="send"] .i-send{display:block}
#actBtn[data-s="stop"] .i-stop{display:block}
#actBtn[data-s="idle"] .i-send{display:block}
#actBtn[data-s="idle"]{opacity:.4}
.frame.idle-wave #actBtn[data-s="idle"]{opacity:1;background:var(--accent);color:#fff}
.frame.idle-wave #actBtn[data-s="idle"] .i-send{display:none}
.frame.idle-wave #actBtn[data-s="idle"] .i-wave{display:block}
.frame.stop-accent #actBtn[data-s="stop"]{background:var(--accent);color:#fff}
.i-stop{width:13px!important;height:13px!important}
.i-stopo{width:17px!important;height:17px!important}
.frame.stop-outline #actBtn[data-s="stop"] .i-stop{display:none}
.frame.stop-outline #actBtn[data-s="stop"] .i-stopo{display:block}
.frame.wave-dot #actBtn{position:relative}
.frame.wave-dot.idle-wave #actBtn[data-s="idle"]::after{content:"";position:absolute;top:8px;right:9px;width:6px;height:6px;border-radius:50%;background:#5A9BFF}
/* stacked composer: grows to two rows while typing */
.frame.stack .cbox.tall{flex-wrap:wrap;border-radius:26px;padding:14px 8px 8px}
.frame.stack .cbox.tall .ctext{order:-1;flex:1 0 100%;padding:0 10px 10px;white-space:pre-wrap}
.frame.stack .cbox.tall #plusBtn{margin-right:auto}
.frame.nomic #micBtn,.frame.noplus #plusBtn{display:none}

/* ---------- controls ---------- */
.controls{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:center}
.btn{background:#262521;color:#ECEAE4;border:1px solid #34332e;border-radius:9px;padding:8px 14px;font-size:13px}
.btn:hover{border-color:#55534b}
.btn.primary{background:#D97757;border-color:#D97757;color:#fff}
.btn.on{border-color:#D97757;background:#33241d}
.seg{display:inline-flex;border:1px solid #34332e;border-radius:9px;overflow:hidden}
.seg button{background:#1e1d1a;color:#bbb;border:none;padding:8px 11px;font-size:12px}
.seg button.on{background:#3a3833;color:#fff}
.clock{font-variant-numeric:tabular-nums;font-size:12px;color:#8d8a82;min-width:52px;text-align:center}

/* ---------- panel ---------- */
.panel{background:#1b1a18;border:1px solid #2c2b27;border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:20px;align-self:start}
.panel h3{margin:0 0 9px;font-size:11px;letter-spacing:.16em;color:#8d8a82;font-weight:600}
textarea,.txt,select{width:100%;background:#121110;color:#e5e2da;border:1px solid #33322d;border-radius:9px;padding:10px;
  font:12.5px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}
textarea{min-height:240px;resize:vertical}
.txt,select{font:13px Inter,sans-serif;padding:8px 10px}
.hint{font-size:11.5px;color:#8d8a82;line-height:1.6;margin-top:6px}
.hint code{color:#e2a68e}
.styles{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.styleCard{background:#121110;border:1px solid #33322d;border-radius:10px;padding:9px;text-align:left;color:#ddd;display:flex;flex-direction:column;gap:7px;font-size:12.5px}
.styleCard.on{border-color:#D97757;box-shadow:0 0 0 1px #D97757 inset}
.mini{height:38px;border-radius:6px;display:flex;flex-direction:column;justify-content:center;gap:4px;padding:0 7px}
.mini .mu{align-self:flex-end;width:46%;height:8px;border-radius:5px}
.mini .ma{width:72%;height:4px;border-radius:3px;opacity:.8}
.styleCard small{color:#8d8a82;font-size:11px}
.swatches{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.sw{display:flex;align-items:center;gap:8px;font-size:12px;color:#cfcbc2}
.sw input{width:30px;height:24px;border:1px solid #3a3833;border-radius:6px;padding:0;background:none}
.prow{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.toggles{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.toggle{display:flex;align-items:center;gap:8px;font-size:12.5px;color:#cfcbc2}
.fields{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:12px}
.field{display:flex;flex-direction:column;gap:5px;font-size:12px;color:#cfcbc2}
.field.full{grid-column:1/-1}

/* library */
.styleCard{position:relative}
.styleCard .xbtn{position:absolute;top:5px;right:5px;background:rgba(0,0,0,.55);color:#ddd;line-height:22px;text-align:center}
.slist{display:flex;flex-direction:column;gap:6px;margin-top:10px}
.sitem{display:flex;align-items:center;gap:8px;background:#121110;border:1px solid #33322d;border-radius:9px;padding:5px 5px 5px 10px}
.sitem .nm{flex:1;min-width:0;text-align:left;background:none;border:none;color:#e5e2da;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:4px 0}
.sitem .nm:hover{color:#fff}
.sitem small{color:#8d8a82;font-size:11px;flex:0 0 auto}
.xbtn{display:inline-block;background:none;border:none;color:#8d8a82;font-size:16px;width:26px;height:26px;border-radius:6px;cursor:pointer;flex:0 0 26px}
.xbtn:hover{color:#fff;background:#2a2925}

/* record view */
body.clean .top,body.clean .panel,body.clean .controls{display:none}
body.clean .app{grid-template-columns:1fr;padding:0;min-height:100vh;height:100vh;place-items:center}
body.clean .stage{position:static;margin:0;box-shadow:none}
body.clean .frame,body.clean .frame.phone{height:min(92vh,800px);max-height:none}
body.clean .stage{justify-content:center;min-height:100vh}
.exitClean{position:fixed;top:10px;left:10px;opacity:.12;display:none;z-index:9}
.exitClean:hover{opacity:1}
body.clean .exitClean{display:block}
