/* Opt-in presentation only; no effect on PGN, training, editor or landscape.
   Board size is independent of MultiPV and of the length of its variations. */
html[data-responsive-workspace][data-mobile-analysis] {
    overflow: hidden !important;
    --mobile-analysis-board: min(calc(100vw - 40px), max(240px, calc((var(--mobile-analysis-height) - var(--mobile-analysis-header, 48px) - var(--mobile-analysis-paint, 0px) - 144px) * .6)));
}
html[data-responsive-workspace][data-mobile-analysis] body {
    min-height: 0 !important;
    height: auto !important;
    overflow: hidden !important;
}
html[data-responsive-workspace][data-mobile-analysis] body .chess-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto minmax(0, 1fr) !important;
    grid-template-areas: "analysis-header" "analysis-board" "analysis-controls" !important;
    width: 100% !important;
    height: var(--mobile-analysis-height) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    overflow: hidden !important;
}
html[data-responsive-workspace][data-mobile-analysis] body .chess-layout > .mobile-header {
    grid-area: analysis-header;
    position: relative !important;
    min-height: 48px !important;
    padding: 2px 8px !important;
}
html[data-responsive-workspace][data-mobile-analysis] body .chess-layout > .chess-container {
    grid-area: analysis-board;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 4px 16px 23px !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
}
html[data-responsive-workspace][data-mobile-analysis] body .chess-container > .play-surface,
html[data-responsive-workspace][data-mobile-analysis] body .chess-container #board.board {
    width: var(--mobile-analysis-board) !important;
    height: var(--mobile-analysis-board) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    aspect-ratio: 1;
}
html[data-responsive-workspace][data-mobile-analysis] body #paintTouchControls {
    order: -1;
    margin: 0 auto 8px !important;
    width: min(100%, 620px);
}
html[data-responsive-workspace][data-mobile-analysis] body .chess-layout > .controls-container {
    grid-area: analysis-controls;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 6px max(4px, env(safe-area-inset-bottom)) !important;
    gap: 3px !important;
    overflow: hidden !important;
}
html[data-responsive-workspace][data-mobile-analysis] body .controls-container > .navigation-section {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
}
html[data-responsive-workspace][data-mobile-analysis] body .navigation-buttons-redesigned {
    min-height: 44px !important;
    height: 44px !important;
    padding: 0 4px !important;
}
html[data-responsive-workspace][data-mobile-analysis] body #mobileWorkspace {
    position: relative !important;
    inset: auto !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 12px !important;
    grid-template-areas: "mobile-tabs" "mobile-busy" "mobile-body" !important;
    grid-template-rows: auto auto minmax(0, 1fr) !important;
}
/* The selected module supplies its title. No duplicate heading/expand sheet. */
html[data-responsive-workspace][data-mobile-analysis] body #mobileWorkspace > .mobile-workspace__header,
html[data-responsive-workspace][data-mobile-analysis] body #mobileWorkspaceBackdrop,
html[data-responsive-workspace][data-mobile-analysis] body #workbenchEngineSummary { display: none !important; }
html[data-responsive-workspace][data-mobile-analysis] body #mobileWorkspace > .mobile-workspace__tabs {
    padding: 2px 4px !important;
    min-height: 44px !important;
}
html[data-responsive-workspace][data-mobile-analysis] body #mobileWorkspace .mobile-workspace__tabs > button {
    min-height: 44px !important;
    padding-block: 4px !important;
}
html[data-responsive-workspace][data-mobile-analysis] body #mobileWorkspace > .mobile-workspace__body {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 2px 4px 4px !important;
    overflow: hidden !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #mobileWorkspace #stockfish-panel:not(.hidden) {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel > .stockfish-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    min-height: 48px !important;
    padding: 2px 5px !important;
    gap: 4px !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel .stockfish-title {
    min-width: 0 !important;
    font-size: clamp(10px, 2vw, 13px) !important;
    line-height: 1.4 !important;
    white-space: normal !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel .stockfish-controls {
    flex: 0 0 auto !important;
    width: auto !important;
    flex-wrap: nowrap !important;
    gap: 3px !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel .stockfish-controls::before { display: none !important; }
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel .stockfish-controls button {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 4px !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel > .stockfish-content {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    padding: 3px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
}
/* The web source offer remains reachable; it must not consume an analysis row. */
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel > .stockfish-source-footer {
    flex: 0 0 auto;
    padding: 0 6px !important;
    margin: 0 !important;
    font-size: 10px !important;
    line-height: 20px !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel > .stockfish-source-footer a {
    display: inline-block;
    min-height: 24px !important;
    padding: 2px 4px !important;
    line-height: 20px !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel .analysis-line.is-visible {
    grid-template-columns: 48px minmax(0, 1fr) 24px !important;
    min-height: 58px !important;
    padding: 4px !important;
    gap: 4px !important;
    flex: 0 0 auto !important;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel .line-moves {
    display: flex !important;
    flex-wrap: nowrap !important;
    min-width: 0 !important;
    gap: 3px !important;
    padding-bottom: 2px;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
}
html[data-responsive-workspace][data-mobile-analysis="engine"] body #stockfish-panel .engine-pv-move {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    min-width: 44px !important;
    min-height: 44px !important;
    touch-action: pan-x pan-y !important;
}
html[data-responsive-workspace][data-mobile-analysis="book"] body #mobileWorkspace #workbenchPgnPane,
html[data-responsive-workspace][data-mobile-analysis="book"] body #mobileWorkspace #workbenchBookPane { display: contents !important; }
html[data-responsive-workspace][data-mobile-analysis="book"] body #mobileWorkspace #opening-explorer-panel.visible {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
}
html[data-responsive-workspace][data-mobile-analysis="book"] body #opening-explorer-panel .explorer-header { flex: 0 0 auto; padding: 4px 8px !important; }
html[data-responsive-workspace][data-mobile-analysis="book"] body #opening-explorer-panel .explorer-table-container {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    touch-action: pan-y;
}
html[data-responsive-workspace][data-mobile-analysis] body #mobileWorkspace :is(#workbenchMotorEmpty, #workbenchBookEmpty):not([hidden]) {
    min-height: 0 !important;
    overflow-y: auto !important;
    padding: 10px !important;
    margin: 0 !important;
}
