/* Ghost UI v4.9: optically aligned taskbar glyphs + current-chat Cortex mini pipeline. */

/* Keep the mutable taskbar hidden while deferred v4 modules create, replace and decorate its controls. */
body[data-ghost-ui="v4"]:not(.ghost-taskbar-ready) #controlNav,
body[data-ghost-ui="v4"]:not(.ghost-taskbar-ready) .memory-manager-btn,
body[data-ghost-ui="v4"]:not(.ghost-taskbar-ready) #ghostShellPrefsBtn,
body[data-ghost-ui="v4"]:not(.ghost-taskbar-ready) #ghostTaskbarToggle{visibility:hidden!important}
body.ghost-taskbar-ready #sidebar .control-nav-btn:not(.ghost-taskbar-nav-item):not(#maintenanceOpenBtn),
body.ghost-taskbar-ready #sidebar .memory-manager-btn:not(.ghost-taskbar-nav-item){visibility:hidden!important}

/* The taskbar used several unrelated Unicode glyphs. Give every workspace the same optical box. */
#sidebar .ghost-taskbar-nav-item{
  position:relative!important;
  box-sizing:border-box!important;
}
#sidebar .ghost-taskbar-nav-item::before{
  content:none!important;
  display:none!important;
}
#sidebar .ghost-taskbar-glyph{
  width:24px;height:24px;flex:0 0 24px;
  display:grid;place-items:center;
  color:#78dcf7;
  line-height:1;
  pointer-events:none;
}
#sidebar .ghost-taskbar-glyph svg{
  width:18px;height:18px;display:block;
}
#sidebar [data-ghost-taskbar-kind="shell"] .ghost-taskbar-glyph{color:#b29eff}
#sidebar [data-ghost-taskbar-kind="browser"] .ghost-taskbar-glyph{color:#67d7ff}
#sidebar [data-ghost-taskbar-kind="control"] .ghost-taskbar-glyph{color:#76ddf8}
#sidebar [data-ghost-taskbar-kind="cortex"] .ghost-taskbar-glyph{color:#a88cff}
#sidebar [data-ghost-taskbar-kind="nexus"] .ghost-taskbar-glyph{color:#61ddf7}
#sidebar [data-ghost-taskbar-kind="sentinel"] .ghost-taskbar-glyph{color:#8bb8ff}
#sidebar [data-ghost-taskbar-kind="mcp"] .ghost-taskbar-glyph{color:#93aaff}
#sidebar [data-ghost-taskbar-kind="memory"] .ghost-taskbar-glyph{color:#65d8ff}

#ghostHomeBtn::after{content:"Home"!important}
#ghostChatsBtn::after{content:"Chats"!important}
#ghostBrowserNavBtn::after{content:"Ghost Browser"!important}
#controlNav [data-control-tab="settings"]::after{content:"Control Plane"!important}
#controlNav [data-control-tab="memory"]::after{content:"Cortex Lab"!important}
#nexusOpenBtn::after{content:"Nexus"!important}
#sentinelOpenBtn::after{content:"Sentinel"!important}
#ghostMcpNavBtn::after{content:"MCP Access"!important}
.memory-manager-btn.ghost-taskbar-nav-item::after{content:"Memory Viewer"!important}

body:not(.ghost-taskbar-collapsed) #sidebar .ghost-taskbar-nav-item{
  min-height:44px!important;
  gap:10px!important;
}
body:not(.ghost-taskbar-collapsed) #sidebar .ghost-taskbar-nav-item::after{
  font-size:.78rem!important;
}
body:not(.ghost-taskbar-collapsed) #ghostShellPrefsBtn{
  min-height:44px!important;
  gap:10px!important;
}
body:not(.ghost-taskbar-collapsed) #ghostShellPrefsBtn>span:not(.ghost-taskbar-glyph){display:none!important}
body:not(.ghost-taskbar-collapsed) #ghostShellPrefsBtn>strong{font-size:.72rem!important}

body.ghost-taskbar-collapsed #controlNav{
  align-items:center!important;
  gap:6px!important;
}
body.ghost-taskbar-collapsed #sidebar .ghost-taskbar-nav-item,
body.ghost-taskbar-collapsed #ghostShellPrefsBtn,
body.ghost-taskbar-collapsed #ghostTaskbarToggle{
  width:48px!important;height:48px!important;min-height:48px!important;max-height:48px!important;
  margin-left:auto!important;margin-right:auto!important;
  padding:0!important;
  border-radius:13px!important;
  display:grid!important;place-items:center!important;
  justify-content:center!important;
  gap:0!important;
}
body.ghost-taskbar-collapsed #sidebar .ghost-taskbar-nav-item::after{display:none!important}
body.ghost-taskbar-collapsed #sidebar .ghost-taskbar-glyph{
  width:24px;height:24px;margin:0!important;
}
body.ghost-taskbar-collapsed #sidebar .ghost-taskbar-glyph svg{width:19px;height:19px}
body.ghost-taskbar-collapsed #ghostShellPrefsBtn>span:not(.ghost-taskbar-glyph),
body.ghost-taskbar-collapsed #ghostShellPrefsBtn>strong{display:none!important}
body.ghost-taskbar-collapsed #ghostTaskbarToggle .ghost-taskbar-toggle-icon{
  width:24px;height:24px;display:grid;place-items:center;
}
body.ghost-taskbar-collapsed #ghostTaskbarToggle .ghost-taskbar-toggle-icon::before{
  width:24px!important;height:24px!important;border-radius:8px!important;
  background:rgba(var(--accent-rgb),.055)!important;
}
body.ghost-taskbar-collapsed .ghost-nav-badge{
  right:3px!important;top:3px!important;
  min-width:14px!important;height:14px!important;padding:0 3px!important;
  font-size:.45rem!important;
}

