/* ===== Nest Studio — the measured pane's subtabs and its placement editor =====
   The drawing, rail and inspector stay in shared.css; only editing a part lives here. */

/* Sheet and Part are subtabs here, the same split the inspector makes on the right */
.nest-measured-side { display: flex; flex-direction: column; min-height: 0; gap: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); overflow: hidden; }
.nest-measured-side .nest-inspector-body { padding: 0.5rem 0.6rem 0.7rem; }
.nest-measured-side .nest-pick-head { margin-top: 0; }
.nest-measured-side .nest-pick-list { overflow-y: visible; }

/* --- Dragging a part out of the list to cut another copy of it --- */

/* the grip goes before the row's button, so the row itself becomes the flex line */
.nest-pick-list li[draggable="true"] { display: flex; align-items: center; cursor: grab; }
.nest-pick-list li[draggable="true"]:active { cursor: grabbing; }
.nest-pick-list li.is-dragging { opacity: 0.4; }
/* six dots, the usual sign that a row is picked up rather than pressed */
.nest-pick-grip { flex: none; width: 0.5rem; height: 1rem; margin-left: 0.25rem;
  background-image: radial-gradient(var(--border) 42%, transparent 44%);
  background-size: 0.25rem 0.33rem; }
.nest-pick-list li[draggable="true"]:hover .nest-pick-grip {
  background-image: radial-gradient(var(--text-muted) 42%, transparent 44%); }
/* the stage says it will take the drop, in the blue everything picked is marked in */
#nests-nest-stage.is-drop-target { outline: 2px dashed var(--primary); outline-offset: -4px; }

/* --- A measured part's copies, one editable row each --- */

/* the seq column is fixed, the three numbers share what is left, and flip/delete sit at the end */
.nest-placement-grid { display: flex; flex-direction: column; gap: 0.2rem; }
.nest-placement-head,
.nest-placement-row { display: grid; grid-template-columns: 1.1rem repeat(3, minmax(0, 1fr)) 1.6rem 1.7rem;
  gap: 0.25rem; align-items: center; }
