/* Analysis layout repair: no overlapping board or engine at intermediate widths. */
.tool-page:has(.analysis-controls-panel)>.tool-card:first-of-type{box-sizing:border-box;min-width:0;align-items:start!important}
.tool-page .tool-card:first-of-type>.board-with-eval,
.tool-page .tool-card:first-of-type>.live-notation,
.tool-page .tool-card:first-of-type>.analysis-controls-panel,
.tool-page .tool-card:first-of-type>.review-side-stats{min-width:0!important;box-sizing:border-box!important}
.tool-page .tool-card:first-of-type>.board-with-eval{width:100%!important;max-width:100%!important;overflow:hidden}
.tool-page .tool-card:first-of-type>.board-with-eval .chess-board{width:100%!important;max-width:100%!important;min-width:0!important;box-sizing:border-box}
.tool-page .tool-card:first-of-type>.live-notation{overflow-x:hidden!important}
.tool-page .tool-card:first-of-type>.live-notation .analysis-engine-header{display:flex!important;flex-wrap:wrap!important;gap:10px 14px!important;align-items:center!important;min-width:0}
.tool-page .tool-card:first-of-type>.live-notation .engine-line{min-width:0!important;grid-template-columns:24px minmax(0,1fr) 50px 54px!important;gap:6px!important}
.tool-page .tool-card:first-of-type>.live-notation .engine-line>*{min-width:0;overflow-wrap:anywhere}
.tool-page .tool-card:first-of-type>.live-notation .engine-line-moves{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tool-page .tool-card:first-of-type>.review-side-stats{align-self:start!important;margin-top:0!important}
@media(min-width:1250px){
 .tool-page:has(.analysis-controls-panel)>.tool-card:first-of-type{
  display:grid!important;grid-template-columns:minmax(170px,195px) minmax(0,660px) minmax(300px,1fr)!important;
  gap:12px 18px!important
 }
 .tool-page .tool-card:first-of-type>.analysis-controls-panel{grid-column:1!important;grid-row:2/span 2!important}
 .tool-page .tool-card:first-of-type>.review-side-stats{grid-column:1!important;grid-row:4!important}
 .tool-page .tool-card:first-of-type>.board-top-switch{grid-column:2!important;grid-row:2!important}
 .tool-page .tool-card:first-of-type>.board-with-eval{grid-column:2!important;grid-row:3/span 3!important}
 .tool-page .tool-card:first-of-type>.live-notation{grid-column:3!important;grid-row:2/span 5!important;max-height:780px!important}
}
@media(max-width:1249px){
 .tool-page:has(.analysis-controls-panel)>.tool-card:first-of-type{display:grid!important;grid-template-columns:minmax(0,1fr)!important}
 .tool-page .tool-card:first-of-type>.board-top-switch{grid-column:1!important;grid-row:2!important}
 .tool-page .tool-card:first-of-type>.board-with-eval{grid-column:1!important;grid-row:3!important;max-width:720px!important}
 .tool-page .tool-card:first-of-type>.analysis-controls-panel{grid-column:1!important;grid-row:4!important}
 .tool-page .tool-card:first-of-type>.review-side-stats{grid-column:1!important;grid-row:5!important}
 .tool-page .tool-card:first-of-type>.live-notation{grid-column:1!important;grid-row:6!important;max-height:none!important}
}
@media(min-width:760px) and (max-width:1249px){
 .tool-page:has(.analysis-controls-panel)>.tool-card:first-of-type{grid-template-columns:minmax(0,1fr) minmax(280px,.8fr)!important}
 .tool-page .tool-card:first-of-type>.board-top-switch{grid-column:1!important;grid-row:2!important}
 .tool-page .tool-card:first-of-type>.board-with-eval{grid-column:1!important;grid-row:3/span 3!important}
 .tool-page .tool-card:first-of-type>.analysis-controls-panel{grid-column:2!important;grid-row:2!important}
 .tool-page .tool-card:first-of-type>.review-side-stats{grid-column:2!important;grid-row:3!important}
 .tool-page .tool-card:first-of-type>.live-notation{grid-column:2!important;grid-row:4/span 3!important}
}

/* Final layout: control rail contains statistics; board and engine never share cells. */
.tool-page .tool-card:first-of-type>.analysis-controls-panel>.review-side-stats{
 display:block!important;position:static!important;grid-column:auto!important;grid-row:auto!important;
 margin:14px 0 0!important;padding:13px 10px!important;min-height:0!important;
 width:100%!important;max-width:100%!important;overflow-wrap:anywhere!important;
}
.tool-page .tool-card:first-of-type>.analysis-controls-panel>.review-side-stats .review-graph{max-width:100%;overflow:hidden}
.tool-page .tool-card:first-of-type>.board-top-switch{min-width:0!important;max-width:100%!important;justify-content:flex-start!important;flex-wrap:wrap!important;overflow:visible!important}
.tool-page .tool-card:first-of-type>.board-top-switch .switch-label{margin:0!important}
.tool-page .tool-card:first-of-type>.live-notation .analysis-engine-header>*{max-width:100%;min-width:0}
.tool-page .tool-card:first-of-type>.board-with-eval{justify-self:stretch!important;align-self:start!important}
@media(min-width:1250px){
 .tool-page:has(.analysis-controls-panel)>.tool-card:first-of-type{
  grid-template-columns:minmax(170px,195px) minmax(0,660px) minmax(310px,1fr)!important;
  grid-template-rows:auto auto minmax(0,auto)!important;align-items:start!important;
 }
 .tool-page .tool-card:first-of-type>.analysis-controls-panel{grid-column:1!important;grid-row:2/span 4!important;align-self:start!important}
 .tool-page .tool-card:first-of-type>.board-top-switch{grid-column:2!important;grid-row:2!important}
 .tool-page .tool-card:first-of-type>.board-with-eval{grid-column:2!important;grid-row:3/span 3!important}
 .tool-page .tool-card:first-of-type>.live-notation{grid-column:3!important;grid-row:2/span 4!important}
}
@media(min-width:760px) and (max-width:1249px){
 .tool-page .tool-card:first-of-type>.analysis-controls-panel{grid-column:2!important;grid-row:2/span 2!important}
 .tool-page .tool-card:first-of-type>.board-top-switch{grid-column:1!important;grid-row:2!important}
 .tool-page .tool-card:first-of-type>.board-with-eval{grid-column:1!important;grid-row:3/span 4!important}
 .tool-page .tool-card:first-of-type>.live-notation{grid-column:2!important;grid-row:4/span 3!important}
}
@media(max-width:759px){
 .tool-page .tool-card:first-of-type>.board-top-switch{grid-column:1!important;grid-row:2!important}
 .tool-page .tool-card:first-of-type>.board-with-eval{grid-column:1!important;grid-row:3!important}
 .tool-page .tool-card:first-of-type>.analysis-controls-panel{grid-column:1!important;grid-row:4!important}
 .tool-page .tool-card:first-of-type>.live-notation{grid-column:1!important;grid-row:5!important}
}

/* DOM-owned layout: the three columns are actual sibling containers. */
.tool-page:has(.analysis-three-column)>.tool-card:first-of-type{
 display:block!important;position:relative!important;overflow:visible!important;
}
.tool-page .tool-card:first-of-type>.analysis-three-column{
 display:grid!important;grid-template-columns:175px minmax(0,660px) minmax(280px,1fr)!important;
 gap:16px!important;align-items:start!important;width:100%!important;min-width:0!important;
}
.analysis-three-column>.analysis-controls-panel,
.analysis-three-column>.analysis-board-column,
.analysis-three-column>.analysis-engine-column{
 grid-column:auto!important;grid-row:auto!important;min-width:0!important;
 position:relative!important;transform:none!important;align-self:start!important;
}
.analysis-three-column>.analysis-controls-panel{display:flex!important;flex-direction:column!important;gap:0!important}
.analysis-three-column .analysis-board-column{display:flex!important;flex-direction:column!important;gap:10px!important}
.analysis-three-column .analysis-board-column>.board-top-switch{
 display:flex!important;position:static!important;min-height:32px!important;flex-wrap:wrap!important;
 width:100%!important;margin:0!important;padding:0!important;
}
.analysis-three-column .analysis-board-column>.board-with-eval{
 display:grid!important;position:relative!important;width:100%!important;max-width:100%!important;
 min-width:0!important;margin:0!important;grid-column:auto!important;grid-row:auto!important;
}
.analysis-three-column .analysis-engine-column>.live-notation{
 position:relative!important;grid-column:auto!important;grid-row:auto!important;
 width:100%!important;max-width:100%!important;min-width:0!important;margin:0!important;
 box-sizing:border-box!important;overflow:hidden!important;
}
.analysis-three-column .analysis-engine-header{
 display:flex!important;position:static!important;flex-wrap:wrap!important;
 align-items:center!important;gap:10px!important;width:100%!important;
}
.analysis-three-column .analysis-controls-panel>.review-side-stats{
 display:block!important;position:static!important;margin:12px 0 0!important;
 width:100%!important;min-height:0!important;box-sizing:border-box!important;
}
.analysis-three-column .analysis-board-column .chess-board{
 width:100%!important;max-width:100%!important;min-width:0!important;aspect-ratio:1!important;
}
@media(max-width:1200px){
 .tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:minmax(155px,190px) minmax(0,1fr)!important;
 }
 .analysis-three-column>.analysis-engine-column{grid-column:2!important;grid-row:2!important}
 .analysis-three-column>.analysis-controls-panel{grid-column:1!important;grid-row:1/span 2!important}
 .analysis-three-column>.analysis-board-column{grid-column:2!important;grid-row:1!important}
}
@media(max-width:700px){
 .tool-page .tool-card:first-of-type>.analysis-three-column{grid-template-columns:minmax(0,1fr)!important}
 .analysis-three-column>.analysis-board-column{grid-column:1!important;grid-row:1!important}
 .analysis-three-column>.analysis-controls-panel{grid-column:1!important;grid-row:2!important}
 .analysis-three-column>.analysis-engine-column{grid-column:1!important;grid-row:3!important}
}

