/* STL to G-code Converter: loader, 3D preview, placement, slicing results and settings.
   Colours come from the shared tokens, so the panel follows the light and dark themes. The preview
   palette below uses documented categorical steps chosen so that feature types that touch in a print
   stay apart under protanopia and deuteranopia (adjacent pairs ΔE ≥ 8.4 OKLab ×100, normal vision ≥ 19.8),
   stepped separately for the dark theme. The legend and the per-feature table carry the same identity. */
.slc {
  --slc-c-outer: #eda100;
  --slc-c-inner: #2a78d6;
  --slc-c-solid: #e87ba4;
  --slc-c-sparse: #008300;
  --slc-c-support: #1baf7a;
  --slc-c-skirt: #6250d6;
  --slc-c-travel: var(--ink-soft);
  --slc-model: var(--action);
  --slc-model-error: var(--error);
  --slc-canvas: var(--field);
  --slc-grid: var(--border-faint);
  --slc-volume: var(--border-soft);
  display: grid;
  gap: 1.1rem;
  padding: clamp(14px, 2.4vw, 32px);
  text-align: left;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shade);
  min-width: 0;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .slc {
    --slc-c-outer: #c98500;
    --slc-c-inner: #3987e5;
    --slc-c-solid: #d55181;
    --slc-c-sparse: #008300;
    --slc-c-support: #199e70;
    --slc-c-skirt: #9085e9;
  }
}
:root[data-theme="dark"] .slc {
  --slc-c-outer: #c98500;
  --slc-c-inner: #3987e5;
  --slc-c-solid: #d55181;
  --slc-c-sparse: #008300;
  --slc-c-support: #199e70;
  --slc-c-skirt: #9085e9;
}
.slc *, .slc *::before, .slc *::after { box-sizing: border-box; }
.slc [hidden] { display: none !important; }
.slc h2 { margin: 0 0 .35rem; font-size: 1.45rem; letter-spacing: -.02em; }
.slc h3 { margin: 0 0 .6rem; font-size: 1.08rem; }
.slc p { margin: 0; color: var(--ink-soft); }
.slc-head p { max-width: 78ch; }
.slc-sub { font-size: .85rem; color: var(--ink-soft); }
.slc-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.slc :is(input, textarea, select, button, summary, a, canvas):focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Controls */
.slc button, .slc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .45rem .9rem;
  font: inherit;
  font-size: .92rem;
  font-weight: 650;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.slc button:disabled { opacity: .5; cursor: default; }
