/* ============================================================================
   milling-simulator / demo.css

   Every colour is a token from msu-theme.css; nothing here defines one.
   Gold and red-orange are fills and strokes only, never text (contrast
   rules 1 and 2 in the token layer). Control shapes follow the other
   machining labs, so this reads as one of them.

   The finished part uses the lathe lab's language: the drawing's outline in
   --cat1, metal still to remove in --cat2, metal cut past the drawing in
   --cat3. The block itself is grey. Gouges are striped as well as coloured,
   and every state is also named in words (legend, status, inspection).
   ==========================================================================*/

[data-interactive="milling-simulator"] {
  margin: 1rem 0;
  padding: clamp(.5rem, 2vw, 1rem);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  min-width: 0;
  display: flex; flex-direction: column; gap: 1rem;
}

/* ---- drawings (static figures and the live drawing panel) ---------------*/
.msd-figure { margin: 0; display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.msd-figure figcaption { color: var(--ink-soft); font-size: .92rem; }
/* A drawing is read at its own scale; on a phone it scrolls sideways
   rather than shrinking its lettering below legibility. */
.msd-scroll {
  overflow-x: auto; overscroll-behavior-x: contain;
  background: var(--paper);
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  min-width: 0;
}
.msd-scroll:focus-visible { outline: 3px solid var(--cat2); outline-offset: 2px; }
.msd-svg { display: block; width: 100%; min-width: 42rem; height: auto; }
.msd-setup { min-width: 60rem; }
.msd-rack { min-width: 60rem; }
.msd-figures { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }

.msd-vis      { fill: none; stroke: var(--ink); stroke-width: .45; stroke-linejoin: round; stroke-linecap: round; }
.msd-thin     { fill: none; stroke: var(--ink); stroke-width: .22; }
.msd-center   { fill: none; stroke: var(--ink-soft); stroke-width: .2; stroke-dasharray: 3 .8 .6 .8; }
.msd-hidden   { fill: none; stroke: var(--ink-soft); stroke-width: .28; stroke-dasharray: 1.4 .9; }
.msd-section  { stroke: none; }
.msd-hatch-line { stroke: var(--ink-soft); stroke-width: .18; }
.msd-cut      { fill: none; stroke: var(--ink); stroke-width: .25; stroke-dasharray: 5 1 1 1; }
.msd-cut-end  { fill: none; stroke: var(--ink); stroke-width: .7; }
.msd-arrow    { fill: var(--ink); }
.msd-ext, .msd-dim { fill: none; stroke: var(--ink); stroke-width: .2; }
.msd-jaw      { fill: color-mix(in srgb, var(--ink-soft) 16%, transparent); stroke: var(--ink-soft); stroke-width: .3; }
.msd-parallel { fill: color-mix(in srgb, var(--ink-soft) 10%, transparent); stroke: var(--ink-soft); stroke-width: .3; }
.msd-axis     { fill: none; stroke: var(--accent); stroke-width: .5; }
.msd-origin   { fill: var(--msu-gold); stroke: var(--ink); stroke-width: .3; }
.msd-zero     { fill: none; stroke: var(--accent); stroke-width: .3; stroke-dasharray: 2 1; }
.msd-t        { font-family: var(--f-display); font-size: 3.4px; fill: var(--ink); }
.msd-t-dim    { font-size: 3.2px; }
.msd-t-label  { font-size: 3.6px; font-weight: 700; letter-spacing: .04em; }
.msd-t-note   { font-size: 3.1px; }
.msd-t-small  { font-size: 2.6px; fill: var(--ink-soft); }

/* ---- tools, side on -------------------------------------------------------*/
.ms-tool-cut    { fill: color-mix(in srgb, var(--ink-soft) 58%, var(--surface)); stroke: var(--ink); stroke-width: .4; stroke-linejoin: round; }
.ms-tool-body   { fill: color-mix(in srgb, var(--ink-soft) 36%, var(--surface)); stroke: var(--ink); stroke-width: .4; }
.ms-tool-holder { fill: color-mix(in srgb, var(--ink-soft) 18%, var(--surface)); stroke: var(--ink-soft); stroke-width: .4; }
.ms-tool-insert { fill: var(--msu-gold); stroke: var(--ink); stroke-width: .3; }
.ms-tool-helix  { fill: none; stroke: var(--surface); stroke-width: .5; opacity: .75; }
.ms-tool-axis   { fill: none; stroke: var(--ink-soft); stroke-width: .25; stroke-dasharray: 3 1 .6 1; }
.ms-tool-icon   { display: block; overflow: visible; }

/* ---- the live simulator --------------------------------------------------*/
/* The printed figures step aside on screen once the machine is running. */
[data-interactive="milling-simulator"].is-live .ms-static { display: none; }
[data-ms-live]:empty { display: none; }
/* Three containers: the whole app (layout), the work column (readout) and
   the views (what fits on them). */
.ms-app { display: flex; flex-direction: column; gap: .55rem; min-width: 0; container: ms-app / inline-size; }
.ms-app [hidden] { display: none !important; }

[data-interactive="milling-simulator"] button {
  min-height: 2.75rem;
  padding: .45rem .75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-xs);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-display); font-weight: 700; font-size: .86rem;
  letter-spacing: .02em; line-height: 1.2;
  cursor: pointer;
}
[data-interactive="milling-simulator"] button:hover:not(:disabled) { background: var(--surface-2); }
[data-interactive="milling-simulator"] button:disabled { opacity: .5; cursor: default; }
[data-interactive="milling-simulator"] button[aria-pressed="true"] {
  border-color: var(--accent); color: var(--accent); background: var(--surface-2);
  box-shadow: inset 0 -3px 0 var(--accent);
}
[data-interactive="milling-simulator"] button[aria-expanded="true"] { border-color: var(--accent); background: var(--surface-2); }
[data-interactive="milling-simulator"] .ms-primary { border-color: var(--accent); background: var(--accent); color: var(--paper); }
[data-interactive="milling-simulator"] .ms-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
[data-interactive="milling-simulator"] :is(button, input, canvas, .msd-scroll, summary, .ms-inspect):focus-visible {
  outline: 3px solid var(--cat2); outline-offset: 2px;
}
[data-interactive="milling-simulator"] input {
  min-height: 2.75rem; min-width: 0;
  padding: .3rem .45rem;
  border: 1px solid var(--rule); border-radius: var(--radius-xs);
  background: var(--surface); color: var(--ink);
  font-family: var(--f-mono); font-size: 1rem;
}
.ms-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ms-small-label { font-family: var(--f-display); font-size: .76rem; font-weight: 700; color: var(--ink-soft); }

