/* One viewport layout for every workspace section. Original controls retain their handlers. */
body.rex-window-open { overflow: hidden !important; }
body.rex-window-open > .top,
body.rex-window-open > .stage,
body.rex-window-open > .command { display: none !important; }

#workspace.rex-window-active[data-rex-window-mode] {
  --rex-window-header: 58px;
  --rex-window-rail: 0px;
  position: fixed !important; inset: 0 !important;
  display: block !important; width: 100% !important; height: 100dvh !important;
  max-width: none !important; max-height: none !important; min-height: 0 !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
  background: #071019 !important; overflow: hidden !important; box-sizing: border-box;
  scrollbar-gutter: auto !important;
  z-index: 2147483000 !important;
}
#workspace.rex-window-active.rex-sidebar-open[data-rex-window-mode] {
  --rex-window-rail: 196px;
}
#workspace.rex-window-active[data-rex-window-mode] > .workspace-head {
  position: absolute !important; inset: 0 0 auto !important;
  display: flex !important; flex-wrap: nowrap !important; align-items: center !important;
  justify-content: space-between !important; gap: 12px !important;
  width: 100% !important; height: var(--rex-window-header) !important;
  min-height: 0 !important; margin: 0 !important; padding: 0 14px !important;
  border-bottom: 1px solid #203744 !important; background: #0a141d !important;
  box-sizing: border-box; z-index: 4 !important;
}
#workspace.rex-window-active[data-rex-window-mode] > .workspace-head > div:first-child {
  min-width: 0; overflow: hidden;
}
#workspace.rex-window-active[data-rex-window-mode] .workspace-kicker { display: none !important; }
#workspace.rex-window-active[data-rex-window-mode] #workspaceTitle {
  margin: 0 !important; font-size: 15px !important; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#workspace.rex-window-active[data-rex-window-mode] > .workspace-head > button:not(#rexModeSwitch),
#workspace.rex-window-active[data-rex-window-mode] #webFullscreen,
#workspace.rex-window-active[data-rex-window-mode] #webMinimize { display: none !important; }

#workspace.rex-window-active[data-rex-window-mode] > .workspace-modes {
  position: absolute !important; inset: var(--rex-window-header) auto 0 0 !important;
  display: none !important; flex-direction: column !important; flex-wrap: nowrap !important;
  align-items: stretch !important; align-content: start !important;
  width: var(--rex-window-rail) !important; height: auto !important;
  max-height: none !important; min-height: 0 !important; margin: 0 !important;
  padding: 12px 10px 72px !important; gap: 6px !important;
  background: #09151e !important; border-right: 1px solid #203744;
  overflow-x: hidden !important; overflow-y: auto !important; box-sizing: border-box;
  align-self: stretch !important;
  z-index: 3 !important;
}
#workspace.rex-window-active.rex-sidebar-open[data-rex-window-mode] > .workspace-modes {
  display: flex !important;
}
#workspace.rex-window-active[data-rex-window-mode] > .workspace-modes > button,
#workspace.rex-window-active[data-rex-window-mode] > .workspace-modes > .rex-nav-group {
  width: 100% !important; min-width: 0 !important; flex: 0 0 auto !important;
  margin: 0 !important; text-align: left;
}
#workspace.rex-window-active[data-rex-window-mode] .rex-nav-group > .rex-nav-group-items {
  position: static !important; width: 100% !important; min-width: 0 !important;
  max-width: none !important; grid-template-columns: 1fr !important;
  box-sizing: border-box; box-shadow: none !important;
}
#rexWindowTools {
  display: grid; gap: 6px; padding-bottom: 12px; margin-bottom: 6px;
  border-bottom: 1px solid #28414e;
}
#rexWindowTools button {
  width: 100%; min-height: 38px; border-radius: 9px; text-align: left;
  border: 1px solid #284958; background: #102633; color: #dff7ff;
  padding: 9px 10px; font-size: 11px; font-weight: 750; cursor: pointer;
}
#rexWindowTools [data-rex-control="stopRex"] { border-color: #613744; color: #ffd0d7; }
#rexWindowTools .sharing-active { border-color: #4bddba; color: #b9fff0; }
#rexWindowTools [hidden] { display: none !important; }

