/* ── Side panels collapse ──────────────────────────────────────────────────
   The pieces sidebar (left, `w-56`) and the size guide (right, `w-72`) each
   collapse to a thin rail, like Sketch's measures panel. `product/sidePanels.js`
   owns their open/closed state (default, then the user's remembered
   choice) and flips `.board-panel--collapsed` here. The width is deliberately
   *not* transitioned: the board's viewBox is re-derived from the canvas's new
   size the moment the class flips, and an animated width would leave the
   pieces scaled wrong while it ran. */
.board-panel {
  --board-panel-rail-w: 26px;  /* collapsed: just the toggle */

  position: relative;
}

.board-panel-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Leave the top-right corner to the toggle (the id outranks Tailwind's `px-3`). */
#pieces-panel .pieces-panel-switcher-row { padding-right: 32px; }

/* Expanded: a small chevron in the panel's top-right corner. */
.board-panel-toggle {
  position: absolute;
  top: 9px;
  right: 6px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  color: rgba(127, 85, 28, .76);
  background: transparent;
  border: 1px solid rgba(154, 106, 36, .52);
  cursor: pointer;
  transition: color .12s, background-color .12s, border-color .12s;
}
.board-panel-toggle:hover {
  color: #7f551c;
  background: rgba(154, 106, 36, .07);
  border-color: rgba(127, 85, 28, .78);
}
.board-panel-toggle:focus-visible {
  outline: 1px solid var(--emerald);
  outline-offset: 1px;
}
.board-panel-chevron { transition: transform .16s ease; }
.board-panel-toggle-label { display: none; }

/* Collapsed: the toggle *is* the rail — full height, with a vertical label.
   The doubled class outranks Tailwind's `w-56` / `w-72`. */
.board-panel.board-panel--collapsed {
  width: var(--board-panel-rail-w);
}
.board-panel--collapsed .board-panel-content { display: none; }
.board-panel--collapsed .board-panel-toggle {
  inset: 0;
  width: 100%;
  height: 100%;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  padding-top: 8px;
  border: 0;
}
.board-panel--collapsed .board-panel-chevron { transform: rotate(180deg); }
.board-panel--collapsed .board-panel-toggle-label {
  display: block;
  writing-mode: vertical-rl;
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sheet panel (right): picture over the cotes per size ──────────────── */
#sheet-panel { border-left-color: var(--border-warm); }

.sheet-section { display: flex; flex-direction: column; min-height: 0; }
.sheet-section--image { flex: 0 0 auto; border-bottom: 1px solid var(--border-warm); }
.sheet-section--chart { flex: 1 1 auto; }

.sheet-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--warm-gray-soft);
}
/* The first heading shares its row with the toggle. */
.sheet-heading--first { min-height: 38px; padding-right: 36px; }
.sheet-heading-meta { font-weight: 500; letter-spacing: 0.06em; text-transform: none; }

.sheet-image { padding: 0 12px 12px; }

.sheet-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 132px;
  padding: 14px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--warm-gray);
  background: var(--cream);
  border: 1px dashed rgba(120, 80, 30, 0.38);
  cursor: pointer;
  transition: color .12s, border-color .12s, background-color .12s;
}
.sheet-dropzone:hover,
.sheet-dropzone.is-dragover {
  color: var(--emerald);
  border-color: var(--emerald);
  background: rgba(43, 106, 100, 0.05);
}
.sheet-dropzone:focus-visible { outline: 1px solid var(--emerald); outline-offset: 1px; }
.sheet-dropzone-hint { font-size: var(--fs-micro); color: var(--warm-gray-soft); }
.sheet-dropzone.is-busy { cursor: progress; opacity: 0.7; }
.sheet-dropzone--empty { cursor: default; }
.sheet-dropzone--empty:hover { color: var(--warm-gray); border-color: rgba(120, 80, 30, 0.38); background: var(--cream); }

.sheet-figure {
  position: relative;
  margin: 0;
  background: var(--cream);
  border: 1px solid var(--border-warm);
}
.sheet-figure.is-dragover { border-color: var(--emerald); }
.sheet-figure.is-editable { cursor: pointer; }
.sheet-figure.is-editable:hover { border-color: var(--emerald); }
/* The picture and its arrows share one SVG (sheetPanel.js); `meet` keeps the
   picture's proportions inside the frame. */