/* ---- the job and its goal --------------------------------------------------*/
.ms-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem .6rem; }
.ms-jobs, .ms-head-tools { display: flex; flex-wrap: wrap; gap: .3rem; }
[data-interactive="milling-simulator"] .ms-jobs button { padding-inline: .6rem; }
.ms-job-name { display: none; font-weight: 600; }
@container ms-app (min-width: 60rem) { .ms-job-name { display: inline; } .ms-job-name::before { content: " · "; } }
.ms-goal { margin: 0; font-size: .98rem; line-height: 1.4; }
.ms-goal strong { font-family: var(--f-display); }
.ms-hints { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: .3rem; font-size: .95rem; }
.ms-hints:empty { display: none; }
.ms-hints li { padding-left: .2rem; }

/* The operating controls keep their natural height. The picture takes the
   remaining screen room; no control panel becomes a scrolling frame. */
.ms-workbench { min-width: 0; display: flex; flex-direction: column; gap: .6rem; }
.ms-machine { min-width: 0; display: flex; flex-direction: column; gap: .4rem; container: ms-work / inline-size; }
.ms-panel { min-width: 0; display: flex; flex-direction: column; gap: .45rem; }
.ms-panel > * { flex-shrink: 0; }
/* The views grow with the width, but never past the height that keeps the
   readout above them and the status and Undo below them on the screen a
   link to the simulator lands on (about 30rem of page and bench around
   them; 181 mm of top view and section for every 190 mm across). */
