/* Balance Equations */
/* wide frame: the moves on the left, the balance in the middle, the working on the right */
.bl-body{display:grid;grid-template-columns:15em minmax(0,1fr) 15.5em;grid-template-rows:minmax(0,1fr);grid-template-areas:"moves stage side"}
.bl-moves{grid-area:moves;display:flex;flex-direction:column;gap:.42em;padding:.65em .6em;background:#fff;border-right:2px solid var(--ink);overflow:auto;min-height:0}
.bl-moves .btn{justify-content:flex-start;gap:.5em;padding:.25em .6em;white-space:normal;text-align:left;line-height:1.12;font-size:.92em;min-height:max(2.6em,42px)}
.bl-moves .toggle{margin-bottom:.25em}
.bl-ico{flex:none;width:1.35em;height:1.35em;overflow:visible}
.btn.ready{background:var(--gold);box-shadow:0 0 0 3px #fff,0 0 0 5px var(--gold)}
.btn.ready:hover{background:#ffc93d}
/* "Show me": the tool makes the moves itself */
.bl-show{display:flex;flex-direction:column;gap:.3em;margin-top:.35em;padding-top:.45em;border-top:2px dashed var(--grid-strong)}
.bl-show>.ctl-label{padding-left:.15em}
.bl-show-btns{display:flex;gap:.4em}
.bl-show-btns .btn{flex:1 1 0;min-width:0;justify-content:center;text-align:center;padding:.25em .4em}
.bl-show.in-bar{flex-direction:row;align-items:center;gap:.45em;margin:0;padding:0;border:0}
.bl-show.in-bar .bl-show-btns{gap:.55em}
.bl-show.in-bar .btn{flex:none;padding:0 .9em}
#stage{grid-area:stage;display:flex;flex-direction:column;min-width:0;min-height:0}
.bl-side{grid-area:side;width:auto;padding:.85em .7em .7em;display:flex}

/* ---- the equation, the bin and the message ---- */
.bl-top{flex:none;display:flex;align-items:center;gap:.6em;height:3.4em;padding:.35em .7em 0}
.bl-bin{flex:none;width:3.6em;height:3.3em;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;font:700 .86em/1 var(--font-head);color:var(--soft)}
.bl-bin svg{width:2.7em;height:2.9em;overflow:visible}
.bl-bin span{margin-top:.1em;font-size:1.05em}
.bl-lid{transform-box:fill-box;transform-origin:8% 100%;transition:transform .16s}
.bl-bin.open .bl-lid{transform:rotate(-32deg) translate(-.05em,-.08em)}
.bl-bin.open svg>path:first-of-type{fill:#12a5b3}
.bl-bin.gulp svg{animation:bl-gulp .32s}
@keyframes bl-gulp{0%{transform:none}35%{transform:scale(1.12,.9)}70%{transform:scale(.96,1.05)}100%{transform:none}}
.bl-pad{flex:none;width:3.1em}
.bl-eqbox{flex:1;min-width:0;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}
.bl-eq{display:inline-flex;align-items:baseline;gap:.32em;white-space:nowrap;line-height:1.1;font:700 40px/1.1 var(--font-head);color:var(--ink);font-variant-numeric:tabular-nums}
.eq-s{display:inline-flex;align-items:baseline;gap:.22em}
.bl-eq .x,.bl-work .x,.own-card .x{color:var(--blue);font-style:italic;font-weight:700;padding-right:.04em}
.bl-eq .num+.x,.own-eq .num+.x{margin-left:-.2em}
.bl-eq .rel{display:inline-block;min-width:.7em;text-align:center}
.bl-eq .rel.no{color:var(--red)}
.bl-msg{flex:none;margin:0 auto;max-width:44em;height:2.4em;padding:0 .8em;display:flex;align-items:center;justify-content:center;text-align:center;
  font:400 .95em/1.25 var(--font-body);color:var(--soft);text-wrap:balance;overflow:hidden}
.bl-msg.hint{color:var(--ink);font-weight:700}
.bl-msg.hint::before{content:"";flex:none;width:.55em;height:.55em;margin-right:.5em;border-radius:50%;background:var(--gold);box-shadow:0 0 0 2px var(--ink)}
.bl-msg.good{color:var(--green);font-weight:700}
.bl-msg.bad{color:var(--red);font-weight:700}

/* ---- the picture ---- */
.bl-pic{flex:1;min-height:0;position:relative}
.bl-pic>svg{position:absolute;inset:0;width:100%;height:100%;display:block}
#bal .bl-item{cursor:grab;outline:none}
#bal .bl-item:focus-visible .bl-body-g{filter:drop-shadow(0 0 2px #fff) drop-shadow(0 0 3px var(--blue)) drop-shadow(0 0 2px var(--blue))}
#bal .bl-inbag{cursor:default}
#bal .bl-tag{transition:opacity .25s;pointer-events:none}
#bal .bl-sign,#bal .bl-stand,#bal .bl-beam{pointer-events:none}
.bl-fly{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;z-index:40;overflow:visible}
/* while nothing flies, the cover is not there: else Chrome's compositor takes its touch-action (manipulation, from the
   frame) for the picture, not the picture's "none", and can start to scroll the page under a finger that drags a thing */
.bl-fly:empty{display:none}
.bl-fly .held{filter:drop-shadow(3px 7px 5px rgba(20,26,34,.3))}
@media (prefers-reduced-motion:reduce){.bl-lid,#bal .bl-tag{transition:none}.bl-bin.gulp svg{animation:none}}

/* ---- the working: a page of an exercise book ---- */
.bl-book{position:relative;flex:1;min-height:0;display:flex;border:2px solid var(--ink);border-radius:.7em;background:#fff}
.bl-book::before{content:"";position:absolute;top:0;bottom:0;left:2em;border-left:2px solid rgba(217,56,30,.45);pointer-events:none}
.bl-cap{position:absolute;top:-.78em;left:.9em;margin:0;padding:0 .4em;background:#fff;font:600 .8em/1.4 var(--font-head);color:var(--soft);white-space:nowrap;z-index:1}
.bl-work{flex:1;min-width:0;overflow:auto;padding:.55em .5em .5em 2.3em;display:grid;grid-template-columns:1fr auto 1fr;align-content:start;
  font:700 1.22em/1 var(--font-head);color:var(--ink);overscroll-behavior:contain;scroll-behavior:smooth}
.bl-work .wl,.bl-work .wn,.bl-work .wbad{grid-column:1/-1;display:grid;grid-template-columns:subgrid;align-items:center}
.bl-work .wl{height:1.9em;border-bottom:1px solid var(--grid-strong);border-radius:.2em}
.bl-work .wl.now{background:var(--blue-tint)}
.wl-l{justify-self:end;white-space:nowrap;padding-left:.2em}
.wl-r{justify-self:start;white-space:nowrap;padding-right:.2em}
.wl-eq{padding:0 .35em}
.bl-work .wn{height:1.25em;font-size:.68em;color:var(--red)}
.wn-l{justify-self:end;padding-right:.15em}
.wn-r{justify-self:start;padding-left:.15em}
.bl-work .wbad{height:1.8em;margin-top:.25em;color:var(--red);border:2px dashed #f2a493;border-radius:.4em;opacity:.9}
.wbad-note{grid-column:1/-1;margin:.25em 0 0;font:600 .62em/1.25 var(--font-body);color:var(--red);text-align:center}
.wck-head{grid-column:1/-1;margin:.7em 0 .1em;font:600 .62em/1.3 var(--font-head);color:var(--soft);text-align:center}
.bl-work .wl.wck{color:var(--green);border-bottom-color:var(--grid)}
.bl-work .tick{margin-left:.35em;font-size:1.1em}

/* ---- make your own ---- */
.bl-own{position:absolute;inset:0;z-index:30;display:flex;align-items:center;justify-content:center;padding:.8em;background:rgba(244,247,251,.85)}
.bl-own[hidden]{display:none}
.own-card{max-width:100%;max-height:100%;overflow:auto;background:#fff;border:2px solid var(--ink);border-radius:.8em;padding:.8em 1.1em 1em;
  box-shadow:0 .3em 1.2em rgba(20,26,34,.2);display:flex;flex-direction:column;gap:.55em}
.own-card h2{margin:0;font-size:1.15em}
.own-row{display:flex;flex-wrap:wrap;align-items:center;gap:.35em .5em;font:600 1em var(--font-head)}
.own-name{width:5.2em;color:var(--soft);font-size:.9em}
.own-row .stepper input{width:2.6ch}
.own-row>.x{font-size:1.3em}
.own-calc{display:inline-flex;align-items:baseline;gap:.25em}
.own-d{min-width:1.6em;padding:.2em .35em;border:2px dashed var(--grid-strong);border-radius:.5em;text-align:center;font:700 1.2em var(--font-head)}
.own-d.bad{color:var(--red);border-color:var(--red)}
.own-hint{color:var(--soft);font-size:.85em}
.own-prev{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:center;gap:.2em .5em;min-height:2em;font:700 1.5em var(--font-head)}
.own-prev .lbl{font:600 .55em var(--font-head);color:var(--soft)}
.own-eq{display:inline-flex;align-items:baseline;gap:.25em;white-space:nowrap}
.own-msg{margin:0;min-height:2.6em;font:400 .95em/1.3 var(--font-body);color:var(--soft)}
.own-msg.bad{color:var(--ink);background:var(--gold-tint);border:2px solid var(--ink);border-radius:.6em;padding:.35em .7em;font-weight:700}
.own-btns{display:flex;flex-wrap:wrap;gap:.5em;justify-content:flex-end}

/* ---- narrow frame (tablet, phone): the balance on top, then the moves, then the working ---- */
@container (max-width:1000px){
  .bl-body{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto auto;grid-template-areas:"stage" "moves" "side"}
  .bl-moves{flex-direction:row;flex-wrap:wrap;justify-content:center;align-items:center;border-right:0;border-top:2px solid var(--ink);padding:.45em .5em;overflow:visible}
  .bl-moves .toggle{margin-bottom:0}
  .bl-moves .bl-show{flex-direction:row;align-items:center;gap:.45em;margin:0;padding:0 0 0 .5em;border-top:0;border-left:2px dashed var(--grid-strong)}
  .bl-show-btns .btn{flex:none;padding:.25em .7em}
  .bl-side{height:8.6em;border-left:0;border-top:2px solid var(--ink);padding:.8em .6em .5em}
}
@container (max-width:560px){
  #bar{gap:.4em .45em}
  #bar .btn{padding:0 .6em;min-width:max(2.5em,40px)}
  #bar>.ctl>.ctl-label{display:none}
  .tool-app{padding-bottom:1em}
  .bl-body{border-bottom:2px solid var(--ink)}
  .bl-top{height:2.7em;padding:.25em .45em 0;gap:.3em}
  .bl-bin{font-size:.78em;width:3.4em;height:3.2em}
  .bl-pad{width:2.4em}
  .bl-msg{height:2.6em;font-size:.86em;padding:0 .5em}
  .bl-moves{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.32em;padding:.4em}
  .bl-moves .btn{font-size:.84em;padding:.2em .4em;justify-content:center;text-align:center;gap:.3em;min-height:max(2.9em,40px)}
  .bl-moves .bl-ico{width:1.2em;height:1.2em}
  .bl-moves .bl-show,.bl-moves .bl-show-btns{display:contents}
  .bl-moves .bl-show>.ctl-label{display:none}
  .bl-side{height:7.2em;padding:.75em .45em .4em}
  .bl-work{font-size:1.1em;padding-left:2.1em}
  .bl-book::before{left:1.8em}
  .own-name{width:100%}
}