.sheet-picture {
  display: block;
  width: 100%;
  height: auto;
  max-height: 34vh;
}
.sheet-image-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}
.sheet-image-btn {
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--charcoal-mid);
  background: var(--white);
  border: 1px solid var(--border-warm);
  cursor: pointer;
  transition: color .12s, border-color .12s, background-color .12s;
}
.sheet-image-btn:hover { color: var(--emerald); border-color: var(--emerald); }
.sheet-image-btn--accent { color: var(--emerald); border-color: rgba(43, 106, 100, 0.45); }
.sheet-image-btn--accent:hover { color: var(--white); background: var(--emerald); }
.sheet-image-btn--danger:hover { color: #b91c1c; border-color: #b91c1c; background: rgba(190, 50, 40, 0.06); }
.sheet-image-btn:disabled { opacity: 0.5; cursor: progress; }

.sheet-chart { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0 0 12px; }

.sheet-chart-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  color: var(--charcoal-mid);
}
.sheet-chart-table th,
.sheet-chart-table td {
  padding: 5px 8px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid rgba(120, 80, 30, 0.14);
}
.sheet-chart-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 500;
  color: var(--warm-gray);
  background: var(--cream-surf);
  border-bottom-color: var(--border-warm);
}
/* The cote names stay in view while the sizes scroll sideways. */
.sheet-chart-table .sheet-chart-name {
  position: sticky;
  left: 0;
  z-index: 1;
  max-width: 124px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  font-family: var(--sans);
  font-size: var(--fs-sm);
  color: var(--charcoal);
  background: var(--white);
  border-right: 1px solid rgba(120, 80, 30, 0.14);
}
.sheet-chart-table thead .sheet-chart-name {
  z-index: 3;
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  color: var(--warm-gray);
  background: var(--cream-surf);
}
/* Repère letters: the same badge as the arrows on the picture. */
.sheet-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-family: var(--sans);
  font-size: var(--fs-2xs);
  font-weight: 700;
  line-height: 1;
  color: var(--white);
  background: var(--emerald);
  border-radius: 999px;
}
.sheet-letter.is-empty { color: var(--warm-gray-soft); background: var(--cream-dark); }
.sheet-chart-table .sheet-chart-letter {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 30px;
  min-width: 30px;
  padding: 4px 3px 4px 6px;
  text-align: left;
  background: var(--white);
}
.sheet-chart-table thead .sheet-chart-letter { z-index: 3; background: var(--cream-surf); }
/* With letters, the names stick just after them. */
.sheet-chart-table.has-letters .sheet-chart-name { left: 30px; }
/* The size the board shows. */
.sheet-chart-table .is-current {
  color: var(--emerald-dark);
  font-weight: 600;
  background: rgba(43, 106, 100, 0.07);
}
.sheet-chart-table thead .is-current { background: #e9f0ec; }
.sheet-chart-missing { color: var(--warm-gray-soft); }

.sheet-empty {
  margin: 0 12px;
  padding: 14px 12px;
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--warm-gray);
  background: var(--cream);
  border: 1px solid var(--border-warm);
}
.sheet-empty a { color: var(--emerald); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }

.sheet-footer {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border-warm);
  background: var(--cream-surf);
}
.sheet-pdf-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--charcoal);
  border: 1px solid var(--charcoal);
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
.sheet-pdf-btn:hover:not(:disabled) { background: var(--emerald); border-color: var(--emerald); }
.sheet-pdf-btn:focus-visible { outline: 1px solid var(--emerald); outline-offset: 2px; }
.sheet-pdf-btn:disabled { opacity: 0.45; cursor: default; }
.sheet-pdf-btn[aria-busy="true"] { cursor: progress; }

/* ── Annotation editor (annotationEditor.js) ──────────────────────────────
   Full window over the board: the picture as large as it fits on the left, the
   arrow list on the right (stacked on a phone). */
