#connection-badge{box-sizing:border-box;position:fixed;right:12px;top:86px;z-index:1001;display:flex;align-items:center;gap:8px;width:132px;min-height:44px;margin:0;padding:7px 9px;background:#153d37ed;color:#edfff7;border:1px solid #7ac3ad;border-radius:6px;box-shadow:0 0 11px #75e7bb20;text-align:left;touch-action:manipulation;font:12px system-ui}
#connection-badge strong{display:block;font-size:11px;line-height:14px;font-weight:750}#connection-badge small{display:block;font-size:11px;line-height:15px;max-width:99px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.connection-square{display:block;flex:none;width:8px;height:8px;border-radius:1px;background:#b3c2c8;box-shadow:0 0 6px #b3c2c850}
#connection-badge[data-state=responding] .connection-square{background:#83f5be;box-shadow:0 0 8px #83f5be80}
#connection-badge[data-state=unstable] .connection-square,#connection-badge[data-state=slow] .connection-square,#connection-badge[data-state=rate-limited] .connection-square{background:#ffd274}
#connection-badge[data-state=offline] .connection-square,#connection-badge[data-state=server-error] .connection-square,#connection-badge[data-state=no-response] .connection-square,#connection-badge[data-state=access-error] .connection-square,#connection-badge[data-state=application-error] .connection-square,#connection-badge[data-state=request-error] .connection-square{background:#ff9a8e}
#connection-badge:focus-visible{outline:3px solid #cbffe6;outline-offset:2px}
body.lab-panel-open>#connection-badge,body.lab-panel-open>#connection-dialog{visibility:visible!important}
#world-status{max-width:min(460px,calc(100vw - 170px))}
#connection-dialog{box-sizing:border-box;position:fixed;inset:0;width:min(460px,calc(100vw - 24px));max-height:calc(100dvh - 24px);margin:auto;padding:0;border:1px solid #76cbb7;border-radius:14px;background:#173b37;color:#effff8;box-shadow:0 18px 80px #0009;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;z-index:100002}
#connection-dialog::backdrop{background:#071c22c9}
#connection-dialog .connection-card{padding:16px;display:flex;flex-direction:column;gap:15px}
#connection-dialog .connection-heading{position:sticky;top:-16px;background:#173b37;z-index:1;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 0}
#connection-dialog h2{font-size:23px;line-height:1.2;margin:0}#connection-dialog h3{font-size:17px;margin:0 0 7px;line-height:1.3;color:#e8fff1}
#connection-dialog p{font-size:14px;line-height:1.45;margin:5px 0;color:#e0f0e9}#connection-dialog small,#connection-dialog .connection-note{font-size:12px;color:#b7d8cb;line-height:1.4}
#connection-dialog section{border-bottom:1px solid #6d9e8d55;padding-bottom:12px}#connection-dialog .connection-summary{background:#214f44;border:1px solid #76cbb755;border-radius:8px;padding:12px}
#connection-dialog button{min-height:44px;margin:0;padding:9px 14px;border:1px solid #83c9b2;border-radius:6px;background:#28574c;color:#f1fff7;font:700 14px system-ui;touch-action:manipulation;cursor:pointer}
#connection-dialog button:focus-visible,#connection-dialog summary:focus-visible{outline:3px solid #c0ffdf;outline-offset:2px}#connection-dialog button:disabled{opacity:.55;cursor:wait}
#connection-dialog [data-connection-close]{width:44px;height:44px;min-width:44px;font-size:27px;line-height:1;padding:0}
#connection-dialog [data-connection-retry],#connection-dialog [data-connection-done]{background:#b9f4da;color:#123e30;width:100%;margin-top:8px}
#connection-dialog .connection-metrics{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:12px 0}#connection-dialog dt{font-size:12px;line-height:1.4;color:#bedace}#connection-dialog dd{margin:3px 0 0;font-size:18px;font-weight:750;overflow-wrap:anywhere}
#connection-dialog summary{min-height:44px;display:list-item;padding:10px 2px;font-size:15px;font-weight:750;cursor:pointer;touch-action:manipulation}
#connection-dialog .connection-details{display:grid;grid-template-columns:1fr 1fr;gap:8px 14px;margin:8px 0}#connection-dialog .connection-details dd{font-size:13px;font-weight:600;margin:0}
@media(pointer:coarse){#connection-badge{top:74px;width:120px}#connection-badge small{max-width:87px}#world-status{max-width:min(460px,calc(100vw - 154px))}}
@media(max-height:550px){#connection-badge{top:auto;bottom:max(8px,env(safe-area-inset-bottom));left:12px;right:auto;width:120px;min-height:44px}#connection-dialog .connection-card{padding:12px;gap:12px}#connection-dialog .connection-heading{top:-12px}#world-status{max-width:min(460px,calc(100vw - 36px))}}
/* Maker Lab reserves a header slot: connection health must never cover part controls. */
body:has(#cosmic-playground.lab-open)>#connection-badge{top:10px;right:10px;bottom:auto;left:auto;width:44px;height:44px;min-height:44px;padding:0;justify-content:center}
body:has(#cosmic-playground.lab-open)>#connection-badge>span:not(.connection-square){display:none}
#cosmic-playground.lab-open .object-lab .lab-header{padding-right:64px}
@media(max-height:500px) and (min-width:701px){body:has(#cosmic-playground.lab-open)>#connection-badge{top:3px}}
