/* 3D scene of the machining-code viewer (nc/scene). Lives inside #nc-viewport.
   Overlay layout (viewer-client-api.md): top-left status chips (shell), top-right view cube (here),
   bottom-left legend (here), bottom-centre transport (player), bottom-right toasts (shell). */

.nc-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  /* UX3-30: a long press on the 3D view or anything of the scene over it (legend, cube, view tools,
     tags, chips) selects no text and shows no callout; nothing here scrolls, so no pan-y (UX3-23). */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* The scene reads this computed colour for the WebGL clear colour. */
  background: var(--nc-viewport-bg, #e8ecf1);
  /* Shell tokens (nc_viewer.css) first; the literals are fallbacks for a bare page. */
  --nc-scene-font: var(--nc-font, system-ui, -apple-system, "Segoe UI", sans-serif);
  --nc-scene-fg: var(--nc-text, #172033);
  --nc-scene-muted: var(--nc-text-dim, #566377);
  --nc-scene-accent: var(--nc-accent, #0d73d9);
  --nc-scene-accent-fg: var(--nc-accent-contrast, #ffffff);
  --nc-scene-face: var(--nc-panel, #ffffff);
  /* Overlay borders keep >= 3:1 against the viewport (#6e7a8c on #e8ecf1 = 3.6:1). */
  --nc-scene-face-border: #6e7a8c;
  --nc-scene-face-hover: var(--nc-accent-soft, rgba(13, 115, 217, 0.11));
  --nc-scene-face-hover-fg: var(--nc-accent-strong, #0a5fb4);
  --nc-scene-tool-bg: var(--nc-panel, #ffffff);
  --nc-scene-tool-border: #6e7a8c;
  --nc-scene-chip-bg: color-mix(in srgb, var(--nc-panel, #ffffff) 92%, transparent);
  --nc-scene-chip-border: var(--nc-border, #d8e0e9);
  --nc-scene-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  --nc-scene-label-halo: var(--nc-viewport-bg, #ffffff);
  --nc-scene-ink: #0f172a;
  /* B-12: the shell's axis tokens (both themes); the literals are fallbacks for a bare page. */
  --nc-scene-axis-x: var(--nc-axis-x, #c03a3a);
  --nc-scene-axis-y: var(--nc-axis-y, #147b3a);
  --nc-scene-axis-z: var(--nc-axis-z, #2f63c9);
  --nc-scene-dim: #475569;
  --nc-scene-ring: #0f172a;
}

:root[data-theme="dark"] .nc-scene {
  background: var(--nc-viewport-bg, #10151c);
  --nc-scene-fg: var(--nc-text, #e1e7ef);
  --nc-scene-muted: var(--nc-text-dim, #9aa6b8);
  --nc-scene-accent-fg: var(--nc-accent-contrast, #0b1220);
  --nc-scene-face: var(--nc-panel-2, #19202a);
  --nc-scene-face-border: #66758a; /* 3.7:1 on #10151c */
  --nc-scene-face-hover: var(--nc-accent-soft, rgba(61, 149, 242, 0.17));
  --nc-scene-face-hover-fg: var(--nc-accent-strong, #6aaff5);
  --nc-scene-tool-bg: var(--nc-panel, #141a22);
  --nc-scene-tool-border: #66758a;
  --nc-scene-chip-bg: color-mix(in srgb, var(--nc-panel, #141a22) 92%, transparent);
  --nc-scene-chip-border: var(--nc-border, #29323e);
  --nc-scene-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  --nc-scene-label-halo: var(--nc-viewport-bg, #000000);
  --nc-scene-ink: #ffffff;
  --nc-scene-axis-x: var(--nc-axis-x, #f07474);
  --nc-scene-axis-y: var(--nc-axis-y, #4cc38a);
  --nc-scene-axis-z: var(--nc-axis-z, #6ea8ff);
  --nc-scene-dim: #a7b3c4;
  --nc-scene-ring: #ffffff;
}

/* Fallbacks only (zero specificity): keep the app's empty message and the player's transport above the canvas. */
:where(#nc-viewport > .nc-empty),
:where(#nc-viewport > #nc-transport) {
  position: relative;
  z-index: 1;
}

.nc-scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

/* D-05: while a drag turns the view (a turning arrow, its middle on the cursor), pans it (grabbing) or
   zooms it (ns-resize) — over the hover's and measuring's own cursors (set inline). */
.nc-scene[data-drag="orbit"] .nc-scene-canvas {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cg stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13.2 9.4A5.4 5.4 0 1 1 11.8 4.2' fill='none' stroke='%23fff' stroke-width='3.6'/%3E%3Cpath d='M13.5 5.9 12.7 1.8 9.5 5.1Z' fill='%23fff' stroke='%23fff' stroke-width='2.4'/%3E%3Cpath d='M13.2 9.4A5.4 5.4 0 1 1 11.8 4.2' fill='none' stroke='%231b1f24' stroke-width='1.6'/%3E%3Cpath d='M13.5 5.9 12.7 1.8 9.5 5.1Z' fill='%231b1f24'/%3E%3C/g%3E%3C/svg%3E") 8 8, grabbing !important;
}

.nc-scene[data-drag="pan"] .nc-scene-canvas {
  cursor: grabbing !important;
}

.nc-scene[data-drag="zoom"] .nc-scene-canvas {
  cursor: ns-resize !important;
}

/* ------------------------------------------------------------------ labels projected from 3D */

.nc-scene-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.nc-scene-content-labels {
  position: absolute;
  inset: 0;
}

.nc-scene-axis-label {
  position: absolute;
  left: 0;
  top: 0;
  margin: -6px 0 0 -4px;
  font: var(--nc-fw-semibold, 600) var(--nc-fs-sm, 12px) / 1 var(--nc-scene-font);
  text-shadow: 0 0 3px var(--nc-scene-label-halo), 0 0 2px var(--nc-scene-label-halo);
  will-change: transform;
}

.nc-scene-axis-label.is-x { color: var(--nc-scene-axis-x); }
.nc-scene-axis-label.is-y { color: var(--nc-scene-axis-y); }
.nc-scene-axis-label.is-z { color: var(--nc-scene-axis-z); }
/* UX4-15: a panel's origin corner names its legs in ink (RGB would read as op colours). */
.nc-scene-axis-label.is-ink { color: var(--nc-scene-ink); }

/* Tags are placed by their top-left corner (the scene's label placer picks the side, C-03). */
.nc-scene-tag {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font: var(--nc-fw-semibold, 600) var(--nc-fs-sm, 12px) / 1.2 var(--nc-scene-font);
  font-variant-numeric: tabular-nums;
  color: var(--nc-scene-dim);
  text-shadow: 0 0 3px var(--nc-scene-label-halo), 0 0 2px var(--nc-scene-label-halo), 0 0 1px var(--nc-scene-label-halo);
  will-change: transform;
}

.nc-scene-tag[hidden] { display: none; }

/* R3-13: a chip behind the dimension text, so the dimension line does not run through it. */
.nc-scene-tag.is-dim {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--nc-scene-chip-bg);
  text-shadow: none;
}

/* During playback the labels right next to the marker step back (NP-07). */
.nc-scene-tag.is-faded {
  opacity: 0.3;
}

.nc-scene-tag.is-origin {
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--nc-scene-chip-border);
  background: var(--nc-scene-chip-bg);
  color: var(--nc-scene-fg);
  font-weight: 600;
  text-shadow: none;
}

.nc-scene-tag.is-banding {
  padding: 0 4px;
  border-radius: 3px;
  border-left: 3px solid var(--banding, currentColor);
  background: var(--nc-scene-chip-bg);
  color: var(--nc-scene-fg);
  text-shadow: none;
}

/* Orbit pivot: where a drag turns about. After the release it fades out (D-05, 300 ms = PIVOT_FADE_MS). */
.nc-scene-pivot {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nc-scene-accent);
  box-shadow: 0 0 0 2px var(--nc-scene-label-halo);
  transition: opacity 300ms ease-out;
}

.nc-scene-pivot.is-fading {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .nc-scene-pivot { transition: none; }
}

/* ------------------------------------------------------------------ playback position marks
   One colour + one outline for "where the machine is" (PLAYBACK_COLORS, set from JS per theme):
   ring = the colour that stands out on this theme, halo = the other one (RP-03/14). */

.nc-scene-marks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.nc-scene-cross {
  stroke: var(--nc-scene-mark-ring, #111827);
  stroke-width: 1;
  opacity: 0.25;
}

.nc-scene-mark-plan .is-halo,
.nc-scene-mark-foot .is-halo {
  fill: none;
  stroke: var(--nc-scene-mark-halo, #f5b700);
  stroke-width: 4;
}

.nc-scene-mark-plan .is-ring {
  fill: color-mix(in srgb, var(--nc-scene-play, #f5b700) 35%, transparent);
  stroke: var(--nc-scene-mark-ring, #111827);
  stroke-width: 2;
}

.nc-scene-mark-foot .is-ring {
  fill: none;
  stroke: var(--nc-scene-mark-ring, #111827);
  stroke-width: 2;
}

/* Drill progress just outside the ring (r + 3), in the ring colour (NP-03). */
.nc-scene-mark-plan .is-progress {
  fill: none;
  stroke: var(--nc-scene-mark-ring, #111827);
  stroke-width: 2;
}

/* The op is on the far face: the marker ring is dashed like a hidden line (RP-04). */
.nc-scene-mark-plan.is-back .is-ring,
.nc-scene-mark-plan.is-back .is-halo {
  stroke-dasharray: 4 3;
}

.nc-scene-mark-plan .is-arms-halo {
  fill: none;
  stroke: var(--nc-scene-mark-halo, #f5b700);
  stroke-width: 4;
  stroke-linecap: square;
}

.nc-scene-mark-plan .is-arms {
  fill: none;
  stroke: var(--nc-scene-mark-ring, #111827);
  stroke-width: 2;
}

.nc-scene-mark-foot .is-plumb {
  stroke: var(--nc-scene-mark-ring, #111827);
  stroke-width: 1;
}

/* Beacon: 28 → 44 px, 1.2 s, while playing and 1.5 s after a seek or an op change. */
.nc-scene-beacon {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

.nc-scene-beacon::before {
  content: "";
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  box-sizing: border-box;
  border: 2px solid var(--nc-scene-mark-ring, #111827);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--nc-scene-mark-halo, #f5b700);
  animation: nc-scene-beacon 1200ms ease-out infinite;
}

.nc-scene-beacon[hidden] { display: none; }

@keyframes nc-scene-beacon {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(1.5714); opacity: 0; }
}

/* With a spindle rotation that matters (data-spin cw | ccw, as seen on screen) the ring becomes a
   rotation sign (two arcs with open chevrons, the stroke style of the app's icons): same radius,
   2 px ink + 1 px halo, growing 28 → 44 px and fading in step with the ring, turning 45° that way. */
.nc-scene-rotor {
  display: none;
  position: absolute;
  left: -17px;
  top: -17px;
  width: 34px;
  height: 34px;
  overflow: visible;
}

.nc-scene-beacon[data-spin="cw"]::before,
.nc-scene-beacon[data-spin="ccw"]::before { display: none; }

.nc-scene-beacon[data-spin="cw"] .nc-scene-rotor,
.nc-scene-beacon[data-spin="ccw"] .nc-scene-rotor { display: block; }

/* The sign is drawn clockwise; mirrored it turns the other way. */
.nc-scene-beacon[data-spin="ccw"] .nc-scene-rotor { transform: scaleX(-1); }

.nc-scene-rotor-spin {
  animation: nc-scene-rotor 1200ms ease-out infinite;
}

.nc-scene-rotor path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.nc-scene-rotor .is-halo {
  stroke: var(--nc-scene-mark-halo, #f5b700);
  stroke-width: 4;
}

.nc-scene-rotor .is-ring {
  stroke: var(--nc-scene-mark-ring, #111827);
  stroke-width: 2;
}

@keyframes nc-scene-rotor {
  from { transform: scale(1) rotate(0deg); opacity: 0.9; }
  to { transform: scale(1.5714) rotate(45deg); opacity: 0; }
}

/* Start of the program before playback (RP-10, C-11): a hollow ring just outside the first hole
   (Ø + 6 px, --nc-start-r from JS) so the hole stays visible, a short leader to the ▶ badge, then the
   label with the first op. JS places the leader, badge and label for the side it picks. */
.nc-scene-start {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  --nc-start-r: 9px;
}

.nc-scene-start[hidden] { display: none; }

.nc-scene-start-ring {
  position: absolute;
  left: calc(-1 * var(--nc-start-r));
  top: calc(-1 * var(--nc-start-r));
  width: calc(2 * var(--nc-start-r));
  height: calc(2 * var(--nc-start-r));
  box-sizing: border-box;
  border: 3px solid var(--nc-scene-play, #f5b700);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--nc-scene-play-outline, #111827), inset 0 0 0 1px var(--nc-scene-play-outline, #111827);
}

.nc-scene-start-leader {
  position: absolute;
  background: var(--nc-scene-play-outline, #111827);
  box-shadow: 0 0 0 1px var(--nc-scene-play, #f5b700);
}

.nc-scene-start-play {
  position: absolute;
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  border: 2px solid var(--nc-scene-play-outline, #111827);
  border-radius: 50%;
  background: var(--nc-scene-play, #f5b700);
  box-shadow: 0 0 0 1px var(--nc-scene-label-halo);
}

.nc-scene-start-play::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 3px;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent var(--nc-scene-play-outline, #111827);
}

.nc-scene-start-label,
.nc-scene-face-badge,
.nc-scene-locator-label {
  position: absolute;
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--nc-scene-chip-border);
  background: var(--nc-scene-chip-bg);
  color: var(--nc-scene-fg);
  font: var(--nc-fw-semibold, 600) var(--nc-fs-sm, 12px) / 1.2 var(--nc-scene-font);
  box-shadow: var(--nc-scene-shadow);
}

.nc-scene-start-label {
  left: 40px;
  top: -10px;
  /* A little more see-through than other chips: the first holes may sit under it (M3-03). */
  background: color-mix(in srgb, var(--nc-panel, #ffffff) 85%, transparent);
}

/* Far-face op: which face, next to the marker (RP-04). */
.nc-scene-face-badge {
  left: 0;
  top: 0;
  translate: 14px calc(-100% - 12px);
  border-color: var(--nc-scene-mark-ring, #111827);
}

.nc-scene-face-badge[hidden] { display: none; }

/* Focused hole: an explicit depth/end marker and the remaining material, also in head-on views. */
.nc-scene-hole-depth {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  stroke: var(--nc-scene-fg);
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0 0 1px var(--nc-viewport-bg, #10151c));
}
.nc-scene-hole-depth .is-remaining { stroke-dasharray: 4 4; }
.nc-scene-hole-depth .is-leader { stroke-width: 1; }
.nc-scene-hole-depth-label {
  position: absolute;
  display: grid;
  gap: 4px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border: 1px solid var(--nc-scene-fg);
  border-radius: 6px;
  background: var(--nc-scene-face);
  color: var(--nc-scene-fg);
  font: var(--nc-fs-sm, 12px) / 1.4 var(--nc-scene-font);
  box-shadow: var(--nc-scene-shadow);
  pointer-events: none;
}
.nc-scene-hole-depth-label span { color: var(--nc-scene-muted); }
.nc-scene-hole-depth-label[hidden] { display: none; }

/* Tool off screen: an arrow chip on the edge, click = move to the tool (RP-07). */
.nc-scene-offscreen {
  position: absolute;
  left: -12px;
  top: -12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid var(--nc-scene-play-outline, #111827);
  border-radius: 50%;
  background: var(--nc-scene-play, #f5b700);
  color: var(--nc-scene-play-outline, #111827);
  box-shadow: var(--nc-scene-shadow);
  cursor: pointer;
  pointer-events: auto;
}

.nc-scene-offscreen svg {
  width: 16px;
  height: 16px;
  rotate: var(--angle, 0rad);
}

.nc-scene-offscreen[hidden] { display: none; }

.nc-scene-offscreen:focus-visible {
  outline: 2px solid var(--nc-scene-accent);
  outline-offset: 2px;
}

/* UX2-15, UX2-18: chips over the 3D view (bottom middle of the free area, the scene places the
   column) in the off-screen tool button's language: the playback yellow with its outline. */
.nc-scene-viewchips {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.nc-scene-viewchips[hidden] { display: none; }

.nc-scene-viewchip {
  display: inline-flex;
  align-items: center;
  min-height: calc(26px * var(--nc-ui-scale, 1));
  margin: 0;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1px solid var(--nc-scene-play-outline, #111827);
  border-radius: 999px;
  background: var(--nc-scene-play, #f5b700);
  color: var(--nc-scene-play-outline, #111827);
  box-shadow: var(--nc-scene-shadow);
  font: var(--nc-fw-semibold, 600) var(--nc-fs-sm, 12px) / 1 var(--nc-scene-font);
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
}

.nc-scene-viewchip[hidden] { display: none; }

.nc-scene-viewchip:hover {
  filter: brightness(1.06);
}

.nc-scene-viewchip:focus-visible {
  outline: 2px solid var(--nc-scene-accent);
  outline-offset: 2px;
}

/* Arrival of a link move: 28 → 56 px over 500 ms (RP-05). */
.nc-scene-ping {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

.nc-scene-ping[hidden] { display: none; }

.nc-scene-ping::before {
  content: "";
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  box-sizing: border-box;
  border: 2px solid var(--nc-scene-mark-ring, #111827);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--nc-scene-mark-halo, #f5b700);
  animation: nc-scene-ping 500ms ease-out forwards;
}

@keyframes nc-scene-ping {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(2); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .nc-scene-beacon::before {
    left: -16px;
    top: -16px;
    width: 32px;
    height: 32px;
    animation: none;
    opacity: 0.9;
  }

  /* A still sign shows the way the spindle turns (32 px like the still ring). */
  .nc-scene-rotor-spin {
    animation: none;
    transform: scale(1.1429);
    opacity: 0.9;
  }

  .nc-scene-ping::before { animation: none; opacity: 0; }
}

/* Pulsing ring around a selected op that is only a few pixels on screen (I-06). */
.nc-scene-locator {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

.nc-scene-locator::before {
  content: "";
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  box-sizing: border-box;
  border: 2px solid var(--nc-scene-accent);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--nc-scene-label-halo);
  animation: nc-scene-locate 600ms ease-out 2;
}

@keyframes nc-scene-locate {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(0.43); opacity: 0.6; }
}

/* Leader label of a small selected op ("#8 Ø6×12"), up and right of the ring (R3-07). */
.nc-scene-locator::after {
  content: "";
  position: absolute;
  left: 9px;
  top: -10px;
  width: 12px;
  height: 1px;
  background: var(--nc-scene-accent);
  rotate: -45deg;
  transform-origin: left center;
}

.nc-scene-locator:not(:has(.nc-scene-locator-label))::after { display: none; }

/* The hole-depth card names the same op: the ring stays, its leader label goes (C-03). */
.nc-scene-locator.is-bare::after,
.nc-scene-locator.is-bare .nc-scene-locator-label { display: none; }

.nc-scene-locator-label {
  left: 17px;
  top: -34px;
  border-color: var(--nc-scene-accent);
}

@media (prefers-reduced-motion: reduce) {
  .nc-scene-locator::before { animation: none; }
}

/* ------------------------------------------------------------------ view cube and view tools (top right) */

.nc-scene-nav {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  /* B-04: the tool rows grow with the text size setting (1 / 1.125 / 1.25). */
  width: calc(92px * var(--nc-ui-scale, 1));
  user-select: none;
  -webkit-user-select: none;
}

/* B-09: nothing to look at yet — no cube and no view tools on the empty screen. */
#nc-app[data-state="empty"] .nc-scene-nav,
.nc-scene[data-empty="true"] .nc-scene-nav {
  display: none;
}

.nc-scene-cube {
  position: relative;
  width: 88px;
  height: 88px;
}

.nc-scene-cube-axes {
  position: absolute;
  inset: 0;
  width: 88px;
  height: 88px;
  overflow: visible;
  pointer-events: none;
}

.nc-scene-cube-axes line {
  stroke-width: 2;
  stroke-linecap: round;
}

.nc-scene-cube-axes text {
  font: 700 var(--nc-fs-micro, 11px)/1 var(--nc-scene-font);
  text-anchor: middle;
  dominant-baseline: central;
  stroke: none;
}

.nc-scene-cube-axes .is-x { stroke: var(--nc-scene-axis-x); fill: var(--nc-scene-axis-x); }
.nc-scene-cube-axes .is-y { stroke: var(--nc-scene-axis-y); fill: var(--nc-scene-axis-y); }
.nc-scene-cube-axes .is-z { stroke: var(--nc-scene-axis-z); fill: var(--nc-scene-axis-z); }
.nc-scene-cube-axes text.is-x,
.nc-scene-cube-axes text.is-y,
.nc-scene-cube-axes text.is-z { stroke: none; }

.nc-scene-cube-body {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}

/* C-16: a face is a 3 × 3 grid of spots — the face (middle), its edges (strips), its corners
   (squares). 56 px = 2 × CUBE_HALF, the strips CUBE_CORNER (nc_viewer_scene.js). */
.nc-scene-cube-face {
  position: absolute;
  left: -28px;
  top: -28px;
  width: 56px;
  height: 56px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 10px 1fr 10px;
  grid-template-rows: 10px 1fr 10px;
  border: 1px solid var(--nc-scene-face-border);
  border-radius: 2px;
  background: var(--nc-scene-face);
  color: var(--nc-scene-fg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.nc-scene-cube-spot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: var(--nc-fw-semibold, 600) var(--nc-fs-sm, 12px) / 1 var(--nc-scene-font);
  letter-spacing: -0.02em;
  cursor: pointer;
}

/* The word may be wider than the middle cell at text size 1.25: it overflows over the strips but
   never takes their clicks. */
.nc-scene-cube-label {
  white-space: nowrap;
  pointer-events: none;
}

/* C-16: the face square to the view reads strongest; faces turned far away recede. */
.nc-scene-cube-face[data-emphasis="front"] .nc-scene-cube-label {
  font-weight: var(--nc-fw-bold, 700);
}

.nc-scene-cube-face[data-emphasis="tilted"] .nc-scene-cube-label {
  font-weight: var(--nc-fw-medium, 500);
  color: var(--nc-scene-muted);
}

/* Every piece of the spot under the pointer (an edge on two faces, a corner on three) or with the
   focus lights up together. */
.nc-scene-cube-spot.is-hot,
.nc-scene-cube-spot.is-focus {
  background: var(--nc-scene-face-hover);
  color: var(--nc-scene-face-hover-fg);
}

.nc-scene-cube-spot.is-edge.is-hot,
.nc-scene-cube-spot.is-corner.is-hot,
.nc-scene-cube-spot.is-edge.is-focus,
.nc-scene-cube-spot.is-corner.is-focus {
  background: color-mix(in srgb, var(--nc-scene-accent) 32%, transparent);
}

.nc-scene-cube-spot.is-hot .nc-scene-cube-label,
.nc-scene-cube-spot.is-focus .nc-scene-cube-label {
  color: var(--nc-scene-face-hover-fg);
}

.nc-scene-cube-spot:focus-visible {
  outline: 2px solid var(--nc-scene-accent);
  outline-offset: -2px;
  z-index: 1;
}

.nc-scene-cube.is-dragging,
.nc-scene-cube.is-dragging .nc-scene-cube-spot {
  cursor: grabbing;
}

/* UX2-19: the air round a corner or an edge that a press there picks. */
.nc-scene-cube.is-snap:not(.is-dragging) {
  cursor: pointer;
}

/* UX2-19: the cube takes presses 10 px round its box — an iso view's top and bottom corners sit
   45.7 px from the centre, past the 88 px box, and their 16 × 16 hit squares with them. Under the
   cube's body (painted later), so the drawing and its pieces stay as they are. */
.nc-scene-cube::before {
  content: "";
  position: absolute;
  inset: -10px;
  /* RS-03: the ring only (the box itself is the cube's own): a press there that is no corner or edge
     goes to the 3D view (nc_viewer_scene.js cubePressOwner), and the pointer shows the view's cursor. */
  clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 10px 10px, 10px calc(100% - 10px), calc(100% - 10px) calc(100% - 10px), calc(100% - 10px) 10px, 10px 10px);
}

/* RS-03: measuring, the ring off a corner or an edge measures like the 3D view next to it. */
.nc-scene[data-measure="true"] .nc-scene-cube:not(.is-snap)::before {
  cursor: crosshair;
}

.nc-scene-cube {
  touch-action: none;
}

/* View lock (top/bottom): only the top/bottom faces answer; the locked face is marked. */
.nc-scene-cube-spot:disabled {
  cursor: default;
}

.nc-scene-cube-spot:disabled .nc-scene-cube-label {
  color: var(--nc-scene-muted);
  font-weight: var(--nc-fw-semibold, 600);
}

.nc-scene-cube-face.is-locked {
  background: var(--nc-scene-accent);
  color: var(--nc-scene-accent-fg);
}

.nc-scene-cube-face.is-locked .nc-scene-cube-label,
.nc-scene-cube-face.is-locked .nc-scene-cube-spot.is-hot .nc-scene-cube-label {
  color: var(--nc-scene-accent-fg);
}

.nc-scene-cube-face.is-locked .nc-scene-cube-spot.is-hot,
.nc-scene-cube-face.is-locked .nc-scene-cube-spot.is-focus {
  background: color-mix(in srgb, var(--nc-scene-accent-fg) 18%, transparent);
}

.nc-scene-lock-badge {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid var(--nc-scene-accent);
  border-radius: 4px;
  background: var(--nc-scene-accent);
  color: var(--nc-scene-accent-fg);
  cursor: pointer;
  box-shadow: var(--nc-scene-shadow);
}

.nc-scene-lock-badge[hidden] { display: none; }

.nc-scene-lock-badge:focus-visible {
  outline: 2px solid var(--nc-scene-accent);
  outline-offset: 2px;
}

/* UX5-04 (K1-07): a triad leg the opaque faces would cover is drawn over them — dashed behind the cube,
   solid on its near side (nc_viewer_scene.js triadPlaces); REV-S-06: every letter is drawn here, ringed in
   the face colour. REV-S-07: the dashed leg is faint, so the face words it crosses (앞, 왼쪽 …) still read. */
.nc-scene-cube-axes.is-over line.is-behind {
  stroke-width: 1.5;
  stroke-dasharray: 3 2.5;
  opacity: 0.5;
}

.nc-scene-cube-axes.is-over text[class] {
  paint-order: stroke;
  stroke: var(--nc-scene-face);
  stroke-width: 3px;
  stroke-linejoin: round;
}

/* UX5-06 (K1-09): a face view's neighbour triangles and a plan's ↺ / ↻ in the 88 px box round the 56 px
   face square (16 px each side), while the pointer is over the cube (a finger: after a press on it). */
.nc-scene-cube-steps {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.nc-scene-cube-steps[hidden],
.nc-scene-cube-step[hidden] {
  display: none;
}

.nc-scene-cube-step {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--nc-scene-muted);
  cursor: pointer;
  pointer-events: auto;
}

.nc-scene-cube-step:hover {
  background: var(--nc-scene-face-hover);
  color: var(--nc-scene-face-hover-fg);
}

/* 16 px along the side each: a triangle in the middle of its side; ↺ ▲ ↻ share the top row between the
   triad's letters, which sit at x 16 and 72 there (the lock badge keeps the top left 18 px). REV-S-08: 13 px
   deep from the box's edge — the 3 px next to the face square stay the edge's (UX2-19: the edge view). */
.nc-scene-cube-step.is-up { left: 36px; top: 0; width: 16px; height: 13px; }
.nc-scene-cube-step.is-down { left: 36px; top: 75px; width: 16px; height: 13px; }
.nc-scene-cube-step.is-left { left: 0; top: 36px; width: 13px; height: 16px; }
.nc-scene-cube-step.is-right { left: 75px; top: 36px; width: 13px; height: 16px; }
.nc-scene-cube-step.is-ccw { left: 20px; top: 0; width: 16px; height: 13px; }
.nc-scene-cube-step.is-cw { left: 52px; top: 0; width: 16px; height: 13px; }
.nc-scene-cube-step svg { pointer-events: none; } /* ↺ ↻ (14 px) overhang their 13 px: no hit there */
.nc-scene-cube-step.is-down svg { transform: rotate(180deg); }
.nc-scene-cube-step.is-left svg { transform: rotate(-90deg); }
.nc-scene-cube-step.is-right svg { transform: rotate(90deg); }
.nc-scene-cube-step.is-ccw svg { transform: scaleX(-1); }

/* The touch cube (120 px, UX3-27) scales them with it: each hit grows 2 px outward to a 24 px finger. */
@media (pointer: coarse) {
  .nc-scene-cube-step::before {
    content: "";
    position: absolute;
    inset: 0;
  }

  .nc-scene-cube-step.is-up::before,
  .nc-scene-cube-step.is-ccw::before,
  .nc-scene-cube-step.is-cw::before { top: -2px; }
  .nc-scene-cube-step.is-down::before { bottom: -2px; }
  .nc-scene-cube-step.is-left::before { left: -2px; }
  .nc-scene-cube-step.is-right::before { right: -2px; }
}

.nc-scene-segment-button:disabled,
.nc-scene-segment-button:disabled:hover {
  cursor: default;
  color: var(--nc-scene-fg);
  opacity: 0.55;
}

.nc-scene-tools,
.nc-scene-tools-row {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
}

.nc-scene-tool {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: calc(28px * var(--nc-ui-scale, 1));
  height: calc(28px * var(--nc-ui-scale, 1));
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid var(--nc-scene-tool-border);
  border-radius: 6px;
  background: var(--nc-scene-tool-bg);
  color: var(--nc-scene-fg);
  cursor: pointer;
  box-shadow: var(--nc-scene-shadow);
}

.nc-scene-tool:hover {
  border-color: var(--nc-scene-face-hover-fg);
  color: var(--nc-scene-face-hover-fg);
}

/* UX2-12: four view tools share the row (↶ 이전 보기 first) — each 20 px wide at text size 1, its
   hit area 24 px (2 px into each gap); the icons a size smaller. */
.nc-scene-tools .nc-scene-tool {
  position: relative;
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

.nc-scene-tools .nc-scene-tool::before {
  content: "";
  position: absolute;
  inset: 0 -2px;
}

.nc-scene-tools .nc-scene-tool svg {
  width: 16px;
  height: 16px;
}

/* No view to go back to in this file yet: muted (a press still says so). */
.nc-scene-tool.is-back.is-empty {
  color: var(--nc-scene-muted);
}

.nc-scene-tool:focus-visible,
.nc-scene-segment-button:focus-visible,
.nc-scene-legend-item:focus-visible,
.nc-scene-legend-toggle:focus-visible {
  outline: 2px solid var(--nc-scene-accent);
  outline-offset: 2px;
}

.nc-scene-tool:disabled {
  opacity: 0.55;
  cursor: default;
}

.nc-scene-tool.is-workpiece[data-mode="xray"] svg { stroke-dasharray: 2 1.6; }
.nc-scene-tool.is-workpiece[data-mode="solid"] svg { fill: currentColor; fill-opacity: 0.35; }

/* Projection as a two-state segment: [원근 | 직교] (D-17). */
.nc-scene-segment {
  display: flex;
  flex: 1;
  min-width: calc(60px * var(--nc-ui-scale, 1));
  height: calc(28px * var(--nc-ui-scale, 1));
  box-sizing: border-box;
  border: 1px solid var(--nc-scene-tool-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--nc-scene-tool-bg);
  box-shadow: var(--nc-scene-shadow);
}

.nc-scene-segment-button {
  flex: 1;
  min-width: 24px;
  margin: 0;
  padding: 0 2px;
  white-space: nowrap; /* B-04: 「원근/직교」 never splits at text size 1.25 */
  border: 0;
  background: transparent;
  color: var(--nc-scene-muted);
  font: var(--nc-fw-medium, 500) var(--nc-fs-sm, 12px) / 1 var(--nc-scene-font);
  cursor: pointer;
}

.nc-scene-segment-button + .nc-scene-segment-button {
  border-left: 1px solid var(--nc-scene-tool-border);
}

.nc-scene-segment-button:hover {
  color: var(--nc-scene-face-hover-fg);
}

.nc-scene-segment-button[aria-pressed="true"] {
  background: var(--nc-scene-accent);
  color: var(--nc-scene-accent-fg);
  font-weight: 600;
}

/* UX3-35: the segment clips what lies outside it (overflow: hidden, its rounded corners): the ring
   goes inside the button, as on the cube's spots. */
.nc-scene-segment-button:focus-visible {
  outline-offset: -2px;
}

/* On the pressed (accent) half the ring is the accent's text colour. */
.nc-scene-segment-button[aria-pressed="true"]:focus-visible {
  outline-color: var(--nc-scene-accent-fg);
}

/* ------------------------------------------------------------------ legend (bottom left) */

.nc-scene-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  max-width: calc(100% - 20px - 110px);
  padding: 3px 8px 3px 3px;
  box-sizing: border-box;
  border: 1px solid var(--nc-scene-chip-border);
  border-radius: 8px;
  background: var(--nc-scene-chip-bg);
  box-shadow: var(--nc-scene-shadow);
  color: var(--nc-scene-fg);
  font: var(--nc-fw-medium, 500) var(--nc-fs-sm, 12px) / 1.2 var(--nc-scene-font);
}

.nc-scene-legend[hidden] { display: none; }

.nc-scene-legend[data-collapsed="true"] {
  padding-right: 3px;
}

.nc-scene-legend-toggle {
  flex: none;
  min-height: 24px;
  margin: 0;
  padding: 0 7px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--nc-scene-muted);
  font: var(--nc-fw-semibold, 600) var(--nc-fs-sm, 12px) / 1 var(--nc-scene-font);
  cursor: pointer;
}

.nc-scene-legend-toggle::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(1px) rotate(45deg);
}

.nc-scene-legend-toggle[aria-expanded="true"]::after {
  transform: translateY(-1px) rotate(-135deg);
}

.nc-scene-legend-toggle:hover {
  background: var(--nc-hover, rgba(23, 32, 51, 0.055));
  color: var(--nc-scene-fg);
}

.nc-scene-legend-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 10px;
  min-width: 0;
}

.nc-scene-legend-items[hidden] { display: none; }

.nc-scene-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}

button.nc-scene-legend-item {
  padding: 0 5px;
  margin: 0 -5px;
  border-radius: 5px;
  cursor: pointer;
}

button.nc-scene-legend-item:hover {
  background: var(--nc-hover, rgba(23, 32, 51, 0.055));
  color: var(--nc-scene-face-hover-fg);
}

/* B-17: a toggle is a chip — shown: tinted with a check; hidden: muted, dashed, "⊘" in its text. */
button.nc-scene-legend-item.is-toggle {
  min-height: 24px;
  margin: 0;
  padding: 0 6px 0 5px;
  border: 1px solid transparent;
}

button.nc-scene-legend-item.is-toggle[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--nc-scene-accent) 45%, transparent);
  background: var(--nc-scene-face-hover);
}

button.nc-scene-legend-item.is-toggle[aria-pressed="true"]::before {
  content: "";
  flex: none;
  width: 4px;
  height: 8px;
  margin: -2px 1px 0 1px;
  border: solid var(--nc-scene-face-hover-fg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

button.nc-scene-legend-item.is-toggle[aria-pressed="false"] {
  border-color: var(--nc-scene-chip-border);
  border-style: dashed;
  color: var(--nc-scene-muted);
}

button.nc-scene-legend-item.is-toggle:hover {
  border-color: var(--nc-scene-face-hover-fg);
  color: var(--nc-scene-face-hover-fg);
}

.nc-scene-legend-sample {
  position: relative;
  flex: none;
  display: inline-block;
  width: 18px;
  height: 10px;
  --sample: var(--nc-scene-fg);
}

.nc-scene-legend-item {
  position: relative;
}

.nc-scene-legend-sample.is-cut::before,
.nc-scene-legend-sample.is-rapid::before,
.nc-scene-legend-sample.is-link::before,
.nc-scene-legend-sample.is-selected::before,
.nc-scene-legend-sample.is-line::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
}

.nc-scene-legend-sample.is-cut::before {
  height: 2px;
  margin-top: -1px;
  background: var(--sample);
}

.nc-scene-legend-sample.is-rapid::before {
  height: 0;
  border-top: 1px dashed var(--sample);
  opacity: 0.85;
}

.nc-scene-legend-sample.is-link::before {
  height: 0;
  border-top: 1px dotted var(--sample);
  opacity: 0.6;
}

/* K3: the path before the last re-plot — grey dashes (the changed ops' heavier grey). */
.nc-scene-legend-sample.is-previous::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  margin-top: -1px;
  border-top: 2px dashed var(--sample);
}

/* Selection = the path's own colour, heavier, with an ink outline: shown neutral here. */
.nc-scene-legend-sample.is-selected::before {
  height: 3px;
  margin-top: -1.5px;
  background: var(--nc-scene-face);
  box-shadow: 0 0 0 1px var(--nc-scene-ink);
}

/* Selected code line/segment: amber with a dark outline, like the 3D highlight. */
.nc-scene-legend-sample.is-line::before {
  height: 4px;
  margin-top: -2px;
  background: var(--sample);
  box-shadow: 0 0 0 1px var(--sample-halo, #ffffff), 0 0 0 2px color-mix(in srgb, var(--nc-scene-fg) 35%, transparent);
}

/* Hole as drawn (R3-05/22): 2 px ring, 55 % fill, 1 px ink outline. */
.nc-scene-legend-sample.is-hole {
  width: 12px;
  height: 12px;
  box-sizing: border-box;
  border: 2px solid var(--sample);
  border-radius: 50%;
  background: color-mix(in srgb, var(--sample) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--nc-scene-ink) 50%, transparent);
}

/* Far face: dashed path + hollow solid hole with a halo (R3-06). */
.nc-scene-legend-sample.is-back::before {
  content: "";
  position: absolute;
  left: 0;
  width: 10px;
  top: 50%;
  border-top: 2px dashed var(--sample);
  margin-top: -1px;
  opacity: 0.6;
}

.nc-scene-legend-sample.is-back::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  box-sizing: border-box;
  border: 2px solid var(--sample);
  border-radius: 50%;
  opacity: 0.85;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--nc-scene-face) 60%, transparent);
}

.nc-scene-legend-sample.is-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--sample);
}

/* Edge processing as drawn: a thin dotted line in its own bronze. */
.nc-scene-legend-sample.is-edge::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: -1px;
  border-top: 2px dotted var(--sample);
}

/* A machining with no drawing (external file, NC code): the document mark. */
.nc-scene-legend-sample.is-ref {
  width: 12px;
  height: 14px;
  background: no-repeat center / 12px 14px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14' fill='none' stroke='%2364748b' stroke-width='1.2'%3E%3Cpath d='M1.5 1.5h6l3 3v8h-9z'/%3E%3Cpath d='M7.5 1.5v3h3'/%3E%3Cpath d='M3.5 7.5h5M3.5 10h5'/%3E%3C/svg%3E");
}

/* Breakout risk as drawn in the scene: a red burst (colours from nc/model BREAKOUT_COLORS). */
.nc-scene-legend-sample.is-breakout {
  width: 12px;
  height: 12px;
}

.nc-scene-legend-sample.is-breakout::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--nc-scene-breakout, #dc2626);
  clip-path: polygon(50% 0%, 63% 31%, 98% 29%, 73% 54%, 86% 89%, 50% 70%, 14% 89%, 27% 54%, 2% 29%, 37% 31%);
}

/* Breakout risk mark: a burst on the wall corner and an arrow the way the cutter pushes the corner
   out (--nc-push, set per frame from the projected `push`). A click selects the move. */
.nc-scene-breakout {
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  pointer-events: none; /* UX3-09: only its middle (.nc-scene-mark-hit) takes the pointer */
  will-change: transform;
  --nc-push: 0rad;
}

.nc-scene-breakout[hidden] { display: none; }

.nc-scene-breakout svg {
  width: 24px;
  height: 24px;
  overflow: visible;
}

.nc-scene-breakout .is-burst {
  fill: var(--nc-scene-breakout, #dc2626);
  stroke: var(--nc-scene-breakout-outline, #ffffff);
  stroke-width: 1.4;
  stroke-linejoin: round;
}

.nc-scene-breakout .is-push { transform: rotate(var(--nc-push)); }

.nc-scene-breakout .is-push path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nc-scene-breakout .is-push .is-halo {
  stroke: var(--nc-scene-breakout-outline, #ffffff);
  stroke-width: 4;
}

.nc-scene-breakout .is-push .is-line {
  stroke: var(--nc-scene-breakout, #dc2626);
  stroke-width: 2;
}

.nc-scene-breakout.no-push .is-push { display: none; }

.nc-scene-breakout:hover .is-burst,
.nc-scene-breakout.is-selected .is-burst {
  stroke: var(--nc-scene-ink);
  stroke-width: 2;
}

.nc-scene-breakout.is-selected svg { transform: scale(1.25); }

/* UX3-21: a far-face or dimmed burst steps back — its burst and arrow only: the count chip stays
   opaque (white on red 4.8:1, 11 px). */
.nc-scene-breakout.is-back svg,
.nc-scene-breakout.is-dim svg { opacity: 0.5; }

.nc-scene-breakout.is-selected.is-back svg { opacity: 1; }

/* Reference mark in the scene: a small neutral document chip at the op's position (not a warning). */
.nc-scene-ref {
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  border: 1px solid var(--nc-scene-chip-border);
  border-radius: 4px;
  background: var(--nc-scene-chip-bg);
  color: var(--nc-scene-fg);
  pointer-events: none; /* UX3-09: only its middle (.nc-scene-mark-hit) takes the pointer */
  will-change: transform;
}

.nc-scene-ref[hidden] { display: none; }

/* UX3-09: a breakout or reference mark takes the pointer on a 12 px disc at its middle only (the
   drawing stays): round it the hole or path under the mark is hovered and clicked. A press here is
   still a 3D press (UX2-03: a drag turns the view, the page never pans). */
.nc-scene-mark-hit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
}

.nc-scene-ref svg {
  width: 11px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
}

.nc-scene-ref:hover { border-color: var(--nc-scene-face-border); }

.nc-scene-ref.is-selected {
  border-color: var(--nc-scene-ink);
  box-shadow: 0 0 0 1px var(--nc-scene-ink);
}

.nc-scene-ref.is-back,
.nc-scene-ref.is-dim { opacity: 0.55; }

.nc-scene-ref.is-selected.is-back { opacity: 1; }

/* U3-03: each item's short words (`이동 12`, `터짐 10`, `반대면`), shown instead of its full text in the
   compact legend; the full text stays in the title and for screen readers. */
.nc-scene-legend-short {
  display: none;
  font-variant-numeric: tabular-nums;
}

/* More than two lines of words: the short words (one count each). */
.nc-scene-legend.is-compact .nc-scene-legend-items {
  gap: 0 8px;
}

.nc-scene-legend.is-compact .nc-scene-legend-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.nc-scene-legend.is-compact .nc-scene-legend-short {
  display: inline;
}

.nc-scene-legend.is-compact .nc-scene-legend-item {
  gap: 3px;
}

/* The selection key's fixed slot: both forms in one grid cell, the unused one invisible, so the
   legend keeps its size when something is selected (U2-04). */
.nc-scene-legend-slot {
  display: inline-grid;
  align-items: center;
}

.nc-scene-legend-form {
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.nc-scene-legend-form[data-off] {
  visibility: hidden;
}

/* K3-20: nothing selected — the selection key stays (last in the legend), faint. */
.nc-scene-legend-item.is-selection[data-idle] .nc-scene-legend-form {
  opacity: 0.5;
}

.nc-scene-legend.is-compact .nc-scene-legend-form {
  gap: 3px;
}

/* ------------------------------------------------------------------ hover tooltip */

.nc-scene-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: min(360px, calc(100% - 16px));
  padding: 6px 8px;
  box-sizing: border-box;
  border: 1px solid var(--nc-scene-chip-border);
  border-radius: 6px;
  background: var(--nc-panel, #ffffff);
  box-shadow: var(--nc-shadow, 0 10px 28px rgba(15, 23, 42, 0.14));
  color: var(--nc-scene-fg);
  font: var(--nc-fs-sm, 12px) / 1.35 var(--nc-scene-font);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.nc-scene-tooltip[hidden] { display: none; }

.nc-scene-tooltip-title {
  font-weight: 600;
}

.nc-scene-tooltip-row {
  color: var(--nc-scene-muted);
  font-family: var(--nc-mono, ui-monospace, monospace);
  font-size: var(--nc-fs-sm, 12px);
}

.nc-scene-tooltip-note {
  color: var(--nc-scene-muted);
  font-size: var(--nc-fs-sm, 12px);
}

/* ------------------------------------------------------------------ nothing to draw (D-23, W-14) */

.nc-scene-note {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: min(26em, calc(100% - 32px));
  padding: 12px 16px;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  border: 1px solid var(--nc-scene-chip-border);
  border-radius: 8px;
  background: var(--nc-scene-chip-bg);
  box-shadow: var(--nc-scene-shadow);
  color: var(--nc-scene-muted);
  font: var(--nc-fs-md, 13px) / 1.5 var(--nc-scene-font);
  text-align: center;
  pointer-events: none;
}

.nc-scene-note[hidden] { display: none; }

.nc-scene-note strong {
  color: var(--nc-scene-fg);
  font-size: var(--nc-fs-lg, 14px);
  font-weight: var(--nc-fw-semibold, 600);
}

/* Only rapids, or a panel without ops: keep the note small and out of the way (the panel stays
   visible), below the shell's top-left status chips. */
.nc-scene[data-nomotion="partial"] .nc-scene-note,
.nc-scene[data-nomotion="panel"] .nc-scene-note {
  top: 48px;
  transform: translateX(-50%);
  padding: 6px 12px;
  font-size: 12px;
}

.nc-scene-unsupported {
  position: absolute;
  inset: 0;
  margin: auto;
  height: fit-content;
  max-width: 28em;
  padding: 16px;
  text-align: center;
  color: var(--nc-scene-muted);
  font: 14px/1.5 var(--nc-scene-font);
}

/* UX3-46: the WebGL context is lost — nothing of the old picture (marks, op numbers, tags, tooltip,
   chips, cube, legend) floats over the blank canvas, and the canvas (white while lost) gives way to
   the viewport colour; only the note says what is going on. Hidden, not removed: the layout (and the
   fit) stays as it was for the restore. */
.nc-scene[data-context-lost] > :not(.nc-scene-gpu) {
  visibility: hidden;
}

.nc-scene-gpu {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: min(26em, calc(100% - 32px));
  padding: 14px 18px;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  border: 1px solid var(--nc-scene-chip-border);
  border-radius: 8px;
  background: var(--nc-scene-face);
  box-shadow: var(--nc-scene-shadow);
  color: var(--nc-scene-fg);
  font: var(--nc-fs-md, 13px) / 1.5 var(--nc-scene-font);
  text-align: center;
}

.nc-scene-gpu[hidden] { display: none; }

.nc-scene-gpu-reload {
  min-height: 32px;
  padding: 0 16px;
  border: 1px solid var(--nc-scene-accent);
  border-radius: 6px;
  background: var(--nc-scene-accent);
  color: var(--nc-scene-accent-fg);
  font: var(--nc-fw-semibold, 600) var(--nc-fs-md, 13px) / 1 var(--nc-scene-font);
  cursor: pointer;
}

.nc-scene-gpu-reload:focus-visible {
  outline: 2px solid var(--nc-scene-accent);
  outline-offset: 2px;
}

/* Narrow viewports: the legend may use the full width (the cube sits above it). */
@media (max-width: 899px) {
  .nc-scene-legend {
    max-width: calc(100% - 20px);
  }
}

/* ------------------------------------------------------------------ op numbers (F3, showOpNumbers) */

.nc-scene-opnums {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* UX2-26: a chip's text or place change lays out this layer only. */
  contain: layout style;
}

.nc-scene-opnums[hidden] { display: none; }

.nc-scene-opnum {
  position: absolute;
  left: 0;
  top: 0;
  padding: 1px 4px 1px 3px;
  border: 1px solid var(--nc-scene-chip-border);
  border-left: 3px solid var(--op, var(--nc-scene-fg));
  border-radius: 3px;
  background: var(--nc-scene-chip-bg);
  color: var(--nc-scene-fg);
  font: var(--nc-fw-semibold, 600) var(--nc-fs-micro, 11px) / 1.25 var(--nc-scene-font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  will-change: transform;
}

.nc-scene-opnum[hidden] { display: none; }

/* An op on the far face: its number steps back like its path. */
.nc-scene-opnum.is-back {
  opacity: 0.55;
  border-style: dashed;
  border-left-style: solid;
}

/* ------------------------------------------------------------------ measure (F4) */

.nc-scene[data-measure="true"] .nc-scene-canvas {
  cursor: crosshair;
}

.nc-scene-measure {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.nc-scene-measure .is-line-halo {
  stroke: var(--nc-scene-label-halo);
  stroke-width: 4;
  stroke-linecap: round;
}

.nc-scene-measure .is-line {
  stroke: var(--nc-scene-accent);
  stroke-width: 2;
  stroke-linecap: round;
}

.nc-scene-measure .is-point {
  fill: var(--nc-scene-accent);
  stroke: var(--nc-scene-label-halo);
  stroke-width: 2;
}

/* A label moved off the line: a thin leader to the middle of the line (C-10). */
.nc-scene-measure .is-leader {
  stroke: var(--nc-scene-accent);
  stroke-width: 1;
  stroke-dasharray: 3 2;
}

/* The snap target under the cursor (hole centre, panel corner). */
.nc-scene-measure .is-snap {
  fill: none;
  stroke: var(--nc-scene-accent);
  stroke-width: 2;
  stroke-dasharray: 3 2;
}

/* 2026-11-03 R1: an arc centre (⊕), an element's middle (▲), an element end (□) and a chord vertex
   inside an arc (small ◇) — solid, so the shape reads at a glance; the dashed ring stays for a hole
   centre, a reference mark and a corner. */
.nc-scene-measure .is-snap[data-kind="center"],
.nc-scene-measure .is-snap[data-kind="mid"],
.nc-scene-measure .is-snap[data-kind="end"],
.nc-scene-measure .is-snap[data-kind="vertex"] {
  stroke-dasharray: none;
  stroke-linejoin: round;
}

/* Placed by its top-left corner beside the line, inside the free 3D area (C-10). */
.nc-scene-measure-label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 3px 7px;
  border: 1px solid var(--nc-scene-accent);
  border-radius: 5px;
  background: var(--nc-panel, #ffffff);
  color: var(--nc-scene-fg);
  box-shadow: var(--nc-scene-shadow);
  font: var(--nc-fw-medium, 500) var(--nc-fs-sm, 12px) / 1.3 var(--nc-scene-font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.nc-scene-measure-label[hidden] { display: none; }

/* UX2-20: the line to the cursor before the second point — dashed, its label lighter. */
.nc-scene-measure.is-live .is-line {
  stroke-dasharray: 6 4;
}

.nc-scene-measure-label.is-live {
  border-style: dashed;
  opacity: 0.9;
}

.nc-scene-measure-label strong {
  font-size: var(--nc-fs-md, 13px);
  font-weight: var(--nc-fw-bold, 700);
}

/* 2026-11-04 R3: the second point locked to an axis (Alt+X / Y / Z) — the band, its points and the
   label's frame in that axis's colour (the result it gave keeps it); while aimed, a faint guide along
   the axis through the first point and a dotted leader from a snapped target to its place on the axis. */
.nc-scene-measure[data-lock="x"],
.nc-scene-measure-label[data-lock="x"] { --nc-scene-measure-lock: var(--nc-scene-axis-x); }
.nc-scene-measure[data-lock="y"],
.nc-scene-measure-label[data-lock="y"] { --nc-scene-measure-lock: var(--nc-scene-axis-y); }
.nc-scene-measure[data-lock="z"],
.nc-scene-measure-label[data-lock="z"] { --nc-scene-measure-lock: var(--nc-scene-axis-z); }

.nc-scene-measure[data-lock] .is-line {
  stroke: var(--nc-scene-measure-lock);
  stroke-width: 2.5;
}

.nc-scene-measure[data-lock] .is-point {
  fill: var(--nc-scene-measure-lock);
}

.nc-scene-measure .is-guide {
  stroke: var(--nc-scene-measure-lock, var(--nc-scene-accent));
  stroke-width: 1;
  stroke-dasharray: 2 5;
  opacity: 0.7;
}

.nc-scene-measure .is-lock-leader {
  stroke: var(--nc-scene-measure-lock, var(--nc-scene-accent));
  stroke-width: 1.5;
  stroke-dasharray: 1 3;
  stroke-linecap: round;
}

/* The frame 2 px thick without growing the label (its size is measured by its text). */
.nc-scene-measure-label[data-lock] {
  border-color: var(--nc-scene-measure-lock);
  box-shadow: inset 0 0 0 1px var(--nc-scene-measure-lock), var(--nc-scene-shadow);
}

/* Inferred stock (F9): a faint dashed chip at its far top corner. */
.nc-scene-tag.is-inferred {
  padding: 1px 5px;
  border: 1px dashed var(--nc-scene-chip-border);
  border-radius: 3px;
  background: var(--nc-scene-chip-bg);
  color: var(--nc-scene-muted);
  font-weight: var(--nc-fw-medium, 500);
  text-shadow: none;
}

/* F6: beside a tall part in a top/bottom view the legend stands as a column on the right, under the
   view cube (one strip for both), instead of a row under the part. */
.nc-scene-legend.is-column {
  left: auto;
  right: 10px;
  flex-direction: column;
  align-items: stretch;
  max-width: 180px;
  padding: 3px 8px 6px 3px;
}

.nc-scene-legend.is-column .nc-scene-legend-items {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 0;
  padding-left: 5px;
}

.nc-scene-legend.is-column .nc-scene-legend-item {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* C-24: one burst stands for several marks on the same corner (depth passes): their count beside it. */
.nc-scene-breakout-count {
  position: absolute;
  left: 15px;
  top: -3px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  box-sizing: border-box;
  border-radius: 7px;
  background: var(--nc-scene-breakout, #dc2626);
  box-shadow: 0 0 0 1px var(--nc-scene-breakout-outline, #ffffff);
  color: var(--nc-scene-breakout-outline, #ffffff);
  font: var(--nc-fw-bold, 700) var(--nc-fs-micro, 11px) / 14px var(--nc-scene-font);
  font-variant-numeric: tabular-nums;
  text-align: center;
  pointer-events: none;
}

/* C-23, U2-06: holes of several ops at one spot (top / bottom view) — how many ("×3"), at the ring's
   lower right. Not a chip: no border, no fill (a hole ring and the red breakout count are round
   chips), the dim ink on a halo. */
.nc-scene-counts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.nc-scene-count {
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% -50%;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  color: var(--nc-scene-dim);
  font: var(--nc-fw-bold, 700) calc(var(--nc-fs-micro, 11px) - 1px) / 1 var(--nc-scene-font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-shadow: 0 0 3px var(--nc-scene-label-halo), 0 0 2px var(--nc-scene-label-halo), 0 0 1px var(--nc-scene-label-halo);
  will-change: transform;
}

.nc-scene-count::before {
  content: "×";
  font-weight: var(--nc-fw-semibold, 600);
}

.nc-scene-count[hidden] { display: none; }

/* === SCENE-CAM (1회차) === */

/* B-12: the 3D axes and their letters use the shell's axis tokens (one set with the DRO letters). */
.nc-scene {
  --nc-scene-axis-x: var(--nc-axis-x, #c03a3a);
  --nc-scene-axis-y: var(--nc-axis-y, #147b3a);
  --nc-scene-axis-z: var(--nc-axis-z, #2f63c9);
}

:root[data-theme="dark"] .nc-scene {
  --nc-scene-axis-x: var(--nc-axis-x, #f07474);
  --nc-scene-axis-y: var(--nc-axis-y, #4cc38a);
  --nc-scene-axis-z: var(--nc-axis-z, #6ea8ff);
}

/* C-05 / D-22: "이 자리 op 3개 · 다시 누르면 다음 (…)" above the hovered target's own rows. */
.nc-scene-tooltip-stack {
  color: var(--nc-scene-accent);
  font-size: var(--nc-fs-sm, 12px);
  font-weight: var(--nc-fw-semibold, 600);
  padding-bottom: 2px;
  margin-bottom: 1px;
  border-bottom: 1px solid var(--nc-scene-chip-border);
}

/* === INT-UI: 1회차 통합 === */
/* An op Engine could not read but could place (F-08): the reference chip with a warning sign. */
.nc-scene-ref.is-unsupported {
  border-color: color-mix(in srgb, var(--nc-warning, #8f5400) 60%, var(--nc-scene-chip-border));
  color: var(--nc-warning, #8f5400);
}
.nc-scene-ref.is-unsupported svg {
  width: 12px;
  height: 12px;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nc-scene-legend-sample.is-unsupported {
  width: 12px;
  height: 12px;
  background: no-repeat center / 12px 12px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='%23b45309' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 1.5L13 12.5H1z'/%3E%3Cpath d='M7 5.5v3.4M7 10.4v.3'/%3E%3C/svg%3E");
}

/* === SCENE3-A: 양면 보기 (3회차 K1, C-22) === */
/* The dual plan: the pane heads (top-centre of each half, above the labels), the divider, and the
   other pane's copy layer (op numbers, breakout / reference marks, the tool's place) that the
   pointer passes through — moving onto that pane makes it the active one first. */
.nc-scene-pane-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--nc-scene-face-border);
  opacity: 0.55;
  pointer-events: none;
}
.nc-scene-pane-divider[hidden] { display: none; }
.nc-scene-pane-head {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 8px;
  border: 1px solid var(--nc-scene-chip-border);
  border-radius: 999px;
  background: var(--nc-scene-chip-bg);
  box-shadow: var(--nc-scene-shadow);
  color: var(--nc-scene-muted);
  font: var(--nc-fw-medium, 500) var(--nc-fs-sm, 12px) / 1.4 var(--nc-scene-font);
  white-space: nowrap;
  pointer-events: auto; /* its title explains the pane */
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
}
.nc-scene-pane-head[hidden] { display: none; }
/* The pane the cursor is in (its labels, picking, keys). */
.nc-scene-pane-head.is-active {
  border-color: color-mix(in srgb, var(--nc-scene-accent) 55%, var(--nc-scene-chip-border));
  color: var(--nc-scene-fg);
  font-weight: var(--nc-fw-semibold, 600);
}
.nc-scene-ghost,
.nc-scene-ghost * {
  pointer-events: none !important;
}
.nc-scene-ghost .nc-scene-breakout { cursor: default; }
/* Where the tool is, seen in the other pane: a hollow ring in the playback colours. */
.nc-scene-ghost-tool {
  position: absolute;
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  box-sizing: border-box;
  border: 2px solid var(--nc-scene-mark-ring, #0f172a);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--nc-scene-mark-halo, #facc15);
  will-change: transform;
}
.nc-scene-ghost-tool[hidden] { display: none; }
.nc-scene-ghost-tool.is-faint { opacity: 0.4; }
/* The active pane is not the face being machined: its playback marks step back. */
.nc-scene-labels.is-off-face .nc-scene-marks,
.nc-scene-labels.is-off-face .nc-scene-beacon {
  opacity: 0.4;
}

/* ------------------------------------------------------------------ touch screens (UX3-27) */
/* A finger needs room: the cube at 120 px (88 × 15/11 — its pieces, the ring round it and the corner /
   edge hits grow with it, nc_viewer_scene.js cubeLocal), the view tools two to a row at 40 px, the
   projection segment and the legend's buttons 40 px high. */
@media (pointer: coarse) {
  .nc-scene-nav {
    width: calc(124px * var(--nc-ui-scale, 1));
  }

  .nc-scene-cube {
    scale: calc(120 / 88);
    transform-origin: 50% 0;
    margin-bottom: 32px;
  }

  .nc-scene-tools {
    flex-wrap: wrap;
  }

  .nc-scene-tools .nc-scene-tool {
    flex: 1 1 calc(50% - 2px);
    height: calc(40px * var(--nc-ui-scale, 1));
  }

  .nc-scene-tools .nc-scene-tool::before {
    inset: 0;
  }

  .nc-scene-tools-row .nc-scene-tool {
    width: calc(40px * var(--nc-ui-scale, 1));
    height: calc(40px * var(--nc-ui-scale, 1));
  }

  .nc-scene-segment {
    height: calc(40px * var(--nc-ui-scale, 1));
  }

  /* Two halves inside the 80 px segment's 1 px frame: 39 px each (40 ran 「직교」 2 px under the
     frame's clip — REV-S-02's measure). */
  .nc-scene-segment-button {
    min-width: 39px;
  }

  .nc-scene-legend-toggle {
    min-width: 44px;
    min-height: 40px;
  }

  button.nc-scene-legend-item,
  button.nc-scene-legend-item.is-toggle {
    min-height: 40px;
  }

  .nc-scene-legend-items {
    row-gap: 4px;
  }

  /* REV-S-04: a fingertip lands 5–10 px off — a breakout or reference mark takes a finger on a 24 px
     disc (the whole ★); the hole or path under it is the second tap on the same spot (its stack). */
  .nc-scene-mark-hit {
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
  }
}

/* ------------------------------------------------------------------ forced colours (UX3-36) */
/* Windows high contrast: the 3D canvas keeps its own colours, so what is read against it keeps them
   too — the cube, the breakout and reference marks (★), the legend's colour keys. A pressed button
   the system would flatten shows it in the system's Highlight. */
@media (forced-colors: active) {
  .nc-scene-cube,
  .nc-scene-breakout,
  .nc-scene-ref,
  .nc-scene-legend-sample {
    forced-color-adjust: none;
  }

  /* A key in the ink colour (no op colour of its own) reads on the system's background. */
  .nc-scene-legend-sample {
    --sample: CanvasText;
  }

  /* Own system colours (not adjusted): an adjusted one gets a Canvas backplate behind its words. */
  .nc-scene-segment-button[aria-pressed="true"],
  button.nc-scene-legend-item.is-toggle[aria-pressed="true"] {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }

  button.nc-scene-legend-item.is-toggle[aria-pressed="true"]::before {
    border-color: HighlightText;
  }

  .nc-scene-segment-button[aria-pressed="true"]:focus-visible {
    outline-color: HighlightText;
  }

  /* UX5-10 (ux5 K1-14): an op number chip keeps its op colour strip — the key to the path it names
     (the canvas keeps its colours) — with its words and frame in the system's colours. */
  .nc-scene-opnum {
    forced-color-adjust: none;
    border-color: CanvasText;
    border-left-color: var(--op, CanvasText);
    background: Canvas;
    color: CanvasText;
  }
}
