/* Phone-first lower-workspace visual system.
   Board/header/history geometry belongs to mobile-chess-shell.css. */
.mobile-workspace-tab-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:1rem;height:1rem;color:currentColor}
.mobile-workspace-tab-icon svg{display:block;width:100%;height:100%;fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.8}
/* Keep Navigate source controls aligned with the shared strip at compact widths. */
@media(max-width:1000px){
  #trainerLayout.workspace-analyze #explorePositionSourceControl{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    align-items:center!important;
    gap:.28rem!important;
  }
  #trainerLayout.workspace-analyze #explorePositionSourceControl>.mobile-page-tab-strip{
    display:flex!important;
    grid-column:1/-1!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    min-width:0!important;
  }
  #trainerLayout.workspace-analyze #explorePositionSourceControl .explore-position-collection-navigation{
    grid-column:1/-1!important;
    grid-row:2!important;
  }
}
@media (max-width:760px){
  :root{
    --mobile-ui-hit:44px;
    --mobile-ui-form-font:16px;
    --mobile-ui-gap-xs:.3rem;
    --mobile-ui-gap-sm:.5rem;
    --mobile-ui-gap-md:.75rem;
    --mobile-ui-radius:10px;
  }

  .mobile-workspace-section{
    display:grid;
    gap:var(--mobile-ui-gap-sm);
    min-width:0;
    padding:.65rem;
    border:1px solid var(--ai-color-border,#cfd8e6);
    border-radius:var(--mobile-ui-radius);
    background:var(--ai-color-surface-1,#fff);
  }
  .mobile-workspace-section>h2,
  .mobile-workspace-section>h3{margin:0;font-size:.95rem;line-height:1.25}
  .mobile-workspace-section>p{margin:0;color:var(--ai-color-text-muted,#667085);line-height:1.4}

  .mobile-inline-panel{
    display:grid;
    gap:var(--mobile-ui-gap-sm);
    min-width:0;
    padding:.65rem;
    border:1px solid var(--ai-color-border,#cfd8e6);
    border-radius:var(--mobile-ui-radius);
    background:var(--ai-color-surface-2,#f5f7fa);
  }
  .mobile-inline-panel[hidden]{display:none!important}

  .mobile-action-row{
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:var(--mobile-ui-gap-sm);
  }
  .mobile-action-row>button,
  .mobile-action-row>a,
  .mobile-inline-panel button,
  .mobile-workspace-section button{
    min-height:var(--mobile-ui-hit);
  }

  .mobile-form-control,
  .mobile-inline-panel input:not([type="checkbox"]):not([type="radio"]),
  .mobile-inline-panel select,
  .mobile-inline-panel textarea,
  .mobile-workspace-section input:not([type="checkbox"]):not([type="radio"]),
  .mobile-workspace-section select,
  .mobile-workspace-section textarea{
    min-height:var(--mobile-ui-hit);
    font-size:var(--mobile-ui-form-font);
  }
  .mobile-inline-panel textarea,
  .mobile-workspace-section textarea{min-height:5.5rem;line-height:1.4}

  .mobile-details{
    display:grid;
    gap:var(--mobile-ui-gap-xs);
    min-width:0;
    padding:.5rem .55rem;
    border-top:1px solid var(--ai-color-border,#cfd8e6);
    background:color-mix(in srgb,var(--ai-color-surface-2,#f5f7fa) 75%,transparent);
  }
  .mobile-details[hidden]{display:none!important}

  .mobile-segmented-control{
    display:grid;
    grid-auto-flow:column;
    grid-auto-columns:1fr;
    gap:.25rem;
    padding:.2rem;
    border:1px solid var(--ai-color-border,#cfd8e6);
    border-radius:var(--mobile-ui-radius);
    background:var(--ai-color-surface-2,#f5f7fa);
  }
  .mobile-segmented-control>button{min-height:var(--mobile-ui-hit);border-radius:8px}

  .mobile-primary-action{font-weight:700}
  .mobile-destructive-action{color:#b42318;border-color:color-mix(in srgb,#b42318 55%,var(--ai-color-border,#cfd8e6))}
}

/* Navigate / Analyze split. The old internal tokens remain `position` and
   `explain` so persisted sessions stay compatible, but their mobile ownership
   is now explicit: Navigate shows sources, while Analyze switches between
   numerical and human analysis views. The shared board shell remains the only
   geometry owner. */
@media (max-width:760px){
  html.mobile-chess-shell-active[data-mobile-mode="explain"],
  html.mobile-chess-shell-active[data-mobile-mode="explain"] body,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] .chess-app{
    height:auto!important;
    min-height:100%!important;
    max-height:none!important;
    overflow:visible!important;
    overscroll-behavior-y:auto!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze{
    height:auto!important;
    min-height:100%!important;
    max-height:none!important;
    grid-template-rows:auto max-content max-content!important;
    overflow:visible!important;
    align-content:start!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.middle-column,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.right-column{
    grid-column:1!important;
    width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    overflow:visible!important;
    align-self:start!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.middle-column{
    grid-row:3!important;
    display:block!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.right-column{
    grid-row:2!important;
    display:block!important;
  }
  /* Source selection is Navigate-only. The analysis tabs and result surfaces
     remain directly below the board without inheriting a second frame. */
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.middle-column>#explorePositionSourceControl{
    display:none!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.middle-column>.engine-panel,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.middle-column>#lichessPanel,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.right-column>#annotationPanel{
    width:100%!important;
    max-width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.middle-column>.engine-panel{
    display:flex!important;
    flex-direction:column!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.right-column>#annotationPanel{
    display:grid!important;
    grid-template-rows:auto auto!important;
    gap:var(--mobile-ui-gap-sm)!important;
  }
  /* The page owns scrolling in Analyze, just as it does in Navigate. Keep the
     currently selected human-analysis view mutually exclusive, but let its
     content contribute normal document height. */
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel>#positionAnalysisPane,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel>#moveAnalysisPane,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel #annotationPositionContent,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel #annotationMoveContent{
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel #annotationPositionContent,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel #annotationMoveContent{
    flex:none!important;
  }
}

/* Analyze follows the same compact mobile strip contract as Play and Navigate.
   Put the existing human-analysis frame first so its Position / Move / Comment
   / Settings tabs are visible before the longer numerical analysis surface. */
@media (max-width:760px){
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.right-column{
    grid-row:2!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.middle-column{
    grid-row:3!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.middle-column>.explore-view-toolbar{
    display:grid!important;
    grid-template-columns:minmax(0,1fr) auto!important;
    align-items:stretch!important;
    gap:.2rem!important;
    width:100%!important;
    height:44px!important;
    min-height:44px!important;
    max-height:44px!important;
    margin:0 0 .35rem!important;
    padding:0!important;
  }
}

@media (max-width:760px){
  /* Explore: the three position sources are always available as one compact
     tab row. Collection arrows appear below it only for Repertoire or Saved
     positions, keeping source choice separate from collection navigation. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column>.explore-position-source{
    display:grid!important;
    gap:.35rem!important;
    margin:0 0 .45rem!important;
    padding:.45rem!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs{
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:.28rem!important;
    margin:0!important;
    padding:0!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-option{
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    gap:.18rem!important;
    min-width:0!important;
    min-height:2.75rem!important;
    padding:.35rem .22rem!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:9px!important;
    background:var(--ai-color-surface-2,#edf2f8)!important;
    color:var(--ai-color-text,#162033)!important;
    text-align:center!important;
    font:inherit!important;
    font-size:clamp(.68rem,3.05cqw,.84rem)!important;
    font-weight:700!important;
    line-height:1.08!important;
    overflow-wrap:anywhere!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-option.active,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-option[aria-selected="true"]{
    border-color:var(--ai-color-accent,#4267ff)!important;
    background:var(--ai-color-accent,#4267ff)!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
    box-shadow:none!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-collection-navigation{
    margin-top:0!important;
  }
}

@media (max-width:760px){
  /* Continuations are part of the phone document, not a nested pane. Let the
     table add real page height so the shared shell can compact the board when
     the reader scrolls down. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open>.middle-column{
    display:block!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open #lichessPanel{
    display:block!important;
    flex:none!important;
    width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open #lichessPanel .lvgb-tree-workspace,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open #lichessPanel .lvgb-explorer-moves-panel,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open #lichessPanel .lvgb-explorer-table-scroll,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open #lichessPanel .lvgb-tree-viewport{
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
  }
  /* Continuations keeps its source/view controls in place and gives only the
     dense rows a bounded touch-scroll region. The compact/expanded shell
     variable reserves the board; the remaining height belongs to this table. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open #lichessPanel .lvgb-explorer-table-scroll{
    max-height:calc(100dvh - var(--mobile-shell-compact-height,var(--mobile-shell-expanded-height,0px)) - 7.2rem)!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
    scrollbar-width:none;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open #lichessPanel .lvgb-explorer-table-scroll::-webkit-scrollbar{
    display:none;width:0;height:0;
  }

  /* Setup needs the expanded shell reservation for its overlay. Continuations
     has its own bounded row scroller, so once the shared board becomes compact
     it should give the recovered height back to the controls and table. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.explore-continuations-open.mobile-chess-shell-compact{
    grid-template-rows:max-content!important;
  }

  /* Keep every prominent Explore control aligned while preserving the 44px
     touch target. Compactness comes from spacing and type, not tiny hit areas. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-collection-navigation{
    gap:.2rem!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-option{
    height:44px!important;
    min-height:44px!important;
    padding:.2rem .18rem!important;
    border-radius:8px!important;
    font-size:.74rem!important;
    line-height:1.05!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-collection-navigation{
    min-height:44px!important;
    margin-top:0!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-collection-navigation>strong{
    min-width:0!important;
    padding:0 .15rem!important;
    font-size:.74rem!important;
    line-height:1.05!important;
    text-align:center!important;
  }
}

@media (max-width:760px){
  /* Explain uses the same forms, sections and action hierarchy as the other
     lower workspaces. Settings/comments are inline and never cover the board. */
  #annotationPanel{gap:var(--mobile-ui-gap-sm)}
  #explainViewSelector{margin:0 0 var(--mobile-ui-gap-sm);grid-template-columns:repeat(4,minmax(0,1fr))!important}
  #positionAnalysisPane>.analysis-pane-header{
    display:grid!important;
    grid-template-columns:minmax(0,1fr) auto;
    gap:var(--mobile-ui-gap-xs)!important;
    align-items:center!important;
  }
  #positionAnalysisPane>.analysis-pane-header>h2{grid-column:1}
  #positionAnalysisPane>.analysis-pane-header>#positionStatusCell{grid-column:1/-1;grid-row:2}
  #positionAnalysisPane>.analysis-pane-header>button{
    min-width:var(--mobile-ui-hit)!important;
    min-height:var(--mobile-ui-hit)!important;
    height:var(--mobile-ui-hit)!important;
    padding:.35rem!important;
  }
  #explainSettingsPopover{
    position:static!important;
    inset:auto!important;
    transform:none!important;
    width:100%!important;
    max-width:none!important;
    max-height:max(12rem,calc(100dvh - var(--mobile-shell-expanded-board) - 15rem))!important;
    margin:.45rem 0 0!important;
    overflow:auto!important;
    overscroll-behavior:contain!important;
    scrollbar-width:none;
    -ms-overflow-style:none;
    box-shadow:none!important;
    z-index:auto!important;
  }
  #explainSettingsPopover::-webkit-scrollbar{display:none;width:0;height:0}
  #explainSettingsPopover .engine-settings-heading{margin:0!important;cursor:default!important}
  #explainSettingsPopover .engine-settings-form{gap:var(--mobile-ui-gap-sm)!important}
  #explainSettingsPopover select,
  #explainSettingsPopover input{
    min-height:var(--mobile-ui-hit)!important;
    height:auto!important;
    font-size:var(--mobile-ui-form-font)!important;
  }
  #explainSettingsPopover .engine-field>span,
  #explainSettingsPopover .engine-method-note{font-size:clamp(.92rem,4.2cqw,1rem)!important;line-height:1.3!important;font-weight:650!important}
  #explainSettingsPopover .engine-settings-heading strong{font-size:1rem!important;line-height:1.25!important;font-weight:750!important}
  #explainSettingsPopover .explain-settings-actions{display:flex!important;gap:var(--mobile-ui-gap-sm)!important;margin-top:.15rem!important}
  #explainSettingsPopover .explain-settings-save-button{display:inline-flex!important}
  #explainSettingsPopover .explain-settings-actions button{min-height:var(--mobile-ui-hit)!important}

  #positionCommentPanel{margin-top:var(--mobile-ui-gap-sm);overflow:visible!important}
  #positionCommentPanel .comments-compact-row{gap:var(--mobile-ui-gap-sm)}
  #positionCommentPanel button{min-height:var(--mobile-ui-hit)!important}
  #positionCommentPanel textarea{font-size:var(--mobile-ui-form-font)!important;min-height:5.5rem!important}

  #annotationPanel>.explain-view-selector #explainSettingsButton,
  #annotationPanel>.explain-view-selector #explainMobileCommentButton{
    display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:.18rem!important;width:auto!important;min-width:0!important;height:auto!important;min-height:var(--mobile-ui-hit)!important;
    margin:0!important;
    justify-self:stretch!important;place-self:stretch!important
  }
  #annotationPanel>.explain-view-selector>button{
    justify-self:stretch!important;width:auto!important;
    opacity:1!important;filter:none!important;transform:none!important;
    -webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important;
    font-synthesis:none!important;font-weight:750!important
  }
  #annotationPanel>.explain-view-selector #explainSettingsButton{
    opacity:1!important;filter:none!important;color:var(--ai-color-text,#162033)!important
  }
  #annotationPanel>.explain-view-selector #explainMobileCommentButton{grid-column:3!important}
  #annotationPanel>.explain-view-selector #explainSettingsButton{grid-column:4!important}
  #annotationPanel>.explain-view-selector #explainSettingsButton.active,
  #annotationPanel>.explain-view-selector #explainSettingsButton[aria-selected="true"]{
    color:var(--ai-color-accent-contrast,#fff)!important
  }
  #explainSettingsPopover,
  #explainSettingsPopover .engine-settings-heading,
  #explainSettingsPopover .engine-field,
  #explainSettingsPopover .engine-field>span,
  #explainSettingsPopover select,
  #explainSettingsPopover input,
  #explainSettingsPopover button{
    -webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important;
    font-synthesis:none!important;filter:none!important;opacity:1!important
  }
}

/* Final shared strip typography. Every contextual mobile tab strip uses the
   same compact label scale, weight, padding, and icon gap. */
@media (max-width:760px){
  .mobile-tab-strip>.mobile-workspace-tab,
  #annotationPanel>.explain-view-selector>button{
    gap:.28rem!important;
    padding:.2rem .3rem!important;
    font-family:inherit!important;
    font-size:var(--mobile-control-font,.78rem)!important;
    font-weight:var(--mobile-control-weight,700)!important;
    line-height:var(--mobile-control-line,1.05)!important;
  }
}

@media (max-width:760px){
  /* Every contextual workspace switcher uses the same compact tab geometry.
     The surrounding grids may have different column counts, but the control
     itself keeps one visual language everywhere. */
  .mobile-workspace-tab{
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    gap:.18rem!important;
    width:100%!important;
    height:44px!important;
    min-height:44px!important;
    min-width:0!important;
    box-sizing:border-box!important;
    padding:.2rem .18rem!important;
    border-radius:9px!important;
    font-family:inherit!important;
    font-size:var(--mobile-control-font,.78rem)!important;
    font-weight:var(--mobile-control-weight,700)!important;
    line-height:var(--mobile-control-line,1.05)!important;
    touch-action:manipulation!important;
    user-select:none!important;
    -webkit-user-select:none!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    font-synthesis:none!important;
    -webkit-font-smoothing:antialiased!important;
    text-rendering:optimizeLegibility!important;
  }
  .mobile-workspace-tab .mobile-workspace-tab-icon{
    width:1rem!important;
    height:1rem!important;
    flex:0 0 1rem!important;
  }
  .mobile-workspace-tab[aria-selected="true"],
  .mobile-workspace-tab.active{
    background:var(--ai-color-accent,#4267ff)!important;
    border-color:var(--ai-color-accent,#4267ff)!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
  }
  .mobile-tab-strip{
    display:grid!important;
    grid-auto-flow:column!important;
    grid-auto-columns:minmax(0,1fr)!important;
    gap:0!important;
    padding:.2rem!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:12px!important;
    background:var(--ai-color-surface-2,#f5f7fa)!important;
    min-width:0!important;
  }
  .mobile-tab-strip[hidden]{display:none!important}
  .mobile-tab-strip>.mobile-workspace-tab{
    border-color:transparent!important;
    border-radius:7px!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  .mobile-tab-strip>.mobile-workspace-tab[aria-selected="true"],
  .mobile-tab-strip>.mobile-workspace-tab.active{
    border-color:var(--ai-color-accent,#4267ff)!important;
    background:var(--ai-color-accent,#4267ff)!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
  }
  .mobile-primary-tab,
  .board-column>.history-navigation>.history-arrow,
  .board-column>.history-navigation>#favoritePositionButton{
    touch-action:manipulation!important;
    user-select:none!important;
    -webkit-user-select:none!important;
  }

  /* Play and Explore use the same lower-workspace frame as Explain. The frame
     belongs to the tab surface, while each page supplies its own pane below. */
  .mobile-tab-frame{
    box-sizing:border-box!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:12px!important;
    background:var(--ai-color-surface-1,#fff)!important;
    box-shadow:none!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze #explorePositionSourceControl{
    padding:.45rem!important;
  }
  /* Keep the Play frame stable while its contextual tab content changes. */
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playModeInfo{
    margin:0!important;
    padding:.45rem!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:12px!important;
    background:var(--ai-color-surface-1,#fff)!important;
    box-shadow:none!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-controls-row{
    margin:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls{
    gap:.28rem!important;
    padding:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls>button{
    border-radius:9px!important;
    box-shadow:none!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls>button{
    background:var(--ai-color-surface-2,#edf2f8)!important;
    color:var(--ai-color-text,#162033)!important;
    border-color:var(--ai-color-border,#cfd8e6)!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls>button[aria-selected="true"]{
    background:var(--ai-color-accent,#4267ff)!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
    border-color:var(--ai-color-accent,#4267ff)!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #machineActivity[hidden],
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playMovesPanel[hidden]{
    display:none!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playStartChoices{
    margin:.35rem 0 0!important;
    padding:.45rem!important;
    border-radius:12px!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playStartChoices .play-start-choice-actions{
    gap:.35rem!important;
    align-items:stretch!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playStartChoices .play-start-choice-actions>button{
    min-height:2.8rem!important;
    padding:.35rem .45rem!important;
    border-radius:10px!important;
    font-weight:700!important;
    line-height:1.15!important;
    text-align:center!important;
  }

  /* Keep the settings form compact at its bottom edge: an empty error should
     not create a spacer, and the action row should follow Move delay closely. */
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #newGameDialog>form>label{
    display:grid!important;
    grid-template-columns:minmax(0,1fr) 8rem!important;
    align-items:center!important;
    column-gap:.5rem!important;
    margin:.18rem 0 0!important;
    font-size:1rem!important;
    font-weight:700!important;
    line-height:1.2!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #newGameDialog>form>label>#moveDelaySelect{
    width:8rem!important;
    min-width:8rem!important;
    font-size:1rem!important;
    font-weight:700!important;
    line-height:1.2!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #newGameDialog #newGameError:empty{
    display:none!important;
    min-height:0!important;
    margin:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #newGameDialog .new-game-actions{
    margin-top:.18rem!important;
  }

  /* Settings: the fieldset already names the side, so the repeated player
     label adds no value on a phone. Keep the actual controls and their ARIA
     names, but let each card size to its own contents. */
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .player-definition-grid{
    align-items:start!important;
    gap:.28rem!important;
    margin:.28rem 0 .45rem!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .player-definition-card{
    align-self:start!important;
    padding:.35rem .35rem!important;
    display:grid!important;
    row-gap:.28rem!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .player-definition-card>label{
    margin:0!important;
    gap:0!important;
    font-size:0!important;
    line-height:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .player-definition-card>label select,
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .player-definition-card>label input{
    font-size:var(--mobile-ui-form-font)!important;
    line-height:1.2!important;
  }
}

@media (max-width:760px){
  /* Overview and Continuations are two views of one Position workspace. Keep
     the shared controls on the same width grid and let either view contribute
     to the document height, so switching tabs cannot move the controls. */
  html.mobile-chess-shell-active{
    scrollbar-gutter:stable!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column{
    width:100%!important;
    max-width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column>.explore-position-source,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column>#lichessPanel{
    width:100%!important;
    max-width:100%!important;
    box-sizing:border-box!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column>.explore-position-source{
    padding:0!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column>.explore-position-source-tabs{
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column>.explore-view-toolbar{
    display:flex!important;
    justify-content:space-between!important;
    gap:.2rem!important;
    align-items:stretch!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-collection-navigation{
    display:grid!important;
    grid-template-columns:44px minmax(0,1fr) 44px!important;
    align-items:center!important;
    justify-items:stretch!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-option,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-collection-navigation>button{
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    height:44px!important;
    min-height:44px!important;
    margin:0!important;
    box-sizing:border-box!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-compact-stats{
    flex:1 1 auto!important;
    min-width:0!important;
    font-size:.66rem!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-continuations-engine-status{
    margin:.12rem 0 .25rem!important;
    font-size:.68rem!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-collection-navigation[hidden]{
    display:none!important;
  }
}

/* Final mobile override for the shared Setup panel. Play-specific rules are
   loaded earlier but can otherwise restore the old three-column parent grid. */
@media (max-width:760px){
  :root{
    --mobile-control-font:var(--chess-notation-font-size,.78125rem);
    --mobile-control-weight:700;
    --mobile-control-line:1.05;
  }

  /* Setup replaces the lower Navigate surface. Keep the single shared gap
     below the arrows, but let the source strip and menus use the full pane. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.mobile-position-setup-open{
    gap:.5rem!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze.mobile-position-setup-open>.middle-column{
    padding:0!important;
  }

  /* Play legal moves is the reference label treatment for compact mobile
     actions. Apply it to every equivalent action surface so the interface
     does not change type scale between tabs. */
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playStartChoices .play-start-choice-actions>button,
  html[data-mobile-mode="play"] #trainerLayout.workspace-play.position-setup-open .setup-panel.setup-docked .setup-edit-actions>button,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-option{
    font-family:inherit!important;
    font-size:var(--mobile-control-font)!important;
    font-weight:var(--mobile-control-weight)!important;
    line-height:var(--mobile-control-line)!important;
    font-synthesis:none!important;
    -webkit-font-smoothing:antialiased!important;
    text-rendering:optimizeLegibility!important;
  }
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .mobile-workspace-tab-icon{
    width:1rem!important;height:1rem!important;
  }

  #trainerLayout.workspace-play.position-setup-open .setup-panel.setup-docked .setup-position-actions,
  #trainerLayout.workspace-analyze.mobile-position-setup-open .setup-panel.setup-docked .setup-position-actions{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    gap:.35rem!important;
    align-items:stretch!important;
  }
  #trainerLayout.workspace-play.position-setup-open .setup-panel.setup-docked .setup-edit-actions,
  #trainerLayout.workspace-analyze.mobile-position-setup-open .setup-panel.setup-docked .setup-edit-actions{
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:.35rem!important;
  }
  #trainerLayout.workspace-play.position-setup-open .setup-panel.setup-docked .setup-edit-actions>button,
  #trainerLayout.workspace-analyze.mobile-position-setup-open .setup-panel.setup-docked .setup-edit-actions>button{
    width:100%!important;
    min-width:0!important;
    min-height:var(--mobile-ui-hit)!important;
    height:auto!important;
    padding:.25rem .3rem!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    text-align:center!important;
  }
  #trainerLayout.workspace-play.position-setup-open .setup-panel.setup-docked .setup-edit-actions>button,
  #trainerLayout.workspace-analyze.mobile-position-setup-open .setup-panel.setup-docked .setup-edit-actions>button{
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:9px!important;
    background:var(--ai-color-surface-2,#edf2f8)!important;
    color:var(--ai-color-text,#162033)!important;
    font-family:inherit!important;
    font-size:var(--mobile-control-font)!important;
    font-weight:var(--mobile-control-weight)!important;
    line-height:var(--mobile-control-line)!important;
  }
  #trainerLayout.workspace-play.position-setup-open .setup-panel.setup-docked .setup-edit-actions .momentary-active,
  #trainerLayout.workspace-analyze.mobile-position-setup-open .setup-panel.setup-docked .setup-edit-actions .momentary-active{
    background:var(--ai-color-accent,#4267ff)!important;
    border-color:var(--ai-color-accent,#4267ff)!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
  }

  /* Navigate's metadata line follows the same readable mobile scale as the
     other controls. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze #navigateTabContent>.explore-view-toolbar .explore-compact-stats{
    font-family:var(--ai-font-interface,system-ui,-apple-system,"Segoe UI",sans-serif)!important;
    font-size:1rem!important;
    line-height:1.08!important;
  }

  /* Explore source and view controls use the same compact label treatment as
     Play's lower tabs: identical family, weight, size, and line height. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-option{
    font-family:inherit!important;
    font-size:var(--mobile-control-font)!important;
    font-weight:var(--mobile-control-weight)!important;
    line-height:var(--mobile-control-line)!important;
    font-synthesis:none!important;
    -webkit-font-smoothing:antialiased!important;
    text-rendering:optimizeLegibility!important;
  }

  /* Final connected-tab pass. Keep the visual tab treatment identical even
     where older page-specific rules supplied a small gap or separate radius. */
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls.mobile-tab-strip,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs.mobile-tab-strip,
  html[data-mobile-mode="explain"] #annotationPanel>.explain-view-selector.mobile-tab-strip,
  html[data-mobile-mode="training"] .lvgb-training-tabs.mobile-tab-strip{
    gap:0!important;
    padding:.2rem!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:12px!important;
    background:var(--ai-color-surface-2,#f5f7fa)!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls.mobile-tab-strip,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs.mobile-tab-strip,
  html[data-mobile-mode="explain"] #annotationPanel>.explain-view-selector.mobile-tab-strip,
  html[data-mobile-mode="training"] .lvgb-training-tabs.mobile-tab-strip{
    box-sizing:border-box!important;
    height:44px!important;
    min-height:44px!important;
    max-height:44px!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls.mobile-tab-strip>button.mobile-workspace-tab,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs.mobile-tab-strip>button.mobile-workspace-tab,
  html[data-mobile-mode="explain"] #annotationPanel>.explain-view-selector.mobile-tab-strip>button.mobile-workspace-tab,
  html[data-mobile-mode="training"] .lvgb-training-tabs.mobile-tab-strip>button.mobile-workspace-tab{
    box-sizing:border-box!important;
    height:100%!important;
    min-height:0!important;
  }
  /* The Explain strip is the width reference: its single frame uses all of
     the available lower-workspace track. Remove page-specific wrapper and
     strip insets so Play and Explore cannot add a second side margin. */
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playModeInfo.mobile-tab-frame,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze #explorePositionSourceControl.mobile-tab-frame{
    width:100%!important;
    max-width:none!important;
    margin-left:0!important;
    margin-right:0!important;
  }
  /* Explain has one frame at the tab surface. Explore's desktop middle pane
     is another framed container, so neutralize it on mobile and let the
     position-source surface be the single owner of this boundary. */
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column{
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
    padding:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls.mobile-tab-strip,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs.mobile-tab-strip,
  html[data-mobile-mode="explain"] #annotationPanel>.explain-view-selector.mobile-tab-strip,
  html[data-mobile-mode="training"] .lvgb-training-tabs.mobile-tab-strip{
    width:100%!important;
    max-width:none!important;
    margin-left:0!important;
    margin-right:0!important;
  }
  /* Explain's right column is the only mobile workspace whose scroll owner
     also reserves a stable scrollbar gutter. The scrollbar is hidden on phone,
     so release that unused width and keep the frame flush on both sides. */
  html[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>.right-column{
    scrollbar-gutter:auto!important;
  }
  /* Train's embedded standalone shell is an implementation wrapper, not a
     second mobile card. Let the tab strip and the active panel own their own
     borders while keeping the shared app width and spacing stable. */
  html[data-mobile-mode="training"] #trainerLayout.mobile-chess-shell #lichessSharedRoot>.lvgb-app[data-mode="standalone"]{
    box-sizing:border-box!important;
    gap:0!important;
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  html[data-mobile-mode="training"] #trainerLayout.mobile-chess-shell #lichessSharedRoot>.lvgb-app[data-mode="standalone"]>.lvgb-view{
    gap:0!important;
    padding-right:0!important;
  }
  html[data-mobile-mode="training"] #trainerLayout.mobile-chess-shell>.middle-column>#lichessPanel{
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play>.board-column>.play-side-column>#playModeInfo.mobile-tab-frame,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze>.middle-column>#explorePositionSourceControl.mobile-tab-frame{
    margin:0!important;
    padding:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.mobile-chess-shell #playModeInfo.mobile-tab-frame>.play-controls-row{
    margin:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-side-column .play-mode-info.mobile-tab-frame{
    margin:0!important;
    padding:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playModeInfo.mobile-tab-frame{
    margin:0!important;
    padding:0!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playModeInfo.settings-open{
    display:none!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playModeInfo.start-open{
    margin:0!important;
    padding:0!important;
    border:0!important;
    background:transparent!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play #playModeInfo.start-open #playStartChoices{
    margin:0!important;
    padding:0!important;
    border:0!important;
    background:transparent!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play{
    gap:.45rem!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play>.play-side-column{
    gap:0!important;
  }
  .mobile-tab-strip>.mobile-workspace-tab,
  .mobile-tab-strip>.mobile-workspace-tab.secondary{
    border-radius:7px!important;
    border-color:transparent!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  .mobile-tab-strip>.mobile-workspace-tab[aria-selected="true"],
  .mobile-tab-strip>.mobile-workspace-tab.active{
    border-color:var(--ai-color-accent,#4267ff)!important;
    background:var(--ai-color-accent,#4267ff)!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
  }
  /* Page-specific legacy selectors are more specific than the generic tab
     rule above. Reassert the Explain-style flat inactive tabs at the same
     component depth so every strip has one frame, not framed child cards. */
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls.mobile-tab-strip>button.mobile-workspace-tab,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs.mobile-tab-strip>button.mobile-workspace-tab{
    background:transparent!important;
    border:0!important;
    border-radius:0!important;
    box-shadow:none!important;
    color:var(--ai-color-text,#162033)!important;
  }
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls.mobile-tab-strip>button.mobile-workspace-tab[aria-selected="true"],
  html[data-mobile-mode="play"] #trainerLayout.workspace-play .play-game-controls.mobile-tab-strip>button.mobile-workspace-tab.active,
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs.mobile-tab-strip>button.mobile-workspace-tab[aria-selected="true"],
  html[data-mobile-mode="position"] #trainerLayout.workspace-analyze .explore-position-source-tabs.mobile-tab-strip>button.mobile-workspace-tab.active{
    background:var(--ai-color-accent,#4267ff)!important;
    border-color:var(--ai-color-accent,#4267ff)!important;
    border-radius:7px!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
  }
}

/* Analyze is one primary workspace with two exclusive mobile views. Keep the
   view switch in the document flow below the shared board shell, then expose
   only the selected numerical or human-analysis surface beneath it. */
@media (max-width:760px){
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze{
    grid-template-rows:auto max-content max-content!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>#mobileAnalyzeViewTabs{
    display:flex!important;
    grid-column:1!important;
    grid-row:2!important;
    align-items:stretch!important;
    gap:0!important;
    width:100%!important;
    max-width:100%!important;
    height:48px!important;
    min-height:48px!important;
    max-height:48px!important;
    margin:0!important;
    padding:2px!important;
    box-sizing:border-box!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>#mobileAnalyzeViewTabs>#mobileAnalyzeViewChoices{
    display:grid!important;
    flex:1 1 auto!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    align-items:stretch!important;
    gap:0!important;
    width:auto!important;
    min-width:0!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-sizing:border-box!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>#mobileAnalyzeViewTabs>#mobileAnalyzeViewChoices>button{
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    gap:.28rem!important;
    width:100%!important;
    min-width:0!important;
    height:100%!important;
    min-height:0!important;
    margin:0!important;
    padding:.2rem .3rem!important;
    border:0!important;
    border-radius:7px!important;
    background:transparent!important;
    color:var(--ai-color-text,#162033)!important;
    font-family:inherit!important;
    font-size:var(--mobile-control-font,.78rem)!important;
    font-weight:var(--mobile-control-weight,700)!important;
    line-height:var(--mobile-control-line,1.05)!important;
    font-synthesis:none!important;
    -webkit-font-smoothing:antialiased!important;
    text-rendering:optimizeLegibility!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>#mobileAnalyzeViewTabs>#mobileAnalyzeViewChoices>button.active,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>#mobileAnalyzeViewTabs>#mobileAnalyzeViewChoices>button[aria-selected="true"]{
    background:var(--ai-color-accent,#4267ff)!important;
    border-color:var(--ai-color-accent,#4267ff)!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze>#mobileAnalyzeViewTabs .mobile-workspace-tab-icon{
    width:1rem!important;
    height:1rem!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"][data-mobile-analysis-submode="engine"] #trainerLayout.workspace-analyze>.middle-column{
    grid-column:1!important;
    grid-row:3!important;
    display:block!important;
    width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"][data-mobile-analysis-submode="engine"] #trainerLayout.workspace-analyze>.right-column{
    display:none!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"][data-mobile-analysis-submode="explain"] #trainerLayout.workspace-analyze>.middle-column{
    display:none!important;
  }
  html.mobile-chess-shell-active[data-mobile-mode="explain"][data-mobile-analysis-submode="explain"] #trainerLayout.workspace-analyze>.right-column{
    grid-column:1!important;
    grid-row:3!important;
    display:block!important;
    width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
  }
}

/* Final high-specificity mobile contextual strip typography. Page-specific
   selectors must resolve to the same compact reference treatment. */
@media (max-width:760px){
  html.mobile-chess-shell-active[data-mobile-mode] #trainerLayout .mobile-tab-strip>button.mobile-workspace-tab,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel>.explain-view-selector>button,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel>.explain-view-selector #explainSettingsButton,
  html.mobile-chess-shell-active[data-mobile-mode="explain"] #trainerLayout.workspace-analyze #annotationPanel>.explain-view-selector #explainMobileCommentButton{
    gap:.28rem!important;
    padding:.2rem .3rem!important;
    font-family:inherit!important;
    font-size:var(--mobile-control-font,.78rem)!important;
    font-weight:var(--mobile-control-weight,700)!important;
    line-height:var(--mobile-control-line,1.05)!important;
  }
}

/* One connected page strip, with Help as a separate trailing action rather
   than an extra tab. This is shared by Play, Navigate, Analyze and Train. */
@media (max-width:1000px){
  html[data-mobile-mode] #trainerLayout .mobile-page-tab-strip{
    position:relative!important;
    box-sizing:border-box!important;
    display:flex!important;
    align-items:stretch!important;
    gap:0!important;
    width:100%!important;
    min-width:0!important;
    height:48px!important;
    min-height:48px!important;
    max-height:48px!important;
    margin:0!important;
    padding:2px!important;
    border:1px solid var(--ai-color-border,#cfd8e6)!important;
    border-radius:12px!important;
    background:var(--ai-color-surface-2,#f5f7fa)!important;
  }
  html[data-mobile-mode] #trainerLayout .mobile-page-tab-strip[hidden]{display:none!important}
  html[data-mobile-mode] #trainerLayout .mobile-page-tab-strip>[role="tablist"]{
    box-sizing:border-box!important;
    display:grid!important;
    flex:1 1 auto!important;
    grid-auto-flow:column!important;
    grid-auto-columns:minmax(0,1fr)!important;
    min-width:0!important;
    width:auto!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    gap:0!important;
    margin:0!important;
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
  }
  /* These two tablists also carry .mobile-tab-strip for legacy sizing, whose
     page-specific frame rules outrank the shared reset above. Keep their
     outer page strip as the only visible frame. */
  html[data-mobile-mode="play"] #trainerLayout #playControlsRow>.play-game-controls.mobile-tab-strip,
  html[data-mobile-mode="position"] #trainerLayout #explorePositionSourceControl #explorePositionSourceChoices,
  html[data-mobile-mode="training"] #trainerLayout .mobile-page-tab-strip>.lvgb-training-tabs.mobile-tab-strip{
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  html[data-mobile-mode] #trainerLayout .mobile-page-tab-strip>[role="tablist"]>.mobile-workspace-tab{
    box-sizing:border-box!important;
    height:100%!important;
    min-height:0!important;
    padding:.2rem .3rem!important;
    border:0!important;
    border-radius:7px!important;
    background:transparent!important;
    box-shadow:none!important;
    color:var(--ai-color-text,#162033)!important;
  }
  html[data-mobile-mode] #trainerLayout .mobile-page-tab-strip>[role="tablist"]>.mobile-workspace-tab[aria-selected="true"],
  html[data-mobile-mode] #trainerLayout .mobile-page-tab-strip>[role="tablist"]>.mobile-workspace-tab.active{
    border-color:var(--ai-color-accent,#4267ff)!important;
    background:var(--ai-color-accent,#4267ff)!important;
    color:var(--ai-color-accent-contrast,#fff)!important;
  }
  /* Train has four different-length labels. Size tabs to their contents and
     share spare width without changing the common strip height or typography. */
  html[data-mobile-mode="training"] #trainerLayout #lichessTrainingMobileLaunch{
    min-width:0!important;
    width:100%!important;
  }
  html[data-mobile-mode="training"] #trainerLayout .mobile-page-tab-strip>.lvgb-training-tabs.mobile-tab-strip{
    display:flex!important;
    flex:1 1 0!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    scrollbar-width:none;
  }
  html[data-mobile-mode="training"] #trainerLayout .lvgb-training-tabs.mobile-tab-strip>button.mobile-workspace-tab{
    flex:1 0 auto!important;
    width:auto!important;
    min-width:max-content!important;
    padding:.2rem 6px!important;
    gap:3px!important;
  }
  html[data-mobile-mode="training"] #trainerLayout .lvgb-training-tabs.mobile-tab-strip::-webkit-scrollbar{display:none;width:0;height:0}
  html[data-mobile-mode] #trainerLayout .mobile-strip-help{
    position:relative!important;
    box-sizing:border-box!important;
    display:inline-flex!important;
    flex:0 0 44px!important;
    align-items:center!important;
    justify-content:center!important;
    width:44px!important;
    min-width:44px!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    margin:0!important;
    padding:0!important;
    border:0!important;
    border-radius:7px!important;
    background:transparent!important;
    color:var(--ai-color-text-muted,#627086)!important;
    box-shadow:none!important;
    cursor:pointer!important;
  }
  html[data-mobile-mode] #trainerLayout .mobile-strip-help::before{
    position:absolute!important;
    top:50%!important;
    left:0!important;
    width:1px!important;
    height:26px!important;
    background:var(--ai-color-border,#cfd8e6)!important;
    content:""!important;
    transform:translateY(-50%)!important;
  }
  html[data-mobile-mode] #trainerLayout .mobile-strip-help svg{
    display:block!important;
    width:20px!important;
    height:20px!important;
    fill:none!important;
    stroke:currentColor!important;
    stroke-linecap:round!important;
    stroke-linejoin:round!important;
    stroke-width:1.8!important;
  }
  html[data-mobile-mode] #trainerLayout #explorePositionSourceControl>.mobile-page-tab-strip{
    grid-column:1/-1!important;
  }
  html[data-mobile-mode="position"] #trainerLayout #explorePositionSourceControl{
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  html[data-mobile-mode] #trainerLayout .lvgb-mobile-explorer-columns #lichessExplorerColumnsInfo{
    display:none!important;
  }
}
