.plc-pinwrap > .plc-pin { z-index: 8; }
.de-editor [data-de-pin] { z-index:10; }
.de-editor .de-figure-marker {
  width:var(--de-figure-size,7%); min-width:0; height:auto; min-height:0;
  padding:0; border:0; background:transparent; box-shadow:none;
}
.de-editor .de-figure-marker::before { content:""; position:absolute; left:50%; top:50%; width:max(100%,44px); height:max(100%,44px); transform:translate(-50%,-50%); }
.de-editor .de-figure-marker.df-operator { aspect-ratio:2/3; transform:translate(-50%,-100%); }
.de-editor .de-figure-marker.df-placard { aspect-ratio:1; transform:translate(-50%,-50%); }
.de-editor .de-figure-marker svg,.de-editor .de-figure-marker.df-operator .df-worker-glyph { display:block; width:100%; height:100%; }
.de-editor .de-figure-marker .df-label,.df-figure > .df-label { position:absolute; left:50%; top:100%; transform:translateX(-50%); width:max-content; max-width:180px; pointer-events:none; }
/* Machine diagram editor + shared figure rendering. Namespaced to avoid the app shell. */
.de-editor { --de-ink:#263b38; --de-muted:#687a75; --de-line:#d7e1db; --de-paper:#f7f8f2; --de-accent:#245d50; --de-warm:#f4eee1; color:var(--de-ink); font:14px/1.45 var(--isolate-font-family,system-ui,sans-serif); }
.de-editor * { box-sizing:border-box; }
.de-editor [hidden] { display:none!important; }
.de-head { display:flex; flex-wrap:wrap; align-items:flex-start; justify-content:space-between; gap:10px; margin:0 0 12px; }
.de-head h3 { font-size:16px; margin:0; color:var(--de-ink); }
.de-head p { color:var(--de-muted); margin:4px 0 0; font-size:12px; }
.de-toolbar { display:flex; flex-wrap:wrap; gap:7px; align-items:center; margin-bottom:12px; }
.de-toolbar button,.de-palette button,.de-field button { min-height:44px; border:1px solid var(--de-line); border-radius:7px; background:#fbfcf8; color:var(--de-ink); padding:8px 12px; font:inherit; cursor:pointer; }
.de-toolbar button:hover,.de-palette button:hover,.de-field button:hover { background:#eaf1e9; border-color:#b7c9bd; }
.de-toolbar button:focus-visible,.de-palette button:focus-visible,.de-field button:focus-visible,.de-marker:focus-visible { outline:3px solid #bb7a34; outline-offset:2px; }
.de-toolbar .de-undo { margin-left:auto; }
.de-warning { padding:10px 12px; margin:0 0 12px; border-left:3px solid #b47a38; background:#faf4e8; color:#59462d; font-size:12px; }
.de-layout { display:grid; grid-template-columns:minmax(0,1fr); gap:14px; align-items:start; }
.de-side { display:grid; gap:12px; min-width:0; }
.de-card { border:1px solid var(--de-line); border-radius:9px; padding:12px; background:var(--de-paper); }
.de-card h4 { margin:0 0 8px; color:var(--de-ink); font-size:12px; letter-spacing:.04em; text-transform:uppercase; }
.de-palette { display:grid; gap:7px; }
.de-palette button { display:flex; align-items:center; justify-content:flex-start; gap:9px; text-align:left; background:#fff; min-height:48px; }
.de-palette button[draggable="true"] { cursor:grab; }
.de-pin-swatch { display:inline-grid; place-items:center; width:31px; height:31px; flex:0 0 31px; border:2px solid #fff; border-radius:50%; box-shadow:0 0 0 1px #56645d; font-size:10px; font-weight:750; }
.de-note-swatch { background:#fff7e6; color:#39382e; border:2px solid #9a7040; border-radius:4px; }
.de-figure-swatch { display:inline-grid; place-items:center; width:32px; height:32px; border:1px solid #a9b9ad; border-radius:6px; background:#eef3ed; color:#355b4d; }
.de-figure-swatch svg { width:22px;height:22px; }
.de-missing { border:1px solid #d9b27f; background:#fff7e9; border-radius:6px; padding:8px; color:#654b2b; font-size:12px; }
.de-source-list { display:grid; gap:6px; max-height:220px; overflow:auto; }
.de-source-row { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:8px; font-size:12px; }
.de-source-row button { min-height:44px; display:flex; align-items:center; gap:8px; width:100%; text-align:left; border:1px solid var(--de-line); background:#fff; border-radius:6px; padding:5px 8px; cursor:grab; color:var(--de-ink); }
.de-source-row button:focus-visible { outline:3px solid #bb7a34; outline-offset:2px; }
.de-source-row button span:last-child { min-width:0; overflow:hidden; text-overflow:ellipsis; }
.de-source-code { display:inline-grid; place-items:center; min-width:34px; min-height:30px; padding:0 5px; border-radius:4px; font-weight:750; font-size:11px; }
.de-source-row .de-source-add { width:44px; justify-self:end; padding:0; justify-content:center; font-size:20px; cursor:pointer; }
.de-blank { color:var(--de-muted); font-size:12px; }
.de-selected { display:grid; gap:9px; }
.de-selected .de-empty { color:var(--de-muted); font-size:12px; }
.de-field { min-width:0; display:grid; grid-template-columns:minmax(0,1fr) minmax(75px,110px); align-items:center; gap:8px; font-size:12px; }
.de-field input,.de-field select { width:100%; min-width:0; min-height:44px; border:1px solid var(--de-line); border-radius:6px; padding:8px; color:var(--de-ink); background:#fff; font:inherit; }
.de-field input:focus,.de-field select:focus { outline:2px solid #8aa99a; }
.de-field-wide { grid-template-columns:1fr; }
.de-field-wide input { min-width:0; }
.de-field-actions { display:flex; gap:6px; }
.de-field-actions button { flex:1; }
.de-delete { background:#fff1eb!important; color:#833d2d!important; }
.de-stage-note { margin:7px 0 0; font-size:11px; color:var(--de-muted); }

/* The existing annotation wrapper is retained: image dimensions follow its natural ratio. */
.de-editor #annotation-photo { position:relative; display:block; width:100%; max-width:100%; overflow:hidden; line-height:0; background:#e7e8df; touch-action:none; }
.de-editor #annotation-photo > img { display:block; width:100%; height:auto; max-width:100%; max-height:none; object-fit:contain; }
.de-editor #annotation-pins { position:absolute; inset:0; overflow:visible; pointer-events:none; }
.de-marker { position:absolute; left:var(--de-x); top:var(--de-y); transform:translate(-50%,-50%); pointer-events:auto; touch-action:none; user-select:none; cursor:grab; }
.de-marker:active { cursor:grabbing; }
.de-marker.de-selected-marker { z-index:4; }
.de-loto-marker { display:grid; place-items:center; width:44px; height:44px; min-width:44px; padding:0 3px; border:2px solid #fff; border-radius:50%; box-shadow:0 1px 4px #15221f80; font-size:10px; line-height:1; font-weight:800; }
.de-note-marker { display:grid; place-items:center; width:44px; height:44px; min-width:44px; border:2px solid #fff; border-radius:5px; background:#fff2d6; color:#3d372d; box-shadow:0 1px 4px #15221f80; font-size:12px; font-weight:800; }
.de-figure-marker { width:var(--de-figure-size,44px); min-width:44px; height:44px; display:grid; place-items:center; border:2px solid #fff; border-radius:10px; background:#f0f3eb; box-shadow:0 1px 5px #15221f75; }
.de-figure-marker svg { width:30px; height:30px; }
.de-figure-marker.df-operator { overflow:visible; }
.de-figure-marker.df-operator .df-worker-glyph { width:26px; height:39px; }
.de-figure-marker .df-worker-body { fill:#d0a64e; stroke:#344941; stroke-width:1.8; }
.de-figure-marker .df-worker-head { fill:#e9c59a; stroke:#344941; stroke-width:1.8; }
.de-figure-marker .df-worker-face { fill:none; stroke:#344941; stroke-width:2; stroke-linecap:round; }
.de-figure-marker .df-worker-limb { fill:none; stroke:#344941; stroke-width:4; stroke-linecap:round; }
.de-figure-marker.df-placard { border-radius:5px; background:#e8f0ec; color:#355b4d; }
.de-figure-marker.df-placard svg { fill:#fff; stroke:currentColor; stroke-width:2.4; stroke-linecap:round; stroke-linejoin:round; transform:rotate(var(--df-rotation,0deg)); }
.de-editor .de-figure-layer { position:absolute; inset:0; pointer-events:none; }
.de-editor .de-figure { position:absolute; left:var(--df-x,50%); top:var(--df-y,50%); }
.de-editor .de-figure .df-label { position:absolute; left:50%; top:100%; transform:translateX(-50%); white-space:nowrap; line-height:1.2; }
.de-editor .de-legend { display:none; }
.de-marker.de-selected-marker::after { content:""; position:absolute; inset:-5px; border:2px dashed #253f38; border-radius:50%; pointer-events:none; }

/* Pin buttons keep a generous 44px hit target while their visible glyph scales independently. */
.de-editor .de-pin-marker {
  width:44px; min-width:44px; height:44px; min-height:44px; padding:0;
  border:0; border-radius:0; background:transparent; box-shadow:none;
  display:grid; place-items:center; overflow:visible;
}
.de-editor .de-pin-marker::before {
  content:""; position:absolute; left:50%; top:50%;
  width:44px; height:44px; transform:translate(-50%,-50%);
}
.de-editor .de-pin-marker .de-pin-glyph {
  position:relative; z-index:1; display:grid; place-items:center;
  width:var(--de-pin-size,44px); height:var(--de-pin-size,44px);
  min-width:22px; min-height:22px; padding:2px;
  border:2px solid #fff; border-radius:50%;
  background:var(--de-pin-color,#fff1d4); color:var(--de-pin-ink,#3d372d);
  box-shadow:0 1px 4px #15221f80;
  font-size:var(--de-pin-font-size,12px); line-height:1;
  font-weight:800; text-align:center; overflow:hidden; overflow-wrap:anywhere;
}
.de-editor .de-pin-marker.de-note-marker .de-pin-glyph {
  border-radius:5px; font-size:var(--de-note-font-size,13px);
}
.de-editor .de-pin-marker .de-pin-label {
  position:absolute; z-index:2; left:50%;
  top:calc(50% + max(22px, var(--de-pin-label-offset,22px)));
  transform:translateX(-50%); width:max-content; max-width:min(180px, 56vw);
  padding:2px 5px; border:1px solid #b9c8be; border-radius:3px;
  background:#fffdf7; color:#283b35;
  box-shadow:0 1px 3px #15221f30;
  font:600 var(--de-pin-label-font-size,10px)/1.2 var(--isolate-font-family,system-ui,sans-serif);
  text-align:center; overflow-wrap:anywhere; pointer-events:none;
}

/* Shared printable/read-only figure rendering; anchor coordinates are the operator's feet. */
.df-figure-layer { position:absolute; inset:0; z-index:3; pointer-events:none; overflow:visible; }
.df-figure { position:absolute; left:var(--df-x); top:var(--df-y); }
.df-operator { width:var(--df-size); min-width:0; aspect-ratio:2/3; transform:translate(-50%,-100%); display:block; }
.df-operator-art { position:relative; display:block; width:100%; transform:rotate(var(--df-rotation)); transform-origin:50% 100%; }
.df-worker-glyph { display:block; width:100%; height:auto; overflow:visible; }
.df-worker-body { fill:#d1a74f; stroke:#263d37; stroke-width:2.2; }
.df-worker-head { fill:#eac69b; stroke:#263d37; stroke-width:2.2; }
.df-worker-face { fill:none; stroke:#263d37; stroke-width:2.5; stroke-linecap:round; }
.df-worker-limb { fill:none; stroke:#263d37; stroke-width:4.8; stroke-linecap:round; stroke-linejoin:round; }
.df-facing { position:absolute; top:8%; right:-20%; width:26%; height:1.5px; background:#263d37; transform:rotate(-28deg); transform-origin:left center; }
.df-facing::after { content:""; position:absolute; right:-1px; top:-3px; width:6px; height:6px; border-top:1.5px solid #263d37; border-right:1.5px solid #263d37; transform:rotate(45deg); }
.df-placard { width:var(--df-size); min-width:0; aspect-ratio:1; transform:translate(-50%,-50%); display:block; color:#355b4d; }
.df-placard-glyph { display:block; width:100%; height:auto; fill:#f5f7f2; stroke:currentColor; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; transform:rotate(var(--df-rotation,0deg)); }
.df-label { max-width:180px; margin-top:2px; padding:2px 5px; border:1px solid #b9c8be; border-radius:3px; background:#fffdf7; color:#283b35; font:600 10px/1.2 var(--isolate-font-family,system-ui,sans-serif); text-align:center; overflow-wrap:anywhere; }
.df-legend { position:static; display:flex; flex-wrap:wrap; gap:4px 10px; padding:5px 7px; border:1px solid #c9d5cc; border-radius:4px; background:#fffdf7; color:#344b43; font:600 9px/1.2 var(--isolate-font-family,system-ui,sans-serif); }
.df-legend > span { display:flex; align-items:center; gap:5px; }
.df-legend i { display:inline-block; width:10px; height:10px; }
.df-legend-operator { border-radius:50%; background:#d1a74f; border:1px solid #263d37; }
.df-legend-placard { background:#f5f7f2; border:1px solid #355b4d; }
.df-legend small { font-size:8px; font-weight:500; color:#596a63; }
.plc-page .df-label { font-size:1cqw; max-width:18cqw; padding:.18cqw .45cqw; margin-top:.18cqw; border-width:.08cqw; }
.plc-page .df-legend { font-size:.85cqw; gap:.3cqw .8cqw; padding:.4cqw .6cqw; border-width:.08cqw; }
.plc-page .df-legend small { font-size:.85cqw; }
.plc-page .df-legend i { width:1cqw; height:1cqw; }
.de-editor .df-figure-layer .df-legend { display:none; }
.de-editor .de-figure-marker.df-operator { width:var(--de-figure-size,44px); min-width:44px; transform:translate(-50%,-100%); }
.de-editor .de-figure-marker.df-placard { width:var(--de-figure-size,44px); min-width:44px; transform:translate(-50%,-50%); display:grid; }
.de-editor .de-figure-marker.df-operator .df-worker-glyph { width:26px; height:39px; }
.de-editor .de-figure-marker.df-operator .df-operator-art { position:relative; display:block; width:26px; height:39px; transform:rotate(var(--df-rotation)); transform-origin:50% 100%; }
.de-editor .de-figure-marker .df-facing { right:-4px; top:5px; width:12px; }

@media (min-width:760px) {
  .de-layout { grid-template-columns:minmax(0,1fr) 250px; }
  .de-side { position:sticky; top:10px; }
}
@media (min-width:1120px) {
  .de-layout { grid-template-columns:minmax(0,1fr) 290px; gap:18px; }
}
@media (max-width:759px) {
  .de-toolbar .de-undo { margin-left:0; }
  .de-palette { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .de-source-list { max-height:180px; }
}
@media print {
  .df-figure-layer,.df-figure,.df-legend { display:block!important; visibility:visible!important; }
  .df-figure-layer { overflow:visible!important; }
  .df-label,.df-legend { print-color-adjust:exact; -webkit-print-color-adjust:exact; }
  .de-editor { display:none!important; }
}

/* Point list and machine diagram are two views of the same saved source IDs. */
.de-map-help { margin: 0 0 10px; font-size: 12px; line-height: 1.55; color: #4d6257; }
.de-map-state { border-radius: 7px; background: #eef5f0; color: #174835; padding: 9px 10px; margin: 0 0 10px; font-size: 12px; font-weight: 600; line-height: 1.45; }
.de-source-list { max-height: 350px; }
.de-source-row { grid-template-columns: minmax(0,1fr) auto auto auto; gap: 6px; }
.de-source-row.is-active { border-radius: 8px; background: #eff5ef; box-shadow: inset 0 0 0 2px #427c61; }
.de-source-row .de-source-name { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.35; }
.de-source-row .de-source-name small { color: #536a5b; font-size: 10px; font-weight: 550; overflow-wrap: anywhere; }
.de-source-row .de-source-locate, .de-source-row .de-source-place { width: auto; min-width: 62px; white-space: normal; text-align: center; cursor: pointer; justify-content: center; padding: 7px 9px; font-size: 11px; font-weight: 650; }
.de-source-row .de-source-locate:disabled { opacity: .5; cursor: not-allowed; }
.de-source-row .de-source-place { background: #eaf5ee; color: #175138; border-color: #8cbea4; }
.de-source-row .de-source-add { flex-shrink: 0; }
@media (max-width: 780px) {
  .de-source-row { grid-template-columns: minmax(0,1fr) repeat(2, auto); }
  .de-source-row > button:first-child { grid-column: 1 / -1; }
  .de-source-list { max-height: none; }
  .de-source-row .de-source-place { min-height: 44px; }
}