.annot-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 26, 23, 0.45);
}
.annot-card {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: min(820px, 100%);
  background: var(--white);
  border: 1px solid var(--border-warm);
  box-shadow: 0 18px 60px rgba(30, 20, 10, 0.3);
}
.annot-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--cream-surf);
  border-bottom: 1px solid var(--border-warm);
}
.annot-head h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--charcoal);
}
.annot-hint { margin: 3px 0 0; font-size: var(--fs-md); color: var(--warm-gray); }
.annot-done {
  flex: 0 0 auto;
  padding: 6px 16px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--charcoal);
  border: 1px solid var(--charcoal);
  cursor: pointer;
}
.annot-done:hover { background: var(--emerald); border-color: var(--emerald); }
.annot-done:focus-visible { outline: 1px solid var(--emerald); outline-offset: 2px; }
.annot-body { display: flex; flex: 1 1 auto; min-height: 0; }
.annot-stage {
  flex: 1 1 auto;
  min-width: 0;
  padding: 16px;
  background: var(--cream);
  background-image:
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 22px 22px;
}
.annot-svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
.annot-svg .sheet-arrow { cursor: move; }
.annot-svg .sheet-arrow-handle { cursor: grab; }
.annot-preview {
  stroke: var(--emerald);
  stroke-dasharray: 6 4;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  stroke-width: 2px;
}
.annot-side {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border-warm);
}
.annot-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--warm-gray-soft);
  border-bottom: 1px solid var(--border-warm);
}
.annot-empty,
.annot-no-cotes { margin: 12px 14px 0; font-size: var(--fs-md); line-height: 1.45; color: var(--warm-gray); }
.annot-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 0; }
.annot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 14px;
  border-left: 2px solid transparent;
  cursor: pointer;
}
.annot-row:hover { background: rgba(43, 106, 100, 0.04); }
.annot-row.is-selected { background: rgba(43, 106, 100, 0.08); border-left-color: var(--emerald); }
.annot-cote {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--charcoal);
  background: var(--white);
  border: 1px solid var(--border-warm);
  border-radius: 0;
}
.annot-cote:focus { outline: none; border-color: var(--emerald); }
.annot-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--warm-gray-soft);
  border: 1px solid transparent;
  cursor: pointer;
}
.annot-delete:hover { color: #b91c1c; border-color: rgba(185, 28, 28, 0.35); background: rgba(190, 50, 40, 0.06); }

@media (max-width: 760px) {
  .annot-backdrop { padding: 0; }
  .annot-card { width: 100%; height: 100%; }
  .annot-body { flex-direction: column; }
  .annot-stage { flex: 1 1 60%; padding: 8px; }
  .annot-side { flex: 1 1 40%; border-left: 0; border-top: 1px solid var(--border-warm); }
}

/* ── Piece list (sidebar) ── */
.piece-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-warm);
  cursor: pointer;
  transition: background 0.1s;
}

.piece-row:hover { background: rgba(217, 119, 6, 0.08); }

.piece-row.selected {
  background: rgba(217, 119, 6, 0.08);
  border-left: 2px solid #d97706;
  padding-left: 8px;
}

.piece-row .piece-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #6b7280;
}