/* 2026-11-04: balanced three-column desktop layout */
@media(min-width:1201px){
 .tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:240px minmax(0,1fr) 300px!important;
  column-gap:20px!important;align-items:start!important;
 }
 .analysis-three-column>.analysis-board-column{
  width:100%!important;max-width:700px!important;justify-self:center!important;
  margin-inline:auto!important;
 }
 .analysis-three-column>.analysis-controls-panel{width:100%!important;max-width:none!important}
 .analysis-three-column>.analysis-engine-column{width:100%!important;min-width:0!important}
}
.analysis-three-column .analysis-board-column>.board-top-switch{display:none!important}
.analysis-three-column .analysis-engine-column .analysis-engine-header{
 display:flex!important;justify-content:flex-start!important;gap:12px 18px!important;
 align-items:center!important;flex-wrap:wrap!important;padding:4px 0 12px!important;
}
.analysis-three-column .analysis-engine-column .analysis-engine-header label{
 flex:0 0 auto!important;white-space:nowrap!important;
}
.analysis-three-column .analysis-controls-panel>.review-side-stats{
 padding:14px!important;margin-top:14px!important;
}
.analysis-three-column .analysis-controls-panel>.review-side-stats p{
 overflow-wrap:normal!important;word-break:normal!important;
}
@media(min-width:701px) and (max-width:1200px){
 .tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:220px minmax(0,1fr)!important;gap:16px!important;
 }
 .analysis-three-column>.analysis-board-column{max-width:680px!important;justify-self:center!important}
}