.ms-views { position: relative; display: flex; flex-direction: column; gap: .35rem; min-width: 0; container: ms-views / inline-size;
  max-width: none; width: 100%; margin-inline: auto; }
/* the view switch: two halves of one control, in the top left corner of the views */
.ms-viewbar { position: absolute; z-index: 1; top: .3rem; left: .35rem; display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .5rem; pointer-events: none; }
.ms-viewbar-btns, .ms-viewbar .ms-turn { display: flex; pointer-events: auto; }
.ms-viewbar .ms-turn[hidden] { display: none; }
[data-interactive="milling-simulator"] .ms-viewbar button { min-height: 2.25rem; padding: .2rem .6rem; font-size: .8rem; border-radius: 0; background: color-mix(in srgb, var(--paper) 90%, transparent); }
[data-interactive="milling-simulator"] .ms-viewbar button:first-child { border-radius: var(--radius-xs) 0 0 var(--radius-xs); }
[data-interactive="milling-simulator"] .ms-viewbar button:last-child { border-radius: 0 var(--radius-xs) var(--radius-xs) 0; margin-left: -1px; }
[data-interactive="milling-simulator"] .ms-viewbar button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--paper); box-shadow: none; }
.ms-viewbar .ms-view-how { font-family: var(--f-display); font-size: .68rem; color: var(--ink-soft);
  padding: 0 .25rem; border-radius: 2px; background: color-mix(in srgb, var(--paper) 85%, transparent); }
