/* Desktop Analyze: show the existing Analysis and Explain workspaces together.
   Phone/tablet keep the original exclusive Analysis / Explain switch.
   Navigate's Setup/Repertoire/Saved controls stay mounted but never render here.
   The board geometry and primary navigation are owned by their canonical CSS. */
.desktop-analyze-panel-heading{display:none}
@media (min-width:1001px){
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]{
    grid-template-columns:var(--board-lock-zone-px) var(--board-lock-divider-width) minmax(0,var(--position-pane-track,50fr)) .72rem minmax(0,var(--explain-pane-track,50fr))!important;
    grid-template-rows:minmax(0,1fr)!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.board-column,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>#workspaceDivider{
    grid-row:1!important;
  }
  /* There are no Analyze/Explain selection buttons or extra Help button on
     desktop. Their mobile equivalents remain fully functional below 1001px. */
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>#mobileAnalyzeViewTabs{
    display:none!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>#analysisDivider{
    display:block!important;grid-column:4!important;grid-row:1!important;
    width:.72rem!important;min-width:.72rem!important;
    height:100%!important;min-height:0!important;align-self:stretch!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.middle-column,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.right-column{
    grid-row:1!important;display:flex!important;flex-direction:column!important;
    width:100%!important;height:100%!important;min-width:0!important;min-height:0!important;
    max-height:100%!important;box-sizing:border-box!important;
    padding:.58rem .65rem!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:10px!important;
    background:var(--ai-color-surface-1,#fff)!important;
    overflow-x:hidden!important;overflow-y:auto!important;
    overscroll-behavior:contain!important;
    font-family:var(--ai-font-interface,Inter,"Segoe UI",Arial,sans-serif)!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.middle-column{
    grid-column:3!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.right-column{
    grid-column:5!important;
  }
  /* Unsigned Analyze's older full-width Stockfish fallback must not hide the
     canonical Explain panel or span the divider on larger desktop screens. */
  html.chess-unsigned[data-mobile-mode="explain"][data-mobile-analysis-submode] #trainerLayout.workspace-analyze>.middle-column{
    grid-column:3!important;display:flex!important;
  }
  html.chess-unsigned[data-mobile-mode="explain"][data-mobile-analysis-submode] #trainerLayout.workspace-analyze>.right-column{
    grid-column:5!important;display:flex!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.middle-column>.desktop-analyze-panel-heading,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.right-column>.desktop-analyze-panel-heading{
    display:block!important;flex:0 0 auto!important;
    width:100%!important;box-sizing:border-box!important;
    margin:0 0 .55rem!important;padding:0 0 .55rem!important;
    border-bottom:1px solid var(--ai-color-border,#d4dce6)!important;
    color:var(--ai-color-text,#10213a)!important;
    font-family:var(--ai-font-interface,Inter,"Segoe UI",Arial,sans-serif)!important;
    font-size:.95rem!important;font-weight:700!important;line-height:1.3!important;
    letter-spacing:normal!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.middle-column>#explorePositionSourceControl,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.middle-column>#navigateTabContent{
    display:none!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.middle-column>.engine-panel,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]>.right-column>#annotationPanel:not([hidden]){
    min-width:0!important;max-width:100%!important;
  }
}

/* Adaptive concurrent Analyze cards, scoped exclusively to desktop >1000px. */
@media (min-width:1001px){
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"][data-desktop-analyze-layout="four"]{
    grid-template-columns:var(--board-lock-zone-px) var(--board-lock-divider-width) minmax(0,1.4fr) repeat(3,minmax(0,1fr))!important;
    grid-template-rows:minmax(0,1fr)!important;column-gap:var(--board-lock-gap)!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"][data-desktop-analyze-layout="grid"]{
    grid-template-columns:var(--board-lock-zone-px) var(--board-lock-divider-width) repeat(2,minmax(0,1fr))!important;
    grid-template-rows:repeat(2,minmax(0,1fr))!important;column-gap:var(--board-lock-gap)!important;row-gap:.4rem!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>.board-column,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>#workspaceDivider{
    grid-row:1/-1!important;align-self:stretch!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>#analysisDivider{display:none!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>.right-column,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>.right-column>#annotationPanel:not([hidden]){display:contents!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>.right-column>#annotationPanel[hidden]{display:none!important}
  /* The unsigned-session fallback has greater specificity and forces this
     container into column five. Flatten it only in expanded desktop layouts,
     so Position, Move and Comment become independent grid items again. */
  html.chess-unsigned[data-mobile-mode="explain"][data-mobile-analysis-submode] #trainerLayout.workspace-analyze:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>.right-column{
    grid-column:auto!important;
    display:contents!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>.right-column>.desktop-analyze-panel-heading,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #explainViewSelector{display:none!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"])>.middle-column{grid-column:3!important;grid-row:1!important;overflow-y:auto!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"][data-desktop-analyze-layout="four"] #positionAnalysisPane{grid-column:4!important;grid-row:1!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"][data-desktop-analyze-layout="four"] #moveAnalysisPane{grid-column:5!important;grid-row:1!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"][data-desktop-analyze-layout="four"] #positionCommentPanel{grid-column:6!important;grid-row:1!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"][data-desktop-analyze-layout="grid"] #positionAnalysisPane{grid-column:4!important;grid-row:1!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"][data-desktop-analyze-layout="grid"] #moveAnalysisPane{grid-column:3!important;grid-row:2!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"][data-desktop-analyze-layout="grid"] #positionCommentPanel{grid-column:4!important;grid-row:2!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #positionAnalysisPane,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #moveAnalysisPane,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #positionCommentPanel{
    display:flex!important;flex-direction:column!important;box-sizing:border-box!important;
    width:100%!important;height:100%!important;max-height:100%!important;min-width:0!important;min-height:0!important;
    margin:0!important;padding:.58rem .65rem!important;border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:10px!important;background:var(--ai-color-surface-1,#fff)!important;
    overflow-x:hidden!important;overflow-y:auto!important;overscroll-behavior:contain!important;
    font-family:var(--ai-font-interface,Inter,"Segoe UI",Arial,sans-serif)!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #positionAnalysisPane>.analysis-pane-header,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #moveAnalysisPane>.analysis-pane-header{
    display:flex!important;align-items:center!important;flex-wrap:wrap!important;gap:.4rem!important;
    width:100%!important;flex:0 0 auto!important;padding:0 0 .5rem!important;margin:0 0 .5rem!important;
    border-bottom:1px solid var(--ai-color-border,#d4dce6)!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #positionAnalysisPane>.analysis-pane-header h2,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #moveAnalysisPane>.analysis-pane-header h2{
    flex:1 1 auto!important;margin:0!important;font-size:.95rem!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #positionStatusCell,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #moveStatusCell{
    flex:1 1 100%!important;order:5!important;min-width:0!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #annotationPositionContent,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #annotationMoveContent{
    display:block!important;flex:1 1 auto!important;min-height:0!important;max-width:100%!important;overflow:auto!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #positionCommentPanel .comments-compact-row{
    display:flex!important;align-items:center!important;flex-wrap:wrap!important;gap:.5rem!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"]:is([data-desktop-analyze-layout="four"],[data-desktop-analyze-layout="grid"]) #positionCommentPanel .comments-heading{
    flex:1 1 100%!important;margin:0!important;padding:0 0 .5rem!important;
    border-bottom:1px solid var(--ai-color-border,#d4dce6)!important;font-size:.95rem!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] .desktop-explain-settings-gear{
    min-width:2.1rem!important;width:2.1rem!important;min-height:2.1rem!important;
    padding:.3rem!important;flex:0 0 auto!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] .desktop-explain-settings-gear>span:last-child{display:none!important}
  /* Keep the native showModal() dialog in the viewport/top layer rather than
     inheriting document-flow placement from old settings surfaces. */
  html .desktop-explain-settings-dialog[open]{
    position:fixed!important;inset:0!important;margin:auto!important;
    z-index:2147483647!important;
    box-sizing:border-box;width:min(28rem,calc(100vw - 2rem));
    max-height:calc(100dvh - 2rem);padding:1rem;overflow-y:auto!important;
    overscroll-behavior:contain;
    border:1px solid var(--ai-color-border,#cfd8e6);border-radius:12px;
    background:var(--ai-color-surface-1,#fff);color:var(--ai-color-text,#10213a);
    box-shadow:0 18px 55px #0004;
  }
  html .desktop-explain-settings-dialog::backdrop{background:rgba(7,16,30,.45)}
  /* Explicitly hide the child outside the active dialog. Never let the old
     fixed-position form paint independently beneath the board or other cards. */
  html .desktop-explain-settings-dialog:not([open]) #explainSettingsPopover{display:none!important}
  /* The em dash was an empty-comment placeholder, not an action or status.
     Keep Edit visible without meaningless placeholder text on desktop. */
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #positionCommentPanel .comment-readonly.empty{
    display:none!important;
  }
  /* Shared continuation header must never stack Info and Evaluate vertically
     when the desktop Analysis column is narrower than the full viewport. */
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    .lvgb-mobile-explorer-columns>span.lvgb-explorer-header-actions{
    display:flex!important;flex-direction:row!important;flex-wrap:nowrap!important;
    align-items:center!important;justify-content:flex-end!important;
    min-width:2.35rem!important;width:2.35rem!important;max-width:none!important;
    height:1.35rem!important;min-height:1.35rem!important;
    gap:.12rem!important;padding:0!important;overflow:visible!important;
    white-space:nowrap!important;justify-self:end!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    .lvgb-mobile-explorer-columns>span.lvgb-explorer-header-actions>button{
    display:grid!important;place-items:center!important;flex:0 0 1.1rem!important;
    width:1.1rem!important;min-width:1.1rem!important;height:1.1rem!important;
    min-height:1.1rem!important;margin:0!important;padding:0!important;
    border:0!important;border-radius:50%!important;line-height:1!important;
  }
  /* A permanent SCORE/ENG calculation bar replaces the phone-only lightning
     popup on desktop. The continuation rows remain separately scrollable. */
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu.lvgb-explorer-evaluate-menu{
    display:flex!important;flex-wrap:wrap!important;align-items:center!important;
    gap:.35rem!important;padding:.4rem .5rem!important;margin:.15rem 0 .4rem!important;
    width:100%!important;box-sizing:border-box!important;
    background:var(--ai-color-surface-2,#edf2f8)!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:8px!important;font-size:.76rem!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu .lvgb-evaluation-title{display:inline!important;flex:0 0 auto;font-size:.76rem}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu>span{flex:1 1 100%!important;font-size:.72rem!important;white-space:normal!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu>button{
    min-height:1.9rem!important;padding:.3rem .55rem!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:6px!important;font-size:.76rem!important;font-weight:700!important;
    background:var(--ai-color-surface-1,#fff)!important;color:var(--ai-color-text,#10213a)!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu>button[aria-pressed="true"]{
    color:var(--ai-color-accent-contrast,#fff)!important;background:var(--ai-color-accent,#4267ff)!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessExplorerEvaluateButton{
    display:none!important;
  }
  /* Float the column explanation to the RIGHT of the continuation table.
     Using the native modal top layer prevents ancestor scroll/contain clipping. */
  html #lichessExplorerColumnHelp.explore-help-sheet:modal{
    position:fixed!important;inset:auto!important;
    left:var(--continuation-help-left,auto)!important;
    top:var(--continuation-help-top,1rem)!important;
    transform:none!important;margin:0!important;
    width:var(--continuation-help-width,24rem)!important;
    max-width:calc(100vw - 1.5rem)!important;
    max-height:calc(100dvh - 2rem)!important;
    overflow:hidden!important;
    z-index:2147483647!important;
  }
  html .desktop-explain-settings-dialog #explainSettingsPopover.explain-settings-popover:not([hidden]){
    display:block!important;position:static!important;inset:auto!important;transform:none!important;
    width:100%!important;max-width:none!important;height:auto!important;max-height:75dvh!important;
    margin:0!important;padding:0!important;border:0!important;box-shadow:none!important;overflow:auto!important;
  }
}

.lvgb-explorer-desktop-hint{display:none!important}
/* Desktop Analyze: one-row SCORE/ENG calculator and light hover help.
   Phone/tablet retain their existing lightning menu and modal column help. */
@media (min-width:1001px){
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu.lvgb-explorer-evaluate-menu{
    display:flex!important;flex-flow:row nowrap!important;align-items:center!important;
    gap:.22rem!important;padding:.18rem .3rem!important;margin:.08rem 0 .2rem!important;
    box-sizing:border-box!important;min-height:2rem!important;max-height:2.2rem!important;
    width:100%!important;overflow:hidden!important;border-radius:6px!important;
    font-size:.69rem!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu .lvgb-evaluation-title{
    display:inline!important;flex:0 0 auto!important;order:0!important;font-size:.69rem!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu>span{
    order:10!important;flex:1 1 auto!important;min-width:0!important;
    white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;
    font-size:.63rem!important;text-align:right!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    #lichessExplorerEvaluateMenu>button{
    order:1!important;flex:0 0 auto!important;min-height:1.55rem!important;
    margin:0!important;padding:.16rem .31rem!important;font-size:.66rem!important;
    border-radius:5px!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessExplorerEvaluateButton,
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessExplorerColumnsInfo{display:none!important}
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane
    .lvgb-explorer-header-actions>.lvgb-explorer-desktop-hint{
    display:inline-flex!important;align-items:center!important;justify-content:center!important;
    flex:0 0 1.25rem!important;width:1.25rem!important;height:1.25rem!important;
    margin:0!important;padding:0!important;border:0!important;
    border-radius:50%!important;background:transparent!important;box-shadow:none!important;
    color:var(--ai-color-text-muted,#627086)!important;cursor:help!important;
    font:700 .83rem/1 var(--ai-font-interface,system-ui)!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] .lvgb-explorer-desktop-hint:focus-visible{
    outline:1px solid var(--ai-color-accent,#4267ff)!important;
  }
  html #lichessExplorerColumnHelp.explore-help-sheet:popover-open{
    position:fixed!important;inset:auto!important;
    left:var(--continuation-help-left,auto)!important;top:var(--continuation-help-top,1rem)!important;
    margin:0!important;transform:none!important;
    width:var(--continuation-help-width,22rem)!important;
    max-width:calc(100vw - 1.5rem)!important;max-height:min(70dvh,34rem)!important;
    padding:0!important;overflow:hidden!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;border-radius:9px!important;
    background:var(--ai-color-surface-1,#fff)!important;color:var(--ai-color-text,#10213a)!important;
    box-shadow:0 10px 28px rgba(16,33,58,.2)!important;
  }
  html #lichessExplorerColumnHelp:popover-open .explore-sheet-card{max-height:min(70dvh,34rem)!important}
  html #lichessExplorerColumnHelp:popover-open .explore-sheet-heading{padding:.45rem .65rem!important}
  html #lichessExplorerColumnHelp:popover-open .explore-sheet-heading .eyebrow,
  html #lichessExplorerColumnHelp:popover-open .explore-sheet-close{display:none!important}
  html #lichessExplorerColumnHelp:popover-open .explore-sheet-heading h2{font-size:.83rem!important}
  html #lichessExplorerColumnHelp:popover-open .explore-help-content{
    padding:.4rem .65rem .65rem!important;gap:.5rem!important;font-size:.74rem!important
  }
}

/* Desktop Analyze uses the permanent SCORE/ENG/Top 3/Top 5 strip.
   Hide only its mobile lightning trigger; keep the floating continuation info icon. */
@media (min-width:1001px){
  html #trainerLayout.workspace-analyze #lichessPanel #lichessExplorerPane #lichessExplorerEvaluateButton{
    display:none!important;
  }
}
