*, *::before, *::after { box-sizing: border-box; }

body {
  font-size: 13px;
  background: #e8e8e8;
  margin: 0;
  overflow: hidden;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.label-xs  { font-size: 11px; color: #555; display: block; margin-bottom: 1px; }
.label-xs.label-inline { display: inline; margin-bottom: 0; }
.label-sm  { font-size: 12px; color: #333; }
.btn-xs    { font-size: 11px; padding: 2px 7px; line-height: 1.4; border-radius: 3px; }
.form-control-xs  { font-size: 12px; padding: 2px 6px; height: 26px; }
.form-select-xs   { font-size: 12px; padding: 2px 22px 2px 6px; height: 26px; }

/* ── App layout ──────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════════
   LEFT PANEL
══════════════════════════════════════════════════════════════════════════ */
.panel-left {
  width: 300px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #ccc;
  flex-shrink: 0;
}

/* ── Left tab nav ──────────────────────────────────────────────────────── */
.left-tab-nav {
  display: flex;
  border-bottom: 1px solid #ddd;
  background: #f5f5f5;
  flex-shrink: 0;
}
.left-tab {
  flex: 1;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  color: #666;
  transition: color .12s, border-color .12s;
}
.left-tab:hover  { color: #333; background: #ececec; }
.left-tab.active { color: #0d6efd; border-bottom-color: #0d6efd; background: #fff; }

/* ── Left panes ────────────────────────────────────────────────────────── */
.left-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 8px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
}
.panel-header-tp {
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
}
.panel-header-tp .tp-add-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-left: auto;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

/* Toolpath list */
.tp-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

.tp-list-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 8px;
  background: #f5f5f5;
  border-top: 1px solid #ddd;
}
.tp-footer-main {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: space-between;
}
.tp-footer-save-clear {
  margin-left: auto;
}
.tp-list-footer .btn {
  height: 24px;
  min-height: 24px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.tp-icon-btn {
  padding: 2px 7px;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
}
.tp-icon-btn img {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}
.tp-icon-btn:disabled img {
  opacity: 0.45;
}
.tp-aspire-import-btn {
  color: #9E311C;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0 8px;
  min-width: auto;
  line-height: 1;
  gap: 4px;
}
.tp-aspire-import-btn:hover:not(:disabled) {
  color: #7a2515;
}
.tp-add-icons .tp-icon-btn {
  padding: 2px 5px;
  min-width: 26px;
  flex-shrink: 0;
}
.tp-footer-icon-actions {
  max-width: 100%;
}

/* Each toolpath row */
.tp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  user-select: none;
  min-width: 0;
  width: 100%;
}
.tp-row:hover   { background: #eef4ff; }
.tp-row.active  { background: #d0e4ff; }

.tp-type-icon {
  flex-shrink: 0;
  width: 18px; height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5a6b80;
}
.tp-row.active .tp-type-icon { color: #1c4e8a; }
.tp-type-icon svg { display: block; }
/* Per-type accent so the icon also reads by color, not shape alone */
.tp-type-icon svg[data-tp-type="drill"]   { color: #c0392b; }
.tp-type-icon svg[data-tp-type="pocket"]  { color: #2e7d32; }
.tp-type-icon svg[data-tp-type="profile"] { color: #2b6cb0; }
.tp-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.2);
}
.tp-info {
  flex: 1;
  min-width: 0;
}
.tp-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tp-meta {
  font-size: 10px;
  color: #888;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tp-row-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  opacity: 1;
  transition: color 0.1s;
}
.tp-row-delete:hover { color: #dc3545; }
.tp-row-duplicate {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #888;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  opacity: 1;
  transition: color 0.1s;
}
.tp-row-duplicate:hover { color: #0d6efd; }
.tp-row-drag {
  flex-shrink: 0;
  color: #888;
  font-size: 14px;
  line-height: 1;
  cursor: grab;
  padding: 0 2px;
  user-select: none;
}
.tp-row-dragging {
  opacity: 0.5;
}

/* ── Layers pane ───────────────────────────────────────────────────────── */
.layer-list {
  flex: 1;
  overflow-y: auto;
}
.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid #f0f0f0;
}
.layer-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: #2c3e50;
  flex-shrink: 0;
  border-radius: 4px;
}
.layer-eye:hover { background: #eef2f6; }
.layer-eye.off { color: #b0b6bd; }
.layer-row-all {
  background: #f7f9fb;
  border-bottom: 1px solid #e3e8ee;
}
.layer-name-all { font-weight: 600; color: #2c3e50; }
.layer-row.layer-hidden .layer-name,
.layer-row.layer-hidden .layer-swatch { opacity: 0.45; }
.layer-swatch {
  width: 28px;
  height: 20px;
  border: 1px solid #bbb;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.layer-name {
  flex: 1;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-empty {
  padding: 20px 12px;
  font-size: 12px;
  color: #aaa;
  font-style: italic;
  text-align: center;
}

/* ── Tools pane ─────────────────────────────────────────────────────────── */
.tool-list {
  flex: 1;
  overflow-y: auto;
}
.tool-item {
  border-bottom: 1px solid #eee;
}
.tool-item-chevron {
  font-size: 10px;
  line-height: 1;
  color: #888;
  width: 14px;
  flex-shrink: 0;
  text-align: center;
}
.tool-item--expanded .tool-item-chevron {
  color: #0d6efd;
}
.tool-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  cursor: pointer;
  user-select: none;
}
.tool-row:focus {
  outline: 2px solid rgba(13, 110, 253, 0.45);
  outline-offset: -2px;
}
.tool-row:hover  { background: #eef4ff; }
.tool-row.active { background: #d0e4ff; }

.tool-num-badge {
  font-size: 10px;
  font-weight: 700;
  font-family: monospace;
  background: #6c757d;
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
  min-width: 24px;
  text-align: center;
}
.tool-row.active .tool-num-badge { background: #0d6efd; }

.tool-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-del {
  font-size: 10px;
  padding: 0 5px;
  line-height: 1.6;
  flex-shrink: 0;
}

.tool-editor-body {
  padding: 6px 8px 10px;
  background: #f8f9fa;
  border-top: 1px solid #dce3ec;
}
.tool-section-hdr {
  font-size: 10px;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 2px;
  margin: 7px 0 4px;
}

/* Footer */
.panel-footer {
  padding: 8px;
  border-top: 1px solid #ddd;
  background: #f5f5f5;
  flex-shrink: 0;
}

.post-name-inline {
  font-size: 10px;
  line-height: 1.2;
  max-width: 11em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-bar {
  font-size: 11px;
  word-break: break-all;
}

/* ══════════════════════════════════════════════════════════════════════════
   RIGHT PANEL
══════════════════════════════════════════════════════════════════════════ */
.panel-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Preview toolbar */
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
}

/* ── Right tab nav ──────────────────────────────────────────────────────── */
.right-tab-nav {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.right-tab {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #ccc;
  border-radius: 3px 3px 0 0;
  background: #e8e8e8;
  cursor: pointer;
  color: #666;
  transition: background .1s, color .1s;
}
.right-tab:hover  { background: #ddd; color: #333; }
.right-tab.active { background: #fff; color: #0d6efd; border-bottom-color: #fff; }

/* ── Right panes (preview areas) ────────────────────────────────────────── */
.right-pane {
  flex: 1;
  overflow: auto;
  background: #6e6e6e;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 12px;
  min-height: 0;
}

.preview-hint {
  width: 100%;
  color: #bbb;
  font-size: 14px;
  text-align: center;
  padding: 40px 0;
  pointer-events: none;
}

#pane-selected-sheet {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-content: stretch;
  gap: 0;
  padding: 0;
}
#pane-selected-sheet .selected-sheet-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
#pane-selected-sheet .selected-sheet-layers-dock {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #ddd;
  color: #222;
  cursor: default;
  z-index: 30;
}
#pane-selected-sheet .selected-sheet-layers-dock.d-none {
  display: none !important;
}
#pane-selected-sheet .selected-sheet-layers-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}
#pane-selected-sheet .selected-sheet-layers-host {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
#pane-selected-sheet .selected-sheet-layers-host .layer-list {
  height: 100%;
}
#btn-sheet-layers.active {
  background: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

/* Individual sheet card */
.sheet-container {
  display: inline-flex;
  flex-direction: column;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 3px;
  padding: 2px;
  transition: border-color .12s;
}
.sheet-container:hover          { border-color: rgba(255,255,255,.35); }
.sheet-container.active         { border-color: #5ba4f5; }

.sheet-label {
  font-size: 10px;
  font-weight: 600;
  color: #ddd;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.sheet-container svg {
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
}

/* ── Toolpath tool selector ──────────────────────────────────────────────── */
.ed-tool-row { }
.ed-tool-display {
  font-size: 12px;
  color: #888;
  padding: 3px 6px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #f8f9fa;
  min-height: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ed-tool-display.has-tool {
  color: #212529;
  background: #eef4ff;
  border-color: #c5d8ff;
}

/* Tool picker modal */
.tp-tool-picker-dialog {
  max-width: 360px;
}

/* Tool picker modal rows */
.tp-tool-pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.tp-tool-pick-row:hover  { background: #f0f4ff; }
.tp-tool-pick-row.active { background: #d0e4ff; }
.tp-tool-pick-row.muted  { opacity: 0.55; }
.tp-tool-pick-info {
  flex: 1;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tp-tool-pick-note {
  font-size: 10px;
  color: #dc3545;
  white-space: nowrap;
}

/* ── Toolpath editor ─────────────────────────────────────────────────────── */
/* Toolpath editor — a centered popup dialog (below Bootstrap modals @1055 so the
   passes / tool-picker / tag-picker modals stack on top). */
.tp-editor {
  background: #fff;
  border: 1px solid #c5d8ff;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.32);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, 94vw);
  height: auto;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1045;
}
#tp-editor {
  min-height: 500px;
  height: auto;
}
.tp-editor-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1044;
}
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #e8f0ff;
  border-bottom: 1px solid #c5d8ff;
  flex-shrink: 0;
  gap: 8px;
}
.editor-header-title {
  min-width: 0;
}
.ed-type-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
.ed-type-label {
  font-weight: 600;
  color: #4a5d73;
  text-transform: none;
}
.editor-title {
  min-width: 0;
  flex: 1;
}
.editor-body {
  padding: 8px 10px;
  overflow-y: auto;
  flex: 1 1 auto;
}
#tp-editor .editor-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
#tp-editor .editor-body > :not(#sec-tags) {
  flex: 0 0 auto;
}

/* Compact tool-editor popup: numeric inputs stay narrow (~1/3), fields pack into
   flex rows; only the name/notes fields grow. */
.tool-field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 6px;
  align-items: flex-end;
}
.tool-field { min-width: 0; }
#tool-editor-mount input.form-control-xs[type="number"] { width: 96px; }
#tool-editor-mount .form-select-xs { width: 150px; }
#tool-editor-mount input.form-control-xs[type="text"] { width: 230px; max-width: 100%; }
#tool-editor-mount textarea.tool-notes { width: 100%; }

/* The tool-editor dialog sizes to its content (compact) rather than a fixed width. */
#tool-editor-modal {
  width: fit-content;
  min-width: 350px;
  max-width: 94vw;
}

/* ── Compact editor layout helpers ───────────────────────────────────────── */
.ed-inline-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-end;
}
.ed-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
/* Name field: grows to fill space */
.ed-field-grow { flex: 1 1 70px; min-width: 0; }
.ed-field-tool  { flex: 1 1 100px; min-width: 0; }
.ed-field-actions { flex: 0 0 auto; }
.ed-field-tags { flex: 1 1 100%; min-width: 0; }
.ed-depth-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  align-items: end;
}
.ed-depth-row .ed-col-2 {
  grid-column: span 2;
  min-width: 0;
  width: auto;
  max-width: none;
}
.ed-depth-row .ed-col-1 {
  grid-column: span 1;
  min-width: 0;
}
.ed-depth-row .ed-col-2 > .d-flex {
  width: 100%;
}
.ed-depth-row .ed-col-2 .ed-input-num {
  flex: 1 1 auto;
  width: 100% !important;
  min-width: 0;
}
.ed-tool-actions-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-items: end;
}
.ed-tool-actions-row .ed-field-tool {
  grid-column: span 2;
  width: auto;
  max-width: none;
}
.ed-tool-actions-row .ed-field-actions {
  grid-column: span 1;
  width: auto;
  max-width: none;
}
.ed-input-num   { width: 56px !important; }
#tp-editor .ed-inline-group > .ed-field {
  flex: 1 1 100px;
  min-width: 0;
}
#tp-editor .editor-body .mb-1 {
  margin-bottom: 14px !important;
}
#tp-editor .btn-group-xs {
  flex-wrap: wrap;
  max-width: 100%;
}
#tp-editor .btn-group-xs > .btn,
#tp-editor .btn-group-xs > .btn-check + .btn {
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 4px;
  padding-right: 4px;
}

/* Passes field: label + "Edit passes" button matching the input height (26px) */
#ed-passes-readout-group { flex: 0 0 auto; }
#ed-passes-edit-btn {
  white-space: nowrap;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* "Specify Pass Depths" modal rows */
.gcm-pass-row .gcm-pass-label { min-width: 54px; }
.gcm-pass-row .ed-input-num   { width: 90px !important; }

/* ── btn-group size override (xs) ────────────────────────────────────────── */
.btn-group-xs > .btn,
.btn-group-xs > .btn-check + .btn {
  font-size: 11px;
  padding: 2px 6px;
  line-height: 1.5;
}

.profile-feed-markers {
  opacity: 0.7;
  z-index: 0;
  position: relative;
}

.profile-toolpath-stroke {
  z-index: 1;
  position: relative;
}

/* ── Starting-point picker grid ──────────────────────────────────────────── */
.start-pt-grid {
  display: grid;
  grid-template-columns: repeat(3, 22px);
  grid-template-rows:    repeat(3, 22px);
  gap: 3px;
}
.start-pt-cell {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #9ab;
  background: #fff;
  padding: 0;
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.start-pt-cell:hover   { border-color: #0d6efd; background: #eef4ff; }
.start-pt-cell.active  { background: #0d6efd; border-color: #0a58ca; }
.start-pt-grid-spacer {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

/* Tag chips */
.tag-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 5px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  min-height: 30px;
  max-height: 30px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
}
#sec-tags {
  width: 100%;
  flex: 1 0 auto;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}
#sec-tags > .label-xs {
  flex: 0 0 auto;
}
#sec-tags > .d-flex {
  width: 100%;
  flex: 1 1 auto;
  min-height: 100px;
  align-items: stretch;
}
#sec-tags .tag-chips,
#sec-tags .profile-tag-chips {
  flex: 1 1 auto !important;
  width: 100%;
  min-width: 0;
  min-height: 100px;
  height: auto;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  align-content: flex-start;
  align-self: stretch;
}
#sec-tags > .d-flex > .flex-shrink-0 {
  align-self: flex-start;
}
.profile-tag-chips {
  flex-wrap: wrap;
  white-space: normal;
  max-height: none;
}
.chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid #adb5bd;
  background: #e9ecef;
  color: #555;
  user-select: none;
  transition: background .12s, color .12s;
}
.chip.on {
  background: #0d6efd;
  color: #fff;
  border-color: #0a58ca;
}
.chip.no-tags {
  color: #aaa;
  cursor: default;
  font-style: italic;
}
.chip.chip-assigned {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-right: 4px;
}
.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  border: none;
  background: rgba(0,0,0,0.12);
  color: inherit;
  padding: 0;
}
.chip.chip-assigned.on .chip-remove {
  background: rgba(255,255,255,0.25);
}
.chip-remove:hover {
  opacity: 1;
}
/* Tag picker modal rows */
.tag-picker-list {
  max-height: 50vh;
}
.tag-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
.tag-picker-row:hover { background: #f0f4ff; }
.tag-picker-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.15);
  flex-shrink: 0;
}
.tag-picker-label {
  flex: 1;
  font-size: 12px;
  color: #333;
  cursor: pointer;
}