.piece-row .piece-name {
  flex: 1;
  font-size: var(--fs-md);
  color: var(--charcoal-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.piece-row .piece-name-input {
  flex: 1;
  font-size: var(--fs-md);
  padding: 1px 4px;
  border: 1px solid #111827;
  border-radius: 3px;
  outline: none;
  width: 100%;
}

.piece-row .piece-meta {
  font-size: var(--fs-2xs);
  color: var(--warm-gray);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.piece-row .piece-trash {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--warm-gray-soft);
  border-radius: 3px;
  flex-shrink: 0;
  transition: color 0.1s, background 0.1s;
}

.piece-row .piece-trash:hover { color: #ef4444; background: #fef2f2; }

.piece-row .piece-cut {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--warm-gray-soft);
  border-radius: 3px;
  flex-shrink: 0;
  transition: color 0.1s, background 0.1s;
}
.piece-row .piece-cut:hover { background: rgba(43, 106, 100, 0.1); }
.piece-row .piece-cut.active { color: #2b6a64; }
.piece-row .piece-cut.active:hover { color: #21514c; }

/* ── Cutting-board ── */
#canvas { cursor: default; }
#canvas.panning { cursor: grabbing; }

.piece-path {
  fill: rgba(255, 255, 255, 0.55);
  stroke: #374151;
  stroke-width: 0.8;
  cursor: move;
  transition: fill 0.1s;
}

.piece-path:hover { fill: rgba(124, 58, 237, 0.07); }

/* When a seam allowance is present, the seam path is the solid outer line and
   the actual stitching outline is drawn dashed inside it. */
.piece-path.has-seam {
  stroke-dasharray: 3 2;
}

/* Seam-allowance outline — a second trace offset outward from the piece.
   This is the outer line and stays solid. */
.piece-seam-path {
  fill: none;
  stroke: #000;
  stroke-width: 0.8;
}

/* The outline edge currently hovered in the seam-allowance popup. */
.piece-seam-highlight {
  fill: none;
  stroke: #2563eb;
  stroke-width: 2.4;
  stroke-linecap: round;
  opacity: 0.9;
}

/* Cut-on-fold (au pli) marker, shown on the selected piece's fold edge. */
.piece-fold-mark {
  fill: none;
  stroke: #b45309;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.92;
}
.piece-fold-rail {
  stroke-width: 1.2;
}
.piece-fold-leader,
.piece-fold-arrowhead {
  stroke-width: 1.05;
}

#seam-advanced-btn:hover { background: var(--cream); color: var(--charcoal); }

/* ── Seam-allowance popup — floating, draggable panel (no backdrop, so the
   pieces stay visible behind it). ── */
.seam-modal-card {
  position: fixed;
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 16px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(120, 80, 30, 0.25);
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(30, 20, 10, 0.25);
  overflow: visible;
}

.seam-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid #f0ebe2;
  font-family: var(--mono), monospace;
  font-size: var(--fs-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--charcoal, #333);
  cursor: move;
  user-select: none;
  background: #fbf7f0;
}

.seam-modal-close {
  font-size: 18px;
  line-height: 1;
  color: var(--warm-gray);
  padding: 0 4px;
}
.seam-modal-close:hover { color: #ef4444; }

.seam-modal-default {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #f0ebe2;
  background: #fbf7f0;
}
.seam-modal-default label {
  flex: 1;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--charcoal-mid);
}

/* Edge selector + per-edge value rows. */
.seam-modal-edge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #f0ebe2;
}
.seam-modal-edge label {
  flex: 1;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--charcoal-mid);
}

#notch-mode-select,
#notch-shape-select,
#cutprops-fold-side {
  flex: 0 1 190px;
  font-family: var(--mono), monospace;
  font-size: var(--fs-sm);
  color: var(--charcoal, #333);
  border: 1px solid rgba(120, 80, 30, 0.25);
  border-radius: 3px;
  padding: 3px 5px;
  outline: none;
  background: #fff;
  max-width: 200px;
}
#notch-mode-select:focus,
#notch-shape-select:focus,
#cutprops-fold-side:focus { border-color: #b45309; }

/* The fold-side row reuses .seam-modal-edge (display:flex), whose author rule
   would otherwise beat the UA [hidden] rule — restore hiding explicitly. */
.cutprops-fold-side[hidden] { display: none; }

/* Custom edge dropdown — lets us preview-highlight the edge on option hover,
   which a native <select>/<option> can't do. */
.seam-edge-dropdown {
  position: relative;
  flex: 0 1 190px;
  max-width: 200px;
}
.seam-edge-trigger {
  width: 100%;
  text-align: left;
  font-family: var(--mono), monospace;
  font-size: var(--fs-sm);
  color: var(--charcoal, #333);
  border: 1px solid rgba(120, 80, 30, 0.25);
  border-radius: 3px;
  padding: 3px 22px 3px 5px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seam-edge-trigger::after {
  content: '';
  position: absolute;
  right: 7px;
  top: 50%;
  width: 0;
  height: 0;
  margin-top: -2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid #9ca3af;
}
.seam-edge-trigger:focus,
.seam-edge-trigger.open { border-color: #b45309; }

.seam-edge-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 3px;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(120, 80, 30, 0.25);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(30, 20, 10, 0.18);
}
.seam-edge-list[hidden] { display: none; }
.seam-edge-option {
  font-family: var(--mono), monospace;
  font-size: var(--fs-sm);
  color: var(--charcoal, #333);
  padding: 4px 7px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}
.seam-edge-option:hover { background: #eff4ff; color: #1d4ed8; }
.seam-edge-option.selected { background: #dbe6ff; color: #1d4ed8; font-weight: 600; }

.seam-modal-default input,
#seam-edge-value,
#cutprops-grainline {
  width: 62px;
  font-family: var(--mono), monospace;
  font-size: var(--fs-sm);
  color: var(--charcoal, #333);
  border: 1px solid rgba(120, 80, 30, 0.25);
  border-radius: 3px;
  padding: 3px 5px;
  outline: none;
  text-align: right;
}
.seam-modal-default input:focus,
#seam-edge-value:focus,
#cutprops-grainline:focus { border-color: #b45309; }
#seam-edge-value:disabled { background: var(--cream-dim); color: var(--warm-gray); }

.seam-unit { font-size: var(--fs-xs); color: var(--warm-gray); width: 18px; }

/* Sub-section heading inside the seam popup (e.g. "Propriétés de coupe"). */
.seam-modal-section {
  padding: 9px 14px 4px;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--warm-gray);
  border-top: 1px solid #f0ebe2;
}

/* Cut-properties rows (grainline / au pli / paire / rotation). */
.cutprops-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: var(--fs-sm);
  color: var(--charcoal, #333);
  border-bottom: 1px solid #f0ebe2;
  cursor: pointer;
}
.cutprops-check input[type="checkbox"] {
  appearance: none;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  display: inline-grid;
  place-content: center;
  margin: 0;
  border: 1px solid rgba(120, 80, 30, 0.28);
  border-radius: 3px;
  background: var(--cream-surf, #fefcf8);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.cutprops-check input[type="checkbox"]::after {
  content: '';
  width: 4px;
  height: 7px;
  border: solid var(--white, #fff);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-1px) rotate(45deg) scale(0);
  transition: transform 0.12s ease;
}
.cutprops-check input[type="checkbox"]:hover {
  border-color: var(--emerald, #2b6a64);
  box-shadow: 0 0 0 2px rgba(43, 106, 100, 0.08);
}
.cutprops-check input[type="checkbox"]:focus-visible {
  outline: none;
  border-color: var(--emerald, #2b6a64);
  box-shadow: 0 0 0 3px rgba(43, 106, 100, 0.16);
}
.cutprops-check input[type="checkbox"]:checked {
  border-color: var(--emerald, #2b6a64);
  background: var(--emerald, #2b6a64);
}
.cutprops-check input[type="checkbox"]:checked::after {
  transform: translateY(-1px) rotate(45deg) scale(1);
}
.cutprops-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.cutprops-grainline-row {
  justify-content: space-between;
}
.cutprops-grainline-angle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.cutprops-grainline-angle[hidden] { display: none; }
.cutprops-inline-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--warm-gray);
}

.seam-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 0 0 6px 6px;
  border-top: 1px solid #f0ebe2;
}
.seam-modal-tip { font-size: var(--fs-2xs); color: var(--warm-gray); line-height: 1.3; flex: 1; }
.seam-modal-done {
  background: var(--charcoal, #333);
  color: #fff;
  font-family: var(--mono), monospace;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 3px;
}
.seam-modal-done:hover { background: #b45309; }

.seam-modal-delete {
  font-family: var(--mono), monospace;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #b91c1c;
  padding: 5px 10px;
  border: 1px solid #fecaca;
  border-radius: 3px;
}
.seam-modal-delete:hover { background: #fef2f2; border-color: #ef4444; }

/* Notch popup length input (reuses .seam-modal-* layout). */
#notch-length-input {
  width: 62px;
  font-family: var(--mono), monospace;
  font-size: var(--fs-sm);
  color: var(--charcoal, #333);
  border: 1px solid rgba(120, 80, 30, 0.25);
  border-radius: 3px;
  padding: 3px 5px;
  outline: none;
  text-align: right;
}
#notch-length-input:focus { border-color: #b45309; }

.piece-path.selected {
  stroke: #d97706;
  stroke-width: 2;
  fill: rgba(124, 58, 237, 0.07);
}

.piece-label {
  font-family: var(--sans), system-ui, sans-serif;
  font-size: var(--fs-md);
  font-weight: 600;
  fill: #6b7280;
  pointer-events: none;
  user-select: none;
}

/* Selected piece: the title is clickable to rename it in place. The
   pointer-events override here (not just the SVG attribute) is required because
   the base `.piece-label` rule sets pointer-events:none, and a stylesheet rule
   beats an element presentation attribute. */
.piece-label.editable {
  cursor: text;
  fill: #374151;
  pointer-events: auto;
}
.piece-label.editable:hover { fill: #7dafc4; }

/* In-place rename overlay anchored over the on-canvas title. */
.piece-title-input {
  position: absolute;
  z-index: 20;
  font-family: var(--sans), system-ui, sans-serif;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--charcoal-mid);
  padding: 1px 4px;
  border: 1px solid #111827;
  border-radius: 3px;
  background: #fff;
  outline: none;
  min-width: 60px;
}

.piece-bbox {
  fill: none;
  stroke: #d97706;
  stroke-width: 0.8;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

.piece-extra-point {
  fill: #111827;
  stroke: #111827;
  stroke-width: 1;
}

/* Clickable when the piece is selected (click to add/edit a notch). */
.piece-extra-point.clickable { cursor: pointer; }
.piece-extra-point.clickable:hover { fill: #b45309; stroke: #b45309; }

.piece-extra-label {
  font-family: var(--sans), system-ui, sans-serif;
  font-size: var(--fs-2xs);
  fill: #111827;
  user-select: none;
}

/* Outline vertices (extremity points of the outline curves/lines). */
.piece-outline-point {
  fill: #111827;
  stroke: #111827;
  stroke-width: 1;
}

/* Clickable when the piece is selected (click to add/edit a notch). */
.piece-outline-point.clickable { cursor: pointer; }
.piece-outline-point.clickable:hover { fill: #b45309; stroke: #b45309; }
/* Points stay black even when they carry a notch. */
.piece-outline-point.has-notch { fill: #111827; stroke: #111827; }

/* Notch (cran) — thin black tick projected onto the outer seam line, inward. */
.piece-notch {
  stroke: #000;
  stroke-width: 0.4;
  stroke-linecap: butt;
}
.piece-notch.editing { stroke-width: 0.7; }

.piece-outline-label {
  font-family: var(--sans), system-ui, sans-serif;
  font-size: var(--fs-2xs);
  fill: #111827;
  user-select: none;
}

/* Point/reference labels are draggable when their piece is selected. */
.piece-outline-label.draggable,
.piece-extra-label.draggable {
  cursor: move;
}
.piece-outline-label.draggable:hover,
.piece-extra-label.draggable:hover {
  fill: #7dafc4;
}



/* ── Selected-piece floating toolbar (duplicate / rotate) ── */
.piece-toolbar {
  position: absolute;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 2px;
  background: #fff;
  border: 1px solid #d97706;
  border-radius: 5px;
  box-shadow: 0 4px 14px rgba(30, 20, 10, 0.18);
}
.piece-toolbar.hidden { display: none; }

.piece-tool-btn {
  width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--warm-gray);
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
}
.piece-tool-btn:hover { color: #b45309; background: rgba(217, 119, 6, 0.1); }
.piece-tool-btn-danger:hover { color: #dc2626; background: #fef2f2; }
.piece-tool-btn.final-cut-active { color: #2b6a64; }
.piece-tool-btn.final-cut-active:hover { color: #21514c; background: rgba(43, 106, 100, 0.1); }

/* Pieces excluded from the final cut stay visible but dimmed. */
.piece-group.excluded { opacity: 0.4; }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--warm-gray);
  text-align: center;
}

.empty-state .empty-title { font-size: var(--fs-md); color: var(--warm-gray); }

.empty-state .empty-hint { font-size: var(--fs-xs); color: var(--warm-gray); line-height: 1.4; }