/* Current-chat live Cortex pipeline. The topbar is already the remaining workspace width,
   so container queries react to real usable space rather than the device orientation. */
.topbar.ghost-topbar-live-container{container-type:inline-size;overflow:visible!important}
.ghost-live-cortex{
  position:relative;z-index:75;
  flex:0 0 auto;
}
.ghost-live-cortex-button{
  height:36px;min-width:188px;
  display:flex;align-items:center;gap:5px;
  padding:0 7px;
  border:1px solid rgba(var(--cortex-rgb),.15);
  border-radius:11px;
  background:linear-gradient(145deg,rgba(9,22,40,.78),rgba(5,14,26,.82));
  color:#6e8498;
  cursor:pointer;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.02);
  transition:border-color .15s ease,background .15s ease,box-shadow .15s ease;
}
.ghost-live-cortex-button:hover,.ghost-live-cortex-button:focus-visible,.ghost-live-cortex-button[aria-expanded="true"]{
  outline:none;
  border-color:rgba(var(--cortex-rgb),.30);
  background:linear-gradient(145deg,rgba(14,31,53,.9),rgba(7,18,33,.92));
  box-shadow:0 0 24px rgba(var(--cortex-rgb),.07),inset 0 1px 0 rgba(255,255,255,.025);
}
.ghost-live-cortex-button:focus-visible{outline:2px solid rgba(57,217,255,.72);outline-offset:2px}
.ghost-live-cortex-mark{
  width:24px;height:22px;display:grid;place-items:center;
  border:1px solid rgba(var(--cortex-rgb),.16);border-radius:7px;
  background:rgba(var(--cortex-rgb),.07);color:#b4a2ff;
  font:800 .52rem/1 ui-monospace,SFMono-Regular,Menlo,monospace;
  letter-spacing:.04em;
}
.ghost-live-cortex-stages{display:flex;align-items:center;gap:2px}
.ghost-live-stage{
  position:relative;width:17px;height:24px;display:grid;place-items:center;
  color:#43566a;opacity:.72;
  transition:color .16s ease,opacity .16s ease,filter .16s ease,transform .16s ease;
}
.ghost-live-stage:not(:last-child)::after{
  content:"";position:absolute;right:-2px;top:11px;width:4px;height:1px;
  background:rgba(104,137,164,.18);
}
.ghost-live-stage svg{width:13px;height:13px;display:block}
.ghost-live-stage.waiting{color:#52677c;opacity:.88}
.ghost-live-stage.running{
  color:#55e0ff;opacity:1;
  filter:drop-shadow(0 0 5px rgba(57,217,255,.58));
  animation:ghost-live-pulse 1.05s ease-in-out infinite;
}
.ghost-live-stage.good{color:#53ddb1;opacity:1;filter:drop-shadow(0 0 3px rgba(53,230,162,.26))}
.ghost-live-stage.noop{color:#6b7483;opacity:.76}
.ghost-live-stage.bad{color:#ff758c;opacity:1;filter:drop-shadow(0 0 4px rgba(255,68,95,.32))}
.ghost-live-result{
  min-width:25px;height:20px;padding:0 5px;
  display:grid;place-items:center;
  border:1px solid rgba(255,255,255,.08);border-radius:999px;
  background:rgba(3,12,21,.7);color:#667c8f;
  font:800 .52rem/1 ui-monospace,SFMono-Regular,Menlo,monospace;
  white-space:nowrap;
}
.ghost-live-result.live{border-color:rgba(var(--cortex-rgb),.25);color:#bbaaff;background:rgba(var(--cortex-rgb),.08)}
.ghost-live-result.good{border-color:rgba(53,230,162,.26);color:#68dfb7;background:rgba(35,105,82,.20)}
.ghost-live-result.warn{border-color:rgba(255,184,74,.30);color:#efc575;background:rgba(90,61,16,.22)}
.ghost-live-result.mixed{border-color:rgba(var(--cortex-rgb),.22);color:#d2c4ff;background:linear-gradient(90deg,rgba(53,230,162,.08),rgba(255,184,74,.08))}
.ghost-live-result.bad{border-color:rgba(255,68,95,.33);color:#ff91a4;background:rgba(95,22,37,.26)}
.ghost-live-result.noop{color:#738697}

.ghost-live-cortex-popover[hidden]{display:none!important}
.ghost-live-cortex-popover{
  position:absolute;right:0;top:calc(100% + 9px);
  width:360px;max-height:min(610px,calc(100dvh - 86px));
  overflow:auto;overscroll-behavior:contain;
  border:1px solid rgba(var(--cortex-rgb),.20);border-radius:16px;
  background:radial-gradient(circle at 100% 0,rgba(var(--cortex-rgb),.14),transparent 34%),linear-gradient(165deg,rgba(8,21,36,.992),rgba(3,10,18,.998));
  box-shadow:0 28px 90px rgba(0,0,0,.58),0 0 34px rgba(var(--cortex-rgb),.06),inset 0 1px 0 rgba(255,255,255,.03);
  color:#c8d9e5;
}
.ghost-live-cortex-popover>header{
  display:flex;align-items:flex-start;justify-content:space-between;gap:10px;
  padding:13px 14px;border-bottom:1px solid rgba(var(--cortex-rgb),.09);
}
.ghost-live-cortex-popover>header>div{display:grid;gap:3px;min-width:0}
.ghost-live-cortex-popover>header span{font-size:.50rem;font-weight:850;letter-spacing:.14em;color:#9d8bff}
.ghost-live-cortex-popover>header strong{font-size:.78rem;color:#f0edff;overflow-wrap:anywhere}
.ghost-live-cortex-popover>header small{font:550 .52rem/1.35 ui-monospace,SFMono-Regular,Menlo,monospace;color:#60758b;overflow-wrap:anywhere}
.ghost-live-cortex-popover>header button{
  width:30px;height:30px;flex:0 0 30px;border:1px solid rgba(var(--accent-rgb),.11);border-radius:9px;
  background:rgba(8,26,41,.76);color:#8ca6b9;cursor:pointer;
}
.ghost-live-summary{
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;padding:11px 12px 7px;
}
.ghost-live-summary>div{display:grid;gap:2px;padding:7px;border:1px solid rgba(var(--accent-rgb),.07);border-radius:9px;background:rgba(2,11,19,.55)}
.ghost-live-summary span{font-size:.47rem;color:#60778d}.ghost-live-summary strong{font-size:.68rem;color:#dceaf2;overflow-wrap:anywhere}.ghost-live-summary .good strong{color:#61dcb2}.ghost-live-summary .warn strong{color:#efc474}
.ghost-live-stage-list{display:grid;gap:5px;padding:6px 12px 11px}
.ghost-live-stage-row{
  display:grid;grid-template-columns:27px 82px minmax(0,1fr);align-items:center;gap:7px;
  min-height:34px;padding:6px 8px;border:1px solid rgba(var(--accent-rgb),.06);border-radius:9px;background:rgba(3,13,22,.52);
}
.ghost-live-stage-row-icon{width:25px;height:25px;display:grid;place-items:center;color:#52697c}.ghost-live-stage-row-icon svg{width:14px;height:14px}
.ghost-live-stage-row strong{font-size:.60rem;color:#aebfcb}.ghost-live-stage-row small{font-size:.52rem;line-height:1.35;color:#60778c;overflow-wrap:anywhere}
.ghost-live-stage-row.good{border-color:rgba(53,230,162,.12)}.ghost-live-stage-row.good .ghost-live-stage-row-icon{color:#55dbae}.ghost-live-stage-row.good strong{color:#bce9d8}
.ghost-live-stage-row.running{border-color:rgba(var(--cortex-rgb),.20);background:rgba(var(--cortex-rgb),.045)}.ghost-live-stage-row.running .ghost-live-stage-row-icon{color:#6ce4ff}.ghost-live-stage-row.running strong{color:#dfd8ff}
.ghost-live-stage-row.bad{border-color:rgba(255,68,95,.20);background:rgba(85,18,32,.18)}.ghost-live-stage-row.bad .ghost-live-stage-row-icon,.ghost-live-stage-row.bad strong{color:#ff8fa3}
.ghost-live-cortex-popover>footer{padding:0 12px 12px}.ghost-live-cortex-popover>footer button{width:100%;padding:8px 10px;border:1px solid rgba(var(--cortex-rgb),.20);border-radius:9px;background:rgba(var(--cortex-rgb),.07);color:#c7b9ff;cursor:pointer;font-size:.62rem}.ghost-live-cortex-popover>footer button:disabled{opacity:.4;cursor:default}

@keyframes ghost-live-pulse{0%,100%{transform:scale(.96);opacity:.76}50%{transform:scale(1.08);opacity:1}}

@container (max-width:1180px){
  .ghost-live-cortex-button{min-width:166px;padding-left:5px;padding-right:5px;gap:3px}
  .ghost-live-cortex-mark{display:none}
  .ghost-live-stage{width:16px}
  .ghost-live-stage svg{width:12px;height:12px}
}
@container (max-width:980px){
  .ghost-live-cortex{display:none!important}
}
@media(max-height:650px){
  .ghost-live-cortex-popover{max-height:calc(100dvh - 72px)}
}
