/* Living Universe V0.6 — artwork stays behind the interface throughout the scroll. */
body.kxe-living{isolation:isolate;background:#16124d!important;}
.kxe-universe{position:fixed;inset:0;z-index:-1;pointer-events:none;overflow:hidden;background:#16124d url('universe/space.webp') center/cover no-repeat;contain:strict;}
.kxe-universe-canvas{display:block;width:100%;height:100%;pointer-events:none;}
/* Universe remains visible during both departure and return. */
body.kxe-living .ks-hero{background:transparent!important;position:relative;}
body.kxe-living .kxe-star-map{background:linear-gradient(145deg,#291b61da,#1e134edb);}
body.kxe-living .kxe-rail{background:linear-gradient(155deg,#38216fef,#20134fe8);backdrop-filter:none;}
body.kxe-living .kxe-hq{background:radial-gradient(ellipse at 50% 22%,#8754dc33,transparent 64%)!important;border:0!important;box-shadow:none!important;overflow:visible;isolation:isolate;min-height:clamp(330px,38vw,460px);padding:clamp(20px,4vw,56px) clamp(6px,2vw,24px) 24px;align-content:center;gap:26px;}
.kxe-hq-art{position:absolute;inset:0;pointer-events:none;z-index:-1;overflow:hidden;}
.kxe-hq-art img{position:absolute;object-fit:contain;filter:drop-shadow(0 8px 14px #100b45aa);animation:kxe-hq-float 7s ease-in-out infinite;}
.kxe-hq-planet{width:clamp(68px,15%,170px);right:2%;top:0;transform:rotate(-14deg);opacity:.88;}.kxe-hq-book{width:clamp(58px,12%,120px);left:3%;top:32%;animation-delay:-2s!important;}.kxe-hq-crystal{width:clamp(54px,11%,112px);right:1%;bottom:12%;animation-delay:-4s!important;}.kxe-hq-star{width:clamp(35px,6%,72px);left:14%;top:2%;animation-delay:-3s!important;}
@keyframes kxe-hq-float{0%,100%{translate:0 0}50%{translate:0 -11px}}
body.kxe-living .kxe-hq .ksp-profile-identity{display:flex;flex-direction:column;text-align:center;justify-content:center;gap:10px;position:relative;z-index:1;padding:0 12%;}
body.kxe-living .kxe-hq .ksp-profile-avatar{width:clamp(66px,8vw,96px);height:clamp(66px,8vw,96px);border-radius:50%;border:2px solid #ffd061;background:radial-gradient(#7953d3,#38216f);box-shadow:0 0 32px #8754dc88;}
body.kxe-living .kxe-hq .ksp-profile-identity h1{font-size:clamp(28px,5vw,58px);line-height:1.12;color:#ffd061;text-shadow:0 3px 0 #57317c,0 0 30px #ffd06130;margin:5px 0;opacity:var(--kxe-hud-fade,1);}
body.kxe-living .kxe-hq .ksp-stat-carousel{position:relative;z-index:1;max-width:780px;width:100%;margin:auto;}
body.kxe-living .kxe-hq .ksp-stat{display:grid;grid-template-columns:minmax(0,1fr);justify-items:center;text-align:center;gap:4px;min-height:118px;padding:12px 7px;border:1px solid #a98af0;background:linear-gradient(160deg,#52329cdd,#24134eea);box-shadow:0 5px 0 #150d38,0 0 24px #8754dc22;opacity:var(--kxe-hud-fade,1);}
.kxe-stat-illustrated{display:inline-flex;justify-content:center;align-items:center;width:32px;height:32px;}.kxe-stat-art{width:100%;height:100%;object-fit:contain;display:block;}.kxe-hq .kxe-stat-illustrated{width:48px;height:48px;}.kxe-hq .ksp-stat strong{font-size:clamp(18px,3vw,31px)!important;}
body.kxe-living .kxe-hq .ksp-stat-position{color:#e1d3ff;}
/* Keep the original wallet available to assistive technology. The HUD mirrors only its real values. */
body.kxe-hud-ready #ks-header .ksp-wallet{position:absolute!important;width:1px!important;height:1px!important;clip-path:inset(50%);overflow:hidden;padding:0!important;border:0!important;white-space:nowrap;}
body.kxe-hud-ready #ks-header .ks-header-inner{position:relative;min-height:72px;}
body.kxe-hud-ready #ks-header{background:#20134feb;overflow:visible!important;}
.kxe-hud-name{position:absolute;left:35%;right:35%;top:0;bottom:0;line-height:72px;text-align:center;font-size:clamp(14px,1.6vw,22px);font-weight:850;color:#ffd061;max-width:none;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;pointer-events:none;opacity:0;z-index:2;}
.kxe-hud-stats{display:flex;gap:5px;pointer-events:none;align-items:center;justify-content:flex-end;}
.kxe-hud-badge{display:flex;align-items:center;gap:4px;padding:5px 7px;background:#38216f;border:1px solid #8d6bd0;border-radius:10px;font-size:12px;color:#fff5dc;white-space:nowrap;opacity:0;min-width:0;}
.kxe-hud-badge img{width:23px;height:23px;object-fit:contain;flex:none;}.kxe-hud-badge b{font-size:inherit;font-weight:800;max-width:8ch;overflow:hidden;text-overflow:ellipsis;}

@media(max-width:1000px){.kxe-hud-name{left:31%;right:43%;}.kxe-hud-badge{padding:4px;gap:3px;font-size:11px;}.kxe-hud-badge img{width:19px;height:19px;}}
@media(max-width:760px){body.kxe-hud-ready #ks-header .ks-header-inner{min-height:86px;padding-bottom:30px!important;}.kxe-hud-name{left:6%;right:6%;top:auto;bottom:4px;height:20px;line-height:20px;max-width:none;font-size:13px;}.kxe-hud-stats{gap:3px;}.kxe-hud-badge{padding:3px;gap:2px;font-size:10px;}.kxe-hud-badge img{width:15px;height:15px;}.kxe-hud-badge b{max-width:5ch;}.kxe-hq .kxe-stat-illustrated{width:35px;height:35px;}body.kxe-living .kxe-hq .ksp-stat{min-height:90px;}body.kxe-living .kxe-hq{min-height:320px;gap:20px;}.kxe-hq-art img{opacity:.62;}}
@media(max-width:380px){.kxe-hud-badge img{width:13px;height:13px;}.kxe-hud-badge{padding:2px;}.kxe-hud-stats{gap:2px;}body.kxe-hud-ready #ks-navigation{gap:4px!important;}}
@media(prefers-reduced-motion:reduce){.kxe-hq-art img{animation:none!important;}}
.kxe-motion-off .kxe-hq-art img{animation:none!important;}
body.kxe-hud-ready #ks-header.kxe-hud-compact{background:#20134f;box-shadow:0 6px 22px #0e092e70;}

/* V0.6.1: the same deep-space layer remains visible during the portal. */
body.kxe-living .kxe-singularity-back{background:transparent!important;opacity:0!important;}
html.kxe-arriving::before{background:#16124d url('universe/space.webp') center/cover no-repeat;}
body.kxe-living .kxe-catalog-relic{width:clamp(84px,18%,150px);bottom:8px;right:16px;animation:kxe-hq-float 6s ease-in-out infinite;}
/* The moving HUD is the only visible copy while the original keeps its layout and accessible values. */
body.kxe-hud-ready .kxe-hud-name{overflow:visible;text-shadow:0 2px 6px #160b3d;}
body.kxe-hud-ready #ks-header.kxe-hud-compact .kxe-hud-name{overflow:hidden;}
body.kxe-hud-ready .ksp-profile-hero h1,body.kxe-hud-ready .ksp-profile-hero .ksp-stat{transition:none!important;}
/* Teacher galaxy: orbital medallions with native Core link hit areas. */
body.kxe-living .ksp-teacher-strip.kxe-teacher-galaxy{padding:18px 12px 24px;gap:16px;align-items:stretch;background:linear-gradient(135deg,#281b5d99,#17124d44);border:1px solid #8754dc66;border-radius:24px;scrollbar-color:#8754dc #22164d;}
body.kxe-living .kxe-teacher-galaxy .ksp-teacher-card{--tc:hsl(var(--teacher-hue) 88% 74%);position:relative;isolation:isolate;flex:0 0 clamp(148px,14vw,205px);display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:8px;padding:14px 9px 12px;min-height:204px;overflow:visible;border-radius:22px;border:1px solid color-mix(in srgb,var(--tc) 50%,#38216f);background:radial-gradient(ellipse at 50% 30%,color-mix(in srgb,var(--tc) 20%,transparent),transparent 65%),linear-gradient(160deg,#392470e8,#1b124de8);box-shadow:0 5px 0 #100a30,0 10px 20px #100a3040;text-align:center;outline:none;transition:translate .2s,box-shadow .25s,border-color .25s;}
.kxe-teacher-orbit{position:relative;width:clamp(83px,9vw,122px);height:clamp(83px,9vw,122px);display:grid;place-items:center;isolation:isolate;margin:3px auto 4px;}
.kxe-teacher-orbit:before{content:'';position:absolute;inset:-7px;border-radius:50%;border:1px solid var(--tc);opacity:.42;box-shadow:0 0 18px color-mix(in srgb,var(--tc) 36%,transparent);z-index:-1;}
.kxe-teacher-ring{position:absolute;inset:-7px;border-radius:50%;border:2px solid transparent;border-top-color:var(--tc);border-bottom-color:var(--tc);opacity:.9;animation:kxe-teacher-orbit 8s linear infinite;pointer-events:none;}
@keyframes kxe-teacher-orbit{to{transform:rotate(360deg)}}
body.kxe-living .kxe-teacher-galaxy .ksp-teacher-cover,body.kxe-living .kxe-teacher-galaxy .ksp-teacher-symbol{width:100%;height:100%;min-width:0;border-radius:50%;object-fit:cover;border:2px solid var(--tc);background:radial-gradient(#49309d,#241550);box-shadow:0 0 20px color-mix(in srgb,var(--tc) 22%,transparent);overflow:hidden;}
.kxe-public-planet{width:95%;height:95%;object-fit:contain;}
.kxe-teacher-star{position:absolute;right:-11px;top:-6px;color:var(--tc);font-size:24px;line-height:1;text-shadow:0 0 12px var(--tc);pointer-events:none;}
body.kxe-living .kxe-teacher-galaxy .ksp-teacher-card strong{background:transparent!important;color:#fff5ff!important;min-height:2.5em;padding:0 2px;font-size:clamp(13px,1.1vw,16px);line-height:1.25;display:grid;place-items:center;overflow-wrap:anywhere;width:100%;}
.kxe-teacher-status{font-size:10px;font-weight:750;letter-spacing:.045em;text-transform:uppercase;color:var(--tc);margin-top:auto;}
body.kxe-living .kxe-teacher-galaxy .ksp-teacher-card[aria-current=true]{border-color:#ffd061;outline:none;box-shadow:0 5px 0 #281340,0 0 23px #ffd06155;}
.kxe-teacher-galaxy .ksp-teacher-card[aria-current=true] .kxe-teacher-status{color:#ffd061;}
@media(hover:hover){body.kxe-living .kxe-teacher-galaxy .ksp-teacher-card:hover{translate:0 -6px;border-color:var(--tc);box-shadow:0 9px 0 #100a30,0 0 26px color-mix(in srgb,var(--tc) 50%,transparent);}.kxe-teacher-galaxy .ksp-teacher-card:hover .kxe-teacher-ring{animation-duration:2.5s;}}
body.kxe-living .kxe-teacher-galaxy .ksp-teacher-card:focus-visible{outline:3px solid #ffd061;outline-offset:3px;}
@media(max-width:760px){body.kxe-living .ksp-teacher-strip.kxe-teacher-galaxy{gap:12px;padding:14px 10px 18px;}body.kxe-living .kxe-teacher-galaxy .ksp-teacher-card{flex-basis:142px;min-height:172px;padding:10px 8px;}}
@media(prefers-reduced-motion:reduce){.kxe-teacher-ring,.kxe-catalog-relic{animation:none!important;}.kxe-teacher-galaxy .ksp-teacher-card{translate:none!important;transition:none!important;}}
.kxe-motion-off .kxe-teacher-ring,.kxe-motion-off .kxe-catalog-relic{animation:none!important;}.kxe-motion-off .kxe-teacher-galaxy .ksp-teacher-card{translate:none!important;transition:none!important;}

body.kxe-living .ksp-teacher-strip.kxe-teacher-galaxy{min-width:0;max-width:100%;width:100%;}

/* V0.6.2: teacher carousel, coherent HUD, and full foreground departure. */
body.kxe-living .kxe-teacher-carousel{position:relative;min-width:0;max-width:100%;width:100%;}
body.kxe-living .kxe-teacher-carousel .ksp-teacher-strip{scrollbar-width:none;scroll-snap-type:x proximity;}
body.kxe-living .kxe-teacher-carousel .ksp-teacher-strip::-webkit-scrollbar{display:none;}
body.kxe-living .kxe-teacher-carousel .ksp-teacher-card{scroll-snap-align:start;background:radial-gradient(ellipse at 50% 30%,color-mix(in srgb,var(--tc) 20%,transparent),transparent 65%),linear-gradient(160deg,#392470,#21154f);}
body.kxe-living:not(.kxe-singularity-running) .kxe-teacher-carousel .ksp-teacher-card{opacity:1!important;visibility:visible;}
.kxe-teacher-arrow{position:absolute;top:50%;translate:0 -50%;z-index:4;border:1px solid #b99af1;border-radius:50%;width:38px;height:38px;display:grid;place-items:center;background:#38216f;color:#ffd061;box-shadow:0 0 16px #8754dc80;font-size:26px;font-weight:800;cursor:pointer;line-height:1;}
.kxe-teacher-arrow[hidden]{display:none!important}.kxe-teacher-arrow:disabled{opacity:.35;cursor:default}.kxe-teacher-prev{left:4px}.kxe-teacher-next{right:4px}.kxe-teacher-arrow:not(:disabled):hover{background:#6340aa;box-shadow:0 0 18px #76e8ff88;}

.kxe-teacher-galaxy .kxe-public-planet{display:block;width:90%!important;height:90%!important;object-fit:contain!important;}
body.kxe-living .kxe-hq.kxe-hq-migrating .ksp-profile-identity,body.kxe-living .kxe-hq.kxe-hq-migrating .ksp-stat-carousel{opacity:0!important;pointer-events:none;transition:none!important;}
body.kxe-living .kxe-hq.kxe-hq-migrating .ksp-stat-carousel :is(.ksp-stat-prev,.ksp-stat-next){visibility:hidden;}
/* Header mirrors Core's wallet on every screen; no new auth logic. */
body.kxe-no-hamburger #ks-header #ksp-menu-toggle{display:none!important;}
.kxe-header-account{display:inline-flex;align-items:center;justify-content:center;padding:6px 9px;border-radius:10px;border:1px solid #9372d0;background:#38216f;color:#fff4dd!important;font-size:12px;white-space:nowrap;text-decoration:none;}
.kxe-header-logout{margin:0!important;display:flex!important;}
.kxe-signout .ksp-form{margin-top:8px;}.kxe-signout .ks-button{justify-self:start;}
body.kxe-hud-ready #ks-header .ks-header-inner{overflow:visible!important;}
body.kxe-hud-ready #ks-header .kxe-hud-name{z-index:3;pointer-events:none;}
body.kxe-hud-ready #ks-header .kxe-hud-stats{position:relative;z-index:3;}
body.kxe-hud-ready #ks-header.kxe-hud-compact .kxe-hud-name{left:34%;right:34%;}
#kxe-explore{scroll-margin-top:120px;}
@media(max-width:760px){body.kxe-hud-ready #ks-header.kxe-hud-compact .kxe-hud-name{left:6%;right:6%;}.kxe-header-account{font-size:10px;padding:4px 5px}.kxe-teacher-arrow{width:32px;height:32px;font-size:23px}.kxe-teacher-prev{left:2px}.kxe-teacher-next{right:2px}}
/* Only the foreground disappears. The independent universe remains fully visible. */
body.kxe-ui-engulfed :is(#ks-header,.ks-hero,#ks-footer){opacity:0!important;pointer-events:none!important;}
body.kxe-ui-engulfed .kxe-singularity{pointer-events:auto;}
/* Prevent oversized transformed HUD text from creating a horizontal document scrollbar. */
body.kxe-living{overflow-x:clip;}
body.kxe-hud-ready #ks-header .kxe-hud-name,body.kxe-hud-ready #ks-header.kxe-hud-compact .kxe-hud-name{left:50%;right:auto;width:max-content;max-width:29vw;translate:-50% 0;}
body.kxe-no-hamburger #ks-header #ks-navigation .kxe-header-account{display:inline-flex!important;flex:none;}
@media(max-width:760px){body.kxe-hud-ready #ks-header .kxe-hud-name,body.kxe-hud-ready #ks-header.kxe-hud-compact .kxe-hud-name{left:50%;right:auto;max-width:80vw;}body.kxe-no-hamburger #ks-header #ks-navigation .kxe-header-account{display:inline-flex!important;}body.kxe-hud-ready #ks-header .ks-brand{min-width:0;flex-shrink:1;}body.kxe-hud-ready #ks-header .kxe-hud-stats{gap:3px;}}

/* V0.6.3 — one foreground reconstruction; original portal stays invisible until fragments meet. */
body.kxe-ui-engulfed .ksp-layout{opacity:0!important;pointer-events:none!important;}
/* Account is available in the sidebar / account destination, not as an extra header button. */
body.kxe-no-hamburger #ks-header #ks-navigation .kxe-header-account{display:none!important;}
