// Session badge + HF login (library is owner-only; guests get an isolated 24h workspace).
(async()=>{
const css=document.createElement("style");
css.textContent="#hfLogin{white-space:nowrap}@media (max-width:700px){.top-actions .privacy{display:none}#hfLogin{padding:6px 9px;font-size:11px;white-space:nowrap}#hfLogin .long{display:none}}";
document.head.appendChild(css);
const pill=document.querySelector(".status-pill, .privacy");
const box=document.createElement("span"); box.id="authBox"; box.style.cssText="display:inline-flex;gap:8px;align-items:center";
pill?.parentNode.insertBefore(box,pill);
let me={};
try{me=await (await fetch("/api/v1/me",{credentials:"same-origin",cache:"no-store"})).json()}catch(_){}
const a=document.createElement("a"); a.className="btn btn-soft"; a.id="hfLogin"; a.target="_top";
if(me.signed_in){
if(pill) pill.innerHTML=me.owner?` PRIVAT · nur du`:` GAST · eigene Projekte (${me.guest_ttl_hours||24} h)`;
a.href="/logout"; a.textContent="Abmelden";
}else{
if(pill) pill.innerHTML=` GAST · eigene Projekte (${me.guest_ttl_hours||24} h)`;
a.href="/login"; a.innerHTML="Mit Hugging Face anmelden"; a.title="Mit Hugging Face anmelden";
}
box.appendChild(a);
})();