@container ms-app (min-width: 36rem) {
  .ms-workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(15.5rem, 18rem); gap: .6rem; align-items: stretch; }
  .ms-panel { align-self:start; }
}
@container ms-app (max-width: 35.99rem) {
  .ms-workbench { gap:.35rem; }
  .ms-machine { flex: 0 0 auto; }
  .ms-panel { flex:0 0 auto; gap:.3rem; }
  .ms-views { width:100%; }
}
/* the readout */
.ms-dro {
  display: flex; flex-direction: column; gap: .1rem;
  padding: .35rem .7rem .4rem;
  background: var(--band); color: var(--band-ink);
  border-radius: var(--radius-sm);
}
.ms-dro-vals { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .9rem; }
.ms-dro-v { white-space: nowrap; }
.ms-dro-k { font-family: var(--f-display); font-weight: 800; font-size: .8rem; opacity: .8; margin-right: .3rem; }
.ms-dro-val { display: inline-block; min-width: 4.8rem; text-align: right;
  font-family: var(--f-mono); font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ms-dro.is-cutting { box-shadow: inset .3rem 0 0 var(--cat2); }
.ms-dro-note { margin: 0; font-family: var(--f-display); font-size: .74rem; font-weight: 600; opacity: .85; }
@container ms-work (max-width: 25rem) {
  .ms-dro-val { min-width: 4.1rem; font-size: 1rem; }
  .ms-dro-vals { gap: .1rem .6rem; }
  /* on a phone, Help says what the readout follows */
  .ms-dro-meaning { display: none; }
  .ms-status, .ms-next { font-size: .86rem; }
}

/* the views: the top view, and section A-A at the same X scale under it */
.ms-view {
  position: relative; margin: 0; min-width: 0;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm); overflow: hidden;
}
.ms-view-label, .ms-probe {
  position: absolute; top: .2rem; margin: 0; pointer-events: none;
  font-family: var(--f-display); font-size: .68rem; font-weight: 700; color: var(--ink-soft);
}
.ms-view-label { left: .45rem; display: flex; gap: .5rem; align-items: baseline; }
.ms-view-label, .ms-probe:not(:empty) { padding: 0 .25rem; border-radius: 2px; background: color-mix(in srgb, var(--paper) 85%, transparent); }
.ms-view-label-end { left: auto; right: .45rem; }
.ms-view-name { letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
.ms-view-how { font-weight: 600; }
.ms-probe { right: .45rem; font-variant-numeric: tabular-nums; }
.ms-canvas { display: block; width: 100%; height: auto; touch-action: none; }
.ms-top-canvas { aspect-ratio: 190 / 120; cursor: grab; }
/* the isometric fills the space of the top view and section together */
.ms-iso-canvas { aspect-ratio: 190 / 181; touch-action: auto; }
.ms-view-3d { position:relative; width:100%; aspect-ratio:190 / 150; min-height:10rem; }
.ms-webgl { display:block; width:100%; height:100%; touch-action:none; }
.ms-surface-status { position:absolute; bottom:.3rem; left:.4rem; padding:.15rem .3rem; background:var(--paper); color:var(--ink); font: .7rem var(--f-display); pointer-events:none; }
.ms-surface-status:empty { display:none; }
.ms-render-note { margin:0; padding:.35rem; border-left:3px solid var(--cat2); color:var(--ink); font-size:.85rem; }
.ms-pointer-preview {position:absolute;left:.3rem;right:.3rem;bottom:1.5rem;padding:.25rem;background:var(--paper);color:var(--ink);font:.72rem/1.2 var(--f-display);pointer-events:none;}
.ms-pointer-preview:empty {display:none;}
.ms-comparison,.ms-camera-controls {display:flex;align-items:center;gap:.3rem;min-width:0;}
[data-interactive="milling-simulator"] .ms-comparison button {min-height:2.25rem;padding:.25rem .45rem;white-space:nowrap;font-size:.76rem;}
.ms-comparison select {flex:1;min-width:0;max-width:24rem;}
.ms-camera-controls select {flex:1;min-width:0;}
.ms-camera-controls button {flex:none;}
.ms-camera-controls select,.ms-comparison select {font: .78rem var(--f-display);min-height:2.25rem;padding:.25rem;border:1px solid var(--rule);border-radius:var(--radius-xs);color:var(--ink);background:var(--paper);}
.ms-scene-hint {margin:0;min-height:2.3em;font:.76rem/1.15 var(--f-display);color:var(--ink-soft);display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}
.ms-viewbar[hidden] {display:none!important;}
.ms-orientation { position: absolute; left: .25rem; top: 2.7rem; width: 6.25rem; pointer-events: none;
  border-radius: var(--radius-xs); background: color-mix(in srgb, var(--paper) 90%, transparent); }
.ms-orientation svg { display: block; width: 100%; height: auto; }
.ms-orientation path { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.ms-orientation circle { fill: var(--ink); }
.ms-orientation text { fill: var(--ink); font: 700 12px var(--f-display); }
.ms-axis-text { display: none; }
.ms-key-tool { border: 2px solid var(--accent); border-radius: 50%; width: .8rem; height: .8rem; }
.ms-section-host { touch-action: none; cursor: ns-resize; }
.ms-section-svg { display: block; width: 100%; height: auto; }

/* the legend sits in the empty band in front of the vise */
.ms-legend {
  position: absolute; left: .45rem; right: .45rem; bottom: .2rem; margin: 0; pointer-events: none;
  display: flex; flex-wrap: wrap; gap: .05rem .8rem;
  font-family: var(--f-display); font-size: .68rem; font-weight: 600; color: var(--ink-soft); line-height: 1.3;
}
.ms-legend.is-plain .ms-lg:not(:last-child) { display: none; }
.ms-lg { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap;
  padding: 0 .2rem; border-radius: 2px; background: color-mix(in srgb, var(--paper) 85%, transparent); }
.ms-key { display: inline-block; flex: none; width: 1.15rem; height: .72rem; border-radius: 2px; }
.ms-key-target { border: 2px dashed var(--cat1); }
.ms-key-excess { background: linear-gradient(90deg, color-mix(in srgb, var(--cat2) 35%, var(--paper)), var(--cat2)); }
.ms-key-over { background: repeating-linear-gradient(45deg, var(--cat3) 0 3px, color-mix(in srgb, var(--cat3) 45%, var(--paper)) 3px 6px); }
.ms-key-metal { background: linear-gradient(90deg, color-mix(in srgb, var(--ink) 20%, var(--surface)), color-mix(in srgb, var(--ink) 58%, var(--surface))); }
/* a smaller view keeps the legend short; on a phone-sized view it moves
   under the view, out of the drawing's way */
@container ms-views (max-width: 26rem) {
  .ms-lg-more, .ms-view-how { display: none; }
  .ms-legend { gap: 0 .6rem; }
}
@container ms-views (max-width: 17.99rem) {
  /* The phone toolbar wraps into two rows. Put its axis key under the picture
     so neither the turn buttons nor the cutting geometry can cover it. */
  .ms-orientation { position: static; width: auto; background: none; }
  .ms-orientation svg { display: none; }
  .ms-axis-text { display: block; padding: .15rem .3rem; text-align: center; white-space: nowrap;
    color: var(--ink); font: 700 .75rem/1.4 var(--f-display); }
  .ms-legend { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .25rem .45rem .3rem; border-top: 1px solid var(--rule); }
  .ms-view-iso .ms-lg:last-child { grid-column: 1 / -1; }
}

/* section drawing */
.ms-metal       { fill: color-mix(in srgb, var(--ink) 20%, var(--surface)); }
.ms-hatch-line  { stroke: var(--ink-soft); stroke-width: .3; }
.ms-metal-edge  { fill: none; stroke: var(--ink); stroke-width: .45; stroke-linejoin: round; }
.ms-excess      { fill: var(--cat2); fill-opacity: .55; stroke: none; }
.ms-over        { fill: var(--cat3); fill-opacity: .4; stroke: var(--cat3); stroke-width: .7; stroke-dasharray: 1.6 .8; }
.ms-target-line { fill: none; stroke: var(--cat1); stroke-width: .75; stroke-dasharray: 2.2 1.3; stroke-linejoin: round; }
.ms-jaw-cut     { fill: color-mix(in srgb, var(--ink-soft) 32%, var(--paper)); stroke: var(--ink-soft); stroke-width: .3; }
.ms-jaw-behind  { fill: color-mix(in srgb, var(--ink-soft) 12%, var(--paper)); stroke: var(--ink-soft); stroke-width: .25; }
.ms-parallel    { fill: color-mix(in srgb, var(--ink-soft) 42%, var(--paper)); stroke: var(--ink-soft); stroke-width: .3; }
.ms-parallel-behind { fill: color-mix(in srgb, var(--ink-soft) 18%, var(--paper)); stroke: var(--ink-soft); stroke-width: .25; }
.ms-floor       { stroke: var(--ink-soft); stroke-width: .5; }
.ms-zero        { stroke: var(--accent); stroke-width: .3; stroke-dasharray: 2 1; }
.ms-jawtop      { stroke: var(--ink-soft); stroke-width: .25; stroke-dasharray: 1 1; }
.ms-t           { font-family: var(--f-display); font-size: 3.2px; font-weight: 600; fill: var(--ink); }
.ms-t-axis      { font-size: 6px; fill: var(--ink-soft); }
.ms-t-soft      { fill: var(--ink-soft); }

/* what the last move did, the next step, and Undo */
.ms-feedback {
  display: flow-root;
  padding: .45rem .5rem .45rem .7rem;
  background: var(--surface-2);
  border: 1px solid var(--rule); border-inline-start: .3rem solid var(--accent);
  border-radius: var(--radius-xs);
}
.ms-feedback.is-stop { border-color: var(--cat3); background: var(--cat3-soft); }
.ms-feedback.is-cut { border-inline-start-color: var(--cat2); }
.ms-feedback.is-air { border-inline-start-color: var(--ink-soft); }
.ms-status { margin: 0; font-size: .93rem; line-height: 1.38; }
.ms-status strong { font-family: var(--f-display); }
.ms-status:empty { display: none; }
.ms-feedback-toggle { display: block; }
.ms-feedback:not(.is-expanded) .ms-status,.ms-feedback:not(.is-expanded) .ms-next-text {display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}
@container ms-app (max-width: 35.99rem) {
  .ms-feedback:not(.is-expanded) .ms-status:not(:empty),
  .ms-feedback:not(.is-expanded) .ms-next-text {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  }
  .ms-feedback .ms-feedback-toggle { display: block; min-width: 4.6rem; font-size: .72rem; padding: .2rem .3rem; }
}
.ms-next { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; margin-top: .3rem; font-size: .88rem; line-height: 1.38; }
.ms-next-text { margin: 0; flex: 1 1 14rem; color: var(--ink-soft); }
.ms-next.is-suggest .ms-next-text { color: var(--ink); }
.ms-next strong { font-family: var(--f-display); }
.ms-next:has(.ms-next-text:empty) { display: none; }
[data-interactive="milling-simulator"] .ms-next-fill { border-color: var(--accent); min-height: 2.5rem; }
[data-interactive="milling-simulator"] .ms-link-btn {
  min-height: 0; padding: .05rem .1rem; border: 0; background: transparent; color: var(--accent);
  font-size: .86rem; text-decoration: underline; text-underline-offset: .18em;
}
.ms-fb-act { float: right; margin: 0 0 .25rem .6rem; display: flex; flex-direction: column; gap: .3rem; }
[data-interactive="milling-simulator"] .ms-undo, [data-interactive="milling-simulator"] .ms-stop { min-width: 4.6rem; }
[data-interactive="milling-simulator"] .ms-stop { border-color: var(--cat3); background: var(--cat3-soft); color: var(--cat-ink); }

/* ---- the controls ------------------------------------------------------------*/
.ms-box {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm);
  padding: .45rem .55rem .55rem; display: flex; flex-direction: column; gap: .35rem; min-width: 0;
}
.ms-box-title {
  margin: 0; font-family: var(--f-display); font-size: .68rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft);
}
.ms-tool-now { color: var(--ink); letter-spacing: .02em; text-transform: none; font-size: .8rem; }
.ms-panel button, .ms-panel input { min-height: 2.5rem; }
.ms-kinds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .3rem; }
[data-interactive="milling-simulator"] .ms-kind {
  display: flex; align-items: center; gap: .3rem; min-width: 0;
  padding: .2rem .3rem; font-size: .72rem; line-height: 1.1; text-align: left;
}
.ms-kind svg { flex: none; height: 30px; width: auto; max-width: 1.9rem; }
.ms-kind-name { min-width: 0; overflow-wrap: anywhere; }
.ms-sizes { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .4rem; }
.ms-sizes-label { font-family: var(--f-display); font-size: .74rem; font-weight: 700; color: var(--ink-soft); }
.ms-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
[data-interactive="milling-simulator"] .ms-chip-btn { min-width: 2.55rem; padding: .25rem .4rem; font-variant-numeric: tabular-nums; }
.ms-bore { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.ms-bore label { font-family: var(--f-display); font-size: .78rem; font-weight: 700; }
.ms-bore input { width: 5.6rem; }

.ms-go { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .3rem; }
.ms-go-cell { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.ms-go-label { font-family: var(--f-display); font-weight: 800; font-size: .76rem; color: var(--accent); }
[data-interactive="milling-simulator"] .ms-go-in { width: 100%; text-align: right; font-size: .95rem; }
[data-interactive="milling-simulator"] .ms-go-in.is-edited { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.ms-go-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.ms-go-row > button { flex: 1 1 auto; }

.ms-jog-head { display: flex; align-items: center; gap: .35rem; }
.ms-jog-head .ms-box-title { margin-right: auto; }
.ms-seg { display: flex; flex-wrap: wrap; gap: .25rem; }
[data-interactive="milling-simulator"] .ms-seg button { min-width: 2.4rem; padding: .25rem .4rem; }
.ms-seg-unit { font-family: var(--f-display); font-size: .74rem; font-weight: 700; color: var(--ink-soft); }
.ms-jog {
  display: grid; gap: .28rem;
  grid-template-columns: repeat(3, minmax(2.6rem, 1fr)) minmax(3.4rem, 1.15fr);
  grid-template-areas: ". yp . zp" "xm . xp ." ". ym . zm";
}
.ms-j-yp { grid-area: yp; } .ms-j-xm { grid-area: xm; } .ms-j-xp { grid-area: xp; }
.ms-j-ym { grid-area: ym; } .ms-j-zp { grid-area: zp; } .ms-j-zm { grid-area: zm; }
[data-interactive="milling-simulator"] .ms-jog-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem;
  padding: .15rem .2rem; line-height: 1; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.ms-jog-sub { font-size: .6rem; font-weight: 600; color: var(--ink-soft); letter-spacing: 0; }

/* ---- below the work ------------------------------------------------------------*/
.ms-tray { display: flex; flex-wrap: wrap; gap: .3rem; }
[data-interactive="milling-simulator"] .ms-tray button { font-size: .82rem; }
.ms-drawing { min-width: 0; }
.ms-more { display: grid; gap: .55rem; grid-template-columns: minmax(0, 36rem); }
.ms-view-cap {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  min-height: 2.1rem; padding: .15rem .3rem .15rem .55rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--f-display); font-size: .7rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft);
}
.ms-turn { display: flex; gap: .25rem; }
[data-interactive="milling-simulator"] .ms-mini { min-height: 2.5rem; min-width: 2.5rem; padding: 0 .5rem; font-size: 1.1rem; }
.ms-help {
  display: flex; flex-direction: column; gap: .5rem;
  padding: .7rem .85rem; background: var(--paper);
  border: 1px solid var(--rule); border-radius: var(--radius-sm); font-size: .93rem;
}
.ms-help p { margin: 0; }
.ms-help-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }

