/* Counters */
.ct-main{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column}
/* the number sentence builder: a fixed height, so that the mat does not move when the text changes */
.ct-strip{flex:none;display:flex;align-items:center;gap:.45em 1em;height:calc(max(2.5em,42px) + 1.1em);padding:0 .7em;background:#fff;border-bottom:2px solid var(--ink);overflow:hidden}
.ct-eq{flex:1 1 auto;min-width:0;margin:0;font-size:1.75em;font-weight:700;line-height:1;white-space:nowrap;font-variant-numeric:tabular-nums}
.ct-eq .q{color:var(--soft)}
.ct-eq .ans{color:var(--blue);background:var(--blue-tint);border-radius:.2em;padding:0 .15em}
.ct-build{flex:none;display:flex;align-items:center;gap:.45em}
.ct-op .btn{font-size:1.25em;min-height:max(2em,42px);width:max(2em,42px);padding:0}
.ct-signed input{width:3.4ch}

/* the tray and the quick add buttons */
.ct-quick{position:absolute;z-index:3;display:flex;gap:6px}
.ct-quick.col{flex-direction:column}
.ct-qb{width:max(2.9em,46px);padding:0}
#mat .ct-trayb{fill:#fff;stroke:var(--ink);stroke-width:2;transition:fill .15s,stroke .15s}
#mat .ct-sep{stroke:var(--line);stroke-width:1.5}
#mat .ct-cellg{outline:none}
#mat .ct-cellg.tub{cursor:grab}
#mat .ct-cellbg{fill:transparent}
#mat .ct-cellg.tub:hover .ct-cellbg{fill:var(--desk)}
#mat .ct-cellg:focus-visible .ct-cellbg{stroke:var(--blue);stroke-width:3}
#mat .ct-tublab{font-family:Lexend,Arial,sans-serif;font-weight:700;fill:var(--soft);text-anchor:middle}
#mat .ct-bin{fill:none;stroke:var(--soft);stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
#mat.ct-over .ct-trayb{fill:var(--red-tint);stroke:var(--red)}
#mat.ct-over .ct-bin{stroke:var(--red)}
#mat.ct-over .bin .ct-tublab{fill:var(--red)}

/* the mat and the counters */
#mat .ct-board{fill:#fff;stroke:var(--ink);stroke-width:2}
#mat .ct-bandline{stroke:var(--line);stroke-width:1.5;stroke-dasharray:6 6}
#mat .ct-c{cursor:grab;outline:none}
#mat .ct-c:focus-visible .ct-disc{stroke:var(--blue);stroke-width:5}
#mat .ct-lifted{cursor:grabbing}
#mat .ct-ghost{fill:rgba(31,111,209,.1);stroke:var(--blue);stroke-width:2;stroke-dasharray:6 4;pointer-events:none}
#mat .ct-pulse{fill:none;stroke:var(--gold);pointer-events:none;animation:ct-pulse .6s ease-out forwards}
@keyframes ct-pulse{from{stroke-width:3;opacity:1}to{stroke-width:16;opacity:0}}
@media (prefers-reduced-motion:reduce){#mat .ct-pulse{animation:none;opacity:0}}
#mat .ct-pairring{fill:none;stroke:var(--ink);stroke-width:3;pointer-events:none}
#mat .ct-pairring.new{stroke:var(--blue);stroke-dasharray:8 5}
#mat .ct-badge{stroke:var(--ink);stroke-width:2;pointer-events:none}
#mat .ct-badgen{font-family:Lexend,Arial,sans-serif;font-weight:700;fill:#fff;text-anchor:middle;pointer-events:none}
#mat .ct-rowband{fill:var(--blue-tint);stroke:#bcd3f0;stroke-width:1.5;pointer-events:none}
#mat .ct-rembox{fill:var(--red-tint);stroke:var(--red);stroke-width:2;stroke-dasharray:7 5;pointer-events:none}
#mat .ct-arrlab{font-family:Lexend,Arial,sans-serif;font-weight:700;fill:var(--ink);text-anchor:middle;pointer-events:none}
#mat .ct-remlab{font-family:Lexend,Arial,sans-serif;font-weight:700;fill:var(--red);pointer-events:none}
.ct-msg{position:absolute;z-index:6;top:.6em;left:50%;transform:translateX(-50%);max-width:90%;padding:.45em .9em;background:var(--ink);color:#fff;border-radius:.6em;font-weight:600;font-size:.95em;text-align:center;pointer-events:none;transition:opacity .4s}
.ct-msg.out{opacity:0}

/* the side panel: counts, the mat, the steps */
#side{width:17em;gap:.55em}
.ct-count{display:flex;flex-direction:column;gap:.5em}
.ct-tiles{display:grid;grid-template-columns:1fr 1fr;border:2px solid var(--ink);border-radius:.7em;overflow:hidden;background:#fff}
.ct-tile{display:flex;flex-direction:column;text-align:center;min-width:0}
.ct-tile+.ct-tile{border-left:2px solid var(--ink)}
.ct-head{display:flex;align-items:center;justify-content:center;gap:.3em;padding:.28em .2em;font-weight:700;font-size:.95em}
.ct-tile.y .ct-head{background:#f5c021;color:var(--ink)}
.ct-tile.r .ct-head{background:var(--red);color:#fff}
.ct-dot{display:inline-grid;place-items:center;width:1.25em;height:1.25em;border-radius:50%;background:#fff;color:var(--ink);border:2px solid var(--ink);font-style:normal;font-size:.9em;line-height:1}
.ct-dot:empty{display:none}
.ct-n{font-size:2em;font-weight:700;line-height:1.15;padding:.02em 0;font-variant-numeric:tabular-nums}
.ct-total{display:flex;flex-direction:column;align-items:center;gap:.05em;padding:.25em .4em .4em;border:2px solid var(--ink);border-radius:.7em;background:#fff}
.ct-big{font-size:2.55em;font-weight:700;line-height:1.05;font-variant-numeric:tabular-nums}
.ct-big.hide{color:var(--soft)}
.ct-groups{display:flex;flex-wrap:wrap;justify-content:center;gap:.3em;margin:.1em 0}
.ct-g{display:inline-grid;place-items:center;min-width:2.1em;height:2.1em;padding:0 .35em;border-radius:1.05em;border:2px solid var(--ink);background:var(--c);color:#fff;font-weight:700;font-variant-numeric:tabular-nums}
/* the facts sit at the bottom of the total card (they are a separate element, so that a phone can give them a row) */
.ct-facts{margin:calc(-.5em - 2px) 0 0;padding:0 .4em .45em;display:flex;flex-direction:column;align-items:center;text-align:center;border:2px solid var(--ink);border-top:0;border-radius:0 0 .7em .7em;background:#fff;font-weight:600;color:var(--soft);font-size:.92em;line-height:1.3;font-variant-numeric:tabular-nums}
.ct-facts:empty{display:none}
.ct-total:has(+ .ct-facts:not(:empty)){border-bottom:0;border-radius:.7em .7em 0 0;padding-bottom:.15em}
.ct-facts span:first-child{color:var(--ink);font-weight:700;font-size:1.12em}
.ct-mats{display:flex;flex-direction:column;gap:.6em}
.ct-mats>.ctl{display:flex;flex-direction:column;align-items:stretch;gap:.3em}
.ct-mats .seg{display:grid;grid-template-columns:1fr 1fr;gap:.35em}
.ct-mats>.ctl .seg .btn{margin:0;border-radius:.6em;white-space:normal;line-height:1.1;padding:.15em .35em;text-align:center}
.ct-opt{display:flex;flex-wrap:wrap;align-items:center;gap:.45em .6em}
.ct-opt .seg{display:inline-flex}
.ct-opt .seg .btn{width:max(2.6em,44px)}
.ct-hint{margin:0;font-family:var(--font-body);font-size:.88em;line-height:1.3;color:var(--soft)}
.ct-steps{display:flex;flex-direction:column;gap:.45em}
.ct-road{margin:0;padding:0;list-style:none;counter-reset:st;display:flex;flex-direction:column;gap:.15em}
.ct-road li{counter-increment:st;display:flex;align-items:center;gap:.45em;font-weight:600;font-size:.92em;color:var(--soft)}
.ct-road li::before{content:counter(st);flex:none;display:inline-grid;place-items:center;width:1.6em;height:1.6em;border-radius:50%;border:2px solid var(--line);background:#fff;font-size:.85em}
.ct-road li.done{color:var(--ink)}
.ct-road li.done::before{background:var(--green);border-color:var(--green);color:#fff}
.ct-road li.now::before{background:var(--blue);border-color:var(--blue)}
.ct-steptext{margin:0;padding:.5em .6em;border:2px solid var(--ink);border-left:.45em solid var(--blue);border-radius:.6em;background:#fff;font-weight:500;font-size:.95em;line-height:1.38}

.ct-short{display:none}
/* a short frame (laptop): the mat buttons name themselves, so their heading is for screen readers only */
@container (max-height:600px){
  .ct-mats>.ctl>.ctl-label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
}
/* narrow tool (phone): short labels, the panel under the mat, the builder on two rows */
@container (max-width:520px){
  .ct-long{display:none}
  .ct-short{display:inline}
  #bar{column-gap:.5em}
  .ct-qb{width:42px}
  .ct-signed button{width:40px}
  .ct-signed input{min-width:0;width:2.7ch;font-size:1.15em}
}
@container (max-width:680px){
  .tool-body{flex-direction:column}
  #side{width:auto;height:15em;flex:none;flex-direction:row;flex-wrap:wrap;align-content:flex-start;border-left:0;border-top:2px solid var(--ink);padding:.45em;gap:.45em}
  #side[data-mode=int]{height:12em}
  .ct-count{flex:1 1 100%;flex-direction:row;flex-wrap:wrap;gap:.3em .45em}
  .ct-tiles{flex:2 1 0}
  .ct-total,.ct-total:has(+ .ct-facts:not(:empty)){flex:1.3 1 0;flex-direction:row;flex-wrap:wrap;justify-content:center;align-content:center;gap:0 .4em;padding:.2em;border:2px solid var(--ink);border-radius:.7em}
  .ct-total>.ctl-label{flex-basis:100%;text-align:center}
  .ct-hint{display:none}
  .ct-n{font-size:1.7em}
  .ct-big{font-size:2.1em}
  .ct-facts{flex:1 1 100%;margin:0;padding:0;border:0;background:none;flex-direction:row;flex-wrap:wrap;justify-content:center;gap:0 .9em;font-size:.95em;line-height:1.25}
  .ct-facts span:first-child{font-size:1.05em}
  .ct-groups{display:none}
  .ct-mats{flex:1 1 100%;gap:.45em}
  .ct-mats>.ctl>.ctl-label{display:none}
  .ct-mats .seg{grid-template-columns:repeat(4,1fr);gap:.3em}
  .ct-mats>.ctl .seg .btn{font-size:.9em;padding:.1em .2em}
  .ct-steps{flex:1 1 100%}
  .ct-road{display:none}
  .ct-steptext{font-size:.92em;padding:.35em .5em}
}
/* the builder on two rows (set by the script when one row is too narrow):
   the two numbers and the sign, then the sentence and the buttons */
.ct-strip.two{flex-wrap:wrap;align-content:center;height:calc(2 * max(2.5em,42px) + 1.2em);padding:0 .45em;gap:.35em .3em}
.ct-strip.two::before{content:"";order:1;flex-basis:100%;height:0}
.ct-strip.two .ct-build{display:contents}
.ct-strip.two .ct-build>.ct-signed,.ct-strip.two .ct-build>.ct-op{order:0}
.ct-strip.two .ct-eq{order:2;font-size:1.35em}
.ct-strip.two .ct-build>.btn{order:3}
@container (max-width:680px){
  .ct-strip.two .ct-op .btn{width:40px}
}
