/* Laser Box Builder. The PHYSICS look comes from the kit (kit.css, --kit- variables); these are the page's own pieces,
   with plain fallbacks so the page still works if the kit never arrives. */
:root {
  --lb-bg: var(--kit-bg, #F7FAFC);
  --lb-panel: var(--kit-panel, #ffffff);
  --lb-ink: var(--kit-ink, #17212b);
  --lb-body: var(--kit-body, #2b3742);
  --lb-muted: var(--kit-muted, #5b6874);
  --lb-line: var(--kit-line, #d7dee5);
  --lb-accent: var(--kit-accent, #1E5AAF);
  --lb-action: var(--kit-action, #CC4D15);
  --lb-wood: #e2c48f;          /* basswood, for the 3D view and sheets */
  --lb-wood-dark: #b98c55;
  --lb-cut: #e0261b;           /* Laser Cut red, as in Bambu Suite */
  --lb-score: #2b6fd6;         /* Laser Line blue */
  --lb-warn-bg: #fff4d6;
  --lb-warn-ink: #7a4b00;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --lb-wood: #c9a46c; --lb-wood-dark: #8f6a3d; --lb-cut: #ff6a5c; --lb-warn-bg: #3a2c0c; --lb-warn-ink: #ffd88a; }
}
:root[data-theme="dark"] { --lb-wood: #c9a46c; --lb-wood-dark: #8f6a3d; --lb-cut: #ff6a5c; --lb-warn-bg: #3a2c0c; --lb-warn-ink: #ffd88a; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--lb-bg); color: var(--lb-body); font-family: var(--kit-font, system-ui, sans-serif); line-height: 1.5; }

/* our own top and bottom, until the kit's take their place */
.lb-top { max-width: 1100px; margin: 0 auto; padding: 16px; }
.lb-brand { font: 700 24px var(--kit-font-display, system-ui, sans-serif); color: var(--lb-accent); }
.lb-ver { font-size: 13px; color: var(--lb-muted); font-weight: 400; }
.lb-beta { font-size: 12px; background: var(--lb-action); color: #fff; border-radius: 999px; padding: 2px 8px; vertical-align: middle; }
.lb-foot { max-width: 1100px; margin: 0 auto; padding: 16px; font-size: 13px; color: var(--lb-muted); display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }

/* the page: on a computer the cards on the left, the box and its cut sheets on the right; on a phone the box first,
   then the cards, then the cut sheets (BU-007: a card about the result may sit under the view) */
.lb-layout { max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; display: grid; gap: 16px;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr); grid-template-areas: "cards view" "cards sheets"; grid-template-rows: auto 1fr; align-items: start; }
.lb-cards { grid-area: cards; display: grid; gap: 16px; min-width: 0; margin: 0; }
.lb-area-view { grid-area: view; }
.lb-area-sheets { grid-area: sheets; }
@media (max-width: 860px) {
  .lb-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "view" "cards" "sheets"; grid-template-rows: none; }
}
.lb-card { display: grid; gap: 12px; min-width: 0; }

.lb-field { display: grid; gap: 4px; min-width: 0; }
.lb-field > span { font-size: 14px; color: var(--lb-muted); }
.lb-field input[type="number"], .lb-field input[type="text"], .lb-field input[type="email"], .lb-field input[type="tel"], .lb-field select, .lb-field textarea {
  width: 100%; min-width: 0; font: inherit; font-size: 16px; color: var(--lb-ink); background: var(--lb-panel);
  border: 1px solid var(--lb-line); border-radius: 8px; padding: 8px 10px; }
.lb-dims { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lb-dims input { font-variant-numeric: tabular-nums; }

.lb-seg { display: flex; border: 1px solid var(--lb-line); border-radius: 8px; overflow: hidden; }
.lb-seg label { flex: 1; text-align: center; padding: 8px 6px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--lb-muted); background: var(--lb-panel); position: relative; }
.lb-seg label + label { border-left: 1px solid var(--lb-line); }
.lb-seg input { position: absolute; opacity: 0; pointer-events: none; }
.lb-seg label:has(input:checked) { background: var(--lb-accent); color: #fff; }
.lb-seg label:has(input:focus-visible) { outline: 2px solid var(--lb-accent); outline-offset: -4px; }

.lb-check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.lb-check input { width: 18px; height: 18px; accent-color: var(--lb-accent); flex: none; }
.lb-sides { display: flex; flex-wrap: wrap; gap: 6px; }
.lb-sides label { border: 1px solid var(--lb-line); border-radius: 16px; padding: 4px 11px; font-size: 14px; font-weight: 600; color: var(--lb-muted); background: var(--lb-panel); cursor: pointer; position: relative; }
.lb-sides label:has(input:checked) { background: var(--lb-accent); border-color: var(--lb-accent); color: #fff; }
.lb-sides label:has(input:disabled) { opacity: .4; cursor: not-allowed; }
.lb-sides label:has(input:focus-visible) { outline: 2px solid var(--lb-accent); outline-offset: 2px; }
.lb-sides input { position: absolute; opacity: 0; pointer-events: none; }
input[type="range"] { width: 100%; accent-color: var(--lb-accent); }

.lb-upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lb-upload input[type="file"] { max-width: 100%; }
.lb-upload img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--lb-line); }

.lb-view { position: relative; }
#view { width: 100%; height: 400px; display: block; border-radius: 8px; background: var(--lb-bg); cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }
#view:focus-visible { outline: 2px solid var(--lb-accent); outline-offset: 2px; }
@media (max-width: 860px) { #view { height: 300px; } }
.lb-lid { position: absolute; top: 10px; right: 10px; }

.lb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.lb-stat { display: grid; gap: 2px; }
.lb-stat b { font-size: 19px; color: var(--lb-ink); font-variant-numeric: tabular-nums; }
.lb-stat small { color: var(--lb-muted); font-size: 13px; }
.lb-warn { background: var(--lb-warn-bg); color: var(--lb-warn-ink); border-radius: 8px; padding: 10px 12px; margin: 0; }

.lb-sheets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.lb-sheet { margin: 0; display: grid; gap: 4px; min-width: 0; }
.lb-sheet svg { width: 100%; height: auto; background: var(--lb-bg); border-radius: 8px; border: 1px solid var(--lb-line); }
.lb-sheet figcaption { display: grid; font-size: 13px; color: var(--lb-muted); }
.lb-sheet figcaption b { color: var(--lb-ink); }

.lb-msg { margin: 0; min-height: 1em; }
.lb-msg.ok { color: #1d6b35; }
.lb-msg.err { color: #a3261b; }
.lb-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* without the kit (body has no kit-dressed): plain buttons that still read as buttons; the kit's own look wins once it is in */
body:not(.kit-dressed) .kit-btn { font: 600 15px system-ui, sans-serif; border-radius: 8px; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--lb-accent); background: var(--lb-panel); color: var(--lb-accent); }
body:not(.kit-dressed) .kit-btn.action { background: var(--lb-action); border-color: var(--lb-action); color: #fff; }
body:not(.kit-dressed) .kit-btn[disabled] { opacity: .55; cursor: not-allowed; }
body:not(.kit-dressed) .kit-note { margin: 0; color: var(--lb-muted); font-size: 14px; }
body:not(.kit-dressed) .kit-card-title { margin: 0; font-size: 18px; color: var(--lb-accent); }
body:not(.kit-dressed) .kit-card { background: var(--lb-panel); border: 1px solid var(--lb-line); border-radius: 10px; padding: 16px; }

/* the custom laser jobs page */
.lb-dims-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lb-seg-wrap { flex-wrap: wrap; }
.lb-layout-canvas { width: 100%; height: 340px; display: block; border-radius: 8px; background: var(--lb-bg); }
@media (max-width: 860px) { .lb-layout-canvas { height: 260px; } }
.lb-lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lb-lines td { padding: 6px 4px; border-bottom: 1px solid var(--lb-line); vertical-align: top; }
.lb-lines td:last-child { text-align: right; white-space: nowrap; }
.lb-lines tr.lb-total td { font-weight: 700; color: var(--lb-ink); font-size: 18px; border-bottom: 0; }
.lb-quote-only { background: var(--lb-bg); border: 1px solid var(--lb-line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 4px; }
.lb-quote-only b { color: var(--lb-ink); }
.lb-rights { align-items: flex-start; }
.lb-rights input { margin-top: 3px; }

/* the Laser Art page */
.lb-art-canvas { height: 380px; }
@media (max-width: 860px) { .lb-art-canvas { height: 260px; } }
.lb-lines tr.lb-assembly td { color: var(--lb-muted); font-style: italic; }
.lb-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.lb-row .lb-field { flex: 1 1 140px; }
.lb-marks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lb-marks li { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; border: 1px solid var(--lb-line); border-radius: 8px; padding: 6px 8px; }
.lb-marks li.on { border-color: var(--lb-accent); box-shadow: 0 0 0 1px var(--lb-accent); }
.lb-marks li b { font-size: 14px; color: var(--lb-ink); }
.lb-marks li input[type="text"] { flex: 1 1 120px; min-width: 0; font: inherit; font-size: 15px; border: 1px solid var(--lb-line); border-radius: 6px; padding: 4px 8px; }
.lb-presets { display: grid; gap: 8px; }
.lb-preset { display: grid; gap: 2px; text-align: left; font: inherit; padding: 10px 12px; border: 1px solid var(--lb-line); border-radius: 8px; background: var(--lb-panel); color: var(--lb-ink); cursor: pointer; }
.lb-preset small { color: var(--lb-muted); font-size: 14px; }
.lb-preset[aria-pressed="true"] { border-color: var(--lb-accent); box-shadow: 0 0 0 1px var(--lb-accent); }
.lb-hints { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
.lb-sub { margin: 6px 0 0; font-size: 15px; color: var(--lb-ink); }
.lb-pics { display: grid; gap: 10px; }
.lb-pic { border: 1px solid var(--lb-line); border-radius: 8px; padding: 8px 10px; display: grid; gap: 6px; }
.lb-pic > b { font-size: 15px; color: var(--lb-ink); }
.lb-pic .lb-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: end; }
.lb-pic .lb-row .lb-field { flex: 1 1 110px; }
.lb-pic canvas.lb-burn { display: block; max-width: 100%; height: auto; border-radius: 4px; box-shadow: 0 0 0 1px var(--lb-line); }
.lb-pic .lb-warns { margin: 0; padding-left: 18px; color: var(--lb-warn-ink); background: var(--lb-warn-bg); border-radius: 6px; padding: 6px 10px 6px 24px; font-size: 14px; }
.lb-art-canvas.lb-grab { cursor: grab; touch-action: none; }