#workspace.rex-window-active[data-rex-window-mode] > :is(.workspace-mode-view, #webPanel, #chatWorkspace):not([hidden]) {
  position: absolute !important;
  inset: var(--rex-window-header) 0 0 var(--rex-window-rail) !important;
  display: block !important; width: auto !important; height: auto !important;
  min-height: 0 !important; min-width: 0 !important;
  max-width: none !important; max-height: none !important;
  margin: 0 !important; border-radius: 0 !important;
  align-self: stretch !important; justify-self: stretch !important;
  overflow: auto !important; box-sizing: border-box; z-index: 1 !important;
}
#workspace.rex-window-active[data-rex-window-mode] > [hidden] { display: none !important; }
#workspace.rex-window-active[data-rex-window-mode] > #chatWorkspace:not([hidden]) {
  padding: 0 !important; overflow: hidden !important;
}
#workspace.rex-window-active[data-rex-window-mode] > #webPanel:not([hidden]) {
  display: flex !important; flex-direction: column !important; padding: 0 !important;
  overflow: hidden !important; background: #071019;
}
#workspace.rex-window-active[data-rex-window-mode] #webPanel > .web-toolbar {
  position: relative !important; inset: auto !important; flex: 0 0 auto !important;
  display: flex !important; align-items: center; flex-wrap: nowrap !important;
  gap: 6px; margin: 0 !important; padding: 8px !important;
  height: auto !important; min-height: 48px !important;
  width: 100% !important; box-sizing: border-box; z-index: 2 !important;
}
#workspace.rex-window-active[data-rex-window-mode] #webAddressInput {
  flex: 1 1 0 !important; min-width: 0 !important; width: auto !important;
}
#workspace.rex-window-active[data-rex-window-mode] .web-toolbar button {
  flex: 0 0 auto !important; width: auto !important; min-width: 0 !important;
}
#workspace.rex-window-active[data-rex-window-mode] #rexWebFrame,
#workspace.rex-window-active[data-rex-window-mode] #webFrame {
  flex: 1 1 0 !important; min-height: 0 !important; width: 100% !important;
  height: 100% !important; border: 0 !important; margin: 0 !important;
}
#workspace.rex-window-active[data-rex-window-mode] #webPanel > [hidden] { display: none !important; }
#workspace.rex-window-active[data-rex-window-mode] #rexAppView {
  flex: 1 1 0; min-height: 0; min-width: 0; overflow: auto;
}
#workspace.rex-window-active[data-rex-window-mode] #webPanel > :is(#rexBrowserGuide, #rexBrowserLive, #rexWorkspaceChromiumHost) {
  flex: 1 1 0 !important; min-height: 0 !important; min-width: 0 !important;
  max-height: none !important; margin: 0 !important; border-radius: 0 !important;
  overflow: auto !important; box-sizing: border-box;
}
#workspace.rex-window-active[data-rex-window-mode] #rexBrowserLive > * { flex-shrink: 0; }
#workspace.rex-window-active[data-rex-window-mode] #webPanel:has(#rexWebFrame:not([hidden])) > #rexBrowserGuide {
  flex: 0 0 auto !important; max-height: 35% !important;
}
#workspace.rex-window-active[data-rex-window-mode] #webFrameStatus {
  flex: 0 0 auto; margin: 0; padding: 5px 10px; overflow-wrap: anywhere;
}

#rexWindowControls {
  display: flex; flex: 0 0 auto; align-items: center; gap: 6px; margin-left: auto;
}
#rexWindowControls button {
  min-height: 36px; border-radius: 9px; border: 1px solid #294857;
  background: #0c1b25; color: #dff7ff; padding: 8px 10px;
  font-size: 10px; font-weight: 800; letter-spacing: .025em; cursor: pointer;
}
#rexWindowControls .rex-window-close { border-color: #653341; background: #2a1117; color: #ffc4ce; }
#rexWindowControls button:disabled { opacity: .45; cursor: default; }
#rexWindowControls button:focus-visible,
#rexWindowTools button:focus-visible { outline: 2px solid #8ee9ff; outline-offset: 2px; }
#rexWindowDock {
  position: fixed; left: 12px; bottom: 12px; z-index: 2147483100;
  display: flex; gap: 7px; flex-wrap: wrap; max-width: min(92vw, 840px);
  padding: 7px; border: 1px solid #264654; border-radius: 12px;
  background: #07121aed; box-shadow: 0 12px 35px #0008;
}
#rexWindowDock[hidden] { display: none !important; }
#rexWindowDock button {
  border: 1px solid #2a5569; background: #0c2230; color: #dcf8ff;
  border-radius: 8px; padding: 8px 11px; font-size: 11px; font-weight: 800; cursor: pointer;
}
@media (max-width: 700px) {
  #workspace.rex-window-active[data-rex-window-mode] { --rex-window-header: 54px; }
  #workspace.rex-window-active[data-rex-window-mode] > .workspace-head { gap: 6px !important; padding: 0 8px !important; }
  #workspace.rex-window-active[data-rex-window-mode] #workspaceTitle { font-size: 11px !important; }
  #rexWindowControls { gap: 4px; }
  #rexWindowControls button { min-height: 36px; padding: 7px 6px; font-size: 9px; }
  #workspace.rex-window-active.rex-sidebar-open[data-rex-window-mode] { --rex-window-rail: 0px; }
  #workspace.rex-window-active.rex-sidebar-open[data-rex-window-mode] > .workspace-modes {
    width: min(232px, 82vw) !important; box-shadow: 14px 0 34px #0008;
  }
  #workspace.rex-window-active[data-rex-window-mode] .web-toolbar button { padding: 8px 6px !important; font-size: 9px !important; }
  #workspace.rex-window-active[data-rex-window-mode] #webPanel > .web-toolbar {
    flex-wrap: wrap !important;
  }
  #workspace.rex-window-active[data-rex-window-mode] #webAddressInput {
    order: -1; flex-basis: calc(100% - 50px) !important;
  }
  #workspace.rex-window-active[data-rex-window-mode] #webGo { order: -1; }
}
