body:has(.command-hq:not([hidden])) > .masthead,
body:has(.command-hq:not([hidden])) > footer .stats,
body:has(.command-hq:not([hidden])) .scene canvas,
body:has(.command-hq:not([hidden])) .scene .gate { display: none; }

body:has(.command-hq:not([hidden])) .scene {
    height: 100%;
    background: #04131b url('command-hq.webp') center center / cover no-repeat;
}
.hq-bridge-shell { display: none; }
body:has(.command-hq:not([hidden])) .hq-bridge-shell {
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    width: max(100%, 177.683dvh);
    aspect-ratio: 1672 / 941;
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.hq-window-mask { position: absolute; }
.hq-window-view, .hq-window-spill { position: absolute; inset: 0; }
.hq-window-view {
    opacity: 0;
    clip-path: url(#hq-window-frames);
    background-color: #081724;
    background-repeat: no-repeat;
    background-position: center, center 12%;
    background-size: 100% 100%, 100% 44%;
    transition: opacity .65s ease;
}
.hq-view-echo {
    background-image: linear-gradient(180deg,#09151c22,transparent 23%,#09101a45 44%),url('hq-window-echo.webp');
}
.hq-view-silent {
    background-image: linear-gradient(180deg,#09151c22,transparent 23%,#09101a45 44%),url('hq-window-silent.webp');
}
.scene[data-hq-view="echo"] .hq-view-echo,
.scene[data-hq-view="silent"] .hq-view-silent { opacity: 1; }
@property --hq-window-light {
    syntax: "<color>";
    inherits: false;
    initial-value: transparent;
}
.hq-window-spill {
    --hq-window-light: transparent;
    background:
        radial-gradient(ellipse 29% 15% at 20% 47%, var(--hq-window-light), transparent),
        radial-gradient(ellipse 34% 17% at 50% 49%, var(--hq-window-light), transparent),
        radial-gradient(ellipse 28% 16% at 80% 47%, var(--hq-window-light), transparent),
        radial-gradient(ellipse 58% 27% at 51% 69%, color-mix(in srgb, var(--hq-window-light) 60%, transparent), transparent);
    mix-blend-mode: screen;
    transition: --hq-window-light .65s ease;
}
.scene[data-hq-view="echo"] .hq-window-spill { --hq-window-light: #ff9a4366; }
.scene[data-hq-view="silent"] .hq-window-spill { --hq-window-light: #a780ff76; }
body:has(.command-hq:not([hidden])) .scene::before {
    background: linear-gradient(180deg, #04111b28, transparent 26%, #0310192e 59%, #030a12a3);
}
body:has(.command-hq:not([hidden])) .scene::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 22% 25%, #f6fdff 0 1px, #91eeff58 2px, transparent 4px),
        radial-gradient(circle at 46% 46%, #c1fbff 0 1px, transparent 3px),
        radial-gradient(circle at 64% 14%, #fff 0 1px, #8eeaff77 2px, transparent 5px),
        radial-gradient(circle at 76% 56%, #92f5ff 0 1px, transparent 3px),
        radial-gradient(circle at 90% 30%, #e6fcff 0 1px, transparent 4px),
        radial-gradient(ellipse at 70% 26%, #65d9ee5c, transparent 35%);
    height: 45vh;
    mask-image: linear-gradient(#000 65%, transparent);
    mix-blend-mode: screen;
    animation: hq-window-drift 9s ease-in-out infinite alternate;
    pointer-events: none;
}
@keyframes hq-window-drift {
    from { transform: translate(-2%, -3%); opacity: .43; }
    to { transform: translate(3%, 5%); opacity: 1; }
}
body:has(.command-hq:not([hidden])) > main {
    width: min(96%, 1850px);
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    min-height: 0;
    flex: 1 1 0;
    padding: 0 0 2vh;
}
body:has(.command-hq:not([hidden])) {
    height: 100dvh;
    min-height: 0;
    overflow: clip;
}
body:has(.command-hq:not([hidden])) > footer {
    width: min(96%, 1850px);
    border-color: transparent;
}

.command-hq {
    --hq-cyan: #7ef0ff;
    --hq-edge: #51d4ec;
    --hq-cut: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px),
        calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    max-width: none;
    padding-top: clamp(12px, 2.4vh, 25px);
    overflow: clip;
}
.command-hq .hq-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    flex: 0 0 clamp(114px, 24vh, 246px);
}
.hq-content { flex: 1; min-height: 0; min-width: 0; overflow: auto; scrollbar-gutter: stable; }
.hq-brand {
    position: relative;
    isolation: isolate;
    display: grid;
    justify-items: start;
    flex: 0 1 auto;
    min-width: 0;
    width: fit-content;
    max-width: 100%;
    padding: 10px clamp(14px, 1.6vw, 26px) 11px clamp(53px, 4.3vw, 79px);
}
.hq-brand::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    border-radius: 12px 4px 7px 12px;
    border: 1px solid #65d9f21f;
    background: linear-gradient(104deg,#031a2799,#03121bbb 68%,#082e3b6b);
    box-shadow: inset 0 -1px 0 #55d0e23b, 0 5px 16px #0005;
}
.hq-wordmark {
    display: flex;
    align-items: center;
    gap: 11px;
    color: #f1fbff;
    font-weight: 620;
    font-size: clamp(.95rem, 1.95vw, 2.05rem);
    letter-spacing: .125em;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.15;
    text-shadow: 0 0 13px #72d9f45e;
}
.hq-wordmark > span:last-child { position: relative; z-index: 1; }
.hq-crest {
    position: absolute;
    left: clamp(5px, .7vw, 12px);
    top: 50%;
    width: clamp(76px, 6.1vw, 115px);
    height: clamp(60px, 5.1vw, 96px);
    transform: translateY(-50%);
}
.hq-crest {
    background: url('hq-orbit-mark.svg') left center / 100% 100% no-repeat;
    filter: drop-shadow(0 0 5px #46dfff9c);
}
.hq-sound[aria-pressed="true"] { border-color: #c1faff; box-shadow: inset 0 0 13px #4bd7fa55; }
.panel.command-hq:not([data-page="home"]) h1 span {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.panel.command-hq:not([data-page="home"]) h1 span::before,
.panel.command-hq:not([data-page="home"]) h1 span::after {
    content: "";
    width: clamp(15px, 4vw, 73px);
    height: 1px;
    background: linear-gradient(90deg, transparent, #7aeeff);
}
.panel.command-hq:not([data-page="home"]) h1 span::after {
    transform: rotate(180deg);
}
.panel.command-hq:not([data-page="home"]) h1 {
    display: block;
    justify-self: center;
    min-height: 0;
    padding: 0;
    margin: 5px 0 0;
    color: #cfedf7;
    font: 650 clamp(.67rem, 1.2vw, 1.04rem)/1.2 var(--mono);
    letter-spacing: .29em;
    text-transform: uppercase;
    text-shadow: 0 0 12px #63d4ea;
}
.terminal.command-hq h1::before, .command-hq.auth-panel h1::before { content: none; }
.hq-feedback:empty { display: none; }

.hq-navigation {
    position: absolute;
    top: 43px;
    right: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: min(47%, 760px);
    isolation: isolate;
    overflow: clip;
    border: 1px solid #6cc9da70;
    background: #061d2b88;
    clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px),
        calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}
.hq-navigation::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(110deg, transparent 37%, #9cf3ff40 50%, transparent 63%);
    transform: translateX(-100%);
    animation: hq-menu-scan 6s ease-in-out infinite;
}
@keyframes hq-menu-scan {
    0%, 27% { transform: translateX(-100%); }
    71%, 100% { transform: translateX(100%); }
}
.hq-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 13px;
    border: 1px solid #64def1ac;
    border-radius: 6px;
    color: #ddfaff;
    background: #092936e8;
    font: 650 .88rem/1.35 "Segoe UI", sans-serif;
    cursor: pointer;
    transition: background .16s ease, box-shadow .16s ease;
}
.hq-button:hover { background: #16465c; box-shadow: inset 0 0 16px #47c9ef33; }
.hq-button:focus-visible, .hq-inbox:focus-visible, .hq-profile-button:focus-visible { outline: 2px solid var(--hq-cyan); outline-offset: 3px; }
.hq-navigation .hq-button {
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: clamp(.85rem, 1.4vw, 1.25rem);
    padding-block: 11px;
}
.hq-navigation .hq-button:focus-visible { outline-offset: -3px; }
.hq-navigation .hq-button[aria-pressed="true"], .hq-navigation .hq-button:hover {
    background: linear-gradient(180deg, #103e51, #115a6c);
    box-shadow: inset 0 0 14px #4bd7fa82, inset 0 -2px #57e1ff;
}
.hq-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,2.65fr) minmax(0,1.03fr); gap: clamp(8px, .75vw, 14px); }
@media (min-width: 1051px) {
    .hq-layout { min-height: 54vh; }
}
.hq-card {
    position: relative;
    isolation: isolate;
    min-width: 0;
    min-height: 100%;
    padding: clamp(13px, 1.45vw, 27px);
    filter: drop-shadow(0 0 7px #34c5e33b);
}
.hq-card::before, .hq-card::after {
    content: "";
    position: absolute;
    pointer-events: none;
    clip-path: var(--hq-cut);
}
.hq-card::before {
    z-index: -2;
    inset: 0;
    clip-path: polygon(evenodd,
        16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px),
        calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px, 16px 0,
        16px 1px, 1px 16px, 1px calc(100% - 16px), 16px calc(100% - 1px),
        calc(100% - 16px) calc(100% - 1px), calc(100% - 1px) calc(100% - 16px),
        calc(100% - 1px) 16px, calc(100% - 16px) 1px, 16px 1px);
    background: linear-gradient(132deg, #8ff6ff, #2c8296 22%, #2f8192 68%, #8ff6ff);
    animation: hq-glow 6s ease-in-out infinite alternate;
}
.hq-card::after {
    z-index: -1;
    inset: 1px;
    background:
        radial-gradient(ellipse at 0% 100%, #156d7b42, transparent 67%),
        linear-gradient(152deg,#0627349c,#051c2780 54%,#0734428f);
}
@keyframes hq-glow { from { opacity: .73; } to { opacity: 1; } }
.hq-card h2 {
    margin: 0 0 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid #74d6ea55;
    color: #e8faff;
    font: 700 clamp(.87rem, 1.55vw, 1.45rem)/1.25 var(--mono);
    letter-spacing: .06em;
    text-transform: uppercase;
}
.hq-card p { color: #b8d5df; }
.hq-portrait, .hq-emblem {
    aspect-ratio: .94;
    max-height: 34vh;
    overflow: hidden;
    border: 1px solid #5bacc277;
    border-radius: 5px;
}
.hq-portrait { background: #123242 url('hq-kestrel.webp') center 40% / cover no-repeat; }
.hq-emblem {
    display: grid;
    place-items: center;
    background: radial-gradient(ellipse at center,#28778d5c,transparent 70%),
        repeating-linear-gradient(0deg,#78dfff09 0 1px,transparent 1px 5px),#071927;
}
.hq-emblem .brand-mark { color: var(--hq-cyan); transform: scale(2.3); animation: hq-orbit 18s linear infinite; }
@keyframes hq-orbit { to { transform: scale(2.3) rotate(360deg); } }
.hq-card .hq-caption { color: #80c4d9; margin: 9px 0 0; font: .78rem/1.25 var(--mono); text-transform: uppercase; }
.command-hq .account-name { font-size: clamp(1.12rem, 2vw, 1.8rem); font-weight: 650; color: #e7f8ff; margin: 3px 0 9px; overflow-wrap: anywhere; }
.hq-profile-button {
    width: 100%; text-align: left; padding: 10px 4px 0; border: 0; border-top: 1px solid #72c4d27d;
    background: transparent; color: var(--hq-cyan); font: inherit; text-decoration: underline; cursor: pointer;
}
.hq-profile { display: flex; flex-direction: column; }
.hq-signout { margin-top: auto; padding-top: 12px; }
.hq-signout .hq-button { padding: 5px 10px; font-size: .75rem; background: #09293680; }
.hq-worlds { display: flex; flex-direction: column; }
.hq-worlds-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 5px 12px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #74d6ea55;
}
.hq-worlds-heading h2 { margin: 0; padding: 0; border: 0; }
.hq-view-picker { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 7px; color: #bce7ef; font-size: .75rem; }
.hq-view-picker select {
    max-width: 100%;
    color: #e6fbff;
    background: #092936;
    border: 1px solid #64def1ac;
    border-radius: 5px;
    padding: 4px 6px;
    font: inherit;
}
.hq-view-picker select:focus-visible { outline: 2px solid var(--hq-cyan); outline-offset: 3px; }
.hq-world {
    display: grid;
    grid-template-columns: 35% minmax(0,1fr);
    min-height: clamp(118px, 19.5vh, 238px);
    margin: 7px 0 9px;
    overflow: hidden;
    border: 1px solid #62afc280;
    border-radius: 8px;
    background: linear-gradient(135deg,#102f3c9c,#061e2b94);
}
.hq-world-art { min-height: 100%; background: #123242 center / cover no-repeat; border-right: 1px solid #59a7be70; }
.hq-world-echo .hq-world-art { background-image: url('hq-echo.webp'); background-position: center 56%; }
.hq-world-silent .hq-world-art { background-image: url('hq-silent.webp'); background-position: center 51%; }
.hq-world-detail { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 5px 12px; padding: clamp(9px, 1.2vw, 23px); }
.hq-world h3 { grid-column: 1 / -1; margin: 0; font: 700 clamp(.95rem, 1.85vw, 1.74rem)/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.hq-world dl { align-self: stretch; display: grid; gap: 6px; align-content: end; margin: 0; }
.hq-world dl div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.hq-world dt { color: #80c4d9; font: .64rem/1.2 var(--mono); text-transform: uppercase; }
.hq-world dd { margin: 0; font-size: clamp(.68rem, 1vw, .95rem); }
.hq-world-status::before, .hq-friend-list li::before {
    content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%;
    background: var(--hq-cyan); box-shadow: 0 0 9px currentColor; vertical-align: 1px; color: var(--hq-cyan);
}
.hq-world-echo .hq-world-status::before { color: #ffcc78; background: currentColor; }
.hq-world .hq-button { white-space: nowrap; text-transform: uppercase; min-width: clamp(105px, 10.2vw, 196px); font-size: clamp(.78rem, 1.12vw, 1.15rem); }
.hq-primary { color: #fff1d5; background: linear-gradient(100deg,#744613,#4d2a0a); border-color: #ffbd62; box-shadow: inset 0 0 9px #ffa34b85, 0 0 14px #f6a25352; }
.hq-primary:hover { background: #95581a; }
.hq-browse { align-self: center; min-width: 40%; margin-top: auto; margin-bottom: 1px; color: var(--hq-cyan); text-transform: uppercase; }
.hq-social { display: flex; flex-direction: column; }
.hq-inbox {
    display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;
    margin-bottom: 8px; padding: 10px 8px; border: 1px solid #51b4d366; border-radius: 7px;
    color: #e2f5fc; background: #1133459e; cursor: pointer;
}
.hq-inbox::before { content: "✉"; color: var(--hq-cyan); }
.hq-inbox strong { min-width: 20px; margin-left: auto; border-radius: 4px; color: #06202b; background: var(--hq-cyan); }
.hq-inbox:first-of-type strong { background: #ffbf64; }
.hq-social-friends { margin-top: auto; padding-top: 16px; }
.hq-friend-list { margin: 0; padding: 0; list-style: none; }
.hq-friend-list li { padding: 7px 0; border-bottom: 1px solid #74d6ea3d; }
.hq-friend-list li::before { color: #65e790; background: currentColor; }
.hq-detail { min-height: 220px; animation: appear .24s ease-out; }
.hq-arrive { animation: hq-arrive .36s ease-out; }
@keyframes hq-arrive {
    from { opacity: .52; filter: brightness(1.37); }
    to { opacity: 1; filter: brightness(1); }
}
.hq-directory { display: flex; flex-wrap: wrap; gap: 10px; }
.hq-preview-note { display: block; margin: 8px 5px 0; text-align: right; color: #c4e0ea; font-size: .73rem; }
@media (max-width: 1050px) {
    .hq-navigation { position: static; width: auto; margin-bottom: 14px; }
    .command-hq .hq-header { flex-basis: 110px; }
    .hq-layout { grid-template-columns: minmax(0,1fr) minmax(0,2.45fr) minmax(0,1fr); }
    .hq-world-detail { grid-template-columns: 1fr; }
    .hq-world .hq-button { justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
    .hq-card::before, .hq-emblem .brand-mark, .hq-detail, .hq-arrive, .hq-navigation::after,
    body:has(.command-hq:not([hidden])) .scene::after { animation: none; }
    .hq-button, .hq-window-view, .hq-window-spill { transition: none; }
}


.hq-custom-avatar {
    display: block;
    width: 100%;
    aspect-ratio: .94;
    max-height: 34vh;
    object-fit: cover;
    border: 1px solid #5bacc277;
    border-radius: 5px;
}
.shared-commander h1 { font-size: clamp(2rem,4vw,3rem) !important; }
.shared-commander [data-shared-bio] { white-space: pre-wrap; overflow-wrap: anywhere; }
.shared-commander [data-shared-avatar] { border-radius: 8px; object-fit: cover; }