/* a read-only panel has no delete button, so its rows stop a column short */
.nest-placement-row:not([data-placement]) { grid-template-columns: 1.1rem repeat(3, minmax(0, 1fr)) 1fr; }
.nest-placement-head { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint); padding-bottom: 0.15rem; }
.nest-placement-seq { font-size: 0.7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nest-placement-read { font-size: 0.72rem; color: var(--text); font-variant-numeric: tabular-nums; }
.nest-placement-row input[type="number"] { width: 100%; min-width: 0; font-size: 0.72rem;
  padding: 0.1rem 0.25rem; font-variant-numeric: tabular-nums; }
.nest-placement-flip { display: flex; justify-content: center; }
.nest-placement-del { width: 1.6rem; height: 1.6rem; padding: 0; }

/* says why a row is not on the sheet, in the row itself rather than a summary underneath it */
.nest-flag { margin-left: 0.35rem; padding: 0 0.3rem; border-radius: 0.6rem;
  border: 1px solid var(--border); background: var(--row-stripe); color: var(--text-muted);
  font-size: 0.6rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }

/* a name or a count riding on a section title, which is uppercased and tracked out */
.nest-sub-name { font-family: monospace; font-size: 0.78rem; letter-spacing: 0;
  text-transform: none; font-weight: 500; color: var(--text); }
.nest-count { font-family: monospace; font-size: 0.72rem; letter-spacing: 0;
  text-transform: none; color: var(--text-muted); margin-left: 0.35rem; }

/* the outline's own box on the sheet, under the editable anchor it is derived from · a flex
   sibling of the rows rather than a cell in one, so it indents past the seq column by hand */
.nest-placement-at { padding-left: 1.35rem; margin: -0.05rem 0 0.15rem; font-size: 0.62rem;
  color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* --- Moving a part on the stage: locked by default, then proposed before it is saved --- */

.nest-measured-stage-wrap { position: relative; min-height: 0; display: flex; }
.nest-measured-stage-wrap .nest-measured-stage { flex: 1; min-width: 0; }
/* the palette is a tab of the side panel · its tiles are dragged across onto the stage */
.nest-palette-add { width: 100%; margin-bottom: 0.5rem; }
.nest-palette-items { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.nest-palette-tile { flex: none; display: grid; gap: 0.1rem; justify-items: start; padding: 0.35rem 0.5rem; border: 1px solid var(--cell-border-h);
  border-radius: 6px; background: var(--surface); font-size: 0.75rem; }
.nest-palette-tile[draggable="true"] { cursor: grab; }
.nest-palette-tile.is-dragging { opacity: 0.5; }
.nest-palette-tile svg { width: 6.5rem; height: 2.1rem; display: block; }
.nest-palette-tile svg polygon { fill: var(--badge-success-bg); stroke: var(--success); }
.nest-palette-tile .nest-pick-meta { color: var(--text-faint); }

/* --- The canvas is a bar above a drawing, not a drawing with things floating on it --- */

.nest-canvas-pane { display: flex; flex-direction: column; }
/* the bar takes its own height, so nothing it holds can ever cover the sheet or the rail */
.nest-canvas-bar { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto;
  padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.nest-canvas-bar .nest-file-combo { width: 12rem; flex: 0 0 auto; }
.nest-bar-gap { flex: 1 1 auto; }
/* the drawing takes what is left, and is what the overlays still pin to */
.nest-canvas-body { position: relative; flex: 1 1 auto; min-height: 0; }
.nest-canvas-body > #nests-viewer-empty { position: absolute; inset: 0; margin: 0;
  display: grid; place-items: center; }

/* the measured pane carries its own Sheet/Part panel, so the workspace inspector stands down */
.nest-workspace.is-measured { grid-template-columns: var(--rail-col) minmax(0, 1fr) 0; }

/* the toggle rides at the far right of the band, exactly where the inspector's own sits */
.nest-measured-side .btn-collapse-panel { margin-left: auto; align-self: center; }
/* and it folds to a spine on the same toggle the inspector uses, since it stands in for it */
.nest-workspace.panel-collapsed .nest-measured { grid-template-columns: 11rem minmax(0, 1fr) var(--spine-w); }
.nest-workspace.panel-collapsed .nest-measured-side .nest-inspector-body { display: none; }
/* folded, the band is the toggle and nothing else, so it reads as the way back out at the top */
.nest-workspace.panel-collapsed .nest-measured-side .tab-btn { display: none; }
.nest-workspace.panel-collapsed .nest-measured-side .tab-bar { padding: 0.25rem; border-bottom: none;
  justify-content: center; }
.nest-workspace.panel-collapsed .nest-measured-side .btn-collapse-panel { margin-left: 0; }
/* and it picks its sheet from its own rail, so the prev/next arrows say nothing there */
.nest-workspace.is-measured .nest-overlay-nav { display: none; }

.nest-tool-row { display: flex; gap: 0.25rem; flex: 0 0 auto; }
.nest-tool { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.5rem;
  border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
  font: inherit; font-size: 0.72rem; color: var(--text-sub); cursor: pointer; white-space: nowrap; }
.nest-tool:hover:not(:disabled) { background: var(--row-hover); }
.nest-tool:disabled { opacity: 0.45; cursor: not-allowed; }
.nest-tool .icon-slot { display: inline-flex; width: 0.85rem; height: 0.85rem; }
/* a tool reads as pressed while it is the one the canvas is listening to */
.nest-tool.is-on { background: var(--row-selected); border-color: var(--primary); color: var(--primary); }
.nest-tool--slim { padding: 0.25rem 0.4rem; }
.nest-tool kbd { padding: 0 0.2rem; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 3px; background: var(--table-surface); font: 600 0.6rem ui-monospace, Menlo, Consolas, monospace;
  color: var(--text-faint); }
/* the line that says what the canvas will do next, so the buttons are never silent */
.nest-tool-say { margin: 0; font-size: 0.66rem; color: var(--text-muted); white-space: nowrap; }

.nest-tool-active { padding: 0.1rem 0.45rem; border-radius: 10px; background: var(--primary);
  color: #fff; font-size: 0.64rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
/* how far the keep-out stands in, set where the button that draws it is */
.nest-inset { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem 0.35rem;
  border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
  font-size: 0.66rem; color: var(--text-muted); }
.nest-inset input { width: 3.1rem; padding: 0.1rem 0.2rem; font-size: 0.7rem;
  font-variant-numeric: tabular-nums; }

/* the proposal sits at the foot of the stage, where it cannot be mistaken for part of the panel */
.nest-overlay-confirm { left: 50%; bottom: 0.6rem; transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.5rem;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  box-shadow: 0 2px 8px var(--shadow-md); }
.nest-move-readout { font-size: 0.7rem; color: var(--text-sub); font-variant-numeric: tabular-nums;
  padding-right: 0.2rem; }
/* a mate lands flush, then this backs it off · it sits with the result, not up on the bar */
.nest-gap-field { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1rem 0.35rem;
  border: 1px solid var(--border); border-radius: 4px; background: var(--table-surface);
  font-size: 0.66rem; color: var(--text-muted); }
.nest-gap-field input { width: 3.6rem; padding: 0.1rem 0.25rem; font-size: 0.72rem;
  font-variant-numeric: tabular-nums; }

/* stacked, since two sets of coordinates never fit side by side across a column this narrow */
.nest-placement-at { display: flex; flex-direction: column; align-items: flex-start; gap: 0.05rem; }

/* --- The pointer says which tool has the canvas, since the tool decides what a click takes --- */

/* a hairline cross with a hole at the middle, so the pixel about to be taken is never under the icon ·
   the badge hangs off the lower right, clear of the target, and the hotspot is the centre at 16,16 */
.stage3d.is-measuring .stage3d-canvas {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><g stroke="%230f766e" stroke-width="1.3" stroke-linecap="round"><path d="M16 3v9M16 20v9M3 16h9M20 16h9"/></g><circle cx="16" cy="16" r="1.1" fill="%230f766e"/><g transform="translate(19.5,19.5)"><rect x="0" y="2.5" width="11.5" height="6" rx="1" fill="white" stroke="%230f766e" stroke-width="1.2"/><g stroke="%230f766e" stroke-width="1"><path d="M3 2.5v2.4M6 2.5v3.2M9 2.5v2.4"/></g></g></svg>') 16 16, crosshair;
}
.stage3d.is-mating .stage3d-canvas {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><g stroke="%23213284" stroke-width="1.3" stroke-linecap="round"><path d="M16 3v9M16 20v9M3 16h9M20 16h9"/></g><circle cx="16" cy="16" r="1.1" fill="%23213284"/><g transform="translate(19.5,19)" stroke="%23213284" stroke-width="1.3" fill="none" stroke-linecap="round"><path d="M10.5 0.5v11M1 6h5.5M4.6 3.8 6.9 6 4.6 8.2"/></g></svg>') 16 16, crosshair;
}
.stage3d.is-moving .stage3d-canvas {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><g stroke="%23141413" stroke-width="1.3" stroke-linecap="round"><path d="M16 3v9M16 20v9M3 16h9M20 16h9"/></g><circle cx="16" cy="16" r="1.1" fill="%23141413"/><g transform="translate(19.5,19.5)" stroke="%23141413" stroke-width="1.2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M5.5 0.5v10M0.5 5.5h10M3.6 2.4 5.5 0.5l1.9 1.9M3.6 8.6l1.9 1.9 1.9-1.9M2.4 3.6.5 5.5l1.9 1.9M8.6 3.6l1.9 1.9-1.9 1.9"/></g></svg>') 16 16, move;
}
/* turning the view is still turning the view, whichever tool is being held */
.stage3d.is-measuring .stage3d-canvas--dragging,
.stage3d.is-mating .stage3d-canvas--dragging,
.stage3d.is-moving .stage3d-canvas--dragging { cursor: grabbing; }

/* --- Measuring, and the key list --- */

/* teal throughout, and centred over the stage it belongs to rather than the list beside it */
.nest-overlay-measure { left: 50%; top: 0.6rem; transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.55rem; border-radius: 12px; background: var(--surface);
  border: 1px solid #0f766e; box-shadow: 0 1px 3px var(--shadow-sm); white-space: nowrap; }
.nest-measure-tag { font-size: 0.68rem; font-weight: 600; color: #0f766e; }
/* what the number in front of it is a measurement of, since one pick already measures something */
.nest-measure-kind { padding: 0 0.3rem; border-radius: 0.6rem; background: var(--row-stripe);
  color: var(--text-muted); font-size: 0.6rem; font-weight: 600; letter-spacing: 0.02em; }
#nests-measure-readout { display: flex; align-items: baseline; gap: 0.45rem; font-size: 0.72rem;
  color: var(--text); font-variant-numeric: tabular-nums; }
#nests-measure-readout b { color: #0f766e; font-size: 0.78rem; }
.nest-measure-part { color: var(--text-muted); font-size: 0.66rem; }
.nest-measure-hint { color: var(--text-faint); font-size: 0.68rem; }

.nest-overlay-keys { right: 0.6rem; bottom: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 2px 8px var(--shadow-md); }
.nest-key-title { margin: 0 0 0.3rem; font-size: 0.62rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted); }
.nest-key-row { display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.5rem; align-items: center;
  padding: 0.1rem 0; font-size: 0.7rem; color: var(--text-sub); white-space: nowrap; }
.nest-key { display: inline-block; min-width: 1rem; padding: 0.05rem 0.3rem; border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 3px; background: var(--table-surface);
  font: 600 0.64rem ui-monospace, Menlo, Consolas, monospace; color: var(--text-sub); text-align: center; }

/* --- Nothing in this panel wraps: it is numbers and short names in a narrow column --- */

/* a wrapped row reflows everything under it, so long text is cut with an ellipsis instead */
.nest-measured-side .nest-measured-facts dt,
.nest-measured-side .nest-measured-facts dd,
.nest-measured-side .nest-pick-name,
.nest-measured-side .nest-pick-meta,
.nest-measured-side .info-section-title,
.nest-placement-head > span,
.nest-move-readout { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* the value side is what gives, since the label names the row */
.nest-measured-side .nest-measured-facts dd { min-width: 0; text-align: right; }
.nest-measured-side .nest-measured-facts dt { flex-shrink: 0; }
.nest-measured-side .nest-pick-name { min-width: 0; }
/* the flag is part of the name cell, so it must not be the thing that gets clipped */
.nest-measured-side .nest-pick-name .nest-flag { flex-shrink: 0; }
/* coordinates are the point of this line, so it is the one thing allowed to take a second row */
.nest-placement-at span { min-width: 0; white-space: normal; overflow: visible; }

/* the assembly export · an entry over a list of sheets that tick, and a spacing with its unit beside it */
.nest-assembly-entry { position: relative; }
.nest-assembly-entry input { width: 100%; padding-right: 5.5rem; }
.nest-assembly-count { position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); font-size: 0.75rem; color: var(--text-muted); pointer-events: none; }
.nest-assembly-list { margin-top: 0.3rem; border: 1px solid var(--cell-border-h); border-radius: 6px; max-height: 15rem; overflow-y: auto; }
.nest-assembly-list-top { display: flex; justify-content: space-between; padding: 0.3rem 0.6rem; z-index: 1; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.nest-assembly-row { display: grid; grid-template-columns: 1.1rem minmax(0, 1fr) auto; gap: 0.4rem; align-items: center; width: 100%; padding: 0.25rem 0.6rem;
  border: 0; border-bottom: 1px solid var(--border); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.nest-assembly-row:last-child { border-bottom: 0; }
.nest-assembly-row.is-selected { background: var(--surface-deep); }
.nest-assembly-tick { visibility: hidden; color: var(--primary); display: inline-flex; }
.nest-assembly-row.is-selected .nest-assembly-tick { visibility: visible; }
.nest-spacing { display: flex; gap: 0.4rem; align-items: stretch; }
.nest-spacing input { flex: 1; min-width: 0; }
/* the Sheet tab's toolpath · the tool and Keep Parts Whole, then what leaves the blade too little room */
.nest-toolpath { display: grid; gap: 0.35rem; margin: 0.4rem 0 0.6rem; }
.nest-toolpath-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; }
.nest-toolpath-row .info-label { min-width: 3rem; }
.nest-toolpath-row select { flex: 1; min-width: 0; }
.nest-toolpath-problems { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; font-size: 0.76rem; }
.nest-toolpath-problems li { display: flex; gap: 0.35rem; align-items: baseline; }
