/* ============================================================================
   turning-simulator / demo.css - the lathe simulator's surface.

   Loaded after msu-theme.css and app.css. Every colour is a theme token, so
   both skins and print come for free; nothing here defines a colour of its
   own outside the print block.

   The theme's contrast rules hold here too:
     - gold (--flag, --cat2) and red orange (--cat3) are fills, strokes and
       hatching, never text on a light ground;
     - meaning is never carried by colour alone. Metal still to come off is a
       tint AND is named in the legend; work smaller than the drawing is a
       heavy dashed line AND an inspection line; a refused move is a message
       with a heading, not only a red border.
   ========================================================================== */

[data-interactive="turning-simulator"] { min-width: 0; }
.ts-live > .ts-static { display: none; }

/* ---- shared drawing classes (view, drawings, icons) ------------------------*/
.ts-view, .ts-drawing-svg { display: block; width: 100%; height: auto; }
.ts-view text, .ts-drawing-svg text { font-family: var(--f-display); }
.ts-hatch-bg { fill: var(--surface); }
.ts-hatch-line { stroke: var(--ink-soft); stroke-width: 1.1; }
.ts-sec { stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.ts-ext { fill: var(--surface-2); stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.ts-edge, .ts-thread, .ts-knurl { fill: none; stroke: var(--ink-soft); stroke-width: 1; }
.ts-hidden { fill: none; stroke: var(--ink-soft); stroke-width: 1.2; stroke-dasharray: 6 4; }
.ts-knurl { stroke-width: .8; }
.ts-axis { fill: none; stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 18 4 3 4; }
.ts-z0 path { fill: none; stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 5 4; }
.ts-lbl { fill: var(--ink-soft); font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.ts-chuck { fill: var(--surface-2); stroke: var(--rule); stroke-width: 1.4; }
.ts-jaw { fill: var(--rule); stroke: var(--ink-soft); stroke-width: 1.4; }
.ts-spin path { fill: none; stroke: var(--ink-soft); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ts-spin { opacity: .35; }
.ts-spin-ring { fill: var(--paper); stroke: var(--rule); stroke-width: 1.3; }
.ts-spin-guide { fill: none; stroke: none; }
.ts-spin-view { fill: var(--ink-soft); font: 600 11px var(--f-display); }
.ts-tool-wheel-end { fill: var(--surface-2); stroke: var(--ink); stroke-width: 1.2; }
.ts-tool-axle { fill: none; stroke: var(--ink); stroke-width: 2; }
.ts-tool-fastener { fill: var(--surface-2); stroke: var(--ink); stroke-width: 1.5; }
.ts-tool-label { fill: var(--ink); font: 600 12px var(--f-display); }
.ts-view.is-section .ts-thread, .ts-part-svg.is-section .ts-thread { stroke-dasharray: 5 3; }
.ts-thread-envelope { fill: var(--paper); stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 5 3; }
.ts-ghost { fill: none; stroke: var(--cat1); stroke-width: 1.6; stroke-dasharray: 6 4; stroke-linejoin: round; }
.ts-ghost-root { fill: none; stroke: var(--cat1); stroke-width: 1; stroke-dasharray: 2 3; }
.ts-excess { fill: var(--cat2); fill-opacity: .42; stroke: none; }
.ts-under { fill: none; stroke: var(--cat3); stroke-width: 3.2; stroke-dasharray: 5 2; stroke-linecap: butt; }
.ts-tool-body { fill: var(--surface); stroke: var(--ink); stroke-width: 1.3; stroke-linejoin: round; }
.ts-tool-bar { fill: var(--surface); stroke: var(--ink); stroke-width: 1.3; }
.ts-tool-insert { fill: var(--ink-soft); stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
.ts-tool-wheel { fill: var(--rule); }
.ts-tool-knurl, .ts-tool-flute { fill: none; stroke: var(--paper); stroke-width: 1.1; opacity: .8; }
.ts-tool-knurl { stroke: var(--ink-soft); }
.ts-tool-edge { fill: none; stroke: var(--cat2); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ts-tool-edge.is-forming { stroke: var(--cat1); }
.ts-ref circle { fill: var(--paper); stroke: var(--cat3); stroke-width: 1.6; }
.ts-ref path { stroke: var(--cat3); stroke-width: 1.4; }
.ts-icon { display: block; width: 2.6rem; height: 1.8rem; flex: none; }
.ts-icon .ts-tool-edge { stroke-width: 6; }
.ts-icon .ts-tool-body, .ts-icon .ts-tool-insert, .ts-icon .ts-tool-bar { stroke-width: 3; }

/* drawing (dimensioned target) */
.ts-dline, .ts-dext, .ts-dleader { fill: none; stroke: var(--ink); stroke-width: 1; }
.ts-dext { stroke: var(--ink-soft); }
.ts-dthin { fill: none; stroke: var(--ink); stroke-width: .9; }
.ts-arrowhead { fill: var(--ink); }
.ts-dtxt { fill: var(--ink); font-size: 14px; font-weight: 600; }
.ts-dlbl { fill: var(--ink-soft); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.ts-halo { paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; }
.ts-bore { fill: var(--surface-2); stroke: none; }

/* ---- the lab surface -----------------------------------------------------*/
.ts-lab {
  container: ts-lab / inline-size;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  min-width: 0;
  padding: .75rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.ts-lab [hidden] { display: none !important; }
.ts-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ts-k, .ts-k2 {
  font-family: var(--f-display);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.25;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.ts-k2 { font-size: .66rem; letter-spacing: .06em; }

/* buttons: the fire-table tab look; 44 px to tap, 40 px inside the bench */
.ts-lab button {
  cursor: pointer;
  min-height: 2.75rem;
  margin: 0;
  padding: .4rem .55rem;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-family: var(--f-display);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.2;
  text-transform: uppercase;
}
.ts-lab button:not(:disabled):hover { border-color: var(--accent); background: var(--surface-2); }
.ts-lab button[aria-pressed="true"], .ts-lab button[aria-expanded="true"] { border-color: var(--accent); background: var(--accent); color: var(--paper); }
.ts-lab button[aria-pressed="true"]:not(:disabled):hover,
.ts-lab button[aria-expanded="true"]:not(:disabled):hover { border-color: var(--accent); background: var(--accent); color: var(--paper); }
.ts-lab button:disabled { cursor: not-allowed; opacity: .45; }
.ts-lab :is(button, input, select, summary):focus-visible,
.ts-view-wrap:focus-visible,
.ts-steps label:has(input:focus-visible) { outline: 3px solid var(--cat2); outline-offset: 2px; }
.ts-drawing-scroll:focus-visible { outline: 3px solid var(--cat2); outline-offset: -3px; }
.ts-lab select, .ts-lab input[type="text"] {
  min-height: 2.5rem; min-width: 0; padding: .3rem .5rem;
  border: 1.5px solid var(--rule); border-radius: var(--radius-xs);
  background: var(--paper); color: var(--ink);
  font-family: var(--f-mono); font-size: 1rem;
}

/* ---- the part, its goal and its drawing ---------------------------------------*/
.ts-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .6rem; }
.ts-parts { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; min-width: 0; }
.ts-parts .ts-k { margin-right: .25rem; }
.ts-head-tools { display: flex; flex-wrap: wrap; gap: .3rem; }
.ts-goal { margin: 0; font-size: .95rem; line-height: 1.4; }
.ts-goal strong { font-family: var(--f-display); }
.ts-drawing { margin: 0; display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.ts-drawing-views { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.ts-drawing-views .ts-k { margin-right: .4rem; }
.ts-drawing-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: .7rem; }
.ts-drawing-sheet { break-inside: avoid; }
.ts-drawing-scroll { max-width: 100%; overflow-x: auto; padding-bottom: .3rem; }
.ts-drawing svg { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm); max-width: 40rem; }
.ts-drawing-scroll svg { display: block; width: 100%; min-width: 34rem; }
.ts-drawing-hint { display: block; margin-top: .25rem; font-size: .85rem; color: var(--ink-soft); }
.ts-drawing figcaption { font-size: .95rem; color: var(--ink); }
.ts-teaches { display: block; color: var(--ink-soft); font-size: .9rem; }

/* ---- the workbench: everything the hands need, on one screen ------------------
   Narrow: the work, then its controls, then the tool rack, in one column.
   36rem and up: the controls beside the work, the rack under both.
   68rem and up (a projector): the rack, the work and the controls side by side.
   demo.js sizes the picture so the bench fits between the app bar and the bottom
   of the window; nothing in the bench scrolls. */
.ts-workbench {
  display: grid; gap: .6rem; min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "machine" "panel" "rack";
}
.ts-machine { grid-area: machine; display: flex; flex-direction: column; gap: .4rem; min-width: 0; container: ts-work / inline-size; }
.ts-panel { grid-area: panel; display: flex; flex-direction: column; gap: .55rem; min-width: 0; }
.ts-rack { grid-area: rack; }
@container ts-lab (min-width: 36rem) {
  .ts-workbench { grid-template-columns: minmax(0, 1fr) 17.5rem; grid-template-areas: "machine panel" "rack rack"; align-items: start; }
}
@container ts-lab (min-width: 68rem) {
  .ts-workbench { grid-template-columns: 15.5rem minmax(0, 1fr) 18rem; grid-template-areas: "rack machine panel"; gap: .8rem; }
}

/* the readout */
.ts-dro {
  display: flex; flex-wrap: nowrap; align-items: baseline; gap: .2rem 1rem;
  padding: .45rem .75rem;
  background: var(--band); color: var(--band-ink);
  border-radius: var(--radius-sm);
}
.ts-dro .ts-k { color: var(--band-ink); opacity: .75; margin-right: .35rem; }
.ts-dro b { font-family: var(--f-mono); font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ts-dro-v { white-space: nowrap; }
.ts-dro-v b { display: inline-block; min-width: 4.6rem; text-align: right; }
.ts-dro-tool, .ts-dro-spin { font-family: var(--f-display); font-size: .8rem; font-weight: 600; letter-spacing: .03em; }
/* one line always: a long tool name is cut short rather than adding a line */
.ts-dro-tool { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-dro-spin { margin-left: auto; padding: .1rem .5rem; border: 1px solid currentColor; border-radius: var(--radius-xs); white-space: nowrap; }
.is-running .ts-dro-spin { background: var(--flag); color: var(--msu-navy); border-color: var(--flag); }
/* a narrow readout keeps to one line: the rack and the notes below name the tool */
@container ts-work (max-width: 31rem) { .ts-dro-tool { display: none; } }
@container ts-work (max-width: 20rem) {
  .ts-dro { gap: .2rem .7rem; padding-inline: .6rem; }
  .ts-dro-v b { min-width: 3.9rem; font-size: 1.05rem; }
  .ts-dro-word { display: none; }
}

/* the picture: as wide as its column unless the screen is too short for that */
.ts-view-box { position: relative; min-width: 0; width: 100%; max-width: var(--ts-view-w, none); margin-inline: auto; }
.ts-view-wrap { min-width: 0; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--paper); overflow: hidden; }
.ts-view-wrap svg { border-radius: var(--radius-sm); }
/* The view switch and Close up sit in the picture's bottom margin, below the
   work: the switch over the chuck, which never moves, Close up past the end of
   the bar. Neither adds height to the bench. */
.ts-views { position: absolute; left: .3rem; bottom: .3rem; display: flex; }
.ts-lab .ts-views button, .ts-lab .ts-zoom {
  min-height: 2.25rem; padding: .2rem .55rem; font-size: .72rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
}
.ts-lab .ts-views button + button { margin-left: -1.5px; }
.ts-lab .ts-views button:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }
.ts-lab .ts-views button:last-child { border-start-start-radius: 0; border-end-start-radius: 0; }
.ts-lab .ts-views button[aria-pressed="true"], .ts-lab .ts-zoom[aria-pressed="true"] { background: var(--accent); }
.ts-lab .ts-zoom { position: absolute; right: .3rem; bottom: .3rem; }
.ts-thread-note { position: absolute; right: .3rem; top: .3rem; padding: .12rem .3rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent); color: var(--ink);
  border-radius: var(--radius-xs); font: 600 .65rem/1.15 var(--f-display); text-align: right; pointer-events: none; }

/* what the last move did, with Undo beside it. It keeps three lines, so the
   bench never changes height under the hands; More opens a longer one. */
.ts-feedback {
  --ts-lines: 3;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .5rem;
  padding: .4rem .45rem .4rem .7rem;
  background: var(--paper);
  border: 1px solid var(--rule); border-inline-start: .3rem solid var(--rule);
  border-radius: var(--radius-xs);
}
.ts-feedback.is-stop { border-color: var(--cat3); background: var(--cat3-soft); }
.ts-feedback.is-cut { border-inline-start-color: var(--cat2); }
.ts-feedback.is-form { border-color: var(--cat1); background: var(--cat1-soft); }
.ts-feedback.is-done { border-color: var(--accent); background: var(--surface-2); }
.ts-feedback.is-info { border-inline-start-color: var(--accent); }
.ts-msg {
  grid-column: 1; grid-row: 1;
  min-height: calc(var(--ts-lines) * 1.38em);
  font-size: .93rem; line-height: 1.38;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ts-lines); overflow: hidden;
}
.ts-feedback.is-open .ts-msg { display: block; overflow: visible; }
.ts-msg strong { font-family: var(--f-display); margin-right: .25rem; }
.ts-fb-act { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: .3rem; }
.ts-lab .ts-fb-act button { min-height: 2.25rem; min-width: 5.2rem; padding: .2rem .5rem; background: var(--paper); }
.ts-lab .ts-hold { border-color: var(--cat3); background: var(--cat3-soft); color: var(--cat-ink); }
.ts-lab .ts-more { font-size: .72rem; }
/* More keeps its place when a message is short, so the feedback is always one height */
.ts-lab .ts-more[hidden] { display: block !important; visibility: hidden; }

/* ---- the controls beside the work --------------------------------------------*/
.ts-panel button, .ts-rack button { min-height: 2.5rem; }
.ts-run { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: .35rem; }
.ts-lab .ts-spindle { border-color: var(--accent); }
.ts-lab .ts-spindle[aria-pressed="true"] { background: var(--flag); border-color: var(--flag); color: var(--msu-navy); }
.ts-lab .ts-spindle[aria-pressed="true"]:not(:disabled):hover { background: var(--flag); border-color: var(--flag); color: var(--msu-navy); }

.ts-feed { margin: 0; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.ts-feed .ts-k { margin: 0; }
.ts-feed-row { display: grid; grid-template-columns: 2.9rem minmax(0, 1fr) 6.6rem; align-items: center; gap: .35rem; }
.ts-feed-row label { font-family: var(--f-display); font-weight: 700; font-size: .85rem; line-height: 1.1; }
.ts-feed-row input { width: 100%; }
.ts-lab .ts-feed-row button { padding-inline: .3rem; }

.ts-jog { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.ts-jog-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .3rem; }
.ts-steps { display: flex; gap: .25rem; }
.ts-steps label {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.25rem; min-width: 3.6rem; padding: 0 .35rem; cursor: pointer;
  border: 1.5px solid var(--rule); border-radius: var(--radius-xs);
  font-family: var(--f-mono); font-size: .88rem; color: var(--ink);
}
.ts-steps input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.ts-steps label:hover { border-color: var(--accent); }
.ts-steps label:has(input:checked) { border-color: var(--accent); background: var(--accent); color: var(--paper); }
/* the handwheels as the arrow keys sit: X+ over Z-, X- and Z+ */
.ts-pad {
  display: grid; gap: .3rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas: ". up ." "left down right";
}
.ts-up { grid-area: up; } .ts-left { grid-area: left; } .ts-right { grid-area: right; } .ts-down { grid-area: down; }
.ts-lab .ts-jogbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem;
  min-height: 2.9rem; padding: .2rem .25rem; line-height: 1.1;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.ts-jog-ax { white-space: nowrap; }
.ts-jog-sub { display: block; font-size: .64rem; font-weight: 600; letter-spacing: .02em; text-transform: none; color: var(--ink-soft); }
.ts-jogbtn:disabled .ts-jog-sub { color: inherit; }

/* ---- the tool rack ---------------------------------------------------------------*/
.ts-rack {
  margin: 0; padding: 0; border: 0; min-width: 0;
  display: grid; gap: .3rem .6rem;
  grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
  grid-template-areas: "post tail" "opt opt";
}
.ts-tool-post { grid-area: post; } .ts-tool-tail { grid-area: tail; } .ts-tool-opt { grid-area: opt; }
.ts-tool-group { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.ts-tool-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .3rem; }
.ts-lab .ts-toolbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  padding: .25rem .15rem; text-transform: none; letter-spacing: 0; font-size: .72rem; line-height: 1.1;
}
.ts-toolbtn .ts-icon { width: 2.4rem; height: 1.5rem; }
.ts-toolbtn[aria-pressed="true"] .ts-tool-body, .ts-toolbtn[aria-pressed="true"] .ts-tool-bar { fill: var(--paper); stroke: var(--paper); }
.ts-toolbtn[aria-pressed="true"] .ts-tool-insert { fill: var(--surface-2); stroke: var(--paper); }
/* drill size and thread pitch: set with the tool, shown only for the tool that uses them */
.ts-tool-opt { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .3rem .8rem; }
.ts-tool-opt:not(:has(label:not([hidden]))) { display: none; }
.ts-tool-opt label { display: inline-flex; align-items: center; gap: .45rem; }
@container ts-lab (min-width: 36rem) and (max-width: 67.99rem) {
  /* beside the tailstock tools when one of them needs it */
  .ts-rack { grid-template-columns: minmax(0, 7fr) minmax(0, 3fr) auto; grid-template-areas: "post tail opt"; }
  .ts-tool-opt { flex-direction: column; justify-content: flex-end; align-items: stretch; gap: .2rem; }
  .ts-tool-opt label { flex-direction: column; align-items: flex-start; gap: .2rem; }
}
@container ts-lab (min-width: 68rem) {
  .ts-rack { grid-template-columns: minmax(0, 1fr); grid-template-areas: "post" "tail" "opt"; align-content: start; }
  .ts-tool-row { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ts-tool-opt { justify-content: flex-start; }
}
@container ts-lab (max-width: 35.99rem) {
  /* Spend the phone's height on controls and the work, not repeated headings
     and gaps. The threading row and pitch selector must fit above navigation. */
  .ts-workbench { gap: .3rem; }
  .ts-panel { gap: .4rem; }
  .ts-jog-head { flex-wrap: nowrap; }
  .ts-lab .ts-feed-row button { padding-block: .15rem; }
  .ts-lab .ts-fb-act .ts-more { min-height: 1.5rem; }
  /* one grid of five: the post tools, then the three on the tailstock */
  .ts-rack { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-areas: none; gap: .3rem; }
  .ts-tool-group, .ts-tool-row { display: contents; }
  .ts-tool-group > .ts-k2 { display: none; }
  .ts-tool-opt { grid-area: auto; grid-column: 1 / -1; }
  /* Keep the active setting clear of the site's fixed Exit presentation
     button at the lower right. Its full label can wrap within this row. */
  .ts-tool-opt { justify-content: flex-start; }
  .ts-tool-opt .ts-k2 { max-width: 5rem; }
  .ts-lab .ts-views button, .ts-lab .ts-zoom { min-height: 2rem; padding: .15rem .45rem; font-size: .68rem; }
  .ts-pad { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: "left up down right"; }
  /* the height a phone needs back for the threading pass and its pitch */
  .ts-feed > .ts-k { display: none; }
  .ts-toolbtn .ts-icon { height: 1.15rem; }
}

/* ---- under the bench: the legend, view settings and keys ------------------------*/
.ts-tray { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .8rem; }
.ts-tray-btns { display: flex; flex-wrap: wrap; gap: .3rem; }
.ts-legend { margin: 0; display: flex; flex-wrap: wrap; gap: .1rem 1rem; font-size: .82rem; color: var(--ink-soft); line-height: 1.6; }
.ts-lg { display: inline-flex; align-items: center; gap: .35rem; }
.ts-key { display: inline-block; flex: none; width: 1.4rem; height: .8rem; border-radius: 2px; }
.ts-key-ghost { border: 2px dashed var(--cat1); }
.ts-key-excess { background: var(--cat2); opacity: .55; }
.ts-key-under { border-top: 3px dashed var(--cat3); height: 0; }
.ts-key-edge { border-top: 3px solid var(--cat2); height: 0; }
.ts-key-ref { width: .8rem; border: 2px solid var(--cat3); border-radius: 50%; }
.ts-key-hidden { border-top: 2px dashed var(--ink-soft); height: 0; }
.ts-lab:not(.is-normal) .ts-lg-hidden { display: none; }
.ts-keys { margin: 0; font-size: .9rem; color: var(--ink-soft); }

/* the tool in use: what it does and what it cannot */
.ts-toolinfo {
  display: flex; flex-direction: column; gap: .3rem;
  padding: .6rem .85rem;
  background: var(--surface-2);
  border-inline-start: .3rem solid var(--accent);
  border-radius: var(--radius-xs);
  font-size: .93rem;
}
.ts-toolinfo p { margin: 0; }
.ts-tool-name { font-family: var(--f-display); }
.ts-tag { display: inline-block; margin-left: .4rem; padding: .05rem .45rem; border: 1px solid var(--cat1); background: var(--cat1-soft); color: var(--cat-ink);
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; border-radius: var(--radius-xs); }
.ts-cannot { color: var(--ink-soft); }
.ts-cannot::before { content: "Cannot: "; font-family: var(--f-display); font-weight: 700; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }

/* the tool, draggable; the work under or over it never takes the pointer, so a
   tool hidden inside the work in the normal view can still be dragged */
.ts-view :is(.ts-machine, .ts-z0, .ts-bore, .ts-sec, .ts-ext, .ts-hidden, .ts-edge, .ts-thread, .ts-knurl, .ts-axis, .ts-excess, .ts-ghost, .ts-ghost-root, .ts-under) { pointer-events: none; }
.ts-tool { cursor: grab; touch-action: none; }
.is-dragging .ts-tool { cursor: grabbing; }
.ts-handle { fill: transparent; stroke: none; }
.is-busy .ts-tool { cursor: progress; }

/* spindle running: the chuck's arrow turns */
.ts-spin { transform-box: fill-box; transform-origin: center; }
.is-running .ts-spin { opacity: .9; animation: ts-spin .7s linear infinite; }
@keyframes ts-spin { to { transform: rotate(-360deg); } }
.is-running .ts-spin path { stroke: var(--accent); }
.is-knurling .ts-knurl-teeth { animation: ts-knurl-roll .45s linear infinite; }
.is-knurling [data-ts-knurl-lower] .ts-knurl-teeth { animation-direction: reverse; }
@keyframes ts-knurl-roll { to { transform: translateY(var(--ts-knurl-period)); } }
@media (prefers-reduced-motion: reduce) {
  .is-running .ts-spin, .is-knurling .ts-knurl-teeth { animation: none; }
}

/* chips: only where the model removed metal */
.ts-chip { fill: none; stroke: var(--ink-soft); stroke-width: 1.6; stroke-linecap: round; pointer-events: none;
  animation: ts-chip .65s ease-out forwards; }
@keyframes ts-chip {
  from { transform: translate(var(--x), var(--y)); opacity: 1; }
  to { transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy))) rotate(220deg); opacity: 0; }
}

/* ---- inspection --------------------------------------------------------------*/
.ts-inspect { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.ts-inspect-head { display: flex; flex-direction: column; gap: .2rem; }
.ts-verdict { margin: 0; }
.ts-inspect-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
@container (min-width: 46rem) {
  .ts-inspect-body:has(.ts-partfig:not([hidden])) { grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); align-items: start; }
}
.ts-partfig { margin: 0; }
.ts-partfig[hidden] { display: none; }
.ts-partfig svg { display: block; width: 100%; height: auto; max-height: 12rem; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.ts-partfig .aside { margin: .3rem 0 0; }
.ts-items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: .5rem; }
.ts-item {
  display: flex; flex-direction: column; gap: .2rem;
  padding: .55rem .75rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-inline-start: .3rem solid var(--rule);
  border-radius: var(--radius-xs);
  font-size: .93rem;
}
.ts-item-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem; }
.ts-item-label { font-family: var(--f-display); font-weight: 700; }
.ts-item-row { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); gap: .4rem; align-items: baseline; }
.ts-item-hint { margin: .15rem 0 0; color: var(--ink); font-size: .9rem; }
.ts-badge { font-family: var(--f-display); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .08rem .45rem; border: 1.5px solid var(--rule); border-radius: var(--radius-xs); color: var(--cat-ink); }
.ts-item.is-ok { border-inline-start-color: var(--cat1); }
.ts-item.is-ok .ts-badge { border-color: var(--cat1); background: var(--cat1-soft); }
.ts-item.is-over { border-inline-start-color: var(--cat2); }
.ts-item.is-over .ts-badge { border-color: var(--cat2); background: var(--cat2-soft); }
.ts-item.is-under { border-inline-start-color: var(--cat3); border-inline-start-style: dashed; }
.ts-item.is-under .ts-badge { border-color: var(--cat3); background: var(--cat3-soft); }
.ts-item.is-missing .ts-badge, .ts-item.is-pending .ts-badge { border-style: dashed; }
.ts-notes { margin: 0; padding-left: 1.1rem; font-size: .93rem; }
.ts-notes:empty { display: none; }

.ts-log summary { cursor: pointer; font-family: var(--f-display); font-weight: 700; font-size: .85rem; min-height: 2.5rem; display: flex; align-items: center; }
.ts-log ol { margin: .3rem 0 0; padding-left: 1.6rem; font-size: .88rem; }

/* ---- the static version (no JavaScript, and paper) ------------------------------*/
.ts-static { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ts-static-fig { margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.ts-static-fig svg { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.ts-static-fig figcaption { font-size: .93rem; color: var(--ink-soft); }
.ts-static-parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1rem; }

/* ---- presentation mode: bigger targets and numbers ------------------------------*/
@container ts-lab (min-width: 36rem) {
  .presenting .ts-lab button { min-height: 3rem; font-size: .9rem; }
  .presenting .ts-panel button, .presenting .ts-rack button { min-height: 2.75rem; }
  .presenting .ts-lab .ts-views button, .presenting .ts-lab .ts-zoom { min-height: 2.25rem; font-size: .78rem; }
  .presenting .ts-dro b { font-size: 1.45rem; }
  .presenting .ts-msg { font-size: 1.1rem; }
}

/* ---- print: the drawing, the work as it stands and the inspection; no controls ---*/
@media print {
  .ts-lab:not(.ts-measured) { display: none !important; }
  .ts-static-parts { grid-template-columns: minmax(0, 1fr); }
  .ts-static-parts .ts-static-fig { break-inside: avoid; }
  .ts-static-parts .ts-static-fig:has(.ts-drawing-pair) { break-inside: auto; }
  .ts-drawing-views { display: none !important; }
  .ts-static-parts svg { max-width: 36rem; }
  .ts-workbench { display: block; }
  .ts-view-box { max-width: none; }
  .ts-lab .ts-drawing[hidden] { display: flex !important; }
  .ts-drawing-scroll { overflow: visible; }
  .ts-drawing-scroll svg { min-width: 0; max-width: 100%; }
  .ts-head, .ts-panel, .ts-rack, .ts-tray, .ts-keys, .ts-toolinfo, .ts-log, .ts-fb-act, .ts-zoom, .ts-views { display: none !important; }
  .ts-feedback { display: block; }
  .ts-msg { display: block; min-height: 0; overflow: visible; }
  .ts-lab { border-color: #777; }
  .ts-drawing, .ts-machine, .ts-inspect, .ts-static-fig { break-inside: avoid; }
  .ts-view, .ts-drawing-svg, .ts-part-svg, .ts-dro, .ts-item, .ts-feedback { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .ts-live > .ts-static { display: flex; }
  .ts-chips { display: none; }
}
