.board-message{min-height:1.1rem;color:#8b2018;font:500 .75rem Manrope,sans-serif;margin:8px 0 0}
.editor-save-status{display:flex;align-items:center;gap:8px;min-height:1.7rem;font:700 .72rem Manrope,sans-serif;color:var(--muted)}
.editor-save-status [data-state="saved"]{color:var(--green)}
.editor-save-status [data-state="unsaved"],.editor-save-status [data-state="saving"]{color:#8a5a00}
.editor-save-status [data-state="offline"],.editor-save-status [data-state="conflict"],.editor-save-status [data-state="error"]{color:#8b2018}
.editor-save-status .ghost{padding:3px 7px;font-size:.68rem}
.tree-actions,.material-toolbar,.setup-toolbar,.engine-toolbar,.pattern-tools,.nag-row,.layer-row{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0}
.annotate{display:grid;gap:8px;margin-top:12px}
.annotate textarea{width:100%;font:500 .82rem 'DM Mono',monospace}
.variation{display:block;margin-left:1.1em;color:#5a6774;border-left:2px solid var(--line);padding-left:.45em}
.square.selected{box-shadow:inset 0 0 0 3px #176899}
.square.legal{position:relative}
.square.legal::after{content:'';position:absolute;width:28%;height:28%;border-radius:50%;background:#1e5c4d99}
.square.drag-target{box-shadow:inset 0 0 0 3px #d7f16c,inset 0 0 18px #d7f16c99}
.square.drag-target::after{content:'';position:absolute;inset:9%;border:2px solid #efffb0;border-radius:3px;box-shadow:0 0 12px #d7f16c;pointer-events:none}
.square.check{box-shadow:inset 0 0 0 3px #b42318}
.square.pattern-must{box-shadow:inset 0 0 0 3px #176899}
.square.pattern-empty{box-shadow:inset 0 0 0 3px #5a6774}
.square.pattern-exclude{box-shadow:inset 0 0 0 3px #b42318}
.square.pattern-any{box-shadow:inset 0 0 0 3px #9a6700}
.layer.active{background:#e5ecdc;color:var(--green)}
.palette{display:flex;flex-wrap:wrap;gap:4px;margin:8px 0}
.palette button{width:36px;height:36px;padding:2px;display:grid;place-items:center}
.palette button.active{outline:2px solid var(--green)}
.palette img{width:28px;height:28px}
.mini-board{width:min(280px,100%);aspect-ratio:1;display:grid;grid-template-columns:repeat(8,minmax(0,1fr));grid-template-rows:repeat(8,minmax(0,1fr))}
.material-table{width:100%;border-collapse:collapse;margin:10px 0;font:500 .78rem 'DM Mono',monospace}
.material-table th,.material-table td{border-bottom:1px solid var(--line);padding:6px 4px;text-align:left}
.material-table input{width:4.5rem}
.setup-errors{color:#8b2018;font-size:.8rem}
.engine-compare-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.activity-feed{list-style:none;margin:12px 0;padding:0;display:flex;flex-direction:column;gap:8px}
.activity-feed li{display:grid;grid-template-columns:auto 1fr auto;gap:8px;align-items:baseline;font:500 .82rem 'DM Mono',monospace}
.activity-feed .activity-type{color:#7dd3c7}
.job-list{list-style:none;margin:12px 0;padding:0;display:flex;flex-direction:column;gap:8px}
.job-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 12px;align-items:start;padding:10px;border:1px solid var(--line);border-radius:var(--radius-sm);background:#fff}
.job-row-main{display:grid;gap:3px;min-width:0}.job-row-main strong{overflow-wrap:anywhere}.job-row-main small,.job-row-status{color:var(--muted);font:500 .75rem 'DM Mono',monospace}.job-row details{grid-column:1/-1}.job-row pre{white-space:pre-wrap;overflow-wrap:anywhere;max-height:180px;overflow:auto}.job-row-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.engine-lines{font:500 .8rem 'DM Mono',monospace;padding-left:1.2rem}
.engine-lines button{font:inherit}
.castle-set{border:1px solid var(--line);padding:8px;margin:8px 0}
.nag-comment{color:var(--muted);font-style:italic;margin:0 .35em}
.promo-menu{display:flex;gap:8px;flex-wrap:wrap}
@media(max-width:700px){.mini-board{width:min(100%,280px)}.panel-tabs{overflow:auto}}
:root{--board-min:max(34vmin,280px);--notation-min:max(18vw,220px);--engine-min:max(12vw,168px)}
main{max-width:min(1680px,100%)}
.results-wrap{min-height:0}
.first-use-panel{display:grid;grid-template-columns:minmax(0,1fr);margin:0 0 8px;padding:14px 16px;border:1px solid var(--line);border-radius:var(--radius-md);background:#f7f8f4;color:var(--ink)}
.first-use-state[hidden]{display:none!important}
.first-use-state h2{margin:0 0 5px;font-size:1.05rem;line-height:1.2}
.first-use-copy{max-width:760px;margin:0;color:var(--muted);line-height:1.45}
.first-use-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.first-use-actions button{min-height:36px}
.workbench{grid-template-columns:220px minmax(0,.42fr) minmax(0,2.2fr);align-items:stretch;height:max(70vh,calc(100vh - 96px));max-height:calc(100vh - 96px);min-height:70vh}
.workbench.is-library-collapsed{grid-template-columns:44px minmax(0,.42fr) minmax(0,2.2fr)}
.game-detail{min-width:0;min-height:0;overflow:hidden;height:100%;padding:8px 12px 10px;display:flex;flex-direction:column}
.game-detail h2{font-size:1.2rem;margin:0}
.game-meta{margin:0 0 6px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.library{margin:0;border-right:1px solid var(--line);background:#f7f8f4;min-width:0;height:100%;max-height:none;overflow:auto}
.library-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 8px 0}
.library .eyebrow{margin:4px 4px 8px}
#lib-toggle{padding:4px 8px;font-size:.72rem}
.library.is-collapsed{overflow:hidden}
.library.is-collapsed .library-head{flex-direction:column;padding:10px 4px;gap:12px}
.library.is-collapsed .eyebrow{writing-mode:vertical-rl;transform:rotate(180deg);margin:0}
.library.is-collapsed .library-explorer{display:none}
.library.is-collapsed #lib-toggle{padding:8px 6px}
.library-explorer{display:flex;flex-direction:column;border:0;border-radius:0;min-height:0;background:transparent;overflow:visible}
.library-tree{display:flex;flex-direction:column;align-items:stretch;gap:2px;margin:0;border-right:0;padding:4px 8px 12px;background:transparent;overflow:visible;max-height:none}
.tree-group{font:700 .68rem 'DM Mono',monospace;letter-spacing:.08em;text-transform:uppercase;color:var(--green);margin:10px 8px 4px}
.tree-item{display:flex;flex:none;width:100%;gap:8px;align-items:flex-start;text-align:left;border:0;background:transparent;padding:8px;border-radius:8px;cursor:pointer;color:inherit}
.tree-item:hover,.tree-row:hover .tree-item{background:#e5ecdc}
.tree-item.active{background:#e5ecdc;outline:2px solid var(--green)}
.tree-copy{display:flex;flex-direction:column;gap:2px;min-width:0}
.tree-copy strong{font:700 .88rem Manrope,sans-serif}
.tree-copy span,.tree-item #lib-masters-meta,.tree-item #lib-private-meta{color:var(--muted);font-size:.72rem;line-height:1.3;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tree-icon{width:22px;text-align:center;flex:none}
.tree-row{display:flex;align-items:flex-start;gap:2px;padding-left:calc(var(--depth,0)*14px);cursor:pointer}
.tree-twist{border:0;background:transparent;cursor:pointer;width:18px;padding:8px 0;color:var(--muted)}
.tree-twist-spacer{width:18px;flex:none}
.library-pane{padding:8px 10px 14px;border-top:1px solid var(--line)}
.library-toolbar{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap}
#library-pane-title{margin:0;font:700 1rem Manrope,sans-serif}
.library-actions{display:flex;gap:6px;flex-wrap:wrap}
.library-actions .ghost{padding:7px 10px;font-size:.75rem}
.library-hint{margin:0 0 10px;color:var(--muted);font-size:.82rem}
.library-tile-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:10px}
.library-tiles{margin-top:14px}
.library-tile{display:flex;flex-direction:column;align-items:flex-start;gap:6px;padding:14px 12px;border:1px solid var(--line);border-radius:10px;background:#fbfcf8;cursor:pointer;text-align:left;min-height:92px}
.library-tile:hover{border-color:var(--green);background:#e5ecdc}
.tile-icon{font-size:1.4rem}
.library-tile strong{font:700 .85rem Manrope,sans-serif}
.library-tile span{color:var(--muted);font-size:.72rem}
.tree-item[disabled],#copy-session:disabled{opacity:.55;cursor:not-allowed}
@media(max-width:900px){.workbench{grid-template-columns:1fr;height:auto;max-height:none}.library{border-right:0;border-bottom:1px solid var(--line);max-height:240px;height:auto}.game-list{max-height:40vh;height:auto}}
@media(max-width:560px){.first-use-panel{padding:12px}.first-use-actions{display:grid;grid-template-columns:minmax(0,1fr)}.first-use-actions button{width:100%}}
#import-dialog menu,#folder-dialog menu,#conflict-dialog menu,#delete-folder-dialog menu{display:flex;gap:8px;flex-wrap:wrap;padding:0;margin:12px 0 0}
#conflict-dialog{width:min(980px,calc(100vw - 32px));max-height:calc(100vh - 32px);overflow:auto;border:1px solid var(--line);border-radius:14px;padding:18px;background:#fff;color:var(--ink)}
#conflict-dialog::backdrop{background:rgba(11,32,27,.58);backdrop-filter:blur(2px)}
.conflict-form{display:grid;gap:10px}.conflict-form :is(h3,h4,p){margin:0}.conflict-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.conflict-grid section{display:grid;gap:7px;min-width:0}.conflict-form textarea{box-sizing:border-box;width:100%;min-height:150px;resize:vertical;padding:9px;border:1px solid var(--line);border-radius:7px;background:#f7f8f4;color:var(--ink);font:500 .75rem 'DM Mono',monospace}.conflict-form textarea[readonly]{background:#eef2ec}.conflict-form menu{justify-content:flex-end}.conflict-form .board-message{min-height:1.1rem}
@media(max-width:700px){.conflict-grid{grid-template-columns:minmax(0,1fr)}#conflict-dialog{inset:0;width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0}}
.game-list{min-width:0;min-height:0;height:100%;max-height:none;overflow-x:hidden;overflow-y:auto}
.game{display:block;width:100%;max-width:100%;min-width:0;overflow:hidden;text-align:left}
.game-row{display:grid;grid-template-columns:34px minmax(0,1fr);align-items:stretch;border-bottom:1px solid var(--line);background:#fff}
.game-row .game{border:0;border-radius:0;border-bottom:0}
.game-row.is-export-selected{background:#edf5e8;outline:2px solid color-mix(in srgb,var(--green) 45%,transparent);outline-offset:-2px}
.game-select{display:flex;align-items:flex-start;justify-content:center;padding:15px 4px 8px;cursor:pointer}
.game-select input{width:18px;height:18px;margin:0;accent-color:var(--green);cursor:pointer}
.game-select:focus-within{outline:2px solid var(--green);outline-offset:-2px}
.selection-status{margin:0 0 6px;color:var(--muted);font-size:.78rem}
.game-title{display:flex;gap:8px;align-items:baseline;min-width:0}
.game-title span:first-child{min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.game-title span:last-child{flex:none;white-space:nowrap}
.game-sub,.game-tag{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.report-block{font:500 .82rem Manrope,sans-serif;white-space:pre-wrap;background:#f6f7f2;border:1px solid var(--line);padding:12px;border-radius:8px;max-height:360px;overflow:auto}
.board-stage{flex:1 1 auto;min-width:0;min-height:0;overflow:hidden;container-type:size;display:grid;grid-template-columns:22px minmax(0,min(58%,100cqh)) minmax(0,1fr) minmax(0,.62fr);gap:8px;align-items:start}
.board-stage.is-notation-collapsed{grid-template-columns:22px auto 36px minmax(var(--engine-min),1fr)}
.board-stage.is-engine-collapsed{grid-template-columns:22px auto minmax(var(--notation-min),1fr) 36px}
.board-stage.is-notation-collapsed.is-engine-collapsed{grid-template-columns:22px minmax(0,min(58%,100cqh)) 36px 36px}
.board-shell{min-width:0;min-height:0;height:auto;width:min(100%,100cqh);aspect-ratio:1 / 1;align-self:start;justify-self:start;overflow:hidden}
.board-stage .board{width:100%;height:auto;max-width:none;max-height:none;aspect-ratio:1 / 1;grid-auto-rows:minmax(0,1fr)}
.board-grid-row{display:contents}

/* A size-contained grid has no intrinsic block size. On the stacked mobile
   layout that collapsed the entire board stage to zero height. Keep inline
   containment for responsive queries while allowing rows to size the stage. */
@media(max-width:900px){
  .board-stage,
  .board-stage.is-notation-collapsed,
  .board-stage.is-engine-collapsed,
  .board-stage.is-notation-collapsed.is-engine-collapsed{container-type:inline-size}
}
@media(max-width:700px){
  /* Firefox's Manrope metrics can make the compact headline a few pixels wider
     than the content column. Restore the authored line break on phone widths. */
  .intro h1{white-space:normal;overflow-wrap:anywhere}
  .intro h1 br{display:block}
}
.position-info{flex:none;max-width:none;margin-top:6px}
.position-status{display:flex;align-items:baseline;gap:6px 10px;min-width:0}
.position-status .eyebrow,.position-status strong{margin:0;min-width:0}
#move-label{overflow-wrap:anywhere}
.position-actions{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;margin-top:4px}
.position-actions .replay-nav,.position-actions .copy-row{display:flex;flex-wrap:wrap;gap:4px}
.position-actions .ghost{padding:5px 8px;font-size:.75rem}
@media(max-width:500px){.position-status{align-items:flex-start;flex-direction:column;gap:2px}}
#position-provenance{margin:2px 0 0;font-size:.72rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.board-message{margin:0;min-height:0}
.tools-bar{flex:none;display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}
.tool-btn{padding:5px 9px;font-size:.75rem}
.tool-btn.active{outline:2px solid var(--green)}
.tool-dialog{width:min(760px,92vw);max-height:min(80vh,720px);overflow:auto;border:1px solid var(--line);border-radius:12px;padding:12px 16px 16px;background:#fff;color:var(--ink)}
.tool-dialog input,.tool-dialog select,.tool-dialog textarea{color:var(--ink);background:#fff;border:1px solid var(--line)}
/* Native dialogs and nested controls must not inherit the dark engine palette. */
dialog{background:#fff;color:var(--ink)}
dialog :is(input,select,textarea,button){color:var(--ink)}
#panel-position,.position-search,#panel-position label,#panel-position .panel-meta{color:var(--ink)}
.tool-dialog.is-positioned{position:fixed;margin:0}
.tool-dialog::backdrop{background:rgba(16,43,37,.4)}
.dialog-actions{display:flex;align-items:center;gap:5px;flex:none}
.tool-dialog .pane-head{cursor:grab;touch-action:none}
.tool-dialog .pane-head:active{cursor:grabbing}
.dialog-actions .ghost{padding:5px 8px;font-size:.75rem}
.info-icon{position:relative;display:inline-grid;place-items:center;width:19px;height:19px;min-width:19px;padding:0;border:1px solid var(--green);border-radius:50%;background:#fff;color:var(--green);font:800 .7rem/1 Manrope,sans-serif;cursor:help}
.info-icon:hover,.info-icon:focus-visible{background:var(--green);color:#fff;outline:2px solid var(--lime);outline-offset:2px}
.info-tooltip{position:absolute;z-index:5;left:50%;bottom:calc(100% + 7px);width:min(250px,70vw);padding:7px 9px;border-radius:6px;background:#102b25;color:#fff;font:500 .75rem/1.35 Manrope,sans-serif;text-align:left;box-shadow:0 4px 16px #102b2544;opacity:0;pointer-events:none;transform:translate(-50%,4px);transition:opacity .12s,transform .12s}
.info-tooltip::after{content:'';position:absolute;left:50%;top:100%;border:5px solid transparent;border-top-color:#102b25;transform:translateX(-50%)}
.info-icon:hover .info-tooltip,.info-icon:focus-visible .info-tooltip{opacity:1;transform:translate(-50%,0)}
.field-info{display:inline-grid;vertical-align:middle;margin-left:3px}
.similarity-weights{margin:8px 0}.similarity-weights summary{cursor:pointer;color:var(--green)}
.similarity-weight-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 10px;margin-top:8px}
.similarity-hits{margin:8px 0 0;padding-left:1.25rem;display:grid;gap:8px}.similarity-hits li{line-height:1.4}
.similarity-components{color:var(--green);font:500 .75rem 'DM Mono',monospace}
@media(max-width:500px){.similarity-weight-grid{grid-template-columns:1fr}}
.eval-bar{width:22px;border-radius:4px;background:#5c4638;position:relative;overflow:hidden;min-height:0;height:min(58cqw,100cqh);align-self:start}
.eval-bar-fill{position:absolute;bottom:0;left:0;right:0;height:50%;background:#eddfc7;transition:height .18s ease}
.notation-box{background:#fff;border:1px solid var(--line);border-radius:8px;min-width:0;min-height:0;height:100%;overflow:hidden;display:flex;flex-direction:column}
.pane-head{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:6px 8px;border-bottom:1px solid var(--line)}
.pane-head .eyebrow{margin:0}
.notation-body{display:flex;flex-direction:column;min-height:0;flex:1;overflow:hidden}
.notation-box .moves{flex:1;min-height:0;overflow:auto;padding:8px 10px;font:500 .88rem 'DM Mono',monospace;line-height:1.55}
.ply-row{display:grid;grid-template-columns:2.2rem minmax(3.2rem,1fr) minmax(3.2rem,1fr);gap:2px 8px;align-items:baseline;padding:1px 0}
.ply-row .move-num{margin:0;white-space:nowrap}
.ply-row .san{white-space:nowrap;text-align:left;min-width:0}
.ply-row .nag-comment{grid-column:1/-1;font-size:.75em}
.variation{display:block;font-size:.84em;color:var(--muted);padding:2px 0 4px 2.2rem}
.notation-notes{border-top:1px solid var(--line);padding:6px 8px;font-size:.78rem}
.notation-notes summary{cursor:pointer;color:var(--muted)}
.notation-box .tree-actions{display:flex;flex-wrap:wrap;gap:4px;padding:6px 8px}
.notation-box .tree-actions .ghost{padding:4px 7px;font-size:.7rem}
.notation-box .annotate{padding:6px 8px;gap:6px}
.notation-box .annotate textarea{min-height:44px;font-size:.75rem}
.notation-box .nag-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;padding:0 8px 6px}
.notation-box .nag-row .ghost{display:grid;grid-template-columns:2rem minmax(0,1fr) auto;align-items:center;gap:5px;padding:5px 6px;text-align:left;font-size:.66rem}
.notation-box .nag-row .ghost[aria-pressed="true"]{background:#dcebcf;color:var(--green);box-shadow:inset 0 0 0 2px var(--green)}
.nag-symbol{font:800 .9rem 'DM Mono',monospace;text-align:center}.nag-row kbd{color:var(--muted);font:600 .58rem 'DM Mono',monospace}.nag-help{margin:0;padding:0 8px 8px;color:var(--muted);font-size:.65rem;line-height:1.35}
.notation-box.is-collapsed .notation-body{display:none}
.notation-box.is-collapsed .pane-head{flex-direction:column;padding:8px 4px;height:100%}
.notation-box.is-collapsed .eyebrow{writing-mode:vertical-rl;transform:rotate(180deg)}
.engine-box{background:#17312b;color:#d9e5df;border-radius:8px;min-width:0;max-width:none;max-height:none;height:100%;min-height:0;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable;display:flex;flex-direction:column}
.engine-box::after{content:'';display:block;flex:0 0 14px;min-height:14px}
.engine-box.is-collapsed{overflow:hidden}
.engine-box.is-collapsed::after{display:none}
.engine-box.is-collapsed .engine-pv,.engine-box.is-collapsed .engine-run-controls,.engine-box.is-collapsed .engine-more,.engine-box.is-collapsed .engine-foot,.engine-box.is-collapsed #engine-start,.engine-box.is-collapsed #engine-stop,.engine-box.is-collapsed .engine-eval,.engine-box.is-collapsed .engine-name,.engine-box.is-collapsed .engine-depth-label{display:none}
.engine-box.is-collapsed .engine-head{flex-direction:column;padding:8px 4px;height:100%;background:#17312b}
.engine-head{display:flex;flex:0 0 auto;flex-wrap:wrap;align-items:center;gap:6px;padding:6px 8px;background:#102822}
.engine-eval{font:800 1.05rem 'DM Mono',monospace;color:var(--lime);min-width:2.8rem}
.engine-head .primary,.engine-head .ghost{padding:7px 12px;font:800 .9rem Manrope,sans-serif;letter-spacing:.02em}
.engine-box .ghost{color:#102b25;background:#e8f4ee;border-color:#cfe6da}
.engine-box .ghost:hover{color:#102b25;background:#f4fbf7;border-color:#edf6f1}
.engine-box .ghost:disabled{opacity:.45;color:#102b25;background:#8fb5a8;border-color:#8fb5a8}
.engine-box .primary{color:#102b25}
.engine-name{font:700 .78rem Manrope,sans-serif}
.engine-depth-label{font:500 .72rem 'DM Mono',monospace;color:#9bb5ab}
.engine-run-controls{display:flex;flex:0 0 auto;align-items:end;flex-wrap:wrap;gap:8px;padding:8px 10px;border-top:1px solid #2b4a42;border-bottom:1px solid #2b4a42;background:#17312b}
.engine-run-controls label{display:grid;gap:3px;color:#d9e5df;font:700 .78rem Manrope,sans-serif}
.engine-run-controls input{width:5.25rem;min-height:36px;padding:5px 8px;border:1px solid #70988b;border-radius:6px;background:#fff;color:#102b25;font:700 .9rem 'DM Mono',monospace}
.engine-run-controls input:focus{outline:3px solid color-mix(in srgb,var(--lime) 55%,transparent);outline-offset:1px}
.engine-run-note{align-self:center;color:#b7cbc3;font-size:.72rem;line-height:1.35}
.engine-pv{list-style:none;margin:0;padding:4px 0;font:500 .76rem 'DM Mono',monospace;overflow:visible;flex:0 0 auto;min-height:0;max-height:none}
.engine-pv li{display:grid;grid-template-columns:3.4rem 1fr;gap:8px;padding:8px 10px;cursor:pointer;line-height:1.4;align-items:start}
.engine-pv li:hover{background:#24443c}
.engine-pv li.is-previewing{background:#2b5147;box-shadow:inset 3px 0 0 var(--lime)}
.engine-pv-moves{display:inline;line-height:1.75}
.engine-pv-move{display:inline;padding:1px 3px;border:0;border-radius:3px;background:transparent;color:inherit;font:inherit;cursor:pointer}
.engine-pv-move:hover,.engine-pv-move:focus-visible,.engine-pv-move.is-previewing-move{background:#dff58a;color:#102b25;outline:none}
.engine-arrow-group.is-ghost .engine-arrow{stroke:#dff58a;stroke-dasharray:1.2 1.2}
.engine-arrow-group.is-ghost .engine-arrowhead{fill:#dff58a}
.engine-pv strong{color:var(--lime)}
.engine-pv span{overflow:visible;text-overflow:unset;white-space:normal;word-break:break-word}
.engine-more{flex:0 0 auto;padding:6px 10px 10px;border-top:1px solid #2b4a42;font-size:.78rem}
.engine-more summary{cursor:pointer;color:#9bb5ab}
.engine-more label{display:block;margin:6px 0}
.engine-setting-note{margin:8px 0 0;color:#b7cbc3;line-height:1.35}
.engine-foot{flex:0 0 auto;margin:0;padding:6px 10px 10px;font-size:.72rem;color:#9bb5ab}
@media(max-width:1100px){.board-stage{grid-template-columns:14px minmax(0,min(58%,76vh)) minmax(0,1fr)}.eval-bar{height:min(58cqw,76vh)}.board-stage.is-notation-collapsed{grid-template-columns:14px minmax(0,min(58%,76vh)) 36px}.board-stage.is-engine-collapsed{grid-template-columns:14px minmax(0,min(58%,76vh)) minmax(0,1fr) 36px}.board-stage.is-notation-collapsed.is-engine-collapsed{grid-template-columns:14px minmax(0,min(58%,76vh)) 36px 36px}.engine-box{grid-column:1/-1;height:200px}.board-stage.is-engine-collapsed .engine-box{height:36px}}
@media(max-width:900px){.board-stage{grid-template-columns:14px minmax(0,min(76%,82vh));flex:none}.eval-bar{height:min(76cqw,82vh)}.board-stage.is-notation-collapsed{grid-template-columns:14px minmax(0,min(76%,82vh)) 36px}.board-stage.is-engine-collapsed{grid-template-columns:14px minmax(0,min(76%,82vh)) 36px}.board-stage.is-notation-collapsed.is-engine-collapsed{grid-template-columns:14px minmax(0,min(76%,82vh)) 36px 36px}.notation-box,.engine-box{grid-column:1/-1;height:240px}.board-stage.is-notation-collapsed .notation-box,.board-stage.is-engine-collapsed .engine-box{height:36px}}
.book-saved{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}
.book-saved button{padding:5px 9px;font-size:.78rem}
.book-saved button.active{outline:2px solid var(--green)}
.book-tree-wrap{max-height:360px;overflow:auto;border:1px solid var(--line);border-radius:8px;padding:8px 10px;background:#fbfcf8}
.book-tree{list-style:none;margin:0;padding:0 0 0 1rem;font:500 .82rem 'DM Mono',monospace}
.book-tree .book-san{font-weight:700;color:var(--ink)}
.book-tree .book-meta{color:var(--muted);font-size:.75rem}
.keys-tabs{display:flex;flex-wrap:wrap;gap:4px;margin:8px 0}
.keys-tabs .active{outline:2px solid var(--green)}
.keys-list{display:flex;flex-direction:column;gap:4px;margin-top:8px}
.key-row{display:flex;justify-content:space-between;align-items:baseline;gap:8px;width:100%;text-align:left;padding:6px 8px;border:1px solid var(--line);border-radius:6px;background:#fff;font:500 .82rem Manrope,sans-serif;cursor:pointer}
.key-row:hover{background:#f4fbf7}
.key-row span:last-child{color:var(--muted);font:500 .75rem 'DM Mono',monospace;white-space:nowrap}
.report-block{font-size:.82rem}
.report-block h2,.report-block h3{margin:12px 0 6px;font-size:.95rem}
.report-block table{width:100%;border-collapse:collapse;margin:0 0 10px}
.report-block th,.report-block td{border:1px solid var(--line);padding:4px 6px;text-align:left}
.report-block .incomplete{display:inline-block;margin-left:6px;padding:1px 6px;border-radius:999px;background:#f3e2c7;font-size:.72rem}
.report-block .report-export{white-space:pre-wrap;font:500 .78rem 'DM Mono',monospace;margin:0}
.report-block .report-links{display:flex;flex-wrap:wrap;gap:8px}
/* Phase 2 surfaces share the same control language as the main workbench. */
.library-actions .ghost,.tree-item,.library-tile,.key-row,.castle-set{border-radius:var(--radius-sm)}.library-pane{background:#fbfcf8}.library-tile-grid{grid-template-columns:repeat(auto-fill,minmax(140px,1fr))}.library-tile{transition:background .15s ease,border-color .15s ease,transform .15s ease}.library-tile:hover{transform:translateY(-1px)}.notation-box,.engine-box{border-radius:var(--radius-md)}.notation-box .moves,.engine-pv{scrollbar-color:#a8b8af transparent;scrollbar-width:thin}.notation-box .moves:focus-within,.engine-pv:focus-within{outline:2px solid var(--lime);outline-offset:-2px}.engine-box{box-shadow:0 8px 22px rgba(16,43,37,.12)}.engine-head{min-height:42px}.engine-pv li{transition:background .12s ease}.engine-pv li:focus-visible{outline:2px solid var(--lime);outline-offset:-2px}.material-table th{font-weight:800;color:var(--green);background:#f1f4ed}.tool-dialog .pane-head{position:sticky;top:-12px;z-index:1;background:#fff;padding-top:12px}.tool-dialog :is(input,select,textarea){border-radius:var(--radius-sm);padding:7px 9px;min-height:36px}.tool-dialog textarea{min-height:84px;resize:vertical}.tool-dialog :is(input,select,textarea):focus-visible{border-color:var(--focus);box-shadow:0 0 0 2px rgba(23,102,153,.16)}.dialog-actions .ghost,.dialog-actions .info-icon{min-height:32px}.setup-toolbar,.material-toolbar,.engine-toolbar,.pattern-tools{align-items:end}
@media(max-width:700px){.tool-dialog{width:min(94vw,760px);padding:8px 12px 12px}.library-tile-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.engine-head{align-items:center}.engine-head .primary,.engine-head .ghost{padding:6px 9px}}
.tool-dialog>label{color:var(--ink)}
.tool-dialog :is(.position-search,.material-toolbar,.setup-toolbar,.engine-toolbar,.pattern-tools) label{color:var(--ink)}
/* Professional research layout: readable game identities and a stable analysis column. */
.workbench{grid-template-columns:190px minmax(250px,.72fr) minmax(700px,2.1fr);height:max(560px,calc(100vh - 160px));max-height:none}
.workbench.is-library-collapsed{grid-template-columns:44px minmax(270px,.72fr) minmax(700px,2.1fr)}
.game-title span:first-child{white-space:normal;line-height:1.25;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.game-sub{white-space:normal;line-height:1.35}.game-tag:empty{display:none}
.annotation-badge{display:inline-flex;align-items:center;margin-left:7px;padding:1px 6px;border:1px solid color-mix(in srgb,var(--green) 45%,transparent);border-radius:999px;background:#e8f1e4;color:var(--green);font:700 .62rem 'DM Mono',monospace;letter-spacing:.02em;vertical-align:middle}
.topbar-actions{display:flex;align-items:center;gap:8px}.account-button{white-space:nowrap}
#account-dialog{width:min(460px,calc(100vw - 32px));border:0;border-radius:12px;padding:0;box-shadow:0 24px 80px #102b2555;color:var(--ink);background:#fff}
#account-dialog::backdrop{background:#102b2588;backdrop-filter:blur(3px)}
.account-shell{display:grid;gap:14px;padding:22px}.account-shell [hidden]{display:none!important}.account-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.account-heading h2{margin:0;font-size:1.55rem}.account-heading .eyebrow{margin-bottom:4px}
#account-form{display:grid;gap:12px}#account-form>label:not(.check){display:grid;gap:5px;font-weight:700}#account-form input:not([type="checkbox"]){width:100%;min-height:42px;border:1px solid var(--line);border-radius:6px;padding:8px 10px;color:var(--ink);background:#fff}.account-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:4px}.account-terms{margin:0;color:var(--muted);font-size:.78rem;align-items:flex-start}.account-terms a{color:var(--green);font-weight:800;text-underline-offset:2px}.account-shell .load-error{margin:0}
.account-notice{margin:0;padding:9px 11px;border-radius:6px;background:#eef8d8;color:#254626;font-size:.84rem}.account-notice.is-error{background:#fff0ec;color:#7c251b}.account-verification-actions{display:grid;gap:10px;padding:12px;border:1px solid var(--line);border-radius:8px;background:#f8fbf9}.account-verification-actions details{font-size:.84rem}.account-verification-actions summary{cursor:pointer;font-weight:700}.account-verification-actions form{display:grid;gap:9px;margin-top:10px}.account-verification-actions form label{display:grid;gap:4px;font-weight:700}.account-verification-actions input{width:100%;min-height:40px;border:1px solid var(--line);border-radius:6px;padding:7px 9px;color:var(--ink);background:#fff}
.account-data-export{padding:12px;border:1px solid var(--line);border-radius:8px;background:#f8fbf9;font-size:.84rem}.account-data-export summary{cursor:pointer;font-weight:700}.account-data-export>p{color:var(--muted)}.account-data-export form{display:grid;gap:9px}.account-data-export form label{display:grid;gap:4px;font-weight:700}.account-data-export input{width:100%;min-height:40px;border:1px solid var(--line);border-radius:6px;padding:7px 9px;color:var(--ink);background:#fff}
.account-deletion{padding:12px;border:1px solid #e1b2aa;border-radius:8px;background:#fff8f6;font-size:.84rem}.account-deletion summary{cursor:pointer;font-weight:800;color:#7c251b}.account-deletion p{line-height:1.45}.account-deletion form{display:grid;gap:9px}.account-deletion form label{display:grid;gap:4px;font-weight:700}.account-deletion input{width:100%;min-height:40px;border:1px solid var(--line);border-radius:6px;padding:7px 9px;color:var(--ink);background:#fff}.account-deletion .danger{justify-content:center;min-height:40px;border:1px solid #a3382b;border-radius:6px;background:#a3382b;color:#fff;font-weight:800}.account-deletion .danger:hover{background:#83291f}.account-deletion-warning{font-weight:800;color:#7c251b}
@media(max-width:700px){.topbar-actions #demo-button{display:none}.topbar-actions{gap:4px}.account-button{padding:8px 10px}.account-actions{align-items:stretch;flex-direction:column-reverse}.account-actions>*{width:100%}}
.board-stage,.board-stage.is-notation-collapsed,.board-stage.is-engine-collapsed,.board-stage.is-notation-collapsed.is-engine-collapsed{grid-template-columns:20px minmax(480px,min(60%,100cqh)) minmax(280px,1fr);grid-template-rows:minmax(250px,1fr) minmax(200px,.78fr);align-items:stretch;flex:0 0 500px}
.eval-bar{grid-column:1;grid-row:1/-1;height:min(56cqw,100cqh)}.board-shell{grid-column:2;grid-row:1/-1}.notation-box{grid-column:3;grid-row:1;height:100%}.engine-box{grid-column:3;grid-row:2;height:100%}.board-stage.is-notation-collapsed{grid-template-rows:38px 1fr}.board-stage.is-engine-collapsed{grid-template-rows:1fr 38px}.board-stage.is-notation-collapsed .notation-box,.board-stage.is-engine-collapsed .engine-box{height:38px}
.tools-bar{display:flex;align-items:stretch;gap:8px;flex-wrap:nowrap;overflow-x:auto}.tool-group{display:flex;align-items:center;gap:4px;padding:4px 6px 4px 8px;border:1px solid var(--line);border-radius:9px;background:#f7f8f4;flex:none}.tool-group-label{color:var(--muted);font:700 .62rem 'DM Mono',monospace;text-transform:uppercase;letter-spacing:.06em}.tool-group .tool-btn{border:0;background:transparent;padding:6px 8px}.tool-group .tool-btn:hover{background:#e5ecdc}
.maneuver-heading{display:grid;grid-template-columns:minmax(220px,.5fr) 1fr;gap:12px;align-items:end}.maneuver-builder{display:grid;gap:8px;margin:10px 0}.maneuver-step{display:grid;grid-template-columns:repeat(3,minmax(76px,1fr)) repeat(3,auto);gap:8px;align-items:end;margin:0;padding:10px;border:1px solid var(--line);border-radius:8px}.maneuver-step legend{padding:0 5px;color:var(--green);font-weight:800}.maneuver-step label{display:flex;flex-direction:column;gap:3px;color:var(--ink);font-size:.72rem;font-weight:700}.maneuver-step label.check{flex-direction:row;align-items:center;padding-bottom:8px}.expert-input{margin:10px 0;padding:8px 10px;border:1px solid var(--line);border-radius:8px}.expert-input summary{cursor:pointer;color:var(--muted);font-weight:700}.explorer-table td:nth-child(3),.explorer-table td:last-child{font-weight:800;color:var(--green)}
@media(max-width:1200px){.workbench{grid-template-columns:160px minmax(220px,.65fr) minmax(620px,2fr)}.workbench.is-library-collapsed{grid-template-columns:44px minmax(240px,.65fr) minmax(620px,2fr)}.board-stage,.board-stage.is-notation-collapsed,.board-stage.is-engine-collapsed,.board-stage.is-notation-collapsed.is-engine-collapsed{grid-template-columns:16px minmax(420px,min(60%,100cqh)) minmax(250px,1fr);flex-basis:450px}}
@media(max-width:900px){.workbench,.workbench.is-library-collapsed{grid-template-columns:1fr;height:auto;max-height:none}.game-list{height:40vh;max-height:40vh}.board-stage,.board-stage.is-notation-collapsed,.board-stage.is-engine-collapsed,.board-stage.is-notation-collapsed.is-engine-collapsed{grid-template-columns:16px minmax(0,1fr);grid-template-rows:auto 230px 230px;flex:0 0 auto;height:auto;overflow:visible}.eval-bar{grid-column:1;grid-row:1;height:auto}.board-shell{grid-column:2;grid-row:1}.notation-box,.engine-box{grid-column:1/-1;height:230px}.notation-box{grid-row:2}.engine-box{grid-row:3}.board-stage.is-notation-collapsed .notation-box,.board-stage.is-engine-collapsed .engine-box{height:38px}.maneuver-step{grid-template-columns:repeat(3,minmax(70px,1fr))}.maneuver-heading{grid-template-columns:1fr}.tool-group-label{display:none}}

/* Desktop fit: preserve a substantial board while keeping every workbench
   column inside the viewport at 1280px and above. */
@media(min-width:901px){
  .workbench,.workbench.is-library-collapsed{grid-template-columns:180px 240px minmax(0,1fr);}
  .game-detail{min-width:0;overflow:visible;}
  .board-stage,.board-stage.is-notation-collapsed,.board-stage.is-engine-collapsed,.board-stage.is-notation-collapsed.is-engine-collapsed{
    grid-template-columns:20px minmax(420px,min(60%,100cqh)) minmax(0,1fr);
    grid-template-rows:minmax(210px,1fr) minmax(170px,.78fr);
    flex:1 1 auto;
    flex-basis:auto;
    min-width:0;
    overflow:visible;
  }
  .board-shell{min-width:0;width:min(100%,max(420px,100cqh));}
  .notation-box,.engine-box{min-width:0;}
  .tools-bar{flex-wrap:wrap;overflow:visible;align-content:flex-start;}
  .tool-group{flex:1 1 auto;min-width:0;}
  .tool-group .tool-btn{white-space:normal;}
}

.footer-links{display:flex;gap:16px;align-items:center}
.footer-links a{color:inherit;text-underline-offset:3px}

@media(min-width:901px) and (max-width:1200px){
  .workbench,.workbench.is-library-collapsed{grid-template-columns:160px 220px minmax(0,1fr);}
  .board-stage,.board-stage.is-notation-collapsed,.board-stage.is-engine-collapsed,.board-stage.is-notation-collapsed.is-engine-collapsed{
    grid-template-columns:16px minmax(390px,min(60%,100cqh)) minmax(0,1fr);
  }
  .board-shell{width:min(100%,max(390px,100cqh));}
}

/* The desktop search controls stay available without pushing the board below
   the fold when a filter disclosure was left open. */
@media(min-width:901px){
  main{padding-top:8px;}
  .intro{margin-bottom:8px;grid-template-rows:auto auto;}
  .intro h1{line-height:1;}
  .intro .lede{line-height:1.25;}
  .research{position:relative;padding:10px 14px;}
  .search-filters{position:relative;margin-top:5px;}
  .search-filters[open] .filter-grid,.search-filters[open] .filters{
    position:absolute;left:0;right:0;z-index:4;background:var(--dark);padding-left:14px;padding-right:14px;
  }
  .search-filters[open] .filter-grid{top:31px;padding-top:12px;}
  .search-filters[open] .filters{top:calc(31px + 245px);padding-bottom:12px;}
  .results-wrap{margin-top:8px;}
  .result-head{min-height:24px;margin-bottom:5px;}
  .board-stage,.board-stage.is-notation-collapsed,.board-stage.is-engine-collapsed,.board-stage.is-notation-collapsed.is-engine-collapsed{
    height:clamp(420px,52vh,640px);
    min-height:420px;
    flex:0 0 clamp(420px,52vh,640px);
    grid-template-rows:minmax(0,1fr) minmax(0,1fr);
  }
  .board-shell{width:min(100%,max(420px,100cqh));}
  .position-info{padding-top:4px;}
  .position-actions{margin-top:2px;}
  .tools-bar{margin-top:4px;}
}

/* 1280x720 desktop budget: reserve the vertical space for the board first.
   The global workbench min-height (560px) and an open filter disclosure were
   previously responsible for pushing the board below the fold. */
@media(min-width:901px){
  .intro{
    height:32px;
    max-height:32px;
    overflow:hidden;
    display:flex;
    align-items:center;
    gap:16px;
    margin-bottom:4px;
  }
  .intro .eyebrow{flex:none;margin:0;font-size:.62rem;}
  .intro h1{flex:none;font-size:1.45rem;line-height:1;white-space:nowrap;}
  .intro .lede{margin:0;max-width:none;font-size:.75rem;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  .intro .data-status{flex:none;margin:0;font-size:.62rem;}
  .research{padding:8px 12px;}
  .results-wrap{margin-top:5px;}
  .workbench,.workbench.is-library-collapsed{
    height:auto;
    min-height:0;
    max-height:none;
  }
  .game-detail{height:auto;}
  .game-detail{padding:4px 10px 8px;}
  .detail-top{font-size:.65rem;line-height:1.1;}
  .game-detail h2{font-size:1rem;line-height:1.1;}
  .game-meta{font-size:.7rem;line-height:1.1;}
}

/* Short desktop viewports keep a real 420px playing surface and place the
   essential move controls on the same line below it.  The board shell also
   reserves the coordinate gutter so the 8x8 surface itself is not reduced. */
@media(min-width:1101px) and (max-height:800px){
  .game-detail{position:relative;}
  .detail-top{position:absolute;top:5px;right:10px;z-index:1;}
  .detail-top #opening-code{display:none;}
  .game-detail h2{padding-right:120px;margin-top:1px;}
  .game-meta{margin:1px 0 4px;}
  .board-stage,.board-stage.is-notation-collapsed,.board-stage.is-engine-collapsed,.board-stage.is-notation-collapsed.is-engine-collapsed{
    grid-template-columns:20px minmax(442px,min(62%,calc(100cqh + 22px))) minmax(0,1fr);
  }
  .board-shell{width:min(100%,max(442px,calc(100cqh + 22px)));}
  .position-info{
    min-height:34px;
    padding:2px 0 0;
    display:grid;
    grid-template-columns:minmax(150px,auto) minmax(0,1fr);
    align-items:center;
    gap:8px;
  }
  .position-status{white-space:nowrap;}
  .position-actions{margin:0;min-width:0;}
  .replay-nav{justify-content:flex-start;gap:4px;}
  .replay-nav .ghost{padding:5px 8px;}
  .copy-row,#position-provenance,.board-message:empty{display:none;}
  .engine-head{
    display:grid;
    grid-template-columns:auto minmax(0,1fr) auto;
    align-items:center;
    gap:3px 6px;
    padding:5px 7px;
  }
  .engine-name{min-width:0;font-size:.68rem;line-height:1.15;}
  .engine-depth-label{text-align:right;font-size:.62rem;}
  .engine-head .primary,.engine-head .ghost{padding:5px 7px;font-size:.68rem;line-height:1.1;}
  #engine-start{grid-column:1;}
  #engine-stop{grid-column:2;justify-self:start;}
  #engine-toggle{grid-column:3;}
  .engine-more{padding:3px 8px;font-size:.65rem;}
  .engine-foot{padding:2px 8px;font-size:.62rem;line-height:1.25;}
  #engine-meta{display:none;}
  .engine-pv li{padding:5px 8px;font-size:.68rem;}
}

/* Guided tools: one decision per page instead of a dense form at the board edge. */
.flow-dialog{width:min(1040px,calc(100vw - 32px));height:min(760px,calc(100vh - 32px));max-height:calc(100vh - 32px);padding:0;overflow:hidden;border-radius:16px;background:#fbfcf8;color:var(--ink);box-shadow:0 28px 90px rgba(9,35,29,.32);display:flex;flex-direction:column;box-sizing:border-box}
.flow-dialog:not([open]){display:none}
html:has(.flow-dialog[open]),body:has(.flow-dialog[open]){overflow:hidden;overscroll-behavior:none}
.flow-dialog::backdrop{background:rgba(11,32,27,.58);backdrop-filter:blur(2px)}
.flow-header{min-height:112px;box-sizing:border-box;display:flex;align-items:flex-start;justify-content:space-between;gap:24px;padding:22px 26px 18px;border-bottom:1px solid var(--line);background:#fff}
.flow-header h2{margin:3px 0 5px;font-size:1.55rem;letter-spacing:-.045em}
.flow-header p{margin:0;max-width:620px;color:var(--muted);font-size:.9rem;line-height:1.5}
.flow-header .dialog-actions{display:flex;align-items:center;gap:10px;flex:none}
.flow-progress{padding:6px 10px;border-radius:999px;background:#e9efe7;color:var(--green);font:800 .72rem 'DM Mono',monospace;white-space:nowrap}
.flow-layout{display:grid;grid-template-columns:220px minmax(0,1fr);flex:1;min-height:0}
.flow-steps{list-style:none;margin:0;padding:26px 18px;background:var(--dark);color:#dbe8e2;display:flex;flex-direction:column;gap:6px}
.flow-steps li{position:relative;display:grid;grid-template-columns:32px 1fr;column-gap:10px;row-gap:1px;padding:11px 8px;border-radius:10px;opacity:.56}
.flow-steps li>span{grid-row:1/3;width:30px;height:30px;display:grid;place-items:center;border:1px solid #698078;border-radius:50%;font:800 .72rem 'DM Mono',monospace}
.flow-steps strong{font-size:.86rem;color:#fff}.flow-steps small{font-size:.7rem;line-height:1.35;color:#b8c9c2}
.flow-steps li.current{background:#29483f;opacity:1}.flow-steps li.current>span{border-color:var(--lime);background:var(--lime);color:var(--dark)}
.flow-steps li.complete{opacity:.82}.flow-steps li.complete>span{border-color:#9db6ad;color:var(--lime)}
.flow-pages{min-width:0;min-height:0;overflow:auto;background:#fbfcf8}
.flow-page{min-height:100%;padding:34px 40px 26px;box-sizing:border-box;display:flex;flex-direction:column}
.flow-page[hidden]{display:none!important}
.step-kicker{margin:0 0 7px;color:var(--green);font:800 .7rem 'DM Mono',monospace;letter-spacing:.08em}
.flow-page h3{margin:0 0 8px;font-size:1.45rem;letter-spacing:-.04em;outline:none}
.flow-lede{margin:0 0 26px;max-width:620px;color:var(--muted);line-height:1.55}
.flow-choice,.flow-scan{display:flex;flex-direction:column;gap:8px;max-width:540px;font-weight:800;color:var(--ink)}
.flow-choice select{min-height:52px;font-size:1rem;background:#fff}
.flow-scan{margin:0 0 20px}.flow-scan input{max-width:180px}
.flow-page-actions{position:sticky;bottom:-26px;display:flex;justify-content:flex-end;gap:10px;margin:auto -40px -26px;padding:16px 40px;background:linear-gradient(to bottom,rgba(251,252,248,.9),#fbfcf8 28%);border-top:1px solid var(--line)}
.flow-page-actions .ghost:first-child{margin-right:auto}
.flow-result{min-height:320px;padding:18px;border:1px solid var(--line);border-radius:10px;background:#fff;color:var(--ink);font-size:.88rem;overflow:auto}
.report-subject{max-width:620px;padding:20px;border:1px solid var(--line);border-radius:10px;background:#fff}
.report-subject[hidden]{display:none!important}.report-subject p{margin:0 0 16px;color:var(--muted);line-height:1.5}
.report-subject label{display:flex;flex-direction:column;gap:7px;margin-bottom:14px;font-weight:800}.report-subject input{width:100%;box-sizing:border-box}
.report-result-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:18px}.report-export-actions{display:flex;gap:8px;flex-wrap:wrap}
.flow-dialog #adv-maneuver-fields,.flow-dialog #adv-structure-fields,.flow-dialog #adv-attack-fields,.flow-dialog #adv-similar-fields{padding:18px;border:1px solid var(--line);border-radius:10px;background:#fff}
@media(max-width:760px){.flow-dialog{inset:0;width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0}.flow-header{min-height:auto;padding:16px;align-items:flex-start}.flow-header>div:first-child p:last-child{display:none}.flow-header h2{font-size:1.2rem}.flow-header .dialog-actions{flex-direction:column-reverse;align-items:flex-end}.flow-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr)}.flow-steps{padding:8px 12px;flex-direction:row;gap:4px;overflow-x:auto}.flow-steps li{min-width:36px;display:block;padding:4px;background:transparent}.flow-steps li>span{width:28px;height:28px}.flow-steps strong,.flow-steps small{display:none}.flow-pages{min-height:0}.flow-page{padding:24px 18px 18px}.flow-page-actions{bottom:-18px;margin:auto -18px -18px;padding:14px 18px}.maneuver-step{grid-template-columns:repeat(2,minmax(0,1fr))}.report-result-head{flex-direction:column}}

/* Final desktop gate fixes. Keep these overrides at the end of the cascade so
   the compact workbench remains deterministic at 1280, 1440 and 1920px. */
.square,
.game {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: inherit;
}
.square {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  line-height: 1;
}
.square.light { background: #eddfc7; }
.square.dark { background: #7b9d72; }
.game {
  display: block;
  width: 100%;
  min-height: 0;
  text-align: left;
}
.square:focus-visible,
.game:focus-visible {
  outline: 3px solid var(--focus, #176699);
  outline-offset: -3px;
}

@media (min-width: 901px) {
  /* The summary is the always-available keyboard entry point. Filter fields
     float over the research surface so opening them never moves the board. */
  .research { overflow: visible; padding-block: 6px; }
  .search-filters { display: block; position: relative; margin-top: 5px; }
  .search-filters > summary {
    display: flex;
    align-items: center;
    min-height: 26px;
    list-style: none;
    color: #fff;
    cursor: pointer;
  }
  .search-filters > summary::-webkit-details-marker { visibility: hidden; width: 0; }
  .search-filters > summary::before {
    content: '▸';
    color: var(--lime);
    margin-right: 7px;
    transition: transform .15s ease;
  }
  .search-filters[open] > summary::before { transform: rotate(90deg); }
  .search-filters > summary:focus-visible {
    outline: 2px solid var(--lime);
    outline-offset: 3px;
  }
  .search-filters > summary span { color: #9fb7af; }
  .search-filters[open] .filter-grid,
  .search-filters[open] .filters {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 20;
    margin: 0;
    background: var(--dark);
    box-shadow: 0 14px 28px rgba(16,43,37,.24);
  }
  .search-filters[open] .filter-grid {
    top: 31px;
    padding: 12px 14px 14px;
  }
  .search-filters[open] .filters {
    top: calc(31px + 245px);
    padding: 0 14px 12px;
  }

  /* A bounded workbench gives the two large lists their own scroll regions. */
  .workbench,
  .workbench.is-library-collapsed {
    grid-template-columns: 180px 240px minmax(0, 1fr);
    height: clamp(560px, calc(100vh - 155px), 820px);
    min-height: 560px;
    max-height: calc(100vh - 155px);
    overflow: hidden;
  }
  .workbench.is-library-collapsed {
    grid-template-columns: 44px 240px minmax(0, 1fr);
  }
  .library {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  .library-explorer {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
  }
  .game-list {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
  .game-detail { min-height: 0; overflow: hidden; }
  /* The short-height desktop rule above has lower specificity than the base
     flex declaration. Keep secondary copy actions out of the 720px frame so
     the board, navigation and tool strip remain visible. */
  .position-actions .copy-row { display: none; }
  .tools-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    max-height: 66px;
    overflow-x: hidden;
    overflow-y: auto;
    align-content: start;
    scrollbar-gutter: stable;
  }
  .tool-group {
    grid-column: span 2;
    min-width: 0;
    flex: none;
    overflow: hidden;
  }
  .tool-group-label { font-size: .58rem; }
  .tool-group .tool-btn { padding: 4px 5px; font-size: .68rem; }

  /* The playing surface always retains at least 420px on desktop. */
  .board-stage,
  .board-stage.is-notation-collapsed,
  .board-stage.is-engine-collapsed,
  .board-stage.is-notation-collapsed.is-engine-collapsed {
    height: clamp(420px, 52vh, 640px);
    min-height: 420px;
    flex: 0 0 clamp(420px, 52vh, 640px);
    grid-template-columns: 20px minmax(442px, min(62%, calc(100cqh + 22px))) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }
  .board-shell {
    width: min(100%, max(442px, calc(100cqh + 22px)));
    min-width: 442px;
  }
}

/* A 720px-tall desktop viewport has room for the complete 420px board only
   when the result summary shares the compact header band. The summary stays
   readable and clickable above the workbench; it no longer consumes a row. */
@media (min-width: 1101px) and (max-height: 800px) {
  .topbar { height: 52px; }
  main { padding-top: 4px; }
  .research { padding-block: 4px; }
  .results-wrap { position: relative; margin-top: 5px; }
  .result-head {
    position: absolute;
    top: -26px;
    left: 0;
    right: 0;
    z-index: 5;
    height: 24px;
    margin: 0;
  }
}

/* At wide desktop widths the filter summary gets a reserved slot beside the
   search field. Its disclosure remains visible while the closed form adds no
   vertical height to the board-first layout. */
@media (min-width: 1101px) {
  .research { position: relative; }
  .searchbar { padding-right: min(32vw, 410px); }
  .search-filters {
    position: absolute;
    top: 6px;
    right: 12px;
    width: min(32vw, 410px);
    margin: 0;
    z-index: 10;
  }
  .search-filters > summary { background: var(--dark); }
  .search-filters[open] .filter-grid,
  .search-filters[open] .filters {
    left: auto;
    right: 0;
    width: min(900px, calc(100vw - 48px));
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .search-filters[open] .filters { top: calc(31px + 315px); }
  .workbench,
  .workbench.is-library-collapsed { grid-template-columns: 160px 220px minmax(0, 1fr); }
  .workbench.is-library-collapsed { grid-template-columns: 44px 220px minmax(0, 1fr); }
  .board-stage,
  .board-stage.is-notation-collapsed,
  .board-stage.is-engine-collapsed,
  .board-stage.is-notation-collapsed.is-engine-collapsed {
    grid-template-columns: 16px minmax(442px, min(62%, calc(100cqh + 22px))) minmax(0, 1fr);
  }
  .board-shell { width: min(100%, max(442px, calc(100cqh + 22px))); }
}

/* Explorer is a non-modal companion panel. When open, reserve its right
   region inside the selected-game column and temporarily hide the panels it
   replaces; the board never ends up underneath a translucent dialog. */
@media (min-width: 901px) {
  .game-detail:has(#panel-explorer[open]) {
    --explorer-width: clamp(300px, 40%, 420px);
    position: relative;
  }
  .game-detail:has(#panel-explorer[open]) .board-stage {
    width: calc(100% - var(--explorer-width) - 12px);
    grid-template-columns: 20px minmax(442px, 1fr);
  }
  .game-detail:has(#panel-explorer[open]) .notation-box,
  .game-detail:has(#panel-explorer[open]) .engine-box { visibility: hidden; }
  #panel-explorer.tool-dialog[open] {
    position: absolute;
    /* Ignore a stale draggable offset: the companion surface belongs to the
       reserved right slot and must never drift back over the board. */
    inset: 21px 0 auto auto !important;
    z-index: 30;
    width: var(--explorer-width, 360px);
    height: clamp(420px, 52vh, 640px);
    max-height: none;
    margin: 0;
    overflow: auto;
    box-shadow: 0 14px 30px rgba(16,43,37,.22);
  }
}

/* Reflow the short desktop header instead of stacking controls over one
   another. The filter disclosure occupies the reserved search slot; the
   result summary gets a readable compact row before the workbench. */
@media (min-width: 1101px) and (max-height: 800px) {
  .search-filters { top: 4px; right: 12px; }
  .results-wrap { margin-top: 5px; }
  .result-head {
    position: static;
    height: 20px;
    min-height: 20px;
    margin: 0;
    line-height: 1;
  }
  .result-head p { line-height: 1.2; }
  .game-detail { padding: 1px 10px 4px; }
  .detail-top { font-size: .6rem; line-height: 1; }
  .game-detail h2 { font-size: .92rem; line-height: 1.05; }
  .game-meta { margin: 0 0 2px; font-size: .64rem; line-height: 1; }
  .position-info {
    min-height: 30px;
    height: 30px;
    margin-top: 2px;
  }
  .position-actions .ghost {
    padding: 3px 6px;
    font-size: .66rem;
    line-height: 1;
  }
  .tools-bar {
    grid-auto-rows: 22px;
    max-height: 52px;
    padding-top: 2px;
    gap: 2px;
  }
  .tool-group .tool-btn { padding: 3px 4px; font-size: .64rem; line-height: 1; }
}

/* Keep an expanded desktop filter form in its own vertical space. The fields
   remain a disclosure, but no longer cover the result actions beneath them. */
@media (min-width: 901px) {
  .research:has(.search-filters[open]) { padding-bottom: 327px; }
}

/* The board shell contains the 420px playing surface plus its file-label row.
   Reserve that row in the stage instead of allowing it to spill into the
   position controls below. */
@media (min-width: 901px) {
  .board-stage,
  .board-stage.is-notation-collapsed,
  .board-stage.is-engine-collapsed,
  .board-stage.is-notation-collapsed.is-engine-collapsed {
    --board-size: clamp(420px, 52vh, 640px);
    height: calc(var(--board-size) + 22px);
    min-height: calc(420px + 22px);
    flex-basis: calc(var(--board-size) + 22px);
    grid-template-columns: 20px minmax(442px, min(62%, calc(var(--board-size) + 22px))) minmax(0, 1fr);
  }
  .board-shell {
    width: min(100%, max(442px, calc(var(--board-size) + 22px)));
    min-width: 442px;
  }

  /* The move list is the flexible row in the notation panel. */
  .notation-body { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .notation-box .tree-actions { margin: 0; }
  .notation-box .moves { min-height: 0; height: auto; }

  /* Each engine line has rank, evaluation and PV text in one row. */
  .engine-pv li { grid-template-columns: max-content max-content minmax(0, 1fr); }
  .engine-pv li > .engine-line-rank { grid-column: 1; white-space: nowrap; }
  .engine-pv li > strong { grid-column: 2; white-space: nowrap; }
  .engine-pv li > span:last-child { grid-column: 3; min-width: 0; }
}

/* User-sized desktop columns. The separators overlay the grid boundaries so
   they do not consume a content track or disturb the mobile stack. */
.workspace-column-resizer { display: none; }
@media (max-width: 1023px) {
  .workspace-column-resizer { display: none; }
}
@media (min-width: 1024px) {
  .workbench,
  .workbench.is-library-collapsed {
    --library-width: 240px;
    --library-track-width: var(--library-width);
    --games-width: 320px;
    position: relative;
    grid-template-columns: var(--library-track-width) var(--games-width) minmax(0, 1fr);
  }
  .workbench.is-library-collapsed { --library-track-width: 44px; }

  .workspace-scroll-pane {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
  .workspace-scroll-pane-library { min-width: 240px; overscroll-behavior: contain; }
  .workspace-scroll-pane-games { min-width: 320px; overscroll-behavior: contain; }
  .workspace-scroll-pane-detail { min-width: 320px; overscroll-behavior: contain; }
  .workbench.is-library-collapsed .workspace-scroll-pane-library { min-width: 44px; }
  .library-explorer { overflow: visible; }

  .workspace-column-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 25;
    display: block;
    width: 12px;
    padding: 0;
    border: 0;
    transform: translateX(-50%);
    background: transparent;
    cursor: col-resize;
    touch-action: none;
  }
  .workspace-column-resizer::before {
    position: absolute;
    inset: 0 5px;
    background: color-mix(in srgb, var(--green) 45%, var(--line));
    content: '';
    opacity: .42;
    transition: inset .12s ease, opacity .12s ease, background .12s ease;
  }
  .workspace-column-resizer:hover::before,
  .workspace-column-resizer.is-resizing::before,
  .workspace-column-resizer:focus-visible::before {
    inset-inline: 3px;
    background: var(--lime);
    opacity: 1;
  }
  .workspace-column-resizer:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
  }
  #resize-library-games { left: var(--library-track-width); }
  #resize-games-detail { left: calc(var(--library-track-width) + var(--games-width)); }
  .workbench.is-library-collapsed #resize-library-games { display: none; }
  body.is-resizing-columns { cursor: col-resize; user-select: none; }
}

/* Wide detail split: the board and the notation/engine stack share a third
   persisted separator. It only appears when both sides can retain useful
   working widths; narrower layouts keep their responsive automatic split. */
@media (min-width: 1280px) {
  .board-stage,
  .board-stage.is-notation-collapsed,
  .board-stage.is-engine-collapsed,
  .board-stage.is-notation-collapsed.is-engine-collapsed {
    --board-panel-width: 442px;
    position: relative;
    height: var(--board-panel-width);
    min-height: 360px;
    flex-basis: var(--board-panel-width);
    grid-template-columns: 20px minmax(360px, var(--board-panel-width)) minmax(320px, 1fr);
  }
  .board-shell {
    width: var(--board-panel-width);
    min-width: 360px;
  }
  .workspace-column-resizer-board-detail {
    top: 0;
    bottom: 0;
    left: calc(32px + var(--board-panel-width));
  }
  .game-detail:has(#panel-explorer[open]) .workspace-column-resizer-board-detail { display: none; }
  .game-detail:has(#panel-explorer[open]) .board-stage {
    height: clamp(420px, 52vh, 640px);
    min-height: 420px;
    grid-template-columns: 20px minmax(442px, 1fr);
  }
}

/* When resizing leaves the engine stack narrow, keep rank and score together
   and give the principal variation a full line of its own. This avoids the
   staggered text columns visible in a squeezed analysis pane. */
.engine-box { container-type: inline-size; }
@container (max-width: 520px) {
  .engine-pv li {
    grid-template-columns: max-content minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 3px;
  }
  .engine-pv li > .engine-line-rank { grid-column: 1; grid-row: 1; }
  .engine-pv li > strong { grid-column: 2; grid-row: 1; }
  .engine-pv li > span:last-child {
    grid-column: 1 / -1;
    grid-row: 2;
    overflow-wrap: anywhere;
    text-align: left;
  }
}
