/* Step 18.22g – the existing left/right Hero sidebars as movable Nexus windows.
   Only activates when the small side-window controller found an actual rail. */
body.nexus-side-windows-ready .nexus-register-stage--active {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-areas: "main" !important;
  width: min(1240px, 100%);
  margin-inline: auto;
}
body.nexus-side-windows-ready .nexus-register-stage--active > .nexus-register-card {
  grid-area: main; max-width: 1140px;
}
body.nexus-side-windows-ready.nexus-page-public .nexus-pages-hero-layout {
  grid-template-columns: minmax(0,1fr) !important;
  grid-template-areas: "main" !important;
}
body.nexus-side-windows-ready.nexus-page-public .nexus-page-main-region {
  grid-area: main; min-width: 0; width: min(1120px,100%); margin-inline: auto;
}
body .nexus-side-window {
  position: fixed !important;
  top: 82px; left: 12px;
  width: min(328px, calc(100vw - 24px));
  height: min(690px, calc(100dvh - 98px));
  min-width: min(270px, calc(100vw - 24px));
  min-height: 180px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  margin: 0 !important;
  padding: 0 12px 14px !important;
  overflow: auto !important;
  scrollbar-gutter: stable;
  resize: both;
  overscroll-behavior: contain;
  display: block !important;
  box-sizing: border-box;
  border: 1px solid rgba(126,211,253,.42);
  border-radius: 10px;
  background: linear-gradient(165deg, rgba(7,20,34,.98), rgba(5,12,24,.98));
  box-shadow: 0 18px 65px rgba(0,0,0,.60), 0 0 0 1px rgba(100,190,245,.04);
  color: #ecf7ff;
  pointer-events: auto !important;
  user-select: auto !important;
  isolation: isolate;
}
body .nexus-side-window[hidden] { display: none !important; }
body .nexus-side-window--dragging { box-shadow: 0 30px 80px rgba(0,0,0,.75), 0 0 0 1px rgba(143,216,255,.35); }
body .nexus-side-window--maximized {
  left: 8px !important; top: 8px !important;
  width: calc(100vw - 16px) !important;
  height: calc(100dvh - 16px) !important;
  max-width: none; max-height: none;
  resize: none;
}
body .nexus-side-window > .nexus-side-window__header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 50px; margin: 0 -12px 13px; padding: 7px 9px 7px 13px;
  border-bottom: 1px solid rgba(143,216,255,.22);
  background: linear-gradient(95deg,#153149,#0c1c30);
  cursor: grab; touch-action: none; user-select: none !important;
}
body .nexus-side-window--dragging > .nexus-side-window__header { cursor: grabbing; }
.nexus-side-window__title { font-size: 13px; font-weight: 800; letter-spacing: .015em; color: #eaf5ff; }
.nexus-side-window__actions { display: flex; gap: 6px; }
.nexus-side-window__button {
  width: 33px; height: 33px; display: grid; place-items: center;
  font: 21px/1 system-ui,sans-serif; cursor: pointer;
  background: #122b3e; color: #ecf7ff; border: 1px solid #385b70; border-radius: 6px;
}
.nexus-side-window__button:hover { background: #1e4560; }
.nexus-side-window__button--close:hover { background: #74323d; border-color: #db7787; }
.nexus-side-window__button:focus-visible, .nexus-side-window__launcher:focus-visible { outline: 2px solid #7deaff; outline-offset: 2px; }
.nexus-side-window__launcher {
  position: fixed; bottom: max(16px,env(safe-area-inset-bottom,0px));
  z-index: 106; min-height: 42px; max-width: calc(50vw - 25px);
  border: 1px solid rgba(143,216,255,.48); border-radius: 8px;
  padding: 9px 14px; background: #0d2638; color: #ebf8ff;
  box-shadow: 0 14px 38px rgba(0,0,0,.52);
  font: 700 12px/1.25 system-ui,sans-serif; cursor: pointer;
}
.nexus-side-window__launcher[hidden] { display: none !important; }
.nexus-side-window__launcher--left { left: 16px; }
.nexus-side-window__launcher--right { right: 16px; }
.nexus-side-window__launcher:hover { background:#17425e; }
/* Page HUD deliberately turns off pointer events for layout wrappers. Restore
   the window and all controls without making the surrounding stage interactive. */
.nexus-page-public .nexus-side-window, .nexus-page-public .nexus-side-window * { pointer-events: auto; }
.nexus-page-public .nexus-side-window__header { user-select: none; }
body .nexus-side-window > :not(.nexus-side-window__header) { margin-bottom: 12px; }
@media(max-width:700px) {
  body .nexus-side-window, body .nexus-side-window--maximized {
    left: 8px !important; top: 67px !important;
    width: calc(100vw - 16px) !important;
    height: min(640px, calc(100dvh - 84px)) !important;
    min-width: 0; min-height: 0; max-width: none; max-height: none;
    resize: none; border-radius: 8px;
  }
  body .nexus-side-window > .nexus-side-window__header { cursor: default; }
  .nexus-side-window__button[data-nexus-side-maximize] { display: none; }
  .nexus-side-window__launcher { padding: 8px 11px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { .nexus-side-window, .nexus-side-window__launcher { transition: none; } }
/* A floating shell window needs to out-rank the ordinary document footer.
   Elevate only while visible, so closed windows leave the page's HUD order
   unchanged and the legal window keeps its dedicated topmost layer. */
body.nexus-side-windows-ready .nexus-register-stage--active:has(> .nexus-side-window:not([hidden])),
body.nexus-side-windows-ready.nexus-page-public > .nexus-page-shell:has(.nexus-side-window:not([hidden])) {
  z-index: 62;
}

/* Step 18.22u: a visible side window must lift its ANCESTOR stacking context.
   Header z=80; a child z=105 cannot escape its former shell z=62.
   Hidden windows leave the original shell/desktop editor hierarchy untouched. */
body.nexus-side-windows-ready.nexus-page-public > .nexus-page-shell:has(.nexus-side-window:not([hidden])) {
  z-index: 110;
}
body.nexus-side-windows-ready .nexus-register-stage--active:has(> .nexus-side-window:not([hidden])) {
  z-index: 110;
}
@media(max-width:700px) {
  /* Dynamic values use the REAL header/footer rectangles, not a guessed 67px.
     The window can scroll internally without covering mobile navigation. */
  body .nexus-side-window, body .nexus-side-window--maximized {
    top: var(--nexus-side-window-safe-top, 110px) !important;
    height: max(160px, calc(100dvh - var(--nexus-side-window-safe-top, 110px) - var(--nexus-side-window-safe-bottom, 12px) - 8px)) !important;
  }
}

/* STEP 18.22y – Public Hero planner reuses the existing account-header style.
   No detached left/right launchers or footer overlays on public Hero pages. */
body.nexus-page-public .nexus-page-account > .nexus-side-window__launcher--left {
  position:static;inset:auto;left:auto;right:auto;bottom:auto;z-index:auto;
  display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;
  min-height:42px;max-width:none;margin:0;padding:7px 10px;
  border:1px solid var(--np-line);border-radius:5px;
  background:transparent;color:var(--np-text);box-shadow:none;
  font:inherit;font-weight:inherit;line-height:inherit;white-space:nowrap;
}
body.nexus-page-public .nexus-page-account > .nexus-side-window__launcher--left:hover,
body.nexus-page-public .nexus-page-account > .nexus-side-window__launcher--left.is-open {
  border-color:rgba(143,216,255,.45);background:rgba(143,216,255,.09);
}
body.nexus-page-public .nexus-page-account > .nexus-side-window__launcher--left:focus-visible {
  outline:2px solid #7deaff;outline-offset:2px;
}