/* Align analysis toggles and expand the right panel toward the board. */
@media(min-width:1201px){
 .tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:240px minmax(0,1fr) 340px!important;
  column-gap:14px!important;
 }
 .analysis-three-column>.analysis-engine-column{justify-self:stretch!important}
}
.analysis-three-column .analysis-engine-column .analysis-engine-header{
 display:flex!important;flex-direction:column!important;align-items:stretch!important;
 gap:9px!important;padding:4px 0 13px!important;
}
.analysis-three-column .analysis-engine-column .analysis-engine-header>label{
 display:grid!important;grid-template-columns:42px minmax(0,1fr)!important;
 align-items:center!important;justify-content:start!important;
 column-gap:12px!important;width:100%!important;min-height:28px!important;
 margin:0!important;padding:0!important;box-sizing:border-box!important;
}
.analysis-three-column .analysis-engine-column .analysis-engine-header>label input[type="checkbox"]{
 grid-column:1!important;grid-row:1!important;margin:0!important;
}
.analysis-three-column .analysis-engine-column .analysis-engine-header>label span{
 grid-column:2!important;grid-row:1!important;white-space:nowrap!important;
}
.analysis-three-column .analysis-engine-column .analysis-engine-header>label:has(input[role="switch"]) input[role="switch"]{
 width:42px!important;height:24px!important;min-width:42px!important;
}