.slc .slc-primary { color: var(--on-action); background: var(--action); box-shadow: 3px 3px 0 var(--shade); }
.slc .slc-primary:hover:not(:disabled):not(.slc-disabled) { background: var(--primary-dark); }
.slc .slc-disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.slc-check { display: flex; align-items: center; gap: .5rem; min-height: 42px; font-size: .92rem; font-weight: 500; }
.slc-check input { flex: none; width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--action); }
.slc-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .65rem .75rem; align-items: start; }
.slc-place .slc-fields { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.slc-field { display: grid; grid-template-rows: auto auto; gap: .25rem; min-width: 0; font-size: .82rem; font-weight: 650; }
.slc-label { display: block; min-height: 2.3em; line-height: 1.15; }
.slc-wide .slc-label { min-height: 0; }
.slc-wide { grid-column: 1 / -1; }
.slc-unit { font-weight: 450; color: var(--ink-soft); }
.slc-help { font-size: .78rem; font-weight: 450; color: var(--ink-soft); }
.slc-error { font-size: .8rem; font-weight: 600; color: var(--error); }
.slc input[type="number"], .slc select, .slc textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: .45rem .55rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
}
.slc textarea { font-family: var(--font-mono); font-size: .8rem; line-height: 1.45; resize: vertical; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.slc [aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 2px var(--error-a25); }
.slc-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Loader */
.slc-load { display: grid; gap: .65rem; padding: 1rem; background: var(--blue-tint); border: 2px dashed var(--line); border-radius: 10px; }
.slc-load[data-over="true"] { border-style: solid; background: var(--action-tint); }
.slc-load-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.slc-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.slc-file:focus-visible + .slc-load-row .slc-primary { outline: 3px solid var(--primary); outline-offset: 2px; }
.slc-examples { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.slc-examples button { min-height: 38px; padding: .35rem .75rem; font-size: .85rem; border-width: 1.5px; }
.slc-status { min-height: 1.4em; font-weight: 600; color: var(--ink) !important; overflow-wrap: anywhere; }
.slc-status[data-kind="error"] { padding: .5rem .75rem; background: var(--error-soft); border-left: 4px solid var(--error); border-radius: 6px; }
.slc-status[data-kind="busy"] { color: var(--ink-soft) !important; }

/* Layout */
.slc-grid { display: grid; gap: 1.25rem; min-width: 0; }
@media (min-width: 1000px) { .slc-grid { grid-template-columns: minmax(0, 1fr) minmax(19rem, 23rem); align-items: start; } }
.slc-main { display: grid; gap: 1rem; min-width: 0; }

/* Model info */
.slc-model, .slc-place, .slc-result { display: grid; gap: .7rem; padding: 1rem; border: 2px solid var(--line); border-radius: 10px; min-width: 0; }
.slc-model { background: var(--paper-3); }
.slc-model-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.slc-model-head h3 { margin: 0; overflow-wrap: anywhere; }
.slc-model-head button { min-height: 38px; font-size: .85rem; border-width: 1.5px; }
.slc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .5rem; margin: 0; }
.slc-stats div { padding: .45rem .6rem; background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 6px; min-width: 0; }
.slc-stats dt { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.slc-stats dd { margin: .15rem 0 0; font: 600 .98rem var(--font-mono); overflow-wrap: anywhere; }
.slc-notes { display: grid; gap: .3rem; margin: 0; padding-left: 1.1rem; font-size: .85rem; color: var(--ink-soft); }
.slc-notes:empty { display: none; }
.slc-note { padding: .45rem .7rem; font-size: .86rem; color: var(--ink) !important; background: var(--warning-soft); border-left: 4px solid var(--warning); border-radius: 6px; }

/* Preview */
.slc-example-preview { display: grid; gap: .45rem; margin: 0; }
.slc-example-preview img { display: block; width: 100%; height: auto; border-radius: 10px; }
.slc-example-preview figcaption { color: var(--ink-soft); font-size: .85rem; }
.slc-view { display: grid; gap: .55rem; min-width: 0; }
.slc-view-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.slc-pills { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; border: 0; }
.slc-pills label { position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: .4rem .95rem; font-size: .92rem; font-weight: 650; background: var(--bg-2); border: 2px solid var(--line); border-radius: 999px; cursor: pointer; }
.slc-pills input { position: absolute; opacity: 0; pointer-events: none; }
.slc-pills label:has(input:checked) { color: var(--on-action); background: var(--action); box-shadow: 2px 2px 0 var(--shade); }
.slc-pills label:has(input:disabled) { opacity: .5; cursor: default; }
.slc-pills label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.slc-view-buttons { display: flex; flex-wrap: wrap; gap: .4rem; }
.slc-view-buttons button { min-width: 42px; padding: .35rem .7rem; font-size: .85rem; border-width: 1.5px; }
.slc-canvas { display: block; width: 100%; height: clamp(280px, 52vw, 540px); background: var(--slc-canvas); border: 2px solid var(--line); border-radius: 10px; touch-action: none; cursor: grab; }
.slc-canvas:active { cursor: grabbing; }
.slc-layers { display: grid; grid-template-columns: auto 42px minmax(0, 1fr) 42px; align-items: center; gap: .45rem; }
.slc-layer-label { font-size: .88rem; font-weight: 650; }
.slc-layers input[type="range"] { width: 100%; min-width: 0; min-height: 42px; accent-color: var(--action); }
.slc-layers button { padding: 0; font-size: 1.2rem; }
.slc-layers output { grid-column: 1 / -1; font: 600 .88rem var(--font-mono); }
.slc-legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: 0; padding: .55rem .75rem; border: 1.5px solid var(--border-soft); border-radius: 8px; }
.slc-legend legend { padding: 0 .3rem; font-size: .8rem; font-weight: 700; }
.slc-legend label { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; font-size: .86rem; }
.slc-legend input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--action); }
.slc-swatch { width: 1.4rem; height: .55rem; border-radius: 3px; border: 1px solid var(--line); }
.slc-swatch-outer { background: var(--slc-c-outer); }
.slc-swatch-inner { background: var(--slc-c-inner); }
.slc-swatch-solid { background: var(--slc-c-solid); }
.slc-swatch-sparse { background: var(--slc-c-sparse); }
.slc-swatch-support { background: var(--slc-c-support); }
.slc-swatch-skirt { background: var(--slc-c-skirt); }
.slc-swatch-travel { height: 2px; background: var(--slc-c-travel); border: 0; }

