:root{font:14px system-ui,sans-serif;color:#263b47;background:#f5f7f8}*{box-sizing:border-box}body{margin:0}button,input,select,textarea{font:inherit}button{background:white;border:1px solid #d8e1e5;border-radius:6px;padding:8px 11px;color:inherit;cursor:pointer}button:hover{background:#edf3f5}button.active,.primary{background:#263b47;color:white}button:disabled{opacity:.4;cursor:default}header{height:64px;display:flex;align-items:center;gap:8px;padding:12px 20px;background:white;border-bottom:1px solid #dce4e8}header strong{font-size:20px;margin-right:auto}small,.muted{font-size:12px;color:#71838b}header small{display:block;font-weight:400}#saveStatus{font-size:12px;margin-right:12px}main{display:grid;grid-template-columns:210px minmax(300px,1fr) 270px;height:calc(100dvh - 230px);min-height:420px}aside{padding:16px;background:white;overflow:auto;border-right:1px solid #dce4e8}h3{font-size:13px;margin:16px 0 10px}h3:first-child{margin-top:0}h3 button{padding:2px 8px;float:right}.row{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.workspace{display:flex;flex-direction:column;min-width:0}nav{display:flex;gap:5px;padding:8px;background:white;flex-wrap:wrap}nav span{flex:1}#viewport{flex:1;position:relative;overflow:hidden;background:#edf2f3;min-height:250px}svg{width:100%;height:100%;display:block;touch-action:none;user-select:none}.legend{position:absolute;bottom:12px;left:14px;pointer-events:none;line-height:1.7;font-size:12px}#status{padding:9px 14px;background:white;font-size:12px;min-height:36px}#parts button{display:block;width:100%;text-align:left;margin:5px 0}#parts small{display:block;margin-top:3px}#layers label{display:block;padding:7px 0}input[type=checkbox]{accent-color:#269878}label.field{display:block;font-size:12px;margin:10px 0}input:not([type=checkbox]):not([type=file]),select,textarea{display:block;width:100%;border:1px solid #ccd9df;border-radius:5px;padding:8px;margin-top:5px;background:white;color:#263b47}textarea{min-height:80px;resize:vertical}.triple{display:grid;grid-template-columns:repeat(3,1fr);gap:7px}.hint{font-size:12px;line-height:1.7;background:#eef5f3;padding:10px;border-radius:5px}footer{background:white;border-top:1px solid #dce4e8;padding:14px 20px;height:166px;overflow:auto}footer strong{margin-right:auto}#steps{display:flex;gap:8px;overflow:auto;margin-top:12px}#steps button{white-space:nowrap}#note{font-size:12px;margin:9px 0;color:#71838b}dialog{border:0;border-radius:12px;width:440px;max-width:95vw;padding:24px;box-shadow:0 20px 80px #13232d44}dialog::backdrop{background:#182a3655}h2{font-size:19px;margin-top:0}#error{color:#b73e3e}#inspector .row{margin-top:12px}@media(max-width:850px){main{grid-template-columns:150px minmax(260px,1fr)}#inspector{grid-column:1/-1;max-height:350px}main{height:auto}.workspace{height:65vh}header{flex-wrap:wrap;height:auto}header strong{width:100%}footer{height:auto;min-height:160px}}
.transform-bar{position:absolute;top:10px;left:10px;right:10px;width:max-content;max-width:calc(100% - 20px);padding:10px;border:1px solid #d8e1e5;border-radius:8px;background:#ffffffed;box-shadow:0 3px 12px #263b4714}.transform-bar[hidden]{display:none}.transform-buttons{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}.transform-buttons button:nth-child(3n+1){color:#c43f3f}.transform-buttons button:nth-child(3n+2){color:#177455}.transform-buttons button:nth-child(3n){color:#2869b6}.transform-buttons [data-move]{cursor:grab;touch-action:none}.transform-settings{display:flex;gap:8px;align-items:center;margin:8px 0}.transform-settings label{display:flex;align-items:center;gap:4px;font-size:12px}.transform-settings input#rotationStep{width:66px;margin:0;padding:4px}.transform-settings select{width:auto;margin:0;padding:4px;font-size:12px}
.transform-bar{position:static;flex-shrink:0;width:auto;max-width:none;margin:0 8px 8px;box-shadow:none}.transform-buttons{grid-template-columns:repeat(6,minmax(0,1fr))}.selection-order{display:inline-block;background:#e8872c;color:white;padding:1px 6px;border-radius:10px}.endpoint-card{background:#f1f5f6;border-radius:8px;padding:14px}.endpoint-card p{margin:5px 0 14px}dialog{max-height:90dvh;overflow:auto}#spacing{width:100%;margin-bottom:12px}#multiSelect{width:100%;position:sticky;top:0;z-index:1}@media(max-width:850px){main{grid-template-columns:130px minmax(0,1fr)}.transform-buttons{grid-template-columns:repeat(3,minmax(0,1fr))}.transform-settings{flex-wrap:wrap}.workspace{height:75vh}}@media(max-width:500px){main{display:flex;flex-direction:column}main>aside:first-child{max-height:220px}.workspace{height:65vh;min-height:430px}#inspector{max-height:none}#parts{display:flex;gap:6px;overflow-x:auto}#parts button{min-width:150px}header button{padding:7px}.transform-buttons{grid-template-columns:repeat(6,minmax(0,1fr))}.transform-buttons button{padding:6px 2px;font-size:11px}}
.workspace{overflow:hidden}#viewport{min-height:100px}.transform-bar{height:130px;min-height:130px;overflow:auto}.transform-bar button:disabled{opacity:.45}#parts details{border:1px solid #dce4e8;border-radius:7px;margin:8px 0;padding:8px}#parts summary{cursor:pointer;font-weight:600;overflow-wrap:anywhere}#parts summary small{display:inline;font-weight:400}#parts{display:block}main>aside:first-child{overflow-anchor:none}#inspector{overflow-anchor:none}@media(max-width:500px){main>aside:first-child{height:220px;min-height:220px}#parts{display:block}.workspace{height:650px;min-height:650px}.transform-bar{height:135px;min-height:135px}}
/* Consistent action colors, including dynamically created inspector controls. */
button:is(#applySize,#place,#applyRotation,#assignProcess,[data-action="apply"]){--action-color:#187348;--action-hover:#105735}
button:is(#editStep,[data-action="edit"]){--action-color:#245eae;--action-hover:#194781}
button:is(#deleteStep,#removePart,[data-action="delete"]){--action-color:#b33438;--action-hover:#8e2529}
button:is(#applySize,#place,#applyRotation,#assignProcess,#editStep,#deleteStep,#removePart,[data-action]){background:var(--action-color);border-color:var(--action-color);color:#fff;font-weight:600}
button:is(#applySize,#place,#applyRotation,#assignProcess,#editStep,#deleteStep,#removePart,[data-action]):hover:not(:disabled){background:var(--action-hover);border-color:var(--action-hover)}
button:is(#applySize,#place,#applyRotation,#assignProcess,#editStep,#deleteStep,#removePart,[data-action]):disabled{background:#e4e9ec;border-color:#d5dde1;color:#76848c;opacity:1}
button:focus-visible{outline:3px solid #e6a333;outline-offset:3px}
/* Mobile: keep the scene in place and open tools in a bottom panel. */
.mobile-nav{display:none}
@media(max-width:850px){
 body{height:100dvh;overflow:hidden;display:flex;flex-direction:column}
 header{height:58px;min-height:58px;padding:6px 10px;flex-wrap:nowrap;gap:4px}header strong{width:auto;font-size:16px}header small,#saveStatus{display:none}header button{padding:8px 6px;font-size:12px;min-height:40px}
 main{display:block;flex:1;min-height:0;height:auto;position:relative;overflow:hidden}
 .workspace{height:100%;min-height:0}
 #views{flex-wrap:nowrap;overflow-x:auto;flex-shrink:0;padding:6px;gap:4px}#views button{white-space:nowrap;min-height:44px;padding:7px 9px}#views span{display:none}
 .transform-bar{height:128px;min-height:128px;margin:0;padding:6px;border-radius:0;border-width:0 0 1px}.transform-buttons{grid-template-columns:repeat(6,minmax(0,1fr))}.transform-buttons button{padding:5px 1px;font-size:11px;min-height:44px}.transform-settings{margin:5px 0;flex-wrap:nowrap}.transform-bar>small{display:none}
 #viewport{min-height:60px}.legend{bottom:4px;font-size:11px}.legend small{display:none}#status{height:34px;min-height:34px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:8px}
 main>aside:first-child,#inspector,footer{display:none}
 body[data-panel=materials] main>aside:first-child,body[data-panel=inspector] #inspector,body[data-panel=process] footer{display:block;position:fixed;z-index:5;left:0;right:0;bottom:calc(56px + env(safe-area-inset-bottom));height:42dvh;min-height:0;max-height:42dvh;overflow:auto;padding:16px;border:1px solid #dce4e8;border-radius:16px 16px 0 0;box-shadow:0 -6px 20px #263b4720}
 .mobile-nav{display:grid;grid-template-columns:repeat(4,1fr);flex-shrink:0;height:calc(56px + env(safe-area-inset-bottom));padding:5px 6px calc(5px + env(safe-area-inset-bottom));gap:4px;z-index:6;border-top:1px solid #dce4e8}.mobile-nav button{font-size:12px;padding:6px 2px}.mobile-nav button[aria-pressed=true]{background:#263b47;color:white}
 aside button,footer button{min-height:44px}input:not([type=checkbox]):not([type=file]),select,textarea{font-size:16px;min-height:44px}dialog{padding:18px;max-height:85dvh}
}

@media(max-width:850px){#magnet{position:sticky;right:0;z-index:2;box-shadow:-5px 0 8px #ffffffaa;flex-shrink:0}#magnet:not(.active){background:white}}
/* Compact project menu and grouped tools. */
header{position:relative}header strong{white-space:nowrap}#menuToggle{min-width:44px;font-size:22px}#headerMenu{position:absolute;right:10px;top:56px;z-index:20;background:white;padding:8px;box-shadow:0 5px 24px #263b4733;border:1px solid #dce4e8;border-radius:10px;display:flex;gap:8px}#headerMenu[hidden]{display:none}#headerMenu button{font-size:24px;min-width:48px;min-height:48px}
.transform-bar{position:absolute;top:8px;left:8px;right:8px;z-index:3;height:auto;min-height:0;background:#fffffff2;margin:0;border:1px solid #d8e1e5;border-radius:10px;padding:8px;box-shadow:0 3px 12px #263b4714}.transform-bar[hidden]{display:none}.transform-buttons button{white-space:nowrap}.transform-settings{margin-bottom:0}
#inspector>button,#inspector .row>button,#spacingTools button{width:100%;min-height:44px;margin-bottom:8px}#spacingTools{padding:8px 0}#spacingTools .hint{margin-top:0}
footer>.row{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px}footer>.row>strong{grid-column:1/-1}#before,#after{grid-column:span 3}footer button{white-space:normal}#addStep,#editStep,#deleteStep{grid-column:span 2}#stepEarlier,#stepLater{grid-column:span 3}#steps{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));max-height:220px;overflow-y:auto;overflow-x:hidden}#steps button{text-align:left;white-space:normal;min-height:44px}#steps button[hidden]{display:none}#stepSearch{margin-top:10px}footer{height:260px}main{height:calc(100dvh - 324px)}
@media(max-width:850px){
 header{height:54px;min-height:54px}header strong{font-size:17px}
 main{height:auto}#views{display:grid;grid-template-columns:repeat(20,minmax(0,1fr));overflow:visible;gap:4px;padding:6px}#views [data-view]{grid-column:span 5}#views #zoomOut,#views #zoomIn,#views #fit,#views #grid{grid-column:span 3}#views #magnet{grid-column:span 8;position:static;box-shadow:none}#views button{padding:5px;min-width:0;font-size:14px;min-height:40px;white-space:nowrap}
 .transform-bar{height:auto;min-height:0;padding:7px}.transform-buttons button{font-size:14px;min-height:40px}.transform-settings{margin:5px 0 0}.transform-settings input#rotationStep{min-height:36px}.transform-settings select{min-height:36px}
 footer>.row{position:static}#steps{display:grid;grid-template-columns:1fr;max-height:none;overflow:visible}#steps button{width:100%;padding:12px}#stepSearch{position:sticky;top:0;z-index:1;background:white}body[data-panel=process] footer{height:55dvh;max-height:55dvh}
}
footer>.row>strong{order:0}#before,#after{order:1}#addStep,#editStep,#deleteStep{order:2}#stepEarlier,#stepLater{order:3}

/* Separate process actions by purpose, then separate search/navigation. */
footer>.row{display:flex;flex-direction:column;align-items:stretch;gap:0}
footer>.row>strong{margin:0 0 10px}
.process-action-group{display:flex;gap:6px}
.process-action-group+.process-action-group{border-top:1px solid #d5dfe4;margin-top:12px;padding-top:12px}
.process-action-group>button{flex:1;min-width:0;min-height:44px}
.process-search-divider{border:0;border-top:1px solid #d5dfe4;margin:14px 0 12px}
input#stepSearch{margin-top:0}
@media(max-width:850px){#views #dimensions{grid-column:span 10}#views #magnet{grid-column:span 8}#views #dimensions{grid-column:1/-1;min-height:34px}main>aside:first-child>.row{display:grid;grid-template-columns:1fr 1fr}}

.transform-settings{display:flex;align-items:center;gap:8px;margin-top:10px;padding-top:10px;border-top:1px solid #e0e7eb}
#copyPart{margin-left:auto;flex-shrink:0;white-space:nowrap;min-height:38px;padding:7px 10px;background:#eef5fa;border-color:#bfd4e2;color:#245878}
.rotation-preview-actions{display:flex;align-items:center;gap:8px;margin-top:10px;padding-top:10px;border-top:1px solid #e0e7eb;flex-wrap:wrap}.rotation-preview-actions[hidden]{display:none}#turnHint{font-size:12px;color:#24628d}
@media(max-width:850px){.transform-settings{display:grid;grid-template-columns:minmax(0,1fr) 96px 64px;gap:5px;margin-top:8px;padding-top:8px}.transform-settings label{min-width:0;gap:3px;white-space:nowrap}.transform-settings input#rotationStep{width:50px;min-width:0;font-size:14px}.transform-settings select{width:100%;font-size:12px;padding:4px}#copyPart{width:64px;padding:5px;margin:0;font-size:13px;min-height:38px}}
#workspaceDialog{width:520px}#workspaceDialog>div>button{margin:5px 4px 5px 0}#workspaceDialog>div>h2{margin:0 auto 0 0}#workspaceAccount{max-width:130px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#workspaceDialog p{overflow-wrap:anywhere}
#workspaceDialog{max-width:calc(100vw - 28px);max-height:calc(100dvh - 32px);box-sizing:border-box;overflow:auto;padding:20px;border:1px solid #d7e1e7;border-radius:14px}
#workspaceDialog .row{gap:8px;flex-wrap:wrap;border-bottom:1px solid #d7e1e7;padding-bottom:12px;margin-bottom:14px}
#workspaceDialog h3{border-top:1px solid #d7e1e7;padding-top:14px;margin-top:20px}
#workspaceDialog input,#workspaceDialog select,#workspaceDialog textarea{box-sizing:border-box;width:100%;min-width:0}
#workspaceDialog textarea{min-height:90px}#workspaceDialog button{min-height:42px}
.invite-qr:empty{display:none}.invite-qr{padding:14px 0}.invite-qr img{display:block;margin:0 auto 12px;width:256px}
@media(max-width:850px){#workspaceAccount{max-width:110px;order:1}#menuToggle{order:2}#workspaceDialog{padding:16px}#workspaceDialog>div:not(.row)>button{width:100%;margin:4px 0}}
