/* PlyFill work area: part cards, drop zone, tiles, More numbers, sheet row and pager, board,
   sheet figures, busy pill, tooltip, empty state. Owner: work area (ui/designs.js, ui/board.js,
   ui/results.js). Loaded by the app page only, after app.css (tokens and shared controls live there:
   .chip/.chips, .seg2, .mini/.switch/.track, .x, .iw, .field, .pseg, .btn).
   Redesign 2026-11-24 from mockup/plyfill-redesign.html. */

/* ---------- 1 · Parts: part cards ---------- */
.models{display:grid;gap:10px}
.models:empty{display:none}
.card{display:flex;flex-direction:column;gap:12px;min-width:0;padding:12px;border:1px solid var(--line-2);border-radius:12px;background:var(--chrome-2)}
.card-head{display:flex;gap:8px;align-items:center;min-width:0}
.card-head .x{width:24px;margin-left:-2px}
.card.off > :not(.card-head),.card.off .thumbbox,.card.off .meta{opacity:.45}
/* thumbnail of the first piece, the design's letter in its colour, "+N" for the rest of a set */
.thumbbox{position:relative;width:46px;height:56px;flex:none;display:grid;place-items:center;border-radius:8px;background:var(--bg)}
.thumb{display:block;width:36px;height:44px}
.thumb path{fill:color-mix(in srgb,var(--mc) 30%,transparent);stroke:var(--mc);stroke-width:1.3;stroke-linejoin:round;vector-effect:non-scaling-stroke}
.thumb path.eng{fill:none;stroke:var(--ink-2);stroke-width:1;opacity:.8}
.thumb path.grain{fill:none;stroke:var(--key);stroke-width:1;opacity:.3}
.thumbbox .badge{position:absolute;left:-5px;top:-5px;min-width:20px;height:20px;padding:0 4px;display:grid;place-items:center;border-radius:6px;background:var(--mc);color:var(--solid-ink);font-size:11px;font-weight:700;line-height:1;box-shadow:0 0 0 2px var(--chrome-2)}
.thumbbox .more-n{position:absolute;right:3px;bottom:3px;padding:0 4px;border-radius:5px;background:var(--chrome-2);color:var(--ink-2);font-size:10.5px;font-weight:600;line-height:15px}
.card .meta{flex:1;min-width:0}
/* name and size: one line each (ellipsis, the full text is in title), so the head stays thumbnail-high */
.card .nm{font-size:14px;font-weight:600;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.card .sz{font-size:12px;color:var(--ink-3);font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* quantity */
.qty-ctl{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--ink-2)}
.stepper{display:inline-flex;align-items:center;border:1px solid var(--line-2);border-radius:10px;background:var(--bg);overflow:hidden}
.stepper button{width:32px;height:32px;border:0;background:transparent;color:var(--ink-2);font-size:16px;line-height:1}
.stepper button:hover{color:var(--ink);background:var(--line)}
.stepper button:focus-visible{outline-offset:-2px}
.stepper input{width:52px;height:32px;padding:0;border:0;border-left:1px solid var(--line);border-right:1px solid var(--line);border-radius:0;background:transparent;color:var(--ink);text-align:center;font-size:13px;font-variant-numeric:tabular-nums;-moz-appearance:textfield;appearance:textfield}
.stepper input::-webkit-inner-spin-button,.stepper input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
.stepper input:focus-visible{outline-offset:-2px}
.max-note{margin:-4px 0 0;font-size:12px;color:var(--ink-3)}
.chip .chev{width:9px;height:9px;transition:transform .15s}
.chip[aria-expanded="true"] .chev{transform:rotate(180deg)}
/* the Scale chip's area: file line, piece thumbnails of a set, units + scale, keep inner shapes */
.mx{display:flex;flex-direction:column;gap:10px;padding:10px;border:1px solid var(--line);border-radius:10px;background:var(--chrome)}
.m-file{margin:0;font-size:12px;color:var(--ink-3);overflow-wrap:anywhere}
.thumbs{display:flex;flex-wrap:wrap;gap:6px}
.thumb.sm{width:42px;height:36px;padding:4px;border:1px solid var(--line);border-radius:6px;background:var(--bg)}
.facts{display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:8px}
.facts .iw{height:30px}
/* grain lock: the same job with the design turned 90°, to compare orientations */
.cmp{margin:-4px 0 0;font-size:12px;color:var(--ink-3)}
.cmp b{font-weight:500;color:var(--ink-2)}
.result{display:flex;justify-content:space-between;align-items:baseline;gap:8px;padding-top:10px;border-top:1px solid var(--line);font-size:12.5px}
.result .a{color:var(--ink-2);white-space:nowrap}
.result .b{min-width:0;font-weight:600;text-align:right}
.result .b.warn{color:var(--bad);font-weight:500}

/* the "Add a design" button (#addFiles); before any design it is the big drop zone */
.add{display:flex;flex-direction:column;align-items:center;gap:4px;width:100%;padding:18px 12px;border:1px dashed var(--dash);border-radius:12px;background:transparent;color:var(--ink);text-align:center;transition:border-color .15s,background .15s}
.add:hover,.dragging .add{border-color:var(--key);background:var(--key-bg)}
.add svg{width:18px;height:18px;color:var(--key)}
.add strong{font-size:13px;font-weight:600}
.add span{font-size:12px;color:var(--ink-3)}
.parts.is-empty .add{padding:40px 14px}
.parts.is-empty .add svg{width:24px;height:24px}

/* ---------- tiles ---------- */
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
.tile{min-width:0;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--chrome)}
.tile .k{font-size:12px;color:var(--ink-3)}
.tile .vrow{display:flex;align-items:baseline;gap:8px;min-width:0}
.tile .v{font-size:26px;font-weight:700;letter-spacing:-.02em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.3}
.tile .v.dims{font-size:22px;line-height:1.48}
.tile .v .u{font-size:.6em;font-weight:600;letter-spacing:0;color:var(--ink-3)} /* the size's unit, after the value */
.tile .v.fit1{font-size:18px}
.tile .v.fit2{font-size:15px}
.tile .s{font-size:12px;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tile.hot{border-color:var(--key);background:var(--key-bg)}
.tile.hot .k{color:var(--key)}
.tile.hot .s{color:var(--ink-2)}
.grade{font-size:12px;font-weight:600;white-space:nowrap}
.grade.good{color:var(--good)} .grade.fair{color:var(--key)} .grade.low{color:var(--low)}
/* the yield bar: parts | offcut kept | scrap */
.bar{display:flex;margin-top:6px;height:5px;border-radius:3px;overflow:hidden;background:var(--line)}
.bar span{display:block;height:100%;transition:width .35s ease}
.b-used{background:var(--good)}
.b-off{background:repeating-linear-gradient(135deg,rgba(127,174,110,.35) 0 3px,rgba(127,174,110,.75) 3px 5px)}
.b-scrap{background:var(--scrap)}

/* ---------- More numbers ---------- */
.more{margin-top:-6px}
.more-btn{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 4px;border:0;background:transparent;color:var(--ink-2);font-size:12px}
.more-btn:hover{color:var(--ink)}
.more-btn svg{width:10px;height:10px;transition:transform .15s}
.more-btn[aria-expanded="true"] svg{transform:rotate(180deg)}
.stats{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:8px;margin:6px 0 0}
.stat{min-width:0;padding:8px 10px;border:1px solid var(--line);border-radius:10px;background:var(--chrome)}
.stat dt{font-size:12px;color:var(--ink-3)}
.stat dd{margin:0;min-width:0}
.stat .v{display:block;font-size:14px;font-weight:600;color:var(--ink);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.stat .s{display:block;font-size:11.5px;line-height:1.35;color:var(--ink-3)}

/* ---------- sheet row: pager, goal line, zoom, refill, in | mm ---------- */
.sheetrow{display:flex;flex-wrap:wrap;align-items:center;gap:10px}
.pager{display:flex;align-items:center;gap:4px}
.pager .t{padding:0 4px;font-size:13px;font-weight:600;white-space:nowrap;font-variant-numeric:tabular-nums}
.pager button{width:30px;height:30px;display:grid;place-items:center;padding:0;border:1px solid var(--line);border-radius:50%;background:var(--chrome);color:var(--ink-2);font-size:17px;line-height:1}
.pager button:hover:not(:disabled){color:var(--ink);border-color:var(--line-2)}
.pager button:disabled{opacity:.4;cursor:default}
.sheetrow > .hint{flex:1 1 140px;min-width:0;margin:0;font-size:12px;color:var(--ink-2)}
.tools{margin-left:auto;display:flex;align-items:center;gap:8px}
.zoom{display:flex;align-items:center;gap:2px;padding:3px;border:1px solid var(--line);border-radius:999px;background:var(--chrome)}
.zoom button{width:30px;height:30px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--ink-2);font-size:15px}
.zoom button:hover{color:var(--ink);background:var(--line)}
.zoom #zoomFit{width:auto;min-width:42px;padding:0 8px;border-radius:999px;font-size:12px}
.zoom .pct{min-width:40px;text-align:center;font-size:12px;color:var(--ink-2);font-variant-numeric:tabular-nums}
#refill .ic{width:14px;height:14px}

/* ---------- board of sheets ---------- */
.board-wrap{position:relative;flex:1 1 auto;min-height:0}
.board{position:absolute;inset:0;overflow:auto;background-color:var(--canvas);background-image:radial-gradient(var(--canvas-dot) 1px,transparent 1.4px);background-size:18px 18px;background-attachment:local}
.board-cap{margin:0;padding:12px 16px 0;text-align:center;font-size:11.5px;color:var(--ink-3)}
/* arranging: a gold pill with a spinner over the board, the sheets dimmed behind it */
.busy{position:absolute;top:44%;left:50%;transform:translate(-50%,-50%);z-index:4;display:inline-flex;align-items:center;gap:12px;padding:13px 22px 13px 15px;border-radius:999px;background:rgba(27,26,24,.97);border:1px solid var(--key);color:var(--ink);font:600 14.5px/1 var(--font);white-space:nowrap;box-shadow:0 14px 40px rgba(0,0,0,.55),0 0 0 5px rgba(253,175,1,.14);pointer-events:none;animation:busyIn .18s ease-out}
.busy .spin{width:22px;height:22px;flex:none;border-radius:50%;border:3px solid rgba(253,175,1,.22);border-top-color:var(--key);border-right-color:var(--key);animation:spin .75s linear infinite}
@keyframes busyIn{from{opacity:0;transform:translate(-50%,calc(-50% + 6px))}}
.board-wrap.is-busy .sheets{opacity:.4;filter:saturate(.6);transition:opacity .25s,filter .25s}
.is-busy #refill .ic,.stage:has(.board-wrap.is-busy) #refill .ic{animation:spin .75s linear infinite}
.sheets{display:flex;flex-wrap:wrap;justify-content:center;align-items:flex-start;gap:22px 28px;padding:12px 16px 24px}
.sheets:empty{display:none}
@supports (justify-content:safe center){.sheets{justify-content:safe center}}
.sheet{margin:0;display:grid;gap:4px}
.sheet figcaption{display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 10px;padding-left:34px;font-size:11.5px;line-height:1.4;color:var(--ink-3);font-variant-numeric:tabular-nums}
.cap-name{font-size:12.5px;font-weight:600;color:var(--ink)}
.sheet.cur .cap-name{color:var(--key)} /* the sheet the pager is on (several sheets) */
.cap-pct{color:var(--ink-2)}
.cap-off{color:var(--good)}
.cap-lay{color:var(--key)} /* layout size / sheet needed: same colour as its dimensions on the sheet */
.sheet canvas{display:block;touch-action:manipulation}
/* empty board: what PlyFill does, and the sample job */
.empty-card{max-width:360px;margin:7vh auto 24px;padding:28px 26px;display:grid;justify-items:center;gap:6px;text-align:center;background:var(--chrome);border:1px solid var(--line);border-radius:14px;box-shadow:0 14px 40px rgba(0,0,0,.35)}
.empty-card .ic{width:26px;height:26px;margin-bottom:6px;color:var(--key)}
.empty-card h1{margin:0;font-size:20px;font-weight:700;letter-spacing:-.01em;line-height:1.25;text-wrap:balance}
.empty-card .em-sub{margin:0;font-size:13px;color:var(--ink-2)}
.empty-card .em-fine{margin:4px 0 12px;font-size:12px;color:var(--ink-3);line-height:1.5}
.empty-card .btn{border-color:var(--key);color:var(--key)}
.empty-card .btn:hover{background:var(--key-bg);color:var(--key)}
/* hover a part: its details (body-level, follows the pointer) */
.tip{position:fixed;left:0;top:0;z-index:50;pointer-events:none;display:grid;gap:2px;max-width:250px;padding:8px 10px;border-radius:8px;background:var(--chrome-2);border:1px solid var(--line-2);color:var(--ink-2);font-size:12px;line-height:1.35;box-shadow:0 10px 30px rgba(0,0,0,.45)}
.tip strong{font-weight:600;color:var(--ink)}

/* ---------- 760-1099 px: board on top, parts below it, setup at the right ---------- */
@media (min-width:760px) and (max-width:1099.98px){
  .tiles{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
  .tile{padding:10px 12px}
  .tile .v{font-size:22px}
  .tile .v.dims{font-size:17px;line-height:1.65}
  .tile .v.dims .full{display:none}
  .tile .v.dims .short{display:inline}
  .tile .k .full{display:none}
  .tile .k .short{display:inline}
  .models{grid-template-columns:repeat(auto-fill,minmax(250px,1fr));align-items:start}
  .sheetrow > .hint{flex-basis:100%;order:3}
}

/* ---------- phone (below 760 px) ---------- */
@media (max-width:759.98px){
  .tiles{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .tile{padding:8px 10px;border-radius:10px}
  .tile .k{font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .tile .v{font-size:18px}
  .tile .v.dims{font-size:15px;line-height:1.6}
  .tile .s,.tile .bar,.tile .grade,.tile .v .u{display:none}
  .more{margin-top:-4px}
  .more-btn{height:44px}
  .stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  /* one row at 360 px: pager "1/2" | zoom | refill (icon only) | in mm. With several sheets Fit
     makes way for the pager (− steps back to 100 %, which is the fit). */
  .sheetrow{flex-wrap:nowrap;gap:4px}
  .sheetrow > .hint{display:none}
  .tools{margin-left:auto;gap:4px;flex-wrap:nowrap;min-width:0}
  .pager{gap:0;flex:none}
  .pager.single{display:none}
  .sheetrow:has(.pager:not(.single):not([hidden])) #zoomFit{display:none}
  .pager .t{min-width:24px;padding:0 2px;font-size:12.5px;text-align:center}
  /* the board grows with its sheets up to --ph-board-max (app.css); several sheets scroll inside it */
  .app .stage > .board-wrap{height:auto;max-height:var(--ph-board-max)}
  .board-wrap > .board{position:relative;inset:auto;max-height:var(--ph-board-max)}
  .board-cap{display:none}
  .sheets{padding:8px 4px 14px;gap:18px}
  .pager button{width:44px;height:44px}
  .zoom{gap:0;padding:0}
  .zoom button,.zoom #zoomFit{min-width:44px;height:44px}
  .zoom button{width:44px}
  .zoom #zoomFit{padding:0 4px}
  .zoom .pct{display:none}
  #refill{width:44px;min-width:44px;flex:none;padding:0;font-size:0;gap:0}
  #refill .ic{width:18px;height:18px}
  .pseg label{min-width:40px;padding:0 8px}
  .sheet figcaption{padding-left:4px}
  .empty-card{margin:4vh 12px 16px;padding:22px 18px}
  .empty-card h1{font-size:18px}
  /* part card: 44 px targets */
  .stepper button{width:44px;height:44px}
  .stepper input{height:44px}
  .facts .iw{height:44px}
  .thumbbox .badge{left:-4px;top:-4px}
  .card-head .x{width:44px;margin-left:0}
}