/* Placement and actions */
.slc-place .slc-buttons button { min-height: 40px; font-size: .86rem; border-width: 1.5px; }
.slc-fit { font-size: .9rem; font-weight: 600; }
.slc-fit[data-kind="ok"] { color: var(--success-strong); }
.slc-fit[data-kind="error"] { padding: .45rem .7rem; color: var(--ink) !important; background: var(--error-soft); border-left: 4px solid var(--error); border-radius: 6px; }
.slc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.slc-progress { display: flex; align-items: center; gap: .6rem; flex: 1 1 14rem; min-width: 0; }
.slc-progress progress { flex: 1; min-width: 0; height: 12px; accent-color: var(--action); }
.slc-progress span { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }
.slc-result { background: var(--green-wash); }
.slc-result h3 { margin: 0; }
.slc-result-stats dd { font-size: 1.05rem; }
.slc-result .slc-button { overflow-wrap: anywhere; }
.slc-table-wrap summary { font-weight: 650; cursor: pointer; }
.slc-scroll { max-width: 100%; overflow-x: auto; }
.slc table { width: 100%; margin-top: .5rem; border-collapse: collapse; font-size: .86rem; }
.slc th, .slc td { padding: .38rem .6rem; text-align: left; border-bottom: 1px solid var(--border-faint); white-space: nowrap; }
.slc thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: var(--paper-3); }
.slc tbody th { font-weight: 600; }
.slc td { font-family: var(--font-mono); }

/* Settings */
.slc-settings { display: grid; gap: .6rem; min-width: 0; }
.slc-settings-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.slc-settings-head h3 { margin: 0; }
.slc-settings-head button { min-height: 38px; font-size: .85rem; border-width: 1.5px; }
.slc-section { padding: .65rem .8rem; background: var(--bg-2); border: 2px solid var(--line); border-radius: 10px; min-width: 0; }
.slc-section > summary { min-height: 30px; font-weight: 700; cursor: pointer; }
.slc-section[open] > summary { margin-bottom: .6rem; }
.slc-sub-section { grid-column: 1 / -1; padding: .45rem .6rem; border: 1.5px solid var(--border-soft); border-radius: 8px; min-width: 0; }
.slc-sub-section > summary { font-size: .86rem; font-weight: 650; cursor: pointer; }
.slc-sub-section[open] > summary { margin-bottom: .55rem; }
.slc-foot { font-size: .85rem; }
.slc-renderer { font-size: .8rem; }

/* Space the page holds for this view until it mounts (see .tool-view-placeholder in _workspace.css).
   Each height is a little under the space the view takes at that width, measured as how far the
   content below moves when the view replaces the placeholder, so nothing below it moves. Re-measure
   after changing the view's layout: node scripts/measure-tool-views.js --apply <id>. */
.tool-view-placeholder[data-tool="stl-to-gcode"] { min-height: 3065px; }
@media (max-width: 999px) { .tool-view-placeholder[data-tool="stl-to-gcode"] { min-height: 2253px; } }
