/* Desktop panes must retain their contents at laptop heights and browser zoom.
   The phone shell remains owned by mobile-chess-shell.css. */
@media (min-width:1001px){
  #trainerLayout.workspace-play>.board-column{
    --play-page-pad-y:max(2rem,var(--board-lock-pad-y,2rem));
    padding-top:var(--play-page-pad-y)!important;
    padding-bottom:var(--play-page-pad-y)!important;
  }
  #trainerLayout:is(.workspace-analyze,.workspace-training){
    --board-lock-pad-y:2rem;
  }

  /* Auto tracks were shrinking the Settings border while its form overflowed
     behind Game moves. The column owns scrolling; cards keep their height. */
  #trainerLayout.workspace-play>.board-column>.play-side-column:not(.desktop-play-wide){
    grid-template-rows:max-content max-content minmax(10rem,1fr)!important;
    align-content:start!important;
  }
  #trainerLayout.workspace-play>.board-column>.play-side-column:not(.desktop-play-wide):has(#moveList:empty){
    grid-template-rows:max-content max-content max-content!important;
  }
  #trainerLayout.workspace-play>.board-column>.play-side-column:not(.desktop-play-wide)>#desktopPlaySettingsPanel{
    height:auto!important;min-height:max-content!important;
  }
  #trainerLayout.workspace-play>.board-column>.play-side-column>#playMovesPanel:has(#moveList:empty){
    height:auto!important;min-height:0!important;align-self:start!important;
  }

  /* Navigate has the same intrinsic-height requirement when its cards stack.
     Keep wide, independently scrolling cards intact. */
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot{
    flex:0 0 auto!important;
    --setup-tile-size:min(2.65rem,calc(var(--board-lock-size-px,400px) / 8));
  }
  /* Tools are controls, not a second board. Twelve compact tiles fit in a
     single row on laptop panes instead of reserving two oversized rows. */
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot .setup-palette{
    grid-template-columns:repeat(auto-fit,minmax(0,var(--setup-tile-size)))!important;
    gap:.25rem!important;margin:.35rem 0 .5rem!important;
  }
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot .setup-piece{
    width:var(--setup-tile-size)!important;height:var(--setup-tile-size)!important;
    padding:.15rem!important;
  }
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot .setup-piece .piece{
    inline-size:80%!important;block-size:80%!important;
  }
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot .setup-toggle-field{
    display:flex!important;align-items:center!important;justify-content:center!important;
    flex-wrap:wrap!important;gap:.35rem .65rem!important;padding:.35rem .5rem!important;
  }
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot .setup-option-label{
    font-size:.85rem!important;
  }
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot .castling-rights{
    margin:.5rem 0 0!important;padding:.4rem .55rem!important;
  }
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot .castling-side{
    gap:.2rem!important;
  }
  #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigateSetupSlot .castling-rights>.hint{
    margin:.35rem 0 0!important;font-size:.75rem!important;line-height:1.35!important;
  }
  @container desktop-navigate (max-width:54rem){
    #trainerLayout.workspace-analyze[data-mobile-mode="position"]>.middle-column>#navigateTabContent{
      overflow-y:auto!important;overflow-x:hidden!important;
    }
    #trainerLayout.workspace-analyze[data-mobile-mode="position"] #desktopNavigatePanels{
      flex:0 0 auto!important;height:max-content!important;min-height:0!important;
      grid-template-rows:max-content max-content!important;align-content:start!important;
    }
    #trainerLayout.workspace-analyze[data-mobile-mode="position"] .desktop-navigate-collections{
      grid-template-rows:max-content max-content!important;min-height:max-content!important;
    }
    #trainerLayout.workspace-analyze[data-mobile-mode="position"] .desktop-navigate-card{
      min-height:max-content!important;overflow:visible!important;
    }
  }
  @container desktop-navigate (min-width:34rem) and (max-width:54rem){
    #trainerLayout.workspace-analyze[data-mobile-mode="position"] .desktop-navigate-collections{
      grid-template-columns:repeat(2,minmax(0,1fr))!important;
      grid-template-rows:max-content!important;
    }
    #trainerLayout.workspace-analyze[data-mobile-mode="position"] .desktop-navigate-collections:has(#desktopNavigateRepertoireDetail>#lichessPanel:not([hidden])){
      grid-template-columns:minmax(0,1fr)!important;
    }
  }

  /* Narrow Analyze cards keep legible controls and a shared horizontal table
     scroll instead of truncating controls or painting column labels together. */
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane #lichessExplorerEvaluateMenu.lvgb-explorer-evaluate-menu{
    flex-wrap:wrap!important;max-height:none!important;overflow:visible!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane{
    overflow-x:auto!important;
  }
  html #trainerLayout.workspace-analyze[data-mobile-mode="explain"] #lichessPanel #lichessExplorerPane :is(.lvgb-mobile-explorer-columns,.lvgb-tree-node-row){
    min-width:24rem!important;
  }
  #trainerLayout.workspace-training #lichessSharedRoot>.lvgb-app>[data-lvgb-view="training"]{
    scrollbar-gutter:stable;
  }
}
