/* The full batch sits inside a deeper tray, using the supplied illustrated rim.
   Nine-slicing keeps its corners intact at different grid proportions. */
.pair-builder .source-tray{position:relative;aspect-ratio:auto;min-height:0;height:auto;background:none;box-shadow:none}
.pair-builder .source-cookies{position:relative;overflow:visible}
.work-content .pair-builder .source-tray{
  box-sizing:content-box;aspect-ratio:auto;height:auto;width:max-content;max-width:none;margin:0 auto;
  padding:2px;border:16px solid transparent;
  border-image:url('assets/art/cookie-kitchen-v1/tray_blue.webp') 74 105 58 105 fill / 16px / 0 stretch;
  filter:drop-shadow(0 4px 2px #78532b33);
}
.work-content .pair-builder .shelf{
  display:grid;grid-template-columns:repeat(var(--source-cols,5),var(--source-unit,48px));
  grid-template-rows:repeat(var(--source-rows,4),var(--source-unit,48px));
  gap:4px;min-height:0;padding:0;margin:0;overflow:visible;border:0;background:none;box-shadow:none;
}
.work-content .pair-builder:not(.demo-builder) .cookie-btn{
  width:var(--source-unit,48px);height:var(--source-unit,48px);max-width:none;min-width:44px;min-height:44px;
}
.work-content .pair-builder .selected-label{bottom:0;font-size:10px;line-height:1.1;padding:2px 4px;white-space:nowrap}
.work-content .pair-builder .empty-shelf{grid-column:1/-1;grid-row:1/-1;margin:0;padding:2px;font-size:12px;line-height:1.2}
body[data-family=CC-A][data-stage=arrange] .pair-builder{max-width:none}
body[data-family=CC-A][data-stage=arrange] .placement-copy{grid-column:1/-1}
body[data-family=CC-A][data-stage=arrange] .pair-work{max-width:none}
body[data-family=CC-A][data-stage=arrange] .source-surface{align-self:center;background:none;box-shadow:none}
body[data-family=CC-A][data-stage=arrange] .pair-builder .active-pair{align-self:center;max-width:240px}
body[data-family=CC-A][data-stage=arrange] .pair-builder .placement-hint{height:3.9em;min-height:0}
body[data-family=CC-A][data-stage=arrange] .pair-rack{--pair-cell:64px}
body[data-family=CC-A][data-stage=arrange] .pair-rack[data-columns="2"]{--pair-cell:60px}

/* Tall desktop: full tray above the two serving plates, beside completed pairs. */
body[data-family=CC-A][data-pair-layout=wide][data-stage=arrange] .work-content{grid-template-columns:minmax(0,1.8fr) minmax(244px,1fr);grid-template-rows:auto auto minmax(0,1fr)}
body[data-family=CC-A][data-pair-layout=wide][data-stage=arrange] .work-content .pair-builder{height:100%;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto;align-content:center;gap:16px;align-self:stretch}
body[data-family=CC-A][data-pair-layout=wide][data-stage=arrange] .pair-work{grid-column:2;grid-row:3}
body[data-family=CC-A][data-pair-layout=wide][data-stage=arrange] .source-tray{border-width:20px;border-image-width:20px}
body[data-family=CC-A][data-pair-layout=wide][data-stage=arrange] .source-surface{width:100%}

/* Shorter/wider views: use the workbench width for source, plates, and pairs. */
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .work-content{grid-template-columns:minmax(0,1.9fr) minmax(128px,.85fr) minmax(196px,1.1fr);grid-template-rows:auto auto minmax(0,1fr);gap:8px 14px}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .pair-builder{display:contents}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .work-title{grid-column:1/3}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .placement-copy{grid-column:1/3}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .source-surface{grid-column:1;grid-row:3}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .active-pair{grid-column:2;grid-row:3}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .pair-work{grid-column:3;grid-row:1/4}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .pair-rack{--pair-cell:52px}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .pair-rack[data-columns="2"]{--pair-cell:44px}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .pair-rack .undo-pair{min-width:44px;min-height:44px}

/* Phone: source spans the top; serving plates and growing pairs share the bottom.
   Empty serving sides reserve only one row, not five invisible rows. */
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .work-content{grid-template-columns:minmax(0,1fr) 148px;grid-template-rows:auto auto auto minmax(0,1fr);gap:6px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .work-content:has(.pair-rack[data-columns="2"]){grid-template-columns:minmax(0,1fr) 196px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-builder{display:contents}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .source-surface{grid-column:1/-1;grid-row:3;align-self:start}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-builder .active-pair{grid-column:1;grid-row:4;align-self:end;margin:0 auto;max-width:180px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-work{grid-column:2;grid-row:4;align-self:end}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-rack{--pair-cell:52px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-rack[data-columns="2"]{--pair-cell:44px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-rack .undo-pair{min-width:44px;min-height:44px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .active-pair-slots{gap:4px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-builder .pair-slot{min-width:44px;min-height:62px;padding:0}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-builder .surface-label{font-size:10px;line-height:14px;margin-bottom:3px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pairs-label{display:none}
.demo-builder .source-cookies{height:auto}

/* A clear recipe cue above the objects. Equal side tracks keep the desktop
   heading centered independently of Undo; narrower views retain its touch area. */
body[data-family=CC-A][data-stage=arrange] .work-content>.work-title{
 display:grid;grid-template-columns:104px minmax(0,1fr) 104px;align-items:center;
}
body[data-family=CC-A][data-stage=arrange] .work-content>.work-title h2{
 grid-column:2;justify-self:center;text-align:center;font-size:34px;line-height:1.1;
 padding:8px 18px 10px;
}
body[data-family=CC-A][data-stage=arrange] .work-content>.work-title button{grid-column:3;justify-self:end}
body[data-family=CC-A][data-stage=arrange] .placement-copy{
 text-align:center;padding:8px 12px;border-radius:12px;
 background:linear-gradient(90deg,transparent,#fff5dca8 24% 76%,transparent);
}
body[data-family=CC-A][data-stage=arrange] .placement-copy .placement-instruction{
 font-size:20px;line-height:1.25;font-weight:800;color:#50331f;margin:0 0 4px;
 text-shadow:0 1px 0 #fff5df;
}
body[data-family=CC-A][data-stage=arrange] .placement-copy .input-guidance{
 font-size:16px;line-height:1.3;font-weight:600;color:#593e29;margin:0;
}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .work-content>.work-title,
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .work-content>.work-title{grid-template-columns:minmax(0,1fr) auto}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .work-content>.work-title h2{grid-column:1;font-size:28px;padding:7px 12px 9px}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .work-content>.work-title button,
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .work-content>.work-title button{grid-column:2}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .placement-copy{padding:3px 6px}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .placement-copy .placement-instruction{font-size:18px;margin-bottom:3px}
body[data-family=CC-A][data-pair-layout=compact][data-stage=arrange] .placement-copy .input-guidance{font-size:15px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .work-content>.work-title h2{grid-column:1;font-size:22px;padding:6px 9px 7px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .placement-copy{padding:2px 3px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .placement-copy .placement-instruction{font-size:15px;line-height:1.2;margin-bottom:3px}
body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .placement-copy .input-guidance{font-size:13px;line-height:1.25}

@media(min-width:701px) and (max-width:1100px){
 body[data-family=CC-A][data-pair-layout=wide][data-stage=arrange] .pair-rack[data-columns="2"]{--pair-cell:56px}
}
@media(max-height:800px){
 body[data-family=CC-A][data-pair-layout=phone][data-stage=arrange] .pair-rack{--pair-cell:44px}
}
.work-content .pair-builder .shelf:has(.empty-shelf){grid-template-columns:minmax(140px,1fr)}

/* Let cookies and their serving surfaces use the available workbench, while
   the existing footer continues to reserve a separate row for the action. */
body[data-family=CC-A][data-stage=arrange] .pair-builder .active-pair{max-width:380px}
body[data-family=CC-A][data-stage=arrange] .pair-builder .pair-slot{min-height:var(--serving-height,82px)}
body[data-family=CC-A][data-stage=arrange] .pair-builder .pair-slot .btn-content{height:calc(var(--serving-height,82px) - 10px)}
body[data-family=CC-A][data-stage=arrange] .pair-builder .pair-slot img{width:calc(var(--serving-height,82px) - 22px);height:calc(var(--serving-height,82px) - 22px)}
body[data-family=CC-A][data-stage=arrange] .pair-builder .placement-hint{height:3.9em}
body[data-family=CC-A] .work-content .pair-rack .plate-row .undo-pair{min-width:44px;min-height:44px}
@media(min-width:701px){
 body[data-family=CC-A] .work-content .pair-heads{font-size:15px;line-height:20px;margin-bottom:9px}
 body[data-family=CC-A] .work-content .pairs-label{font-size:12px;margin-bottom:8px}
 body[data-family=CC-A] .work-content .leftover-column{width:126px}
 body[data-family=CC-A] .work-content .leftover-heading{font-size:13px;line-height:20px;margin-bottom:9px}
 body[data-family=CC-A] .work-content .leftover-tray>span{height:calc(var(--leftover-cookie,80px) + 8px)}
 body[data-family=CC-A] .work-content .leftover-column img{width:var(--leftover-cookie,80px);height:var(--leftover-cookie,80px)}
 body[data-family=CC-A][data-pair-layout=wide][data-stage=arrange] .pair-builder .surface-label{font-size:12px;margin-bottom:6px}
}
@media(max-width:700px){
 body[data-family=CC-A][data-stage=arrange] .pair-builder .active-pair{max-width:180px}
 body[data-family=CC-A][data-stage=arrange] .pair-builder .pair-slot img{width:44px;height:44px}
}

body[data-family=CC-A][data-stage=arrange] .pair-builder .pair-slot .spot-mark{position:absolute;left:50%;bottom:var(--plate-mark-offset,6px);transform:translateX(-50%);margin:0}
body[data-family=CC-A][data-stage=arrange] .pair-builder .pair-slot img{width:var(--pending-cookie,52px);height:var(--pending-cookie,52px)}
/* An odd cookie shares the serving trays, opposite a visibly empty spot. */
.pair-rack .unmatched-row{display:contents}
body[data-view=game] .pair-rack .unmatched-row img{width:calc(var(--pair-cell) - 8px);height:calc(var(--pair-cell) - 8px);margin:0;filter:drop-shadow(0 3px 1px #76633945)}
.pair-rack .partner-space::before{content:"";position:absolute;inset:8px;border:2px dashed #73915e;border-radius:50%;background:#fff9e6aa;pointer-events:none}
.pair-rack .partner-space>span{position:relative;color:#435d34;font-size:clamp(10px,calc(var(--pair-cell) * .13),18px);line-height:1.15;text-align:center;font-weight:700}
.tutorial-mini .demo-partner-space{display:grid;place-content:center;width:48px;height:48px;border:2px dashed #73915e;border-radius:50%;color:#435d34;font-size:11px;line-height:1.1;background:#fff9e6}
.demo-two>div{max-width:190px}
/* Odd/Even are the actions at this step, so an empty footer need not take room
   away from the serving trays. */
body[data-family=CC-A][data-stage=parity] .workbench{grid-template-rows:minmax(0,1fr)}
body[data-family=CC-A][data-stage=parity] .check-area{display:none}
@media(max-width:700px) and (max-height:700px){
 body[data-family=CC-A][data-stage=parity] .parity-question h2{font-size:21px;line-height:1.2;margin:0 0 6px}
 body[data-family=CC-A][data-stage=parity] .parity-question p{font-size:12px;line-height:1.3;margin:0 0 10px}
 /* Keep the optional box decoration in one row, leaving room for the largest
    odd batch above it. Its buttons retain their full touch height. */
 body[data-view=game] .pair-result:has(.unmatched-row){padding:8px;gap:4px}
 .pair-result:has(.unmatched-row) .result-outcome{gap:4px}
 .pair-result:has(.unmatched-row) .result-label-board{grid-template-columns:44px minmax(0,1fr);padding:8px;gap:5px}
 .pair-result:has(.unmatched-row) .box-preview{width:44px;height:44px;margin:0}
 .pair-result:has(.unmatched-row) .box-options{grid-column:2;grid-row:1;gap:4px}
}
/* Keep the completed equation together beside larger cookies at narrow desktop
   widths; caption width must not force the total onto a second row. */
@media(min-width:701px) and (max-width:950px){
 body[data-family=CC-A] .work-content>.equation-area:not(.guided-count) .equation{flex-wrap:nowrap;gap:6px}
 body[data-family=CC-A] .work-content>.equation-area:not(.guided-count) .equation-term{gap:6px}
 body[data-family=CC-A] .work-content>.equation-area:not(.guided-count) .number-wrap{max-width:66px}
 body[data-family=CC-A] .work-content>.equation-area:not(.guided-count) .number-caption{font-size:11px;max-width:66px}
 body[data-family=CC-A] .work-content>.equation-area:not(.guided-count) .math-symbol{font-size:22px}
 body[data-family=CC-A] .work-content>.equation-area:not(.guided-count) .equation-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
 body[data-family=CC-A] .work-content>.equation-area:not(.guided-count) .equation-actions button{min-width:0;padding:5px;font-size:12px;min-height:48px}
}