/* inspection */
.ms-inspect {
  display: flex; flex-direction: column; gap: .55rem;
  padding: .8rem .9rem; background: var(--paper);
  border: 1px solid var(--rule); border-inline-start: .3rem solid var(--rule); border-radius: var(--radius-sm);
  scroll-margin-top: calc(var(--appbar-h, 3.5rem) + 1rem);
}
.ms-inspect.is-complete { border-color: var(--cat1); background: var(--cat1-soft); }
.ms-inspect.is-over { border-inline-start-color: var(--cat3); }
.ms-inspect-summary { margin: 0; font-family: var(--f-display); font-weight: 700; }
.ms-rows { gap: .45rem; }
.ms-rows > li, .ms-checks > li { padding-left: 0; }
.ms-rows > li::before, .ms-checks > li::before { display: none; }
.ms-row { padding: .5rem .65rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-xs); display: flex; flex-direction: column; gap: .3rem; }
.ms-row-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin: 0; }
.ms-row-label { font-weight: 600; }
.ms-row-measured { margin: 0; font-size: .9rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ms-chip {
  font-family: var(--f-display); font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .1rem .45rem; border: 1.5px solid var(--rule); border-radius: var(--radius-xs); color: var(--cat-ink);
  background: var(--surface-2); white-space: nowrap;
}
.ms-row.is-ok .ms-chip   { background: var(--cat1-soft); border-color: var(--cat1); }
.ms-row.is-todo .ms-chip { background: var(--cat2-soft); border-color: var(--cat2); }
.ms-row.is-over .ms-chip { background: var(--cat3-soft); border-color: var(--cat3); }
.ms-checks { gap: .2rem; font-size: .92rem; }
.ms-checks .ms-mark { display: inline-block; width: 1.1rem; font-weight: 700; }
.ms-checks .is-ok .ms-mark { color: var(--accent); }
.ms-record { display: none; }

/* presentation: the same machine, read from across the room */
.presenting [data-interactive="milling-simulator"] .ms-dro-val { font-size: 1.5rem; }
/* the panel title and the track bar take more of the screen here */
.presenting [data-interactive="milling-simulator"] .ms-views { max-width:none; }
@container ms-app (max-width:35.99rem){
  .ms-machine {gap:.25rem;}
  .ms-dro {padding:.25rem .45rem;}
  .ms-dro-note {display:none;}
  .ms-box {padding:.25rem;gap:.2rem;}
  .ms-toolbox>.ms-box-title,.ms-movebox>.ms-box-title {display:none;}
  .ms-kinds {grid-template-columns:repeat(6,minmax(0,1fr));gap:.2rem;}
  [data-interactive="milling-simulator"] .ms-kind {flex-direction:column;justify-content:center;padding:.15rem;font-size:.61rem;gap:.1rem;min-height:3.1rem;text-align:center;}
  .ms-kind svg {height:18px;}
  .ms-sizes-label {display:none;}
  .ms-sizes,.ms-chips {gap:.2rem;}
  [data-interactive="milling-simulator"] .ms-chip-btn {min-height:2.25rem;padding:.15rem .3rem;}
  .ms-go-row {gap:.25rem;}
  .ms-jog {grid-template-columns:repeat(6,minmax(0,1fr));grid-template-areas:none;gap:.2rem;}
  .ms-jog>.ms-jog-btn {grid-area:auto;min-height:2.5rem;}
  .ms-jog-sub {display:none;}
  .ms-jog-head {gap:.25rem;}
  .ms-feedback {padding:.3rem .4rem;}
  .ms-next-text {font-size:.75rem;}
  .ms-status {font-size:.82rem;}
  [data-interactive="milling-simulator"] .ms-feedback button {min-height:2.1rem;font-size:.7rem;padding:.15rem .3rem;}
  .ms-fb-act {gap:.2rem;margin-left:.35rem;}
  .ms-camera-controls button {min-height:2.25rem;padding:.2rem .4rem;font-size:.76rem;}
  .ms-comparison select {max-width:none;}
}
.presenting [data-interactive="milling-simulator"] .ms-status { font-size: 1.05rem; }
.presenting [data-interactive="milling-simulator"] .ms-legend,
.presenting [data-interactive="milling-simulator"] .ms-view-label { font-size: .8rem; }

@container ms-app (max-width:35.99rem) {
  /* Presentation's large type must not wrap a live coordinate onto a second
     row or push operating controls behind the fixed navigation. */
  .ms-dro-vals {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.25rem;}
  .ms-dro-v {display:flex;align-items:baseline;min-width:0;}
  [data-interactive="milling-simulator"] .ms-dro-val,
  .presenting [data-interactive="milling-simulator"] .ms-dro-val {min-width:0;flex:1;font-size:1rem;line-height:1.4;}
  .ms-dro {line-height:1.3;}
  .ms-go-label {line-height:1.15;}
  .ms-view-3d {min-height:140px;}
  [data-interactive="milling-simulator"] .ms-go-in {min-height:2.5rem;line-height:1.2;}
  /* Full text opens the optional explanation/suggested move. The compact
     operating state keeps the outcome and recovery together in one row. */
  .ms-feedback:not(.is-expanded) {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.3rem;align-items:center;}
  .ms-feedback:not(.is-expanded) .ms-fb-act {grid-column:2;grid-row:1;float:none;flex-direction:row;margin:0;}
  .ms-feedback:not(.is-expanded) .ms-status {grid-column:1;grid-row:1;font-size:.82rem;}
  .ms-feedback:not(.is-expanded) .ms-next {display:none;}
  .ms-feedback:has(.ms-stop:not([hidden])) .ms-undo {display:none;}
}

@media print {
  .ms-workbench { display: block; height: auto; }
  [data-interactive="milling-simulator"] {
    background: #FFF !important; border-color: #777 !important; color: #111 !important;
  }
  [data-interactive="milling-simulator"].is-live .ms-static { display: flex; flex-direction: column; gap: 1.25rem; }
  .ms-static > .msd-figure { width: 100%; }
  [data-ms-live] { display: none !important; }
  .ms-record:not(:empty) { display: flex; flex-direction: column; gap: .4rem; break-inside: avoid; }
  .ms-record-img { width: 60%; max-width: 4in; }
  .msd-scroll { overflow: visible; border-color: #999 !important; background: #FFF !important; }
  .msd-svg { min-width: 0; }
  .msd-figure { break-inside: avoid; }
}