/* Wider right-hand rail; maintain its right edge while extending left. */
@media(min-width:1300px){
 .tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:240px minmax(0,1fr) 405px!important;
  column-gap:12px!important;
 }
 .analysis-three-column>.analysis-board-column{
  max-width:min(700px,100%)!important;
  justify-self:center!important;
 }
}
@media(min-width:1201px) and (max-width:1299px){
 .tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:225px minmax(0,1fr) 355px!important;column-gap:12px!important;
 }
}
.analysis-three-column .analysis-engine-header>label.analysis-uniform-switch{
 display:flex!important;flex-flow:row nowrap!important;align-items:center!important;
 justify-content:flex-start!important;gap:14px!important;
 width:100%!important;height:32px!important;min-height:32px!important;
 padding:0!important;margin:0!important;
}
.analysis-three-column .analysis-engine-header>label.analysis-uniform-switch>input[type="checkbox"]{
 appearance:none!important;-webkit-appearance:none!important;
 display:block!important;position:relative!important;
 flex:0 0 46px!important;width:46px!important;min-width:46px!important;max-width:46px!important;
 height:25px!important;min-height:25px!important;max-height:25px!important;
 margin:0!important;padding:0!important;border-radius:99px!important;
 border:1px solid #47758c!important;background:#244359!important;
 box-sizing:border-box!important;cursor:pointer!important;transform:none!important;
}
.analysis-three-column .analysis-engine-header>label.analysis-uniform-switch>input[type="checkbox"]::before{
 content:""!important;position:absolute!important;top:3px!important;left:3px!important;
 width:17px!important;height:17px!important;border-radius:50%!important;
 background:#a9c1d0!important;transform:none!important;transition:left .15s ease!important;
}
.analysis-three-column .analysis-engine-header>label.analysis-uniform-switch>input[type="checkbox"]:checked{
 background:#087fa7!important;border-color:#36b6df!important;
}
.analysis-three-column .analysis-engine-header>label.analysis-uniform-switch>input[type="checkbox"]:checked::before{
 left:24px!important;background:#b8f2ff!important;
}
.analysis-three-column .analysis-engine-header>label.analysis-uniform-switch>.analysis-switch-caption{
 display:block!important;position:static!important;flex:1 1 auto!important;
 margin:0!important;padding:0!important;white-space:nowrap!important;
 font-size:12px!important;line-height:20px!important;
}

/* Analysis wide desktop: allocate the real board + evaluation bar before the sidebars.
   Avoid any fixed sidebar width forcing content over the board. */
@media(min-width:1450px){
 main.tool-page:has(.analysis-three-column){
  width:calc(100% - 48px)!important;max-width:1900px!important;
  margin-left:auto!important;margin-right:auto!important;
 }
 main.tool-page .tool-card:first-of-type>.analysis-three-column{
  display:grid!important;
  grid-template-columns:minmax(245px,1fr) minmax(730px,760px) minmax(380px,1.65fr)!important;
  column-gap:16px!important;align-items:start!important;
  width:100%!important;max-width:100%!important;box-sizing:border-box!important;
 }
 .analysis-three-column>.analysis-controls-panel{
  width:100%!important;max-width:none!important;justify-self:stretch!important;
 }
 .analysis-three-column>.analysis-board-column{
  width:100%!important;min-width:0!important;max-width:760px!important;
  justify-self:center!important;overflow:visible!important;
 }
 .analysis-three-column>.analysis-engine-column{
  width:100%!important;min-width:0!important;max-width:none!important;
  justify-self:stretch!important;overflow:hidden!important;
 }
}
/* Between laptop and wide desktop sizes, move engine beneath the board instead
   of shrinking the board's square geometry or overlapping it. */
@media(min-width:701px) and (max-width:1449px){
 main.tool-page:has(.analysis-three-column){
  width:calc(100% - 32px)!important;max-width:none!important;
 }
 main.tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:minmax(215px,260px) minmax(0,1fr)!important;
  column-gap:16px!important;
 }
 .analysis-three-column>.analysis-controls-panel{grid-column:1!important;grid-row:1/span 2!important}
 .analysis-three-column>.analysis-board-column{
  grid-column:2!important;grid-row:1!important;max-width:760px!important;
  min-width:0!important;justify-self:center!important;
 }
 .analysis-three-column>.analysis-engine-column{
  grid-column:2!important;grid-row:2!important;min-width:0!important;
  max-width:760px!important;justify-self:center!important;width:100%!important;
 }
}
@media(max-width:700px){
 main.tool-page:has(.analysis-three-column){width:calc(100% - 20px)!important}
 .analysis-three-column>.analysis-board-column,
 .analysis-three-column>.analysis-controls-panel,
 .analysis-three-column>.analysis-engine-column{min-width:0!important;max-width:100%!important}
}
.analysis-three-column .analysis-engine-column>.live-notation{
 width:100%!important;max-width:100%!important;box-sizing:border-box!important;
}
.analysis-three-column .analysis-engine-column .engine-lines-panel{
 width:100%!important;max-width:100%!important;min-width:0!important;
 overflow-x:auto!important;box-sizing:border-box!important;
}
.analysis-three-column .analysis-engine-column .engine-line{
 min-width:0!important;max-width:100%!important;
}
.analysis-three-column .analysis-engine-column .engine-line-moves{
 min-width:0!important;overflow:hidden!important;text-overflow:ellipsis!important;
}

