@@ -329,21 +329,30 @@ export function GuidedTour({ activeTab, chatEnabled = true, onTabChange, onClose
329329
330330 // Compute card position via CSS custom properties so the static styles
331331 // live in the SCSS module while runtime values flow through inline.
332+ // Threshold reflects the real card footprint, not just header chrome:
333+ // step 1 ("Quickstart — author from a brief") plus the 14-step
334+ // counter + tab badge + Skip/Next action row lands around 280px on
335+ // desktop, so a 200px "below" check happily placed the card in a
336+ // slot it could never fit. The card itself is also max-heighted +
337+ // overflow-y: auto in the SCSS so even worst-case anchors keep the
338+ // controls reachable, but biasing toward "above" / "right" first
339+ // avoids the awkward inner scroll on the most common targets.
340+ const CARD_MIN_VERTICAL_SLOT = 320 ;
332341 const cardVars : CSSProperties = { } ;
333342 if ( ! isMobile && rect ) {
334343 const below = vh - ( rect . top + rect . height + 10 ) ;
335344 const above = rect . top - 10 ;
336345 const right = vw - ( rect . left + rect . width + 10 ) ;
337346
338- if ( below >= 200 ) {
347+ if ( below >= CARD_MIN_VERTICAL_SLOT ) {
339348 ( cardVars as Record < string , string > ) [ '--card-top' ] = `${ rect . top + rect . height + 16 } px` ;
340349 ( cardVars as Record < string , string > ) [ '--card-left' ] = `${ Math . max ( 16 , Math . min ( rect . left , vw - CARD_W - 16 ) ) } px` ;
341- } else if ( above >= 200 ) {
350+ } else if ( above >= CARD_MIN_VERTICAL_SLOT ) {
342351 ( cardVars as Record < string , string > ) [ '--card-bottom' ] = `${ vh - rect . top + 16 } px` ;
343352 ( cardVars as Record < string , string > ) [ '--card-left' ] = `${ Math . max ( 16 , Math . min ( rect . left , vw - CARD_W - 16 ) ) } px` ;
344353 } else if ( right >= CARD_W + 24 ) {
345354 ( cardVars as Record < string , string > ) [ '--card-left' ] = `${ rect . left + rect . width + 16 } px` ;
346- ( cardVars as Record < string , string > ) [ '--card-top' ] = `${ Math . max ( 16 , rect . top ) } px` ;
355+ ( cardVars as Record < string , string > ) [ '--card-top' ] = `${ Math . max ( 16 , Math . min ( rect . top , vh - CARD_MIN_VERTICAL_SLOT - 16 ) ) } px` ;
347356 } else {
348357 ( cardVars as Record < string , string > ) [ '--card-bottom' ] = '24px' ;
349358 ( cardVars as Record < string , string > ) [ '--card-right' ] = '24px' ;
0 commit comments