/* Atlas AI desktop sidecar. The terminal's existing --alerts-w grid slot is
   retained as a layout token only; Atlas never uses the .alerts-rail namespace. */
body.terminal-mode:not(.atlas-ai-collapsed){--alerts-w:404px}
body.terminal-mode.atlas-ai-collapsed{--alerts-w:52px}

body.terminal-mode > .body > aside.right.atlas-ai-rail{
  position:relative;
  min-width:0;
  min-height:0;
  padding:0!important;
  overflow:hidden!important;
  border-left:1px solid #1a1a1e!important;
  background:#050506!important;
  isolation:isolate;
}

body.terminal-mode .atlas-ai-rail > vr-atlas-ai-sidebar{
  display:block;
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
  --surface:#050506;
  --surface-2:#0b0c0e;
  --surface-3:#141619;
  --ink:#f2f2f4;
  --ink-2:#c8c8d0;
  --muted:#7a7a82;
  --faint:#55555d;
  --line:#202228;
  --line-strong:#3a3d45;
  --blue-600:#69e7ad;
  --blue-100:rgba(105,231,173,.09);
  --atlas-action:#69e7ad;
  --atlas-on-blue:#06110c;
  --atlas-head-bg:linear-gradient(180deg,#0d0e11 0%,#060708 100%);
  --atlas-thread-bg:#050506;
  --atlas-composer-wrap-bg:linear-gradient(180deg,#050506 0%,#08090a 100%);
  --atlas-composer-bg:#0d0f11;
  --atlas-card-bg:#0f1114;
  --atlas-quick-bg:#0d0f12;
  --atlas-elevated:#13161a;
  --atlas-head-shadow:0 14px 34px rgba(0,0,0,.28);
  --atlas-composer-shadow:0 18px 44px rgba(0,0,0,.34);
  --atlas-mark-filter:grayscale(1) contrast(1.08) brightness(1.08) drop-shadow(0 2px 5px rgba(0,0,0,.7));
  --atlas-send-bg:#dff9eb;
  --atlas-send-shadow:0 9px 26px rgba(105,231,173,.2);
  --green-600:#4ade80;
  --green-100:rgba(74,222,128,.08);
  --amber-600:#fbbf24;
  --amber-100:rgba(251,191,36,.09);
  --red-600:#ef4444;
}

body.terminal-mode .atlas-ai-toggle{
  appearance:none;
  position:absolute;
  top:14px;
  left:10px;
  z-index:4;
  width:30px;
  height:38px;
  padding:0;
  place-items:center;
  border:1px solid rgba(200,200,208,.28);
  border-radius:0;
  background:#0a0a0c;
  color:#fff;
  font:900 15px/1 "JetBrains Mono",monospace;
  cursor:pointer;
  transition:background-color .15s,border-color .15s,color .15s;
}
body.terminal-mode .atlas-ai-toggle:hover,
body.terminal-mode .atlas-ai-toggle:focus-visible{
  border-color:rgba(200,200,208,.58);
  background:#111116;
  color:#fff;
}
body.terminal-mode .atlas-ai-toggle:focus-visible{outline:2px solid #d4d4da;outline-offset:2px}
body.terminal-mode:not(.atlas-ai-collapsed) .atlas-ai-toggle{display:none!important}

body.terminal-mode.atlas-ai-collapsed .atlas-ai-rail > vr-atlas-ai-sidebar{display:none!important}
body.terminal-mode.atlas-ai-collapsed .atlas-ai-toggle{display:grid!important}
body.terminal-mode.atlas-ai-collapsed .atlas-ai-rail::before{
  content:"ATLAS AI";
  position:absolute;
  top:72px;
  left:50%;
  transform:translateX(-50%);
  writing-mode:vertical-rl;
  text-orientation:mixed;
  color:#8a8a92;
  font:800 10px/1 "JetBrains Mono",monospace;
  letter-spacing:.25em;
  white-space:nowrap;
}
body.terminal-mode.atlas-ai-collapsed .atlas-ai-rail::after{
  content:"";
  position:absolute;
  left:50%;
  bottom:18px;
  width:5px;
  height:5px;
  transform:translateX(-50%);
  border-radius:50%;
  background:#fbbf24;
  box-shadow:0 0 0 3px rgba(251,191,36,.08);
}

@media(max-width:1440px) and (min-width:1281px){
  body.terminal-mode:not(.atlas-ai-collapsed){--alerts-w:374px}
}
@media(max-width:1280px) and (min-width:1081px){
  body.terminal-mode:not(.atlas-ai-collapsed){--alerts-w:336px}
}
body.terminal-mode .atlas-compact-open{
  display:none;
  appearance:none;
  min-height:34px;
  padding:0 12px;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(200,200,208,.24);
  background:#0a0a0c;
  color:#c8c8d0;
  font:800 9px/1 "JetBrains Mono",monospace;
  letter-spacing:.16em;
  white-space:nowrap;
  cursor:pointer;
}
body.terminal-mode .atlas-compact-open:hover,
body.terminal-mode .atlas-compact-open:focus-visible{border-color:rgba(200,200,208,.58);background:#111116;color:#fff;outline:none}
body.terminal-mode .atlas-compact-open:focus-visible{outline:2px solid #d4d4da;outline-offset:2px}

/* Keep Atlas in the Terminal's real right-hand grid rail on normal desktops.
   Only compact screens use the non-squeezing drawer treatment. */
@media(max-width:1280px){
  body.terminal-mode > .body{
    grid-template-columns:var(--lane-w,220px) minmax(0,1fr)!important;
  }
  body.terminal-mode:not(.atlas-ai-collapsed) > .body{
    z-index:12000!important;
  }
  body.terminal-mode.atlas-ai-collapsed > .body > aside.right.atlas-ai-rail{
    display:none!important;
  }
  body.terminal-mode.atlas-ai-collapsed .atlas-compact-open{display:inline-flex}
  body.terminal-mode > .body > aside.right.atlas-ai-rail{
    display:block!important;
    position:fixed!important;
    inset:max(0px,env(safe-area-inset-top)) 0 0 auto!important;
    width:min(100%,420px)!important;
    max-width:100%!important;
    height:auto!important;
    max-height:none!important;
    z-index:12000;
    border-left:1px solid #303038!important;
    background:#050506!important;
    box-shadow:-24px 0 60px rgba(0,0,0,.58);
  }
  body.terminal-mode.atlas-ai-collapsed > .body > aside.right.atlas-ai-rail{
    inset:auto max(10px,env(safe-area-inset-right)) max(72px,calc(env(safe-area-inset-bottom) + 72px)) auto!important;
    width:52px!important;
    height:64px!important;
    border:1px solid rgba(200,200,208,.28)!important;
    background:#070709!important;
    box-shadow:0 12px 32px rgba(0,0,0,.42);
    overflow:hidden!important;
  }
  body.terminal-mode.atlas-ai-collapsed .atlas-ai-rail::before,
  body.terminal-mode.atlas-ai-collapsed .atlas-ai-rail::after{
    display:none!important;
  }
  body.terminal-mode .atlas-ai-toggle{
    top:11px;
    left:5px;
    width:40px;
    height:40px;
  }
  body.terminal-mode:not(.atlas-ai-collapsed) .atlas-ai-rail > vr-atlas-ai-sidebar{
    display:block!important;
    width:100%!important;
    height:100%!important;
  }
}
@media(max-width:1080px){
  body.terminal-mode > .body{grid-template-columns:var(--lane-w,200px) minmax(0,1fr)!important}
}
@media(max-width:720px){
  body.terminal-mode > .body{grid-template-columns:minmax(0,1fr)!important}
  body.terminal-mode.atlas-ai-collapsed .atlas-compact-open{
    display:inline-flex!important;
    min-width:44px;
    min-height:44px;
    padding:0 8px;
    font-size:8px;
    letter-spacing:.1em;
  }
}
@media(max-width:430px){
  body.terminal-mode:not(.atlas-ai-collapsed) > .body > aside.right.atlas-ai-rail{
    width:100%!important;
    border-left:0!important;
  }
}
@media(prefers-reduced-motion:reduce){
  body.terminal-mode .atlas-ai-toggle{transition:none}
}