/* 2026-11-04: reserve the board's actual rendered width before positioning the engine.
   Do not let the right card float over the last chessboard files. */
@media(min-width:1550px){
 main.tool-page:has(.analysis-three-column){width:calc(100% - 40px)!important;max-width:2000px!important}
 main.tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:minmax(270px,1fr) minmax(0,740px) minmax(360px,1.25fr)!important;
  gap:16px!important;
 }
 .analysis-three-column>.analysis-controls-panel{min-width:0!important;max-width:100%!important}
 .analysis-three-column>.analysis-board-column{
  min-width:0!important;max-width:740px!important;width:100%!important;
  justify-self:center!important;
 }
 .analysis-three-column>.analysis-engine-column{
  min-width:0!important;width:100%!important;max-width:100%!important;
  justify-self:stretch!important;align-self:start!important;
 }
 .analysis-three-column>.analysis-engine-column>.live-notation{
  width:100%!important;max-width:100%!important;min-width:0!important;
 }
}
/* Keep three columns only if they can actually fit; otherwise stack the engine. */
@media(min-width:701px) and (max-width:1549px){
 main.tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:minmax(215px,260px) minmax(0,1fr)!important;
 }
 .analysis-three-column>.analysis-engine-column{
  grid-column:2!important;grid-row:2!important;
 }
}

/* Hard containment: the eval meter and chessboard must share the CENTER grid cell,
   never expand its intrinsic width or paint into the right-hand engine cell. */
.analysis-three-column>.analysis-board-column,
.analysis-three-column>.analysis-engine-column{box-sizing:border-box!important;min-width:0!important}
.analysis-three-column>.analysis-board-column>.board-with-eval{
 display:grid!important;
 grid-template-columns:30px minmax(0,1fr)!important;
 grid-template-rows:auto!important;
 gap:8px!important;
 width:100%!important;max-width:100%!important;min-width:0!important;
 overflow:hidden!important;box-sizing:border-box!important;
}
.analysis-three-column>.analysis-board-column>.board-with-eval>.board-eval-wrap{
 grid-column:1!important;grid-row:1!important;
 width:30px!important;min-width:0!important;max-width:30px!important;
 height:100%!important;box-sizing:border-box!important;
}
.analysis-three-column>.analysis-board-column>.board-with-eval>#board{
 grid-column:2!important;grid-row:1!important;
 display:grid!important;width:100%!important;min-width:0!important;max-width:100%!important;
 height:auto!important;aspect-ratio:1/1!important;box-sizing:border-box!important;
 overflow:hidden!important;
}
@media(min-width:1550px){
 main.tool-page .tool-card:first-of-type>.analysis-three-column{
  grid-template-columns:minmax(270px,1fr) minmax(0,740px) minmax(360px,1.25fr)!important;
  gap:20px!important;
 }
 .analysis-three-column>.analysis-board-column{max-width:740px!important}
 .analysis-three-column>.analysis-engine-column{margin-left:0!important;position:relative!important;z-index:1!important}
}

/* Preserve a genuinely square 8x8 board regardless of evaluation bar height. */
.analysis-three-column .analysis-board-column>.board-with-eval{
 display:grid!important;
 grid-template-columns:30px minmax(0,1fr)!important;
 grid-template-rows:minmax(0,auto)!important;
 align-items:start!important;
}
.analysis-three-column .analysis-board-column>.board-with-eval>#board{
 display:grid!important;
 grid-template-columns:repeat(8,minmax(0,1fr))!important;
 grid-template-rows:repeat(8,minmax(0,1fr))!important;
 width:100%!important;height:auto!important;
 aspect-ratio:1 / 1!important;
 min-height:0!important;max-height:none!important;
 align-self:start!important;justify-self:stretch!important;
}
.analysis-three-column .analysis-board-column>.board-with-eval>#board>.light,
.analysis-three-column .analysis-board-column>.board-with-eval>#board>.dark{
 width:100%!important;height:100%!important;
 min-width:0!important;min-height:0!important;
 aspect-ratio:1 / 1!important;box-sizing:border-box!important;
}
.analysis-three-column .analysis-board-column>.board-with-eval>.board-eval-wrap{
 align-self:stretch!important;max-height:100%!important;
}