.ms-datum-grid {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  grid-template-rows: repeat(3, 28px);
  gap: 5px;
}
.ms-datum-cell {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #444;
  background: #fff;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.ms-datum-cell:hover { background: #f0f4ff; }
.ms-datum-cell.active {
  background: #212529;
  border-color: #212529;
}

.ms-z-zero-options {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: center;
}
.ms-z-zero-options .form-check {
  flex: 0 0 auto;
  white-space: nowrap;
}

.post-raw-pre {
  min-height: 240px;
}

.gcode-result-preview {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.35;
  max-height: min(55vh, 520px);
  overflow: auto;
  white-space: pre;
  word-break: normal;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #f8f9fa;
  color: #212529;
}

/* ── 3D toolpath preview overlay ───────────────────────────────────────── */
#preview3d-overlay {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  background: #20242a;
}
.preview3d-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: #2b313a;
  color: #e8eaed;
  font-size: 12px;
  flex: 0 0 auto;
}
.preview3d-title { font-weight: 600; white-space: nowrap; }
.preview3d-views { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.preview3d-views .btn { padding: 1px 8px; }
.preview3d-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  overflow: hidden;
}
.preview3d-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.preview3d-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.preview3d-canvas {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: block;
}

.preview3d-playbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  background: #2b313a;
  flex: 0 0 auto;
}
.preview3d-play { width: 34px; }
.preview3d-speed {
  width: 64px;
  font-size: 11px;
  padding: 2px 4px;
  background: #20242a;
  color: #e8eaed;
  border-color: #444;
}
.preview3d-slider { flex: 1 1 auto; }
.preview3d-clock {
  color: #e8eaed;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 2D simulation overlay shares the 3D overlay chrome */
.preview2d-overlay {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  background: #20242a;
}

.preview2d-panel {
  position: absolute;
  z-index: 6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.preview2d-panel-gcode {
  left: 12px;
  top: 56px;
  width: 270px;
  max-height: 52%;
}
.preview2d-panel-info {
  left: 12px;
  bottom: 56px;
  width: 210px;
}
.preview2d-panel-sheets {
  right: 12px;
  top: 56px;
  width: 210px;
  max-height: calc(100% - 120px);
}
.preview2d-sheets {
  display: flex;
  flex-direction: column;
  padding: 4px;
  gap: 3px;
}
.preview2d-sheet-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #dfe6ef;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.3;
}
.preview2d-sheet-row:hover {
  background: rgba(255, 255, 255, 0.14);
}
.preview2d-sheet-row-active {
  background: #3a6fd8;
  border-color: #6f9dff;
  color: #fff;
}
.preview2d-sheet-num {
  flex: 0 0 auto;
  min-width: 18px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.preview2d-sheet-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.preview2d-sheet-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview2d-sheet-dims {
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}
.preview2d-playall {
  flex: 0 0 auto;
  min-width: 40px;
}
.preview2d-playall-on {
  background: #3a6fd8;
  border-color: #6f9dff;
  color: #fff;
}
.preview2d-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 5px 8px 5px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #e6ebf2;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
}
.preview2d-panel-title {
  flex: 1 1 auto;
  min-width: 0;
}
.preview2d-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.preview2d-panel-collapsed .preview2d-panel-body {
  display: none;
}
.preview2d-panel-collapsed .preview2d-panel-head {
  border-bottom: none;
}
.preview2d-gcode-copy {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  padding: 2px;
  line-height: 0;
  cursor: pointer;
  opacity: 0.85;
  border-radius: 3px;
}
.preview2d-gcode-copy:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}
.preview2d-gcode-copy img {
  width: 14px;
  height: 14px;
  display: block;
}
.preview2d-gcode-copy-toast {
  display: none;
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 600;
  color: #9fe3a8;
  white-space: nowrap;
  pointer-events: none;
}
.preview2d-gcode-copy-toast.preview2d-gcode-copy-toast-visible {
  display: inline;
}
.preview2d-gcode {
  padding: 6px 0;
  overflow: auto;
  color: #cdd6e0;
  white-space: pre;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
}
.preview2d-cutinfo {
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.55;
  color: #f2f2f2;
  overflow-wrap: anywhere;
  font-family: ui-monospace, Consolas, monospace;
}
.preview2d-gcode-line {
  cursor: pointer;
  padding: 0 10px;
}
.preview2d-gcode-line-cur {
  background: #3a6fd8;
  color: #fff;
  font-weight: 700;
}
.preview2d-gcode-ln {
  opacity: 0.45;
}
.preview2d-clipboard-ta {
  position: fixed;
  opacity: 0;
  left: -9999px;
  top: 0;
}
