/* Review-only layout: evidence and choices have reserved space, independent of the board. */
body[data-step=review] .steps{display:none}
body[data-step=review] main{padding:6px 10px max(6px,env(safe-area-inset-bottom))}
body[data-step=review] .studio-review-heading{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 6px;padding:0 2px 4px}
body[data-step=review] .studio-review-heading>div:first-child{display:contents}
body[data-step=review] .studio-review-heading h2{font-size:1rem;margin:0;grid-column:1;grid-row:1}
body[data-step=review] .studio-review-heading .studio-tools{grid-column:2;grid-row:1}
body[data-step=review] .studio-review-heading .review-summary{grid-column:1/-1;grid-row:2;margin:0}
body[data-step=review] .studio-tools button{min-height:44px;font-size:.75rem;padding:8px}
body[data-step=review] .review-summary{display:block;line-height:1.4}
body[data-step=review] .review-summary:has(>#full-reread:not([hidden])){display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:8px}
body[data-step=review] #full-reread{min-height:44px;margin:0;padding:6px 12px;font-size:.875rem;color:#ffe1a2;background:#302616;border-color:#8b7240}
body[data-step=review] #progress,body[data-step=review] #pending{font-size:.75rem}
body[data-step=review] #pending{display:inline}
body[data-step=review] .move-strip{display:flex;margin:3px 0 6px;min-height:48px}
body[data-step=review] .move-strip button{min-height:48px;min-width:83px;font-size:.875rem}
body[data-step=review] .move-strip button small{font-size:.6875rem}
body[data-step=review] .review-work{position:relative;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(222px,1fr) auto;align-content:start;align-items:stretch;gap:6px;overflow:auto;padding:0;min-height:0;overscroll-behavior:contain}
body[data-step=review] .review-work>.position-pane{height:100%;min-height:222px;align-self:stretch;overflow:visible;container-type:size;display:flex;flex-direction:column;justify-content:safe center}
body[data-step=review] .board-wrap{width:202px;flex:none;margin:0 auto;padding:8px 7px 20px 20px}
@supports(width:1cqh){body[data-step=review] .review-work .board-wrap{width:min(calc(100cqw - 12px),max(140px,calc(100cqh - 44px)),360px)}}
body[data-step=review] .board-controls{width:100%;max-width:430px;min-height:40px;margin:2px auto;font-size:.6875rem}
body[data-step=review] .board-controls button{min-height:40px;margin:0}
body[data-step=review] .correction-pane{min-width:0;max-height:none;overflow:visible}
body[data-step=review] .focus{padding:8px 10px;border-radius:14px;border-left:4px solid var(--reading-color,#88c9ff)}
body[data-step=review] .focus-heading{min-height:36px;gap:5px;margin:0 0 3px;flex-wrap:wrap}
body[data-step=review] .focus-heading #move-label{font-size:.75rem;letter-spacing:0;color:var(--text)}
body[data-step=review] #zoom-row{min-height:44px;margin:-4px 0;font-size:.75rem;padding:5px}
body[data-step=review] .fragment-labels{display:grid;font-size:.6875rem;margin:0 0 2px}
body[data-step=review] #fragment{height:64px;max-height:64px;margin:0 0 4px}
body[data-step=review] #fragment-empty{font-size:.75rem;margin:0 0 5px;padding:8px}
body[data-step=review] #photo-page-label{font-size:.6875rem;margin:0 0 4px}
body[data-step=review] #photo-page-label:empty{display:none}
body[data-step=review] .suggestion-row{gap:5px}
body[data-step=review] #options{grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
body[data-step=review] #options button{min-width:0;min-height:56px;font-size:1.125rem;padding:6px 3px}
body[data-step=review] #options small{font-size:.6875rem;white-space:normal;overflow-wrap:anywhere}
body[data-step=review] #more-options{min-width:44px;min-height:56px}
body[data-step=review] .suggestion-row #open-correction{min-height:56px;width:60px;font-size:.75rem}
body[data-step=review] .suggestion-row.without-options #options{display:none}
body[data-step=review] .suggestion-row.without-options #open-correction{width:100%;font-size:.875rem}
body[data-step=review] .reading-actions{margin-top:5px;min-height:0}
.reading-footer{display:flex;align-items:center;gap:8px;justify-content:space-between;margin-top:4px}
body[data-step=review] .reading-footer p{font-size:.6875rem;line-height:1.35;margin:0;min-width:0}
body[data-step=review] #open-reading-tools{flex-shrink:0;min-height:44px;padding:5px 8px;font-size:.75rem;background:transparent;border-color:transparent;color:var(--gold)}
#studio-content #reading-tools .reading-actions{display:grid;grid-template-columns:1fr;gap:10px}
#studio-content #reading-tools button{width:100%;min-height:48px;white-space:normal}
body[data-step=review] #options-help{font-size:.75rem;line-height:1.35}
body[data-step=review] .review-dock{display:block;margin-top:6px;padding-top:5px}
body[data-step=review] .review-navigation{grid-template-columns:minmax(48px,.65fr) 44px minmax(66px,1fr) 44px minmax(82px,1fr);gap:5px}
body[data-step=review] .review-navigation #save-game{font-weight:700;background:var(--gold);border-color:var(--gold);color:#1a140a}
.review-navigation .play-symbol{display:none}
body[data-step=review] .review-navigation button{min-height:48px}
body[data-step=review] .review-navigation #next-pending{font-size:.8125rem;color:#ffe1a2;background:#302616;border-color:#8b7240}
body[data-step=review] .review-navigation #play{background:#242019;border-color:#69583b;color:var(--text);font-size:.875rem}
body[data-step=review] .review-navigation #play[aria-pressed=true]{background:#483a20;color:#fff5db}
body[data-step=review] .review-commit{grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;margin-top:3px}
body[data-step=review] .review-commit button{min-height:44px;background:transparent;border-color:transparent;font-size:.75rem}
body[data-step=review] #navigation-position{display:flex;grid-column:auto;position:static;clip-path:none;width:auto;height:auto;min-height:44px;justify-content:center;font-size:.8125rem;color:var(--text)}
body[data-step=review] #end-here{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:2px;border-color:#69583b;color:#ffe1a2;padding:4px;line-height:1.2}
body[data-step=review] #end-here #navigation-position{min-height:0;font-size:.6875rem}
#end-result{width:100%;margin:4px 0 12px}
body[data-step=review] #suggested-end{flex:none;min-height:44px;margin:0 0 4px;padding:6px 10px;font-size:.8125rem;text-align:left;color:#ffe1a2;border-color:#8b7240;background:#302616}
#end-controls:has(#end-evidence:not([hidden]))>p:first-of-type{display:none}

/* Status, selection and focus are independent signals, never colour alone. */
[data-state=proposal]{--reading-color:#88c9ff;--reading-bg:#142631}
[data-state=doubt]{--reading-color:#f1ca76;--reading-bg:#302616}
[data-state=unreadable],[data-state=conflict]{--reading-color:#ffaaa0;--reading-bg:#3b1e20}
[data-state=blocked]{--reading-color:#c0c4cb;--reading-bg:#24252a}
[data-state=confirmed]{--reading-color:#90dfad;--reading-bg:#163023}
body[data-step=review] .review-mark{font-size:.75rem;color:var(--reading-color);font-weight:600}
body[data-step=review] .move-strip button[data-state],#sequence .move-row button[data-state]{border-left:3px solid var(--reading-color);background:var(--reading-bg)}
body[data-step=review] .move-strip button[data-state] small,#sequence .move-row button[data-state] small{color:var(--reading-color)}
body[data-step=review] .move-strip button[aria-current],#sequence .move-row button[aria-current]{color:var(--text);outline:2px solid #f4efe6;outline-offset:-2px;box-shadow:none}
body[data-step=review] #resolve-earlier{font-size:.8125rem;color:#f4efe6;border-color:#8b929e}
body[data-step=review] #repair-photo-gaps{min-height:44px;font-size:.8125rem;margin:4px 0}

/* Same live canvas and controls in the panel; no stale screenshot or duplicate draft. */
#studio-dialog[open]{display:flex;flex-direction:column}
#studio-dialog .sheet-heading{position:static;flex:none}
#studio-content{min-height:0;overflow:auto;overscroll-behavior:contain}
#studio-content #reading-evidence{position:sticky;top:0;z-index:1;background:#161411;padding:0 0 8px;margin:0 0 8px}
#studio-content #reading-evidence:has(#photo-fallback:not([hidden])){position:static}
#studio-content .focus-heading{flex-wrap:wrap}
#studio-content #fragment{height:90px;max-height:90px}
#studio-content #options,#studio-content #extra-options{margin:6px 0;gap:7px}
#studio-content #options button,#studio-content #extra-options button{min-width:0;min-height:56px;font-size:1.125rem}
#studio-content .options small{font-size:.75rem;white-space:normal}
#studio-content #extra-options{border-top:1px solid #605031;padding-top:12px}
#studio-content #position-pane{height:auto;container-type:normal;overflow:visible}
#studio-content #position-pane .board-wrap{width:min(100%,430px)}
#studio-content #position-pane .board-controls{min-height:44px}

@media(min-width:760px){
 body[data-step=review] main{padding:12px 22px}
 body[data-step=review] .review-work{grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:minmax(222px,1fr);gap:22px}
 body[data-step=review] .correction-pane{align-self:center}
 body[data-step=review] #fragment{height:90px;max-height:90px}
 body[data-step=review] .review-dock{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:20px}
 body[data-step=review] .review-commit{margin:0}
}
/* Short screens and large text scroll from the top. Neither the board nor the
   photo is hidden to make the controls fit; navigation remains outside this area. */
@media(max-height:590px) and (max-width:759px){
 body[data-step=review] .correction-pane{align-self:start;width:100%}
 body[data-step=review] .move-strip{min-height:44px;margin-bottom:4px}
 body[data-step=review] #fragment{height:52px;max-height:52px}
}
/* Content can reflow at large text sizes; never clip the only recovery controls. */
@media(max-height:450px){
 #studio-content #reading-evidence{position:static}
}
/* When the viewport cannot contain the minimum board, let the page scroll as
   one surface instead of creating a viewport shorter than the board itself. */
@media(max-height:740px){
 body[data-step=review]{height:auto;min-height:100dvh;overflow:auto;padding-bottom:0}
 body[data-step=review] main{height:auto;min-height:100dvh}
 body[data-step=review] .workspace,body[data-step=review] .review-panel{height:auto;min-height:0;flex:none}
 body[data-step=review] .review-work{flex:none;overflow:visible;grid-template-rows:auto;align-items:start}
 body[data-step=review] .review-work>.position-pane{height:240px;min-height:240px}
 body[data-step=review] .correction-pane{align-self:start}
 body[data-step=review] .review-dock{position:sticky;bottom:0;z-index:6;background:#0b0a08}
}

/* Keep each square legible on a phone. The evidence and board share a scroll
   surface while navigation stays reachable independently on tall screens. */
@media(max-width:759px) {
 body[data-step=review] .review-work {display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start}
 body[data-step=review] .review-work>.position-pane {display:block;flex:none;order:0;height:auto;min-height:0;container-type:normal}
 body[data-step=review] .review-work>.correction-pane {flex:none;order:1;align-self:stretch}
 body[data-step=review] .review-work .board-wrap,
 body[data-step=review] .review-work:has(#resolve-earlier:not([hidden])) .board-wrap {
  width:min(100%,440px);max-width:100%;min-width:0
 }
 body[data-step=review] .board-controls button {min-height:44px}
 body[data-step=review] .review-work #go-to-reading {display:inline-block;color:var(--gold)}
}
#go-to-reading {display:none}
#review-actions-toggle {display:none}
@media(min-height:741px) {
 /* The workspace scrolls here. Keep focus changes inside it, including on
    the visually hidden live status after comparing or correcting a move. */
 html:has(>body[data-step=review]) {overflow:clip}
}
@media(max-width:759px) and (orientation:portrait) {
 body[data-step=review] main {padding-bottom:0}
 body[data-step=review] .review-dock {margin-top:2px;padding-top:2px}
 body[data-step=review] .review-navigation {grid-template-columns:minmax(44px,.85fr) 44px 44px 44px minmax(49px,1.25fr) minmax(48px,.85fr);gap:3px}
 .review-navigation #play-label {display:none}
 .review-navigation .play-symbol {display:inline}
 .review-navigation .play-symbol::before {content:"▶"}
 .review-navigation [aria-pressed=true] .play-symbol::before {content:"Ⅱ"}
 body[data-step=review] .review-navigation button {padding-inline:3px;overflow-wrap:anywhere}
 body[data-step=review] #review-actions-toggle {display:block;font-size:.78rem}
 body[data-step=review] .review-dock:has(#review-actions-toggle[aria-expanded=false]) .review-commit {display:none}
 /* Place the paper directly after the board; the row and its choices stay
    together. Dialogs and the fallback for a missing crop keep their layout. */
 .review-work #reading-evidence:has(>#fragment:not([hidden])) {display:flex;flex-direction:column}
 .review-work #reading-evidence:has(>#fragment:not([hidden]))>.fragment-labels {order:-2}
 .review-work #reading-evidence:has(>#fragment:not([hidden]))>#fragment {order:-1;flex:none}
}
/* When there is room for only one of the two, show the photographed row
   first. The board keeps its full width further down the same scroll area. */
@media(max-width:759px) and (max-height:740px) and (orientation:portrait) {
 body[data-step=review] .review-work:has(#fragment:not([hidden]))>.correction-pane {order:-1}
}
@media(max-width:759px) and (min-height:741px) and (orientation:portrait) {
 body[data-step=review] .review-work {container:review-area / size}
 @container review-area (min-aspect-ratio: 7/10) {
  .review-work>.correction-pane:has(#fragment:not([hidden])) {order:-1}
 }
}
@media(min-width:760px) {
 body[data-step=review] .review-work>.position-pane {display:block;height:auto;min-height:0;container-type:normal;align-self:start}
 body[data-step=review] .review-work .board-wrap {width:min(100%, max(260px, calc(100dvh - 270px)), 500px)}
}
@media(min-width:620px) and (max-width:759px) and (orientation:landscape) {
 body[data-step=review] .review-work {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.15fr);align-items:start;gap:10px}
 body[data-step=review] .review-work .board-wrap,
 body[data-step=review] .review-work:has(#resolve-earlier:not([hidden])) .board-wrap {width:min(100%,max(210px,calc(100dvh - 104px)))}
}
@media(min-width:760px) and (max-width:900px) and (min-height:1000px) and (orientation:portrait) {
 body[data-step=review] .review-work {grid-template-columns:minmax(0,620px);grid-template-rows:max-content max-content;justify-content:center;align-content:start}
 body[data-step=review] .review-work>.position-pane {width:100%}
}
